@fish-under-sea/dsh-agent-teams-fish 1.0.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/NOTICE.md +13 -7
  2. package/README.en.md +20 -12
  3. package/README.md +20 -12
  4. package/compatibility.json +82 -46
  5. package/icon.png +0 -0
  6. package/lib/artifacts.js +148 -25
  7. package/lib/client/ActivityPanel.js +26 -5
  8. package/lib/client/WorkspaceActivity.js +6 -4
  9. package/lib/client/activity-monitor.js +113 -41
  10. package/lib/client/locales.js +14 -0
  11. package/lib/client.js +433 -199
  12. package/lib/client.js.map +1 -1
  13. package/lib/command.js +7 -4
  14. package/lib/git-artifact-stamp.json +2 -2
  15. package/lib/harness-compat.js +120 -62
  16. package/lib/index.js +7 -10
  17. package/lib/mailbox.js +15 -5
  18. package/lib/members.js +221 -154
  19. package/lib/snapshot.js +15 -10
  20. package/lib/state.js +41 -8
  21. package/lib/tools.js +123 -64
  22. package/lib/types/artifacts.d.ts +6 -3
  23. package/lib/types/client/activity-monitor.d.ts +13 -4
  24. package/lib/types/client/locales.d.ts +14 -0
  25. package/lib/types/harness-compat.d.ts +63 -16
  26. package/lib/types/mailbox.d.ts +2 -0
  27. package/lib/types/members.d.ts +5 -17
  28. package/lib/types/snapshot.d.ts +12 -7
  29. package/lib/types/state.d.ts +10 -3
  30. package/lib/types/types.d.ts +5 -0
  31. package/lib/types/web-routes.d.ts +2 -0
  32. package/lib/types/workspace-audit-service.d.ts +35 -0
  33. package/lib/types/workspace-audit-worker.d.ts +1 -0
  34. package/lib/web-routes.js +31 -0
  35. package/lib/workspace-audit-service.js +165 -0
  36. package/lib/workspace-audit-worker.js +11 -0
  37. package/lib/workspace-audit.js +6 -5
  38. package/locale/en.json +6 -0
  39. package/locale/zh.json +6 -0
  40. package/package.json +69 -64
  41. package/pnpm-workspace.yaml +306 -273
  42. package/release-notes/v0.1.25.md +16 -0
  43. package/release-notes/v0.1.26.md +19 -0
  44. package/release-notes/v0.1.27.md +42 -0
  45. package/release-notes/v0.1.28.md +45 -0
  46. package/release-notes/v0.1.29.md +23 -0
  47. package/release-notes/v1.1.0.md +42 -0
  48. package/release-notes/v2.0.0.md +17 -0
  49. package/scripts/artwork-role-match.test.mjs +517 -0
  50. package/scripts/capabilities.test.mjs +301 -0
  51. package/scripts/check-install-channel.mjs +55 -0
  52. package/scripts/check-install-channel.test.mjs +39 -0
  53. package/scripts/clean-build.mjs +14 -0
  54. package/scripts/client-harness-migration.test.mjs +46 -0
  55. package/scripts/compatibility.mjs +20 -0
  56. package/scripts/compatibility.test.mjs +187 -0
  57. package/scripts/corrupt-teamjson.test.mjs +180 -0
  58. package/scripts/custom-artwork.test.mjs +273 -0
  59. package/scripts/fallback-tdd.mjs +61 -0
  60. package/scripts/fixtures/harness-benchmark-scope.mjs +16 -0
  61. package/scripts/fixtures/harness-benchmark-scope.test.mjs +18 -0
  62. package/scripts/fixtures/harness-complex-case.mjs +201 -0
  63. package/scripts/fixtures/harness-complex-case.test.mjs +21 -0
  64. package/scripts/fixtures/harness-complex-oracle.mjs +63 -0
  65. package/scripts/fixtures/harness-issue-case.mjs +51 -0
  66. package/scripts/fixtures/harness-issue159-case.mjs +28 -0
  67. package/scripts/fixtures/harness-model-case.mjs +127 -0
  68. package/scripts/fixtures/harness-model-case.test.mjs +37 -0
  69. package/scripts/fixtures/harness-model-driver.mjs +100 -0
  70. package/scripts/fixtures/harness-runtime-credentials.mjs +23 -0
  71. package/scripts/fixtures/harness-runtime-entry.mjs +171 -0
  72. package/scripts/fixtures/harness-runtime-idle.mjs +42 -0
  73. package/scripts/fixtures/harness-runtime-llm.mjs +193 -0
  74. package/scripts/fixtures/harness-runtime-protocol.mjs +187 -0
  75. package/scripts/fixtures/harness-runtime-resume.mjs +24 -0
  76. package/scripts/fixtures/harness-runtime-stability.mjs +282 -0
  77. package/scripts/fixtures/harness-runtime-tools.mjs +13 -0
  78. package/scripts/fixtures/harness-runtime-web-approval.mjs +341 -0
  79. package/scripts/fixtures/issue-336-audit-worker.mjs +18 -0
  80. package/scripts/git-artifacts.mjs +64 -0
  81. package/scripts/git-artifacts.test.mjs +32 -0
  82. package/scripts/harness-compat-tdd.mjs +492 -0
  83. package/scripts/harness-issue-verify.mjs +26 -0
  84. package/scripts/harness-model-benchmark.mjs +163 -0
  85. package/scripts/harness-runtime-platform.test.mjs +31 -0
  86. package/scripts/harness-runtime-scenarios.mjs +297 -0
  87. package/scripts/harness-runtime-verify.mjs +169 -0
  88. package/scripts/harness-source-verify.mjs +211 -0
  89. package/scripts/harness-source-verify.test.mjs +97 -0
  90. package/scripts/harness-validation.mjs +68 -0
  91. package/scripts/harness-validation.test.mjs +95 -0
  92. package/scripts/http-body.test.mjs +72 -0
  93. package/scripts/import-vendor-artwork.mjs +78 -0
  94. package/scripts/inline-plan-blank-optional-tdd.mjs +121 -0
  95. package/scripts/issue-159.test.mjs +78 -0
  96. package/scripts/issue-188.test.mjs +148 -0
  97. package/scripts/issue-189.test.mjs +100 -0
  98. package/scripts/issue-203-card.test.mjs +181 -0
  99. package/scripts/issue-205.test.mjs +163 -0
  100. package/scripts/issue-234.test.mjs +424 -0
  101. package/scripts/issue-236-stale-module.test.mjs +63 -0
  102. package/scripts/issue-236.test.mjs +59 -0
  103. package/scripts/issue-262.test.mjs +98 -0
  104. package/scripts/issue-336.test.mjs +404 -0
  105. package/scripts/legacy-session-source-repair.test.mjs +201 -0
  106. package/scripts/lifecycle-verify.mjs +1573 -0
  107. package/scripts/lineage-identity.test.mjs +77 -0
  108. package/scripts/member-failure-tdd.mjs +451 -0
  109. package/scripts/member-spawn-recovery.test.mjs +92 -0
  110. package/scripts/quality-gates-amend.test.mjs +161 -0
  111. package/scripts/quality-gates-content-bound.test.mjs +572 -0
  112. package/scripts/quality-gates-cross-binding.test.mjs +184 -0
  113. package/scripts/quality-gates-excluded-scope.test.mjs +163 -0
  114. package/scripts/quality-gates-repair-scope.test.mjs +143 -0
  115. package/scripts/quality-gates-repair-wiring.test.mjs +189 -0
  116. package/scripts/quality-gates-tdd.mjs +1238 -0
  117. package/scripts/quality-gates-work-order.test.mjs +494 -0
  118. package/scripts/readme-version.mjs +89 -0
  119. package/scripts/readme-version.test.mjs +77 -0
  120. package/scripts/release-metadata.mjs +45 -0
  121. package/scripts/release-metadata.test.mjs +66 -0
  122. package/scripts/scoped-release.test.mjs +52 -0
  123. package/scripts/stability-tdd.mjs +144 -0
  124. package/scripts/stress-verify.mjs +548 -0
  125. package/scripts/symlink-support.mjs +46 -0
  126. package/scripts/sync-skill.mjs +103 -0
  127. package/scripts/tool-policies.test.mjs +280 -0
  128. package/scripts/update-skills.mjs +105 -0
  129. package/scripts/update-skills.test.mjs +79 -0
  130. package/scripts/upgrade-status.mjs +66 -0
  131. package/scripts/upgrade-status.test.mjs +83 -0
  132. package/scripts/verify-package.mjs +73 -0
  133. package/scripts/verify.mjs +2199 -0
  134. package/scripts/web-routes-verify.mjs +142 -0
  135. package/scripts/workspace-activity.test.mjs +346 -0
  136. package/scripts/workspace-summary.test.mjs +49 -0
  137. package/src/artifacts.ts +487 -0
  138. package/src/artwork-source.ts +262 -0
  139. package/src/capabilities.ts +113 -0
  140. package/src/client/ActivityPanel.module.css +2390 -0
  141. package/src/client/ActivityPanel.tsx +1507 -0
  142. package/src/client/AgentTeamsCard.module.css +148 -0
  143. package/src/client/AgentTeamsCard.tsx +155 -0
  144. package/src/client/StagingPlanEditor.tsx +829 -0
  145. package/src/client/TeamChatEntry.tsx +27 -0
  146. package/src/client/WorkspaceActivity.module.css +41 -0
  147. package/src/client/WorkspaceActivity.tsx +137 -0
  148. package/src/client/activity-model.ts +372 -0
  149. package/src/client/activity-monitor.ts +440 -0
  150. package/src/client/agent-teams-card-definition.ts +250 -0
  151. package/src/client/artwork.ts +374 -0
  152. package/src/client/icons.tsx +17 -0
  153. package/src/client/index.tsx +140 -0
  154. package/src/client/locales.ts +481 -0
  155. package/src/client/panel-geometry.ts +194 -0
  156. package/src/client/session-navigation.ts +73 -0
  157. package/src/client/workspace-state.ts +52 -0
  158. package/src/command.ts +145 -0
  159. package/src/css-modules.d.ts +4 -0
  160. package/src/event-types.ts +177 -0
  161. package/src/events.ts +78 -0
  162. package/src/harness-compat.ts +570 -0
  163. package/src/index.ts +599 -0
  164. package/src/lineage.ts +248 -0
  165. package/src/mailbox.ts +185 -0
  166. package/src/members.ts +1230 -0
  167. package/src/profiles.ts +765 -0
  168. package/src/quality-gates.ts +2124 -0
  169. package/src/scheduler.ts +554 -0
  170. package/src/snapshot.ts +333 -0
  171. package/src/state.ts +1317 -0
  172. package/src/tool-names.ts +14 -0
  173. package/src/tool-policies.ts +219 -0
  174. package/src/tools.ts +2939 -0
  175. package/src/types.ts +414 -0
  176. package/src/web-routes.ts +128 -0
  177. package/src/workspace-audit-service.ts +182 -0
  178. package/src/workspace-audit-worker.ts +12 -0
  179. package/src/workspace-audit.ts +57 -0
