Repository navigation
feat(agent): Skill Hub + 沙箱只读 / 可写开关(只读时拦截写类工具) - #230
Merged
Merged
Conversation
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.
What and why / 改了什么、为什么
让用户看得到 Agent 会按什么方法做事(Skill Hub),并能把它关进「只读」沙箱:只查、只给建议,不改任何数据。基于 #222 的技能注册表(
packages/core/src/agent/skills.ts),不改技能内容和自动加载逻辑。GET /api/agent/skills返回注册表目录(skillCatalog():id、标题、什么时候用、触发词(由 triggers 正则拆成可读关键词)、完整方法、示例说法example)+ 沙箱说明。前端AgentSkillHub对话框(/skills打开):搜索、触发词紫色小胶囊、展开看方法、「试一下」把示例填进输入框(命中触发词 → 自动加载该技能)。packages/core/src/agent/sandbox.ts。Run 请求带sandbox: "read_only" | "workspace_write"(默认可写;非法值 400)。只读时applySandbox包一层:白名单放行读类工具(overview / search / list / get / changes / read_file / find_files / web_search / fetch_page / reconcile_memory / export_data / tool_manual / skill_read / request_user_input,email_sync 仅action=status),其余(含将来新加的工具)一律不执行,回{ok:false, error:{code:"read_only", message, retryable:false, suggestedAction}},描述前加「只读模式下不可用」。模式记进run.llm_runtime.sandbox,续跑 / 回答 Ask 时沿用。ToolErrorCode加read_only。host.ts只动了三处:RunOptions.sandbox、tools外包applySandbox、llm_runtime记sandbox;没碰上下文窗口 / MAX_STEPS。/readonly/write;只读时模式胶囊显示锁 +「只读」。docs/design/components.md、docs/route-coverage.md同步。无表结构变更。怎么测的 / Testing
backend-ts: 新增 Skill Hub 目录契约、只读 Run(save 被拦成 read_only 结构化错误、overview 照常、记忆没写入、写类工具描述标注、llm_runtime 记模式、非法 sandbox 400)、可写 Run 照常写入;agent-sandbox.test.ts(模式解析、白名单 / 未知工具算写 / email_sync 读写、包装行为);vitest✅ 224、typecheck✅。frontend: 新增AgentSkillHub.test.tsx(筛选、列表 / 触发词 / 展开方法 / 试一下、沙箱切换、加载失败)、AgentComposerControls模式菜单用例;typecheck✅、vitest✅ 287、design:audit✅ 0 new、build✅。风险 / Risk
怎么撤回 / How to revert
revert 这个 PR;无数据变更(沙箱选择存在浏览器 localStorage 的 composer 设置里)。
Checklist