dsh-team-control 0.2.8 → 0.3.1
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.
- package/README.md +21 -21
- package/index.js +317 -144
- package/package.json +3 -3
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 调
|
|
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
|
-
//
|
|
205
|
-
//
|
|
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
|
-
// 成员跑完 →
|
|
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 保存用户勾选的子集与备注,
|
|
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」等于关思考,不是可派发的强度:既不进面板胶囊,也不进
|
|
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
|
-
// 面板与
|
|
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(见
|
|
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('所有模型路由都已停用:请先在面板「模型路由」页启用,或调用
|
|
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}。完整列表见
|
|
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;
|
|
@@ -735,6 +812,41 @@ async function assertRouteEnabled(s, ctx, provider, model, effort = null) {
|
|
|
735
812
|
}
|
|
736
813
|
}
|
|
737
814
|
|
|
815
|
+
/**
|
|
816
|
+
* 归一化看板建卡入参的模型路由:接受 { provider?, model, reasoningEffort? } 或
|
|
817
|
+
* "provider/model"/"model" 字符串;缺 model 返回 null(由调用方决定报错还是丢弃)。
|
|
818
|
+
*/
|
|
819
|
+
function normalizeBoardRoute(input) {
|
|
820
|
+
if (input == null) return null;
|
|
821
|
+
let provider = null;
|
|
822
|
+
let model = null;
|
|
823
|
+
let effort = null;
|
|
824
|
+
if (typeof input === 'string') {
|
|
825
|
+
const raw = input.trim();
|
|
826
|
+
const slash = raw.indexOf('/');
|
|
827
|
+
if (slash > 0) {
|
|
828
|
+
provider = raw.slice(0, slash).trim() || null;
|
|
829
|
+
model = raw.slice(slash + 1).trim() || null;
|
|
830
|
+
} else {
|
|
831
|
+
model = raw || null;
|
|
832
|
+
}
|
|
833
|
+
} else if (typeof input === 'object') {
|
|
834
|
+
provider = input.provider != null && String(input.provider).trim() ? String(input.provider).trim() : null;
|
|
835
|
+
model = input.model != null && String(input.model).trim() ? String(input.model).trim() : null;
|
|
836
|
+
effort = input.reasoningEffort != null && String(input.reasoningEffort).trim() ? String(input.reasoningEffort).trim() : null;
|
|
837
|
+
}
|
|
838
|
+
if (!model) return null;
|
|
839
|
+
return { provider, model, ...(effort ? { reasoningEffort: effort } : {}) };
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/** 显式 route 入参:undefined/null = 未设置,其余必须带 model,否则提前报错。 */
|
|
843
|
+
function boardRouteParam(input, label) {
|
|
844
|
+
if (input == null) return null;
|
|
845
|
+
const route = normalizeBoardRoute(input);
|
|
846
|
+
if (!route) throw new Error(`${label} 需要 model:传 { provider?, model, reasoningEffort? } 或 "provider/model"`);
|
|
847
|
+
return route;
|
|
848
|
+
}
|
|
849
|
+
|
|
738
850
|
function rememberMember(sessionId, teamId, memberId, cwd, permissionPreset = null, name = null) {
|
|
739
851
|
if (sessionId == null) return;
|
|
740
852
|
const key = String(sessionId);
|
|
@@ -752,14 +864,14 @@ function rememberMember(sessionId, teamId, memberId, cwd, permissionPreset = nul
|
|
|
752
864
|
|
|
753
865
|
async function teamOf(s, teamId, { refresh = false, sessionId = null } = {}) {
|
|
754
866
|
// 模型偶尔会漏掉必填的 teamId。先显式挡住,避免 /api/teams/undefined 被误报成「团队不存在」;
|
|
755
|
-
// 同一会话内
|
|
867
|
+
// 同一会话内 dsh_team_create 过的团队可以直接兜底(DSH 对直接注册的工具不做 required 运行时校验)。
|
|
756
868
|
const missing = teamId == null || String(teamId).trim() === '' || String(teamId) === 'undefined' || String(teamId) === 'null';
|
|
757
869
|
if (missing && sessionId) {
|
|
758
870
|
const bound = sessionMember.get(String(sessionId))?.teamId || teamBySession.get(String(sessionId));
|
|
759
871
|
if (bound) teamId = bound;
|
|
760
872
|
}
|
|
761
873
|
if (teamId == null || String(teamId).trim() === '' || String(teamId) === 'undefined' || String(teamId) === 'null') {
|
|
762
|
-
throw new Error('缺少 teamId:请把
|
|
874
|
+
throw new Error('缺少 teamId:请把 dsh_team_create 返回的 result.team.id(形如 team_xxx)作为 teamId 参数传入后重试。');
|
|
763
875
|
}
|
|
764
876
|
const key = String(teamId);
|
|
765
877
|
if (!refresh && teamCache.has(key)) return teamCache.get(key);
|
|
@@ -769,7 +881,7 @@ async function teamOf(s, teamId, { refresh = false, sessionId = null } = {}) {
|
|
|
769
881
|
return team;
|
|
770
882
|
} catch (err) {
|
|
771
883
|
if (err && err.status === 404) {
|
|
772
|
-
throw new Error(`团队不存在或 teamId 无效: ${key}(teamId 来自
|
|
884
|
+
throw new Error(`团队不存在或 teamId 无效: ${key}(teamId 来自 dsh_team_create 返回值,请核对后重试)`);
|
|
773
885
|
}
|
|
774
886
|
throw err;
|
|
775
887
|
}
|
|
@@ -813,7 +925,7 @@ async function resolveAgentPreset(ctx, requested, fallback, store = null) {
|
|
|
813
925
|
* 宿主默认 agentPreset 的 id。
|
|
814
926
|
*
|
|
815
927
|
* DSH 的 subagent 在 request 里省略 agentPreset 时,会继承父会话的实时组合
|
|
816
|
-
* (`composeFrom(parent)`),并不会自动套用宿主默认。因此
|
|
928
|
+
* (`composeFrom(parent)`),并不会自动套用宿主默认。因此 dsh_team_spawn 必须显式
|
|
817
929
|
* 把默认预设传下去,否则成员就只能拿到 Lead 根组合里的宿主级工具(比如没有 shell)。
|
|
818
930
|
*/
|
|
819
931
|
async function hostDefaultAgentPreset(ctx) {
|
|
@@ -835,7 +947,7 @@ async function hostDefaultAgentPreset(ctx) {
|
|
|
835
947
|
// ---------------------------------------------------------------------------
|
|
836
948
|
// Leader 自建 agentPreset
|
|
837
949
|
//
|
|
838
|
-
// 内置 preset 不满足时,Lead 用
|
|
950
|
+
// 内置 preset 不满足时,Lead 用 dsh_team_preset({action:'save'}) 把一份组合定义写到固定目录,
|
|
839
951
|
// 并立刻调用宿主 `agentPresets.register()` 生效(无需重启 DSH)。目录里的 JSON 文档
|
|
840
952
|
// (JSON 是合法 YAML)在插件启动时也会被重新注册,因此跨会话可复用。
|
|
841
953
|
// ---------------------------------------------------------------------------
|
|
@@ -1073,18 +1185,17 @@ function taskBrief(teamId, task, member) {
|
|
|
1073
1185
|
'',
|
|
1074
1186
|
'执行要求:',
|
|
1075
1187
|
'1) 直接在本会话里做这件事(用你自己的工具,不要委派给别的 agent)。',
|
|
1076
|
-
'2) 每开始或完成一步、以及验收通过后,调用
|
|
1077
|
-
'3) 收工前,如果这次任务产生了对后续任务可复用的结论(接口约定、坑、决策理由、未决问题),调用
|
|
1078
|
-
'4) 完成或失败后必须调用
|
|
1079
|
-
`
|
|
1080
|
-
'5) 需要 Lead 决策或补充信息时用
|
|
1188
|
+
'2) 每开始或完成一步、以及验收通过后,调用 dsh_team_todo 更新该任务的计划清单(teamId/taskId 同上)。',
|
|
1189
|
+
'3) 收工前,如果这次任务产生了对后续任务可复用的结论(接口约定、坑、决策理由、未决问题),调用 dsh_team_memory_write 存一条简短 handoff(scope="member",kind="handoff",value 不超过 300 字);没有可复用结论就跳过,不要为了留记忆而写。只有 Lead 明确要求上传时才写 scope="team"。',
|
|
1190
|
+
'4) 完成或失败后必须调用 dsh_team_report_task,例如:',
|
|
1191
|
+
` dsh_team_report_task({ teamId: "${teamId}", taskId: "${task.id}", status: "done", summary: "一句话结果 + 关键产物路径" })`,
|
|
1192
|
+
'5) 需要 Lead 决策或补充信息时用 dsh_team_send(teamId 同上,to: "lead"),不要自己猜测。',
|
|
1081
1193
|
].join('\n');
|
|
1082
1194
|
}
|
|
1083
1195
|
|
|
1084
1196
|
/** 把任务投递给成员:由 Lead 发一条消息进成员信箱(running 时在最近 step 边界送达)。 */
|
|
1085
1197
|
async function deliverTask(s, ctx, lead, teamId, task, member) {
|
|
1086
|
-
|
|
1087
|
-
if (!subs || typeof subs.sendMessage !== 'function') throw new Error('subagents 服务不可用,无法派发给 agent 成员');
|
|
1198
|
+
if (!canDeliverTo(ctx, lead)) throw new Error('subagents 服务不可用,无法派发给 agent 成员');
|
|
1088
1199
|
if (!member.agentSessionId) throw new Error(`成员 ${member.name} 还没有绑定 sub-agent 会话`);
|
|
1089
1200
|
const brief = taskBrief(teamId, task, member);
|
|
1090
1201
|
// 简报本身就是一条 Lead→成员的消息:先落信箱,面板【消息与回执】才有「提问 → 回复」可配对;
|
|
@@ -1097,8 +1208,9 @@ async function deliverTask(s, ctx, lead, teamId, task, member) {
|
|
|
1097
1208
|
});
|
|
1098
1209
|
messageId = recorded?.message?.id || null;
|
|
1099
1210
|
} catch { messageId = null; }
|
|
1100
|
-
|
|
1101
|
-
|
|
1211
|
+
await sendAgentMessage(ctx, lead, String(member.agentSessionId), brief, {
|
|
1212
|
+
signal: AbortSignal.timeout(s.requestTimeoutMs),
|
|
1213
|
+
});
|
|
1102
1214
|
await markDelivered(s, messageId);
|
|
1103
1215
|
}
|
|
1104
1216
|
|
|
@@ -1154,7 +1266,7 @@ async function dispatchLoop(s, ctx, teamId) {
|
|
|
1154
1266
|
}
|
|
1155
1267
|
}
|
|
1156
1268
|
|
|
1157
|
-
// ---------- 权限审批转发:成员 preset 触发 approval/request → Lead 用
|
|
1269
|
+
// ---------- 权限审批转发:成员 preset 触发 approval/request → Lead 用 dsh_team_approve 决定 ----------
|
|
1158
1270
|
const pendingApprovals = new Map();
|
|
1159
1271
|
|
|
1160
1272
|
// 审批分类:approval/request 只带 toolName 与 callId,不带命令参数;
|
|
@@ -1306,8 +1418,7 @@ function cancelPendingApprovals() {
|
|
|
1306
1418
|
}
|
|
1307
1419
|
|
|
1308
1420
|
async function notifyLeadOfApproval(s, ctx, req, info) {
|
|
1309
|
-
|
|
1310
|
-
if (!subs || typeof subs.sendMessage !== 'function' || !req?.agent) return false;
|
|
1421
|
+
if (!req?.agent || !canDeliverTo(ctx, req.agent)) return false;
|
|
1311
1422
|
const team = await teamOf(s, info.teamId);
|
|
1312
1423
|
const leadId = leadByTeam.get(info.teamId)?.id != null
|
|
1313
1424
|
? String(leadByTeam.get(info.teamId).id)
|
|
@@ -1324,11 +1435,11 @@ async function notifyLeadOfApproval(s, ctx, req, info) {
|
|
|
1324
1435
|
`requestId=${info.requestId}`,
|
|
1325
1436
|
'',
|
|
1326
1437
|
`成员因 permissionPreset「${info.preset || 'unknown'}」的审批策略暂停,等待你决定。`,
|
|
1327
|
-
`批准本次操作:
|
|
1438
|
+
`批准本次操作:dsh_team_approve({ teamId: "${info.teamId}", requestId: "${info.requestId}", decision: "allow" })`,
|
|
1328
1439
|
`拒绝:把 decision 改成 "deny"(可加 reason)。`,
|
|
1329
1440
|
`超过 ${minutes} 分钟未决定将自动拒绝。`,
|
|
1330
1441
|
].join('\n');
|
|
1331
|
-
await
|
|
1442
|
+
await sendAgentMessage(ctx, req.agent, leadId, text, { signal: AbortSignal.timeout(s.requestTimeoutMs) });
|
|
1332
1443
|
return true;
|
|
1333
1444
|
}
|
|
1334
1445
|
|
|
@@ -1344,14 +1455,13 @@ const interruptNotified = new Set();
|
|
|
1344
1455
|
* 会话已经回收时发不出去——那种情况事件流/面板里仍有记录,不阻塞其它泵。
|
|
1345
1456
|
*/
|
|
1346
1457
|
async function notifyLeadOfMemberInterrupt(s, ctx, info) {
|
|
1347
|
-
|
|
1348
|
-
if (!subs || typeof subs.sendMessage !== 'function' || !info) return false;
|
|
1458
|
+
if (!info) return false;
|
|
1349
1459
|
const sessionId = info.sessionId != null ? String(info.sessionId) : null;
|
|
1350
1460
|
const teamId = info.teamId != null ? String(info.teamId) : null;
|
|
1351
1461
|
if (!sessionId || !teamId) return false;
|
|
1352
1462
|
const agents = agentsOf(ctx);
|
|
1353
1463
|
const sender = agents && typeof agents.get === 'function' ? agents.get(sessionId) : undefined;
|
|
1354
|
-
if (!sender) return false;
|
|
1464
|
+
if (!sender || !canDeliverTo(ctx, sender)) return false;
|
|
1355
1465
|
let leadId = info.leadSessionId != null ? String(info.leadSessionId) : null;
|
|
1356
1466
|
if (!leadId) {
|
|
1357
1467
|
const cached = leadByTeam.get(teamId);
|
|
@@ -1378,13 +1488,13 @@ async function notifyLeadOfMemberInterrupt(s, ctx, info) {
|
|
|
1378
1488
|
? '该成员的回合以错误结束,任务按失败重试策略处理(可能已重新派发);反复失败需要你介入。'
|
|
1379
1489
|
: '该成员没有正常收工,任务不会被当成完成;中断后它需要你确认才能继续。',
|
|
1380
1490
|
info.status === 'failed'
|
|
1381
|
-
? `下一步:
|
|
1491
|
+
? `下一步:dsh_team_status({ teamId: "${teamId}" }) 看进度;需要人工接手时用 dsh_team_task/dsh_team_member 调整。`
|
|
1382
1492
|
: (info.memberId
|
|
1383
|
-
? `下一步:
|
|
1384
|
-
: `下一步:
|
|
1493
|
+
? `下一步:dsh_team_status({ teamId: "${teamId}" }) 看进度;确认后 dsh_team_control({ teamId: "${teamId}", memberId: "${info.memberId}", action: "resume" }) 继续。`
|
|
1494
|
+
: `下一步:dsh_team_status({ teamId: "${teamId}" }) 看进度;确认后 dsh_team_dispatch 重新派发。`),
|
|
1385
1495
|
];
|
|
1386
1496
|
try {
|
|
1387
|
-
await
|
|
1497
|
+
await sendAgentMessage(ctx, sender, leadId, lines.join('\n'), {
|
|
1388
1498
|
signal: AbortSignal.timeout(s.requestTimeoutMs),
|
|
1389
1499
|
});
|
|
1390
1500
|
return true;
|
|
@@ -1664,7 +1774,7 @@ async function forceStopPump(s, ctx) {
|
|
|
1664
1774
|
const TODO_TO_PLAN = { pending: 'open', in_progress: 'active', completed: 'done' };
|
|
1665
1775
|
|
|
1666
1776
|
/**
|
|
1667
|
-
* 成员没用
|
|
1777
|
+
* 成员没用 dsh_team_todo、而是用了内置 todo_write 时,把 DSH 的 `todos` 投影镜像成 sidecar 计划。
|
|
1668
1778
|
* todo_write 每次整份替换,这里也整份替换(POST /api/tasks/<taskId>/todos),
|
|
1669
1779
|
* 于是「todo 完成 → 计划步骤完成」自动同步,面板与团队校验都能看到成员的真实 plan。
|
|
1670
1780
|
*/
|
|
@@ -1736,14 +1846,12 @@ const steerInFlight = new Set();
|
|
|
1736
1846
|
|
|
1737
1847
|
async function steerPump(s, ctx) {
|
|
1738
1848
|
if (!sessionMember.size) return;
|
|
1739
|
-
const subs = subagentsOf(ctx);
|
|
1740
|
-
if (!subs || typeof subs.sendMessage !== 'function') return;
|
|
1741
1849
|
const teams = new Set();
|
|
1742
1850
|
for (const binding of sessionMember.values()) if (binding?.teamId) teams.add(binding.teamId);
|
|
1743
1851
|
|
|
1744
1852
|
for (const teamId of teams) {
|
|
1745
1853
|
const caller = leadByTeam.get(teamId);
|
|
1746
|
-
if (!caller) continue;
|
|
1854
|
+
if (!caller || !canDeliverTo(ctx, caller)) continue;
|
|
1747
1855
|
const res = await request(
|
|
1748
1856
|
s,
|
|
1749
1857
|
`/api/messages${qs({ team: teamId, status: 'queued', limit: 100 })}`,
|
|
@@ -1770,7 +1878,7 @@ async function steerPump(s, ctx) {
|
|
|
1770
1878
|
if (!text) { await markDelivered(s, message.id); continue; }
|
|
1771
1879
|
steerInFlight.add(message.id);
|
|
1772
1880
|
try {
|
|
1773
|
-
await
|
|
1881
|
+
await sendAgentMessage(ctx, caller, String(binding[0]), text, {
|
|
1774
1882
|
signal: AbortSignal.timeout(s.requestTimeoutMs),
|
|
1775
1883
|
});
|
|
1776
1884
|
await markDelivered(s, message.id);
|
|
@@ -1797,7 +1905,7 @@ function assistantReplyText(message) {
|
|
|
1797
1905
|
|
|
1798
1906
|
/**
|
|
1799
1907
|
* 把成员这一轮的结论作为 member→lead 的消息落库(kind=response)。
|
|
1800
|
-
* 成员用 send_message /
|
|
1908
|
+
* 成员用 send_message / dsh_team_report_task 回话都不经过消息总线,面板里只剩 Lead 单向提问;
|
|
1801
1909
|
* 收工时补一条回复,【消息与回执】才能配对成双向箭头并展示两条正文。
|
|
1802
1910
|
*/
|
|
1803
1911
|
async function flushMemberReply(s, sessionId) {
|
|
@@ -2023,11 +2131,11 @@ async function boardApplyExecutionModel(ctx, agent, task, settings) {
|
|
|
2023
2131
|
* 触发 prewalk 交接的「实现动作」。
|
|
2024
2132
|
*
|
|
2025
2133
|
* 对齐官方语义:不在计划提交时切换,而是等规划模型在同一条会话里落下第一笔实现
|
|
2026
|
-
* 动作之后(首个 edit/write 类工具结果;团队任务则是 Lead 的首次
|
|
2134
|
+
* 动作之后(首个 edit/write 类工具结果;团队任务则是 Lead 的首次 dsh_team_task 派发),
|
|
2027
2135
|
* 再把剩下的活交给执行模型,避免便宜模型接手后才发现计划不可执行。
|
|
2028
2136
|
*/
|
|
2029
2137
|
const PREWALK_EDIT_TOOLS = new Set(['write', 'edit', 'str_replace_editor']);
|
|
2030
|
-
const PREWALK_DISPATCH_TOOLS = new Set(['
|
|
2138
|
+
const PREWALK_DISPATCH_TOOLS = new Set(['dsh_team_task']);
|
|
2031
2139
|
|
|
2032
2140
|
/** 执行阶段已武装、等待首次实现动作的会话:sessionId → { task, settings }。 */
|
|
2033
2141
|
const prewalkArmed = new Map();
|
|
@@ -2158,7 +2266,7 @@ function boardBranchLines(task) {
|
|
|
2158
2266
|
|
|
2159
2267
|
function boardPlanningPrompt(task, settings) {
|
|
2160
2268
|
const useTeam = task.useTeam !== false;
|
|
2161
|
-
// 同会话模式:规划与执行是同一个会话,
|
|
2269
|
+
// 同会话模式:规划与执行是同一个会话,dsh_team_board_plan_submit 会直接领执行槽位,
|
|
2162
2270
|
// 所以执行规则从一开始就写进规划 prompt,提交后不再补发「现在开始执行」。
|
|
2163
2271
|
const sameSession = task.executionMode === 'same';
|
|
2164
2272
|
const models = boardPromptModels(task);
|
|
@@ -2168,7 +2276,7 @@ function boardPlanningPrompt(task, settings) {
|
|
|
2168
2276
|
? '这一轮先只做规划,不要写代码、不要修改文件、不要创建团队。'
|
|
2169
2277
|
: '只做规划,不写代码、不修改文件、不创建团队。',
|
|
2170
2278
|
sameSession
|
|
2171
|
-
? '计划提交后读取
|
|
2279
|
+
? '计划提交后读取 dsh_team_board_plan_submit 的返回:status 是 inprogress 就直接在同一会话里按计划开始执行(此时可以写文件、可以调用 team_*);status 是 planned 说明执行槽位已满,立刻停下等待调度器。'
|
|
2172
2280
|
: '规划完成后不要开始执行;调度器会在执行槽位空出后,在同一会话里让你继续。',
|
|
2173
2281
|
'',
|
|
2174
2282
|
`工作区:${task.workspacePath}`,
|
|
@@ -2202,7 +2310,7 @@ function boardPlanningPrompt(task, settings) {
|
|
|
2202
2310
|
...head,
|
|
2203
2311
|
...body,
|
|
2204
2312
|
'',
|
|
2205
|
-
'最后必须调用
|
|
2313
|
+
'最后必须调用 dsh_team_board_plan_submit({ plan: "<完整 markdown>", summary: "<一句话>" })。',
|
|
2206
2314
|
'不要只把计划写在回复里。',
|
|
2207
2315
|
...(sameSession
|
|
2208
2316
|
? ['', '提交后如果返回 inprogress,继续按下面的规则执行;返回 planned 则忽略这些规则并停下:', '', ...boardLeadRules(task)]
|
|
@@ -2214,21 +2322,21 @@ function boardLeadRules(task) {
|
|
|
2214
2322
|
const useTeam = task.useTeam !== false;
|
|
2215
2323
|
const models = boardPromptModels(task);
|
|
2216
2324
|
// 任务已有关联团队(重试、失败后继续、或完成后再次执行)时,在原团队上接着干,
|
|
2217
|
-
// 不要每轮都
|
|
2325
|
+
// 不要每轮都 dsh_team_create 出一个新团队。
|
|
2218
2326
|
const teams = Array.isArray(task.teams) ? task.teams.filter(Boolean).map(String) : [];
|
|
2219
2327
|
const teamRule = teams.length
|
|
2220
|
-
? `1. 本任务已关联团队:${teams.join('、')}。不要调用
|
|
2221
|
-
+ '在原团队里用
|
|
2222
|
-
+ '只有原团队已被删除或全部不可用时,才允许
|
|
2223
|
-
: '1. 先调用
|
|
2328
|
+
? `1. 本任务已关联团队:${teams.join('、')}。不要调用 dsh_team_create 新建团队:先 dsh_team_status 查看这些团队的现状,`
|
|
2329
|
+
+ '在原团队里用 dsh_team_task 追加剩余工作继续推进;已经完成的成员任务不要重复创建。'
|
|
2330
|
+
+ '只有原团队已被删除或全部不可用时,才允许 dsh_team_create 新团队(若既有团队需要继续保留、只是要并行新建,必须显式传 force: true)。'
|
|
2331
|
+
: '1. 先调用 dsh_team_create 创建团队;name 用任务标题,workspace 用上面的路径。需要多个团队就多次创建,所有团队都会自动绑定到本任务。';
|
|
2224
2332
|
// 用户嘴里的「新任务」经常被 Lead 误当成当前团队的 DAG 节点:先强制做归属判断。
|
|
2225
2333
|
const scopeRules = [
|
|
2226
2334
|
'先判断用户这次说的事是不是「新任务」:',
|
|
2227
2335
|
'- 同一目标 / 同一模块或文件 / 同一验收 / 同一分支 → 是本任务的一部分,在本任务(或本团队)里继续推进。',
|
|
2228
|
-
'- 交付物或验收不同、需要单独分支或单独规划、做完之后不再依赖本任务上下文 → 这是独立的一件事:调用
|
|
2229
|
-
'- 用户明确说「建看板任务 / 加一张卡 / 单开一个会话」→ 一律
|
|
2336
|
+
'- 交付物或验收不同、需要单独分支或单独规划、做完之后不再依赖本任务上下文 → 这是独立的一件事:调用 dsh_team_board_task_create 给它建一张看板卡(workspaceId / workspacePath 沿用本任务),不要用 dsh_team_task 塞进当前团队。',
|
|
2337
|
+
'- 用户明确说「建看板任务 / 加一张卡 / 单开一个会话」→ 一律 dsh_team_board_task_create,禁止 dsh_team_task。',
|
|
2230
2338
|
'- 判断不清就先问用户一句「这算当前任务的一部分,还是另开一张卡?」,不要猜。',
|
|
2231
|
-
'记住:
|
|
2339
|
+
'记住:dsh_team_task 只拆解当前任务,它不会出现在用户的看板上;用户说的「任务」通常指看板卡片。',
|
|
2232
2340
|
];
|
|
2233
2341
|
const teamRules = [
|
|
2234
2342
|
'开始执行前,先加载 `dsh-agent-team` 技能(调用 skill 工具,参数 {"name":"dsh-agent-team"}),按技能里的团队编排流程、工具字段与常见错法执行,不要凭记忆猜参数。',
|
|
@@ -2237,22 +2345,22 @@ function boardLeadRules(task) {
|
|
|
2237
2345
|
'',
|
|
2238
2346
|
'规则:',
|
|
2239
2347
|
teamRule,
|
|
2240
|
-
'2. 调用
|
|
2348
|
+
'2. 调用 dsh_team_models 查看可用路由;只能使用以下模型:',
|
|
2241
2349
|
models,
|
|
2242
|
-
'3. 用
|
|
2243
|
-
'4. 用户反馈 Bug 时,不要自己去读代码排查:先判断归属成员,用
|
|
2244
|
-
'5. 每轮结束前必须先调用
|
|
2245
|
-
'6. 用户再次发消息时,先调用
|
|
2350
|
+
'3. 用 dsh_team_task 拆解并派发;用 dsh_team_status / dsh_team_report 跟踪。不要自己写代码,不要重复成员的工作。成员按能力域分配:同一模块/相邻功能、或一个成员能顺手做完的多个条目,合并给同一个成员;成员数取能完成工作的最小值,不要按需求条目数量等量创建成员。',
|
|
2351
|
+
'4. 用户反馈 Bug 时,不要自己去读代码排查:先判断归属成员,用 dsh_team_send 把复现步骤与怀疑点派给对应成员定位、修复;你只做分派、汇总与状态汇报。',
|
|
2352
|
+
'5. 每轮结束前必须先调用 dsh_team_board_task_status 对齐状态:全部任务成功→done(附完成摘要),失败→failed(附原因),仍需继续或等待用户→inprogress。不能只在开始时调用一次。',
|
|
2353
|
+
'6. 用户再次发消息时,先调用 dsh_team_board_task_status({ status: "inprogress" }),再继续处理。',
|
|
2246
2354
|
];
|
|
2247
2355
|
const soloRules = [
|
|
2248
|
-
'本任务不开启团队:由你自己直接完成所有工作,不要调用
|
|
2356
|
+
'本任务不开启团队:由你自己直接完成所有工作,不要调用 dsh_team_create / dsh_team_spawn / dsh_team_task。',
|
|
2249
2357
|
'',
|
|
2250
2358
|
...scopeRules,
|
|
2251
2359
|
'',
|
|
2252
2360
|
'规则:',
|
|
2253
2361
|
'1. 按任务描述直接修改文件、运行命令并验证结果。',
|
|
2254
|
-
'2. 每轮结束前必须先调用
|
|
2255
|
-
'3. 用户再次发消息时,先调用
|
|
2362
|
+
'2. 每轮结束前必须先调用 dsh_team_board_task_status 对齐状态:全部完成→done(附完成摘要),失败→failed(附原因),仍需继续或等待用户→inprogress。不能只在开始时调用一次。',
|
|
2363
|
+
'3. 用户再次发消息时,先调用 dsh_team_board_task_status({ status: "inprogress" }),再继续处理。',
|
|
2256
2364
|
];
|
|
2257
2365
|
return useTeam ? teamRules : soloRules;
|
|
2258
2366
|
}
|
|
@@ -2321,8 +2429,8 @@ async function guardBoardTeamReuse(s, sessionId, force) {
|
|
|
2321
2429
|
}
|
|
2322
2430
|
if (!alive.length) return;
|
|
2323
2431
|
throw new Error(
|
|
2324
|
-
`本任务已关联团队:${alive.join('、')}。重试/续跑请在原团队上继续:先用
|
|
2325
|
-
+ '确实需要与之并行新建团队时,调用
|
|
2432
|
+
`本任务已关联团队:${alive.join('、')}。重试/续跑请在原团队上继续:先用 dsh_team_status 查看现状,再用 dsh_team_task 追加剩余工作,不要重复 dsh_team_create。`
|
|
2433
|
+
+ '确实需要与之并行新建团队时,调用 dsh_team_create 并显式传 force: true。',
|
|
2326
2434
|
);
|
|
2327
2435
|
}
|
|
2328
2436
|
|
|
@@ -2559,16 +2667,16 @@ function buildTools(s, ctx) {
|
|
|
2559
2667
|
const tools = [];
|
|
2560
2668
|
|
|
2561
2669
|
tools.push({
|
|
2562
|
-
name: '
|
|
2563
|
-
description: 'START HERE to build a working team of agents.
|
|
2670
|
+
name: 'dsh_team_create',
|
|
2671
|
+
description: 'START HERE to build a working team of agents — but only AFTER two gates: (1) CLARIFY: if the request is vague, grill the user in numbered rounds, each question with your recommended answer, until scope/acceptance are settled — facts are yours to look up (read code, run commands, or dispatch a throwaway subagent), decisions belong to the user; (2) RESEARCH: read the workspace AGENTS.md/CLAUDE.md and the relevant code so the brief names real files, current behavior and constraints. Do not dispatch on a one-line request. Then: 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
2672
|
parameters: {
|
|
2565
2673
|
type: 'object',
|
|
2566
2674
|
additionalProperties: false,
|
|
2567
2675
|
properties: {
|
|
2568
2676
|
name: { type: 'string', description: 'Team name.' },
|
|
2569
2677
|
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.
|
|
2571
|
-
agentPreset: { type: 'string', description: 'Default DSH agent preset (composition: tools/skills/MCP + system prompt) for members. Omit to use the host default.
|
|
2678
|
+
permissionPreset: { type: 'string', description: 'Default DSH permission preset for members (sandbox + approval policy). Default workspace-write. dsh_team_spawn can override it per member.' },
|
|
2679
|
+
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
2680
|
maxMembers: { type: 'integer', description: 'Member cap, 0 means unlimited. Default 64. Extra members are queued, never errors.' },
|
|
2573
2681
|
maxConcurrency: { type: 'integer', description: 'Max simultaneously running tasks. Default 8.' },
|
|
2574
2682
|
failurePolicy: { type: 'string', enum: ['continue', 'abort'], description: 'Team-level default failure policy.' },
|
|
@@ -2598,7 +2706,7 @@ function buildTools(s, ctx) {
|
|
|
2598
2706
|
});
|
|
2599
2707
|
teamCache.set(team.id, team);
|
|
2600
2708
|
if (exec?.agent) leadByTeam.set(team.id, exec.agent);
|
|
2601
|
-
// 会话级粘性绑定:即使后续
|
|
2709
|
+
// 会话级粘性绑定:即使后续 dsh_team_spawn 漏传 teamId,也能解析到本会话刚建的团队。
|
|
2602
2710
|
if (exec?.agent?.id != null) teamBySession.set(String(exec.agent.id), String(team.id));
|
|
2603
2711
|
await bindBoardTeam(s, exec, team.id);
|
|
2604
2712
|
return { team, panel: panelUrl(s) };
|
|
@@ -2606,22 +2714,22 @@ function buildTools(s, ctx) {
|
|
|
2606
2714
|
});
|
|
2607
2715
|
|
|
2608
2716
|
tools.push({
|
|
2609
|
-
name: '
|
|
2610
|
-
description: "Add one member to a team; returns the member `id` you use as
|
|
2717
|
+
name: 'dsh_team_spawn',
|
|
2718
|
+
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
2719
|
parameters: {
|
|
2612
2720
|
type: 'object',
|
|
2613
2721
|
additionalProperties: false,
|
|
2614
2722
|
properties: {
|
|
2615
|
-
teamId: { type: 'string', description: '
|
|
2723
|
+
teamId: { type: 'string', description: 'dsh_team_create 返回的 result.team.id(形如 team_xxx)。漏传时自动使用当前会话刚创建的团队。' },
|
|
2616
2724
|
name: { type: 'string', description: 'Unique member name inside the team; this is the addressable target.' },
|
|
2617
2725
|
role: { type: 'string', description: 'Role label shown on the panel.' },
|
|
2618
2726
|
permissionPreset: { type: 'string', description: "DSH permission preset for this member (sandbox + approval policy). Defaults to the team's permissionPreset." },
|
|
2619
2727
|
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
|
|
2621
|
-
model: { type: 'string', description: 'LLM model id, as returned by
|
|
2728
|
+
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.' },
|
|
2729
|
+
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
2730
|
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
2731
|
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
|
|
2732
|
+
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
2733
|
description: { type: 'string', description: 'One-line description of what this member is responsible for.' },
|
|
2626
2734
|
},
|
|
2627
2735
|
required: ['teamId', 'name', 'prompt'],
|
|
@@ -2638,8 +2746,8 @@ function buildTools(s, ctx) {
|
|
|
2638
2746
|
throw new Error('subagents 服务不可用:无法创建 sub-agent 成员(需要宿主启用 dsh-subagent)。');
|
|
2639
2747
|
}
|
|
2640
2748
|
const caller = exec?.agent;
|
|
2641
|
-
if (!caller) throw new Error('
|
|
2642
|
-
if (!args.prompt) throw new Error('
|
|
2749
|
+
if (!caller) throw new Error('dsh_team_spawn 需要 Lead 会话上下文(exec.agent 缺失:不能在非 agent 调用里起成员)。');
|
|
2750
|
+
if (!args.prompt) throw new Error('dsh_team_spawn 需要 prompt(成员的初始指令)。');
|
|
2643
2751
|
|
|
2644
2752
|
const context = args.contextMode === 'fork' ? 'fork' : 'fresh';
|
|
2645
2753
|
// 省略 preset 时 DSH 继承 Lead 的实时组合,不会套宿主默认;
|
|
@@ -2701,7 +2809,7 @@ function buildTools(s, ctx) {
|
|
|
2701
2809
|
label: memberLabel(memberName, description),
|
|
2702
2810
|
signal: exec.signal || AbortSignal.timeout(s.requestTimeoutMs),
|
|
2703
2811
|
}));
|
|
2704
|
-
// 成员跑的是一整轮 agent loop,结果由
|
|
2812
|
+
// 成员跑的是一整轮 agent loop,结果由 dsh_team_report_task 汇报;这里只防止未处理的 rejection。
|
|
2705
2813
|
if (started && started.result && typeof started.result.catch === 'function') started.result.catch(() => {});
|
|
2706
2814
|
// 子会话发布后立刻把 preset 落到会话(会覆盖 subagent 继承来的 approval=never)。
|
|
2707
2815
|
const presetResult = applyPermissionPreset(ctx, sessionId, permissionPreset);
|
|
@@ -2751,8 +2859,8 @@ function buildTools(s, ctx) {
|
|
|
2751
2859
|
});
|
|
2752
2860
|
|
|
2753
2861
|
tools.push({
|
|
2754
|
-
name: '
|
|
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
|
|
2862
|
+
name: 'dsh_team_models',
|
|
2863
|
+
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
2864
|
parameters: {
|
|
2757
2865
|
type: 'object',
|
|
2758
2866
|
additionalProperties: false,
|
|
@@ -2784,7 +2892,7 @@ function buildTools(s, ctx) {
|
|
|
2784
2892
|
};
|
|
2785
2893
|
});
|
|
2786
2894
|
const hint = models.length
|
|
2787
|
-
? '在
|
|
2895
|
+
? '在 dsh_team_spawn 里用 agentProvider + model;providerNote 是该厂商整体强项(用户填写的厂商备注),note 是单模型差异;'
|
|
2788
2896
|
+ 'efforts 是该 route 允许派发的 reasoningEffort 列表(省略时只在 route 不变时继承 Lead 的 effort,被禁止的 effort 会被拒绝)。'
|
|
2789
2897
|
: '没有启用的模型路由:请让用户在面板「模型路由」页勾选需要的 provider/model。';
|
|
2790
2898
|
return {
|
|
@@ -2797,8 +2905,8 @@ function buildTools(s, ctx) {
|
|
|
2797
2905
|
});
|
|
2798
2906
|
|
|
2799
2907
|
tools.push({
|
|
2800
|
-
name: '
|
|
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
|
|
2908
|
+
name: 'dsh_team_preset',
|
|
2909
|
+
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
2910
|
parameters: {
|
|
2803
2911
|
type: 'object',
|
|
2804
2912
|
additionalProperties: false,
|
|
@@ -2851,8 +2959,8 @@ function buildTools(s, ctx) {
|
|
|
2851
2959
|
});
|
|
2852
2960
|
|
|
2853
2961
|
tools.push({
|
|
2854
|
-
name: '
|
|
2855
|
-
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.',
|
|
2962
|
+
name: 'dsh_team_status',
|
|
2963
|
+
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. Read it once when reporting to the user; do not call it repeatedly to watch a running member — a rising `seq` already proves it is working, and the host wakes the Lead when it finishes.',
|
|
2856
2964
|
parameters: {
|
|
2857
2965
|
type: 'object',
|
|
2858
2966
|
additionalProperties: false,
|
|
@@ -2899,13 +3007,13 @@ function buildTools(s, ctx) {
|
|
|
2899
3007
|
});
|
|
2900
3008
|
|
|
2901
3009
|
tools.push({
|
|
2902
|
-
name: '
|
|
3010
|
+
name: 'dsh_team_task_get',
|
|
2903
3011
|
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
3012
|
parameters: {
|
|
2905
3013
|
type: 'object',
|
|
2906
3014
|
additionalProperties: false,
|
|
2907
3015
|
properties: {
|
|
2908
|
-
taskId: { type: 'string', description: 'Task id returned by
|
|
3016
|
+
taskId: { type: 'string', description: 'Task id returned by dsh_team_task (task_…).' },
|
|
2909
3017
|
teamId: { type: 'string', description: 'Optional ownership check; inferred from the caller session when omitted.' },
|
|
2910
3018
|
},
|
|
2911
3019
|
required: ['taskId'],
|
|
@@ -2915,7 +3023,7 @@ function buildTools(s, ctx) {
|
|
|
2915
3023
|
async execute(args) {
|
|
2916
3024
|
const task = await request(s, `/api/tasks/${encodeURIComponent(args.taskId)}`);
|
|
2917
3025
|
const teamId = String(args.teamId || task.teamId || '');
|
|
2918
|
-
if (!teamId) throw new Error('
|
|
3026
|
+
if (!teamId) throw new Error('dsh_team_task_get 无法确定 teamId:请显式传入');
|
|
2919
3027
|
if (args.teamId && String(task.teamId) !== String(args.teamId)) {
|
|
2920
3028
|
throw new Error(`task ${task.id} 不属于 team ${args.teamId}`);
|
|
2921
3029
|
}
|
|
@@ -2927,8 +3035,8 @@ function buildTools(s, ctx) {
|
|
|
2927
3035
|
});
|
|
2928
3036
|
|
|
2929
3037
|
tools.push({
|
|
2930
|
-
name: '
|
|
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
|
|
3038
|
+
name: 'dsh_team_task',
|
|
3039
|
+
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. Never create a duplicate task or re-send a brief just to nudge a member that is still running — wait for its dsh_team_report_task.',
|
|
2932
3040
|
parameters: {
|
|
2933
3041
|
type: 'object',
|
|
2934
3042
|
additionalProperties: false,
|
|
@@ -2944,7 +3052,7 @@ function buildTools(s, ctx) {
|
|
|
2944
3052
|
type: 'object',
|
|
2945
3053
|
additionalProperties: false,
|
|
2946
3054
|
properties: {
|
|
2947
|
-
from: { type: 'string', description: 'Upstream **task** id (starts with task_), taken from the
|
|
3055
|
+
from: { type: 'string', description: 'Upstream **task** id (starts with task_), taken from the dsh_team_task result — not a member id.' },
|
|
2948
3056
|
condition: { type: 'string', enum: ['all_success', 'any_success', 'on_failure', 'artifact_exists'] },
|
|
2949
3057
|
artifactPath: { type: 'string', description: 'Workspace-relative path for condition=artifact_exists.' },
|
|
2950
3058
|
},
|
|
@@ -2955,7 +3063,7 @@ function buildTools(s, ctx) {
|
|
|
2955
3063
|
priority: { type: 'integer', description: 'Smaller runs first. Default 0.' },
|
|
2956
3064
|
failurePolicy: { type: 'string', enum: ['continue', 'skip', 'abort_team', 'retry'] },
|
|
2957
3065
|
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
|
|
3066
|
+
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
3067
|
},
|
|
2960
3068
|
required: ['teamId', 'subject', 'plan'],
|
|
2961
3069
|
},
|
|
@@ -2984,8 +3092,8 @@ function buildTools(s, ctx) {
|
|
|
2984
3092
|
});
|
|
2985
3093
|
|
|
2986
3094
|
tools.push({
|
|
2987
|
-
name: '
|
|
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
|
|
3095
|
+
name: 'dsh_team_send',
|
|
3096
|
+
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. This is a REDIRECTION tool, not a progress-nudge tool: while a member is still running do NOT use it to ask how it is going, whether it is done, or to re-send the brief — the default interrupt discards its in-flight step and pushes it to wrap up early just to answer. Send once only when the member is blocked, reported an error, or you must correct a wrong direction (prefer interrupt:false for that), then end the turn.",
|
|
2989
3097
|
parameters: {
|
|
2990
3098
|
type: 'object',
|
|
2991
3099
|
additionalProperties: false,
|
|
@@ -2994,7 +3102,7 @@ function buildTools(s, ctx) {
|
|
|
2994
3102
|
to: { type: 'string', description: "Member name (agent teams) or member id, or '*' for broadcast." },
|
|
2995
3103
|
message: { type: 'string', description: 'Message body.' },
|
|
2996
3104
|
correlationId: { type: 'string', description: 'Optional correlation id to pair a request with its response.' },
|
|
2997
|
-
interrupt: { type: 'boolean', description: 'Default true: if the target member is running, interrupt its current turn before delivering so this message takes effect immediately. false = keep the current turn and deliver at the next step boundary; the message is still queued durably and will be read (a pending steer forces another turn, an idle member is woken), but it may land only after the member finished the current step, so it cannot be relied on to change this turn.' },
|
|
3105
|
+
interrupt: { type: 'boolean', description: 'Use true only when you must change an instruction mid-flight; never as a nudge. Default true: if the target member is running, interrupt its current turn before delivering so this message takes effect immediately. false = keep the current turn and deliver at the next step boundary; the message is still queued durably and will be read (a pending steer forces another turn, an idle member is woken), but it may land only after the member finished the current step, so it cannot be relied on to change this turn.' },
|
|
2998
3106
|
},
|
|
2999
3107
|
required: ['teamId', 'to', 'message'],
|
|
3000
3108
|
},
|
|
@@ -3012,7 +3120,7 @@ function buildTools(s, ctx) {
|
|
|
3012
3120
|
const members = st?.members || [];
|
|
3013
3121
|
const resolve = (v) => members.find((m) => m.name === v || m.id === v) || null;
|
|
3014
3122
|
if (!toLead && args.to !== '*' && (members.length ? !resolve(args.to) : false)) {
|
|
3015
|
-
throw new Error(`
|
|
3123
|
+
throw new Error(`dsh_team_send: 找不到成员 ${args.to}(可用成员 name 或 memberId;广播用 '*';给 Lead 留言用 to:"lead")`);
|
|
3016
3124
|
}
|
|
3017
3125
|
const recorded = await request(s, '/api/messages', {
|
|
3018
3126
|
method: 'POST',
|
|
@@ -3030,8 +3138,7 @@ function buildTools(s, ctx) {
|
|
|
3030
3138
|
const subs = subagentsOf(ctx);
|
|
3031
3139
|
// 成员之间互通必须借 Lead 的 agent 句柄:成员会话都挂在 Lead 下,成员直发会「belongs to another parent session」。
|
|
3032
3140
|
const caller = leadByTeam.get(args.teamId) || exec?.agent;
|
|
3033
|
-
if (!
|
|
3034
|
-
const content = [{ type: 'text', text: String(args.message) }];
|
|
3141
|
+
if (!caller || !canDeliverTo(ctx, caller)) return { ...recorded, delivered: false };
|
|
3035
3142
|
const candidates = args.to === '*' ? members : [resolve(args.to)].filter(Boolean);
|
|
3036
3143
|
const targets = candidates.filter((m) => m.agentSessionId);
|
|
3037
3144
|
const delivered = [];
|
|
@@ -3053,7 +3160,9 @@ function buildTools(s, ctx) {
|
|
|
3053
3160
|
interruptErrors.push({ target: target.name, error: String(err?.message || err) });
|
|
3054
3161
|
}
|
|
3055
3162
|
}
|
|
3056
|
-
await
|
|
3163
|
+
await sendAgentMessage(ctx, caller, sid, String(args.message), {
|
|
3164
|
+
signal: AbortSignal.timeout(s.requestTimeoutMs),
|
|
3165
|
+
});
|
|
3057
3166
|
delivered.push(target.name);
|
|
3058
3167
|
// 投递成功才补记送达:这一条消息确实进了成员会话
|
|
3059
3168
|
const row = (recorded.messages || [recorded.message]).find((m) => m && String(m.to) === String(target.id));
|
|
@@ -3073,7 +3182,7 @@ function buildTools(s, ctx) {
|
|
|
3073
3182
|
});
|
|
3074
3183
|
|
|
3075
3184
|
tools.push({
|
|
3076
|
-
name: '
|
|
3185
|
+
name: 'dsh_team_todo',
|
|
3077
3186
|
description: '设置或更新一个任务的执行计划清单(todo)。与内置 todo_write 不同:这份清单落盘在 sidecar,面板主页 Plan 区域实时渲染,Lead 与成员都能看到(内置 todo 只属于当前会话)。语义是整体替换——每次提交完整清单(最多 50 条),用 status 标注进度:open(未开始)/ active(进行中)/ done(已完成)/ blocked(被阻塞)。Lead 在派发前/后用它给任务补计划;成员每开始或完成一步、以及通过验收后调用它更新状态。',
|
|
3078
3187
|
parameters: {
|
|
3079
3188
|
type: 'object',
|
|
@@ -3111,7 +3220,7 @@ function buildTools(s, ctx) {
|
|
|
3111
3220
|
});
|
|
3112
3221
|
|
|
3113
3222
|
tools.push({
|
|
3114
|
-
name: '
|
|
3223
|
+
name: 'dsh_team_report_task',
|
|
3115
3224
|
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
3225
|
parameters: {
|
|
3117
3226
|
type: 'object',
|
|
@@ -3160,7 +3269,7 @@ function buildTools(s, ctx) {
|
|
|
3160
3269
|
};
|
|
3161
3270
|
|
|
3162
3271
|
tools.push({
|
|
3163
|
-
name: '
|
|
3272
|
+
name: 'dsh_team_memory_write',
|
|
3164
3273
|
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
3274
|
parameters: {
|
|
3166
3275
|
type: 'object',
|
|
@@ -3202,7 +3311,7 @@ function buildTools(s, ctx) {
|
|
|
3202
3311
|
});
|
|
3203
3312
|
|
|
3204
3313
|
tools.push({
|
|
3205
|
-
name: '
|
|
3314
|
+
name: 'dsh_team_memory_read',
|
|
3206
3315
|
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
3316
|
parameters: {
|
|
3208
3317
|
type: 'object',
|
|
@@ -3233,7 +3342,7 @@ function buildTools(s, ctx) {
|
|
|
3233
3342
|
});
|
|
3234
3343
|
|
|
3235
3344
|
tools.push({
|
|
3236
|
-
name: '
|
|
3345
|
+
name: 'dsh_team_memory_list',
|
|
3237
3346
|
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
3347
|
parameters: {
|
|
3239
3348
|
type: 'object',
|
|
@@ -3261,7 +3370,7 @@ function buildTools(s, ctx) {
|
|
|
3261
3370
|
});
|
|
3262
3371
|
|
|
3263
3372
|
tools.push({
|
|
3264
|
-
name: '
|
|
3373
|
+
name: 'dsh_team_memory_share',
|
|
3265
3374
|
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
3375
|
parameters: {
|
|
3267
3376
|
type: 'object',
|
|
@@ -3284,7 +3393,7 @@ function buildTools(s, ctx) {
|
|
|
3284
3393
|
});
|
|
3285
3394
|
|
|
3286
3395
|
tools.push({
|
|
3287
|
-
name: '
|
|
3396
|
+
name: 'dsh_team_memory_delete',
|
|
3288
3397
|
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
3398
|
parameters: {
|
|
3290
3399
|
type: 'object',
|
|
@@ -3302,8 +3411,8 @@ function buildTools(s, ctx) {
|
|
|
3302
3411
|
});
|
|
3303
3412
|
|
|
3304
3413
|
tools.push({
|
|
3305
|
-
name: '
|
|
3306
|
-
description: 'Pump the agent-team dispatcher once: claim ready tasks for idle members and send each member its brief. Normally unnecessary —
|
|
3414
|
+
name: 'dsh_team_dispatch',
|
|
3415
|
+
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. It is a recovery pump, not a heartbeat: do not call it in a loop to watch a running member.',
|
|
3307
3416
|
parameters: {
|
|
3308
3417
|
type: 'object',
|
|
3309
3418
|
additionalProperties: false,
|
|
@@ -3318,8 +3427,8 @@ function buildTools(s, ctx) {
|
|
|
3318
3427
|
});
|
|
3319
3428
|
|
|
3320
3429
|
tools.push({
|
|
3321
|
-
name: '
|
|
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
|
|
3430
|
+
name: 'dsh_team_approve',
|
|
3431
|
+
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
3432
|
parameters: {
|
|
3324
3433
|
type: 'object',
|
|
3325
3434
|
additionalProperties: false,
|
|
@@ -3334,7 +3443,7 @@ function buildTools(s, ctx) {
|
|
|
3334
3443
|
output: jsonOutput('{ requestId, decision, memberId, toolName, reason }'),
|
|
3335
3444
|
async execute(args, exec) {
|
|
3336
3445
|
const requestId = String(args.requestId || '').trim();
|
|
3337
|
-
if (!requestId) throw new Error('
|
|
3446
|
+
if (!requestId) throw new Error('dsh_team_approve requires requestId');
|
|
3338
3447
|
const entry = pendingApprovals.get(requestId);
|
|
3339
3448
|
if (!entry) throw new Error('审批请求不存在或已处理(可能已超时)。请以成员收到的审批消息里的 requestId 为准。');
|
|
3340
3449
|
if (String(entry.teamId) !== String(args.teamId)) throw new Error('teamId 与审批请求不匹配');
|
|
@@ -3350,7 +3459,7 @@ function buildTools(s, ctx) {
|
|
|
3350
3459
|
});
|
|
3351
3460
|
|
|
3352
3461
|
tools.push({
|
|
3353
|
-
name: '
|
|
3462
|
+
name: 'dsh_team_control',
|
|
3354
3463
|
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
3464
|
parameters: {
|
|
3356
3465
|
type: 'object',
|
|
@@ -3367,7 +3476,7 @@ function buildTools(s, ctx) {
|
|
|
3367
3476
|
output: jsonOutput('{ member, ... }'),
|
|
3368
3477
|
async execute(args, exec) {
|
|
3369
3478
|
if (args.action === 'abort') {
|
|
3370
|
-
if (!args.taskId) throw new Error('
|
|
3479
|
+
if (!args.taskId) throw new Error('dsh_team_control abort requires taskId');
|
|
3371
3480
|
const res = await request(s, `/api/tasks/${encodeURIComponent(args.taskId)}/abort`, { method: 'POST', body: { reason: args.reason || 'lead abort' } });
|
|
3372
3481
|
if (!res?.wasRunning || !res?.member?.agentSessionId) return res;
|
|
3373
3482
|
const sid = String(res.member.agentSessionId);
|
|
@@ -3383,7 +3492,7 @@ function buildTools(s, ctx) {
|
|
|
3383
3492
|
(err) => ({ ok: false, error: String(err?.message || err) }));
|
|
3384
3493
|
return { ...res, agent: interrupted };
|
|
3385
3494
|
}
|
|
3386
|
-
if (!args.memberId) throw new Error(`
|
|
3495
|
+
if (!args.memberId) throw new Error(`dsh_team_control ${args.action} requires memberId`);
|
|
3387
3496
|
const id = encodeURIComponent(args.memberId);
|
|
3388
3497
|
if (args.action === 'interrupt') {
|
|
3389
3498
|
const res = await request(s, `/api/members/${id}/interrupt`, { method: 'POST', body: { reason: args.reason || 'lead interrupt' } });
|
|
@@ -3415,15 +3524,15 @@ function buildTools(s, ctx) {
|
|
|
3415
3524
|
return res;
|
|
3416
3525
|
}
|
|
3417
3526
|
if (args.action === 'assign') {
|
|
3418
|
-
if (!args.taskId) throw new Error('
|
|
3527
|
+
if (!args.taskId) throw new Error('dsh_team_control assign requires taskId');
|
|
3419
3528
|
return await request(s, `/api/members/${id}/assign`, { method: 'POST', body: { taskId: args.taskId } });
|
|
3420
3529
|
}
|
|
3421
|
-
throw new Error(`
|
|
3530
|
+
throw new Error(`dsh_team_control unknown action: ${args.action}`);
|
|
3422
3531
|
},
|
|
3423
3532
|
});
|
|
3424
3533
|
|
|
3425
3534
|
tools.push({
|
|
3426
|
-
name: '
|
|
3535
|
+
name: 'dsh_team_member',
|
|
3427
3536
|
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
3537
|
parameters: {
|
|
3429
3538
|
type: 'object',
|
|
@@ -3431,7 +3540,7 @@ function buildTools(s, ctx) {
|
|
|
3431
3540
|
properties: {
|
|
3432
3541
|
action: { type: 'string', enum: ['update', 'retire', 'remove'] },
|
|
3433
3542
|
teamId: { type: 'string', description: 'Team id; omit to resolve from the current Lead session.' },
|
|
3434
|
-
memberId: { type: 'string', description: 'Member id returned by
|
|
3543
|
+
memberId: { type: 'string', description: 'Member id returned by dsh_team_spawn / dsh_team_status.' },
|
|
3435
3544
|
role: { type: 'string', description: 'update: new role label.' },
|
|
3436
3545
|
model: { type: 'string', description: 'update: new LLM model id (empty to inherit). Rebuilds the session.' },
|
|
3437
3546
|
agentProvider: { type: 'string', description: 'update: new LLM provider route id. Rebuilds the session.' },
|
|
@@ -3452,7 +3561,7 @@ function buildTools(s, ctx) {
|
|
|
3452
3561
|
if (current.teamId !== team.id) throw new Error('member 不属于指定团队');
|
|
3453
3562
|
|
|
3454
3563
|
if (args.action === 'retire' || args.action === 'remove') {
|
|
3455
|
-
if (args.action === 'remove' && args.confirm !== true) throw new Error('
|
|
3564
|
+
if (args.action === 'remove' && args.confirm !== true) throw new Error('dsh_team_member remove requires confirm:true');
|
|
3456
3565
|
const mode = args.action === 'remove' ? 'remove' : 'retire';
|
|
3457
3566
|
const res = await request(s, `/api/members/${id}?mode=${mode}${mode === 'remove' ? '&confirm=1' : ''}`, { method: 'DELETE' });
|
|
3458
3567
|
let agent = null;
|
|
@@ -3469,7 +3578,7 @@ function buildTools(s, ctx) {
|
|
|
3469
3578
|
return { ...res, agent, panel: panelUrl(s) };
|
|
3470
3579
|
}
|
|
3471
3580
|
|
|
3472
|
-
if (args.action !== 'update') throw new Error(`
|
|
3581
|
+
if (args.action !== 'update') throw new Error(`dsh_team_member unknown action: ${args.action}`);
|
|
3473
3582
|
if (current.status === 'retired') throw new Error('member is retired; create a new member instead');
|
|
3474
3583
|
|
|
3475
3584
|
const has = (key) => Object.prototype.hasOwnProperty.call(args, key);
|
|
@@ -3504,7 +3613,7 @@ function buildTools(s, ctx) {
|
|
|
3504
3613
|
const subs = subagentsOf(ctx);
|
|
3505
3614
|
const caller = exec?.agent;
|
|
3506
3615
|
if (!subs || typeof subs.startActivation !== 'function') throw new Error('subagents 服务不可用:无法重建成员会话');
|
|
3507
|
-
if (!caller) throw new Error('
|
|
3616
|
+
if (!caller) throw new Error('dsh_team_member update 需要 Lead 会话上下文(exec.agent 缺失)');
|
|
3508
3617
|
|
|
3509
3618
|
const leadRoute = leadRouteOf(caller);
|
|
3510
3619
|
const oldRoute = {
|
|
@@ -3547,7 +3656,7 @@ function buildTools(s, ctx) {
|
|
|
3547
3656
|
|
|
3548
3657
|
const sessionId = randomUUID();
|
|
3549
3658
|
const started = await subs.startActivation(activationSpec({
|
|
3550
|
-
prompt: [{ type: 'text', text: `你是团队成员 ${current.name}(${role || 'teammate'})。配置刚刚更新,这是新的会话;当前没有任务,等待 Lead 派发。收到任务后按简报执行,完成时调用
|
|
3659
|
+
prompt: [{ type: 'text', text: `你是团队成员 ${current.name}(${role || 'teammate'})。配置刚刚更新,这是新的会话;当前没有任务,等待 Lead 派发。收到任务后按简报执行,完成时调用 dsh_team_report_task。` }],
|
|
3551
3660
|
parent: caller,
|
|
3552
3661
|
...(team.workspace ? { cwd: team.workspace } : {}),
|
|
3553
3662
|
...(Object.keys(agentOptions).length ? { agentOptions } : {}),
|
|
@@ -3609,7 +3718,7 @@ function buildTools(s, ctx) {
|
|
|
3609
3718
|
});
|
|
3610
3719
|
|
|
3611
3720
|
tools.push({
|
|
3612
|
-
name: '
|
|
3721
|
+
name: 'dsh_team_report',
|
|
3613
3722
|
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
3723
|
parameters: {
|
|
3615
3724
|
type: 'object',
|
|
@@ -3627,7 +3736,7 @@ function buildTools(s, ctx) {
|
|
|
3627
3736
|
|
|
3628
3737
|
|
|
3629
3738
|
tools.push({
|
|
3630
|
-
name: '
|
|
3739
|
+
name: 'dsh_team_board_plan_submit',
|
|
3631
3740
|
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
3741
|
parameters: {
|
|
3633
3742
|
type: 'object',
|
|
@@ -3641,7 +3750,7 @@ function buildTools(s, ctx) {
|
|
|
3641
3750
|
output: jsonOutput('{ board task }'),
|
|
3642
3751
|
async execute(args, exec) {
|
|
3643
3752
|
const sessionId = exec?.agent?.id != null ? String(exec.agent.id) : null;
|
|
3644
|
-
if (!sessionId) throw new Error('
|
|
3753
|
+
if (!sessionId) throw new Error('dsh_team_board_plan_submit 只能在规划会话里调用');
|
|
3645
3754
|
const task = await request(s, '/api/board/agents/plan', {
|
|
3646
3755
|
method: 'POST',
|
|
3647
3756
|
body: { sessionId, plan: args.plan, summary: args.summary || null },
|
|
@@ -3653,7 +3762,7 @@ function buildTools(s, ctx) {
|
|
|
3653
3762
|
const agent = rec?.handle?.agent || exec?.agent;
|
|
3654
3763
|
if (task.leadPermissionPreset) boardSetPermission(ctx, agent, task.leadPermissionPreset);
|
|
3655
3764
|
// prewalk:这里只武装、不切模型。规划模型先按计划落下第一笔实现动作
|
|
3656
|
-
// (首次 edit/write 或首次
|
|
3765
|
+
// (首次 edit/write 或首次 dsh_team_task 派发),确认计划可执行后再交给执行模型。
|
|
3657
3766
|
if (task.prewalk) {
|
|
3658
3767
|
const boardSettings = await request(
|
|
3659
3768
|
s,
|
|
@@ -3672,7 +3781,7 @@ function buildTools(s, ctx) {
|
|
|
3672
3781
|
}
|
|
3673
3782
|
}
|
|
3674
3783
|
if (rec) { rec.phase = 'execution'; rec.sawRunning = false; }
|
|
3675
|
-
} else if (rec) {
|
|
3784
|
+
} else if (rec && task?.status !== 'done') {
|
|
3676
3785
|
rec.phase = 'planned';
|
|
3677
3786
|
}
|
|
3678
3787
|
if (task?.executionMode === 'new' && rec) {
|
|
@@ -3689,7 +3798,7 @@ function buildTools(s, ctx) {
|
|
|
3689
3798
|
});
|
|
3690
3799
|
|
|
3691
3800
|
tools.push({
|
|
3692
|
-
name: '
|
|
3801
|
+
name: 'dsh_team_board_task_status',
|
|
3693
3802
|
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
3803
|
parameters: {
|
|
3695
3804
|
type: 'object',
|
|
@@ -3703,7 +3812,7 @@ function buildTools(s, ctx) {
|
|
|
3703
3812
|
output: jsonOutput('{ board task }'),
|
|
3704
3813
|
async execute(args, exec) {
|
|
3705
3814
|
const sessionId = exec?.agent?.id != null ? String(exec.agent.id) : null;
|
|
3706
|
-
if (!sessionId) throw new Error('
|
|
3815
|
+
if (!sessionId) throw new Error('dsh_team_board_task_status 只能在看板 Lead 会话里调用');
|
|
3707
3816
|
return await request(s, '/api/board/agents/status', {
|
|
3708
3817
|
method: 'POST',
|
|
3709
3818
|
body: { sessionId, status: args.status, summary: args.summary || null },
|
|
@@ -3712,8 +3821,8 @@ function buildTools(s, ctx) {
|
|
|
3712
3821
|
});
|
|
3713
3822
|
|
|
3714
3823
|
tools.push({
|
|
3715
|
-
name: '
|
|
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
|
|
3824
|
+
name: 'dsh_team_board_task_create',
|
|
3825
|
+
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). Pin models with planRoute/leadRoute/teamModels: call dsh_team_models first and pass { provider?, model, reasoningEffort? } (or "provider/model"); omitted routes follow the board settings, and the card displays the models it uses.',
|
|
3717
3826
|
parameters: {
|
|
3718
3827
|
type: 'object',
|
|
3719
3828
|
additionalProperties: false,
|
|
@@ -3727,6 +3836,46 @@ function buildTools(s, ctx) {
|
|
|
3727
3836
|
useTeam: { type: 'boolean', description: 'Let the Lead orchestrate a team (default true).' },
|
|
3728
3837
|
executionMode: { type: 'string', enum: ['same', 'new'], description: 'same = plan and execute in one session; new = execute in a fresh session.' },
|
|
3729
3838
|
gitBranch: { type: 'string', description: 'Git branch to switch to before spawning; "" auto-generates task/<id>.' },
|
|
3839
|
+
planRoute: {
|
|
3840
|
+
type: 'object',
|
|
3841
|
+
additionalProperties: false,
|
|
3842
|
+
description: 'Planning model; omit to follow the board workspace settings. Use dsh_team_models to pick provider/model/reasoningEffort.',
|
|
3843
|
+
properties: {
|
|
3844
|
+
provider: { type: 'string', description: 'Provider id from dsh_team_models; omit when the model id is unique.' },
|
|
3845
|
+
model: { type: 'string', description: 'Model id from dsh_team_models.' },
|
|
3846
|
+
reasoningEffort: { type: 'string', description: 'Optional reasoning effort id from team_models.' },
|
|
3847
|
+
},
|
|
3848
|
+
required: ['model'],
|
|
3849
|
+
},
|
|
3850
|
+
leadRoute: {
|
|
3851
|
+
type: 'object',
|
|
3852
|
+
additionalProperties: false,
|
|
3853
|
+
description: 'Execution (Lead) model; omit to follow the board workspace settings.',
|
|
3854
|
+
properties: {
|
|
3855
|
+
provider: { type: 'string', description: 'Provider id from dsh_team_models; omit when the model id is unique.' },
|
|
3856
|
+
model: { type: 'string', description: 'Model id from dsh_team_models.' },
|
|
3857
|
+
reasoningEffort: { type: 'string', description: 'Optional reasoning effort id from team_models.' },
|
|
3858
|
+
},
|
|
3859
|
+
required: ['model'],
|
|
3860
|
+
},
|
|
3861
|
+
teamModels: {
|
|
3862
|
+
type: 'array',
|
|
3863
|
+
description: 'Whitelist of models team members may use (dsh_team_spawn enforces it; empty/omitted = unrestricted). Each item is the same { provider?, model, reasoningEffort? } route.',
|
|
3864
|
+
items: {
|
|
3865
|
+
type: 'object',
|
|
3866
|
+
additionalProperties: false,
|
|
3867
|
+
properties: {
|
|
3868
|
+
provider: { type: 'string', description: 'Provider id from dsh_team_models; omit when the model id is unique.' },
|
|
3869
|
+
model: { type: 'string', description: 'Model id from dsh_team_models.' },
|
|
3870
|
+
reasoningEffort: { type: 'string', description: 'Optional reasoning effort id from team_models.' },
|
|
3871
|
+
},
|
|
3872
|
+
required: ['model'],
|
|
3873
|
+
},
|
|
3874
|
+
},
|
|
3875
|
+
prewalk: {
|
|
3876
|
+
type: 'boolean',
|
|
3877
|
+
description: 'Experimental: with executionMode="same", switch the same session to leadRoute after the plan first changes files (default false).',
|
|
3878
|
+
},
|
|
3730
3879
|
},
|
|
3731
3880
|
required: ['title'],
|
|
3732
3881
|
},
|
|
@@ -3756,7 +3905,7 @@ function buildTools(s, ctx) {
|
|
|
3756
3905
|
workspacePath = workspacePath || items[0].path;
|
|
3757
3906
|
}
|
|
3758
3907
|
}
|
|
3759
|
-
if (!workspaceId) throw new Error('
|
|
3908
|
+
if (!workspaceId) throw new Error('dsh_team_board_task_create 需要 workspaceId:当前会话不属于任何看板任务,且工作区不唯一');
|
|
3760
3909
|
// 手填的 workspaceId 可能根本不存在(模型常填 00000000-… 占位 UUID)。这种卡会挂到
|
|
3761
3910
|
// 一个 UI 上不存在的“幽灵工作区”,看板按 workspace_id 过滤后完全看不到,所以这里必须
|
|
3762
3911
|
// 先解析:按 workspacePath 改挂到已注册工作区;DSH 注册表里确实存在(sidecar 还没同步)
|
|
@@ -3770,10 +3919,28 @@ function buildTools(s, ctx) {
|
|
|
3770
3919
|
const registry = (() => { try { return ctx.get('workspaceRegistry'); } catch { return undefined; } })();
|
|
3771
3920
|
const known = registry && typeof registry.get === 'function' ? registry.get(workspaceId) : null;
|
|
3772
3921
|
if (!known) {
|
|
3773
|
-
throw new Error(`
|
|
3922
|
+
throw new Error(`dsh_team_board_task_create 的 workspaceId 不存在:${workspaceId}。可用工作区:${items.map((w) => `${w.id}(${w.title || w.path})`).join('、') || '(sidecar 还没同步到工作区)'}`);
|
|
3774
3923
|
}
|
|
3775
3924
|
}
|
|
3776
3925
|
}
|
|
3926
|
+
// 模型路由:只在显式传入时下发(省略则跟随看板工作区设置),并提前校验可用性,
|
|
3927
|
+
// 避免建卡成功、真正开会话时才因为模型被禁用而失败。
|
|
3928
|
+
const planRoute = args.planRoute === undefined ? undefined : boardRouteParam(args.planRoute, 'planRoute');
|
|
3929
|
+
const leadRoute = args.leadRoute === undefined ? undefined : boardRouteParam(args.leadRoute, 'leadRoute');
|
|
3930
|
+
let teamModels;
|
|
3931
|
+
if (args.teamModels !== undefined) {
|
|
3932
|
+
if (args.teamModels === null) {
|
|
3933
|
+
teamModels = null; // 显式 null 等价于不限制
|
|
3934
|
+
} else if (!Array.isArray(args.teamModels)) {
|
|
3935
|
+
throw new Error('teamModels 需要数组,每项为 { provider?, model, reasoningEffort? } 或 "provider/model"');
|
|
3936
|
+
} else {
|
|
3937
|
+
teamModels = args.teamModels.map((m, i) => boardRouteParam(m, `teamModels[${i}]`)).filter(Boolean);
|
|
3938
|
+
if (!teamModels.length) teamModels = null; // 空数组等价于不限制
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
for (const route of [planRoute, leadRoute, ...(teamModels || [])]) {
|
|
3942
|
+
if (route) await assertRouteEnabled(s, ctx, route.provider, route.model, route.reasoningEffort || null);
|
|
3943
|
+
}
|
|
3777
3944
|
const task = await request(s, '/api/board/tasks', {
|
|
3778
3945
|
method: 'POST',
|
|
3779
3946
|
body: {
|
|
@@ -3786,6 +3953,10 @@ function buildTools(s, ctx) {
|
|
|
3786
3953
|
...(args.useTeam !== undefined ? { useTeam: args.useTeam } : {}),
|
|
3787
3954
|
...(args.executionMode !== undefined ? { executionMode: args.executionMode } : {}),
|
|
3788
3955
|
...(args.gitBranch !== undefined ? { gitBranch: args.gitBranch } : {}),
|
|
3956
|
+
...(planRoute !== undefined ? { planRoute } : {}),
|
|
3957
|
+
...(leadRoute !== undefined ? { leadRoute } : {}),
|
|
3958
|
+
...(teamModels !== undefined ? { teamModels } : {}),
|
|
3959
|
+
...(args.prewalk !== undefined ? { prewalk: args.prewalk } : {}),
|
|
3789
3960
|
},
|
|
3790
3961
|
});
|
|
3791
3962
|
return { task };
|
|
@@ -3793,8 +3964,8 @@ function buildTools(s, ctx) {
|
|
|
3793
3964
|
});
|
|
3794
3965
|
|
|
3795
3966
|
tools.push({
|
|
3796
|
-
name: '
|
|
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
|
|
3967
|
+
name: 'dsh_team_board_task_get',
|
|
3968
|
+
description: 'Read the current workspace-board task of this session (status/planSummary/lastError/gitBranch/planRoute/leadRoute/teamModels/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
3969
|
parameters: {
|
|
3799
3970
|
type: 'object',
|
|
3800
3971
|
additionalProperties: false,
|
|
@@ -3809,6 +3980,8 @@ function buildTools(s, ctx) {
|
|
|
3809
3980
|
id: t.id, workspaceId: t.workspaceId, title: t.title, status: t.status,
|
|
3810
3981
|
executionMode: t.executionMode, needPlan: t.needPlan, useTeam: t.useTeam,
|
|
3811
3982
|
gitBranch: t.gitBranch || null,
|
|
3983
|
+
planRoute: t.planRoute || null, leadRoute: t.leadRoute || null,
|
|
3984
|
+
teamModels: t.teamModels || null, prewalk: !!t.prewalk,
|
|
3812
3985
|
planSummary: t.planSummary || null, lastError: t.lastError || null,
|
|
3813
3986
|
planningSessionId: t.planningSessionId || null, leadSessionId: t.leadSessionId || null,
|
|
3814
3987
|
teams: t.teams || [], archivedAt: t.archivedAt || null, updatedAt: t.updatedAt,
|
|
@@ -3818,7 +3991,7 @@ function buildTools(s, ctx) {
|
|
|
3818
3991
|
return { task: pick(task) };
|
|
3819
3992
|
}
|
|
3820
3993
|
const sessionId = exec?.agent?.id != null ? String(exec.agent.id) : null;
|
|
3821
|
-
if (!sessionId) throw new Error('
|
|
3994
|
+
if (!sessionId) throw new Error('dsh_team_board_task_get 需要 taskId,或从看板会话里调用');
|
|
3822
3995
|
const found = await request(s, `/api/board/by-session/${encodeURIComponent(sessionId)}`).catch(() => null);
|
|
3823
3996
|
if (!found || found.ok === false || !found.id) throw new Error('当前会话没有关联的看板任务');
|
|
3824
3997
|
return { task: pick(found) };
|
|
@@ -3829,7 +4002,7 @@ function buildTools(s, ctx) {
|
|
|
3829
4002
|
}
|
|
3830
4003
|
|
|
3831
4004
|
// ---------- trace 上报:把每次工具调用写成 span(running → done/failed) ----------
|
|
3832
|
-
/** 会话 → 团队 的粘性绑定:参数里出现 teamId 或
|
|
4005
|
+
/** 会话 → 团队 的粘性绑定:参数里出现 teamId 或 dsh_team_create 返回后记住,后续调用自动归属。 */
|
|
3833
4006
|
const teamBySession = new Map();
|
|
3834
4007
|
|
|
3835
4008
|
const clipText = (value, max) => {
|
|
@@ -4194,7 +4367,7 @@ export function apply(ctx, config) {
|
|
|
4194
4367
|
});
|
|
4195
4368
|
}
|
|
4196
4369
|
|
|
4197
|
-
// 成员权限审批:preset 的 approval=ask 触发时,把请求转给 Lead,由
|
|
4370
|
+
// 成员权限审批:preset 的 approval=ask 触发时,把请求转给 Lead,由 dsh_team_approve 决定。
|
|
4198
4371
|
// 放在最前面(prepend),确保本插件的成员请求不会再弹出宿主审批 UI。
|
|
4199
4372
|
ctx.effect(() => {
|
|
4200
4373
|
const off = ctx.on('approval/request', (req, next) => onApprovalRequest(s, ctx, req, next), { prepend: true });
|
|
@@ -4226,13 +4399,13 @@ export function apply(ctx, config) {
|
|
|
4226
4399
|
if (!entry) return result;
|
|
4227
4400
|
const name = String(exec?.name || '');
|
|
4228
4401
|
// 任务收工(done/failed)时清掉未触发的武装,避免会话结束后残留。
|
|
4229
|
-
if (name === '
|
|
4402
|
+
if (name === 'dsh_team_board_task_status' && exec?.arguments?.status !== 'inprogress') {
|
|
4230
4403
|
prewalkArmed.delete(sessionId);
|
|
4231
4404
|
return result;
|
|
4232
4405
|
}
|
|
4233
4406
|
if (!boardPrewalkWantsTool(name)) return result;
|
|
4234
4407
|
// 工具报错(参数错、权限拒绝等)不算「已经落到实现」:保持武装,等下一次
|
|
4235
|
-
// 成功的 edit/write(或
|
|
4408
|
+
// 成功的 edit/write(或 dsh_team_task)再交接,避免接手模型先替规划模型收拾失败。
|
|
4236
4409
|
if (result && (result.isError === true || result.error != null)) return result;
|
|
4237
4410
|
prewalkArmed.delete(sessionId);
|
|
4238
4411
|
await boardHandoffExecution(ctx, exec.agent, entry.task, entry.settings);
|
|
@@ -4244,7 +4417,7 @@ export function apply(ctx, config) {
|
|
|
4244
4417
|
prewalkHook.dshTeamHook = 'prewalk';
|
|
4245
4418
|
ctx.on('tools/execute', prewalkHook);
|
|
4246
4419
|
|
|
4247
|
-
// 成员用内置 todo_write 维护计划(没建
|
|
4420
|
+
// 成员用内置 todo_write 维护计划(没建 dsh_team_todo)时,把 DSH 的 `todos` 投影镜像成
|
|
4248
4421
|
// sidecar 计划步骤:面板/团队校验能看到真实 plan,todo 勾完计划步骤也跟着完成。
|
|
4249
4422
|
ctx.on('tools/execute', async (exec, next) => {
|
|
4250
4423
|
const result = await next();
|
|
@@ -4304,7 +4477,7 @@ export function apply(ctx, config) {
|
|
|
4304
4477
|
idleTimers.delete(sessionId);
|
|
4305
4478
|
if (heldSessions.has(sessionId)) { agentStatusBySession.set(sessionId, 'interrupted'); return; }
|
|
4306
4479
|
if (agentStatusBySession.get(sessionId) !== 'idle') return; // 窗口内又跑起来了
|
|
4307
|
-
// 把这一轮最后的正文带给 sidecar:漏调
|
|
4480
|
+
// 把这一轮最后的正文带给 sidecar:漏调 dsh_team_report_task 时,兜底收尾的 task.done 也有摘要可看
|
|
4308
4481
|
const reply = lastReplyBySession.get(sessionId);
|
|
4309
4482
|
reportAgentStatus(s, sessionId, 'idle', reply ? clip(reply, 500) : undefined);
|
|
4310
4483
|
void flushMemberReply(s, sessionId).catch(() => { /* ignore */ });
|
|
@@ -4410,7 +4583,7 @@ export function apply(ctx, config) {
|
|
|
4410
4583
|
}, 'dsh-team.workspace-pump()');
|
|
4411
4584
|
}
|
|
4412
4585
|
|
|
4413
|
-
// 模型目录泵:面板「模型路由」页不再依赖 lead 调
|
|
4586
|
+
// 模型目录泵:面板「模型路由」页不再依赖 lead 调 dsh_team_models。
|
|
4414
4587
|
// 启动即同步(sidecar 可能刚 spawn,失败 2s 重试),成功后按 llmCatalogMs 定时刷新。
|
|
4415
4588
|
if (s.reportLlmCatalog) {
|
|
4416
4589
|
ctx.effect(() => {
|