DAG总览 / 组目录 / G09 核心运行时

dsh-tools · @deepseek-ai/dsh-tools

Layer 4G09
目录:ACP 协议API 网关与控制器附件启动与插件管理客户端运行时客户端 UI 包上下文压缩上下文注入核心运行时凭据与授权交付物文档处理实验特性宿主扩展反馈通道文件系统目标与计划工具守卫Hooks 扩展宿主服务交互命令作业调度LLM 适配LSP 集成MCP 协议规划模式Agent 预设代码执行运行时运行时诊断沙箱定时调度SDK 与协议会话核心会话检索设置Shell 执行技能溢出存储SSH 远程执行存储子代理子进程终端待办类型契约框架 vendorWeb 访问Webhook工作流工作区
依赖链 · 上游(该插件依赖的前驱):
依赖链 · 下游(依赖该插件的节点):
同一拓扑层(Layer 4,层次遍历层序):
↑ Layer 3(24 插件)Layer 4↓ Layer 5(55 插件)

插件信息

包名@deepseek-ai/dsh-tools
分组G09 · 核心运行时
拓扑层Layer 4(层次遍历:被依赖方先于依赖方)
源码路径packages/core/tools

① 实现逻辑

工具注册表与执行流水线:`ToolRuntime`(服务名 `tools`)用 `ScopedLayers` 维护作用域化工具注册与呈现模式,构造时向 systemPrompt 注册 tool-schema provider,并在非 native 默认模式下注册 PTC 折叠与 SDK section (src/index.ts:807-859)。`register()` 以 ctx.effect 绑定注册所有权 (src/index.ts:1063-1086);呈现模式由 `presentAs` 按作用域声明并遮蔽全局默认 (src/index.ts:974-999);执行走 pre/guard/around/post/result 多段 waterfall (src/index.ts:1325,1505,1605,1782)。ptc.ts 实现 `run_code` 传输,经 `ctx.ptcRuntime` 与 `dsh-sandbox` 执行嵌套子调用,审批经 `ctx.get('approval')` 可选消费 (src/index.ts:947,1731; src/ptc.ts:19-22)。schema/json-schema/ts-types/py-types 提供工具参数校验与 TS/Python SDK 渲染;invariant.ts 校验会话内工具调用关系 (src/invariant.ts:77-129)。

内部结构动态 DAG(深色主题:橙色=上游依赖 · 绿色=下游依赖 · 棕色=外部seam · 蓝=本插件)
本插件 上游依赖 下游依赖 外部 seam

② 注册/提供(provides)

③ 依赖(depends_on · 上游前驱)

dsh-agentE1
复用 Agent 类型以在调度中引用所属 agent
src/index.ts:13 import type Agent + package.json:41 peerDep
dsh-invariantsE1+E2
注册会话内工具调用关系不变量
src/invariant.ts:5 import + src/invariant.ts:13 inject(['invariants']) + src/invariant.ts:129 register
dsh-llmE1
复用工具/内容块/调用 id 类型并构造消息与错误
src/index.ts:11-12 import + src/ptc.ts:10 createUserMessage/HarnessError
dsh-sandbox-policyE1
引入沙箱策略服务的上下文类型合并
src/index.ts:18 import type {} (声明合并)
dsh-scopeE1+E2
以作用域层存储工具注册与呈现模式
src/index.ts:9-10 import + src/index.ts:833 new ScopedLayers
dsh-sessionE1+E2
复用会话消息类型并在 invariant 中读取会话校验工具调用
src/index.ts:14 import type UserMessage + src/invariant.ts:4 + src/invariant.ts:121 inject(['sessions']) + src/invariant.ts:77 ctx.sessions
dsh-system-promptE1+E2
向提示装配注册 tool-schema provider 与 SDK/折叠 section
src/index.ts:16 import type + src/index.ts:808 inject(['systemPrompt']) + src/index.ts:854 ctx.systemPrompt.tools
dsh-user-approvalE1+E2
可选消费审批服务以处理升级请求
src/index.ts:21 import type + src/index.ts:947,1731 ctx.get('approval')

