dsh-team-control 0.2.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +21 -21
  2. package/index.js +215 -141
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -4,53 +4,53 @@
4
4
 
5
5
  - 编排内核仍在 sidecar 进程里([`../src/`](../src/)),本插件只做**适配 + 生命周期**,不重写调度/事件流。
6
6
  - 零第三方依赖:只用 Node 内置模块;工具以普通 `ToolDefinition` 对象注册(JSON Schema 参数),不依赖 `defineTool`。
7
- - 14 个工具:`team_create` `team_spawn` `team_member` `team_preset` `team_models` `team_status` `team_task` `team_send` `team_todo` `team_report_task` `team_dispatch` `team_approve` `team_control` `team_report`。
7
+ - 14 个工具:`dsh_team_create` `dsh_team_spawn` `dsh_team_member` `dsh_team_preset` `dsh_team_models` `dsh_team_status` `dsh_team_task` `dsh_team_send` `dsh_team_todo` `dsh_team_report_task` `dsh_team_dispatch` `dsh_team_approve` `dsh_team_control` `dsh_team_report`。
8
8
 
9
9
  ## 调用顺序写在哪(别让模型自己摸)
10
10
 
11
- - 14 个工具里**只有 `team_create` 标了 `START HERE`**:它的 description 直接给出 5 步顺序、`permissionPreset` 的语义、
12
- 以及 `teamId` 取自 `result.team.id`;`team_spawn` 写明返回的 `member.id` 就是后面 `assignee` 要的值;
13
- `team_task` 写明简报必须自包含(成员看不到 Lead 的对话)。模型只看工具面就能按序走。
11
+ - 14 个工具里**只有 `dsh_team_create` 标了 `START HERE`**:它的 description 直接给出 5 步顺序、`permissionPreset` 的语义、
12
+ 以及 `teamId` 取自 `result.team.id`;`dsh_team_spawn` 写明返回的 `member.id` 就是后面 `assignee` 要的值;
13
+ `dsh_team_task` 写明简报必须自包含(成员看不到 Lead 的对话)。模型只看工具面就能按序走。
14
14
  - 完整配方(字段陷阱、拆任务与并发、症状→修法表)在 skill **`dsh-agent-team`**:[`../skills/dsh-agent-team/SKILL.md`](../skills/dsh-agent-team/SKILL.md)。
15
- 本插件启动时把这个目录注册成 skills provider(`name: 'dsh-team'`,rank 600),**装上插件即出现在会话技能目录**,无需 cp;`team_create` 描述末尾也指向它。
15
+ 本插件启动时把这个目录注册成 skills provider(`name: 'dsh-team'`,rank 600),**装上插件即出现在会话技能目录**,无需 cp;`dsh_team_create` 描述末尾也指向它。
16
16
 
17
17
  ## 成员 = 真 DSH sub-agent
18
18
 
19
- `team_spawn` 用 `subagents.startActivation` 拉起一个子会话,成员用自己的模型与工具干活;sidecar 只做任务/DAG/审批/看板:
19
+ `dsh_team_spawn` 用 `subagents.startActivation` 拉起一个子会话,成员用自己的模型与工具干活;sidecar 只做任务/DAG/审批/看板:
20
20
 
21
- 1. `team_spawn` → 解析并下发权限预设、解析 `agentPreset` → `subagents.startActivation({delivery:'parent', childId, provider, label, request:{prompt, parent, cwd: team.workspace, agentOptions?, agentPreset?}})` → 把子会话 id 作为 `sessionId` `POST /api/agents/register`,成员出现在看板上。
21
+ 1. `dsh_team_spawn` → 解析并下发权限预设、解析 `agentPreset` → `subagents.startActivation({delivery:'parent', childId, provider, label, request:{prompt, parent, cwd: team.workspace, agentOptions?, agentPreset?}})` → 把子会话 id 作为 `sessionId` `POST /api/agents/register`,成员出现在看板上。
22
22
  2. 建任务/依赖满足 → 插件调度器(`agentDispatchMs`,默认 1.5s 一跳)调 `POST /api/agents/dispatch` **原子认领**一条 ready 任务 → `subagents.sendMessage(lead, sessionId, [{type:'text', text: 任务简报}])` 把任务发进该成员的信箱。
23
- 3. 成员干完 → 自己调 `team_report_task`(精确摘要/成败,`/api/agents/report`),或由 `agent/status` 事件在回合结束时兜底收尾(`/api/agents/status`)。
23
+ 3. 成员干完 → 自己调 `dsh_team_report_task`(精确摘要/成败,`/api/agents/report`),或由 `agent/status` 事件在回合结束时兜底收尾(`/api/agents/status`)。
24
24
  4. 成员报 `blocked` 时任务退回 `blocked`(**不消耗重试**),阻塞原因进 `blockers` 与 `/api/blockers`。
25
25
  5. 成员的 session 工具调用由 `tools/execute` 上报为 span;sidecar 用 `member.agent_session_id` 把这些 span 挂到成员节点下。
26
26
 
27
- `team_control`:`interrupt` 先落库 `interrupted` 并把在途任务转 `paused`(不计 attempts、不自动重派),然后 `subagents.interrupt` 中止成员当前回合;`resume` 重新武装;`assign` 把 `paused`/ready 任务交给 idle 成员;`abort` 把任务永久置为 `aborted` 终态(不重试)。面板的团队/看板停止另有 `forceStopPump`:轮询到成员刚变为 `interrupted` 后,用持久化的 `parentSessionId` 以 `{kind:'user'}` 授权真正中断其会话,并冻结到 resume。
27
+ `dsh_team_control`:`interrupt` 先落库 `interrupted` 并把在途任务转 `paused`(不计 attempts、不自动重派),然后 `subagents.interrupt` 中止成员当前回合;`resume` 重新武装;`assign` 把 `paused`/ready 任务交给 idle 成员;`abort` 把任务永久置为 `aborted` 终态(不重试)。面板的团队/看板停止另有 `forceStopPump`:轮询到成员刚变为 `interrupted` 后,用持久化的 `parentSessionId` 以 `{kind:'user'}` 授权真正中断其会话,并冻结到 resume。
28
28
 
29
29
  ## 权限:Leader 按成员分配 DSH 权限预设
30
30
 
31
31
  插件**不做权限判定**,也不碰文件/进程/网络。每个成员启动时用宿主的 `permissionPresets.set(session, name)` 下发预设:
32
32
 
33
- - `team_create.permissionPreset`:团队默认值(默认 `workspace-write`)。
34
- - `team_spawn.permissionPreset`:成员覆盖;不传则继承团队。
33
+ - `dsh_team_create.permissionPreset`:团队默认值(默认 `workspace-write`)。
34
+ - `dsh_team_spawn.permissionPreset`:成员覆盖;不传则继承团队。
35
35
  - 返回值里的 `permissionPresetApplied` 表示是否真的写进子会话;宿主没有这个服务或预设名未知时给 `permissionPresetWarning`,不阻断派发。
36
- - `team_member({action:"update", permissionPreset})` 可对 **运行中** 的成员热改权限(直接 `permissionPresets.set`,无需 interrupt);换模型/上下文/组合仍要求先 `interrupt`。
36
+ - `dsh_team_member({action:"update", permissionPreset})` 可对 **运行中** 的成员热改权限(直接 `permissionPresets.set`,无需 interrupt);换模型/上下文/组合仍要求先 `interrupt`。
37
37
 
38
38
  `agentPreset` 是另一套(组合:工具/skill/MCP + 系统提示词):团队默认 + 成员覆盖,用宿主 `agentPresets.list()` 校验;
39
39
  只在 `contextMode: 'fresh'` 时透传给 `startActivation`,`fork` 继承父方组合并返回 `agentPresetWarning`。
40
40
 
41
- 内置预设不够用时,`team_preset({action:"save", id, plugins})` 把组合写到 `~/.dsh/team/presets/<id>.json`
41
+ 内置预设不够用时,`dsh_team_preset({action:"save", id, plugins})` 把组合写到 `~/.dsh/team/presets/<id>.json`
42
42
  (`presetDir` / `DSH_TEAM_PRESET_DIR` 可改)并立刻 `agentPresets.register()`,无需重启;插件启动时会重新加载该目录。
43
43
  `list` 会标出 `host`/`team` 来源,`show` 可读回文档,`delete` 删团队自建;宿主内置 id 不允许覆盖。
44
- - 预设名在 `team_create` / `team_spawn` 时按宿主 `names` 校验,错误信息带可用预设列表。
44
+ - 预设名在 `dsh_team_create` / `dsh_team_spawn` 时按宿主 `names` 校验,错误信息带可用预设列表。
45
45
 
46
- ## 审批:成员 → Lead 的 `team_approve`
46
+ ## 审批:成员 → Lead 的 `dsh_team_approve`
47
47
 
48
48
  成员触发的宿主审批不会静默失败,而是转发给 Lead:
49
49
 
50
50
  1. 全局监听 `approval/request`;请求的 agent 不属于任何团队成员 → 交给后面的 handler(`next()`)。
51
51
  2. 属于成员 → 先做低风险判定:`tools/pre-execute` 按 `callId` 缓存入参,若工具名像 shell、参数带字符串 `command`,且命令是白名单程序、无管道/重定向/命令替换、不命中敏感规则 → 直接返回 `allowed-once` 并镜像 `decidedBy:"auto"`,不通知 Lead。
52
- 3. 其余请求 → `POST /api/approvals` 镜像一条 pending,并 `subagents.sendMessage` 通知 Lead,文本含 `requestId`、成员、工具、原因与 `team_approve` 调用示例。
53
- 4. Lead 调 `team_approve {teamId, requestId, decision: allow|deny, reason?}` → 插件 resolve 为 `allowed-once` / `rejected`,同时把 sidecar 记录改成 allowed/rejected。
52
+ 3. 其余请求 → `POST /api/approvals` 镜像一条 pending,并 `subagents.sendMessage` 通知 Lead,文本含 `requestId`、成员、工具、原因与 `dsh_team_approve` 调用示例。
53
+ 4. Lead 调 `dsh_team_approve {teamId, requestId, decision: allow|deny, reason?}` → 插件 resolve 为 `allowed-once` / `rejected`,同时把 sidecar 记录改成 allowed/rejected。
54
54
  5. 超过 `approvalTimeoutMs`(默认 10 分钟)自动拒绝并标记 expired;成员回合被取消时按 cancelled 处理。
55
55
 
56
56
  ## 模型路由(每个成员不同的 provider / model / effort)
@@ -59,8 +59,8 @@
59
59
  插件把这份映射快照 `POST /api/llm/catalog` 给 sidecar(30s 节流,`llm/adapters-updated` 事件会重置节流);
60
60
  sidecar 只存映射、启用开关和备注,**不代理 LLM 请求、不保存凭据**。
61
61
 
62
- - 面板「模型路由」页:按 provider 分组,逐条启用/停用、写备注;停用项不会出现在 `team_models` 里。
63
- - `team_spawn`:`agentProvider` + `model` 指定 LLM route;`reasoningEffort` 是 adapter 定义的不透明 id。
62
+ - 面板「模型路由」页:按 provider 分组,逐条启用/停用、写备注;停用项不会出现在 `dsh_team_models` 里。
63
+ - `dsh_team_spawn`:`agentProvider` + `model` 指定 LLM route;`reasoningEffort` 是 adapter 定义的不透明 id。
64
64
  实际生效的 route 必须在启用集合里,否则报「模型路由未启用 / 所有模型路由都已停用」。
65
65
  - 实际生效值写进 `request.agentOptions`,返回值 `agent.route` 与 sidecar 成员记录的 `model` 用真实 model id。
66
66
 
@@ -70,7 +70,7 @@ sidecar 只存映射、启用开关和备注,**不代理 LLM 请求、不保
70
70
  dsh plugin --profile web add dsh-team-control
