Large World graph, agent platform, brain stack & dashboard rebuild
Frontend - Large World: collapse org/company/team tiers into one expandable React Flow hierarchy (WorldFlow) with per-click expand, persisted node positions, a compact tree sidebar, wrench multi-select delete across levels, and a sized right slide-out (phone/tablet/full) showing an agent summary + drill button. - Agent page: GitHub-style animated contribution grid (VitalsCard), collapsible System Prompt + Personality cards, restructured anatomy cards, bigger avatar with name/title header row, Markdown/JSON-aware rendering, brain registry + history, avatar generate/upload. - User-icon menu (Infrastructure/Brains/Tools/Profile/Credits) + ToolPanel; Master Planner deploy wizard (Specialists/Swarm/Scheduled/Triggered); Team Runs view; reap-progress modal; dashboard is the single live interface. Backend - cm-brain crate (.brain as the agent definition) + brain apply/history. - Hard-purge reap (FK-ordered) + sandbox release + SSE batch-delete. - Swarm self-verifying loop, mode-aware planner, web.search tool, webhooks (migration 0013), org/company/team delete endpoints, scheduler sweeps. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
9f266d5806
commit
34f744734b
@@ -0,0 +1,70 @@
|
||||
//! `web.search` — grounded web search via Anthropic's server-side web-search tool,
|
||||
//! so agents (e.g. a nightly research team) can find current papers/news/docs.
|
||||
|
||||
use cm_llm::{
|
||||
AnthropicProvider, ChatMessage, ChatRequest, ChatRole, ContentPart, LlmEvent, LlmProvider,
|
||||
ToolDescriptor,
|
||||
};
|
||||
use cm_tools::{Effect, TaintSource};
|
||||
use futures::StreamExt;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use super::{Tool, ToolContext};
|
||||
|
||||
pub struct WebSearch;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Tool for WebSearch {
|
||||
fn descriptor(&self) -> ToolDescriptor {
|
||||
ToolDescriptor {
|
||||
name: "web.search".into(),
|
||||
description: "Search the web for current information (research papers, news, docs) and return a \
|
||||
grounded summary with source URLs."
|
||||
.into(),
|
||||
input_schema: json!({
|
||||
"type": "object",
|
||||
"properties": { "query": { "type": "string", "description": "What to search the web for" } },
|
||||
"required": ["query"]
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
fn effects(&self) -> &'static [Effect] {
|
||||
&[Effect::ReachesExternally]
|
||||
}
|
||||
|
||||
fn output_taint(&self) -> Option<TaintSource> {
|
||||
Some(TaintSource::Web)
|
||||
}
|
||||
|
||||
async fn execute(&self, _ctx: &ToolContext, input: Value) -> Result<Value, String> {
|
||||
let query = input.get("query").and_then(|q| q.as_str()).unwrap_or("").trim().to_string();
|
||||
if query.is_empty() {
|
||||
return Err("query is required".into());
|
||||
}
|
||||
let key = std::env::var("ANTHROPIC_API_KEY")
|
||||
.map_err(|_| "web.search unavailable (ANTHROPIC_API_KEY not set)".to_string())?;
|
||||
let provider = AnthropicProvider::new(key);
|
||||
let request = ChatRequest {
|
||||
system: "You are a web research assistant. Use web search to find current, accurate information \
|
||||
and answer concisely with the key facts and the source URLs."
|
||||
.into(),
|
||||
model: "claude-haiku-4-5-20251001".into(),
|
||||
messages: vec![ChatMessage {
|
||||
role: ChatRole::User,
|
||||
parts: vec![ContentPart::text(query.clone())],
|
||||
}],
|
||||
tools: vec![],
|
||||
max_tokens: 1500,
|
||||
web_search: true,
|
||||
};
|
||||
let mut text = String::new();
|
||||
let mut stream = provider.stream(request).await.map_err(|e| e.to_string())?;
|
||||
while let Some(ev) = stream.next().await {
|
||||
if let Ok(LlmEvent::TextDelta(t)) = ev {
|
||||
text.push_str(&t);
|
||||
}
|
||||
}
|
||||
Ok(json!({ "query": query, "results": text }))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user