@fish-under-sea/dsh-agent-teams-fish 2.0.2 → 2.1.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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schema": 1,
3
- "source": "decb660bc1cd9b5e7b9c877d0dab69af26c93adad43c1a32e0f536b1fba266bc",
4
- "output": "6454b5157475a1c3316d5132fd4615f636793e062f96d4c24af9876530540ac4"
3
+ "source": "d065c3200b9d78230aaf0981b6bf120a0b526f17f393936e548eb64ed3e75694",
4
+ "output": "96abbf30ae7b0fe6854e577596d8ead4c2c0db74489f5ce82de246eccd0aca77"
5
5
  }
@@ -14,6 +14,45 @@ const hostPromptQueue = Symbol.for('dsh.subagent.queuePrompt');
14
14
  // 0.1.5 keeps queueHostSubagentPrompt but replaces its symbol with this
15
15
  // delivery-mode-aware implementation (packages/subagent/subagent/src/internal.ts).
16
16
  const hostPromptDeliver = Symbol.for('dsh.subagent.deliverPrompt');
17
+ const treeWork = new WeakMap();
18
+ function treeBoundary(runtime) {
19
+ const tree = runtime;
20
+ if (typeof tree.rootOf !== 'function' || typeof tree.prompt !== 'function')
21
+ return undefined;
22
+ if (typeof tree.manager?.deliverToMember !== 'function' || typeof tree.manager.dispose !== 'function'
23
+ || !(tree.manager.resident instanceof Map))
24
+ return unsupported('missing audited tree delivery manager');
25
+ return tree;
26
+ }
27
+ /** Track exact branch work before its first await so a targeted stop can join it. */
28
+ function trackTreeWork(manager, root, branch, signal, operation) {
29
+ const pending = treeWork.get(manager) ?? new Set();
30
+ treeWork.set(manager, pending);
31
+ const controller = new AbortController();
32
+ let finish;
33
+ const settled = new Promise(resolve => { finish = resolve; });
34
+ const work = { root, branch, controller, settled };
35
+ pending.add(work);
36
+ try {
37
+ return operation(AbortSignal.any([signal, controller.signal])).finally(() => { pending.delete(work); finish(); });
38
+ }
39
+ catch (error) {
40
+ pending.delete(work);
41
+ finish();
42
+ throw error;
43
+ }
44
+ }
45
+ function deliverTreePrompt(runtime, tree, parent, childId, content, source, signal, delivery) {
46
+ const root = tree.rootOf.call(runtime, parent);
47
+ return tree.manager.deliverToMember.call(tree.manager, root, childId, content, {
48
+ source, signal, delivery,
49
+ // Recheck the exact live caller immediately before native inbox acceptance.
50
+ authorize: () => {
51
+ if (tree.rootOf.call(runtime, parent) !== root)
52
+ throw new SubagentError('AgentTeams caller left its subagent tree', 'UNAUTHORIZED');
53
+ },
54
+ });
55
+ }
17
56
  export function usesManagedActivations(runtime) {
18
57
  return typeof runtime.startActivation === 'function';
19
58
  }