@@ -82,7 +82,7 @@ const ACCENTS = [
82
82
  function accentOf(id) {
83
83
  return ACCENTS[stableHash(id) % ACCENTS.length] ?? ACCENTS[0];
84
84
  }
85
- /** Badge text follows the raw task status (finer than the 4 visual states):
85
+ /** Badge text follows the raw task status:
86
86
  * claimed/pending/failed/cancelled keep their own labels and colors. */
87
87
  const TASK_STATUS_LABEL = {
88
88
  pending: 'task.status.pending',
@@ -186,6 +186,7 @@ function taskSummary(team, t, discarded = false) {
186
186
  const completed = team.tasks.filter((task) => task.status === 'completed');
187
187
  const cancelled = team.tasks.filter((task) => task.status === 'cancelled');
188
188
  const running = team.tasks.filter((task) => task.state === 'running');
189
+ const claimed = team.tasks.filter((task) => task.state === 'claimed');
189
190
  const blocked = team.tasks.filter((task) => task.state === 'blocked');
190
191
  const ready = team.tasks.filter((task) => task.state === 'open' && task.status !== 'completed' && task.status !== 'failed' && task.status !== 'cancelled');
191
192
  const failed = team.tasks.filter((task) => task.status === 'failed');
@@ -204,7 +205,7 @@ function taskSummary(team, t, discarded = false) {
204
205
  failed: failed.length,
205
206
  });
206
207
  }
207
- if (failed.length > 0 && running.length === 0 && ready.length === 0 && blocked.length === 0) {
208
+ if (failed.length > 0 && running.length === 0 && claimed.length === 0 && ready.length === 0 && blocked.length === 0) {
208
209
  return t('task.summary.failedSettled', { count: failed.length });
209
210
  }
210
211
  if (blocked.length > 0 && running.length > 0) {
@@ -215,6 +216,8 @@ function taskSummary(team, t, discarded = false) {
215
216
  }
216
217
  if (running.length > 0)
217
218
  return t('task.summary.running', { tasks: formatTaskIds(running.map((task) => task.id), t) });
219
+ if (claimed.length > 0)
220
+ return t('task.summary.claimed', { tasks: formatTaskIds(claimed.map((task) => task.id), t) });
218
221
  if (ready.length > 0)
219
222
  return t('task.summary.ready', { tasks: formatTaskIds(ready.map((task) => task.id), t) });
220
223
  if (blocked.length > 0)
@@ -223,11 +226,28 @@ function taskSummary(team, t, discarded = false) {
223
226
  }
224
227
  function ProgressOverview({ team, t, discarded = false }) {
225
228
  const running = discarded ? 0 : team.tasks.filter((task) => task.state === 'running').length;
229
+ const claimed = discarded ? 0 : team.tasks.filter((task) => task.state === 'claimed').length;
226
230
  const blocked = discarded ? 0 : team.tasks.filter((task) => task.state === 'blocked').length;
227
231
  const completed = discarded ? 0 : team.tasks.filter((task) => task.status === 'completed').length;
228
232
  const settled = !discarded && team.tasks.length > 0 && team.tasks.every((task) => (task.status === 'completed' || task.status === 'failed' || task.status === 'cancelled'));
229
233
  const summaryTone = discarded ? 'discarded' : blocked > 0 || team.tasks.some(task => task.status === 'failed' || task.status === 'cancelled') ? 'warning' : settled ? 'completed' : 'running';
230
- return (_jsxs("section", { className: css.progressOverview, "aria-label": t('progress.aria'), "data-progress-summary": true, children: [_jsx("span", { className: css.progressTitle, children: t('progress.title') }), team.tasks.length > 0 ? (_jsx("span", { className: css.progressSegments, "aria-hidden": true, children: team.tasks.map((task) => _jsx("span", { "data-state": discarded ? 'cancelled' : taskTone(task.state, task.status) }, task.id)) })) : _jsx("span", { className: css.progressEmpty }), _jsxs("span", { className: css.progressLegend, children: [_jsx("span", { "data-state": "running", children: t('progress.running', { count: running }) }), _jsx("span", { "data-state": "blocked", children: t('progress.blocked', { count: blocked }) }), _jsx("span", { "data-state": "completed", children: t('progress.delivered', { count: completed }) })] }), _jsxs("span", { className: css.progressSummary, "data-state": summaryTone, children: [_jsx("span", { className: css.progressSummaryDot }), _jsx("span", { children: taskSummary(team, t, discarded) })] })] }));
234
+ return (_jsxs("section", { className: css.progressOverview, "aria-label": t('progress.aria'), "data-progress-summary": true, children: [_jsx("span", { className: css.progressTitle, children: t('progress.title') }), team.tasks.length > 0 ? (_jsx("span", { className: css.progressSegments, "aria-hidden": true, children: team.tasks.map((task) => _jsx("span", { "data-state": discarded ? 'cancelled' : taskTone(task.state, task.status) }, task.id)) })) : _jsx("span", { className: css.progressEmpty }), _jsxs("span", { className: css.progressLegend, children: [_jsx("span", { "data-state": "running", children: t('progress.running', { count: running }) }), claimed > 0 && _jsx("span", { "data-state": "claimed", children: t('progress.claimed', { count: claimed }) }), _jsx("span", { "data-state": "blocked", children: t('progress.blocked', { count: blocked }) }), _jsx("span", { "data-state": "completed", children: t('progress.delivered', { count: completed }) })] }), _jsxs("span", { className: css.progressSummary, "data-state": summaryTone, children: [_jsx("span", { className: css.progressSummaryDot }), _jsx("span", { children: taskSummary(team, t, discarded) })] })] }));
235
+ }
236
+ /** Workspace-only summary of durable completion and the current unread inbox.
237
+ * The snapshot is not a chat transcript: it provides at most five unread
238
+ * captain messages, with no timestamps, so do not imply a complete history.
239
+ */
240
+ function WorkspaceSummary({ team, t, discarded }) {
241
+ const completed = discarded ? 0 : team.tasks.filter(task => task.status === 'completed').length;
242
+ const total = team.tasks.length;
243
+ return (_jsxs("div", { className: css.workspaceSummary, children: [_jsxs("section", { className: css.completionCard, "aria-label": t('progress.aria'), children: [_jsx("h3", { children: t('progress.title') }), _jsxs("div", { className: css.completionBody, children: [_jsxs("div", { className: css.completionRing, role: "img", "aria-label": t('team.stats.completed', { completed, total }), "data-completed": completed, "data-total": total, children: [_jsxs("svg", { viewBox: "0 0 120 120", "aria-hidden": true, children: [_jsx("circle", { className: css.ringTrack, cx: "60", cy: "60", r: "51" }), _jsx("circle", { className: css.ringValue, cx: "60", cy: "60", r: "51", pathLength: "100", strokeDasharray: `${total === 0 ? 0 : completed / total * 100} 100` })] }), _jsxs("span", { "aria-hidden": true, children: [_jsxs("strong", { children: [completed, _jsxs("small", { children: [" / ", total] })] }), _jsx("span", { children: t(discarded ? 'task.status.notRun' : 'workspace.completed') })] })] }), total === 0 ? _jsx("p", { className: css.summaryEmpty, children: t('workspace.noTasks') }) : _jsx("ul", { className: css.completionTasks, tabIndex: 0, "aria-label": t('workspace.taskSummary'), children: team.tasks.map(task => _jsxs("li", { "data-state": discarded ? 'cancelled' : taskTone(task.state, task.status), "data-verdict-stale": task.verdictStale === undefined ? undefined : 'true', title: taskTitle(task, taskModelLabel(task, team.members)), children: [_jsx("span", { className: css.completionDot, "aria-hidden": true, children: task.verdictStale !== undefined ? '!' : !discarded && task.status === 'completed' ? '✓' : '·' }), _jsx("span", { className: css.completionTaskId, children: task.id }), _jsx("span", { className: css.completionTaskSubject, title: task.subject, children: task.subject }), _jsx("span", { className: css.completionTaskStatus, children: discarded ? t('task.status.notRun') : task.verdictStale !== undefined ? t('workspace.verdictStale') : taskStatusLabel(task.status, t) })] }, task.id)) })] })] }), _jsxs("section", { className: css.inboxCard, "aria-label": t('workspace.inbox'), children: [_jsxs("header", { children: [_jsx("h3", { children: t('workspace.inbox') }), _jsx("span", { children: t('workspace.inboxHint') })] }), team.captainInbox.length === 0 ? _jsx("p", { className: css.summaryEmpty, children: t('workspace.inboxEmpty') }) : _jsx("ul", { className: css.inboxMessages, tabIndex: 0, "aria-label": t('workspace.inbox'), children: team.captainInbox.map((message, index) => {
244
+ const member = team.members.find(candidate => candidate.name === message.from);
245
+ const vendor = vendorSlug(member);
246
+ const art = message.from === CAPTAIN_ASSIGNEE
247
+ ? leadArtUrl(vendorSlug({ provider: team.captainProvider, model: team.captainModel }))
248
+ : resolveMemberArtwork({ name: message.from, role: member?.role ?? '', vendor }).url;
249
+ return _jsxs("li", { children: [art === null ? _jsx("span", { className: css.inboxInitial, "aria-hidden": true, children: memberInitial(message.from) }) : _jsx("img", { src: art, alt: "", "aria-hidden": true }), _jsxs("div", { children: [_jsx("strong", { children: message.from }), _jsx("p", { children: message.content })] })] }, `${index}:${message.from}`);
250
+ }) })] })] }));
231
251
  }
232
252
  function DependencyMap({ tasks, members, t, discarded = false, workspace = false, onSelectTask }) {
233
253
  const [open, setOpen] = useState(true);
@@ -274,6 +294,7 @@ function DependencyMap({ tasks, members, t, discarded = false, workspace = false
274
294
  return null;
275
295
  const fallbackTask = tasks.find((task) => task.state === 'blocked')
276
296
  ?? tasks.find((task) => task.state === 'running')
297
+ ?? tasks.find((task) => task.state === 'claimed')
277
298
  ?? tasks[0];
278
299
  const detailTask = tasks.find((task) => task.id === focusedTaskId) ?? fallbackTask;
279
300
  const detailModel = taskModelLabel(detailTask, members);
@@ -288,7 +309,7 @@ function DependencyMap({ tasks, members, t, discarded = false, workspace = false
288
309
  const model = taskModelLabel(task, members);
289
310
  return (_jsxs("button", { type: "button", className: css.dagNode, style: parallel
290
311
  ? { height: nodeHeight }
291
- : { left: x, top: y, width: nodeWidth, height: nodeHeight }, "data-task-id": task.id, "data-state": discarded ? 'cancelled' : taskTone(task.state, task.status), "data-verdict-stale": task.verdictStale === undefined ? undefined : 'true', "data-task-model": model || undefined, "data-focused": related?.has(task.id) ?? false, "data-dimmed": related !== null && !related.has(task.id), "aria-pressed": pinnedTaskId === task.id, title: taskTitle(task, model), onClick: () => { const next = pinnedTaskId === task.id ? null : task.id; setPinnedTaskId(next); onSelectTask?.(next); }, onMouseEnter: () => { scheduleHover(task.id); }, onMouseLeave: () => { scheduleHover(null); }, onFocus: () => { setKeyboardTaskId(task.id); }, onBlur: () => { setKeyboardTaskId(null); }, children: [_jsxs("span", { className: css.dagNodeHead, children: [_jsx("span", { className: css.dagNodeDot }), task.id, workspace && _jsx("span", { className: css.dagOwner, children: task.assignee || t('task.assignee.unclaimed') })] }), _jsx("span", { className: css.dagNodeLabel, children: workspace ? task.subject : compactTaskLabel(task.subject) }), task.state === 'running' && (_jsx("span", { className: css.dagRunningState, "aria-label": t('task.runningAria'), children: _jsx(WorkGlyph, { active: true }) }))] }, task.id));
312
+ : { left: x, top: y, width: nodeWidth, height: nodeHeight }, "data-task-id": task.id, "data-state": discarded ? 'cancelled' : taskTone(task.state, task.status), "data-verdict-stale": task.verdictStale === undefined ? undefined : 'true', "data-task-model": model || undefined, "data-focused": related?.has(task.id) ?? false, "data-dimmed": related !== null && !related.has(task.id), "aria-pressed": pinnedTaskId === task.id, title: taskTitle(task, model), onClick: () => { const next = pinnedTaskId === task.id ? null : task.id; setPinnedTaskId(next); onSelectTask?.(next); }, onMouseEnter: () => { scheduleHover(task.id); }, onMouseLeave: () => { scheduleHover(null); }, onFocus: () => { setKeyboardTaskId(task.id); }, onBlur: () => { setKeyboardTaskId(null); }, children: [_jsxs("span", { className: css.dagNodeHead, children: [_jsx("span", { className: css.dagNodeDot }), task.id, workspace && _jsx("span", { className: css.dagOwner, children: task.assignee || t('task.assignee.unclaimed') })] }), _jsx("span", { className: css.dagNodeLabel, children: workspace ? task.subject : compactTaskLabel(task.subject) }), !discarded && task.state === 'claimed' && _jsx("span", { className: css.dagClaimedState, children: t('task.status.claimed') }), task.state === 'running' && (_jsx("span", { className: css.dagRunningState, "aria-label": t('task.runningAria'), children: _jsx(WorkGlyph, { active: true }) }))] }, task.id));
292
313
  })] }) }), _jsxs("section", { className: css.taskDetail, "data-task-detail": detailTask.id, children: [_jsxs("span", { className: css.taskDetailHead, children: [_jsx("span", { className: css.taskDetailId, children: detailTask.id }), _jsx("span", { className: css.taskDetailSubject, title: detailTask.subject, children: detailTask.subject.replace(/^开发\s*/u, '') }), _jsx("span", { className: css.taskDetailBadge, "data-state": discarded ? 'cancelled' : taskTone(detailTask.state, detailTask.status), children: discarded ? t('task.status.notRun') : taskStatusLabel(detailTask.status, t) })] }), _jsxs("span", { className: css.taskDetailLine, children: [detailTask.assignee || t('task.assignee.unclaimed'), " \u00B7 ", discarded
293
314
  ? t('task.detail.notRun')
294
315
  : detailTask.status === 'completed'
@@ -464,7 +485,7 @@ export function TeamSection({ team, modelDirectory, onContinuePlanning, onDiscar
464
485
  return (_jsx("span", { className: css.assignmentChip, "data-state": discarded ? 'cancelled' : taskTone(task.state, task.status), "data-verdict-stale": task.verdictStale === undefined ? undefined : 'true', "data-task-model": model || undefined, title: taskTitle(task, model), children: task.state === 'running' && shortModel !== '' ? `${task.id} · ${shortModel}` : task.id }, task.id));
465
486
  }) })] })] }, member.id || member.name));
