refactor: Prettier 格式化全量前端、Library 服务端分页筛选、Agent 工具输出可视化与 .agent 目录统一
代码质量:
- 新增 .prettierrc + eslint-plugin-prettier,全量格式化所有 TSX/TS/CSS 文件
- npm scripts 新增 format / format:check / lint:fix
Logo 重设计:
- SVG logo 从简单星月改为望远镜+轨道+三角架+星光,favicon 同步更新
Library 服务端分页与多维筛选:
- LibraryQueryParams 支持 q(全局搜索)/status(下载状态)/doctype/author/year/journal/sort_by
- API 返回 {items, total},默认每页 12 条
- 前端新增筛选面板:搜索栏、状态下拉、文献类型、排序、分页控件
Agent 工具输出可视化:
- 新增 SpecialToolRenderers.tsx:query_target 天体参数卡片(含 SIMBAD/VizieR 链接)、search_papers
文献列表(内嵌下载/阅读/星系跳转按钮)
- 系统内部工具(compress_context 等)无错误时自动隐藏,减少时间线噪音
- ToolCallCard 与 Reader/Citation 打通:可在工具输出中直接打开文献或跳转引用星系
.agent 目录统一:
- memory/tool-results/trajectories/images 全部归入 library/.agent/ 子目录
PDF 加载修复:
- BilingualViewer 改用 fetch → blob:// URL 加载 PDF,绕过 iframe SameSite Cookie 限制
This commit is contained in:
@@ -46,6 +46,9 @@ cargo test test_name
|
||||
npm run dev # HMR dev server on :5173, proxies /api to :8000
|
||||
npm run build # TypeScript check + Vite production build → dashboard/dist/
|
||||
npm run lint # ESLint
|
||||
npm run lint:fix # ESLint with auto-fix
|
||||
npm run format # Prettier format all source files
|
||||
npm run format:check # Check formatting without modifying files
|
||||
```
|
||||
|
||||
## Architecture Overview
|
||||
@@ -169,13 +172,14 @@ Session-level modes configure the agent's identity, tool access, step limits, th
|
||||
|
||||
Three built-in modes (registered in `ModeRegistry::builtins()`):
|
||||
|
||||
| Mode | ID | Tools | Max Steps | Thinking | Permission Profile |
|
||||
|------|-----|-------|-----------|----------|---------------------|
|
||||
| 通用科研助手 | `default` | All (unrestricted) | 8 (default) | user-controlled | none |
|
||||
| 深度研究 | `deep-research` | All | 16 | forced on | `research` |
|
||||
| 文献阅读助手 | `literature-reader` | Allowlist (read-only + literature) | 6 | forced off | `readonly` |
|
||||
| Mode | ID | Tools | Max Steps | Thinking | Permission Profile |
|
||||
| ------------ | --------------------- | ---------------------------------- | ----------- | --------------- | ------------------ |
|
||||
| 通用科研助手 | `default` | All (unrestricted) | 8 (default) | user-controlled | none |
|
||||
| 深度研究 | `deep-research` | All | 16 | forced on | `research` |
|
||||
| 文献阅读助手 | `literature-reader` | Allowlist (read-only + literature) | 6 | forced off | `readonly` |
|
||||
|
||||
Key types in `modes/mod.rs`:
|
||||
|
||||
- **`AgentMode`** — static definition struct: id, name, description, icon, identity/principles overrides, extra sections, `ToolSet`, `ModeConfig`
|
||||
- **`ToolSet`** — `All`, `Allowlist(&[&str])`, or `Except(&[&str])` — constrains which tools are available
|
||||
- **`ModeConfig`** — optional overrides for `max_steps`, `enable_thinking`, `tool_timeout_secs`, `permission_profile`
|
||||
@@ -190,6 +194,7 @@ The mode is stored in the `agent_sessions.mode` column (migration `2026062400000
|
||||
Tool execution is gated by a priority-ordered rule chain: **Deny > Allow > Ask** (first match wins). Rules support content-level pattern matching (e.g., `run_bash(rm *)`).
|
||||
|
||||
**Permission modes** (set via `AGENT_PERMISSION_MODE` env or mode's `permission_profile`):
|
||||
|
||||
- `default` — full rule chain evaluation
|
||||
- `accept_edits` — auto-allow `file_write`/`file_edit` within the working directory
|
||||
- `bypass` — skip all Ask checks (Deny rules still enforced)
|
||||
@@ -198,6 +203,7 @@ Tool execution is gated by a priority-ordered rule chain: **Deny > Allow > Ask**
|
||||
**Permission profiles** (`src/agent/runtime/permission_profile.rs`) are named presets loaded by `AGENT_PERMISSION_MODE` or a mode's `permission_profile` field. Profiles `research` and `readonly` are used by deep-research and literature-reader modes respectively.
|
||||
|
||||
**Configuration** (in `.env`):
|
||||
|
||||
- `AGENT_PERMISSIONS_DENY` — comma-separated deny rules (e.g., `run_bash(rm *),run_bash(sudo *)`)
|
||||
- `AGENT_PERMISSIONS_ALLOW` — comma-separated allow rules
|
||||
- `AGENT_PERMISSIONS_ASK` — comma-separated ask rules
|
||||
@@ -207,11 +213,11 @@ Tool execution is gated by a priority-ordered rule chain: **Deny > Allow > Ask**
|
||||
|
||||
The system supports three LLM tiers with cascade fallback:
|
||||
|
||||
| Tier | Env Prefix | Purpose | Fallback |
|
||||
|------|-----------|---------|----------|
|
||||
| Primary | `LLM_` | Main agent reasoning | — |
|
||||
| Medium | `LLM_MEDIUM_` | Translation, RAG | Primary LLM config |
|
||||
| Fast | `LLM_FAST_` | Memory extraction, background tasks | Medium LLM config |
|
||||
| Tier | Env Prefix | Purpose | Fallback |
|
||||
| ------- | --------------- | ----------------------------------- | ------------------ |
|
||||
| Primary | `LLM_` | Main agent reasoning | — |
|
||||
| Medium | `LLM_MEDIUM_` | Translation, RAG | Primary LLM config |
|
||||
| Fast | `LLM_FAST_` | Memory extraction, background tasks | Medium LLM config |
|
||||
|
||||
Each tier has `_API_KEY`, `_API_BASE`, `_MODEL` variants. Unset tiers cascade to the next tier down.
|
||||
|
||||
@@ -224,6 +230,7 @@ When `LLM_VISION_MODEL` env is set, the `analyze_image` tool (`src/agent/tools/a
|
||||
### Auto Memory Extraction
|
||||
|
||||
Controlled by env vars:
|
||||
|
||||
- `EXTRACT_MEMORY_ENABLED` (default `false`) — enables automatic memory extraction at session end and during compaction
|
||||
- `EXTRACT_MEMORY_THROTTLE_TURNS` (default `3`) — extract every N turns
|
||||
- `EXTRACT_MEMORY_MAX_STEPS` (default `3`) — sub-agent max steps for extraction
|
||||
|
||||
Reference in New Issue
Block a user