(path: &Path, agent_id: &str)
| 698 | } |
| 699 | |
| 700 | fn dispatch_model_for_agent(path: &Path, agent_id: &str) -> Option<String> { |
| 701 | let contents = std::fs::read_to_string(path).ok()?; |
| 702 | for line in contents.lines() { |
| 703 | let Ok(record) = serde_json::from_str::<Value>(line) else { |
| 704 | continue; |
| 705 | }; |
| 706 | let message = record.get("message").unwrap_or(&record); |
| 707 | let content = message.get("content").unwrap_or(message); |
| 708 | let Some(items) = content.as_array() else { |
| 709 | continue; |
| 710 | }; |
| 711 | for item in items { |
| 712 | let Some(name) = item.get("name").and_then(Value::as_str) else { |
| 713 | continue; |
| 714 | }; |
| 715 | if is_subagent_dispatch_tool(name) && dispatch_targets_agent(item, agent_id) { |
| 716 | if let Some(model) = cursor_dispatch_model(item) { |
| 717 | return Some(model); |
| 718 | } |
| 719 | } |
| 720 | } |
| 721 | } |
| 722 | None |
| 723 | } |
| 724 | |
| 725 | fn dispatch_targets_agent(item: &Value, agent_id: &str) -> bool { |
| 726 | let input = item.get("input").unwrap_or(item); |
no test coverage detected