466
487
  })] })] }));
467
- })()] }), _jsx(DependencyMap, { tasks: team.tasks, members: team.members, t: t, discarded: discarded, workspace: workspace, onSelectTask: setSelectedTaskId })] }), _jsx(Modal, { open: stopOpen, onClose: () => { if (!stopping)
488
+ })()] }), _jsx(DependencyMap, { tasks: team.tasks, members: team.members, t: t, discarded: discarded, workspace: workspace, onSelectTask: setSelectedTaskId }), workspace && _jsx(WorkspaceSummary, { team: team, t: t, discarded: discarded })] }), _jsx(Modal, { open: stopOpen, onClose: () => { if (!stopping)
468
489
  setStopOpen(false); }, title: t('team.stopTitle', { team: team.name }), closeLabel: t('plan.cancel'), description: t('team.stopDescription', { tasks: unfinishedCount, members: busyCount }), footer: (_jsxs("span", { className: css.stopModalActions, children: [_jsx("button", { type: "button", disabled: stopping, onClick: () => { setStopOpen(false); }, children: t('team.stopCancel') }), _jsxs("button", { type: "button", "data-danger": true, disabled: stopping, onClick: () => { void stopTeam(); }, children: [_jsx(IconStopFill16, {}), stopping ? t('team.stopping') : t('team.stopConfirm')] })] })), children: stopError !== '' && _jsxs("p", { className: css.stopModalError, role: "alert", children: [_jsx(IconWarningOutline16, {}), stopError] }) }), artPreview !== null && (_jsx("div", { className: css.artPreview, "data-art-preview": true, role: "presentation", title: t('member.art.close'), onClick: () => { setArtPreview(null); }, children: _jsxs("figure", { className: css.artPreviewCard, children: [_jsx("img", { className: css.artPreviewImage, src: artPreview.url, alt: "" }), _jsx("figcaption", { className: css.artPreviewCaption, children: formatArtPreviewCaption({ name: artPreview.name, labelKey: artPreview.labelKey, kind: artPreview.kind, t }) })] }) }))] }));
