feat: 实现 Agent 聚合系统(Phase 1)#2
Draft
ully wants to merge 59 commits into
Draft
Conversation
- 速度:社区=云端 /public/network 节点上报(最快 worker,折叠点与展开 worker 同源、颜色一致); 个人源=本地请求历史(我们转发的 avg 首字)。按速度升序排。 - 服务质量:来自本地请求历史 last_status_code —— 三态 成功(2xx)/429/失败(其它)/无请求, 429 与失败同为红、成功绿、无请求灰;自定义即时 tooltip(QualityBadge)说明"上次转发结果"。 个人源=每个源真值;社区=模型级(tokenbank-p2p,服务端暂不分 worker)。 - 折叠行只留速度点+模型名;展开行:速度点+ms 在前,去掉冗余的"忙/闲"(与流量重复)。 - 去掉 star 展示与随机种子(社区不再自测/随机初始化);下拉社区项改按最快 worker 网络速度着色。 - 后端 queryModelProviderLatency 增补 success/last_status_code(供服务质量与个人质量算)。 - 「全部测速」跑完即刻刷新:社区→loadNetwork(network+请求历史)、个人→loadLatency。 - 清理死代码/孤儿组件/未用 import。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
requests 表主键是 id(INTEGER PRIMARY KEY = rowid 别名)。SELECT rowid 在 better-sqlite3 里以 id 返回,r.rowid 为 undefined → UPDATE ... WHERE rowid=? 匹配 0 行,tier/cost_usd 实际没改,但仍返回 updated=rows.length。 改为 SELECT id + WHERE id=?,修复 CI 单测 local-stats.reassign-tier(58b8033 引入)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- 完整集成方案分析(方案对比、架构设计、实施步骤) - 快速参考指南(核心要点、时间线) - 技术实施清单(详细的代码修改、测试计划) 推荐方案:AionUi 作为 Token Bank 前置 Agent(最小侵入性集成) 预计开发周期:4-7 周 核心价值:形成全栈 AI 工作流平台(成本管理 + 任务执行) Co-authored-by: ully <ullyacl@gmail.com>
将 Debug 页面升级为统一的 Agent 调用入口 核心功能: - 🐛 LLM 调试模式(保留现有功能) - 🤖 Agent 工作模式(新增) - 调用已纳管的 Agent(AionUi/Claude Code/Codex) - 实时显示执行过程(步骤/工具调用/文件操作) - 支持 Agent 特有能力(Office 文档生成/代码执行) 技术架构: - AgentExecutor 执行引擎(统一调用各 Agent) - IPC 接口扩展(agent-execute/agent-stop/agent-list-available) - Debug 页面改造(模式切换/Agent 选择器) - AgentExecution 组件(执行结果展示) 预计开发周期:5 周(基础架构 1w + Agent 集成 2w + UI 完善 1w + 测试 1w) MVP 范围:2 周(AionUi Cowork 助手 + 基础结果展示) Co-authored-by: ully <ullyacl@gmail.com>
两个 AI Agent 工具的集成方案: 【aweskill - 技能包管理器】 - 类似 npm,管理 AI Agent 的技能(SKILL.md) - 支持 47+ Agent(Claude Code/Codex/Cursor/Gemini CLI 等) - 中心化存储 (~/.aweskill/skills/) - 技能发现/安装/更新/打包/修复 - AI Agent 可通过自然语言管理技能 【aweswitch - 配置切换工具】 - 快速切换 API 端点、模型、Token - 支持 Claude Code/Codex/OpenCode - Launch 模式(启动新会话)+ Write 模式(修改配置) - 环境变量引用,保护敏感信息 【集成价值】 - 技能管理:在 Token Bank Gateway 页面管理 Agent 技能 - 配置切换:快速切换不同 API 配置,统一追踪成本 - 生态完整:覆盖 Agent 全生命周期(纳管→技能→配置→成本) 实施计划:5 周(aweskill 2w + aweswitch 1w + 深度整合 2w) Co-authored-by: ully <ullyacl@gmail.com>
- 资源管理系统:统一管理Prompt/Skill/Assistant/Template - Profile系统:集成到Provider体系,支持快速切换 - Agent执行增强:原生Office能力和Assistant系统 - 数据模型:SQLite关系数据库替代文件系统 - 不做CLI封装,而是吸收设计思想和技术实现 Co-authored-by: ully <ullyacl@gmail.com>
- 移除Profile快速切换功能设计 - 聚焦资源管理和Agent增强两大核心 - 简化实施计划,减少不必要的复杂度 Co-authored-by: ully <ullyacl@gmail.com>
- AionUi核心价值是Agent聚合,不是Office能力 - Debug页面作为统一Agent操作台 - 调用Gateway已纳管的Agent(Claude Code/Codex等) - 实时执行日志、成本追踪、结果展示 - AgentExecutor统一调用接口 - 优先级:Agent聚合(P0) > 资源管理(P1) > Assistant(P2) Co-authored-by: ully <ullyacl@gmail.com>
- 供给源 = Model Provider + MCP Server - 吸收MCPMate的MCP代理、Profile裁剪、实时监控设计 - MCP Manager管理stdio和HTTP模式的MCP服务器 - Providers页面统一管理Model和MCP - Agent执行时注入MCP工具,统一成本追踪 - 优先级:Agent聚合(P0) > MCP供给源(P1) > 资源管理(P2) Co-authored-by: ully <ullyacl@gmail.com>
- 资源不是产出,而是Agent使用的输入 - 更新架构图:资源层 → 执行层 → 供给层 - 明确资源使用场景:Prompt模板、Skill技能包、Assistant配置、Template工作流 - 资源一次配置,通过投射机制多Agent共享 Co-authored-by: ully <ullyacl@gmail.com>
- Agent聚合只是提供额外的便利 - 用户仍可在Claude Desktop、Codex、Cursor直接操作 - 两种方式并存,自由选择 - 无论哪种方式,成本都通过网关追踪 - 设计原则:非侵入性、增值性、兼容性 Co-authored-by: ully <ullyacl@gmail.com>
- 网关代理、资源管理、Agent聚合可独立使用 - 四种使用模式:完全独立/仅网关/仅资源/全部使用 - 模式C(重点):直连官方API,但使用TB的MCP/Skill资源 - tokenbank-mcp-proxy:独立CLI工具供Agent调用 - 资源投射机制不依赖网关 - 按需组合,灵活使用 Co-authored-by: ully <ullyacl@gmail.com>
- MCPMate有完整的MCP网关/代理(Bridge + Proxy) - Token Bank采用方案B:聚焦管理,不重复造轮子 - 核心:数据管理 + UI界面 + 配置生成 + 监控追踪 - 可选:与MCPMate协同或使用简化代理 - 互补而非竞争:TB管理层 + MCPMate代理层 - 独特价值:与Model统一管理、成本追踪、Agent集成 Co-authored-by: ully <ullyacl@gmail.com>
核心设计: - 三层架构:资源层、执行层、供给层 - 三大核心:Agent聚合(P0)、MCP供给(P1)、资源管理(P2) - 四种模式:完全独立、仅网关、仅资源、全部使用 - 模块化设计:按需组合,非侵入性 技术实现: - AgentExecutor: Agent统一执行器 - MCPManager: MCP轻量级管理 - ResourceManager: 资源CRUD和投射 实施计划: - Phase 1: Agent聚合系统 - Phase 2: MCP供给源 - Phase 3: 资源管理系统 - Phase 4: 测试优化 文档索引: - OVERALL-PLAN.md (总体方案) - native-integration-design.md (详细设计) - mcp-architecture-comparison.md (MCP方案) - modular-architecture.md (模块化架构) Co-authored-by: ully <ullyacl@gmail.com>
数据模型: - 扩展local-stats.js添加agent_tasks/agent_task_steps/agent_modified_files表 - 扩展requests表添加agent_id/mcp_server_id/mcp_capability列 - 添加相关索引优化查询 核心模块: - agent-executor.js: Agent统一执行器 - 支持Claude Code和Codex调用 - 实时步骤监听和记录 - 修改文件追踪 - 任务状态管理 - 成本追踪集成 IPC接口: - ipc-handlers-agent.js: Agent相关IPC处理器 - agent:list - 获取可用Agent列表 - agent:execute - 执行Agent任务 - agent:cancel - 取消任务 - agent:getStatus - 获取任务状态 - 实时事件广播(step/completed/failed/cancelled) - 在main.js中注册handlers 下一步:前端UI实现(Debug页面改造) Co-authored-by: ully <ullyacl@gmail.com>
- 添加 AgentSelector 组件:Agent 选择器,展示可用的 Agent - 添加 ExecutionLog 组件:实时显示 Agent 执行步骤 - 添加 ExecutionResult 组件:展示执行结果和统计信息 - 修改 Debug.jsx 页面: - 添加模式切换器(LLM 模式 / Agent 模式) - 集成 Agent 选择、执行和结果展示 - 支持实时执行日志和任务控制(执行/取消) - 扩展 preload.js:暴露 Agent 执行 API 到渲染进程 - 修正 IPC 事件名称,确保前后端通信一致 Co-authored-by: ully <ullyacl@gmail.com>
Co-authored-by: ully <ullyacl@gmail.com>
Co-authored-by: ully <ullyacl@gmail.com>
Debug 支持多 Agent 标签与 keep-alive 状态恢复,编排派发与子 Agent 输出分离展示;spawn 对已纳管且绑路由的应用注入网关 env。新增 Resources/MCP 后端与页面,stream-json 解析系统事件(如 API 重试)并美化 ExecutionLog 卡片。 Co-authored-by: Cursor <cursoragent@cursor.com>
取消 sdk-cli 误跳过、proxy 占位行 enrich 合并,并支持 linked_data_sources 多源查询;同步改进 Debug Agent 输出解析与任务终态。 Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve conflict in local-stats.js (reassignProviderTier comment). Co-authored-by: Cursor <cursoragent@cursor.com>
单一路径:Agent 通过 tb_get_prompt 自主取回 prompt。 新增 prompt-only MCP 常驻同步;删网关宏/Debug补全/斜杠命令投射; assistant 投射内联 prompt 正文。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
投射语义改为「经 MCP 对某 agent 可见」,复用 resource_projections; MCP 按 TB_CLIENT_ID 过滤可见集;同步范围完全由投射驱动。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
新增 AIUsage 风格托盘浮窗(应用测速 TTFT、圈子帖数、一键开停贡献),避免历史 session 反复导入与打开卡顿;同步增强资源投射/技能扫描、Agent 输出解析与 Debug 体验。 Co-authored-by: Cursor <cursoragent@cursor.com>
归档时合并前端派发步骤与流式细节,避免终态摘要覆盖;新会话切换不再回填旧对话,智能体运行时跟随投射目标。 Co-authored-by: Cursor <cursoragent@cursor.com>
Codex 编排改用临时 MCP profile 与 bridge launcher,修正 resume/-p 参数顺序;内置 bridge 默认启用且经本地 HTTP 向主进程派发子任务。同步补齐历史会话、派发过程保留与输出归档等 Debug 修复。 Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
增加三个方法用于基于 client 过滤 prompt 资源: - listPromptsForClient: 列出投射给指定 client 的 prompt(支持空 clientId 返回全部) - hasPromptProjections: 判断该 client 是否有投射行 - resolvePromptForClient: 在投射校验基础上扩展 resolvePrompt Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…s,按 TB_CLIENT_ID 过滤) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- resource-agent-targets: 删 AGENT_PROMPT_TARGETS/getPromptTarget, listPromptProjectableAgentIds 改为委托 mcp-agent-targets.listSyncEnabledClientIds() - resource-projector: prompt 投射/反投射/健康检查改为纯标记式(projectionType='mcp'), 删除文件写入/TB 标记相关函数(buildPromptFileContent/isTbManagedPromptFile 等) - resource-manager: 删 _resyncPromptProjections 及其调用(权威源=DB,MCP 实时读库无需重刷); 投射 hint 改为提示经 MCP 工具取回;assistant 依赖投射仅保留 skill(prompt 运行时内联) - 测试:新增 prompt-projection-mcp.test.js,删除 prompt-projection-resync.test.js, 更新 resource-projector.test.js 中依赖旧落盘语义的用例 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…script When orchestration launches the bridge MCP via shell launcher, env vars like TB_CLIENT_ID were not passed through because they were only in _buildRuntimeServerConfig's bridge branch, which is bypassed when the launcher is used. Now TB_CLIENT_ID is exported in the generated launcher script alongside TB_MAIN_AGENT_ID, ensuring bridge process receives it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
bridge 的 tb_get_prompt 现经 agent-dispatch-client 统一走 resolvePromptForClient,HTTP 派发端点 /prompt 同步按 clientId 过滤, 避免持 dispatch token 即可绕过投射集读取任意提示词;拒绝消息补充 未投射原因说明。同步修正相关注释与目录 description 的全角标点。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
resolveElectronBinary 兜底纯 Node 场景取 Electron 二进制; writeElectronAsNodeLauncher 内嵌 ELECTRON_RUN_AS_NODE 与 TB_CLIENT_ID; tokenbank-prompts 常驻同步条目物化为 per-client launcher。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
trayAppTodayStats 与面板 apps:stats 同源(网关 proxy + 会话补录); 同一 agent 多条纳管记录按 api-key/manual > shim > session 保留一行并合并用量; 直连应用与经网关同用绿色活跃标,底部按钮宽度 2:1:1。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…对齐 wire model better-sqlite3 由 postinstall electron-rebuild 按 Electron ABI 构建, 系统 Node 跑测试必然 DLOPEN 失败——npm test 改用 electron --test。 patch_route 三处断言仍期望 scene_name,对齐 812ff79 的 model_key 语义。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
与 launcher 路径一致,避免在系统 Node 下把 node 写进 MCP 配置; 导出 resolveElectronBinary 供外部复用。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
面向普通用户,覆盖写作/语言/学习/职场/生活/理财/决策/创意,附少量开发类; 参考社区经典合集(prompts.chat/awesome-chatgpt-prompts, CC0)改写精简。 test_resources_seeded_from_yaml 改为成员判断 + >=50 规模断言。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
catalog 安装 / 手动新建的 skill 此前只写 DB 行、不落盘,导致「已纳管」tab (读磁盘扫描)看不到,且无权威目录不可投射/不可卸载。现经 _ensureSkillOnDisk 统一落盘到 ~/.agents/skills/<name> 并登记 agents-hub scan 投射。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Debug 页在 App keep-alive 下保持挂载,原仅在 mount / 空列表进入 agent 模式时
拉取,故从「资产」投射智能体后返回本页命中前端缓存,新智能体 tab 不显示。
现监听 location 变为 /debug 时 loadAgents({force:true})。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- resource-manager: 删除/新建/安装智能体后清 agent-executor 列表缓存 (此前仅投射清缓存,故删除的智能体在 Debug 仍显示为 tab) - agent:list IPC + preload 透传 force,前端刷新可绕过 45s TTL 缓存 - Debug.loadAgents 把 force 传给 IPC Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1. 取消投射:reference(智能体)/mcp(提示词)纯 DB 标记型投射前端可 × 取消 (此前 canUnprojectProjection 未覆盖这两类,不显示取消按钮); 取消后无运行时投射则回退默认运行时,避免残留 →Codex。 2. 依赖级联纳管:installFromCatalog 纳管智能体时,自动纳管其声明的 skill/prompt 依赖(存在于社区目录且未纳管者),skill 依赖一并落盘。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
此前 _listCustomAssistants 展示所有已纳管智能体(未投射也用默认 runtime 显示), 导致取消投射后仍留在 Debug。现要求至少一条 claude-code/codex 运行时投射才展示, 取消投射即从 Debug 移除,符合「投射=在 Debug 启用」的模型。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
将调试页更名为游乐场;Agent 列表改左侧竖排;LLM 模式可从资产选用提示词。 同步完善会话 trace 中的 Skill 调用识别、闲置 Skill 清理与 MCP 同步发现。 Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
实现 Token Bank 的 Agent 聚合系统,将 Debug 页面升级为统一的 Agent 入口,支持直接调用已纳管的 Agent 完成工作任务。
功能特性
🎯 核心功能
📊 数据库扩展
新增表结构:
agent_tasks:任务记录表agent_task_steps:任务步骤表agent_modified_files:文件修改记录表扩展现有表:
requests表新增agent_id,mcp_server_id,mcp_capability列🔧 技术实现
后端:
AgentExecutor类:核心调度器,基于 EventEmitter 实现实时事件通信前端:
AgentSelector组件:Agent 选择界面ExecutionLog组件:实时日志展示ExecutionResult组件:结果统计展示通信层:
agent:list,agent:execute,agent:cancel,agent:getStatustask:step,task:completed,task:failed,task:cancelled测试
详细测试指南见
TESTING-GUIDE.md快速测试
创建一个 hello.txt 文件,内容是 "Hello from Agent!"文件变更
新增文件
client/electron/agent-executor.js- Agent 执行核心逻辑client/electron/ipc-handlers-agent.js- IPC 通信处理器client/src/components/AgentSelector.jsx- Agent 选择器组件client/src/components/ExecutionLog.jsx- 执行日志组件client/src/components/ExecutionResult.jsx- 执行结果组件TESTING-GUIDE.md- 测试指南文档修改文件
client/electron/local-stats.js- 扩展数据库表结构client/electron/main.js- 注册 Agent IPC handlersclient/electron/preload.js- 暴露 Agent APIclient/src/pages/Debug.jsx- 添加 Agent 模式支持架构说明
Agent 聚合系统作为可选入口,不替代用户直接使用各个 Agent(如 Claude Desktop, Cursor)的方式。用户可以:
后续规划
相关文档
/workspace/docs/OVERALL-PLAN.md- 整体实施方案/workspace/docs/native-integration-design.md- 原生集成设计/workspace/TESTING-GUIDE.md- 测试指南