Files
yaze/src/cli/service/agent/tool_dispatcher.cc
scawful 7c2bf8e1c7 Add ToolDispatcher for Enhanced Tool Call Management
- Introduced `ToolDispatcher` class to handle tool calls from the AI agent, allowing for dynamic execution of commands based on user requests.
- Updated `ConversationalAgentService` to integrate tool dispatching, enabling the agent to respond to tool calls and manage execution results.
- Enhanced `AgentResponse` structure to include a list of tool calls, facilitating communication between the AI and the tool dispatcher.
- Modified AI service implementations to parse and include tool calls in responses, improving the agent's interactive capabilities.

This commit significantly enhances the z3ed system's ability to manage and execute tool calls, paving the way for more complex interactions in ROM hacking.
2025-10-03 12:47:15 -04:00

41 lines
1.1 KiB
C++

#include "cli/service/agent/tool_dispatcher.h"
#include "absl/strings/str_format.h"
#include "cli/handlers/agent/commands.h"
namespace yaze {
namespace cli {
namespace agent {
absl::StatusOr<std::string> ToolDispatcher::Dispatch(
const ToolCall& tool_call) {
std::vector<std::string> args;
for (const auto& [key, value] : tool_call.args) {
args.push_back(absl::StrFormat("--%s", key));
args.push_back(value);
}
if (tool_call.tool_name == "resource-list") {
// Note: This is a simplified approach for now. A more robust solution
// would capture stdout instead of relying on the handler to return a string.
auto status = HandleResourceListCommand(args);
if (!status.ok()) {
return status;
}
return "Successfully listed resources.";
} else if (tool_call.tool_name == "dungeon-list-sprites") {
auto status = HandleDungeonListSpritesCommand(args);
if (!status.ok()) {
return status;
}
return "Successfully listed sprites.";
}
return absl::UnimplementedError(
absl::StrFormat("Unknown tool: %s", tool_call.tool_name));
}
} // namespace agent
} // namespace cli
} // namespace yaze