src/thought -> src/agent
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
39d6ca3fe0
commit
2f0c7ce5c2
21 changed files with 57 additions and 141 deletions
65
src/agent/tools/mod.rs
Normal file
65
src/agent/tools/mod.rs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
// tools/mod.rs — Agent-specific tool dispatch
|
||||
//
|
||||
// Shared tools (memory, files, bash, journal) live in thought/.
|
||||
// This module handles agent-specific tools (control, vision,
|
||||
// working_stack) and delegates everything else to thought::dispatch.
|
||||
|
||||
// Core tools
|
||||
pub mod bash;
|
||||
pub mod edit;
|
||||
pub mod glob;
|
||||
pub mod grep;
|
||||
pub mod memory;
|
||||
pub mod read;
|
||||
pub mod write;
|
||||
|
||||
// Agent-specific tools
|
||||
mod control;
|
||||
mod vision;
|
||||
pub mod working_stack;
|
||||
|
||||
// Re-export
|
||||
pub use crate::agent::{ToolDef, ToolOutput, ProcessTracker, truncate_output};
|
||||
|
||||
/// Dispatch a tool call by name.
|
||||
///
|
||||
/// Tries agent-specific tools first (control, vision), then
|
||||
/// delegates to thought::dispatch for shared tools.
|
||||
///
|
||||
/// Note: working_stack is handled in runner.rs before reaching this
|
||||
/// function (it needs mutable context access).
|
||||
pub async fn dispatch(
|
||||
name: &str,
|
||||
args: &serde_json::Value,
|
||||
tracker: &ProcessTracker,
|
||||
) -> ToolOutput {
|
||||
// Agent-specific tools that return Result<ToolOutput> directly
|
||||
let rich_result = match name {
|
||||
"pause" => Some(control::pause(args)),
|
||||
"switch_model" => Some(control::switch_model(args)),
|
||||
"yield_to_user" => Some(control::yield_to_user(args)),
|
||||
"view_image" => Some(vision::view_image(args)),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(result) = rich_result {
|
||||
return result.unwrap_or_else(ToolOutput::error);
|
||||
}
|
||||
|
||||
// Delegate to shared thought layer (poc-agent uses default provenance)
|
||||
if let Some(output) = crate::agent::dispatch(name, args, tracker, None).await {
|
||||
return output;
|
||||
}
|
||||
|
||||
ToolOutput::error(format!("Unknown tool: {}", name))
|
||||
}
|
||||
|
||||
/// Return all tool definitions (agent-specific + shared).
|
||||
pub fn definitions() -> Vec<ToolDef> {
|
||||
let mut defs = vec![
|
||||
vision::definition(),
|
||||
working_stack::definition(),
|
||||
];
|
||||
defs.extend(control::definitions());
|
||||
defs.extend(crate::agent::all_definitions());
|
||||
defs
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue