|
// retoor <retoor@molodetz.nl>
|
|
|
|
#ifndef R_TOOL_H
|
|
#define R_TOOL_H
|
|
|
|
#include "r_error.h"
|
|
#include <json-c/json.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
typedef struct tool_t tool_t;
|
|
|
|
typedef struct {
|
|
struct json_object *(*get_description)(void);
|
|
char *(*execute)(tool_t *self, struct json_object *args);
|
|
void (*print_action)(const char *name, struct json_object *args);
|
|
} tool_vtable_t;
|
|
|
|
struct tool_t {
|
|
const tool_vtable_t *vtable;
|
|
const char *name;
|
|
};
|
|
|
|
typedef struct {
|
|
tool_t **tools;
|
|
size_t count;
|
|
size_t capacity;
|
|
} tool_registry_t;
|
|
|
|
tool_registry_t *tool_registry_create(void);
|
|
void tool_registry_destroy(tool_registry_t *registry);
|
|
r_status_t tool_registry_register(tool_registry_t *registry, tool_t *tool);
|
|
tool_t *tool_registry_find(tool_registry_t *registry, const char *name);
|
|
struct json_object *tool_registry_get_descriptions(tool_registry_t *registry);
|
|
struct json_object *tool_registry_execute(tool_registry_t *registry,
|
|
struct json_object *tool_calls,
|
|
bool verbose);
|
|
|
|
tool_registry_t *tools_get_registry(void);
|
|
void tools_registry_shutdown(void);
|
|
|
|
typedef enum {
|
|
TOOL_TYPE_ALL,
|
|
TOOL_TYPE_RESEARCHER,
|
|
TOOL_TYPE_DEVELOPER,
|
|
TOOL_TYPE_SECURITY
|
|
} tool_registry_type_t;
|
|
|
|
tool_registry_t *tool_registry_get_specialized(tool_registry_type_t type);
|
|
|
|
void snapshot_live_record(const char *path, const char *content);
|
|
|
|
#endif
|