71
71
  ```
72
72
 
73
- 装完重启 DSH,工具面出现 14 个 `team_*` 工具;`autoStart` 会自己拉起 sidecar。
73
+ 装完重启 DSH,工具面出现 14 个 `dsh_team_*` 工具;`autoStart` 会自己拉起 sidecar。
74
74
  本地开发也可以按绝对路径装:`plugin_manager(action: "install_bundle", target: "<repo>/dsh-plugin")`。
75
75
  卸载:`dsh plugin --profile web remove dsh-team-control`。
76
76
 
@@ -109,7 +109,7 @@ dsh plugin --profile web add dsh-team-control
109
109
  | `freshProvider` | `spawn` | `subagents.startActivation` 的 provider(`context: fresh`) |
110
110
  | `forkProvider` | `fork` | `subagents.startActivation` 的 provider(`context: fork`) |
111
111
 
112
- > 上报采用「会话 → 团队」绑定:任意一次带 `teamId` 的 `team_*` 调用、或 `team_create` 成功后,该会话后续的
112
+ > 上报采用「会话 → 团队」绑定:任意一次带 `teamId` 的 `dsh_team_*` 调用、或 `dsh_team_create` 成功后,该会话后续的
113
113
  > 工具调用都会挂到对应团队;未绑定团队的工具调用直接丢弃。
114
114
 
115
115
  > 本插件**不导出 `Config` schema**,`Config.listConfigs` 的 `status` 是 `absent`;代码侧已做默认值兜底。
package/index.js CHANGED
@@ -84,7 +84,7 @@ function resolveConfig(config) {
84
84
  forceStopPollMs: Number(c.forceStopPollMs) || 1000,
85
85
  // 任务投递后成员会话迟迟没有任何事件(模型路由报错、会话没启动)就判定失败并交回 sidecar 重试
86
86
  agentStartTimeoutMs: Number(c.agentStartTimeoutMs) || 120000,
87
- // 成员触发权限审批(permission preset 的 approval=ask)后,等待 Lead 调 team_approve 的上限
87
+ // 成员触发权限审批(permission preset 的 approval=ask)后,等待 Lead 调 dsh_team_approve 的上限
88
88
  approvalTimeoutMs: Number(c.approvalTimeoutMs) || 600000,
89
89
  // 审批降噪:命令明确是「已知安全程序 + 无重定向/命令替换/脚本块」时直接 allowed-once,
90
90
  // 不打扰 Lead;敏感命令(见 DEFAULT_SENSITIVE_COMMAND_PATTERNS)仍转 Lead 审批
@@ -201,10 +201,10 @@ const qs = (obj) => {
201
201
  // (spawnTeammate / sendMessage / interrupt)和派发,因为只有 Host 进程能创建 DSH agent。
202
202
  //
203
203
  // 流程:
204
- // team_spawn(runtime=agent)→ spawnTeammate → POST /api/agents/register 绑定 session
205
- // team_task 建任务 → sidecar 置 ready → POST /api/agents/dispatch 原子认领(running)
204
+ // dsh_team_spawn(runtime=agent)→ spawnTeammate → POST /api/agents/register 绑定 session
205
+ // dsh_team_task 建任务 → sidecar 置 ready → POST /api/agents/dispatch 原子认领(running)
206
206
  // → sendMessage(lead → member) 把任务说明投进成员信箱
207
- // 成员跑完 → team_report_task(精确摘要)/ agent/status=idle(兜底)→ 任务 done → evaluate 推进依赖
207
+ // 成员跑完 → dsh_team_report_task(精确摘要)/ agent/status=idle(兜底)→ 任务 done → evaluate 推进依赖
208
208
  // → 再跑一轮 dispatch,把新 ready 的任务投给 idle 成员
209
209
 
210
210
  /** teamId → 最近一次调用 team_* 工具的 Lead Agent(发消息必须由 live Lead 发出)。 */
@@ -232,6 +232,83 @@ const subagentsOf = (ctx) => { try { return ctx.get('subagents'); } catch { retu
232
232
  const agentsOf = (ctx) => { try { return ctx.get('agents'); } catch { return undefined; } };
233
233
  const subagentNames = (ctx) => { const svc = subagentsOf(ctx); return svc && typeof svc.list === 'function' ? svc.list() : []; };
234
234
 
235
+ /**
236
+ * 原生 agent 消息工具:DSH 0.2.2 起把「给另一个 agent 发消息」收敛成工具,
237
+ * 工具名是下划线版 `send_message`;连字符 `send-message` 作为别名一起探测,防止宿主改名。
238
+ */
239
+ const NATIVE_SEND_TOOLS = ['send_message', 'send-message'];
240
+ const toolsOf = (ctx) => ctx?.tools || (() => { try { return ctx.get('tools'); } catch { return undefined; } })();
241
+
242
+ /**
243
+ * 探测宿主是否提供原生消息工具(高版本 DSH),返回 `{ tools, name }`。
244
+ *
245
+ * 查可见性时要带发送者作用域:工具可能注册在 agent preset 的 scope 里,只查全局会漏;
246
+ * 低版本没有这个工具(或没有 `tools.execute`)时返回 undefined,调用方继续走 `subagents.sendMessage`。
247
+ */
248
+ function nativeSendTools(ctx, sender) {
249
+ const tools = toolsOf(ctx);
250
+ if (!tools || typeof tools.get !== 'function' || typeof tools.execute !== 'function') return undefined;
251
+ for (const name of NATIVE_SEND_TOOLS) {
252
+ try {
253
+ if (tools.get(name, sender)) return { tools, name };
254
+ } catch { /* 查不到就继续试下一个名字 */ }
255
+ }
256
+ return undefined;
257
+ }
258
+
259
+ /** 还有没有可用的投递通道:原生工具,或低版本的 `subagents.sendMessage`。 */
260
+ function canDeliverTo(ctx, sender) {
261
+ if (!sender) return false;
262
+ if (nativeSendTools(ctx, sender)) return true;
263
+ const subs = subagentsOf(ctx);
264
+ return !!subs && typeof subs.sendMessage === 'function';
265
+ }
266
+
267
+ /**
268
+ * 把一条文本消息投进某个 agent 会话(成员与 Lead 一视同仁)。
269
+ *
270
+ * - 高版本 DSH 提供原生 `send_message` 工具:走工具层调用,接收方由宿主 `resolveName` 解析
271
+ * (传 sessionId 时它会被原样当作会话 id),消息来源标记、空闲唤醒、后续语义变化都交给宿主;
272
+ * - 低版本没有该工具:保持原来的 `subagents.sendMessage(sender, sessionId, content, { signal })`。
273
+ *
274
+ * `sender` 必须是精确的活跃 Agent(两代实现都这么要求),调用方负责从 `agents` 注册表或缓存的
275
+ * Lead 句柄里取。
276
+ */
277
+ async function sendAgentMessage(ctx, sender, targetSessionId, text, opts = {}) {
278
+ const native = nativeSendTools(ctx, sender);
279
+ if (native) {
280
+ const callId = `team-send-${randomUUID()}`;
281
+ const batch = await native.tools.execute({
282
+ calls: [{
283
+ type: 'tool-call',
284
+ id: callId,
285
+ name: native.name,
286
+ arguments: JSON.stringify({ agent: String(targetSessionId), message: String(text) }),
287
+ }],
288
+ signal: opts.signal || AbortSignal.timeout(60000),
289
+ agent: sender,
290
+ });
291
+ const results = Array.isArray(batch?.results) ? batch.results : [];
292
+ const result = (results.find((r) => r && r.callId === callId) || results[0])?.result;
293
+ if (!result) throw new Error('send_message 工具没有返回执行结果');
294
+ if (result.isError) {
295
+ const failure = result.error || {};
296
+ throw new Error(`send_message 工具投递失败:${failure.message || failure.code || '未知错误'}`);
297
+ }
298
+ const messageId = result.value && result.value.messageId;
299
+ return { via: 'tool', messageId: messageId != null ? String(messageId) : undefined };
300
+ }
301
+ const subs = subagentsOf(ctx);
302
+ if (!subs || typeof subs.sendMessage !== 'function') throw new Error('subagents 服务不可用,无法投递消息');
303
+ const messageId = await subs.sendMessage(
304
+ sender,
305
+ String(targetSessionId),
306
+ [{ type: 'text', text: String(text) }],
307
+ opts.signal ? { signal: opts.signal } : {},
308
+ );
309
+ return { via: 'service', messageId: messageId != null ? String(messageId) : undefined };
310
+ }
311
+
235
312
  /** `sessions` / `workspaceChanges`:读成员自己会话里的交付文件(都是可选依赖)。 */
236
313
  const sessionsOf = (ctx) => { try { return ctx.get('sessions'); } catch { return undefined; } };
237
314
  const workspaceChangesOf = (ctx) => { try { return ctx.get('workspaceChanges'); } catch { return undefined; } };
@@ -584,7 +661,7 @@ function activationSpec(request, base) {
584
661
  // ---------- 模型路由:DSH ctx.llm 目录 → sidecar 映射 ----------
585
662
  //
586
663
  // 目录的唯一来源是 Host 的 ctx.llm;这里只把 provider/model 的映射、展示名和
587
- // 模态同步给 sidecar。sidecar 保存用户勾选的子集与备注,team_spawn 只接受
664
+ // 模态同步给 sidecar。sidecar 保存用户勾选的子集与备注,dsh_team_spawn 只接受
588
665
  // 启用项。本插件不代理 LLM 请求、不保存任何凭据。
589
666
  const llmOf = (ctx) => { try { return ctx.get('llm'); } catch { return undefined; } };
590
667
 
@@ -613,7 +690,7 @@ async function effortsOfRoute(llm, provider, model) {
613
690
  ]);
614
691
  const reasoning = info && info.reasoning;
615
692
  if (!reasoning || !Array.isArray(reasoning.efforts)) return undefined;
616
- // 「off」等于关思考,不是可派发的强度:既不进面板胶囊,也不进 team_models,
693
+ // 「off」等于关思考,不是可派发的强度:既不进面板胶囊,也不进 dsh_team_models,
617
694
  // 否则用户能「允许派发 off」而实际语义相反。
618
695
  const efforts = reasoning.efforts
619
696
  .filter((e) => e && e.id && String(e.id) !== 'off')
@@ -677,7 +754,7 @@ async function syncLlmCatalog(s, ctx) {
677
754
  }
678
755
  }
679
756
  // 只上报真正能列出模型的 provider;没模型的(含未配置的 dormant)不进目录,
680
- // 面板与 team_models 就不会出现空分组。
757
+ // 面板与 dsh_team_models 就不会出现空分组。
681
758
  const withModels = providers.filter((p) => models.some((m) => m.provider === p.id));
682
759
  if (!withModels.length) return { ok: true, providers: 0, models: 0, empty: true };
683
760
  await request(s, '/api/llm/catalog', { method: 'POST', body: { providers: withModels, models, partial } });
@@ -711,15 +788,15 @@ async function assertRouteEnabled(s, ctx, provider, model, effort = null) {
711
788
  // `no adapter registered for provider "glm-5.3"`,白起一轮;这里提前拦。
712
789
  const owners = [...new Set(all.filter((m) => !model || m.model === model).map((m) => m.provider))];
713
790
  if (provider && model && owners.length && !owners.includes(provider)) {
714
- throw new Error(`agentProvider「${provider}」不是模型「${model}」所属的 provider:应填 ${owners.join(' 或 ')}。agentProvider 要的是 provider id(见 team_models),不是模型名。`);
791
+ throw new Error(`agentProvider「${provider}」不是模型「${model}」所属的 provider:应填 ${owners.join(' 或 ')}。agentProvider 要的是 provider id(见 dsh_team_models),不是模型名。`);
715
792
  }
716
793
  return;
717
794
  }
718
795
  const enabled = all.filter((m) => m.enabled);
719
- if (!enabled.length) throw new Error('所有模型路由都已停用:请先在面板「模型路由」页启用,或调用 team_models 查看。');
796
+ if (!enabled.length) throw new Error('所有模型路由都已停用:请先在面板「模型路由」页启用,或调用 dsh_team_models 查看。');
720
797
  if (!known.some((m) => m.enabled)) {
721
798
  const sample = enabled.slice(0, 8).map((m) => `${m.provider}/${m.model}`).join(', ');
722
- throw new Error(`模型路由未启用:${[provider, model].filter(Boolean).join('/')}。可用(前 8 条):${sample}。完整列表见 team_models,或在面板「模型路由」页启用。`);
799
+ throw new Error(`模型路由未启用:${[provider, model].filter(Boolean).join('/')}。可用(前 8 条):${sample}。完整列表见 dsh_team_models,或在面板「模型路由」页启用。`);
723
800
  }
724
801
  // effort 闸门:只有该 route 声明了 efforts 才校验;allowedEfforts=null 表示全部允许。
725
802
  if (!effort) return;
@@ -752,14 +829,14 @@ function rememberMember(sessionId, teamId, memberId, cwd, permissionPreset = nul
752
829
 
753
830
  async function teamOf(s, teamId, { refresh = false, sessionId = null } = {}) {
754
831
  // 模型偶尔会漏掉必填的 teamId。先显式挡住,避免 /api/teams/undefined 被误报成「团队不存在」;
755
- // 同一会话内 team_create 过的团队可以直接兜底(DSH 对直接注册的工具不做 required 运行时校验)。
832
+ // 同一会话内 dsh_team_create 过的团队可以直接兜底(DSH 对直接注册的工具不做 required 运行时校验)。
756
833
  const missing = teamId == null || String(teamId).trim() === '' || String(teamId) === 'undefined' || String(teamId) === 'null';
757
834
  if (missing && sessionId) {
758
835
  const bound = sessionMember.get(String(sessionId))?.teamId || teamBySession.get(String(sessionId));
759
836
  if (bound) teamId = bound;
760
837
  }
761
838
  if (teamId == null || String(teamId).trim() === '' || String(teamId) === 'undefined' || String(teamId) === 'null') {
762
- throw new Error('缺少 teamId:请把 team_create 返回的 result.team.id(形如 team_xxx)作为 teamId 参数传入后重试。');
839
+ throw new Error('缺少 teamId:请把 dsh_team_create 返回的 result.team.id(形如 team_xxx)作为 teamId 参数传入后重试。');
763
840
  }
764
841
  const key = String(teamId);
765
842
  if (!refresh && teamCache.has(key)) return teamCache.get(key);
@@ -769,7 +846,7 @@ async function teamOf(s, teamId, { refresh = false, sessionId = null } = {}) {
769
846
  return team;
770
847
  } catch (err) {
771
848
  if (err && err.status === 404) {
772
- throw new Error(`团队不存在或 teamId 无效: ${key}(teamId 来自 team_create 返回值,请核对后重试)`);
849
+ throw new Error(`团队不存在或 teamId 无效: ${key}(teamId 来自 dsh_team_create 返回值,请核对后重试)`);
773
850
  }
774
851
  throw err;
775
852
  }
@@ -813,7 +890,7 @@ async function resolveAgentPreset(ctx, requested, fallback, store = null) {
813
890
  * 宿主默认 agentPreset 的 id。
814
891
  *
815
892
  * DSH 的 subagent 在 request 里省略 agentPreset 时,会继承父会话的实时组合
816
- * (`composeFrom(parent)`),并不会自动套用宿主默认。因此 team_spawn 必须显式
893
+ * (`composeFrom(parent)`),并不会自动套用宿主默认。因此 dsh_team_spawn 必须显式
817
894
  * 把默认预设传下去,否则成员就只能拿到 Lead 根组合里的宿主级工具(比如没有 shell)。
818
895
  */
819
896
  async function hostDefaultAgentPreset(ctx) {
@@ -835,7 +912,7 @@ async function hostDefaultAgentPreset(ctx) {
835
912
  // ---------------------------------------------------------------------------
836
913
  // Leader 自建 agentPreset
837
914
  //
838
- // 内置 preset 不满足时,Lead 用 team_preset({action:'save'}) 把一份组合定义写到固定目录,
915
+ // 内置 preset 不满足时,Lead 用 dsh_team_preset({action:'save'}) 把一份组合定义写到固定目录,
839
916
  // 并立刻调用宿主 `agentPresets.register()` 生效(无需重启 DSH)。目录里的 JSON 文档
840
917
  // (JSON 是合法 YAML)在插件启动时也会被重新注册,因此跨会话可复用。
841
918
  // ---------------------------------------------------------------------------
@@ -1073,18 +1150,17 @@ function taskBrief(teamId, task, member) {
1073
1150
  '',
1074
1151
  '执行要求:',
1075
1152
  '1) 直接在本会话里做这件事(用你自己的工具,不要委派给别的 agent)。',
1076
- '2) 每开始或完成一步、以及验收通过后,调用 team_todo 更新该任务的计划清单(teamId/taskId 同上)。',
1077
- '3) 收工前,如果这次任务产生了对后续任务可复用的结论(接口约定、坑、决策理由、未决问题),调用 team_memory_write 存一条简短 handoff(scope="member",kind="handoff",value 不超过 300 字);没有可复用结论就跳过,不要为了留记忆而写。只有 Lead 明确要求上传时才写 scope="team"。',
1078
- '4) 完成或失败后必须调用 team_report_task,例如:',
1079
- ` team_report_task({ teamId: "${teamId}", taskId: "${task.id}", status: "done", summary: "一句话结果 + 关键产物路径" })`,
1080
- '5) 需要 Lead 决策或补充信息时用 team_send(teamId 同上,to: "lead"),不要自己猜测。',
1153
+ '2) 每开始或完成一步、以及验收通过后,调用 dsh_team_todo 更新该任务的计划清单(teamId/taskId 同上)。',
1154
+ '3) 收工前,如果这次任务产生了对后续任务可复用的结论(接口约定、坑、决策理由、未决问题),调用 dsh_team_memory_write 存一条简短 handoff(scope="member",kind="handoff",value 不超过 300 字);没有可复用结论就跳过,不要为了留记忆而写。只有 Lead 明确要求上传时才写 scope="team"。',
1155
+ '4) 完成或失败后必须调用 dsh_team_report_task,例如:',
1156
+ ` dsh_team_report_task({ teamId: "${teamId}", taskId: "${task.id}", status: "done", summary: "一句话结果 + 关键产物路径" })`,
1157
+ '5) 需要 Lead 决策或补充信息时用 dsh_team_send(teamId 同上,to: "lead"),不要自己猜测。',
1081
1158
  ].join('\n');
1082
1159
  }
1083
1160
 
1084
1161
  /** 把任务投递给成员:由 Lead 发一条消息进成员信箱(running 时在最近 step 边界送达)。 */
1085
1162
  async function deliverTask(s, ctx, lead, teamId, task, member) {
1086
- const subs = subagentsOf(ctx);
1087
- if (!subs || typeof subs.sendMessage !== 'function') throw new Error('subagents 服务不可用,无法派发给 agent 成员');
1163
+ if (!canDeliverTo(ctx, lead)) throw new Error('subagents 服务不可用,无法派发给 agent 成员');
1088
1164
  if (!member.agentSessionId) throw new Error(`成员 ${member.name} 还没有绑定 sub-agent 会话`);
1089
1165
  const brief = taskBrief(teamId, task, member);
1090
1166
  // 简报本身就是一条 Lead→成员的消息:先落信箱,面板【消息与回执】才有「提问 → 回复」可配对;
@@ -1097,8 +1173,9 @@ async function deliverTask(s, ctx, lead, teamId, task, member) {
1097
1173
  });
1098
1174
  messageId = recorded?.message?.id || null;
1099
1175
  } catch { messageId = null; }
1100
- const content = [{ type: 'text', text: brief }];
1101
- await subs.sendMessage(lead, String(member.agentSessionId), content, { signal: AbortSignal.timeout(s.requestTimeoutMs) });
1176
+ await sendAgentMessage(ctx, lead, String(member.agentSessionId), brief, {
1177
+ signal: AbortSignal.timeout(s.requestTimeoutMs),
1178
+ });
1102
1179
  await markDelivered(s, messageId);
1103
1180
  }
1104
1181
 
@@ -1154,7 +1231,7 @@ async function dispatchLoop(s, ctx, teamId) {
1154
1231
  }
1155
1232
  }
1156
1233
 
1157
- // ---------- 权限审批转发:成员 preset 触发 approval/request → Lead 用 team_approve 决定 ----------
1234
+ // ---------- 权限审批转发:成员 preset 触发 approval/request → Lead 用 dsh_team_approve 决定 ----------
1158
1235
  const pendingApprovals = new Map();
1159
1236
 
1160
1237
  // 审批分类:approval/request 只带 toolName 与 callId,不带命令参数;
@@ -1306,8 +1383,7 @@ function cancelPendingApprovals() {
1306
1383
  }
1307
1384
 
1308
1385
  async function notifyLeadOfApproval(s, ctx, req, info) {
1309
- const subs = subagentsOf(ctx);
1310
- if (!subs || typeof subs.sendMessage !== 'function' || !req?.agent) return false;
1386
+ if (!req?.agent || !canDeliverTo(ctx, req.agent)) return false;
1311
1387
  const team = await teamOf(s, info.teamId);
1312
1388
  const leadId = leadByTeam.get(info.teamId)?.id != null
1313
1389
  ? String(leadByTeam.get(info.teamId).id)
@@ -1324,11 +1400,11 @@ async function notifyLeadOfApproval(s, ctx, req, info) {
1324
1400
  `requestId=${info.requestId}`,
1325
1401
  '',
1326
1402
  `成员因 permissionPreset「${info.preset || 'unknown'}」的审批策略暂停,等待你决定。`,
1327
- `批准本次操作:team_approve({ teamId: "${info.teamId}", requestId: "${info.requestId}", decision: "allow" })`,
1403
+ `批准本次操作:dsh_team_approve({ teamId: "${info.teamId}", requestId: "${info.requestId}", decision: "allow" })`,
1328
1404
  `拒绝:把 decision 改成 "deny"(可加 reason)。`,
1329
1405
  `超过 ${minutes} 分钟未决定将自动拒绝。`,
1330
1406
  ].join('\n');
1331
- await subs.sendMessage(req.agent, leadId, [{ type: 'text', text }], { signal: AbortSignal.timeout(s.requestTimeoutMs) });
1407
+ await sendAgentMessage(ctx, req.agent, leadId, text, { signal: AbortSignal.timeout(s.requestTimeoutMs) });
1332
1408
  return true;
1333
1409
  }
1334
1410
 
@@ -1344,14 +1420,13 @@ const interruptNotified = new Set();
1344
1420
  * 会话已经回收时发不出去——那种情况事件流/面板里仍有记录,不阻塞其它泵。
1345
1421
  */
1346
1422
  async function notifyLeadOfMemberInterrupt(s, ctx, info) {
1347
- const subs = subagentsOf(ctx);
1348
- if (!subs || typeof subs.sendMessage !== 'function' || !info) return false;
1423
+ if (!info) return false;
1349
1424
  const sessionId = info.sessionId != null ? String(info.sessionId) : null;
1350
1425
  const teamId = info.teamId != null ? String(info.teamId) : null;
1351
1426
  if (!sessionId || !teamId) return false;
1352
1427
  const agents = agentsOf(ctx);
1353
1428
  const sender = agents && typeof agents.get === 'function' ? agents.get(sessionId) : undefined;
1354
- if (!sender) return false;
1429
+ if (!sender || !canDeliverTo(ctx, sender)) return false;
1355
1430
  let leadId = info.leadSessionId != null ? String(info.leadSessionId) : null;
1356
1431
  if (!leadId) {
1357
1432
  const cached = leadByTeam.get(teamId);
@@ -1378,13 +1453,13 @@ async function notifyLeadOfMemberInterrupt(s, ctx, info) {
1378
1453
  ? '该成员的回合以错误结束,任务按失败重试策略处理(可能已重新派发);反复失败需要你介入。'
1379
1454
  : '该成员没有正常收工,任务不会被当成完成;中断后它需要你确认才能继续。',
1380
1455
  info.status === 'failed'
1381
- ? `下一步:team_status({ teamId: "${teamId}" }) 看进度;需要人工接手时用 team_task/team_member 调整。`
1456
+ ? `下一步:dsh_team_status({ teamId: "${teamId}" }) 看进度;需要人工接手时用 dsh_team_task/dsh_team_member 调整。`
1382
1457
  : (info.memberId
1383
- ? `下一步:team_status({ teamId: "${teamId}" }) 看进度;确认后 team_control({ teamId: "${teamId}", memberId: "${info.memberId}", action: "resume" }) 继续。`
1384
- : `下一步:team_status({ teamId: "${teamId}" }) 看进度;确认后 team_dispatch 重新派发。`),
1458
+ ? `下一步:dsh_team_status({ teamId: "${teamId}" }) 看进度;确认后 dsh_team_control({ teamId: "${teamId}", memberId: "${info.memberId}", action: "resume" }) 继续。`
1459
+ : `下一步:dsh_team_status({ teamId: "${teamId}" }) 看进度;确认后 dsh_team_dispatch 重新派发。`),
1385
1460
  ];
1386
1461
  try {
1387
- await subs.sendMessage(sender, leadId, [{ type: 'text', text: lines.join('\n') }], {
1462
+ await sendAgentMessage(ctx, sender, leadId, lines.join('\n'), {
1388
1463
  signal: AbortSignal.timeout(s.requestTimeoutMs),
1389
1464
  });
1390
1465
  return true;
@@ -1664,7 +1739,7 @@ async function forceStopPump(s, ctx) {
1664
1739
  const TODO_TO_PLAN = { pending: 'open', in_progress: 'active', completed: 'done' };
1665
1740
 
1666
1741
  /**
1667
- * 成员没用 team_todo、而是用了内置 todo_write 时,把 DSH 的 `todos` 投影镜像成 sidecar 计划。
1742
+ * 成员没用 dsh_team_todo、而是用了内置 todo_write 时,把 DSH 的 `todos` 投影镜像成 sidecar 计划。
1668
1743
  * todo_write 每次整份替换,这里也整份替换(POST /api/tasks/<taskId>/todos),
1669
1744
  * 于是「todo 完成 → 计划步骤完成」自动同步,面板与团队校验都能看到成员的真实 plan。
1670
1745
  */
@@ -1736,14 +1811,12 @@ const steerInFlight = new Set();
1736
1811
 
1737
1812
  async function steerPump(s, ctx) {
1738
1813
  if (!sessionMember.size) return;
1739
- const subs = subagentsOf(ctx);
1740
- if (!subs || typeof subs.sendMessage !== 'function') return;
1741
1814
  const teams = new Set();
1742
1815
  for (const binding of sessionMember.values()) if (binding?.teamId) teams.add(binding.teamId);
1743
1816
 
1744
1817
  for (const teamId of teams) {
1745
1818
  const caller = leadByTeam.get(teamId);
1746
- if (!caller) continue;
1819
+ if (!caller || !canDeliverTo(ctx, caller)) continue;
1747
1820
  const res = await request(
1748
1821
  s,
1749
1822
  `/api/messages${qs({ team: teamId, status: 'queued', limit: 100 })}`,
@@ -1770,7 +1843,7 @@ async function steerPump(s, ctx) {
1770
1843
  if (!text) { await markDelivered(s, message.id); continue; }
1771
1844
  steerInFlight.add(message.id);
1772
1845
  try {
1773
- await subs.sendMessage(caller, String(binding[0]), [{ type: 'text', text }], {
1846
+ await sendAgentMessage(ctx, caller, String(binding[0]), text, {
1774
1847
  signal: AbortSignal.timeout(s.requestTimeoutMs),
1775
1848
  });
1776
1849
  await markDelivered(s, message.id);
@@ -1797,7 +1870,7 @@ function assistantReplyText(message) {
1797
1870
 
1798
1871
  /**
1799
1872
  * 把成员这一轮的结论作为 member→lead 的消息落库(kind=response)。
1800
- * 成员用 send_message / team_report_task 回话都不经过消息总线,面板里只剩 Lead 单向提问;
1873
+ * 成员用 send_message / dsh_team_report_task 回话都不经过消息总线,面板里只剩 Lead 单向提问;
1801
1874
  * 收工时补一条回复,【消息与回执】才能配对成双向箭头并展示两条正文。
1802
1875
  */
1803
1876
  async function flushMemberReply(s, sessionId) {
@@ -2023,11 +2096,11 @@ async function boardApplyExecutionModel(ctx, agent, task, settings) {
2023
2096
  * 触发 prewalk 交接的「实现动作」。
2024
2097
  *
2025
2098
  * 对齐官方语义:不在计划提交时切换,而是等规划模型在同一条会话里落下第一笔实现
2026
- * 动作之后(首个 edit/write 类工具结果;团队任务则是 Lead 的首次 team_task 派发),
2099
+ * 动作之后(首个 edit/write 类工具结果;团队任务则是 Lead 的首次 dsh_team_task 派发),
2027
2100
  * 再把剩下的活交给执行模型,避免便宜模型接手后才发现计划不可执行。
2028
2101
  */
2029
2102
  const PREWALK_EDIT_TOOLS = new Set(['write', 'edit', 'str_replace_editor']);
2030
- const PREWALK_DISPATCH_TOOLS = new Set(['team_task']);
2103
+ const PREWALK_DISPATCH_TOOLS = new Set(['dsh_team_task']);
2031
2104
 
2032
2105
  /** 执行阶段已武装、等待首次实现动作的会话:sessionId → { task, settings }。 */
2033
2106
  const prewalkArmed = new Map();
@@ -2158,7 +2231,7 @@ function boardBranchLines(task) {
2158
2231
 
2159
2232
  function boardPlanningPrompt(task, settings) {
2160
2233
  const useTeam = task.useTeam !== false;
2161
- // 同会话模式:规划与执行是同一个会话,board_plan_submit 会直接领执行槽位,
2234
+ // 同会话模式:规划与执行是同一个会话,dsh_team_board_plan_submit 会直接领执行槽位,
2162
2235
  // 所以执行规则从一开始就写进规划 prompt,提交后不再补发「现在开始执行」。
2163
2236
  const sameSession = task.executionMode === 'same';
2164
2237
  const models = boardPromptModels(task);
@@ -2168,7 +2241,7 @@ function boardPlanningPrompt(task, settings) {
2168
2241
  ? '这一轮先只做规划,不要写代码、不要修改文件、不要创建团队。'
2169
2242
  : '只做规划,不写代码、不修改文件、不创建团队。',
2170
2243
  sameSession
2171
- ? '计划提交后读取 board_plan_submit 的返回:status 是 inprogress 就直接在同一会话里按计划开始执行(此时可以写文件、可以调用 team_*);status 是 planned 说明执行槽位已满,立刻停下等待调度器。'
2244
+ ? '计划提交后读取 dsh_team_board_plan_submit 的返回:status 是 inprogress 就直接在同一会话里按计划开始执行(此时可以写文件、可以调用 team_*);status 是 planned 说明执行槽位已满,立刻停下等待调度器。'
2172
2245
  : '规划完成后不要开始执行;调度器会在执行槽位空出后,在同一会话里让你继续。',
2173
2246
  '',
2174
2247
  `工作区:${task.workspacePath}`,
@@ -2202,7 +2275,7 @@ function boardPlanningPrompt(task, settings) {
2202
2275
  ...head,
2203
2276
  ...body,
2204
2277
  '',
2205
- '最后必须调用 board_plan_submit({ plan: "<完整 markdown>", summary: "<一句话>" })。',
2278
+ '最后必须调用 dsh_team_board_plan_submit({ plan: "<完整 markdown>", summary: "<一句话>" })。',
2206
2279
  '不要只把计划写在回复里。',
2207
2280
  ...(sameSession
2208
2281
  ? ['', '提交后如果返回 inprogress,继续按下面的规则执行;返回 planned 则忽略这些规则并停下:', '', ...boardLeadRules(task)]
@@ -2214,21 +2287,21 @@ function boardLeadRules(task) {
2214
2287
  const useTeam = task.useTeam !== false;
2215
2288
  const models = boardPromptModels(task);
2216
2289
  // 任务已有关联团队(重试、失败后继续、或完成后再次执行)时,在原团队上接着干,
2217
- // 不要每轮都 team_create 出一个新团队。
2290
+ // 不要每轮都 dsh_team_create 出一个新团队。
2218
2291
  const teams = Array.isArray(task.teams) ? task.teams.filter(Boolean).map(String) : [];
2219
2292
  const teamRule = teams.length
2220
- ? `1. 本任务已关联团队:${teams.join('、')}。不要调用 team_create 新建团队:先 team_status 查看这些团队的现状,`
2221
- + '在原团队里用 team_task 追加剩余工作继续推进;已经完成的成员任务不要重复创建。'
2222
- + '只有原团队已被删除或全部不可用时,才允许 team_create 新团队(若既有团队需要继续保留、只是要并行新建,必须显式传 force: true)。'
2223
- : '1. 先调用 team_create 创建团队;name 用任务标题,workspace 用上面的路径。需要多个团队就多次创建,所有团队都会自动绑定到本任务。';
2293
+ ? `1. 本任务已关联团队:${teams.join('、')}。不要调用 dsh_team_create 新建团队:先 dsh_team_status 查看这些团队的现状,`
2294
+ + '在原团队里用 dsh_team_task 追加剩余工作继续推进;已经完成的成员任务不要重复创建。'
2295
+ + '只有原团队已被删除或全部不可用时,才允许 dsh_team_create 新团队(若既有团队需要继续保留、只是要并行新建,必须显式传 force: true)。'
2296
+ : '1. 先调用 dsh_team_create 创建团队;name 用任务标题,workspace 用上面的路径。需要多个团队就多次创建,所有团队都会自动绑定到本任务。';
2224
2297
  // 用户嘴里的「新任务」经常被 Lead 误当成当前团队的 DAG 节点:先强制做归属判断。
2225
2298
  const scopeRules = [
2226
2299
  '先判断用户这次说的事是不是「新任务」:',
2227
2300
  '- 同一目标 / 同一模块或文件 / 同一验收 / 同一分支 → 是本任务的一部分,在本任务(或本团队)里继续推进。',
2228
- '- 交付物或验收不同、需要单独分支或单独规划、做完之后不再依赖本任务上下文 → 这是独立的一件事:调用 board_task_create 给它建一张看板卡(workspaceId / workspacePath 沿用本任务),不要用 team_task 塞进当前团队。',
2229
- '- 用户明确说「建看板任务 / 加一张卡 / 单开一个会话」→ 一律 board_task_create,禁止 team_task。',
2301
+ '- 交付物或验收不同、需要单独分支或单独规划、做完之后不再依赖本任务上下文 → 这是独立的一件事:调用 dsh_team_board_task_create 给它建一张看板卡(workspaceId / workspacePath 沿用本任务),不要用 dsh_team_task 塞进当前团队。',
2302
+ '- 用户明确说「建看板任务 / 加一张卡 / 单开一个会话」→ 一律 dsh_team_board_task_create,禁止 dsh_team_task。',
2230
2303
  '- 判断不清就先问用户一句「这算当前任务的一部分,还是另开一张卡?」,不要猜。',
2231
- '记住:team_task 只拆解当前任务,它不会出现在用户的看板上;用户说的「任务」通常指看板卡片。',
2304
+ '记住:dsh_team_task 只拆解当前任务,它不会出现在用户的看板上;用户说的「任务」通常指看板卡片。',
2232
2305
  ];
2233
2306
  const teamRules = [
2234
2307
  '开始执行前,先加载 `dsh-agent-team` 技能(调用 skill 工具,参数 {"name":"dsh-agent-team"}),按技能里的团队编排流程、工具字段与常见错法执行,不要凭记忆猜参数。',
@@ -2237,22 +2310,22 @@ function boardLeadRules(task) {
2237
2310
  '',
2238
2311
  '规则:',
2239
2312
  teamRule,
2240
- '2. 调用 team_models 查看可用路由;只能使用以下模型:',
2313
+ '2. 调用 dsh_team_models 查看可用路由;只能使用以下模型:',
2241
2314
  models,
2242
- '3. 用 team_task 拆解并派发;用 team_status / team_report 跟踪。不要自己写代码,不要重复成员的工作。成员按能力域分配:同一模块/相邻功能、或一个成员能顺手做完的多个条目,合并给同一个成员;成员数取能完成工作的最小值,不要按需求条目数量等量创建成员。',
2243
- '4. 用户反馈 Bug 时,不要自己去读代码排查:先判断归属成员,用 team_send 把复现步骤与怀疑点派给对应成员定位、修复;你只做分派、汇总与状态汇报。',
2244
- '5. 每轮结束前必须先调用 board_task_status 对齐状态:全部任务成功→done(附完成摘要),失败→failed(附原因),仍需继续或等待用户→inprogress。不能只在开始时调用一次。',
2245
- '6. 用户再次发消息时,先调用 board_task_status({ status: "inprogress" }),再继续处理。',
2315
+ '3. 用 dsh_team_task 拆解并派发;用 dsh_team_status / dsh_team_report 跟踪。不要自己写代码,不要重复成员的工作。成员按能力域分配:同一模块/相邻功能、或一个成员能顺手做完的多个条目,合并给同一个成员;成员数取能完成工作的最小值,不要按需求条目数量等量创建成员。',
2316
+ '4. 用户反馈 Bug 时,不要自己去读代码排查:先判断归属成员,用 dsh_team_send 把复现步骤与怀疑点派给对应成员定位、修复;你只做分派、汇总与状态汇报。',
2317
+ '5. 每轮结束前必须先调用 dsh_team_board_task_status 对齐状态:全部任务成功→done(附完成摘要),失败→failed(附原因),仍需继续或等待用户→inprogress。不能只在开始时调用一次。',
2318
+ '6. 用户再次发消息时,先调用 dsh_team_board_task_status({ status: "inprogress" }),再继续处理。',
2246
2319
  ];
2247
2320
  const soloRules = [
2248
- '本任务不开启团队:由你自己直接完成所有工作,不要调用 team_create / team_spawn / team_task。',
2321
+ '本任务不开启团队:由你自己直接完成所有工作,不要调用 dsh_team_create / dsh_team_spawn / dsh_team_task。',
2249
2322
  '',
2250
2323
  ...scopeRules,
2251
2324
  '',
2252
2325
  '规则:',
2253
2326
  '1. 按任务描述直接修改文件、运行命令并验证结果。',
2254
- '2. 每轮结束前必须先调用 board_task_status 对齐状态:全部完成→done(附完成摘要),失败→failed(附原因),仍需继续或等待用户→inprogress。不能只在开始时调用一次。',
2255
- '3. 用户再次发消息时,先调用 board_task_status({ status: "inprogress" }),再继续处理。',
2327
+ '2. 每轮结束前必须先调用 dsh_team_board_task_status 对齐状态:全部完成→done(附完成摘要),失败→failed(附原因),仍需继续或等待用户→inprogress。不能只在开始时调用一次。',
2328
+ '3. 用户再次发消息时,先调用 dsh_team_board_task_status({ status: "inprogress" }),再继续处理。',
2256
2329
  ];
2257
2330
  return useTeam ? teamRules : soloRules;
2258
2331
  }
@@ -2321,8 +2394,8 @@ async function guardBoardTeamReuse(s, sessionId, force) {
2321
2394
  }
2322
2395
  if (!alive.length) return;
2323
2396
  throw new Error(
2324
- `本任务已关联团队:${alive.join('、')}。重试/续跑请在原团队上继续:先用 team_status 查看现状,再用 team_task 追加剩余工作,不要重复 team_create。`
2325
- + '确实需要与之并行新建团队时,调用 team_create 并显式传 force: true。',
2397
+ `本任务已关联团队:${alive.join('、')}。重试/续跑请在原团队上继续:先用 dsh_team_status 查看现状,再用 dsh_team_task 追加剩余工作,不要重复 dsh_team_create。`
2398
+ + '确实需要与之并行新建团队时,调用 dsh_team_create 并显式传 force: true。',
2326
2399
  );
2327
2400
  }
2328
2401
 
@@ -2559,16 +2632,16 @@ function buildTools(s, ctx) {
2559
2632
  const tools = [];
2560
2633
 
2561
2634
  tools.push({
2562
- name: 'team_create',
2563
- description: 'START HERE to build a working team of agents. Order: team_create({name, workspace, permissionPreset?}) → team_models() to see the enabled provider/model routes → team_spawn({teamId, name, prompt, agentProvider?, model?, reasoningEffort?, permissionPreset?}) once per member, choosing a cheap/fast route for mechanical work and a strong-reasoning route for architecture, debugging, or review → team_task({teamId, subject, assignee?, plan, acceptance}) per DAG node → each member finishes by calling team_report_task → inspect with team_status / team_report. Every member is a real DSH sub-agent session (own model, tools, context, message inbox). `permissionPreset` decides the member sandbox + approval policy (DSH permission presets, e.g. workspace-write or danger-full-access); the team value is the default and team_spawn can override it per member. When a member hits an operation its preset requires approval for, the approval is forwarded to the Lead, who decides with team_approve. `workspace` is an absolute directory shared by the members and becomes their cwd. Keep teamId from this response (result.team.id): every later call needs it. Spawn members by capability domain, not one per requirement item: one member can own several related team_task items, so keep the member count at the minimum needed. For the full recipe with per-field pitfalls, load the skill "dsh-agent-team".',
2635
+ name: 'dsh_team_create',
2636
+ description: 'START HERE to build a working team of agents. Order: dsh_team_create({name, workspace, permissionPreset?}) → dsh_team_models() to see the enabled provider/model routes → dsh_team_spawn({teamId, name, prompt, agentProvider?, model?, reasoningEffort?, permissionPreset?}) once per member, choosing a cheap/fast route for mechanical work and a strong-reasoning route for architecture, debugging, or review → dsh_team_task({teamId, subject, assignee?, plan, acceptance}) per DAG node → each member finishes by calling dsh_team_report_task → inspect with dsh_team_status / dsh_team_report. Every member is a real DSH sub-agent session (own model, tools, context, message inbox). `permissionPreset` decides the member sandbox + approval policy (DSH permission presets, e.g. workspace-write or danger-full-access); the team value is the default and dsh_team_spawn can override it per member. When a member hits an operation its preset requires approval for, the approval is forwarded to the Lead, who decides with dsh_team_approve. `workspace` is an absolute directory shared by the members and becomes their cwd. Keep teamId from this response (result.team.id): every later call needs it. Spawn members by capability domain, not one per requirement item: one member can own several related dsh_team_task items, so keep the member count at the minimum needed. For the full recipe with per-field pitfalls, load the skill "dsh-agent-team".',
2564
2637
  parameters: {
2565
2638
  type: 'object',
2566
2639
  additionalProperties: false,
2567
2640
  properties: {
2568
2641
  name: { type: 'string', description: 'Team name.' },
2569
2642
  workspace: { type: 'string', description: 'Absolute directory shared by members; created if missing.' },
2570
- permissionPreset: { type: 'string', description: 'Default DSH permission preset for members (sandbox + approval policy). Default workspace-write. team_spawn can override it per member.' },
2571
- agentPreset: { type: 'string', description: 'Default DSH agent preset (composition: tools/skills/MCP + system prompt) for members. Omit to use the host default. team_spawn can override it per member.' },
2643
+ permissionPreset: { type: 'string', description: 'Default DSH permission preset for members (sandbox + approval policy). Default workspace-write. dsh_team_spawn can override it per member.' },
2644
+ agentPreset: { type: 'string', description: 'Default DSH agent preset (composition: tools/skills/MCP + system prompt) for members. Omit to use the host default. dsh_team_spawn can override it per member.' },
2572
2645
  maxMembers: { type: 'integer', description: 'Member cap, 0 means unlimited. Default 64. Extra members are queued, never errors.' },
2573
2646
  maxConcurrency: { type: 'integer', description: 'Max simultaneously running tasks. Default 8.' },
2574
2647
  failurePolicy: { type: 'string', enum: ['continue', 'abort'], description: 'Team-level default failure policy.' },
@@ -2598,7 +2671,7 @@ function buildTools(s, ctx) {
2598
2671
  });
2599
2672
  teamCache.set(team.id, team);
2600
2673
  if (exec?.agent) leadByTeam.set(team.id, exec.agent);
2601
- // 会话级粘性绑定:即使后续 team_spawn 漏传 teamId,也能解析到本会话刚建的团队。
2674
+ // 会话级粘性绑定:即使后续 dsh_team_spawn 漏传 teamId,也能解析到本会话刚建的团队。
2602
2675
  if (exec?.agent?.id != null) teamBySession.set(String(exec.agent.id), String(team.id));
2603
2676
  await bindBoardTeam(s, exec, team.id);
2604
2677
  return { team, panel: panelUrl(s) };
@@ -2606,22 +2679,22 @@ function buildTools(s, ctx) {
2606
2679
  });
2607
2680
 
2608
2681
  tools.push({
2609
- name: 'team_spawn',
2610
- description: "Add one member to a team; returns the member `id` you use as team_task's `assignee`. This SPAWNS A REAL DSH SUB-AGENT session (`subagents.startActivation`, continuable child) that owns its own model, context, tools and message inbox; `prompt` is required and becomes the member's first instruction — the member cannot see your conversation, so state the team id, its job, the workspace, and end with: finish by calling team_report_task({teamId, taskId, status, summary}). Over the member cap the member becomes `queued` instead of failing. Members are reusable: they run one task at a time and return to `idle`. Model routing: call team_models first, then pass `agentProvider` + `model` to fit the task — a cheap/fast route for mechanical edits and lookups, a strong-reasoning route for architecture, debugging, or review. Pass `reasoningEffort` when the model exposes one; omitting it inherits the Lead's effort only while the route stays the same, otherwise the model's default applies. Omit agentProvider/model to inherit the Lead's route. `permissionPreset` overrides the team default for this member (sandbox + approval policy); approval-required operations are forwarded to the Lead via team_approve.",
2682
+ name: 'dsh_team_spawn',
2683
+ description: "Add one member to a team; returns the member `id` you use as dsh_team_task's `assignee`. This SPAWNS A REAL DSH SUB-AGENT session (`subagents.startActivation`, continuable child) that owns its own model, context, tools and message inbox; `prompt` is required and becomes the member's first instruction — the member cannot see your conversation, so state the team id, its job, the workspace, and end with: finish by calling dsh_team_report_task({teamId, taskId, status, summary}). Over the member cap the member becomes `queued` instead of failing. Members are reusable: they run one task at a time and return to `idle`. Model routing: call dsh_team_models first, then pass `agentProvider` + `model` to fit the task — a cheap/fast route for mechanical edits and lookups, a strong-reasoning route for architecture, debugging, or review. Pass `reasoningEffort` when the model exposes one; omitting it inherits the Lead's effort only while the route stays the same, otherwise the model's default applies. Omit agentProvider/model to inherit the Lead's route. `permissionPreset` overrides the team default for this member (sandbox + approval policy); approval-required operations are forwarded to the Lead via dsh_team_approve.",
2611
2684
  parameters: {
2612
2685
  type: 'object',
2613
2686
  additionalProperties: false,
2614
2687
  properties: {
2615
- teamId: { type: 'string', description: 'team_create 返回的 result.team.id(形如 team_xxx)。漏传时自动使用当前会话刚创建的团队。' },
2688
+ teamId: { type: 'string', description: 'dsh_team_create 返回的 result.team.id(形如 team_xxx)。漏传时自动使用当前会话刚创建的团队。' },
2616
2689
  name: { type: 'string', description: 'Unique member name inside the team; this is the addressable target.' },
2617
2690
  role: { type: 'string', description: 'Role label shown on the panel.' },
2618
2691
  permissionPreset: { type: 'string', description: "DSH permission preset for this member (sandbox + approval policy). Defaults to the team's permissionPreset." },
2619
2692
  agentPreset: { type: 'string', description: "DSH agent preset (composition: tools/skills/MCP + system prompt). Defaults to the team's agentPreset; omit both to join the host default. Only supported with contextMode 'fresh' (the fork provider inherits the Lead's composition)." },
2620
- agentProvider: { type: 'string', description: 'LLM provider route id, as returned by team_models. Omit to inherit the Lead\'s provider. Must be an enabled route in the team panel.' },
2621
- model: { type: 'string', description: 'LLM model id, as returned by team_models. Changing the route clears inherited reasoning effort unless reasoningEffort is set explicitly.' },
2693
+ agentProvider: { type: 'string', description: 'LLM provider route id, as returned by dsh_team_models. Omit to inherit the Lead\'s provider. Must be an enabled route in the team panel.' },
2694
+ model: { type: 'string', description: 'LLM model id, as returned by dsh_team_models. Changing the route clears inherited reasoning effort unless reasoningEffort is set explicitly.' },
2622
2695
  reasoningEffort: { type: 'string', description: 'Adapter-defined reasoning effort id (for example low / medium / high, when the model supports them). Omit to inherit the Lead\'s effort while the route is unchanged; a changed route falls back to the model default.' },
2623
2696
  contextMode: { type: 'string', enum: ['isolated', 'fresh', 'fork'], description: 'Context isolation: `fresh` starts with no Lead history, `fork` inherits completed Lead turns. Default isolated/fresh.' },
2624
- prompt: { type: 'string', description: 'The member’s first instruction. Tell it its role, workspace, and that it must call team_report_task when done.' },
2697
+ prompt: { type: 'string', description: 'The member’s first instruction. Tell it its role, workspace, and that it must call dsh_team_report_task when done.' },
2625
2698
  description: { type: 'string', description: 'One-line description of what this member is responsible for.' },
2626
2699
  },
2627
2700
  required: ['teamId', 'name', 'prompt'],
@@ -2638,8 +2711,8 @@ function buildTools(s, ctx) {
2638
2711
  throw new Error('subagents 服务不可用:无法创建 sub-agent 成员(需要宿主启用 dsh-subagent)。');
2639
2712
  }
2640
2713
  const caller = exec?.agent;
2641
- if (!caller) throw new Error('team_spawn 需要 Lead 会话上下文(exec.agent 缺失:不能在非 agent 调用里起成员)。');
2642
- if (!args.prompt) throw new Error('team_spawn 需要 prompt(成员的初始指令)。');
2714
+ if (!caller) throw new Error('dsh_team_spawn 需要 Lead 会话上下文(exec.agent 缺失:不能在非 agent 调用里起成员)。');
2715
+ if (!args.prompt) throw new Error('dsh_team_spawn 需要 prompt(成员的初始指令)。');
2643
2716
 
2644
2717
  const context = args.contextMode === 'fork' ? 'fork' : 'fresh';
2645
2718
  // 省略 preset 时 DSH 继承 Lead 的实时组合,不会套宿主默认;
@@ -2701,7 +2774,7 @@ function buildTools(s, ctx) {
2701
2774
  label: memberLabel(memberName, description),
2702
2775
  signal: exec.signal || AbortSignal.timeout(s.requestTimeoutMs),
2703
2776
  }));
2704
- // 成员跑的是一整轮 agent loop,结果由 team_report_task 汇报;这里只防止未处理的 rejection。
2777
+ // 成员跑的是一整轮 agent loop,结果由 dsh_team_report_task 汇报;这里只防止未处理的 rejection。
2705
2778
  if (started && started.result && typeof started.result.catch === 'function') started.result.catch(() => {});
2706
2779
  // 子会话发布后立刻把 preset 落到会话(会覆盖 subagent 继承来的 approval=never)。
2707
2780
  const presetResult = applyPermissionPreset(ctx, sessionId, permissionPreset);
@@ -2751,8 +2824,8 @@ function buildTools(s, ctx) {
2751
2824
  });
2752
2825
 
2753
2826
  tools.push({
2754
- name: 'team_models',
2755
- description: 'List the model routes enabled for this team: provider id, model id, display name, note, providerNote (the vendor-level strength the user wrote, e.g. "适合逻辑处理" / "适合做设计"), and modalities. Use it before team_spawn when a task should run on a different model or reasoning effort than the Lead — a cheap/fast route for mechanical work, a strong-reasoning route for architecture, debugging, or review. Only the user-enabled subset is listed; the panel curates it. Pass a listed pair to team_spawn({ agentProvider, model, reasoningEffort }).',
2827
+ name: 'dsh_team_models',
2828
+ description: 'List the model routes enabled for this team: provider id, model id, display name, note, providerNote (the vendor-level strength the user wrote, e.g. "适合逻辑处理" / "适合做设计"), and modalities. Use it before dsh_team_spawn when a task should run on a different model or reasoning effort than the Lead — a cheap/fast route for mechanical work, a strong-reasoning route for architecture, debugging, or review. Only the user-enabled subset is listed; the panel curates it. Pass a listed pair to dsh_team_spawn({ agentProvider, model, reasoningEffort }).',
2756
2829
  parameters: {
2757
2830
  type: 'object',
2758
2831
  additionalProperties: false,
@@ -2784,7 +2857,7 @@ function buildTools(s, ctx) {
2784
2857
  };
2785
2858
  });
2786
2859
  const hint = models.length
2787
- ? '在 team_spawn 里用 agentProvider + model;providerNote 是该厂商整体强项(用户填写的厂商备注),note 是单模型差异;'
2860
+ ? '在 dsh_team_spawn 里用 agentProvider + model;providerNote 是该厂商整体强项(用户填写的厂商备注),note 是单模型差异;'
2788
2861
  + 'efforts 是该 route 允许派发的 reasoningEffort 列表(省略时只在 route 不变时继承 Lead 的 effort,被禁止的 effort 会被拒绝)。'
2789
2862
  : '没有启用的模型路由:请让用户在面板「模型路由」页勾选需要的 provider/model。';
2790
2863
  return {
@@ -2797,8 +2870,8 @@ function buildTools(s, ctx) {
2797
2870
  });
2798
2871
 
2799
2872
  tools.push({
2800
- name: 'team_preset',
2801
- description: 'Create, inspect, list, or delete team-owned agent presets when the host built-ins do not fit. A preset decides what a member OWNS (tool plugins, skill providers, MCP clients, persona/system prompt); permissionPreset decides what it MAY DO. action:list lists host presets plus presets the team already created; action:save writes one JSON document to the fixed team preset directory and registers it with the host immediately (no DSH restart), then the id can be passed to team_create({agentPreset}) / team_spawn({agentPreset}); action:show prints the saved document; action:delete removes a team-owned preset file and unregisters it (host built-ins are read-only). plugins must be a non-empty Cordis entry list, e.g. [{name:"@deepseek-ai/dsh-tool-fs"},{name:"@deepseek-ai/dsh-persona",config:{prefix:"You are a reviewer."}}]. Prefer copying the shape of an existing host preset: call team_preset({action:"show", id:"standard"}) and swap rows.',
2873
+ name: 'dsh_team_preset',
2874
+ description: 'Create, inspect, list, or delete team-owned agent presets when the host built-ins do not fit. A preset decides what a member OWNS (tool plugins, skill providers, MCP clients, persona/system prompt); permissionPreset decides what it MAY DO. action:list lists host presets plus presets the team already created; action:save writes one JSON document to the fixed team preset directory and registers it with the host immediately (no DSH restart), then the id can be passed to dsh_team_create({agentPreset}) / dsh_team_spawn({agentPreset}); action:show prints the saved document; action:delete removes a team-owned preset file and unregisters it (host built-ins are read-only). plugins must be a non-empty Cordis entry list, e.g. [{name:"@deepseek-ai/dsh-tool-fs"},{name:"@deepseek-ai/dsh-persona",config:{prefix:"You are a reviewer."}}]. Prefer copying the shape of an existing host preset: call dsh_team_preset({action:"show", id:"standard"}) and swap rows.',
2802
2875
  parameters: {
2803
2876
  type: 'object',
2804
2877
  additionalProperties: false,
@@ -2851,7 +2924,7 @@ function buildTools(s, ctx) {
2851
2924
  });
2852
2925
 
2853
2926
  tools.push({
2854
- name: 'team_status',
2927
+ name: 'dsh_team_status',
2855
2928
  description: 'Read a live snapshot instead of guessing progress. detail=summary returns every member with status/step/seq/percent/next/blockers/stale and its permissionPreset; detail=dag returns the task DAG with dependencies, readiness, joins and the critical path. `asOf` marks the snapshot time.',
2856
2929
  parameters: {
2857
2930
  type: 'object',
@@ -2899,13 +2972,13 @@ function buildTools(s, ctx) {
2899
2972
  });
2900
2973
 
2901
2974
  tools.push({
2902
- name: 'team_task_get',
2975
+ name: 'dsh_team_task_get',
2903
2976
  description: 'Read ONE DAG task of a team instead of the whole status: subject/status/assignee/attempts/maxAttempts/failurePolicy, its plan and acceptance, plus ledger node info (dependsOn, ready, blocked, blockers). Use it to confirm a task was dispatched, to check whether it is blocked on a dependency or a member, and to decide whether to retry or re-dispatch it. teamId is optional when the caller is already bound to that team.',
2904
2977
  parameters: {
2905
2978
  type: 'object',
2906
2979
  additionalProperties: false,
2907
2980
  properties: {
2908
- taskId: { type: 'string', description: 'Task id returned by team_task (task_…).' },
2981
+ taskId: { type: 'string', description: 'Task id returned by dsh_team_task (task_…).' },
2909
2982
  teamId: { type: 'string', description: 'Optional ownership check; inferred from the caller session when omitted.' },
2910
2983
  },
2911
2984
  required: ['taskId'],
@@ -2915,7 +2988,7 @@ function buildTools(s, ctx) {
2915
2988
  async execute(args) {
2916
2989
  const task = await request(s, `/api/tasks/${encodeURIComponent(args.taskId)}`);
2917
2990
  const teamId = String(args.teamId || task.teamId || '');
2918
- if (!teamId) throw new Error('team_task_get 无法确定 teamId:请显式传入');
2991
+ if (!teamId) throw new Error('dsh_team_task_get 无法确定 teamId:请显式传入');
2919
2992
  if (args.teamId && String(task.teamId) !== String(args.teamId)) {
2920
2993
  throw new Error(`task ${task.id} 不属于 team ${args.teamId}`);
2921
2994
  }
@@ -2927,8 +3000,8 @@ function buildTools(s, ctx) {
2927
3000
  });
2928
3001
 
2929
3002
  tools.push({
2930
- name: 'team_task',
2931
- description: 'Only for decomposing the CURRENT task: declare one task (DAG node) and hand it to a member. When the user asks for a new, separate task card (own deliverable or acceptance, own branch/session), use board_task_create instead — team_task items never appear on the board. The plan is a BRIEF sent to the member’s own sub-agent session, which does the work with its own tools and calls team_report_task when finished — write it self-contained (the member does not see this conversation). `assignee` takes a member **id** from team_spawn, not its name; omit it to let the scheduler pick an idle member. `deps[].from` takes a **task** id returned by an earlier team_task (member ids are rejected). The scheduler satisfies dependencies itself — never poll. The task dispatches immediately to an idle member once dependencies are satisfied; pass dispatch:false to build the DAG first.',
3003
+ name: 'dsh_team_task',
3004
+ description: 'Only for decomposing the CURRENT task: declare one task (DAG node) and hand it to a member. When the user asks for a new, separate task card (own deliverable or acceptance, own branch/session), use dsh_team_board_task_create instead — dsh_team_task items never appear on the board. The plan is a BRIEF sent to the member’s own sub-agent session, which does the work with its own tools and calls dsh_team_report_task when finished — write it self-contained (the member does not see this conversation). `assignee` takes a member **id** from dsh_team_spawn, not its name; omit it to let the scheduler pick an idle member. `deps[].from` takes a **task** id returned by an earlier dsh_team_task (member ids are rejected). The scheduler satisfies dependencies itself — never poll. The task dispatches immediately to an idle member once dependencies are satisfied; pass dispatch:false to build the DAG first.',
2932
3005
  parameters: {
2933
3006
  type: 'object',
2934
3007
  additionalProperties: false,
@@ -2944,7 +3017,7 @@ function buildTools(s, ctx) {
2944
3017
  type: 'object',
2945
3018
  additionalProperties: false,
2946
3019
  properties: {
2947
- from: { type: 'string', description: 'Upstream **task** id (starts with task_), taken from the team_task result — not a member id.' },
3020
+ from: { type: 'string', description: 'Upstream **task** id (starts with task_), taken from the dsh_team_task result — not a member id.' },
2948
3021
  condition: { type: 'string', enum: ['all_success', 'any_success', 'on_failure', 'artifact_exists'] },
2949
3022
  artifactPath: { type: 'string', description: 'Workspace-relative path for condition=artifact_exists.' },
2950
3023
  },
@@ -2955,7 +3028,7 @@ function buildTools(s, ctx) {
2955
3028
  priority: { type: 'integer', description: 'Smaller runs first. Default 0.' },
2956
3029
  failurePolicy: { type: 'string', enum: ['continue', 'skip', 'abort_team', 'retry'] },
2957
3030
  maxAttempts: { type: 'integer' },
2958
- dispatch: { type: 'boolean', description: 'Dispatch immediately after creating (default true). Pass false to build the DAG first and dispatch later with team_dispatch.' },
3031
+ dispatch: { type: 'boolean', description: 'Dispatch immediately after creating (default true). Pass false to build the DAG first and dispatch later with dsh_team_dispatch.' },
2959
3032
  },
2960
3033
  required: ['teamId', 'subject', 'plan'],
2961
3034
  },
@@ -2984,8 +3057,8 @@ function buildTools(s, ctx) {
2984
3057
  });
2985
3058
 
2986
3059
  tools.push({
2987
- name: 'team_send',
2988
- description: "Send a message that a member will actually read: the text is injected into the target sub-agent's message inbox. By default a running member's current turn is interrupted first, so the message immediately starts a fresh turn instead of waiting for the next step boundary; pass `interrupt: false` to keep the current turn and deliver at the next step boundary. An idle member is woken. `to` is a member NAME (member id also accepted) or '*' to broadcast; use to:'lead' to reply to the Lead. Every send is also recorded on the sidecar so the panel shows the conversation. Returns delivery status only, never the member's reply: the reply arrives asynchronously as a new message in a later turn. Never wait for it with sleep/Start-Sleep/delayed scripts, polling loops, or repeated team_status calls — after sending, continue independent work or end the turn.",
3060
+ name: 'dsh_team_send',
3061
+ description: "Send a message that a member will actually read: the text is injected into the target sub-agent's message inbox. By default a running member's current turn is interrupted first, so the message immediately starts a fresh turn instead of waiting for the next step boundary; pass `interrupt: false` to keep the current turn and deliver at the next step boundary. An idle member is woken. `to` is a member NAME (member id also accepted) or '*' to broadcast; use to:'lead' to reply to the Lead. Every send is also recorded on the sidecar so the panel shows the conversation. Returns delivery status only, never the member's reply: the reply arrives asynchronously as a new message in a later turn. Never wait for it with sleep/Start-Sleep/delayed scripts, polling loops, or repeated dsh_team_status calls — after sending, continue independent work or end the turn.",
2989
3062
  parameters: {
2990
3063
  type: 'object',
2991
3064
  additionalProperties: false,
@@ -3012,7 +3085,7 @@ function buildTools(s, ctx) {
3012
3085
  const members = st?.members || [];
3013
3086
  const resolve = (v) => members.find((m) => m.name === v || m.id === v) || null;
3014
3087
  if (!toLead && args.to !== '*' && (members.length ? !resolve(args.to) : false)) {
3015
- throw new Error(`team_send: 找不到成员 ${args.to}(可用成员 name 或 memberId;广播用 '*';给 Lead 留言用 to:"lead")`);
3088
+ throw new Error(`dsh_team_send: 找不到成员 ${args.to}(可用成员 name 或 memberId;广播用 '*';给 Lead 留言用 to:"lead")`);
3016
3089
  }
3017
3090
  const recorded = await request(s, '/api/messages', {
3018
3091
  method: 'POST',
@@ -3030,8 +3103,7 @@ function buildTools(s, ctx) {
3030
3103
  const subs = subagentsOf(ctx);
3031
3104
  // 成员之间互通必须借 Lead 的 agent 句柄:成员会话都挂在 Lead 下,成员直发会「belongs to another parent session」。
3032
3105
  const caller = leadByTeam.get(args.teamId) || exec?.agent;
3033
- if (!subs || typeof subs.sendMessage !== 'function' || !caller) return { ...recorded, delivered: false };
3034
- const content = [{ type: 'text', text: String(args.message) }];
3106
+ if (!caller || !canDeliverTo(ctx, caller)) return { ...recorded, delivered: false };
3035
3107
  const candidates = args.to === '*' ? members : [resolve(args.to)].filter(Boolean);
3036
3108
  const targets = candidates.filter((m) => m.agentSessionId);
3037
3109
  const delivered = [];
@@ -3053,7 +3125,9 @@ function buildTools(s, ctx) {
3053
3125
  interruptErrors.push({ target: target.name, error: String(err?.message || err) });
3054
3126
  }
3055
3127
  }
3056
- await subs.sendMessage(caller, sid, content, { signal: AbortSignal.timeout(s.requestTimeoutMs) });
3128
+ await sendAgentMessage(ctx, caller, sid, String(args.message), {
3129
+ signal: AbortSignal.timeout(s.requestTimeoutMs),
3130
+ });
3057
3131
  delivered.push(target.name);
3058
3132
  // 投递成功才补记送达:这一条消息确实进了成员会话
3059
3133
  const row = (recorded.messages || [recorded.message]).find((m) => m && String(m.to) === String(target.id));
@@ -3073,7 +3147,7 @@ function buildTools(s, ctx) {
3073
3147
  });
3074
3148
 
3075
3149
  tools.push({
3076
- name: 'team_todo',
3150
+ name: 'dsh_team_todo',
3077
3151
  description: '设置或更新一个任务的执行计划清单(todo)。与内置 todo_write 不同:这份清单落盘在 sidecar,面板主页 Plan 区域实时渲染,Lead 与成员都能看到(内置 todo 只属于当前会话)。语义是整体替换——每次提交完整清单(最多 50 条),用 status 标注进度:open(未开始)/ active(进行中)/ done(已完成)/ blocked(被阻塞)。Lead 在派发前/后用它给任务补计划;成员每开始或完成一步、以及通过验收后调用它更新状态。',
3078
3152
  parameters: {
3079
3153
  type: 'object',
@@ -3111,7 +3185,7 @@ function buildTools(s, ctx) {
3111
3185
  });
3112
3186
 
3113
3187
  tools.push({
3114
- name: 'team_report_task',
3188
+ name: 'dsh_team_report_task',
3115
3189
  description: 'Report the outcome of ONE task you were dispatched (agent members: call this as the last thing you do). It marks the task done/failed/blocked on the sidecar, releases the member back to idle, advances the DAG (dependents become ready and are dispatched), and applies the team failure policy. `summary` is what the Lead and the panel will see — put the result, key file paths and any blocker in it.',
3116
3190
  parameters: {
3117
3191
  type: 'object',
@@ -3160,7 +3234,7 @@ function buildTools(s, ctx) {
3160
3234
  };
3161
3235
 
3162
3236
  tools.push({
3163
- name: 'team_memory_write',
3237
+ name: 'dsh_team_memory_write',
3164
3238
  description: 'Save ONE memory into the file-backed memory space (one JSON file per memory, never SQLite). scope=member writes the caller member\'s own space; scope=team writes the shared team space (use it when the Lead asks you to upload). Same (scope, team, owner, key) upserts and bumps version; pass expectedVersion for compare-and-set. Keep handoffs short (<=300 chars) and only save what is actually reusable — do NOT force a memory when the task produced nothing worth carrying.',
3165
3239
  parameters: {
3166
3240
  type: 'object',
@@ -3202,7 +3276,7 @@ function buildTools(s, ctx) {
3202
3276
  });
3203
3277
 
3204
3278
  tools.push({
3205
- name: 'team_memory_read',
3279
+ name: 'dsh_team_memory_read',
3206
3280
  description: 'Read ONE memory by id, or find the first matching memory by scope+key (and optional memberId). Memory ids are portable: a shared memory id can be passed to a member of another team. Returns the full value and version.',
3207
3281
  parameters: {
3208
3282
  type: 'object',
@@ -3233,7 +3307,7 @@ function buildTools(s, ctx) {
3233
3307
  });
3234
3308
 
3235
3309
  tools.push({
3236
- name: 'team_memory_list',
3310
+ name: 'dsh_team_memory_list',
3237
3311
  description: 'List memory metadata (slot/title/kind/source/updatedAt, no value body) for a team. Members see their own private memories + team-scope memories; the Lead sees all memories of the team; shared memories are visible across teams. Use q to search slot/title/tags/value text.',
3238
3312
  parameters: {
3239
3313
  type: 'object',
@@ -3261,7 +3335,7 @@ function buildTools(s, ctx) {
3261
3335
  });
3262
3336
 
3263
3337
  tools.push({
3264
- name: 'team_memory_share',
3338
+ name: 'dsh_team_memory_share',
3265
3339
  description: 'Change a memory\'s visibility: private (owner + team Lead), team (this team\'s members), shared (any team by id). The Lead uses this to hand a member\'s memory to other members; a member can share its own memory.',
3266
3340
  parameters: {
3267
3341
  type: 'object',
@@ -3284,7 +3358,7 @@ function buildTools(s, ctx) {
3284
3358
  });
3285
3359
 
3286
3360
  tools.push({
3287
- name: 'team_memory_delete',
3361
+ name: 'dsh_team_memory_delete',
3288
3362
  description: 'Delete ONE memory file permanently. The owner member or the team Lead may delete; team deletion does NOT cascade to memory files. Shared memory ids keep working across teams until deleted.',
3289
3363
  parameters: {
3290
3364
  type: 'object',
@@ -3302,8 +3376,8 @@ function buildTools(s, ctx) {
3302
3376
  });
3303
3377
 
3304
3378
  tools.push({
3305
- name: 'team_dispatch',
3306
- description: 'Pump the agent-team dispatcher once: claim ready tasks for idle members and send each member its brief. Normally unnecessary — team_task dispatches automatically and team_report_task dispatches the next wave — but useful after team_control/resume, after approving a scope request, or when a member went idle without reporting. Safe to call repeatedly; it returns when no idle member or no ready task is left.',
3379
+ name: 'dsh_team_dispatch',
3380
+ description: 'Pump the agent-team dispatcher once: claim ready tasks for idle members and send each member its brief. Normally unnecessary — dsh_team_task dispatches automatically and dsh_team_report_task dispatches the next wave — but useful after dsh_team_control/resume, after approving a scope request, or when a member went idle without reporting. Safe to call repeatedly; it returns when no idle member or no ready task is left.',
3307
3381
  parameters: {
3308
3382
  type: 'object',
3309
3383
  additionalProperties: false,
@@ -3318,8 +3392,8 @@ function buildTools(s, ctx) {
3318
3392
  });
3319
3393
 
3320
3394
  tools.push({
3321
- name: 'team_approve',
3322
- description: 'Decide a permission approval raised by a member. When a member runs an operation its permission preset requires approval for (sandbox escalation / write outside the sandbox), the DSH approval request is forwarded to the Lead and the member is paused. Read the requestId/member/tool/reason from the forwarded message, then call team_approve with decision "allow" (authorize this one operation) or "deny". Only the Lead of that team can decide. If nobody decides before the timeout, the request is rejected automatically.',
3395
+ name: 'dsh_team_approve',
3396
+ description: 'Decide a permission approval raised by a member. When a member runs an operation its permission preset requires approval for (sandbox escalation / write outside the sandbox), the DSH approval request is forwarded to the Lead and the member is paused. Read the requestId/member/tool/reason from the forwarded message, then call dsh_team_approve with decision "allow" (authorize this one operation) or "deny". Only the Lead of that team can decide. If nobody decides before the timeout, the request is rejected automatically.',
3323
3397
  parameters: {
3324
3398
  type: 'object',
3325
3399
  additionalProperties: false,
@@ -3334,7 +3408,7 @@ function buildTools(s, ctx) {
3334
3408
  output: jsonOutput('{ requestId, decision, memberId, toolName, reason }'),
3335
3409
  async execute(args, exec) {
3336
3410
  const requestId = String(args.requestId || '').trim();
3337
- if (!requestId) throw new Error('team_approve requires requestId');
3411
+ if (!requestId) throw new Error('dsh_team_approve requires requestId');
3338
3412
  const entry = pendingApprovals.get(requestId);
3339
3413
  if (!entry) throw new Error('审批请求不存在或已处理(可能已超时)。请以成员收到的审批消息里的 requestId 为准。');
3340
3414
  if (String(entry.teamId) !== String(args.teamId)) throw new Error('teamId 与审批请求不匹配');
@@ -3350,7 +3424,7 @@ function buildTools(s, ctx) {
3350
3424
  });
3351
3425
 
3352
3426
  tools.push({
3353
- name: 'team_control',
3427
+ name: 'dsh_team_control',
3354
3428
  description: 'Control one member. interrupt stops the sub-agent’s current turn and pauses its in-flight task (no retry, no attempt consumed); resume re-arms it; assign hands a ready task to an idle member; abort permanently voids a task (taskId) without retry.',
3355
3429
  parameters: {
3356
3430
  type: 'object',
@@ -3367,7 +3441,7 @@ function buildTools(s, ctx) {
3367
3441
  output: jsonOutput('{ member, ... }'),
3368
3442
  async execute(args, exec) {
3369
3443
  if (args.action === 'abort') {
3370
- if (!args.taskId) throw new Error('team_control abort requires taskId');
3444
+ if (!args.taskId) throw new Error('dsh_team_control abort requires taskId');
3371
3445
  const res = await request(s, `/api/tasks/${encodeURIComponent(args.taskId)}/abort`, { method: 'POST', body: { reason: args.reason || 'lead abort' } });
3372
3446
  if (!res?.wasRunning || !res?.member?.agentSessionId) return res;
3373
3447
  const sid = String(res.member.agentSessionId);
@@ -3383,7 +3457,7 @@ function buildTools(s, ctx) {
3383
3457
  (err) => ({ ok: false, error: String(err?.message || err) }));
3384
3458
  return { ...res, agent: interrupted };
3385
3459
  }
3386
- if (!args.memberId) throw new Error(`team_control ${args.action} requires memberId`);
3460
+ if (!args.memberId) throw new Error(`dsh_team_control ${args.action} requires memberId`);
3387
3461
  const id = encodeURIComponent(args.memberId);
3388
3462
  if (args.action === 'interrupt') {
3389
3463
  const res = await request(s, `/api/members/${id}/interrupt`, { method: 'POST', body: { reason: args.reason || 'lead interrupt' } });
@@ -3415,15 +3489,15 @@ function buildTools(s, ctx) {
3415
3489
  return res;
3416
3490
  }
3417
3491
  if (args.action === 'assign') {
3418
- if (!args.taskId) throw new Error('team_control assign requires taskId');
3492
+ if (!args.taskId) throw new Error('dsh_team_control assign requires taskId');
3419
3493
  return await request(s, `/api/members/${id}/assign`, { method: 'POST', body: { taskId: args.taskId } });
3420
3494
  }
3421
- throw new Error(`team_control unknown action: ${args.action}`);
3495
+ throw new Error(`dsh_team_control unknown action: ${args.action}`);
3422
3496
  },
3423
3497
  });
3424
3498
 
3425
3499
  tools.push({
3426
- name: 'team_member',
3500
+ name: 'dsh_team_member',
3427
3501
  description: "Update or remove a team member. `update` changes role/permission/model/context. `permissionPreset` (and `role`) applies to a RUNNING member immediately, no interrupt needed; changing model, agentProvider, contextMode, agentPreset or reasoningEffort rebuilds the member's DSH sub-agent session (old context is lost) and therefore requires the member to be idle or interrupted. `retire` keeps the member row as retired and frees capacity; `remove` deletes the row and requires confirm:true. Both release the sub-agent session.",
3428
3502
  parameters: {
3429
3503
  type: 'object',
@@ -3431,7 +3505,7 @@ function buildTools(s, ctx) {
3431
3505
  properties: {
3432
3506
  action: { type: 'string', enum: ['update', 'retire', 'remove'] },
3433
3507
  teamId: { type: 'string', description: 'Team id; omit to resolve from the current Lead session.' },
3434
- memberId: { type: 'string', description: 'Member id returned by team_spawn / team_status.' },
3508
+ memberId: { type: 'string', description: 'Member id returned by dsh_team_spawn / dsh_team_status.' },
3435
3509
  role: { type: 'string', description: 'update: new role label.' },
3436
3510
  model: { type: 'string', description: 'update: new LLM model id (empty to inherit). Rebuilds the session.' },
3437
3511
  agentProvider: { type: 'string', description: 'update: new LLM provider route id. Rebuilds the session.' },
@@ -3452,7 +3526,7 @@ function buildTools(s, ctx) {
3452
3526
  if (current.teamId !== team.id) throw new Error('member 不属于指定团队');
3453
3527
 
3454
3528
  if (args.action === 'retire' || args.action === 'remove') {
3455
- if (args.action === 'remove' && args.confirm !== true) throw new Error('team_member remove requires confirm:true');
3529
+ if (args.action === 'remove' && args.confirm !== true) throw new Error('dsh_team_member remove requires confirm:true');
3456
3530
  const mode = args.action === 'remove' ? 'remove' : 'retire';
3457
3531
  const res = await request(s, `/api/members/${id}?mode=${mode}${mode === 'remove' ? '&confirm=1' : ''}`, { method: 'DELETE' });
3458
3532
  let agent = null;
@@ -3469,7 +3543,7 @@ function buildTools(s, ctx) {
3469
3543
  return { ...res, agent, panel: panelUrl(s) };
3470
3544
  }
3471
3545
 
3472
- if (args.action !== 'update') throw new Error(`team_member unknown action: ${args.action}`);
3546
+ if (args.action !== 'update') throw new Error(`dsh_team_member unknown action: ${args.action}`);
3473
3547
  if (current.status === 'retired') throw new Error('member is retired; create a new member instead');
3474
3548
 
3475
3549
  const has = (key) => Object.prototype.hasOwnProperty.call(args, key);
@@ -3504,7 +3578,7 @@ function buildTools(s, ctx) {
3504
3578
  const subs = subagentsOf(ctx);
3505
3579
  const caller = exec?.agent;
3506
3580
  if (!subs || typeof subs.startActivation !== 'function') throw new Error('subagents 服务不可用:无法重建成员会话');
3507
- if (!caller) throw new Error('team_member update 需要 Lead 会话上下文(exec.agent 缺失)');
3581
+ if (!caller) throw new Error('dsh_team_member update 需要 Lead 会话上下文(exec.agent 缺失)');
3508
3582
 
3509
3583
  const leadRoute = leadRouteOf(caller);
3510
3584
  const oldRoute = {
@@ -3547,7 +3621,7 @@ function buildTools(s, ctx) {
3547
3621
 
3548
3622
  const sessionId = randomUUID();
3549
3623
  const started = await subs.startActivation(activationSpec({
3550
- prompt: [{ type: 'text', text: `你是团队成员 ${current.name}(${role || 'teammate'})。配置刚刚更新,这是新的会话;当前没有任务,等待 Lead 派发。收到任务后按简报执行,完成时调用 team_report_task。` }],
3624
+ prompt: [{ type: 'text', text: `你是团队成员 ${current.name}(${role || 'teammate'})。配置刚刚更新,这是新的会话;当前没有任务,等待 Lead 派发。收到任务后按简报执行,完成时调用 dsh_team_report_task。` }],
3551
3625
  parent: caller,
3552
3626
  ...(team.workspace ? { cwd: team.workspace } : {}),
3553
3627
  ...(Object.keys(agentOptions).length ? { agentOptions } : {}),
@@ -3609,7 +3683,7 @@ function buildTools(s, ctx) {
3609
3683
  });
3610
3684
 
3611
3685
  tools.push({
3612
- name: 'team_report',
3686
+ name: 'dsh_team_report',
3613
3687
  description: 'Export a Markdown run report: members, tasks/DAG, permission approvals (who asked for what, who decided), and the audit table with actor, action, target, and full before/after SHA-256 hashes. Use it for review, handoff, or proving who changed which file.',
3614
3688
  parameters: {
3615
3689
  type: 'object',
@@ -3627,7 +3701,7 @@ function buildTools(s, ctx) {
3627
3701
 
3628
3702
 
3629
3703
  tools.push({
3630
- name: 'board_plan_submit',
3704
+ name: 'dsh_team_board_plan_submit',
3631
3705
  description: 'Submit the finished plan for the current workspace-board task. Call this at the end of the planning session; the scheduler stores the plan and moves the task to planned. In same-session mode this tool also moves the task into the execution slot and keeps this session running: if the returned task status is inprogress, continue with the plan immediately; if it is planned, stop and wait for the scheduler.',
3632
3706
  parameters: {
3633
3707
  type: 'object',
@@ -3641,7 +3715,7 @@ function buildTools(s, ctx) {
3641
3715
  output: jsonOutput('{ board task }'),
3642
3716
  async execute(args, exec) {
3643
3717
  const sessionId = exec?.agent?.id != null ? String(exec.agent.id) : null;
3644
- if (!sessionId) throw new Error('board_plan_submit 只能在规划会话里调用');
3718
+ if (!sessionId) throw new Error('dsh_team_board_plan_submit 只能在规划会话里调用');
3645
3719
  const task = await request(s, '/api/board/agents/plan', {
3646
3720
  method: 'POST',
3647
3721
  body: { sessionId, plan: args.plan, summary: args.summary || null },
@@ -3653,7 +3727,7 @@ function buildTools(s, ctx) {
3653
3727
  const agent = rec?.handle?.agent || exec?.agent;
3654
3728
  if (task.leadPermissionPreset) boardSetPermission(ctx, agent, task.leadPermissionPreset);
3655
3729
  // prewalk:这里只武装、不切模型。规划模型先按计划落下第一笔实现动作
3656
- // (首次 edit/write 或首次 team_task 派发),确认计划可执行后再交给执行模型。
3730
+ // (首次 edit/write 或首次 dsh_team_task 派发),确认计划可执行后再交给执行模型。
3657
3731
  if (task.prewalk) {
3658
3732
  const boardSettings = await request(
3659
3733
  s,
@@ -3689,7 +3763,7 @@ function buildTools(s, ctx) {
3689
3763
  });
3690
3764
 
3691
3765
  tools.push({
3692
- name: 'board_task_status',
3766
+ name: 'dsh_team_board_task_status',
3693
3767
  description: 'Report the current workspace-board task status from the Lead session. Call it at the end of EVERY turn: "done" after all team tasks succeed, "failed" when the task cannot be completed, and "inprogress" while work remains or when waiting for the user (also call it when the user sends a new message after a finished task).',
3694
3768
  parameters: {
3695
3769
  type: 'object',
@@ -3703,7 +3777,7 @@ function buildTools(s, ctx) {
3703
3777
  output: jsonOutput('{ board task }'),
3704
3778
  async execute(args, exec) {
3705
3779
  const sessionId = exec?.agent?.id != null ? String(exec.agent.id) : null;
3706
- if (!sessionId) throw new Error('board_task_status 只能在看板 Lead 会话里调用');
3780
+ if (!sessionId) throw new Error('dsh_team_board_task_status 只能在看板 Lead 会话里调用');
3707
3781
  return await request(s, '/api/board/agents/status', {
3708
3782
  method: 'POST',
3709
3783
  body: { sessionId, status: args.status, summary: args.summary || null },
@@ -3712,8 +3786,8 @@ function buildTools(s, ctx) {
3712
3786
  });
3713
3787
 
3714
3788
  tools.push({
3715
- name: 'board_task_create',
3716
- description: 'Create a new workspace-board task card (the user-facing queue the board scheduler picks up) — use it when the user asks for a new task that is a separate deliverable or deserves its own session/branch (not a step of the current task, which is team_task). This is NOT a team DAG task: team_* tools stay inside the current team. workspaceId defaults to the caller own board task, then to the only registered workspace; pass it when either is ambiguous. Pass gitBranch to run the new task on a git branch ("" = auto `task/<id>`, omitted = no branch).',
3789
+ name: 'dsh_team_board_task_create',
3790
+ description: 'Create a new workspace-board task card (the user-facing queue the board scheduler picks up) — use it when the user asks for a new task that is a separate deliverable or deserves its own session/branch (not a step of the current task, which is dsh_team_task). This is NOT a team DAG task: team_* tools stay inside the current team. workspaceId defaults to the caller own board task, then to the only registered workspace; pass it when either is ambiguous. Pass gitBranch to run the new task on a git branch ("" = auto `task/<id>`, omitted = no branch).',
3717
3791
  parameters: {
3718
3792
  type: 'object',
3719
3793
  additionalProperties: false,
@@ -3756,7 +3830,7 @@ function buildTools(s, ctx) {
3756
3830
  workspacePath = workspacePath || items[0].path;
3757
3831
  }
3758
3832
  }
3759
- if (!workspaceId) throw new Error('board_task_create 需要 workspaceId:当前会话不属于任何看板任务,且工作区不唯一');
3833
+ if (!workspaceId) throw new Error('dsh_team_board_task_create 需要 workspaceId:当前会话不属于任何看板任务,且工作区不唯一');
3760
3834
  // 手填的 workspaceId 可能根本不存在(模型常填 00000000-… 占位 UUID)。这种卡会挂到
3761
3835
  // 一个 UI 上不存在的“幽灵工作区”,看板按 workspace_id 过滤后完全看不到,所以这里必须
3762
3836
  // 先解析:按 workspacePath 改挂到已注册工作区;DSH 注册表里确实存在(sidecar 还没同步)
@@ -3770,7 +3844,7 @@ function buildTools(s, ctx) {
3770
3844
  const registry = (() => { try { return ctx.get('workspaceRegistry'); } catch { return undefined; } })();
3771
3845
  const known = registry && typeof registry.get === 'function' ? registry.get(workspaceId) : null;
3772
3846
  if (!known) {
3773
- throw new Error(`board_task_create 的 workspaceId 不存在:${workspaceId}。可用工作区:${items.map((w) => `${w.id}(${w.title || w.path})`).join('、') || '(sidecar 还没同步到工作区)'}`);
3847
+ throw new Error(`dsh_team_board_task_create 的 workspaceId 不存在:${workspaceId}。可用工作区:${items.map((w) => `${w.id}(${w.title || w.path})`).join('、') || '(sidecar 还没同步到工作区)'}`);
3774
3848
  }
3775
3849
  }
3776
3850
  }
@@ -3793,8 +3867,8 @@ function buildTools(s, ctx) {
3793
3867
  });
3794
3868
 
3795
3869
  tools.push({
3796
- name: 'board_task_get',
3797
- description: 'Read the current workspace-board task of this session (status/planSummary/lastError/gitBranch/sessions) when taskId is omitted, or any board card by taskId. Cheap and safe to call every turn: it returns the status snapshot, not the whole plan body. Use it to decide whether to keep working, wait, or report via board_task_status.',
3870
+ name: 'dsh_team_board_task_get',
3871
+ description: 'Read the current workspace-board task of this session (status/planSummary/lastError/gitBranch/sessions) when taskId is omitted, or any board card by taskId. Cheap and safe to call every turn: it returns the status snapshot, not the whole plan body. Use it to decide whether to keep working, wait, or report via dsh_team_board_task_status.',
3798
3872
  parameters: {
3799
3873
  type: 'object',
3800
3874
  additionalProperties: false,
@@ -3818,7 +3892,7 @@ function buildTools(s, ctx) {
3818
3892
  return { task: pick(task) };
3819
3893
  }
3820
3894
  const sessionId = exec?.agent?.id != null ? String(exec.agent.id) : null;
3821
- if (!sessionId) throw new Error('board_task_get 需要 taskId,或从看板会话里调用');
3895
+ if (!sessionId) throw new Error('dsh_team_board_task_get 需要 taskId,或从看板会话里调用');
3822
3896
  const found = await request(s, `/api/board/by-session/${encodeURIComponent(sessionId)}`).catch(() => null);
3823
3897
  if (!found || found.ok === false || !found.id) throw new Error('当前会话没有关联的看板任务');
3824
3898
  return { task: pick(found) };
@@ -3829,7 +3903,7 @@ function buildTools(s, ctx) {
3829
3903
  }
3830
3904
 
3831
3905
  // ---------- trace 上报:把每次工具调用写成 span(running → done/failed) ----------
3832
- /** 会话 → 团队 的粘性绑定:参数里出现 teamId 或 team_create 返回后记住,后续调用自动归属。 */
3906
+ /** 会话 → 团队 的粘性绑定:参数里出现 teamId 或 dsh_team_create 返回后记住,后续调用自动归属。 */
3833
3907
  const teamBySession = new Map();
3834
3908
 
3835
3909
  const clipText = (value, max) => {
@@ -4194,7 +4268,7 @@ export function apply(ctx, config) {
4194
4268
  });
4195
4269
  }
4196
4270
 
4197
- // 成员权限审批:preset 的 approval=ask 触发时,把请求转给 Lead,由 team_approve 决定。
4271
+ // 成员权限审批:preset 的 approval=ask 触发时,把请求转给 Lead,由 dsh_team_approve 决定。
4198
4272
  // 放在最前面(prepend),确保本插件的成员请求不会再弹出宿主审批 UI。
4199
4273
  ctx.effect(() => {
4200
4274
  const off = ctx.on('approval/request', (req, next) => onApprovalRequest(s, ctx, req, next), { prepend: true });
@@ -4226,13 +4300,13 @@ export function apply(ctx, config) {
4226
4300
  if (!entry) return result;
4227
4301
  const name = String(exec?.name || '');
4228
4302
  // 任务收工(done/failed)时清掉未触发的武装,避免会话结束后残留。
4229
- if (name === 'board_task_status' && exec?.arguments?.status !== 'inprogress') {
4303
+ if (name === 'dsh_team_board_task_status' && exec?.arguments?.status !== 'inprogress') {
4230
4304
  prewalkArmed.delete(sessionId);
4231
4305
  return result;
4232
4306
  }
4233
4307
  if (!boardPrewalkWantsTool(name)) return result;
4234
4308
  // 工具报错(参数错、权限拒绝等)不算「已经落到实现」:保持武装,等下一次
4235
- // 成功的 edit/write(或 team_task)再交接,避免接手模型先替规划模型收拾失败。
4309
+ // 成功的 edit/write(或 dsh_team_task)再交接,避免接手模型先替规划模型收拾失败。
4236
4310
  if (result && (result.isError === true || result.error != null)) return result;
4237
4311
  prewalkArmed.delete(sessionId);
4238
4312
  await boardHandoffExecution(ctx, exec.agent, entry.task, entry.settings);
@@ -4244,7 +4318,7 @@ export function apply(ctx, config) {
4244
4318
  prewalkHook.dshTeamHook = 'prewalk';
4245
4319
  ctx.on('tools/execute', prewalkHook);
4246
4320
 
4247
- // 成员用内置 todo_write 维护计划(没建 team_todo)时,把 DSH 的 `todos` 投影镜像成
4321
+ // 成员用内置 todo_write 维护计划(没建 dsh_team_todo)时,把 DSH 的 `todos` 投影镜像成
4248
4322
  // sidecar 计划步骤:面板/团队校验能看到真实 plan,todo 勾完计划步骤也跟着完成。
4249
4323
  ctx.on('tools/execute', async (exec, next) => {
4250
4324
  const result = await next();
@@ -4304,7 +4378,7 @@ export function apply(ctx, config) {
4304
4378
  idleTimers.delete(sessionId);
4305
4379
  if (heldSessions.has(sessionId)) { agentStatusBySession.set(sessionId, 'interrupted'); return; }
4306
4380
  if (agentStatusBySession.get(sessionId) !== 'idle') return; // 窗口内又跑起来了
4307
- // 把这一轮最后的正文带给 sidecar:漏调 team_report_task 时,兜底收尾的 task.done 也有摘要可看
4381
+ // 把这一轮最后的正文带给 sidecar:漏调 dsh_team_report_task 时,兜底收尾的 task.done 也有摘要可看
4308
4382
  const reply = lastReplyBySession.get(sessionId);
4309
4383
  reportAgentStatus(s, sessionId, 'idle', reply ? clip(reply, 500) : undefined);
4310
4384
  void flushMemberReply(s, sessionId).catch(() => { /* ignore */ });
@@ -4410,7 +4484,7 @@ export function apply(ctx, config) {
4410
4484
  }, 'dsh-team.workspace-pump()');
4411
4485
  }
4412
4486
 
4413
- // 模型目录泵:面板「模型路由」页不再依赖 lead 调 team_models。
4487
+ // 模型目录泵:面板「模型路由」页不再依赖 lead 调 dsh_team_models。
4414
4488
  // 启动即同步(sidecar 可能刚 spawn,失败 2s 重试),成功后按 llmCatalogMs 定时刷新。
4415
4489
  if (s.reportLlmCatalog) {
4416
4490
  ctx.effect(() => {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-team-control",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
- "description": "Expose the local dsh-team sidecar as model-facing tools (team_create / team_spawn / team_status / team_task / team_send / team_report_task / team_dispatch / team_control / team_approve / team_report), spawn real DSH sub-agent members with per-member permission presets, forward member approvals to the Lead, and manage the sidecar lifecycle.",
5
+ "description": "Expose the local dsh-team sidecar as model-facing tools (dsh_team_create / dsh_team_spawn / dsh_team_status / dsh_team_task / dsh_team_send / dsh_team_report_task / dsh_team_dispatch / dsh_team_control / dsh_team_approve / dsh_team_report), spawn real DSH sub-agent members with per-member permission presets, forward member approvals to the Lead, and manage the sidecar lifecycle.",
6
6
  "icon": "./icon.svg",
7
7
  "keywords": [
8
8
  "dsh",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "dsh-team-control-cli": "^0.2.9"
24
+ "dsh-team-control-cli": "^0.3.0"
25
25
  },
26
26
  "exports": {
27
27
  ".": "./index.js",