@@ -21,7 +60,9 @@ export async function startMember(runtime, spec) {
21
60
  const host = runtime;
22
61
  if (typeof host.startActivation === 'function') {
23
62
  const { persona: _persona, toolFilter: _filter, ...request } = spec.request;
24
- const activation = await host.startActivation.call(runtime, { ...spec, request, delivery: 'parent' });
63
+ const activation = await Reflect.apply(host.startActivation, runtime, [treeBoundary(runtime) === undefined
64
+ ? { ...spec, request, delivery: 'parent' }
65
+ : { provider: spec.provider, label: spec.label, ...request, signal: spec.signal, delivery: 'parent' }]);
25
66
  // Preserve native settlement as the missing-report/error fallback on both
26
67
  // fresh and resumed activations. mailbox.ts deduplicates successful reports.
27
68
  void activation.result.catch(() => undefined);
@@ -34,6 +75,7 @@ export async function startMember(runtime, spec) {
34
75
  /** Wrap every available creation API, restoring only this plugin's own methods. */
35
76
  export function guardSubagentCreation(ctx, check) {
36
77
  const runtime = ctx.subagents;
78
+ const tree = treeBoundary(ctx.subagents);
37
79
  ctx.effect(() => {
38
80
  const disposers = [];
39
81
  for (const key of ['start', 'startContinuable', 'startActivation']) {
@@ -42,8 +84,16 @@ export function guardSubagentCreation(ctx, check) {
42
84
  continue;
43
85
  const descriptor = Object.getOwnPropertyDescriptor(runtime, key);
44
86
  const guarded = async (...args) => {
45
- const request = key === 'start' ? args[1] : args[0].request;
46
- check(request.parent);
87
+ const request = key === 'start' ? args[1] : key === 'startActivation' && tree !== undefined
88
+ ? args[0] : args[0].request;
89
+ const parent = request.parent;
90
+ check(parent);
91
+ if (key === 'startActivation' && tree !== undefined) {
92
+ const spec = args[0];
93
+ const root = tree.rootOf.call(ctx.subagents, parent);
94
+ const branch = [parent.id, ...tree.manager.resident.get(parent.id)?.ancestors ?? []];
95
+ return trackTreeWork(tree.manager, root, branch, spec.signal, signal => Reflect.apply(original, ctx.subagents, [{ ...spec, signal }]));
96
+ }
47
97
  return Reflect.apply(original, ctx.subagents, args);
48
98
  };
49
99
  Object.defineProperty(runtime, key, { value: guarded, writable: true, configurable: true });
@@ -74,7 +124,9 @@ export function guardSubagentCreation(ctx, check) {
74
124
  */
75
125
  export function installMemberModelSelection(childCtx, ref) {
76
126
  const install = installModelSelection;
77
- return install.length >= 2 ? install(childCtx, ref) : install(childCtx);
127
+ // 0.2.2-rc.3 keeps the caller-owned selection ref; older hosts ignore the
128
+ // extra argument, so always forward it instead of guessing by arity.
129
+ return install(childCtx, ref);
78
130
  }
79
131
  function boundary(runtime) {
80
132
  return runtime;
@@ -211,6 +263,15 @@ export function assertMemberModelSelection(ctx, captain, route) {
211
263
  throw new Error(`agent-teams: child LLM route "${route.provider}/${route.model}" is not allowed for this Session; choose a route from list_subagent_models`);
212
264
  }
213
265
  }
266
+ /** rc.2 summaries use tree names; the new structured reason owns the outcome. */
267
+ export function successfulSubagentSettlement(source) {
268
+ if (source?.kind !== 'subagent-settled')
269
+ return false;
270
+ const current = source;
271
+ return current.stopReason === undefined
272
+ ? source.summary === `Background subagent ${source.senderSessionId} finished and will do no further work unless you send it more.`
273
+ : current.stopReason === 'completed';
274
+ }
214
275
  /** Install before the first request, including cold resume, with HMR cleanup. */
215
276
  export function installContinuableMemberSetup(ctx, setup) {
216
277
  const runtime = boundary(ctx.subagents);
@@ -225,7 +286,7 @@ export function installContinuableMemberSetup(ctx, setup) {
225
286
  });
226
287
  return;
227
288
  }
228
- if ((typeof runtime[hostPromptQueue] !== 'function' && typeof runtime[hostPromptDeliver] !== 'function') || typeof runtime.sendMessage !== 'function') {
289
+ if (treeBoundary(ctx.subagents) === undefined && ((typeof runtime[hostPromptQueue] !== 'function' && typeof runtime[hostPromptDeliver] !== 'function') || typeof runtime.sendMessage !== 'function')) {
229
290
  return unsupported('missing continuable setup and modern host queue');
230
291
  }
231
292
  const installed = new WeakSet();
@@ -293,6 +354,9 @@ export function installContinuableMemberSetup(ctx, setup) {
293
354
  export async function queueMemberPrompt(runtime, parent, childId, content, signal) {
294
355
  const host = boundary(runtime);
295
356
  const source = agentTeamsSource({ kind: 'agent-teams' }, observedSessionFormatVersion(parent));
357
+ const tree = treeBoundary(runtime);
358
+ if (tree !== undefined)
359
+ return deliverTreePrompt(runtime, tree, parent, childId, content, source, signal, 'queue');
296
360
  if (typeof host.followup === 'function') {
297
361
  return host.followup.call(runtime, parent, childId, content, { source, signal });
298
362
  }
@@ -308,6 +372,9 @@ export async function queueMemberPrompt(runtime, parent, childId, content, signa
308
372
  export async function steerMemberPrompt(runtime, parent, childId, content, signal, live) {
309
373
  const host = boundary(runtime);
310
374
  const source = agentTeamsSource({ kind: 'agent-teams' }, observedSessionFormatVersion(live ?? parent));
375
+ const tree = treeBoundary(runtime);
376
+ if (tree !== undefined)
377
+ return deliverTreePrompt(runtime, tree, parent, childId, content, source, signal, 'steer');
311
378
  const deliver = host[hostPromptDeliver];
312
379
  if (typeof deliver === 'function')
313
380
  return deliver.call(runtime, parent, childId, content, source, signal, 'steer');
@@ -328,6 +395,39 @@ export async function steerMemberPrompt(runtime, parent, childId, content, signa
328
395
  /** Guard all resumable delivery paths, preserving the native service receiver. */
329
396
  export function guardSubagentDelivery(ctx, isRetired) {
330
397
  const runtime = ctx.subagents;
398
+ const tree = treeBoundary(runtime);
399
+ if (tree !== undefined) {
400
+ const manager = tree.manager;
401
+ ctx.effect(() => {
402
+ const original = manager.deliverToMember;
403
+ const descriptor = Object.getOwnPropertyDescriptor(manager, 'deliverToMember');
404
+ let active = true;
405
+ const guarded = async (root, childId, content, options) => {
406
+ if (!active)
407
+ return original.call(manager, root, childId, content, options);
408
+ const branch = [childId, ...manager.resident.get(childId)?.ancestors ?? []];
409
+ return trackTreeWork(manager, root, branch, options.signal, async (signal) => {
410
+ signal.throwIfAborted();
411
+ if (await isRetired(root, childId)) {
412
+ throw new SubagentError(`AgentTeams member "${childId}" was retired and cannot be resumed`, 'NOT_RESUMABLE');
413
+ }
414
+ signal.throwIfAborted();
415
+ return original.call(manager, root, childId, content, { ...options, signal });
416
+ });
417
+ };
418
+ manager.deliverToMember = guarded;
419
+ return () => {
420
+ active = false;
421
+ if (Object.getOwnPropertyDescriptor(manager, 'deliverToMember')?.value !== guarded)
422
+ return;
423
+ if (descriptor === undefined)
424
+ Reflect.deleteProperty(manager, 'deliverToMember');
425
+ else
426
+ Object.defineProperty(manager, 'deliverToMember', descriptor);
427
+ };
428
+ }, 'agent-teams: tree retired member guard');
429
+ return;
430
+ }
331
431
  const host = boundary(runtime);
332
432
  const legacy = host.followup;
333
433
  const queue = host[hostPromptQueue];
@@ -493,6 +593,24 @@ export async function startMemberWithLenientFilter(start, filter, relaxableDeny
493
593
  }
494
594
  /** Targeted recursive cancellation renamed with the unified activation manager. */
495
595
  export async function drainMemberChildren(runtime, parent, ids) {
596
+ const tree = treeBoundary(runtime);
597
+ if (tree !== undefined) {
598
+ const root = tree.rootOf.call(runtime, parent);
599
+ const selected = new Set(ids);
600
+ // The native tree-wide drain also stops unrelated siblings and permanently
601
+ // closes the captain. Join only work in the selected creation branches.
602
+ const pending = [...treeWork.get(tree.manager) ?? []].filter(work => work.root === root && work.branch.some(id => selected.has(id)));
603
+ for (const work of pending)
604
+ work.controller.abort();
605
+ await Promise.all(pending.map(work => work.settled));
606
+ const targets = [...tree.manager.resident.values()].filter(item => item.root === root
607
+ && item.ancestors.includes(parent.id) && (selected.has(item.childId) || item.ancestors.some(id => selected.has(id))));
608
+ const results = await Promise.allSettled(targets.map(item => tree.manager.dispose.call(tree.manager, item)));
609
+ const failures = results.flatMap(result => result.status === 'rejected' ? [result.reason] : []);
610
+ if (failures.length)
611
+ throw new AggregateError(failures, 'AgentTeams member teardown failed');
612
+ return;
613
+ }
496
614
  const host = runtime;
497
615
  const drain = host.drainChildren ?? host.drainContinuableChildren;
498
616
  if (typeof drain !== 'function')
package/lib/index.js CHANGED
@@ -38,6 +38,9 @@ import { authenticatedWebRoutes, readJsonRequest, RequestBodyError, writeJsonWit
38
38
  const WEB_SERVER_KEYS = ['webServer', 'httpServer'];
39
39
  /** Workspace registry service key candidates, newest first. */
40
40
  const WORKSPACE_KEYS = ['workspaceRegistry', 'workspace'];
41
+ function nativeTeamMode(ctx) {
42
+ return ctx.agentTeams;
43
+ }
41
44
  export const name = 'agent-teams';
42
45
  export const inject = ['tools', 'llm', 'subagents', 'systemPrompt', 'agents'];
43
46
  // `z.object()` has an implicit `{}` default in Schemastery. Fallback routes
@@ -173,6 +176,8 @@ export async function resolveArtwork(name, options) {
173
176
  };
174
177
  }
175
178
  export function apply(ctx, config) {
179
+ /** True when a native team-mode service is present and the switch is on. */
180
+ const teamEnabled = (agent) => nativeTeamMode(ctx)?.isEnabled(agent) ?? true;
176
181
  const resolved = {
177
182
  stateDir: config.stateDir ?? '.agent-teams',
178
183
  memberProvider: config.memberProvider ?? 'spawn',
@@ -183,6 +188,7 @@ export function apply(ctx, config) {
183
188
  memberMaxDepth: config.memberMaxDepth ?? 0,
184
189
  maxMembers: config.maxMembers ?? 8,
185
190
  profiles: config.profiles ?? {},
191
+ isTeamEnabled: teamEnabled,
186
192
  // Owner configuration is validated once, at mount: an empty or malformed
187
193
  // policy must never reach a member creation path.
188
194
  toolPolicies: parseToolPolicies(config.toolPolicies),
@@ -202,6 +208,7 @@ export function apply(ctx, config) {
202
208
  stateDir: resolved.stateDir,
203
209
  isPendingMember: agentTeamsRuntime.isPendingMember,
204
210
  order: config.promptSectionOrder,
211
+ isTeamEnabled: teamEnabled,
205
212
  // Keep the bounded profile directory available without extra tool calls.
206
213
  // installTeamCapabilities snapshots this once; no business state rewrites it.
207
214
  captainPrompt: () => usageSectionText(TEAM_TOOL_NAMES.join(', '), formatProfilesForPrompt(config.profiles)),
@@ -349,6 +356,72 @@ export function apply(ctx, config) {
349
356
  }
350
357
  },
351
358
  }), 'agent-teams: model policy route');
359
+ // 模型菜单「启用AgentTeam」开关。官方任务工具与官方团队 UI 行已在 bundle
360
+ // 层停用;原生服务只负责保存每个 Session 的持久开关,这里让开关直接控制
361
+ // Fish AgentTeams(关闭时工具与提示词都不参与本会话)。
362
+ ctx.effect(() => webServer.register({
363
+ kind: 'exact',
364
+ path: '/plugins/dsh-agent-teams/mode',
365
+ handler: async (req, res) => {
366
+ const url = new URL(req.url ?? '/', 'http://x');
367
+ const service = nativeTeamMode(ctx);
368
+ const respond = (status, body) => {
369
+ res.writeHead(status, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
370
+ res.end(JSON.stringify(body));
371
+ };
372
+ if (service === undefined) {
373
+ respond(503, { error: 'native team-mode service is not mounted' });
374
+ return;
375
+ }
376
+ const lookup = (sessionId) => ctx.agents.get(sessionId);
377
+ if (req.method === 'GET') {
378
+ const sessionId = url.searchParams.get('session')?.trim() ?? '';
379
+ if (sessionId === '') {
380
+ respond(400, { error: 'session is required' });
381
+ return;
382
+ }
383
+ const agent = lookup(sessionId);
384
+ if (agent === undefined) {
385
+ respond(409, { error: 'session is not attached' });
386
+ return;
387
+ }
388
+ respond(200, { enabled: service.isEnabled(agent) });
389
+ return;
390
+ }
391
+ if (req.method !== 'POST') {
392
+ res.writeHead(405, { allow: 'GET, POST', 'cache-control': 'no-store' });
393
+ res.end();
394
+ return;
395
+ }
396
+ let payload;
397
+ try {
398
+ payload = await readJsonRequest(req);
399
+ }
400
+ catch (error) {
401
+ respond(error instanceof RequestBodyError ? error.status : 400, { error: error instanceof Error ? error.message : 'invalid request body' });
402
+ return;
403
+ }
404
+ const sessionId = typeof payload['sessionId'] === 'string' ? payload['sessionId'].trim() : '';
405
+ const enabled = payload['enabled'];
406
+ if (sessionId === '' || typeof enabled !== 'boolean') {
407
+ respond(400, { error: 'sessionId and enabled are required' });
408
+ return;
409
+ }
410
+ const agent = lookup(sessionId);
411
+ if (agent === undefined) {
412
+ respond(409, { error: 'session is not attached' });
413
+ return;
414
+ }
415
+ try {
416
+ await service.setEnabled(agent, enabled);
417
+ respond(200, { ok: true, enabled });
418
+ }
419
+ catch (error) {
420
+ ctx.logger.warn(`agent-teams: mode switch failed: ${String(error)}`);
421
+ respond(409, { error: error instanceof Error ? error.message : 'failed to switch AgentTeam mode' });
422
+ }
423
+ },
424
+ }), 'agent-teams: mode route');
352
425
  ctx.effect(() => webServer.register({
353
426
  kind: 'exact',
354
427
  path: '/plugins/dsh-agent-teams/plan',
package/lib/mailbox.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { join } from 'node:path';
2
2
  import { acknowledgeMailbox, CAPTAIN_KEY, discardMailboxMessages, findTeamByCaptain, readMailbox, readUnreadMailbox, readTeam, sanitizeKey, withTeamLock } from "./state.js";
3
- import { sessionOwnEvents } from "./harness-compat.js";
3
+ import { sessionOwnEvents, successfulSubagentSettlement } from "./harness-compat.js";
4
4
  import { leadIdentityOfAsync, sessionLeadsTeamAsync } from "./lineage.js";
5
5
  const PREFIX = 'AgentTeams inbox receipt: ';
6
6
  export function isCurrentMail(team, message) {
@@ -80,8 +80,7 @@ export function installMailboxAdmission(ctx, stateDir) {
80
80
  // result. Keep abnormal endings and missing reports as fallback signals.
81
81
  const successfulSettlements = new Set(decision.messages.flatMap(input => {
82
82
  const source = input.source;
83
- return source?.kind === 'subagent-settled'
84
- && source.summary === `Background subagent ${source.senderSessionId} finished and will do no further work unless you send it more.`
83
+ return successfulSubagentSettlement(source)
85
84
  ? [source.senderSessionId] : [];
86
85
  }));
87
86
  const redundantSettlements = new Set();
@@ -168,8 +167,7 @@ export function installMailboxAdmission(ctx, stateDir) {
168
167
  }
169
168
  const admitted = [];
170
169
  for (const { input, receipt, batch } of inputs) {
171
- if (input.source?.kind === 'subagent-settled' && redundantSettlements.has(input.source.senderSessionId)
172
- && input.source.summary === `Background subagent ${input.source.senderSessionId} finished and will do no further work unless you send it more.`)
170
+ if (successfulSubagentSettlement(input.source) && redundantSettlements.has(input.source.senderSessionId))
173
171
  continue;
174
172
  if (receipt === undefined || batch === undefined || batch.failed === true) {
175
173
  admitted.push(input);
package/lib/members.js CHANGED
@@ -911,7 +911,13 @@ export async function spawnMember(ctx, config, selections, llmSelection, captain
911
911
  // mirror what startContinuable would reject, with an actionable error.
912
912
  const provider = ctx.subagents.getProvider(config.provider);
913
913
  if (provider === undefined) {
914
- throw new Error(`agent-teams: no subagent provider "${config.provider}" is registered (available: ${ctx.subagents.list().join(', ') || 'none'}) — `
914
+ // 0.2.2-rc.3 removed the public `list()`; the private registry still holds
915
+ // the names, so read those when present and fall back to the old API.
916
+ const boundary = ctx.subagents;
917
+ const available = typeof boundary.list === 'function'
918
+ ? boundary.list()
919
+ : [...(boundary.providers?.keys?.() ?? [])];
920
+ throw new Error(`agent-teams: no subagent provider "${config.provider}" is registered (available: ${available.join(', ') || 'none'}) — `
915
921
  + 'check that the subagent provider row (e.g. subagent-spawn) is mounted in the composition');
916
922
  }
917
923
  if (provider.prepareContinuable === undefined) {
package/lib/tools.js CHANGED
@@ -499,6 +499,9 @@ export function registerAgentTeamsTools(ctx, config) {
499
499
  installMemberDelegationGuard(ctx, config.stateDir, config.memberMaxDepth ?? 0);
500
500
  installMailboxAdmission(ctx, config.stateDir);
501
501
  const scheduler = installTeamScheduler(ctx, { stateDir: config.stateDir, executionPrompt: config.executionPrompt, dispatch: dispatchMember });
502
+ /** Step-time admission shared by every `agent_teams_*` tool. */
503
+ const teamEnabled = (agent) => agent === undefined ? false : (config.isTeamEnabled?.(agent) ?? true);
504
+ const registerTool = (definition) => ctx.tools.register(definition, { when: ({ agent }) => teamEnabled(agent) });
502
505
  async function dispatchMember(captain, teamId, memberName, text, signal, mode, attemptId) {
503
506
  const root = stateRootOf(workspaceOf(captain), config);
504
507
  // Record why a member never started. The scheduler treats a failed dispatch as
@@ -783,7 +786,7 @@ export function registerAgentTeamsTools(ctx, config) {
783
786
  captain.cancel({ kind: 'user' }, { keepInbox: true });
784
787
  return { teamId: discarded.teamId };
785
788
  };
786
- ctx.tools.register(defineTool({
789
+ registerTool(defineTool({
787
790
  name: 'agent_teams_create',
788
791
  description: 'Create a team. Use approval=required for a two-phase plan: members and tasks remain unspawned/unclaimed until the user reviews the Web plan and explicitly approves it. Optional profiles expand their configured roster; seed profiles also expand template tasks, while captain profiles leave the graph for the Captain to design. approval=automatic preserves the legacy immediate-execution path.',
789
792
  parameters: {
@@ -998,7 +1001,7 @@ export function registerAgentTeamsTools(ctx, config) {
998
1001
  };
999
1002
  },
1000
1003
  }));
1001
- ctx.tools.register(defineTool({
1004
+ registerTool(defineTool({
1002
1005
  name: 'agent_teams_edit_plan',
1003
1006
  description: 'Atomically revise an AgentTeams plan. While staged, edit tasks and roster without starting work. While running, only update_task is allowed, and only for pending tasks with no prior attempt: correct dependencies, assignees or descriptions before they start; newly ready work is scheduled after commit. Never edit active/finished attempts. Submit dependent edits in order. Never modify .agent-teams files directly.',
1004
1007
  parameters: {
@@ -1127,7 +1130,7 @@ export function registerAgentTeamsTools(ctx, config) {
1127
1130
  };
1128
1131
  },
1129
1132
  }));
1130
- ctx.tools.register(defineTool({
1133
+ registerTool(defineTool({
1131
1134
  name: 'agent_teams_approve',
1132
1135
  description: 'Approve and start a staged team plan. Call this only in response to an explicit user approval in a new user turn; never call it during the turn that created or edited the plan. The Web Approve & Run button uses the same runtime directly.',
1133
1136
  parameters: {
@@ -1159,7 +1162,7 @@ export function registerAgentTeamsTools(ctx, config) {
1159
1162
  return { status: 'running', team_id: approved.teamId, members: approved.members, tasks: approved.tasks };
1160
1163
  },
1161
1164
  }));
1162
- ctx.tools.register(defineTool({
1165
+ registerTool(defineTool({
1163
1166
  name: 'agent_teams_add_member',
1164
1167
  description: 'Add a member to the team roster. Planning and idle roster rows do not call a model. After approval, the member session starts with its first ready task or explicit message and remains durable for later work.',
1165
1168
  parameters: {
@@ -1263,7 +1266,7 @@ export function registerAgentTeamsTools(ctx, config) {
1263
1266
  return latest === undefined ? created : { ...created, member_id: latest.id, status: latest.status };
1264
1267
  },
1265
1268
  }));
1266
- ctx.tools.register(defineTool({
1269
+ registerTool(defineTool({
1267
1270
  name: 'agent_teams_remove_member',
1268
1271
  description: 'Remove a member safely: revoke its current attempts, return all unfinished owned tasks to the shared pending pool, interrupt its live turn, and mark it removed.',
1269
1272
  parameters: {
@@ -1323,7 +1326,7 @@ export function registerAgentTeamsTools(ctx, config) {
1323
1326
  };
1324
1327
  },
1325
1328
  }));
1326
- ctx.tools.register(defineTool({
1329
+ registerTool(defineTool({
1327
1330
  name: 'agent_teams_create_task',
1328
1331
  description: 'Create a task in your team\'s task list. Use kind=work (default) for research, repository audits and general tasks. kind=review is only a quality gate for an existing implementation/repair task via reviewedTaskId. Every call must include a non-empty subject, including verification and review tasks. Tasks can depend on other tasks (dependencies): a task is only claimable once every dependency is completed. Optionally assign it to a member, who still claims it before working.',
1329
1332
  parameters: {
@@ -1482,7 +1485,7 @@ export function registerAgentTeamsTools(ctx, config) {
1482
1485
  return created;
1483
1486
  },
1484
1487
  }));
1485
- ctx.tools.register(defineTool({
1488
+ registerTool(defineTool({
1486
1489
  name: 'agent_teams_reassign_task',
1487
1490
  description: 'Atomically retry, reassign, or let the captain take over one ready unfinished/failed task. The old attempt is revoked before its member is interrupted, so late updates cannot overwrite the new owner. Use assignee="captain" only when you will finish that task in this turn; a captain can own only one unfinished takeover at a time, and an unfinished takeover returns to the member pool when the captain becomes idle.',
1488
1491
  parameters: {
@@ -1618,7 +1621,7 @@ export function registerAgentTeamsTools(ctx, config) {
1618
1621
  };
1619
1622
  },
1620
1623
  }));
1621
- ctx.tools.register(defineTool({
1624
+ registerTool(defineTool({
1622
1625
  name: 'agent_teams_claim_task',
1623
1626
  description: 'Members claim their own ready task or read their existing attempt_id. Captains must use reassign_task to assign and wake a member; claim_task does not dispatch work. A member cannot own a second unfinished task. The returned attempt_id is required for updates and becomes stale after retry/reassignment.',
1624
1627
  parameters: {
@@ -1726,7 +1729,7 @@ export function registerAgentTeamsTools(ctx, config) {
1726
1729
  });
1727
1730
  },
1728
1731
  }));
1729
- ctx.tools.register(defineTool({
1732
+ registerTool(defineTool({
1730
1733
  name: 'agent_teams_update_task',
1731
1734
  description: 'Update a task status/output. Members must supply the current attempt_id returned by claim_task; stale attempts are rejected after takeover/reassignment. Terminal results are immutable, but owners and the captain can append acceptanceResults/commandsRun/evidence_note as attributed supplemental evidence, without reclaiming or changing the verdict. A captain must use reassign_task(assignee="captain") before updating active member-owned work.',
1732
1735
  parameters: {
@@ -1953,7 +1956,7 @@ export function registerAgentTeamsTools(ctx, config) {
1953
1956
  return updated;
1954
1957
  },
1955
1958
  }));
1956
- ctx.tools.register(defineTool({
1959
+ registerTool(defineTool({
1957
1960
  name: 'agent_teams_amend_task',
1958
1961
  description: 'Captain-only controlled contract amendment for one non-terminal quality task: replace a wrong objective/acceptance/verify/inScope/outOfScope when the original contract makes honest completion impossible (for example a verify command that cannot pass, or an inScope that forbids the file the objective names). The amendment is appended to the task\'s revisions ledger with previous values and the reason, and is rejected once a review/requirements task has passed judgment on this task. Members cannot amend contracts; the implementer re-reads the amended contract before its next quality gate. Lists are full replacements, not deltas.',
1959
1962
  parameters: {
@@ -2033,7 +2036,7 @@ export function registerAgentTeamsTools(ctx, config) {
2033
2036
  };
2034
2037
  },
2035
2038
  }));
2036
- ctx.tools.register(defineTool({
2039
+ registerTool(defineTool({
2037
2040
  name: 'agent_teams_send_message',
2038
2041
  description: 'Send coordination or current-task guidance directly to the captain or a teammate. A running recipient receives it at the next model step; an idle recipient wakes. Messages are durably retained until read. Use task creation/reassignment for a new unit of work, not repeated status nudges.',
2039
2042
  parameters: {
@@ -2162,7 +2165,7 @@ export function registerAgentTeamsTools(ctx, config) {
2162
2165
  };
2163
2166
  },
2164
2167
  }));
2165
- ctx.tools.register(defineTool({
2168
+ registerTool(defineTool({
2166
2169
  name: 'agent_teams_status',
2167
2170
  description: 'Team snapshot: members with live activity and tasks with status/assignee/dependencies/output. Captains also see every team mailbox; members see only their own inbox. Use after mailbox progress deliveries or for an explicit status request. After dispatch, end your turn while members work; do not repeatedly poll.',
2168
2171
  parameters: {},
@@ -2308,7 +2311,7 @@ export function registerAgentTeamsTools(ctx, config) {
2308
2311
  return result;
2309
2312
  },
2310
2313
  }));
2311
- ctx.tools.register(defineTool({
2314
+ registerTool(defineTool({
2312
2315
  name: 'agent_teams_resume',
2313
2316
  description: 'Explicitly resume a halted team. Requires a non-empty reason. Does not recreate cancelled tasks; only still-pending work is scheduled.',
2314
2317
  parameters: {
@@ -2361,7 +2364,7 @@ export function registerAgentTeamsTools(ctx, config) {
2361
2364
  return result;
2362
2365
  },
2363
2366
  }));
2364
- ctx.tools.register(defineTool({
2367
+ registerTool(defineTool({
2365
2368
  name: 'agent_teams_delete',
2366
2369
  description: 'End and archive your team: interrupts members and moves the current tasks and mailboxes out of active state for later inspection. Use when the work is done or explicitly abandoned. A same-name archive replaces its previous generation.',
2367
2370
  parameters: {},
@@ -7,6 +7,8 @@ interface CapabilityConfig {
7
7
  isPendingMember: (agent: Agent) => boolean;
8
8
  captainPrompt: () => string;
9
9
  order?: number;
10
+ /** Session model-menu switch; omitted keeps the legacy always-on prompt. */
11
+ isTeamEnabled?: (agent: Agent) => boolean;
10
12
  }
11
13
  /** Call once, after all business definitions have registered. Never per member. */
12
14
  export declare function installTeamCapabilities(ctx: Context, config: CapabilityConfig): void;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 「启用AgentTeam」开关,占据官方模型与推理菜单的 `conversation.input.model.options`
3
+ * 列表槽位。样式、开关与信息按钮完全复用官方 TeamModeToggle;功能改为控制
4
+ * Fish AgentTeams 的会话开关(官方任务工具与官方团队 UI 行由 bundle 停用)。
5
+ *
6
+ * 开关状态读取原生 `agentTeam` 投影(持久化在 Session 日志),写入走 Fish 自己的
7
+ * `/plugins/dsh-agent-teams/mode` 路由;该路由只调用原生服务的 setEnabled,因此
8
+ * 关闭后 Fish 的 agent_teams_* 工具与提示词在下一个模型步骤就不再参与。
9
+ */
10
+ import { type ReactNode } from 'react';
11
+ import type { PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
12
+ import type { AgentTeamsTranslate } from './locales.js';
13
+ /** Props supplied by the official model-options list slot plus our locale. */
14
+ export type AgentTeamToggleProps = PropsRuntime<'conversation.input.model.options'> & {
15
+ t: AgentTeamsTranslate;
16
+ };
17
+ /** Read and change the Fish AgentTeams selection for root Sessions only. */
18
+ export declare function AgentTeamToggle(props: AgentTeamToggleProps): ReactNode;
@@ -5,6 +5,10 @@ export declare const AGENT_TEAMS_LOCALE_NAMESPACE = "agentTeams";
5
5
  export declare const zh: {
6
6
  'workspace.dependencies': string;
7
7
  'workspace.title': string;
8
+ 'mode.label': string;
9
+ 'mode.description': string;
10
+ 'mode.infoLabel': string;
11
+ 'mode.failed': string;
8
12
  'workspace.guide': string;
9
13
  'workspace.eyebrow': string;
10
14
  'workspace.description': string;
@@ -239,6 +243,10 @@ export type AgentTeamsLocaleKey = keyof typeof zh;
239
243
  export declare const en: {
240
244
  'workspace.dependencies': string;
241
245
  'workspace.title': string;
246
+ 'mode.label': string;
247
+ 'mode.description': string;
248
+ 'mode.infoLabel': string;
249
+ 'mode.failed': string;
242
250
  'workspace.guide': string;
243
251
  'workspace.eyebrow': string;
244
252
  'workspace.description': string;
@@ -0,0 +1,17 @@
1
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
2
+ interface SlotMap {
3
+ 'conversation.input.model.options': {
4
+ kind: 'list';
5
+ scope: 'session';
6
+ owner: {
7
+ /** Whether the composer currently refuses selection changes. */
8
+ locked: boolean;
9
+ /** Close the menu and focus its trigger synchronously before opening another overlay. */
10
+ dismiss: () => void;
11
+ /** Report a failed selection through the menu owner's persistent toast. */
12
+ reportFailure: (message: string) => void;
13
+ };
14
+ };
15
+ }
16
+ }
17
+ export {};
@@ -139,6 +139,10 @@ export declare function assertMemberModelSelection(ctx: Context, captain: Agent,
139
139
  provider: string;
140
140
  model: string;
141
141
  }): void;
142
+ /** rc.2 summaries use tree names; the new structured reason owns the outcome. */
143
+ export declare function successfulSubagentSettlement(source: MessageSource | undefined): source is Extract<MessageSource, {
144
+ kind: 'subagent-settled';
145
+ }>;
142
146
  /** Install before the first request, including cold resume, with HMR cleanup. */
143
147
  export declare function installContinuableMemberSetup(ctx: Context, setup: Setup): void;
144
148
  /** Queue a distinct host-authored turn; never substitute model-message steer. */
@@ -36,6 +36,12 @@ export interface ToolsConfig {
36
36
  profiles: Record<string, import('./profiles.ts').TeamProfileConfig>;
37
37
  /** Owner-declared reusable member tool policies, keyed by policy id (#59). */
38
38
  toolPolicies: Record<string, MemberToolPolicy>;
39
+ /**
40
+ * Per-agent gate: the session's model-menu 「启用AgentTeam」 switch must be on
41
+ * for AgentTeams tools and prompt to participate. Omitted keeps the legacy
42
+ * always-on behavior for hosts without the native team-mode service.
43
+ */
44
+ isTeamEnabled?: (agent: Agent) => boolean;
39
45
  }
40
46
  /** Browser/UI mutations allowed while a plan is waiting for approval. */
41
47
  export type StagedPlanMutation = {