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 <optional>
5#include <string>
6#include <vector>
7
8#include "absl/status/statusor.h"
10#include "cli/service/agent/tool_registry.h" // For ToolDefinition
11#include "core/asar_wrapper.h" // For AsarWrapper
12#include "core/project.h" // For YazeProject
13
14namespace yaze {
15
16class Rom;
17
18namespace cli {
19namespace agent {
20
21// ToolCallType enum (moved to ToolRegistry for better cohesion)
22// Removed here.
23
25 public:
26 // ToolPreferences (remains here)
28 bool resources = true;
29 bool dungeon = true;
30 bool overworld = true;
31 bool messages = true;
32 bool dialogue = true; // Added missing dialogue
33 bool gui = true;
34 bool music = true;
35 bool sprite = true;
36#ifdef YAZE_WITH_GRPC
37 bool emulator = true;
38#else
39 bool emulator = false;
40#endif
41 bool filesystem = true;
42 bool build = true; // Placeholder for future build tools
43 bool memory_inspector = true;
44 bool test_helpers = true;
45 bool meta_tools = true; // tools-list, tools-describe, tools-search
46 bool visual_analysis = true;
47 bool code_gen = true;
48 bool project = true; // Project management tools
49 };
50
54 struct ToolInfo {
55 std::string name;
56 std::string category;
57 std::string description;
58 std::string usage;
59 std::vector<std::string> examples;
61 bool requires_project; // New: distinguish project vs ROM dependency
62 };
63
67 std::vector<ToolInfo> GetAvailableTools() const;
68
72 std::optional<ToolInfo> GetToolInfo(const std::string& tool_name) const;
73
77 std::vector<ToolInfo> SearchTools(const std::string& query) const;
78
83 std::vector<ToolCall> calls;
84 bool parallel = false; // If true, execute independent calls in parallel
85 };
86
90 struct BatchResult {
91 std::vector<std::string> results;
92 std::vector<absl::Status> statuses;
94 size_t successful_count = 0;
95 size_t failed_count = 0;
96 };
97
105
106 ToolDispatcher() = default;
107
108 // Execute a tool call and return the result as a string.
109 absl::StatusOr<std::string> Dispatch(const ::yaze::cli::ToolCall& tool_call);
110
111 // Provide ROM, Project, and Asar contexts for tool calls.
112 void SetRomContext(Rom* rom) { rom_context_ = rom; }
114 void SetAsarWrapper(core::AsarWrapper* asar_wrapper) { asar_wrapper_ = asar_wrapper; }
115
117 preferences_ = prefs;
118 }
119 const ToolPreferences& preferences() const { return preferences_; }
120
121 private:
122 // Check if a tool is enabled based on preferences and its category
123 bool IsToolEnabled(const ToolDefinition& def) const;
124
125 Rom* rom_context_ = nullptr;
126 project::YazeProject* project_context_ = nullptr; // New: Project context
127 core::AsarWrapper* asar_wrapper_ = nullptr; // New: Asar wrapper context
129};
130
131} // namespace agent
132} // namespace cli
133} // namespace yaze
134
135#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:24
void SetToolPreferences(const ToolPreferences &prefs)
std::optional< ToolInfo > GetToolInfo(const std::string &tool_name) const
Get detailed information about a specific tool.
void SetProjectContext(project::YazeProject *project)
void SetAsarWrapper(core::AsarWrapper *asar_wrapper)
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)
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:84