(&self, id: Value)
| 2297 | } |
| 2298 | |
| 2299 | async fn read_resource_branches(&self, id: Value) -> JsonRpcResponse { |
| 2300 | let cg = self.cg_snapshot().await; |
| 2301 | let tracedecay_dir = &cg.store_layout().data_root; |
| 2302 | let current = cg.active_branch(); |
| 2303 | |
| 2304 | let branches: Vec<Value> = match crate::branch_meta::load_branch_meta(tracedecay_dir) { |
| 2305 | Some(meta) => meta |
| 2306 | .branches |
| 2307 | .iter() |
| 2308 | .map(|(name, entry)| { |
| 2309 | let db_path = tracedecay_dir.join(&entry.db_file); |
| 2310 | let size_bytes = db_path.metadata().map_or(0, |m| m.len()); |
| 2311 | json!({ |
| 2312 | "name": name, |
| 2313 | "db_file": entry.db_file, |
| 2314 | "parent": entry.parent, |
| 2315 | "size_bytes": size_bytes, |
| 2316 | "last_synced_at": entry.last_synced_at, |
| 2317 | "is_current": current == Some(name.as_str()), |
| 2318 | "is_default": name == &meta.default_branch, |
| 2319 | }) |
| 2320 | }) |
| 2321 | .collect(), |
| 2322 | None => vec![], |
| 2323 | }; |
| 2324 | |
| 2325 | let output = json!({ |
| 2326 | "branch_count": branches.len(), |
| 2327 | "branches": branches, |
| 2328 | }); |
| 2329 | let text = serde_json::to_string_pretty(&output).unwrap_or_default(); |
| 2330 | JsonRpcResponse::success( |
| 2331 | id, |
| 2332 | json!({ |
| 2333 | "contents": [{ |
| 2334 | "uri": "tracedecay://branches", |
| 2335 | "mimeType": "application/json", |
| 2336 | "text": text |
| 2337 | }] |
| 2338 | }), |
| 2339 | ) |
| 2340 | } |
| 2341 | |
| 2342 | /// Handles the `tools/call` method, dispatching to the appropriate tool handler. |
| 2343 | async fn handle_tools_call( |
no test coverage detected