Docker 容器化部署
- 提供 Mode A (Alpine musl, ~23MB) 和 Mode B (Distroless glibc, ~87MB)
两种镜像,Docker Compose 一键启动
- build.rs 支持 SKIP_DASHBOARD_BUILD 跳过前端构建
- 国内镜像加速 (npm/apt/apk) 通过 USE_MIRRORS build-arg 控制
安全:Cookie-Based 鉴权系统
- HttpOnly/SameSite=Strict Cookie 会话管理(24h 过期自动清理)
- 登录/登出/验证接口 + 中间件注入
- 前端登录页面 + 退出按钮
- 三层 CORS:localhost 鉴权 / 全放通 bookmarklet / 受保护路由
- 书签脚本 fetch 添加 credentials:'include'
Coordinator 模式 (P2)
- 4 个 meta-tool (delegate_task/check_task/task_stop/synthesize)
- WorkerPool + Semaphore 并发控制 + 超时保护
- 前端协调者模式开关
Hook 系统:UserPromptSubmit 事件 (P2)
- 第 13 个生命周期事件,fire-and-forget 审计
FTS5 全文搜索 (P3)
- agent_sessions_fts + agent_messages_fts 虚拟表
- search_history Agent 工具 + /api/search/history HTTP 接口
- 前端防抖搜索框 + 仅当前会话筛选
工具加载优化 (P3)
- defer_loading 延迟加载 (7 个重型工具)
- is_readonly 只读标记 (9 个查询工具)
- classifier_summary 工具目录供 LLM 按需判断
模型回退策略 (P3)
- LLM_FALLBACK_MODEL 优先回退 + LLM_FALLBACK_CHAIN 链式轮换
- LlmClient model 改为 Arc<RwLock> 支持运行时切换
- 连续 3 次过载后自动切换
压缩记忆桥接 (P3)
- 压缩丢弃消息 → 子代理提取持久记忆 (extract_memories_from_compaction)
git2 依赖修复
- 切换到 vendored-libgit2,消除 OpenSSL 系统依赖
94 lines
3.3 KiB
Rust
94 lines
3.3 KiB
Rust
// src/agent/tools/target.rs — 天体物理查询工具
|
|
|
|
use async_trait::async_trait;
|
|
use serde_json::json;
|
|
use tracing::info;
|
|
|
|
use crate::agent::tools::{AgentTool, ToolContext, ToolOutput};
|
|
|
|
/// 天体信息查询工具:通过 CDS Sesame 查询天体物理属性
|
|
pub struct QueryTargetTool;
|
|
|
|
#[async_trait]
|
|
impl AgentTool for QueryTargetTool {
|
|
fn name(&self) -> &str {
|
|
"query_target"
|
|
}
|
|
|
|
fn description(&self) -> &str {
|
|
"查询天体的基本物理属性信息。输入天体名称,返回坐标 (RA/Dec)、视星等、光谱型、视差等属性。\
|
|
数据来源为 CDS SIMBAD/Sesame 名称解析服务。适用于:获取天体基本参数、验证天体身份。"
|
|
}
|
|
|
|
fn parameters(&self) -> serde_json::Value {
|
|
json!({
|
|
"type": "object",
|
|
"properties": {
|
|
"object_name": {
|
|
"type": "string",
|
|
"description": "天体名称,如 'NGC 6752', 'GD 358', 'HD 209458', 'M 31' 等"
|
|
}
|
|
},
|
|
"required": ["object_name"]
|
|
})
|
|
}
|
|
|
|
/// 纯读取外部天体数据库,并发安全
|
|
fn is_concurrency_safe(&self, _args: &serde_json::Value) -> bool {
|
|
true
|
|
}
|
|
|
|
async fn execute(&self, args: serde_json::Value, ctx: &ToolContext) -> ToolOutput {
|
|
let object_name = match args.get("object_name").and_then(|n| n.as_str()) {
|
|
Some(n) => n.to_string(),
|
|
None => return ToolOutput::error("缺少必需参数 'object_name'"),
|
|
};
|
|
|
|
info!("[QueryTarget] 查询天体: {}", object_name);
|
|
let state = &ctx.app_state;
|
|
let client = reqwest::Client::new();
|
|
|
|
match crate::services::target::query_target_cached(&state.db, &object_name, None, &client)
|
|
.await
|
|
{
|
|
Ok(info) => {
|
|
let content = format!(
|
|
"天体: {}\nRA: {}\nDec: {}\n视差: {}\n光谱型: {}\nV星等: {}\n别名: {}",
|
|
info.target_name,
|
|
info.ra.as_deref().unwrap_or("未知"),
|
|
info.dec.as_deref().unwrap_or("未知"),
|
|
info.parallax
|
|
.map(|p| format!("{:.4} mas", p))
|
|
.unwrap_or_else(|| "未知".to_string()),
|
|
info.spectral_type.as_deref().unwrap_or("未知"),
|
|
info.v_magnitude
|
|
.map(|v| format!("{:.2}", v))
|
|
.unwrap_or_else(|| "未知".to_string()),
|
|
if info.aliases.is_empty() {
|
|
"无".to_string()
|
|
} else {
|
|
info.aliases.join(", ")
|
|
}
|
|
);
|
|
|
|
ToolOutput::success(
|
|
content,
|
|
json!({
|
|
"target_name": info.target_name,
|
|
"ra": info.ra, "dec": info.dec,
|
|
"parallax": info.parallax,
|
|
"spectral_type": info.spectral_type,
|
|
"v_magnitude": info.v_magnitude,
|
|
"aliases": info.aliases
|
|
}),
|
|
)
|
|
}
|
|
Err(e) => ToolOutput::error(format!("天体 '{}' 查询失败: {}", object_name, e)),
|
|
}
|
|
}
|
|
|
|
fn is_readonly(&self) -> bool {
|
|
true
|
|
}
|
|
}
|