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
|
|
@ -1,8 +1,9 @@
|
|||
// cli/agent.rs — agent subcommand handlers
|
||||
|
||||
use crate::agent::tools::memory;
|
||||
use crate::store;
|
||||
|
||||
pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option<&str>, dry_run: bool, _local: bool, state_dir: Option<&str>) -> Result<(), String> {
|
||||
pub async fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option<&str>, dry_run: bool, _local: bool, state_dir: Option<&str>) -> Result<(), String> {
|
||||
// Mark as agent so tool calls (e.g. poc-memory render) don't
|
||||
// pollute the user's seen set as a side effect
|
||||
// SAFETY: single-threaded at this point (CLI startup, before any agent work)
|
||||
|
|
@ -22,11 +23,10 @@ pub fn cmd_run_agent(agent: &str, count: usize, target: &[String], query: Option
|
|||
let resolved_targets: Vec<String> = if !target.is_empty() {
|
||||
target.to_vec()
|
||||
} else if let Some(q) = query {
|
||||
// Use RPC to resolve query
|
||||
let result = crate::mcp_server::memory_rpc(
|
||||
"memory_query",
|
||||
serde_json::json!({"query": format!("{} | limit:{}", q, count)}),
|
||||
).map_err(|e| e.to_string())?;
|
||||
// Resolve query via typed API
|
||||
let q_str = format!("{} | limit:{}", q, count);
|
||||
let result = memory::memory_query(None, &q_str, None).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
let keys: 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