yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
tool_dispatcher.h
Go to the documentation of this file.
1#ifndef YAZE_SRC_CLI_SERVICE_AGENT_TOOL_DISPATCHER_H_
2#define YAZE_SRC_CLI_SERVICE_AGENT_TOOL_DISPATCHER_H_
3
4#include <map>
5#include <optional>
6#include <string>
7#include <vector>
8
9#include "absl/status/statusor.h"
10#include "cli/service/agent/tool_registry.h" // For ToolDefinition
12#include "core/asar_wrapper.h" // For AsarWrapper + AsarSymbol
13#include "core/project.h" // For YazeProject
14
15namespace yaze {
16
17class Rom;
18
19namespace cli {
20namespace agent {
21
22// ToolCallType enum (moved to ToolRegistry for better cohesion)
23// Removed here.
24
26 public:
27 // ToolPreferences (remains here)
29 bool resources = true;
30 bool dungeon = true;
31 bool overworld = true;
32 bool messages = true;
33 bool dialogue = true; // Added missing dialogue
34 bool gui = true;
35 bool music = true;
36 bool sprite = true;
37#ifdef YAZE_WITH_GRPC
38 bool emulator = true;
39#else
40 bool emulator = false;
41#endif
42 bool filesystem = true;
43 bool build = true; // Placeholder for future build tools
44 bool memory_inspector = true;
45 bool test_helpers = true;
46 bool meta_tools = true; // tools-list, tools-describe, tools-search
47 bool visual_analysis = true;
48 bool code_gen = true;
49 bool project = true; // Project management tools
51 };
52
56 struct ToolInfo {
57 std::string name;
58 std::string category;
59 std::string description;
60 std::string usage;
61 std::vector<std::string> examples;
63 bool requires_project; // New: distinguish project vs ROM dependency
65 std::vector<std::string> required_args;
66 std::vector<std::string> flag_args;
67 };
68
72 std::vector<ToolInfo> GetAvailableTools() const;
73
77 std::optional<ToolInfo> GetToolInfo(const std::string& tool_name) const;
78
82 std::vector<ToolInfo> SearchTools(const std::string& query) const;
83
88 std::vector<ToolCall> calls;
89 bool parallel = false; // If true, execute independent calls in parallel
90 };
91
95 struct BatchResult {
96 std::vector<std::string> results;
97 std::vector<absl::Status> statuses;
99 size_t successful_count = 0;
100 size_t failed_count = 0;
101 };
102
110
111 ToolDispatcher() = default;
112
113 // Execute a tool call and return the result as a string.
114 absl::StatusOr<std::string> Dispatch(const ::yaze::cli::ToolCall& tool_call);
115
116 // Provide ROM, Project, and Asar contexts for tool calls.
117 void SetRomContext(Rom* rom) { rom_context_ = rom; }
119 project_context_ = project;
120 }
121 void SetAsarWrapper(core::AsarWrapper* asar_wrapper) {
122 asar_wrapper_ = asar_wrapper;
123 }
124 // Backend-agnostic assembly symbol table. Preferred path for tools that
125 // just need to read labels — works for both Asar and z3dk backends.
127 const std::map<std::string, core::AsarSymbol>* table) {
129 }
130
132 preferences_ = prefs;
133 }
134 const ToolPreferences& preferences() const { return preferences_; }
135
136 private:
137 // Check if a tool is enabled based on preferences and its category
138 bool IsToolEnabled(const ToolDefinition& def) const;
139 absl::Status ValidateCall(const ToolDefinition& def,
140 const ToolCall& call) const;
141 absl::StatusOr<std::string> DispatchMetaTool(const ToolCall& call) const;
142
143 Rom* rom_context_ = nullptr;
144 project::YazeProject* project_context_ = nullptr; // New: Project context
145 core::AsarWrapper* asar_wrapper_ = nullptr; // New: Asar wrapper context
146 const std::map<std::string, core::AsarSymbol>* assembly_symbol_table_ =
147 nullptr; // Backend-agnostic symbol source (preferred)
148 // Lazy snapshot of asar_wrapper_->GetSymbolTable() used when no explicit
149 // symbol-table pointer was supplied. See Dispatch().
150 std::map<std::string, core::AsarSymbol> asar_symbols_cache_;
152};
153
154} // namespace agent
155} // namespace cli
156} // namespace yaze
157
158#endif // YAZE_SRC_CLI_SERVICE_AGENT_TOOL_DISPATCHER_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
void SetToolPreferences(const ToolPreferences &prefs)
const std::map< std::string, core::AsarSymbol > * assembly_symbol_table_
void SetAssemblySymbolTable(const std::map< std::string, core::AsarSymbol > *table)
std::optional< ToolInfo > GetToolInfo(const std::string &tool_name) const
Get detailed information about a specific tool.
absl::Status ValidateCall(const ToolDefinition &def, const ToolCall &call) const
void SetProjectContext(project::YazeProject *project)
void SetAsarWrapper(core::AsarWrapper *asar_wrapper)
std::map< std::string, core::AsarSymbol > asar_symbols_cache_
std::vector< ToolInfo > SearchTools(const std::string &query) const
Search tools by keyword.
project::YazeProject * project_context_
bool IsToolEnabled(const ToolDefinition &def) const
BatchResult DispatchBatch(const BatchToolCall &batch)
Execute multiple tool calls in a batch.
const ToolPreferences & preferences() const
std::vector< ToolInfo > GetAvailableTools() const
Get list of all available tools.
absl::StatusOr< std::string > Dispatch(const ::yaze::cli::ToolCall &tool_call)
absl::StatusOr< std::string > DispatchMetaTool(const ToolCall &call) const
Modern C++ wrapper for Asar 65816 assembler integration.
Metadata describing a tool for the LLM.
Tool information for discoverability.
Modern project structure with comprehensive settings consolidation.
Definition project.h:164