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,51 +0,0 @@
|
|||
// tools/write.rs — Write file contents
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::agent::types::ToolDef;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Args {
|
||||
file_path: String,
|
||||
content: String,
|
||||
}
|
||||
|
||||
pub fn definition() -> ToolDef {
|
||||
ToolDef::new(
|
||||
"write_file",
|
||||
"Write content to a file. Creates the file if it doesn't exist, \
|
||||
overwrites if it does. Creates parent directories as needed.",
|
||||
json!({
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"file_path": {
|
||||
"type": "string",
|
||||
"description": "Absolute path to the file to write"
|
||||
},
|
||||
"content": {
|
||||
"type": "string",
|
||||
"description": "The content to write to the file"
|
||||
}
|
||||
},
|
||||
"required": ["file_path", "content"]
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn write_file(args: &serde_json::Value) -> Result<String> {
|
||||
let args: Args = serde_json::from_value(args.clone())
|
||||
.context("invalid write_file arguments")?;
|
||||
|
||||
if let Some(parent) = Path::new(&args.file_path).parent() {
|
||||
std::fs::create_dir_all(parent)
|
||||
.with_context(|| format!("Failed to create directories for {}", args.file_path))?;
|
||||
}
|
||||
|
||||
std::fs::write(&args.file_path, &args.content)
|
||||
.with_context(|| format!("Failed to write {}", args.file_path))?;
|
||||
|
||||
Ok(format!("Wrote {} lines to {}", args.content.lines().count(), args.file_path))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue