yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
tool_registry.h
Go to the documentation of this file.
1#ifndef YAZE_CLI_SERVICE_AGENT_TOOL_REGISTRY_H_
2#define YAZE_CLI_SERVICE_AGENT_TOOL_REGISTRY_H_
3
4#include <functional>
5#include <map>
6#include <memory>
7#include <mutex>
8#include <optional>
9#include <string>
10#include <vector>
11
12#include "absl/status/status.h"
13#include "absl/status/statusor.h"
14#include "cli/service/ai/common.h" // For ToolCall
16
17namespace yaze {
18class Rom;
19namespace cli {
20namespace agent {
21
22enum class ToolAccess {
25};
26
31 std::string name;
32 std::string category;
33 std::string description;
34 std::string usage;
35 std::vector<std::string> examples;
36 bool requires_rom = false;
37 bool requires_project = false; // New: distinguish project vs ROM dependency
39 std::vector<std::string> required_args;
40 std::vector<std::string> flag_args;
41};
42
52 public:
53 // Factory function to create a handler instance
55 std::function<std::unique_ptr<resources::CommandHandler>()>;
56
57 static ToolRegistry& Get();
58
59 // Registration
60 void RegisterTool(const ToolDefinition& def, HandlerFactory factory);
61
62 // Discovery
63 std::vector<ToolDefinition> GetAllTools() const;
64 std::optional<ToolDefinition> GetToolDefinition(
65 const std::string& name) const;
66 std::vector<ToolDefinition> GetToolsByCategory(
67 const std::string& category) const;
68
69 // Execution
70 absl::StatusOr<std::unique_ptr<resources::CommandHandler>> CreateHandler(
71 const std::string& tool_name) const;
72
73 private:
74 ToolRegistry() = default;
75 void EnsureInitialized();
76
81
82 std::once_flag init_once_;
83 std::map<std::string, ToolEntry> tools_;
84};
85
86} // namespace agent
87} // namespace cli
88} // namespace yaze
89
90#endif // YAZE_CLI_SERVICE_AGENT_TOOL_REGISTRY_H_
Centralized registry for all agent tools.
void RegisterTool(const ToolDefinition &def, HandlerFactory factory)
std::function< std::unique_ptr< resources::CommandHandler >()> HandlerFactory
std::optional< ToolDefinition > GetToolDefinition(const std::string &name) const
std::map< std::string, ToolEntry > tools_
static ToolRegistry & Get()
std::vector< ToolDefinition > GetToolsByCategory(const std::string &category) const
std::vector< ToolDefinition > GetAllTools() const
absl::StatusOr< std::unique_ptr< resources::CommandHandler > > CreateHandler(const std::string &tool_name) const
Metadata describing a tool for the LLM.
std::vector< std::string > required_args
std::vector< std::string > examples
std::vector< std::string > flag_args