WIP: Output tool via Arc<Mutex<Subconscious>>, ToolHandler to Arc<dyn Fn>
- ToolHandler changed to Arc<dyn Fn(...)> (supports closures) - Subconscious wrapped in Arc<Mutex<>> on Mind - init_output_tool() pushes output tool closure capturing the Arc - Output removed from static memory_tools() - Most tool handlers wrapped in Arc::new() but some have paren issues Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
d167b11283
commit
12798eeae2
15 changed files with 74 additions and 51 deletions
|
|
@ -21,21 +21,18 @@ mod vision;
|
|||
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
|
||||
fn default_timeout() -> u64 { 120 }
|
||||
|
||||
/// Async tool handler function.
|
||||
/// Agent is None when called from contexts without an agent (MCP server, subconscious).
|
||||
pub type ToolHandler = fn(
|
||||
pub type ToolHandler = Arc<dyn Fn(
|
||||
Option<std::sync::Arc<super::Agent>>,
|
||||
serde_json::Value,
|
||||
) -> Pin<Box<dyn Future<Output = anyhow::Result<String>> + Send>>;
|
||||
) -> Pin<Box<dyn Future<Output = anyhow::Result<String>> + Send>>
|
||||
+ Send + Sync>;
|
||||
|
||||
/// A tool with its definition and handler — single source of truth.
|
||||
/// Strings are static — the tool list JSON can be built without
|
||||
/// serialization by interpolating these directly.
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone)]
|
||||
pub struct Tool {
|
||||
pub name: &'static str,
|
||||
pub description: &'static str,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue