tools: each module exports only tool() or tools(), nothing else
Every tool module now has a clean interface: - read, write, edit, grep, glob, bash, vision: pub fn tool() -> Tool - web: pub fn tools() -> [Tool; 2] - memory: pub fn memory_tools() -> Vec<Tool> - channels: pub fn tools() -> Vec<Tool> - control: pub fn tools() -> Vec<Tool> Definition and handler functions are private to each module. mod.rs::tools() just chains the module exports. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
fdb8c989f5
commit
ed150df628
10 changed files with 65 additions and 36 deletions
|
|
@ -265,7 +265,7 @@ fn query(args: &serde_json::Value) -> Result<String> {
|
|||
.map_err(|e| anyhow::anyhow!("{}", e))
|
||||
}
|
||||
|
||||
pub(super) fn output_def() -> ToolDef {
|
||||
fn output_def() -> ToolDef {
|
||||
ToolDef::new("output",
|
||||
"Produce a named output value. Use this to pass structured results \
|
||||
between steps — subsequent prompts can see these in the conversation history.",
|
||||
|
|
@ -275,7 +275,7 @@ pub(super) fn output_def() -> ToolDef {
|
|||
},"required":["key","value"]}))
|
||||
}
|
||||
|
||||
pub(super) fn output(args: &serde_json::Value) -> Result<String> {
|
||||
fn output(args: &serde_json::Value) -> Result<String> {
|
||||
let key = get_str(args, "key")?;
|
||||
if key.starts_with("pid-") || key.contains('/') || key.contains("..") {
|
||||
anyhow::bail!("invalid output key: {}", key);
|
||||
|
|
@ -291,7 +291,7 @@ pub(super) fn output(args: &serde_json::Value) -> Result<String> {
|
|||
|
||||
// ── Journal tools ──────────────────────────────────────────────
|
||||
|
||||
pub(super) fn journal_tail_def() -> ToolDef {
|
||||
fn journal_tail_def() -> ToolDef {
|
||||
ToolDef::new("journal_tail",
|
||||
"Read the last N journal entries (default 1).",
|
||||
json!({"type":"object","properties":{
|
||||
|
|
@ -299,7 +299,7 @@ pub(super) fn journal_tail_def() -> ToolDef {
|
|||
}}))
|
||||
}
|
||||
|
||||
pub(super) fn journal_tail(args: &serde_json::Value) -> Result<String> {
|
||||
fn journal_tail(args: &serde_json::Value) -> Result<String> {
|
||||
let count = args.get("count").and_then(|v| v.as_u64()).unwrap_or(1) as usize;
|
||||
let store = load_store()?;
|
||||
let mut entries: Vec<&crate::store::Node> = store.nodes.values()
|
||||
|
|
@ -317,7 +317,7 @@ pub(super) fn journal_tail(args: &serde_json::Value) -> Result<String> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn journal_new_def() -> ToolDef {
|
||||
fn journal_new_def() -> ToolDef {
|
||||
ToolDef::new("journal_new",
|
||||
"Start a new journal entry.",
|
||||
json!({"type":"object","properties":{
|
||||
|
|
@ -327,7 +327,7 @@ pub(super) fn journal_new_def() -> ToolDef {
|
|||
},"required":["name","title","body"]}))
|
||||
}
|
||||
|
||||
pub(super) fn journal_new(args: &serde_json::Value) -> Result<String> {
|
||||
fn journal_new(args: &serde_json::Value) -> Result<String> {
|
||||
let name = get_str(args, "name")?;
|
||||
let title = get_str(args, "title")?;
|
||||
let body = get_str(args, "body")?;
|
||||
|
|
@ -363,7 +363,7 @@ pub(super) fn journal_new(args: &serde_json::Value) -> Result<String> {
|
|||
Ok(format!("New entry '{}' ({} words)", title, word_count))
|
||||
}
|
||||
|
||||
pub(super) fn journal_update_def() -> ToolDef {
|
||||
fn journal_update_def() -> ToolDef {
|
||||
ToolDef::new("journal_update",
|
||||
"Append text to the most recent journal entry (same thread continuing).",
|
||||
json!({"type":"object","properties":{
|
||||
|
|
@ -371,7 +371,7 @@ pub(super) fn journal_update_def() -> ToolDef {
|
|||
},"required":["body"]}))
|
||||
}
|
||||
|
||||
pub(super) fn journal_update(args: &serde_json::Value) -> Result<String> {
|
||||
fn journal_update(args: &serde_json::Value) -> Result<String> {
|
||||
let body = get_str(args, "body")?;
|
||||
let mut store = load_store()?;
|
||||
let latest_key = store.nodes.values()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue