Handle remove operation
(os: &Os, session: &ChatSession, path: &str)
| 313 | |
| 314 | /// Handle remove operation |
| 315 | async fn handle_remove(os: &Os, session: &ChatSession, path: &str) -> OperationResult { |
| 316 | let sanitized_path = sanitize_path_tool_arg(os, path); |
| 317 | let agent = Self::get_agent(session); |
| 318 | |
| 319 | let async_knowledge_store = match KnowledgeStore::get_async_instance(os, agent).await { |
| 320 | Ok(store) => store, |
| 321 | Err(e) => return OperationResult::Error(format!("Error accessing knowledge base: {}", e)), |
| 322 | }; |
| 323 | let mut store = async_knowledge_store.lock().await; |
| 324 | |
| 325 | let scope_desc = "agent"; |
| 326 | |
| 327 | // Try path first, then name |
| 328 | if store.remove_by_path(&sanitized_path.to_string_lossy()).await.is_ok() { |
| 329 | OperationResult::Success(format!( |
| 330 | "Removed {} knowledge base entry with path '{}'", |
| 331 | scope_desc, path |
| 332 | )) |
| 333 | } else if store.remove_by_name(path).await.is_ok() { |
| 334 | OperationResult::Success(format!( |
| 335 | "Removed {} knowledge base entry with name '{}'", |
| 336 | scope_desc, path |
| 337 | )) |
| 338 | } else { |
| 339 | OperationResult::Warning(format!("Entry not found in {} knowledge base: {}", scope_desc, path)) |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | /// Handle update operation |
| 344 | async fn handle_update(os: &Os, session: &ChatSession, path: &str) -> OperationResult { |
nothing calls this directly
no test coverage detected