④ 被依赖(dependents · 下游消费者)

dsh-agent-instructions
从成功的 read/write/edit 工具结果中提取 file_path,把被触及路径转成指令刷新线索
src/index.ts:18 import type ToolExecution/ToolExecutionResult/ToolExecutionToken + src/index.ts:343 ctx.on('tools/result')
dsh-agent-loop
调度工具调用执行流水线
src/index.ts:29 import + src/tool-calls.ts:17 + src/index.ts:331 inject(['tools'])
dsh-agent-preset-registry
预设重绑后通知工具目录变更
src/index.ts:11 type import + src/index.ts:308 this.owner.emit('tools/change')
dsh-agent-tool-presentation
在 scope 上声明该组合的工具呈现模式
package.json:33 peerDep + src/index.ts:23 import type + src/index.ts:35 inject(['tools']) + src/index.ts:64 ctx.tools.presentAs
dsh-client-ui-chat
工具调用节点与调用树
src/client/conversation-nodes/tool.ts:7 + src/client/model/tool-call-tree.ts:2
dsh-client-ui-plan
工具结果类型
src/client/plan-definition.ts:2 import type
dsh-client-ui-tool
复用工具类型(todo 历史)
src/client/tool/models/todo-history.ts:2 import type
dsh-client-ui-trajectory
工具类型用于工具轨迹定义
src/client/trajectory-tool-definition.ts:6 import type
dsh-cordis-host-runner
动态包经 harness 注册的工具须落入 tools 注册表
src/index.ts:130 static inject ['tools'] + src/guard.ts:19 import
dsh-experimental-auto-review
在工具执行前介入并返回 allow/deny/ask/cancel 决策
src/index.ts:32 import RUN_CODE_NAME/PreToolDecision + src/index.ts:126 inject 'tools' + src/index.ts:686 tools/pre-execute
dsh-experimental-browser-use-chrome-devtools-mcp
把 MCP 工具注册进工具注册表
src/index.ts:11 inject ['browserUse','agents','tools','systemPrompt']
dsh-experimental-browser-use-playwright-mcp
把 MCP 工具注册进工具注册表
src/index.ts:12 inject ['browserUse','agents','tools','systemPrompt']
dsh-experimental-browser-use-stagehand-native
注册浏览器工具并接管其执行信号
src/index.ts:19 import type {} + src/index.ts:25 inject + src/index.ts:179 tools.register + src/index.ts:192 tools/execute
dsh-experimental-computer-use-cua-driver-mcp
MCP 工具注册进工具注册表的前提服务
src/index.ts:17 inject ['computerUse','tools']
dsh-experimental-computer-use-cua-driver-native
注册原生工具并接管其执行信号
src/index.ts:14 import type {} from '@deepseek-ai/dsh-tools' + src/index.ts:20 inject 'tools' + src/index.ts:117 tools.register + src/index.ts:119 tools/execute
dsh-experimental-tool-agent-team
注册模型可见工具并声明输出 schema
src/index.ts:8-9 import defineTool/InferValue + src/index.ts:14 inject 'tools' + src/index.ts:175 tools.register
dsh-file-reference-local
仅在 read 工具存在时展示 @ 提示词,并在工具结果后使工作区索引失效
src/index.ts:14 type-only import + src/index.ts:73 agent.ctx.tools.get('read', agent) + src/index.ts:98 ctx.on('session/event') tool-result invalidate
dsh-hooks-claude-code
在工具执行前后拦截点运行 hook 并映射为工具决策
src/index.ts:26 import (PostToolDecision, PreToolDecision, ToolExecution, ToolExecutionResult) + src/index.ts:244 ctx.on('tools/pre-execute') + src/index.ts:253 ctx.on('tools/post-execute')
dsh-hooks-codex
在工具执行前后拦截点运行 hook 并映射为工具决策
src/index.ts:29 import (PostToolDecision, PreToolDecision, ToolExecution, ToolExecutionResult) + src/index.ts:231 ctx.on('tools/pre-execute') + src/index.ts:240 ctx.on('tools/post-execute')
dsh-mcp-client
把发现的 MCP 工具注册进 harness 工具运行时
src/index.ts:24 type import + src/index.ts:34 inject 'tools' + src/tools.ts:150 ctx.tools.register
dsh-mcp-resources
注册并注销三条共享资源工具
src/tools.ts:8 import defineTool + src/index.ts:49 static inject ['tools'] + src/tools.ts:33 ctx.tools.register
dsh-plan-mode
注册常驻的 exit_plan_mode 工具
src/index.ts:33 import defineTool + src/index.ts:177 inject 'tools' + src/index.ts:278 ctx.tools.register
dsh-plugin-manager
注册面向模型的 plugin_manager 工具
src/tools.ts:9 + src/tools.ts:13 inject 'tools' + src/tools.ts:19 ctx.tools.register
dsh-repeat-tool-reminder
订阅工具执行后瀑布点以观察重复调用并附加提醒
src/index.ts:22 import (PostToolDecision, ToolExecution) + src/index.ts:220 ctx.on('tools/post-execute')
dsh-schedule
用 defineTool 向 agent 作用域注册四个 schedule 工具
src/tools.ts:9-10 import + src/index.ts:101 static inject
dsh-session-checkpoint-policy
在工具执行边界做检查点并复用中止错误码
src/index.ts:10 import + src/index.ts:18 static inject + src/index.ts:70 tools/execute
dsh-shell-env
按一次工具执行上下文解析并贡献环境变量
src/index.ts:16 import type { ToolExecution }; package.json:34 peerDep
dsh-spill-policy
挂载工具结果后处理与 PTC dispatch 日志的 token 保留策略
package.json:39 peerDep + src/index.ts:14 import type + src/index.ts:33 inject['tools'] + src/index.ts:133,152 events
dsh-subagent
校验输出 schema、工具过滤与判定标准 send_message 工具
src/index.ts:38 (import assertObjectJsonSchema) + src/types.ts:16 (import type ObjectJsonSchema,ToolRestriction) + src/continuation.ts:179 (ctx.get('tools')?.get('send_message'))
dsh-tool-ask-user
注册模型可用工具
package.json:31 peerDep + src/index.ts:10 import defineTool; src/index.ts:19 ctx.tools.register
dsh-tool-bash
注册 bash 工具定义并消费工具运行上下文
src/index.ts:18-19 import defineTool/TOOL_ABORTED; src/index.ts:34 inject ['tools']; src/index.ts:540 ctx.tools.register
dsh-tool-bash-persistent
注册持久 bash 工具定义
src/index.ts:13 import defineTool; src/index.ts:441 inject ['tools']; src/index.ts:413 ctx.tools.register
dsh-tool-call-timeout-policy
包装工具执行瀑布点并读取工具声明的超时预算
src/index.ts:16 import ToolExecutionResult + src/index.ts:31 inject ['tools'] + src/index.ts:56-57 ctx.on('tools/execute') + ctx.tools.get
dsh-tool-cordis
defineTool 注册工具并用 ctx.tools 读取 Agent 可见 schema
src/index.ts:10 inject ['tools','cordisInspect'] + src/index.ts:5 import
dsh-tool-fs
通过工具注册表发布文件系统工具
src/index.ts:22 inject ['tools','fs','systemPrompt'] + src/read.ts:8 import
dsh-tool-fs-search
通过工具注册表发布 glob/grep 工具
src/index.ts:70 inject ['tools','systemPrompt','subprocess'] + src/search-core.ts:30 import
dsh-tool-goal
以 defineTool 定义并注册三个目标工具
src/index.ts:19-20 import (defineTool, GenericCallView) + src/index.ts:29 inject ['agents','goals','tools','systemPrompt','sessionProjections'] + src/index.ts:195 ctx.tools.register
dsh-tool-jobs
以上游工具定义注册三个作业控制工具并挂接 tools/pre-execute 拦截
src/index.ts:16 import defineTool + src/index.ts:31 inject tools + src/index.ts:310 ctx.tools.register
dsh-tool-lsp
定义并注册 lsp 工具与其输出 schema/渲染
src/index.ts:15 import defineTool + src/index.ts:47 inject 'tools' + src/index.ts:109 ctx.tools.register
dsh-tool-present
注册工具并订阅 tools/result
src/index.ts:5 import defineTool + src/index.ts:26 inject ['tools','fs','sessionProjections'] + src/index.ts:38 ctx.tools.register
dsh-tool-pwsh
注册 pwsh 工具定义并消费工具运行上下文
src/index.ts:27-28 import defineTool/TOOL_ABORTED; src/index.ts:50 inject ['tools']; src/index.ts:593 ctx.tools.register
dsh-tool-pwsh-persistent
注册持久 pwsh 工具定义
src/index.ts:15 import defineTool; src/index.ts:453 inject ['tools']; src/index.ts:425 ctx.tools.register
dsh-tool-ralph
注册 ralph 工具定义与结果呈现
package.json:34 peerDep + src/index.ts:13 import { defineTool } + src/index.ts:18 static inject ['tools','workflowEngine','subagents','systemPrompt'] + src/index.ts:410 ctx.tools.register
dsh-tool-session-query
注册工具定义并消费工具运行上下文
src/index.ts:10 import; src/index.ts:19 inject ['tools']; src/index.ts:65 ctx.tools.register; src/operations.ts:18 import ToolRunContext
dsh-tool-skill
注册 skill 工具并据其在当前 agent 的可见性决定是否发布技能目录
package.json:33 peerDep + src/index.ts:11 import + src/index.ts:25 inject['tools'] + src/index.ts:161 ctx.tools.register + src/index.ts:220 ctx.tools.get
dsh-tool-str-replace-editor
通过工具注册表发布 str_replace_editor
src/index.ts:503 inject ['tools','fs'] + src/index.ts:15 defineTool import
dsh-tool-subagent
注册委派工具定义
src/index.ts:14 (import defineTool) + src/index.ts:45 (inject ['tools']) + src/index.ts:379 (runtimeCtx.tools.register)
dsh-tool-subagent-control
注册控制与发现工具
src/index.ts:14 (import defineTool) + src/index.ts:21 (inject ['tools','subagents']) + src/index.ts:28 (ctx.tools.register) + src/list-agents.ts:86 (ctx.tools.register)
dsh-tool-terminal
注册工具定义与 schema
package.json:39 peerDep + src/index.ts:14-15 import defineTool + src/index.ts:28 inject ['tools']
dsh-tool-todo
注册 todo_write 工具
package.json:48 peerDep + src/index.ts:12 import defineTool + src/index.ts:23 inject ['tools']
dsh-tool-web
通过 ctx.tools 注册 web_search/web_fetch 工具定义(含 schema、render、presentationMeta)
package.json:33 peerDep + src/fetch.ts:11 import defineTool + src/index.ts:24 static inject ['tools','web','systemPrompt']
dsh-tool-workflow
注册 workflow 工具定义与呈现
package.json:47 peerDep + src/index.ts:17 import { defineTool } + src/index.ts:41 static inject ['tools','workflowEngine','systemPrompt'] + src/index.ts:328 ctx.tools.register
dsh-tool-workspace-dependencies
向工具注册表注册其读路径查询工具
package.json:29 peerDep + src/index.ts:7 import + src/index.ts:12 inject['tools'] + src/index.ts:249 ctx.tools.register
dsh-workflow-ptc
校验 agent() 的结构化输出 schema 是否在支持子集内
package.json:35 peerDep + src/host.ts:9 import { assertObjectJsonSchema } + src/runtime.ts:12 import { assertObjectJsonSchema, JsonSchemaError }
dsh-workspace-changes
在工具执行前捕获文件编辑以覆盖 git 未跟踪路径
src/index.ts:17 import type {} from '@deepseek-ai/dsh-tools' + src/index.ts:156 tools/pre-execute