@fish-under-sea/dsh-agent-teams-fish 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # @fish-under-sea/dsh-agent-teams-fish
2
2
 
3
- **2.2.2 · Upstream v0.1.30 synced · dsh-fish bundle member · Durable teams with Fish vendor artwork**
3
+ **2.3.0 · Upstream v0.1.30 synced · dsh-fish bundle member · Durable teams with Fish vendor artwork**
4
4
 
5
5
  [简体中文](README.md)
6
6
 
7
7
  ## Installation and Compatibility
8
8
 
9
- Since 2.2.2 this package lives in the [Fish-under-sea/dsh-fish](https://github.com/Fish-under-sea/dsh-fish) bundle repository as the workspace member `packages/dsh-agent-teams-fish`, built, versioned and released together with the other members; the former standalone repository no longer evolves separately.
9
+ Since 2.3.0 this package lives in the [Fish-under-sea/dsh-fish](https://github.com/Fish-under-sea/dsh-fish) bundle repository as the workspace member `packages/dsh-agent-teams-fish`, built, versioned and released together with the other members; the former standalone repository no longer evolves separately.
10
10
 
11
11
  ```sh
12
12
  # Bundle install (recommended, includes every member)
13
- dsh plugin --profile <profile> add @fish-under-sea/dsh-fish@2.2.2
13
+ dsh plugin --profile <profile> add @fish-under-sea/dsh-fish@2.3.0
14
14
 
15
15
  # Or install this member alone
16
- dsh plugin --profile <profile> add @fish-under-sea/dsh-agent-teams-fish@2.2.2
16
+ dsh plugin --profile <profile> add @fish-under-sea/dsh-agent-teams-fish@2.3.0
17
17
  ```
18
18
 
19
19
  The bundle already includes this member; do not mount twice. Restart DSH after installation. Requires Node `>=24.9`. Recommended Host: `0.2.2-rc.3`; older targets such as `0.2.2-rc.2` and `0.2.2-rc.1` remain supported. [compatibility.json](compatibility.json) is the exact support authority; desktop and core versions are distinct.
@@ -48,9 +48,9 @@ Maintainers decide when to build and check before a release. Runtime approvals a
48
48
 
49
49
  ## Attribution and History
50
50
 
51
- Based on [NanmiCoder/dsh-agent-teams](https://github.com/NanmiCoder/dsh-agent-teams) (original author Relakkes / 程序员阿江). MIT. Upstream READMEs, NOTICE and release history are preserved. The source baseline follows upstream tag v0.1.30 (commit 4354b0f); since 2.2.2 the package is vendored into the dsh-fish bundle repository and versioned with it.
51
+ Based on [NanmiCoder/dsh-agent-teams](https://github.com/NanmiCoder/dsh-agent-teams) (original author Relakkes / 程序员阿江). MIT. Upstream READMEs, NOTICE and release history are preserved. The source baseline follows upstream tag v0.1.30 (commit 4354b0f); since 2.3.0 the package is vendored into the dsh-fish bundle repository and versioned with it.
52
52
 
53
- - [2.2.2](release-notes/v2.2.2.md)
53
+ - [2.3.0](release-notes/v2.3.0.md)
54
54
  - [1.1.0](release-notes/v1.1.0.md)
55
55
  - [1.0.2](release-notes/v1.0.2.md)
56
56
  - [1.0.1](release-notes/v1.0.1.md)
package/README.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # @fish-under-sea/dsh-agent-teams-fish
2
2
 
3
- **2.2.2 · 同步上游 v0.1.30 · dsh-fish 聚合成员 · 持久团队协作与 Fish 厂商美术**
3
+ **2.3.0 · 同步上游 v0.1.30 · dsh-fish 聚合成员 · 持久团队协作与 Fish 厂商美术**
4
4
 
5
5
  [English](README.en.md)
6
6
 
7
7
  ## 安装与兼容
8
8
 
9
- 自 2.2.2 起,本包并入 [Fish-under-sea/dsh-fish](https://github.com/Fish-under-sea/dsh-fish) 聚合仓库,作为工作区成员 `packages/dsh-agent-teams-fish` 与其它成员统一构建、统一版本、统一发布;原独立仓库不再单独演进。
9
+ 自 2.3.0 起,本包并入 [Fish-under-sea/dsh-fish](https://github.com/Fish-under-sea/dsh-fish) 聚合仓库,作为工作区成员 `packages/dsh-agent-teams-fish` 与其它成员统一构建、统一版本、统一发布;原独立仓库不再单独演进。
10
10
 
11
11
  ```sh
12
12
  # 聚合安装(推荐,含全部成员)
13
- dsh plugin --profile <profile> add @fish-under-sea/dsh-fish@2.2.2
13
+ dsh plugin --profile <profile> add @fish-under-sea/dsh-fish@2.3.0
14
14
 
15
15
  # 或单独安装本成员
16
- dsh plugin --profile <profile> add @fish-under-sea/dsh-agent-teams-fish@2.2.2
16
+ dsh plugin --profile <profile> add @fish-under-sea/dsh-agent-teams-fish@2.3.0
17
17
  ```
18
18
 
19
19
  聚合已包含本成员,不要重复挂载。安装后重启 DSH。Node 要求 `>=24.9`。推荐宿主 `0.2.2-rc.3`;`0.2.2-rc.2`、`0.2.2-rc.1` 等旧版本仍在支持列表内。精确支持列表以 [compatibility.json](compatibility.json) 为唯一事实源,不以桌面应用版本推断核心版本。
@@ -48,9 +48,9 @@ pnpm --filter @fish-under-sea/dsh-agent-teams-fish verify
48
48
 
49
49
  ## 来源与记录
50
50
 
51
- 基于 [NanmiCoder/dsh-agent-teams](https://github.com/NanmiCoder/dsh-agent-teams)(原作者 Relakkes / 程序员阿江)。MIT。保留上游 README、NOTICE 和历史发布说明。源码基线为上游 tag v0.1.30(commit 4354b0f);自 2.2.2 起并入 dsh-fish 聚合仓库,版本随聚合统一。
51
+ 基于 [NanmiCoder/dsh-agent-teams](https://github.com/NanmiCoder/dsh-agent-teams)(原作者 Relakkes / 程序员阿江)。MIT。保留上游 README、NOTICE 和历史发布说明。源码基线为上游 tag v0.1.30(commit 4354b0f);自 2.3.0 起并入 dsh-fish 聚合仓库,版本随聚合统一。
52
52
 
53
- - [2.2.2](release-notes/v2.2.2.md)
53
+ - [2.3.0](release-notes/v2.3.0.md)
54
54
  - [1.1.0](release-notes/v1.1.0.md)
55
55
  - [1.0.2](release-notes/v1.0.2.md)
56
56
  - [1.0.1](release-notes/v1.0.1.md)
@@ -1,12 +1,20 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "recommendedHost": "0.2.2-rc.3",
3
+ "recommendedHost": "0.2.2-rc.5",
4
4
  "previewTag": "next",
5
5
  "supportedHosts": [
6
6
  {
7
- "version": "0.2.2-rc.3",
7
+ "version": "0.2.2-rc.5",
8
8
  "track": "recommended"
9
9
  },
10
+ {
11
+ "version": "0.2.2-rc.4",
12
+ "track": "preview"
13
+ },
14
+ {
15
+ "version": "0.2.2-rc.3",
16
+ "track": "preview"
17
+ },
10
18
  {
11
19
  "version": "0.2.2-rc.2",
12
20
  "track": "preview"
@@ -15,6 +23,10 @@
15
23
  "version": "0.2.2-rc.1",
16
24
  "track": "preview"
17
25
  },
26
+ {
27
+ "version": "0.2.1-rc.3",
28
+ "track": "preview"
29
+ },
18
30
  {
19
31
  "version": "0.2.1-rc.2",
20
32
  "track": "preview"
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schema": 1,
3
- "source": "d065c3200b9d78230aaf0981b6bf120a0b526f17f393936e548eb64ed3e75694",
4
- "output": "96abbf30ae7b0fe6854e577596d8ead4c2c0db74489f5ce82de246eccd0aca77"
3
+ "source": "c91fa7fb8185e1243cd14b96605e6f1bce69229c3298dfc26602ea3f2830ec8c",
4
+ "output": "5fb513894b5346013a3290708452ea34adf96190b3cbce314101c0b683101da4"
5
5
  }
@@ -222,6 +222,37 @@ export function sessionOwnEvents(session) {
222
222
  return unsupported('missing ownEvents/legacy session log');
223
223
  return legacy.events.slice(legacy.header.seedLength ?? 0);
224
224
  }
225
+ /**
226
+ * Search child-owned history in bounded reads on hosts with ranged snapshots.
227
+ * Stop at the first match in the requested direction without copying the full log.
228
+ */
229
+ export function findOwnSessionEvent(session, matches, options = {}) {
230
+ const { order = 'oldest', fromSeq = 0 } = options;
231
+ const start = Math.max(session.inheritedEventCount, fromSeq);
232
+ const end = session.seq;
233
+ const search = (events) => {
234
+ if (order === 'oldest')
235
+ return events.find(matches);
236
+ for (let i = events.length - 1; i >= 0; i--) {
237
+ const event = events[i];
238
+ if (matches(event))
239
+ return event;
240
+ }
241
+ };
242
+ if (typeof session.snapshotEvents !== 'function' || !Number.isSafeInteger(start) || !Number.isSafeInteger(end)) {
243
+ return search(sessionOwnEvents(session));
244
+ }
245
+ const batchSize = 256;
246
+ let cursor = order === 'oldest' ? start : end;
247
+ while (order === 'oldest' ? cursor < end : cursor > start) {
248
+ const from = order === 'oldest' ? cursor : Math.max(start, cursor - batchSize);
249
+ const to = order === 'oldest' ? Math.min(end, cursor + batchSize) : cursor;
250
+ const event = search(session.snapshotEvents(from, to));
251
+ if (event !== undefined)
252
+ return event;
253
+ cursor = order === 'oldest' ? to : from;
254
+ }
255
+ }
225
256
  /** Legacy hosts log each chunk separately; current hosts embed the committed stream. */
226
257
  export function outputLimitTurn(event) {
227
258
  const record = event;
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, successfulSubagentSettlement } from "./harness-compat.js";
3
+ import { findOwnSessionEvent, 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) {
@@ -188,18 +188,8 @@ export function installMailboxAdmission(ctx, stateDir) {
188
188
  // existing turn, a status tool may have consumed this same mail already;
189
189
  // dropping its duplicate must not block the pending tool-result response.
190
190
  if (decision.messages.length > 0 && admitted.length === 0) {
191
- const events = sessionOwnEvents(payload.agent.session);
192
- let continuing = false;
193
- for (let i = events.length - 1; i >= 0; i--) {
194
- const event = events[i];
195
- if (event.type === 'step/start' && event.data.turn === payload.turn) {
196
- continuing = true;
197
- break;
198
- }
199
- if (event.type === 'turn/start')
200
- break;
201
- }
202
- if (!continuing)
191
+ const boundary = findOwnSessionEvent(payload.agent.session, event => event.type === 'turn/start' || (event.type === 'step/start' && event.data.turn === payload.turn), { order: 'newest' });
192
+ if (boundary?.type !== 'step/start')
203
193
  return { kind: 'reject' };
204
194
  }
205
195
  return { ...decision, messages: admitted };
package/lib/members.js CHANGED
@@ -16,7 +16,7 @@ import { foldSubagentDescriptor } from '@deepseek-ai/dsh-subagent';
16
16
  import { createUserMessage, LlmError, ReasoningEffortId } from '@deepseek-ai/dsh-llm';
17
17
  import { randomUUID } from 'node:crypto';
18
18
  import { join } from 'node:path';
19
- import { agentTeamsSource, assertMemberModelSelection, memberModelSelectionPolicy, observedSessionFormatVersion, outputLimitTurn, guardSubagentCreation, installMemberModelSelection, startMember, usesManagedActivations, guardSubagentDelivery, installContinuableMemberSetup, memberToolFilter, queueMemberPrompt, restrictableToolNames, startMemberWithLenientFilter, steerMemberPrompt, sessionOwnEvents } from "./harness-compat.js";
19
+ import { agentTeamsSource, assertMemberModelSelection, memberModelSelectionPolicy, observedSessionFormatVersion, outputLimitTurn, guardSubagentCreation, installMemberModelSelection, startMember, usesManagedActivations, guardSubagentDelivery, installContinuableMemberSetup, memberToolFilter, queueMemberPrompt, restrictableToolNames, startMemberWithLenientFilter, steerMemberPrompt, findOwnSessionEvent } from "./harness-compat.js";
20
20
  import { markMailboxDelivered, appendMailbox, CAPTAIN_KEY, createMessage, readRetiredMemberIds, readTeamSync, readTeam, releaseMailboxDelivery, withTeamLock, writeTeam } from "./state.js";
21
21
  import { mailboxPrompt } from "./mailbox.js";
22
22
  import { nearestLiveLead } from "./lineage.js";
@@ -555,13 +555,13 @@ export function installMemberSelectionRuntime(ctx, stateDir, onFailureSettled) {
555
555
  const pending = new Map();
556
556
  const pendingSetup = new Map();
557
557
  installContinuableMemberSetup(ctx, (childCtx, child) => {
558
- const descriptor = foldSubagentDescriptor(sessionOwnEvents(child.session));
559
- if (descriptor?.mode !== 'continuable' || !descriptor.label.startsWith(MEMBER_LABEL_PREFIX)) {
560
- return () => undefined;
561
- }
562
558
  const parentSessionId = child.session.header.parentSession;
563
559
  if (parentSessionId === undefined)
564
560
  return () => undefined;
561
+ const descriptor = ownSubagentDescriptor(child);
562
+ if (descriptor?.mode !== 'continuable' || !descriptor.label.startsWith(MEMBER_LABEL_PREFIX)) {
563
+ return () => undefined;
564
+ }
565
565
  const identity = descriptor.label.slice(MEMBER_LABEL_PREFIX.length);
566
566
  const separator = identity.indexOf(':');
567
567
  if (separator < 1 || separator === identity.length - 1)
@@ -792,8 +792,10 @@ export function installMemberSelectionRuntime(ctx, stateDir, onFailureSettled) {
792
792
  return {
793
793
  isPendingMember(agent) {
794
794
  const parent = agent.session.header.parentSession;
795
- const descriptor = foldSubagentDescriptor(sessionOwnEvents(agent.session));
796
- return parent !== undefined && descriptor?.mode === 'continuable'
795
+ if (parent === undefined || pending.size === 0)
796
+ return false;
797
+ const descriptor = ownSubagentDescriptor(agent);
798
+ return descriptor?.mode === 'continuable'
797
799
  && pending.has(pendingSelectionKey(parent, descriptor.label));
798
800
  },
799
801
  async withPending(parentSessionId, label, selection, operation, setup) {
@@ -1041,6 +1043,18 @@ export function installRetiredMemberGuard(ctx, stateDir) {
1041
1043
  return retired.has(childId);
1042
1044
  });
1043
1045
  }
1046
+ const subagentDescriptorScan = new WeakMap();
1047
+ /** Harness treats the first descriptor in the child's own log as authoritative. */
1048
+ function ownSubagentDescriptor(agent) {
1049
+ const { session } = agent;
1050
+ const prior = subagentDescriptorScan.get(session);
1051
+ const event = prior?.event ?? findOwnSessionEvent(session, entry => entry.type === 'subagent/descriptor', { fromSeq: prior?.through });
1052
+ // Session history is append-only. After exhausting an own prefix, resume the
1053
+ // scan at newly appended events, and retain the first descriptor once seen.
1054
+ if (typeof session.seq === 'number')
1055
+ subagentDescriptorScan.set(session, { through: session.seq, event });
1056
+ return event === undefined ? undefined : foldSubagentDescriptor([event]);
1057
+ }
1044
1058
  /** Bound all descendant creation, including renamed tools and code-runtime calls. */
1045
1059
  export function installMemberDelegationGuard(ctx, stateDir, maxDepth) {
1046
1060
  let active = true;
@@ -1050,7 +1064,7 @@ export function installMemberDelegationGuard(ctx, stateDir, maxDepth) {
1050
1064
  let ancestor = parent;
1051
1065
  let depth = 1;
1052
1066
  while (ancestor !== undefined) {
1053
- const descriptor = foldSubagentDescriptor(sessionOwnEvents(ancestor.session));
1067
+ const descriptor = ownSubagentDescriptor(ancestor);
1054
1068
  if (descriptor?.label?.startsWith(MEMBER_LABEL_PREFIX)) {
1055
1069
  const identity = descriptor.label.slice(MEMBER_LABEL_PREFIX.length);
1056
1070
  const separator = identity.indexOf(':');
@@ -208,6 +208,9 @@ export function validateCreateTask(team, input) {
208
208
  if (!TASK_KINDS.includes(kind)) {
209
209
  return { ok: false, error: `unknown task kind "${String(kind)}"` };
210
210
  }
211
+ if (!nonemptyString(input.subject)) {
212
+ return { ok: false, error: 'task subject must not be empty' };
213
+ }
211
214
  if (team.halted === true) {
212
215
  const reason = input.resumeReason?.trim() ?? '';
213
216
  if (input.resume !== true || reason === '') {
package/lib/scheduler.js CHANGED
@@ -12,9 +12,11 @@
12
12
  * @module dsh-agent-teams/scheduler
13
13
  */
14
14
  import { join } from 'node:path';
15
- import { deliverToMember } from "./members.js";
15
+ import { deliverToMember, steerCaptainReport } from "./members.js";
16
+ import { nearestLiveLead } from "./lineage.js";
17
+ import { appendTeamEvent, captainSessionOf } from "./events.js";
16
18
  import { isCurrentMail, mailboxPrompt } from "./mailbox.js";
17
- import { markMailboxDelivered, discardMailboxMessages, beginTaskAttempt, CAPTAIN_KEY, claimMailboxDelivery, findTeamByParticipant, invalidateTaskAttempt, readTeam, readPendingMailbox, releaseMailboxDelivery, unsatisfiedDependencies, withTeamLock, writeTeam, } from "./state.js";
19
+ import { appendMailbox, createMessage, readMailbox, markMailboxDelivered, discardMailboxMessages, beginTaskAttempt, CAPTAIN_KEY, claimMailboxDelivery, findTeamByParticipant, invalidateTaskAttempt, readTeam, readPendingMailbox, releaseMailboxDelivery, unsatisfiedDependencies, withTeamLock, writeTeam, } from "./state.js";
18
20
  import { contractStaleness, isVerdictKind, taskKindOf, verdictScopePatterns } from "./quality-gates.js";
19
21
  import { digestWorkspacePaths, snapshotWorkspacePaths } from "./artifacts.js";
20
22
  /** Per-dependency output cap in the assignment prompt. */
@@ -394,6 +396,54 @@ export function installTeamScheduler(ctx, config) {
394
396
  });
395
397
  },
396
398
  };
399
+ const notifyParkedAttempt = async (stateRoot, teamId, agent) => {
400
+ const prepared = await withTeamLock(teamLockKey(stateRoot, teamId), async () => {
401
+ const fresh = await readTeam(stateRoot, teamId);
402
+ const current = fresh?.members.find(candidate => candidate.id === agent.id && candidate.status !== 'removed');
403
+ if (fresh === undefined || current === undefined || current.status !== 'idle'
404
+ || fresh.halted === true || fresh.phase === 'staged' || current.stopping === true)
405
+ return;
406
+ const owned = ownedOpenTask(fresh.tasks, current.name);
407
+ if (owned?.attemptId === undefined || owned.attemptId !== parkedAttempts.get(agent.id)
408
+ || owned.reassigning === true)
409
+ return;
410
+ // Mail history, not the process-local park marker, dedupes notices
411
+ // across acknowledgement, re-parking and scheduler replacement.
412
+ const id = `parked-attempt:${JSON.stringify([current.id, owned.id, owned.attemptId])}`;
413
+ const inbox = await readMailbox(stateRoot, fresh.id, CAPTAIN_KEY);
414
+ if (inbox.some(item => item.id === id))
415
+ return;
416
+ const content = `Member "${current.name}" is idle with open task ${owned.id}`
417
+ + ` (attempt ${owned.attempt ?? 1}, attempt_id ${owned.attemptId}).`
418
+ + ' Scheduling is parked; use agent_teams_reassign_task to resume.';
419
+ const message = {
420
+ ...createMessage(current.name, CAPTAIN_KEY, content),
421
+ id,
422
+ sourceTaskId: owned.id,
423
+ sourceAttemptId: owned.attemptId,
424
+ sourceTaskStatus: owned.status,
425
+ deliveryClaimedAt: Date.now(),
426
+ };
427
+ await appendMailbox(stateRoot, fresh.id, CAPTAIN_KEY, message);
428
+ appendTeamEvent(ctx, captainSessionOf(ctx, fresh.captainSessionId, agent.session), 'agent-teams/message-sent', {
429
+ teamId: fresh.id,
430
+ messageId: message.id,
431
+ from: current.name,
432
+ to: CAPTAIN_KEY,
433
+ content: message.content,
434
+ ts: message.ts,
435
+ });
436
+ return { captainSessionId: fresh.captainSessionId, members: fresh.members, memberName: current.name, message };
437
+ });
438
+ // A steer may synchronously start a turn; all host calls stay outside the lock.
439
+ if (prepared !== undefined) {
440
+ const captain = nearestLiveLead(ctx, prepared);
441
+ const delivered = captain !== undefined && steerCaptainReport(captain, prepared.memberName, prepared.message.content, mailboxPrompt(teamId, CAPTAIN_KEY, [prepared.message]));
442
+ await withTeamLock(teamLockKey(stateRoot, teamId), () => delivered
443
+ ? markMailboxDelivered(stateRoot, teamId, CAPTAIN_KEY, [prepared.message.id])
444
+ : releaseMailboxDelivery(stateRoot, teamId, CAPTAIN_KEY, [prepared.message.id]));
445
+ }
446
+ };
397
447
  const syncMemberStatus = async (agent, status) => {
398
448
  const workspace = agent.session.header.cwd ?? process.cwd();
399
449
  const stateRoot = stateRootOf(workspace, config);
@@ -444,6 +494,7 @@ export function installTeamScheduler(ctx, config) {
444
494
  if (fresh === undefined || current === undefined)
445
495
  return;
446
496
  const next = status === 'running' ? 'working' : 'idle';
497
+ // Guidance can wake the member without replacing its parked attempt.
447
498
  if (next === 'idle') {
448
499
  const owned = ownedOpenTask(fresh.tasks, current.name);
449
500
  if (owned?.attemptId === undefined)
@@ -451,16 +502,16 @@ export function installTeamScheduler(ctx, config) {
451
502
  else
452
503
  parkedAttempts.set(agent.id, owned.attemptId);
453
504
  }
454
- else {
455
- parkedAttempts.delete(agent.id);
456
- }
457
505
  if (current.status === next)
458
506
  return;
459
507
  current.status = next;
460
508
  await writeTeam(stateRoot, fresh);
461
509
  });
462
- if (status === 'idle')
510
+ if (status === 'idle') {
463
511
  await runtime.kickMember(workspace, located.id, member.name);
512
+ // Wait for the member lane before deciding whether its attempt stayed parked.
513
+ await notifyParkedAttempt(stateRoot, located.id, agent);
514
+ }
464
515
  };
465
516
  ctx.on('agent/status', ({ agent, status }) => {
466
517
  void syncMemberStatus(agent, status).catch((error) => {
package/lib/tools.js CHANGED
@@ -573,7 +573,9 @@ export function registerAgentTeamsTools(ctx, config) {
573
573
  if (fresh.halted === true)
574
574
  throw new Error('team is halted; resume before editing tasks');
575
575
  if (!staged && mutations.some(mutation => mutation.action !== 'update_task')) {
576
- throw new Error('a running team only permits update_task edits to pending, never-started tasks; roster and removal edits require a staged plan');
576
+ throw new Error('agent_teams_edit_plan only updates pending, never-started tasks while the team is running. '
577
+ + 'Use agent_teams_create_task, agent_teams_add_member, agent_teams_remove_member, agent_teams_reassign_task, '
578
+ + 'or agent_teams_update_task for other changes on a running team.');
577
579
  }
578
580
  for (const mutation of mutations) {
579
581
  if (mutation.action === 'update_member') {
@@ -800,6 +802,7 @@ export function registerAgentTeamsTools(ctx, config) {
800
802
  members: { type: 'array', required: true, items: { type: 'object', additionalProperties: false, properties: {
801
803
  name: { type: 'string', required: true }, role: { type: 'string', description: 'Member role token. Use one of: engineer、qa、security、researcher、designer、docs、data、operator、audio、video. Pick the closest bucket instead of inventing a new role name — an unknown role loses its role artwork and falls back to the vendor image. Chinese role words are accepted, but the token list is preferred.' },
802
804
  provider: { type: 'string' }, model: { type: 'string' }, reasoning_effort: { type: 'string' },
805
+ executionPrompt: { type: 'string', description: 'Optional member-specific execution prompt.' },
803
806
  tool_policy: { type: 'string', description: 'Optional owner-declared tool-policy id for this member.' },
804
807
  } } },
805
808
  tasks: { type: 'array', required: true, items: { type: 'object', additionalProperties: false, properties: {
@@ -2443,6 +2446,7 @@ async function initializeProfileTeam(input) {
2443
2446
  provider: trimmedOptional(member.provider),
2444
2447
  model: trimmedOptional(member.model),
2445
2448
  reasoning_effort: trimmedOptional(member.reasoning_effort),
2449
+ executionPrompt: trimmedOptional(member.executionPrompt),
2446
2450
  tool_policy: trimmedOptional(member.tool_policy),
2447
2451
  })),
2448
2452
  };
@@ -2695,7 +2699,7 @@ function renderStatus(value) {
2695
2699
  team.loop_state && team.loop_state !== 'running' && team.loop_state !== 'halted' && team.loop_state !== 'escalated'
2696
2700
  ? team.loop_state
2697
2701
  : undefined,
2698
- ].filter((item) => item !== undefined);
2702
+ ].filter((item, index, all) => item !== undefined && all.indexOf(item) === index);
2699
2703
  const lines = [
2700
2704
  `Team "${team.team_name}"${team.description ? ` — ${team.description}` : ''}${flags.length > 0 ? ` [${flags.join(', ')}]` : ''}`,
2701
2705
  ...team.profile === undefined ? [] : [`Profile: ${team.profile.name}${team.profile.task_planning ? ` [${team.profile.task_planning}]` : ''}${team.profile.protocol ? ` — ${team.profile.protocol}` : ''}`],
@@ -127,6 +127,14 @@ export declare function agentTeamsSource(modern: AgentTeamsSource, observed?: nu
127
127
  export declare function onAgentReady(ctx: Context, listener: (agent: Agent, vetoable: boolean) => void): () => void;
128
128
  /** Read child-owned history, excluding any descriptor inherited from a parent. */
129
129
  export declare function sessionOwnEvents(session: Session): readonly SessionEvent[];
130
+ /**
131
+ * Search child-owned history in bounded reads on hosts with ranged snapshots.
132
+ * Stop at the first match in the requested direction without copying the full log.
133
+ */
134
+ export declare function findOwnSessionEvent(session: Session, matches: (event: SessionEvent) => boolean, options?: {
135
+ order?: 'oldest' | 'newest';
136
+ fromSeq?: number;
137
+ }): SessionEvent | undefined;
130
138
  /** Legacy hosts log each chunk separately; current hosts embed the committed stream. */
131
139
  export declare function outputLimitTurn(event: SessionEvent): number | undefined;
132
140
  /** 读取官方 subagent 冻结在本会话的允许模型名单;没有策略时返回 undefined。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fish-under-sea/dsh-agent-teams-fish",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "AgentTeams 多智能体团队协作(DeepSeek Harness 插件):自然语言组队、成员与任务依赖 DAG、信箱通信、右侧栏树状监测 —— 上游 NanmiCoder/dsh-agent-teams 的补充版,新增自定义美术目录、十八厂商头像(十个有厂商 × 岗位全套)与厂商商标徽标。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -65,7 +65,8 @@
65
65
  "llm"
66
66
  ],
67
67
  "engines": {
68
- "node": ">=24.9"
68
+ "node": ">=24.9",
69
+ "dsh": ">=0.2.2-rc.3 <0.3.0"
69
70
  },
70
71
  "publishConfig": {
71
72
  "access": "public",
@@ -74,7 +75,7 @@
74
75
  },
75
76
  "dsh": {
76
77
  "engines": {
77
- "dsh": ">=0.2.2-rc.3"
78
+ "dsh": ">=0.2.2-rc.3 <0.3.0"
78
79
  },
79
80
  "bundle": {
80
81
  "patch": "./cordis.patch.yml"
@@ -127,27 +128,27 @@
127
128
  },
128
129
  "peerDependencies": {
129
130
  "@deepseek-ai/cordis": "^4.1.0",
130
- "@deepseek-ai/dsh-agent": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
131
- "@deepseek-ai/dsh-api-session-controller": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
132
- "@deepseek-ai/dsh-client-connection": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
133
- "@deepseek-ai/dsh-client-locale": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
134
- "@deepseek-ai/dsh-client-store": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
135
- "@deepseek-ai/dsh-client-ui-chat": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
136
- "@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
137
- "@deepseek-ai/dsh-client-ui-layout": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
138
- "@deepseek-ai/dsh-client-ui-model-selection": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
139
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
140
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
141
- "@deepseek-ai/dsh-client-ui-session": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
142
- "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
143
- "@deepseek-ai/dsh-commands": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
144
- "@deepseek-ai/dsh-llm": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
145
- "@deepseek-ai/dsh-session": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
146
- "@deepseek-ai/dsh-session-projection": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
147
- "@deepseek-ai/dsh-subagent": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
148
- "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
149
- "@deepseek-ai/dsh-tools": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
150
- "@deepseek-ai/dsh-util-values": "0.2.2-rc.3 || 0.2.1-alpha.2 || 0.2.0-rc.2 || 0.1.7-rc.2 || 0.1.5-rc.3 || 0.1.5-rc.2 || 0.1.5-rc.1 || 0.1.2-rc.1 || 0.1.2-alpha.5 || 0.1.2-alpha.2 || 0.2.1-rc.2",
131
+ "@deepseek-ai/dsh-agent": "^0.2.2-rc.3",
132
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.3",
133
+ "@deepseek-ai/dsh-client-connection": "^0.2.2-rc.3",
134
+ "@deepseek-ai/dsh-client-locale": "^0.2.2-rc.3",
135
+ "@deepseek-ai/dsh-client-store": "^0.2.2-rc.3",
136
+ "@deepseek-ai/dsh-client-ui-chat": "^0.2.2-rc.3",
137
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.3",
138
+ "@deepseek-ai/dsh-client-ui-layout": "^0.2.2-rc.3",
139
+ "@deepseek-ai/dsh-client-ui-model-selection": "^0.2.2-rc.3",
140
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.2.2-rc.3",
141
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.3",
142
+ "@deepseek-ai/dsh-client-ui-session": "^0.2.2-rc.3",
143
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.3",
144
+ "@deepseek-ai/dsh-commands": "^0.2.2-rc.3",
145
+ "@deepseek-ai/dsh-llm": "^0.2.2-rc.3",
146
+ "@deepseek-ai/dsh-session": "^0.2.2-rc.3",
147
+ "@deepseek-ai/dsh-session-projection": "^0.2.2-rc.3",
148
+ "@deepseek-ai/dsh-subagent": "^0.2.2-rc.3",
149
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.3",
150
+ "@deepseek-ai/dsh-tools": "^0.2.2-rc.3",
151
+ "@deepseek-ai/dsh-util-values": "^0.2.2-rc.3",
151
152
  "@deepseek-ai/schemastery": "^3.19.0",
152
153
  "react": "^18.2.0"
153
154
  },
@@ -12,7 +12,7 @@ import { installModelSelection, type Agent, type AgentOptions, type ModelSelecti
12
12
  import type { ContentBlock, MessageId, MessageSource, StreamChunk } from '@deepseek-ai/dsh-llm'
13
13
  import { createUserMessage } from '@deepseek-ai/dsh-llm'
14
14
  import * as dshSession from '@deepseek-ai/dsh-session'
15
- import type { Session, SessionEvent, SessionId } from '@deepseek-ai/dsh-session'
15
+ import type { Session, SessionEvent, SessionId, SessionLogOffset } from '@deepseek-ai/dsh-session'
16
16
  import { SubagentError } from '@deepseek-ai/dsh-subagent'
17
17
  import { BUILTIN_DENY_TOOLS, resolveMemberToolFilter, type MemberToolFilter } from './tool-policies.ts'
18
18
 
@@ -336,6 +336,39 @@ export function sessionOwnEvents(session: Session): readonly SessionEvent[] {
336
336
  return legacy.events.slice(legacy.header.seedLength ?? 0)
337
337
  }
338
338
 
339
+ /**
340
+ * Search child-owned history in bounded reads on hosts with ranged snapshots.
341
+ * Stop at the first match in the requested direction without copying the full log.
342
+ */
343
+ export function findOwnSessionEvent(
344
+ session: Session,
345
+ matches: (event: SessionEvent) => boolean,
346
+ options: { order?: 'oldest' | 'newest'; fromSeq?: number } = {},
347
+ ): SessionEvent | undefined {
348
+ const { order = 'oldest', fromSeq = 0 } = options
349
+ const start = Math.max(session.inheritedEventCount, fromSeq)
350
+ const end = session.seq
351
+ const search = (events: readonly SessionEvent[]) => {
352
+ if (order === 'oldest') return events.find(matches)
353
+ for (let i = events.length - 1; i >= 0; i--) {
354
+ const event = events[i]!
355
+ if (matches(event)) return event
356
+ }
357
+ }
358
+ if (typeof session.snapshotEvents !== 'function' || !Number.isSafeInteger(start) || !Number.isSafeInteger(end)) {
359
+ return search(sessionOwnEvents(session))
360
+ }
361
+ const batchSize = 256
362
+ let cursor: number = order === 'oldest' ? start : end
363
+ while (order === 'oldest' ? cursor < end : cursor > start) {
364
+ const from = order === 'oldest' ? cursor : Math.max(start, cursor - batchSize)
365
+ const to = order === 'oldest' ? Math.min(end, cursor + batchSize) : cursor
366
+ const event = search(session.snapshotEvents(from as SessionLogOffset, to as SessionLogOffset))
367
+ if (event !== undefined) return event
368
+ cursor = order === 'oldest' ? to : from
369
+ }
370
+ }
371
+
339
372
  /** Legacy hosts log each chunk separately; current hosts embed the committed stream. */
340
373
  export function outputLimitTurn(event: SessionEvent): number | undefined {
341
374
  const record = event as SessionEvent | {
package/src/mailbox.ts CHANGED
@@ -3,7 +3,7 @@ import type { Context } from '@deepseek-ai/cordis'
3
3
  import { join } from 'node:path'
4
4
  import { acknowledgeMailbox, CAPTAIN_KEY, discardMailboxMessages, findTeamByCaptain, readMailbox, readUnreadMailbox, readTeam, sanitizeKey, withTeamLock } from './state.ts'
5
5
  import type { TeamMessage, TeamState } from './types.ts'
6
- import { sessionOwnEvents, successfulSubagentSettlement } from './harness-compat.ts'
6
+ import { findOwnSessionEvent, successfulSubagentSettlement } from './harness-compat.ts'
7
7
  import { leadIdentityOfAsync, sessionLeadsTeamAsync } from './lineage.ts'
8
8
 
9
9
  const PREFIX = 'AgentTeams inbox receipt: '
@@ -169,14 +169,10 @@ export function installMailboxAdmission(ctx: Context, stateDir: string): void {
169
169
  // existing turn, a status tool may have consumed this same mail already;
170
170
  // dropping its duplicate must not block the pending tool-result response.
171
171
  if (decision.messages.length > 0 && admitted.length === 0) {
172
- const events = sessionOwnEvents(payload.agent.session)
173
- let continuing = false
174
- for (let i = events.length - 1; i >= 0; i--) {
175
- const event = events[i]!
176
- if (event.type === 'step/start' && event.data.turn === payload.turn) { continuing = true; break }
177
- if (event.type === 'turn/start') break
178
- }
179
- if (!continuing) return { kind: 'reject' }
172
+ const boundary = findOwnSessionEvent(payload.agent.session, event =>
173
+ event.type === 'turn/start' || (event.type === 'step/start' && event.data.turn === payload.turn),
174
+ { order: 'newest' })
175
+ if (boundary?.type !== 'step/start') return { kind: 'reject' }
180
176
  }
181
177
  return { ...decision, messages: admitted }
182
178
  })
package/src/members.ts CHANGED
@@ -20,7 +20,7 @@ import { createUserMessage, LlmError, ReasoningEffortId } from '@deepseek-ai/dsh
20
20
  import type { Session, SessionId } from '@deepseek-ai/dsh-session'
21
21
  import { randomUUID } from 'node:crypto'
22
22
  import { join } from 'node:path'
23
- import { agentTeamsSource, assertMemberModelSelection, memberModelSelectionPolicy, observedSessionFormatVersion, outputLimitTurn, type SessionFormatBearer, guardSubagentCreation, installMemberModelSelection, startMember, usesManagedActivations, guardSubagentDelivery, installContinuableMemberSetup, memberToolFilter, queueMemberPrompt, restrictableToolNames, startMemberWithLenientFilter, steerMemberPrompt, sessionOwnEvents } from './harness-compat.ts'
23
+ import { agentTeamsSource, assertMemberModelSelection, memberModelSelectionPolicy, observedSessionFormatVersion, outputLimitTurn, type SessionFormatBearer, guardSubagentCreation, installMemberModelSelection, startMember, usesManagedActivations, guardSubagentDelivery, installContinuableMemberSetup, memberToolFilter, queueMemberPrompt, restrictableToolNames, startMemberWithLenientFilter, steerMemberPrompt, findOwnSessionEvent } from './harness-compat.ts'
24
24
  import { markMailboxDelivered, appendMailbox, CAPTAIN_KEY, createMessage, readRetiredMemberIds, readTeamSync, readTeam, releaseMailboxDelivery, withTeamLock, writeTeam } from './state.ts'
25
25
  import { mailboxPrompt } from './mailbox.ts'
26
26
  import { nearestLiveLead } from './lineage.ts'
@@ -704,13 +704,13 @@ export function installMemberSelectionRuntime(
704
704
  const pending = new Map<string, MemberLlmSelection>()
705
705
  const pendingSetup = new Map<string, NonNullable<TeamMember['runtimeSetup']>>()
706
706
  installContinuableMemberSetup(ctx, (childCtx, child) => {
707
- const descriptor = foldSubagentDescriptor(sessionOwnEvents(child.session))
707
+ const parentSessionId = child.session.header.parentSession
708
+ if (parentSessionId === undefined) return () => undefined
709
+ const descriptor = ownSubagentDescriptor(child)
708
710
  if (descriptor?.mode !== 'continuable' || !descriptor.label.startsWith(MEMBER_LABEL_PREFIX)) {
709
711
  return () => undefined
710
712
  }
711
713
 
712
- const parentSessionId = child.session.header.parentSession
713
- if (parentSessionId === undefined) return () => undefined
714
714
  const identity = descriptor.label.slice(MEMBER_LABEL_PREFIX.length)
715
715
  const separator = identity.indexOf(':')
716
716
  if (separator < 1 || separator === identity.length - 1) return () => undefined
@@ -916,8 +916,9 @@ export function installMemberSelectionRuntime(
916
916
  return {
917
917
  isPendingMember(agent) {
918
918
  const parent = agent.session.header.parentSession
919
- const descriptor = foldSubagentDescriptor(sessionOwnEvents(agent.session))
920
- return parent !== undefined && descriptor?.mode === 'continuable'
919
+ if (parent === undefined || pending.size === 0) return false
920
+ const descriptor = ownSubagentDescriptor(agent)
921
+ return descriptor?.mode === 'continuable'
921
922
  && pending.has(pendingSelectionKey(parent, descriptor.label))
922
923
  },
923
924
  async withPending<T>(
@@ -1203,6 +1204,22 @@ export function installRetiredMemberGuard(ctx: Context, stateDir: string): void
1203
1204
  })
1204
1205
  }
1205
1206
 
1207
+ const subagentDescriptorScan = new WeakMap<Agent['session'], {
1208
+ through: number
1209
+ event: ReturnType<typeof findOwnSessionEvent>
1210
+ }>()
1211
+
1212
+ /** Harness treats the first descriptor in the child's own log as authoritative. */
1213
+ function ownSubagentDescriptor(agent: Agent) {
1214
+ const { session } = agent
1215
+ const prior = subagentDescriptorScan.get(session)
1216
+ const event = prior?.event ?? findOwnSessionEvent(session, entry => entry.type === 'subagent/descriptor', { fromSeq: prior?.through })
1217
+ // Session history is append-only. After exhausting an own prefix, resume the
1218
+ // scan at newly appended events, and retain the first descriptor once seen.
1219
+ if (typeof session.seq === 'number') subagentDescriptorScan.set(session, { through: session.seq, event })
1220
+ return event === undefined ? undefined : foldSubagentDescriptor([event])
1221
+ }
1222
+
1206
1223
  /** Bound all descendant creation, including renamed tools and code-runtime calls. */
1207
1224
  export function installMemberDelegationGuard(ctx: Context, stateDir: string, maxDepth: number): void {
1208
1225
  let active = true
@@ -1211,7 +1228,7 @@ export function installMemberDelegationGuard(ctx: Context, stateDir: string, max
1211
1228
  let ancestor: Agent | undefined = parent
1212
1229
  let depth = 1
1213
1230
  while (ancestor !== undefined) {
1214
- const descriptor = foldSubagentDescriptor(sessionOwnEvents(ancestor.session))
1231
+ const descriptor = ownSubagentDescriptor(ancestor)
1215
1232
  if (descriptor?.label?.startsWith(MEMBER_LABEL_PREFIX)) {
1216
1233
  const identity = descriptor.label.slice(MEMBER_LABEL_PREFIX.length)
1217
1234
  const separator = identity.indexOf(':')
@@ -391,6 +391,9 @@ export function validateCreateTask(team: TeamState, input: CreateTaskInput): Val
391
391
  if (!(TASK_KINDS as readonly string[]).includes(kind)) {
392
392
  return { ok: false, error: `unknown task kind "${String(kind)}"` }
393
393
  }
394
+ if (!nonemptyString(input.subject)) {
395
+ return { ok: false, error: 'task subject must not be empty' }
396
+ }
394
397
 
395
398
  if (team.halted === true) {
396
399
  const reason = input.resumeReason?.trim() ?? ''
package/src/scheduler.ts CHANGED
@@ -16,9 +16,14 @@ import type { Context } from '@deepseek-ai/cordis'
16
16
  import type { Agent, AgentStatus } from '@deepseek-ai/dsh-agent'
17
17
  import type { SessionId } from '@deepseek-ai/dsh-session'
18
18
  import { join } from 'node:path'
19
- import { deliverToMember } from './members.ts'
19
+ import { deliverToMember, steerCaptainReport } from './members.ts'
20
+ import { nearestLiveLead } from './lineage.ts'
21
+ import { appendTeamEvent, captainSessionOf } from './events.ts'
20
22
  import { isCurrentMail, mailboxPrompt } from './mailbox.ts'
21
23
  import {
24
+ appendMailbox,
25
+ createMessage,
26
+ readMailbox,
22
27
  markMailboxDelivered,
23
28
  discardMailboxMessages,
24
29
  beginTaskAttempt,
@@ -35,7 +40,7 @@ import {
35
40
  } from './state.ts'
36
41
  import { contractStaleness, isVerdictKind, taskKindOf, verdictScopePatterns } from './quality-gates.ts'
37
42
  import { digestWorkspacePaths, snapshotWorkspacePaths } from './artifacts.ts'
38
- import type { TeamMember, TeamState, TeamTask } from './types.ts'
43
+ import type { TeamMember, TeamMessage, TeamState, TeamTask } from './types.ts'
39
44
 
40
45
  /** Per-dependency output cap in the assignment prompt. */
41
46
  export const DEPENDENCY_OUTPUT_MAX_CHARS = 2_000
@@ -486,6 +491,55 @@ export function installTeamScheduler(ctx: Context, config: SchedulerConfig): Tea
486
491
  },
487
492
  }
488
493
 
494
+ const notifyParkedAttempt = async (stateRoot: string, teamId: string, agent: Agent): Promise<void> => {
495
+ const prepared = await withTeamLock(teamLockKey(stateRoot, teamId), async () => {
496
+ const fresh = await readTeam(stateRoot, teamId)
497
+ const current = fresh?.members.find(candidate => candidate.id === agent.id && candidate.status !== 'removed')
498
+ if (fresh === undefined || current === undefined || current.status !== 'idle'
499
+ || fresh.halted === true || fresh.phase === 'staged' || current.stopping === true) return
500
+ const owned = ownedOpenTask(fresh.tasks, current.name)
501
+ if (owned?.attemptId === undefined || owned.attemptId !== parkedAttempts.get(agent.id)
502
+ || owned.reassigning === true) return
503
+ // Mail history, not the process-local park marker, dedupes notices
504
+ // across acknowledgement, re-parking and scheduler replacement.
505
+ const id = `parked-attempt:${JSON.stringify([current.id, owned.id, owned.attemptId])}`
506
+ const inbox = await readMailbox(stateRoot, fresh.id, CAPTAIN_KEY)
507
+ if (inbox.some(item => item.id === id)) return
508
+ const content = `Member "${current.name}" is idle with open task ${owned.id}`
509
+ + ` (attempt ${owned.attempt ?? 1}, attempt_id ${owned.attemptId}).`
510
+ + ' Scheduling is parked; use agent_teams_reassign_task to resume.'
511
+ const message: TeamMessage = {
512
+ ...createMessage(current.name, CAPTAIN_KEY, content),
513
+ id,
514
+ sourceTaskId: owned.id,
515
+ sourceAttemptId: owned.attemptId,
516
+ sourceTaskStatus: owned.status,
517
+ deliveryClaimedAt: Date.now(),
518
+ }
519
+ await appendMailbox(stateRoot, fresh.id, CAPTAIN_KEY, message)
520
+ appendTeamEvent(ctx, captainSessionOf(ctx, fresh.captainSessionId, agent.session), 'agent-teams/message-sent', {
521
+ teamId: fresh.id,
522
+ messageId: message.id,
523
+ from: current.name,
524
+ to: CAPTAIN_KEY,
525
+ content: message.content,
526
+ ts: message.ts,
527
+ })
528
+ return { captainSessionId: fresh.captainSessionId, members: fresh.members, memberName: current.name, message }
529
+ })
530
+ // A steer may synchronously start a turn; all host calls stay outside the lock.
531
+ if (prepared !== undefined) {
532
+ const captain = nearestLiveLead(ctx, prepared)
533
+ const delivered = captain !== undefined && steerCaptainReport(
534
+ captain, prepared.memberName, prepared.message.content,
535
+ mailboxPrompt(teamId, CAPTAIN_KEY, [prepared.message]),
536
+ )
537
+ await withTeamLock(teamLockKey(stateRoot, teamId), () => delivered
538
+ ? markMailboxDelivered(stateRoot, teamId, CAPTAIN_KEY, [prepared.message.id])
539
+ : releaseMailboxDelivery(stateRoot, teamId, CAPTAIN_KEY, [prepared.message.id]))
540
+ }
541
+ }
542
+
489
543
  const syncMemberStatus = async (agent: Agent, status: AgentStatus): Promise<void> => {
490
544
  const workspace = agent.session.header.cwd ?? process.cwd()
491
545
  const stateRoot = stateRootOf(workspace, config)
@@ -530,18 +584,21 @@ export function installTeamScheduler(ctx: Context, config: SchedulerConfig): Tea
530
584
  const current = fresh?.members.find(candidate => candidate.id === agent.id && candidate.status !== 'removed')
531
585
  if (fresh === undefined || current === undefined) return
532
586
  const next = status === 'running' ? 'working' : 'idle'
587
+ // Guidance can wake the member without replacing its parked attempt.
533
588
  if (next === 'idle') {
534
589
  const owned = ownedOpenTask(fresh.tasks, current.name)
535
590
  if (owned?.attemptId === undefined) parkedAttempts.delete(agent.id)
536
591
  else parkedAttempts.set(agent.id, owned.attemptId)
537
- } else {
538
- parkedAttempts.delete(agent.id)
539
592
  }
540
593
  if (current.status === next) return
541
594
  current.status = next
542
595
  await writeTeam(stateRoot, fresh)
543
596
  })
544
- if (status === 'idle') await runtime.kickMember(workspace, located.id, member.name)
597
+ if (status === 'idle') {
598
+ await runtime.kickMember(workspace, located.id, member.name)
599
+ // Wait for the member lane before deciding whether its attempt stayed parked.
600
+ await notifyParkedAttempt(stateRoot, located.id, agent)
601
+ }
545
602
  }
546
603
 
547
604
  ctx.on('agent/status', ({ agent, status }) => {
package/src/tools.ts CHANGED
@@ -744,7 +744,9 @@ export function registerAgentTeamsTools(ctx: Context, config: ToolsConfig): Agen
744
744
  if (!staged && !allowPendingEdits) requireStagedTeam(fresh)
745
745
  if (fresh.halted === true) throw new Error('team is halted; resume before editing tasks')
746
746
  if (!staged && mutations.some(mutation => mutation.action !== 'update_task')) {
747
- throw new Error('a running team only permits update_task edits to pending, never-started tasks; roster and removal edits require a staged plan')
747
+ throw new Error('agent_teams_edit_plan only updates pending, never-started tasks while the team is running. '
748
+ + 'Use agent_teams_create_task, agent_teams_add_member, agent_teams_remove_member, agent_teams_reassign_task, '
749
+ + 'or agent_teams_update_task for other changes on a running team.')
748
750
  }
749
751
  for (const mutation of mutations) {
750
752
  if (mutation.action === 'update_member') {
@@ -967,6 +969,7 @@ export function registerAgentTeamsTools(ctx: Context, config: ToolsConfig): Agen
967
969
  members: { type: 'array', required: true, items: { type: 'object', additionalProperties: false, properties: {
968
970
  name: { type: 'string', required: true }, role: { type: 'string', description: 'Member role token. Use one of: engineer、qa、security、researcher、designer、docs、data、operator、audio、video. Pick the closest bucket instead of inventing a new role name — an unknown role loses its role artwork and falls back to the vendor image. Chinese role words are accepted, but the token list is preferred.' },
969
971
  provider: { type: 'string' }, model: { type: 'string' }, reasoning_effort: { type: 'string' },
972
+ executionPrompt: { type: 'string', description: 'Optional member-specific execution prompt.' },
970
973
  tool_policy: { type: 'string', description: 'Optional owner-declared tool-policy id for this member.' },
971
974
  } } },
972
975
  tasks: { type: 'array', required: true, items: { type: 'object', additionalProperties: false, properties: {
@@ -2616,6 +2619,7 @@ async function initializeProfileTeam(input: {
2616
2619
  provider: trimmedOptional(member.provider),
2617
2620
  model: trimmedOptional(member.model),
2618
2621
  reasoning_effort: trimmedOptional(member.reasoning_effort),
2622
+ executionPrompt: trimmedOptional(member.executionPrompt),
2619
2623
  tool_policy: trimmedOptional(member.tool_policy),
2620
2624
  })),
2621
2625
  }
@@ -2896,7 +2900,7 @@ function renderStatus(value: JsonValue): string {
2896
2900
  team.loop_state && team.loop_state !== 'running' && team.loop_state !== 'halted' && team.loop_state !== 'escalated'
2897
2901
  ? team.loop_state
2898
2902
  : undefined,
2899
- ].filter((item): item is string => item !== undefined)
2903
+ ].filter((item, index, all): item is string => item !== undefined && all.indexOf(item) === index)
2900
2904
  const lines: string[] = [
2901
2905
  `Team "${team.team_name}"${team.description ? ` — ${team.description}` : ''}${flags.length > 0 ? ` [${flags.join(', ')}]` : ''}`,
2902
2906
  ...team.profile === undefined ? [] : [`Profile: ${team.profile.name}${team.profile.task_planning ? ` [${team.profile.task_planning}]` : ''}${team.profile.protocol ? ` — ${team.profile.protocol}` : ''}`],