469
490
  }
470
491
  /** Legacy conversation cards may outlive their host archive. Project their
@@ -4,8 +4,9 @@ import { useEffect, useMemo, useState, useSyncExternalStore } from 'react';
4
4
  import { ActivityPanel, TeamSection, historicCardTeam } from "./ActivityPanel.js";
5
5
  import { OPEN_PANEL_EVENT } from "./AgentTeamsCard.js";
6
6
  import { currentSessionId } from "./session-navigation.js";
7
- import { getActivityMonitorTargetsSnapshot, getActivitySnapshotsSnapshot, startActivityPolling, subscribeActivityMonitorTargets, subscribeActivitySnapshots, updateActivitySnapshots } from "./activity-monitor.js";
7
+ import { getActivityMonitorTargetsSnapshot, getActivitySnapshotsSnapshot, getPublishedActivityRows, startActivityPolling, subscribeActivityMonitorTargets, subscribeActivitySnapshots, updateActivitySnapshots } from "./activity-monitor.js";
8
8
  import { createTeamDiscovery } from "./workspace-state.js";
9
+ import { LEAD_ART } from "./artwork.js";
9
10
  import css from './WorkspaceActivity.module.css';
10
11
  export const TEAM_TAB_KIND = 'agent-teams';
11
12
  export const TEAM_TAB_ID = 'dsh-agent-teams-fish/activity';
@@ -36,11 +37,12 @@ function WorkspaceMonitor({ sessionsList, sidebar, state }) {
36
37
  state.status(current, 'loading');
37
38
  const controller = startActivityPolling(currentTargets, {
38
39
  discoverySessionId: current,
40
+ getPublishedRows: getPublishedActivityRows,
39
41
  onStatus(status) {
40
42
  state.status(current, status);
41
43
  },
42
- publishSnapshots(update) {
43
- updateActivitySnapshots(update);
44
+ publishSnapshots(update, scope) {
45
+ updateActivitySnapshots(update, scope);
44
46
  if (update.teams === undefined)
45
47
  return;
46
48
  const added = discover(update.teams.filter(team => team.captainSessionId === current));
@@ -96,5 +98,5 @@ export function WorkspaceActivity({ sessionId, useTabInfo, t, state, modelDirect
96
98
  tab.actions.close();
97
99
  requestAnimationFrame(() => document.querySelector('[data-composer-card] [contenteditable="true"][role="textbox"], [data-composer-card] textarea')?.focus());
98
100
  };
99
- return (_jsx("div", { className: css.root, "data-agent-teams-workspace": true, "data-session-id": sessionId, children: _jsxs("div", { className: css.content, children: [status === 'error' && _jsxs("div", { className: css.error, role: "alert", children: [_jsx("span", { children: t('workspace.error') }), _jsx("button", { onClick: () => setRetry(value => value + 1), children: t('workspace.retry') })] }), records.length > 1 && _jsx("nav", { className: css.selector, "aria-label": t('workspace.title'), children: records.map(team => _jsxs("button", { "aria-pressed": selected?.teamId === team.teamId, onClick: () => state.select(sessionId, team.teamId), children: [team.name, _jsx("span", { children: t(live.includes(team) ? 'workspace.current' : 'workspace.history') })] }, team.teamId)) }), selected === undefined ? status === 'loading' ? _jsxs("div", { className: css.skeleton, role: "status", "aria-label": t('workspace.loading'), children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }) : _jsxs("section", { className: css.empty, children: [_jsx("span", { className: css.emptyMark, "aria-hidden": true, children: "\u21B3" }), _jsx("h3", { children: t('workspace.emptyTitle') }), _jsx("p", { children: t('workspace.emptyBody') }), _jsx("button", { onClick: backToChat, children: t('workspace.back') })] }) : _jsx(_Fragment, { children: _jsx(TeamSection, { team: selected, workspace: true, historic: history, modelDirectory: selected.phase === 'staged' ? modelDirectories.directoryFor(sessionId) : undefined, onContinuePlanning: backToChat, onDiscarded: backToChat, onNavigate: openMember, t: t }, `${sessionId}:${selected.teamId}`) })] }) }));
101
+ return (_jsx("div", { className: css.root, "data-agent-teams-workspace": true, "data-session-id": sessionId, children: _jsxs("div", { className: css.content, children: [_jsxs("header", { className: css.heading, children: [_jsx("img", { src: LEAD_ART, alt: "", "aria-hidden": true }), _jsx("h2", { children: "AgentTeams" }), _jsx("span", { children: t('workspace.title') })] }), status === 'error' && _jsxs("div", { className: css.error, role: "alert", children: [_jsx("span", { children: t('workspace.error') }), _jsx("button", { onClick: () => setRetry(value => value + 1), children: t('workspace.retry') })] }), records.length > 1 && _jsx("nav", { className: css.selector, "aria-label": t('workspace.title'), children: records.map(team => _jsxs("button", { "aria-pressed": selected?.teamId === team.teamId, onClick: () => state.select(sessionId, team.teamId), children: [team.name, _jsx("span", { children: t(live.includes(team) ? 'workspace.current' : 'workspace.history') })] }, team.teamId)) }), selected === undefined ? status === 'loading' ? _jsxs("div", { className: css.skeleton, role: "status", "aria-label": t('workspace.loading'), children: [_jsx("i", {}), _jsx("i", {}), _jsx("i", {})] }) : _jsxs("section", { className: css.empty, children: [_jsx("span", { className: css.emptyMark, "aria-hidden": true, children: "\u21B3" }), _jsx("h3", { children: t('workspace.emptyTitle') }), _jsx("p", { children: t('workspace.emptyBody') }), _jsx("button", { onClick: backToChat, children: t('workspace.back') })] }) : _jsx(_Fragment, { children: _jsx(TeamSection, { team: selected, workspace: true, historic: history, modelDirectory: selected.phase === 'staged' ? modelDirectories.directoryFor(sessionId) : undefined, onContinuePlanning: backToChat, onDiscarded: backToChat, onNavigate: openMember, t: t }, `${sessionId}:${selected.teamId}`) })] }) }));
100
102
  }
@@ -4,6 +4,13 @@ const targetListeners = new Set();
4
4
  const snapshotListeners = new Set();
5
5
  let targetSnapshot = [];
6
6
  let activitySnapshots = { teams: [], archivedTeams: [] };
7
+ // Keep recent successful visits during reconnects without retaining every
8
+ // conversation's activity and full archive for the life of the tab.
9
+ const MAX_RETAINED_SCOPES = 8;
10
+ const scopedSnapshots = {
11
+ teams: new Map(),
12
+ archivedTeams: new Map(),
13
+ };
7
14
  function targetKey(sessionId, teamId) {
8
15
  return `${sessionId}\u0000${teamId}`;
9
16
  }
@@ -85,11 +92,35 @@ export function subscribeActivitySnapshots(listener) {
85
92
  export function getActivitySnapshotsSnapshot() {
86
93
  return activitySnapshots;
87
94
  }
88
- /** Publish one or both successful state-route responses. */
89
- export function updateActivitySnapshots(update) {
95
+ /** Read the rows owned by one route and optional scope for ETag comparison. */
96
+ export function getPublishedActivityRows(field, scope) {
97
+ return scope === undefined ? activitySnapshots[field] : scopedSnapshots[field].get(scope);
98
+ }
99
+ function replaceActivityRows(field, rows, scope) {
100
+ const current = activitySnapshots[field];
101
+ if (rows === undefined)
102
+ return current;
103
+ const recent = scopedSnapshots[field];
104
+ if (scope === undefined) {
105
+ recent.clear();
106
+ return rows;
107
+ }
108
+ const previous = recent.get(scope);
109
+ recent.delete(scope);
110
+ recent.set(scope, rows);
111
+ const oldest = recent.size > MAX_RETAINED_SCOPES ? recent.keys().next().value : undefined;
112
+ if (oldest !== undefined)
113
+ recent.delete(oldest);
114
+ if (previous === rows)
115
+ return current;
116
+ const otherRows = current.filter(team => team.captainSessionId !== scope && team.captainSessionId !== oldest);
117
+ return otherRows.length === current.length && rows.length === 0 ? current : [...otherRows, ...rows];
118
+ }
119
+ /** Publish full state-route responses or replace the rows for just one captain. */
120
+ export function updateActivitySnapshots(update, scope) {
90
121
  const next = {
91
- teams: update.teams ?? activitySnapshots.teams,
92
- archivedTeams: update.archivedTeams ?? activitySnapshots.archivedTeams,
122
+ teams: replaceActivityRows('teams', update.teams, scope),
123
+ archivedTeams: replaceActivityRows('archivedTeams', update.archivedTeams, scope),
93
124
  };
94
125
  if (next.teams === activitySnapshots.teams && next.archivedTeams === activitySnapshots.archivedTeams)
95
126
  return;
@@ -109,6 +140,17 @@ export const ACTIVITY_PROBE_MS = 5000;
109
140
  /** Host route serving live and archived team snapshots. */
110
141
  export const ACTIVITY_STATE_URL = '/plugins/dsh-agent-teams/state';
111
142
  export const ACTIVITY_HALT_URL = '/plugins/dsh-agent-teams/halt';
143
+ async function readActivityTeams(response, scope) {
144
+ if (!response.ok)
145
+ throw new Error('Activity unavailable');
146
+ const body = (await response.json());
147
+ if (!Array.isArray(body?.teams) || body.teams.some(team => typeof team?.teamId !== 'string' || typeof team?.captainSessionId !== 'string')) {
148
+ throw new Error('Invalid activity response');
149
+ }
150
+ const teams = body.teams;
151
+ // Older hosts can ignore the query and send every team's row.
152
+ return scope === undefined ? teams : teams.filter(team => team.captainSessionId === scope);
153
+ }
112
154
  /**
113
155
  * Start the single polling loop for the current session's requested targets.
114
156
  *
@@ -134,14 +176,32 @@ export function startActivityPolling(monitorTargets, runtime = {}) {
134
176
  const schedule = runtime.schedule ?? ((callback, intervalMs) => setInterval(callback, intervalMs));
135
177
  const cancel = runtime.cancel ?? ((timer) => { clearInterval(timer); });
136
178
  const publishSnapshots = runtime.publishSnapshots ?? updateActivitySnapshots;
179
+ const getPublishedRows = runtime.getPublishedRows
180
+ ?? (runtime.publishSnapshots === undefined ? getPublishedActivityRows : undefined);
137
181
  const settleTargets = runtime.settleTargets ?? settleActivityMonitorTargets;
182
+ const owners = new Set(monitorTargets.map(target => target.sessionId));
183
+ if (discoverySessionId)
184
+ owners.add(discoverySessionId);
185
+ const scope = owners.size === 1 ? owners.values().next().value : undefined;
186
+ const sessionQuery = scope ? new URLSearchParams({ session: scope }).toString() : '';
187
+ const liveUrl = sessionQuery === '' ? ACTIVITY_STATE_URL : `${ACTIVITY_STATE_URL}?${sessionQuery}&summary=1`;
188
+ const archiveUrl = `${ACTIVITY_STATE_URL}?archived=1${sessionQuery === '' ? '' : `&${sessionQuery}`}`;
189
+ const conditionalHeaders = (tag) => tag === undefined ? {} : { headers: { 'if-none-match': tag } };
190
+ // A manual retry can publish to the same store. A 304 only validates the
191
+ // body this controller applied, so send its tag while that body is shown.
192
+ const stillPublished = (field, snapshot) => getPublishedRows === undefined || getPublishedRows(field, scope) === snapshot?.teams;
138
193
  let cancelled = false;
139
194
  let inFlight = false;
140
195
  // Explicit card targets are demanded work: start at the live cadence. A
141
196
  // discovery session starts probing low-frequency and upgrades on detection.
142
197
  let hot = monitorTargets.length > 0;
143
- let discoveryComplete = false;
144
198
  let discoveredLiveKeys = new Set();
199
+ // Archive work stays pending after a failed request, even when the next live
200
+ // request is a 304 and does not publish or recompute the live snapshot.
201
+ let archiveRefreshPending = Boolean(discoverySessionId);
202
+ let missingTargets = new Set();
203
+ let publishedLive;
204
+ let publishedArchive;
145
205
  let controller;
146
206
  let timer;
147
207
  const intervalMs = () => (hot ? ACTIVITY_POLL_MS : ACTIVITY_PROBE_MS);
@@ -155,59 +215,71 @@ export function startActivityPolling(monitorTargets, runtime = {}) {
155
215
  inFlight = true;
156
216
  controller = new AbortController();
157
217
  try {
158
- const liveResponse = await fetchState(ACTIVITY_STATE_URL, {
218
+ const liveTag = stillPublished('teams', publishedLive) ? publishedLive?.tag : undefined;
219
+ const liveResponse = await fetchState(liveUrl, {
159
220
  cache: 'no-store',
160
221
  signal: controller.signal,
222
+ ...conditionalHeaders(liveTag),
161
223
  });
162
- if (!liveResponse.ok)
163
- throw new Error('Activity unavailable');
164
- const body = (await liveResponse.json());
165
224
  if (cancelled)
166
225
  return;
167
- if (!Array.isArray(body.teams))
168
- throw new Error('Invalid activity response');
169
- runtime.onStatus?.('ready');
170
- const liveTeams = body.teams;
171
- publishSnapshots({ teams: liveTeams });
172
- const previousDiscoveredKeys = discoveredLiveKeys;
173
- discoveredLiveKeys = new Set(discoverySessionId === undefined || discoverySessionId === ''
174
- ? []
175
- : liveTeams
176
- .filter((team) => team.captainSessionId === discoverySessionId)
177
- .map((team) => team.teamId));
178
- // A discovery session found its first team: upgrade from the low-frequency
179
- // probe to the live cadence for the rest of the controller lifetime.
180
- if (!hot && discoveredLiveKeys.size > 0) {
181
- hot = true;
182
- reschedule();
226
+ if (liveResponse.status !== 304 || liveTag === undefined) {
227
+ const liveTeams = await readActivityTeams(liveResponse, scope);
228
+ if (cancelled)
229
+ return;
230
+ publishSnapshots({ teams: liveTeams }, scope);
231
+ if (cancelled)
232
+ return;
233
+ publishedLive = { teams: liveTeams, tag: liveResponse.headers?.get('etag') ?? undefined };
234
+ const previousDiscoveredKeys = discoveredLiveKeys;
235
+ discoveredLiveKeys = new Set(discoverySessionId
236
+ ? liveTeams.filter(team => team.captainSessionId === discoverySessionId).map(team => team.teamId)
237
+ : []);
238
+ archiveRefreshPending ||= [...previousDiscoveredKeys].some(teamId => !discoveredLiveKeys.has(teamId));
239
+ missingTargets = new Set(monitorTargets.filter(target => !liveTeams.some(team => team.captainSessionId === target.sessionId && team.teamId === target.teamId)).map(target => target.key));
240
+ // A discovery session found its first team: keep the live cadence.
241
+ if (!hot && discoveredLiveKeys.size > 0) {
242
+ hot = true;
243
+ reschedule();
244
+ }
183
245
  }
184
- const discoveredTeamArchived = [...previousDiscoveredKeys]
185
- .some((teamId) => !discoveredLiveKeys.has(teamId));
186
- const missing = monitorTargets.filter((target) => !liveTeams.some((team) => team.captainSessionId === target.sessionId && team.teamId === target.teamId));
187
- const needsDiscoveryArchive = discoverySessionId !== undefined
188
- && discoverySessionId !== ''
189
- && !discoveryComplete;
190
- if (missing.length === 0 && !needsDiscoveryArchive && !discoveredTeamArchived)
246
+ else if (!stillPublished('teams', publishedLive)) {
247
+ // A concurrent write landed while the conditional request was in flight.
248
+ return;
249
+ }
250
+ runtime.onStatus?.('ready');
251
+ const archiveReplaced = publishedArchive !== undefined && !stillPublished('archivedTeams', publishedArchive);
252
+ if (cancelled || (missingTargets.size === 0 && !archiveRefreshPending && !archiveReplaced))
191
253
  return;
192
254
  // Archives are immutable per team generation. A successful fallback
193
255
  // retires every missing explicit target, including legacy cards whose
194
256
  // host archive no longer exists; a discovery session that already
195
257
  // upgraded keeps polling, and a still-probing one keeps probing, so a
196
258
  // team created later in the same session stays discoverable.
197
- const archivedResponse = await fetchState(`${ACTIVITY_STATE_URL}?archived=1`, {
259
+ const archiveTag = archiveReplaced ? undefined : publishedArchive?.tag;
260
+ const archivedResponse = await fetchState(archiveUrl, {
198
261
  cache: 'no-store',
199
262
  signal: controller.signal,
263
+ ...conditionalHeaders(archiveTag),
200
264
  });
201
- if (!archivedResponse.ok)
202
- throw new Error('Archive unavailable');
203
- const archivedBody = (await archivedResponse.json());
204
265
  if (cancelled)
205
266
  return;
206
- if (!Array.isArray(archivedBody.teams))
207
- throw new Error('Invalid archive response');
208
- publishSnapshots({ archivedTeams: archivedBody.teams });
209
- discoveryComplete = true;
210
- settleTargets(new Set(missing.map((target) => target.key)));
267
+ if (archivedResponse.status !== 304 || archiveTag === undefined) {
268
+ const archivedTeams = await readActivityTeams(archivedResponse, scope);
269
+ if (cancelled)
270
+ return;
271
+ publishSnapshots({ archivedTeams }, scope);
272
+ if (cancelled)
273
+ return;
274
+ publishedArchive = { teams: archivedTeams, tag: archivedResponse.headers?.get('etag') ?? undefined };
275
+ }
276
+ else if (!stillPublished('archivedTeams', publishedArchive)) {
277
+ return;
278
+ }
279
+ archiveRefreshPending = false;
280
+ const settled = missingTargets;
281
+ missingTargets = new Set();
282
+ settleTargets(settled);
211
283
  }
212
284
  catch (error) {
213
285
  if (error?.name === 'AbortError')
@@ -22,6 +22,11 @@ export const zh = {
22
22
  'workspace.completed': '已完成',
23
23
  'workspace.focus': '查看团队',
24
24
  'workspace.noTasks': '等待队长拆解任务',
25
+ 'workspace.inbox': '队长收件箱',
26
+ 'workspace.inboxHint': '最近 5 条未读消息',
27
+ 'workspace.inboxEmpty': '暂无未读消息。成员回报会在这里显示,队长读取后移出。',
28
+ 'workspace.taskSummary': '任务完成情况',
29
+ 'workspace.verdictStale': '结论已过期',
25
30
  'card.memberCount': '{count} 名成员',
26
31
  'action.openActivityPanel': '打开活动面板',
27
32
  'activity.panelButton': '活动面板',
@@ -83,6 +88,7 @@ export const zh = {
83
88
  'task.summary.blockedAndRunning': '{tasks}{more} 等待前置,其余已开工',
84
89
  'task.summary.more': ' 等 {count} 项',
85
90
  'task.summary.running': '{tasks} 正在执行',
91
+ 'task.summary.claimed': '已认领:{tasks}',
86
92
  'task.summary.ready': '{tasks} 已就绪待开工',
87
93
  'task.summary.blocked': '{tasks} 等待前置',
88
94
  'task.summary.failedSettled': '{count} 项已失败,自动循环已停止',
@@ -90,6 +96,7 @@ export const zh = {
90
96
  'progress.aria': '团队总进度',
91
97
  'progress.title': '总进度',
92
98
  'progress.running': '■ 进行中 {count}',
99
+ 'progress.claimed': '■ 已认领 {count}',
93
100
  'progress.blocked': '■ 等待依赖 {count}',
94
101
  'progress.delivered': '■ 已交付 {count}',
95
102
  'dependency.aria': '任务依赖链',
@@ -247,6 +254,11 @@ export const en = {
247
254
  'workspace.completed': 'completed',
248
255
  'workspace.focus': 'View team',
249
256
  'workspace.noTasks': 'Waiting for the captain to define tasks',
257
+ 'workspace.inbox': 'Captain inbox',
258
+ 'workspace.inboxHint': 'Up to 5 recent unread messages',
259
+ 'workspace.inboxEmpty': 'No unread messages. Member reports appear here until the captain reads them.',
260
+ 'workspace.taskSummary': 'Task completion summary',
261
+ 'workspace.verdictStale': 'Verdict outdated',
250
262
  'card.memberCount': '{count} members',
251
263
  'action.openActivityPanel': 'Open activity panel',
252
264
  'activity.panelButton': 'Activity panel',
@@ -308,6 +320,7 @@ export const en = {
308
320
  'task.summary.blockedAndRunning': '{tasks}{more} waiting on prerequisites; other work has started',
309
321
  'task.summary.more': ' and {count} more',
310
322
  'task.summary.running': '{tasks} in progress',
323
+ 'task.summary.claimed': 'Claimed: {tasks}',
311
324
  'task.summary.ready': '{tasks} ready to start',
312
325
  'task.summary.blocked': '{tasks} waiting on prerequisites',
313
326
  'task.summary.failedSettled': '{count} failed; the automatic loop has stopped',
@@ -315,6 +328,7 @@ export const en = {
315
328
  'progress.aria': 'Overall team progress',
316
329
  'progress.title': 'Overall progress',
317
330
  'progress.running': '■ In progress {count}',
331
+ 'progress.claimed': '■ Claimed {count}',
318
332
  'progress.blocked': '■ Waiting {count}',
319
333
  'progress.delivered': '■ Delivered {count}',
320
334
  'dependency.aria': 'Task dependency chain',