Output tool via Arc<Mutex<Subconscious>> closure — complete
ToolHandler is now Arc<dyn Fn(...)> supporting closures that capture state. The output tool is created during init_output_tool() as a closure capturing Arc<Mutex<Subconscious>>, writing directly to Subconscious.state. No more POC_AGENT_OUTPUT_DIR filesystem hack. - All tool handlers wrapped in Arc::new() - Tool is Clone (not Copy) — .copied() → .cloned() - Subconscious wrapped in Arc<Mutex<>> on Mind - Dead filesystem-based output() function removed - memory_tools returns 11 items (output removed from static list) Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
daba424a46
commit
dd85a56902
13 changed files with 14 additions and 16 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use std::sync::Arc;
|
||||
// tools/memory.rs — Native memory graph operations
|
||||
//
|
||||
// Direct library calls into the store — no subprocess spawning.
|
||||
|
|
@ -32,7 +33,7 @@ async fn get_provenance(agent: &Option<std::sync::Arc<crate::agent::Agent>>) ->
|
|||
|
||||
// ── Definitions ────────────────────────────────────────────────
|
||||
|
||||
pub fn memory_tools() -> [super::Tool; 12] {
|
||||
pub fn memory_tools() -> [super::Tool; 11] {
|
||||
use super::Tool;
|
||||
[
|
||||
Tool { name: "memory_render", description: "Read a memory node's content and links.",
|
||||
|
|
@ -236,20 +237,6 @@ async fn query(args: &serde_json::Value) -> Result<String> {
|
|||
.map_err(|e| anyhow::anyhow!("{}", e))
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
let value = get_str(args, "value")?;
|
||||
let dir = std::env::var("POC_AGENT_OUTPUT_DIR")
|
||||
.map_err(|_| anyhow::anyhow!("no output directory set"))?;
|
||||
let path = std::path::Path::new(&dir).join(key);
|
||||
std::fs::write(&path, value)
|
||||
.with_context(|| format!("writing output {}", path.display()))?;
|
||||
Ok(format!("{}: {}", key, value))
|
||||
}
|
||||
|
||||
// ── Journal tools ──────────────────────────────────────────────
|
||||
|
||||
async fn journal_tail(args: &serde_json::Value) -> Result<String> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue