Consolidate memory RPC in tools/memory.rs
- Move memory_rpc(), socket_path(), SocketConn from mcp_server.rs - Convert remaining callers to typed async API: - defs.rs: organize placeholder, run_agent query - cli/agent.rs: query resolution (now async) - mind/identity.rs: Store context loading - Re-export socket_path/memory_rpc from mcp_server for compatibility All external memory access now goes through tools/memory.rs typed API. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
5b07a81aa7
commit
fb46ab095d
6 changed files with 146 additions and 134 deletions
|
|
@ -222,17 +222,19 @@ fn resolve(
|
|||
}
|
||||
|
||||
"organize" => {
|
||||
// Show seed nodes with content and links via RPC
|
||||
// Show seed nodes with content and links via typed API
|
||||
let mut text = format!("### Seed nodes ({} starting points)\n\n", keys.len());
|
||||
let mut result_keys = Vec::new();
|
||||
|
||||
for key in keys {
|
||||
match crate::mcp_server::memory_rpc(
|
||||
"memory_render",
|
||||
serde_json::json!({"key": key}),
|
||||
) {
|
||||
Ok(content) if !content.trim().is_empty() => {
|
||||
text.push_str(&format!("#### {}\n\n{}\n\n---\n\n", key, content));
|
||||
let content = tokio::task::block_in_place(|| {
|
||||
tokio::runtime::Handle::current().block_on(
|
||||
crate::agent::tools::memory::memory_render(None, key, None)
|
||||
)
|
||||
});
|
||||
match content {
|
||||
Ok(c) if !c.trim().is_empty() => {
|
||||
text.push_str(&format!("#### {}\n\n{}\n\n---\n\n", key, c));
|
||||
result_keys.push(key.clone());
|
||||
}
|
||||
_ => continue,
|
||||
|
|
@ -619,10 +621,11 @@ pub fn run_agent(
|
|||
} else {
|
||||
format!("{} | limit:{}", def.query, padded)
|
||||
};
|
||||
let result = crate::mcp_server::memory_rpc(
|
||||
"memory_query",
|
||||
serde_json::json!({"query": query}),
|
||||
).map_err(|e| e.to_string())?;
|
||||
let result = tokio::task::block_in_place(|| {
|
||||
tokio::runtime::Handle::current().block_on(
|
||||
crate::agent::tools::memory::memory_query(None, &query, None)
|
||||
)
|
||||
}).map_err(|e| e.to_string())?;
|
||||
let filtered: Vec<String> = result.lines()
|
||||
.filter(|l| !l.is_empty() && *l != "no results")
|
||||
.map(|s| s.to_string())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue