thought: wire up agent and subconscious to use shared tools
- agent/tools/mod.rs: remove duplicated tool implementations, delegate
to thought::dispatch for shared tools, keep only agent-specific
tools (control, vision, working_stack)
- subconscious/api.rs: replace duplicated memory/tool dispatch with
thought::dispatch, use thought::all_definitions() for tool schemas
- Delete agent/tools/{bash,read,write,edit,grep,glob_tool,journal,memory}.rs
(now live in thought/)
Both poc-agent and subconscious agents now use the same tool
implementations through the thought layer. Agent-specific behavior
(node tracking in runner.rs, control tools) stays in agent/.
This commit is contained in:
parent
bfc558893a
commit
36bde60ba0
10 changed files with 31 additions and 1101 deletions
|
|
@ -1,65 +0,0 @@
|
|||
// tools/read.rs — Read file contents
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::agent::types::ToolDef;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Args {
|
||||
file_path: String,
|
||||
#[serde(default = "default_offset")]
|
||||
offset: usize,
|
||||
limit: Option<usize>,
|
||||
}
|
||||
|
||||
fn default_offset() -> usize { 1 }
|
||||
|
||||
pub fn definition() -> ToolDef {
|
||||
ToolDef::new(
|
||||
"read_file",
|
||||
"Read the contents of a file. Returns the file contents with line numbers.",
|
||||
json!({
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"file_path": {
|
||||
"type": "string",
|
||||
"description": "Absolute path to the file to read"
|
||||
},
|
||||
"offset": {
|
||||
"type": "integer",
|
||||
"description": "Line number to start reading from (1-based). Optional."
|
||||
},
|
||||
"limit": {
|
||||
"type": "integer",
|
||||
"description": "Maximum number of lines to read. Optional."
|
||||
}
|
||||
},
|
||||
"required": ["file_path"]
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn read_file(args: &serde_json::Value) -> Result<String> {
|
||||
let args: Args = serde_json::from_value(args.clone())
|
||||
.context("invalid read_file arguments")?;
|
||||
|
||||
let content = std::fs::read_to_string(&args.file_path)
|
||||
.with_context(|| format!("Failed to read {}", args.file_path))?;
|
||||
|
||||
let lines: Vec<&str> = content.lines().collect();
|
||||
let offset = args.offset.max(1) - 1;
|
||||
let limit = args.limit.unwrap_or(lines.len());
|
||||
|
||||
let mut output = String::new();
|
||||
for (i, line) in lines.iter().skip(offset).take(limit).enumerate() {
|
||||
output.push_str(&format!("{:>6}\t{}\n", offset + i + 1, line));
|
||||
}
|
||||
|
||||
if output.is_empty() {
|
||||
output = "(empty file)\n".to_string();
|
||||
}
|
||||
|
||||
Ok(output)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue