arco-workbench 0.1.6 → 0.1.8

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 (236) hide show
  1. package/CONTRIBUTING.md +52 -12
  2. package/README.md +20 -13
  3. package/client/dist/assets/{PhosphorBackdrop-BR-TgB5x.js → PhosphorBackdrop-D7jdAV_G.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-DgcFj6JN.js → ThemedBackgroundShaderImpl-DrDm60h8.js} +1 -1
  5. package/client/dist/assets/{XtermView-CflVBQgC.js → XtermView-BGFujb1e.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-BB-emfmi.js → galleryEditor-D951A2sE.js} +1 -1
  7. package/client/dist/assets/{index-B_EqHDz3.js → index-CsVy3eZm.js} +248 -248
  8. package/client/dist/index.html +1 -1
  9. package/client/src/buildCheck.ts +3 -1
  10. package/client/src/components/AppUpdateNotice.tsx +2 -1
  11. package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +24 -12
  12. package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +65 -15
  13. package/client/src/components/ClusterRightPanel/SkillsControl.tsx +107 -0
  14. package/client/src/components/ClusterRightPanel/index.tsx +6 -1
  15. package/client/src/components/ClusterTaskBoardTab.tsx +9 -22
  16. package/client/src/components/HeaderVersionBox.tsx +7 -4
  17. package/client/src/components/NeedsYouBadge.tsx +3 -3
  18. package/client/src/components/ProviderReleasesModal.tsx +8 -4
  19. package/client/src/components/ProvidersPopover.tsx +28 -23
  20. package/client/src/components/SettingsPanel.tsx +2 -2
  21. package/client/src/components/SkillsSettings.tsx +5 -0
  22. package/client/src/components/TabBar.tsx +91 -9
  23. package/client/src/components/TerminalInput.tsx +12 -10
  24. package/client/src/components/TranscriptSendDialog.tsx +12 -8
  25. package/client/src/components/TranscriptWorkerDialog.tsx +119 -0
  26. package/client/src/components/UpdateAction.tsx +18 -4
  27. package/client/src/components/UpdateResultNotice.tsx +3 -1
  28. package/client/src/components/clusterNeedsYou.ts +11 -18
  29. package/client/src/help/content/cluster.tsx +54 -22
  30. package/client/src/help/content/composer.tsx +22 -0
  31. package/client/src/help/content/header.tsx +19 -1
  32. package/client/src/help/content/misc.tsx +8 -0
  33. package/client/src/help/content/rightPanel.tsx +1 -1
  34. package/client/src/help/content/settings.tsx +19 -5
  35. package/client/src/help/content/tabbar.tsx +5 -0
  36. package/client/src/help/manualSections/actions.tsx +31 -0
  37. package/client/src/help/manualSections/clusters.tsx +58 -21
  38. package/client/src/help/manualSections/configuration.tsx +38 -4
  39. package/client/src/help/manualSections/maintenance.tsx +30 -0
  40. package/client/src/help/manualSections/plans.tsx +5 -1
  41. package/client/src/help/manualSections/providers.tsx +32 -8
  42. package/client/src/help/manualSections/troubleshooting.tsx +2 -1
  43. package/client/src/help/manualSections/workflows.tsx +19 -0
  44. package/client/src/help/manualSections/workspace.tsx +6 -0
  45. package/client/src/stores/appUpdateStore.ts +29 -8
  46. package/client/src/utils/transcriptWorkerRequest.ts +24 -0
  47. package/client/src/utils/wsSession.ts +2 -1
  48. package/client/src/ws/handleServerMessage.ts +8 -2
  49. package/docs/ARCHITECTURE.md +1 -1
  50. package/docs/CLIENT.md +9 -8
  51. package/docs/FEATURES.md +8 -5
  52. package/docs/GETTING_STARTED.md +9 -4
  53. package/docs/GOTCHAS.md +2 -1
  54. package/docs/OPERATIONS.md +37 -4
  55. package/docs/PERSISTENCE.md +25 -3
  56. package/docs/PRIMITIVES.md +42 -0
  57. package/docs/PROTOCOL_CLUSTER.md +51 -5
  58. package/docs/PROTOCOL_PRIMITIVES.md +39 -0
  59. package/docs/PROVIDERS.md +50 -13
  60. package/docs/SETTINGS.md +27 -3
  61. package/docs/TASK_LEDGER.md +7 -15
  62. package/node_modules/@arco/shared/dist/clusterCoordination.d.ts +2 -0
  63. package/node_modules/@arco/shared/dist/clusterCoordination.js +5 -1
  64. package/node_modules/@arco/shared/dist/protocol/autoPickup.d.ts +3 -0
  65. package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +3 -2
  66. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +13 -1
  67. package/node_modules/@arco/shared/dist/protocol/index.d.ts +1 -0
  68. package/node_modules/@arco/shared/dist/protocol/index.js +1 -0
  69. package/node_modules/@arco/shared/dist/protocol/models.d.ts +4 -3
  70. package/node_modules/@arco/shared/dist/protocol/models.js +26 -2
  71. package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +2 -1
  72. package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +4 -0
  73. package/node_modules/@arco/shared/dist/protocol/transcriptWorker.d.ts +47 -0
  74. package/node_modules/@arco/shared/dist/protocol/transcriptWorker.js +2 -0
  75. package/node_modules/@arco/shared/dist/runtimeVersions.d.ts +1 -0
  76. package/node_modules/@arco/shared/dist/runtimeVersions.js +14 -0
  77. package/node_modules/@arco/shared/package.json +1 -1
  78. package/package.json +2 -2
  79. package/scripts/packaging/arco.mjs +1 -1
  80. package/scripts/packaging/native-repair.mjs +78 -12
  81. package/scripts/packaging/update.mjs +5 -1
  82. package/server/dist/atomicFile.js +1 -2
  83. package/server/dist/capabilities.d.ts +5 -2
  84. package/server/dist/capabilities.js +59 -9
  85. package/server/dist/cliUpdateDecision.d.ts +1 -1
  86. package/server/dist/cliUpdateDecision.js +5 -3
  87. package/server/dist/clusterAutoTurn.d.ts +4 -0
  88. package/server/dist/clusterAutoTurn.js +29 -25
  89. package/server/dist/clusterBusyReminder.js +1 -1
  90. package/server/dist/clusterDirector.js +1 -1
  91. package/server/dist/clusterPeerOps.js +10 -7
  92. package/server/dist/clusterProgress.js +1 -1
  93. package/server/dist/clusterSkills.d.ts +13 -0
  94. package/server/dist/clusterSkills.js +81 -0
  95. package/server/dist/clusterSnapshots.js +2 -0
  96. package/server/dist/clusterStore.d.ts +10 -2
  97. package/server/dist/clusterStore.js +64 -1
  98. package/server/dist/diagnostics/codeSkew.js +1 -0
  99. package/server/dist/eventLog.d.ts +7 -0
  100. package/server/dist/eventLog.js +70 -13
  101. package/server/dist/historyLimits.d.ts +1 -0
  102. package/server/dist/historyLimits.js +3 -0
  103. package/server/dist/http/router.js +1 -1
  104. package/server/dist/index.js +24 -1
  105. package/server/dist/jsonlLines.d.ts +4 -0
  106. package/server/dist/jsonlLines.js +53 -0
  107. package/server/dist/management/identity.js +1 -0
  108. package/server/dist/mcp/clusterMcpTools.js +4 -4
  109. package/server/dist/project/taskLedger.d.ts +4 -0
  110. package/server/dist/project/taskLedger.js +7 -4
  111. package/server/dist/providerConversation.d.ts +1 -0
  112. package/server/dist/providerConversation.js +17 -0
  113. package/server/dist/providers/claude-native/resumeSummary.d.ts +9 -0
  114. package/server/dist/providers/claude-native/resumeSummary.js +102 -49
  115. package/server/dist/providers/claude-native/worker.js +8 -4
  116. package/server/dist/providers/claude.js +2 -1
  117. package/server/dist/providers/clusterTaskToolDefinitions.js +4 -4
  118. package/server/dist/providers/codex-appserver/catalog.js +16 -1
  119. package/server/dist/providers/codex.js +2 -1
  120. package/server/dist/providers/codexCodeMode.d.ts +1 -1
  121. package/server/dist/providers/codexCodeMode.js +4 -3
  122. package/server/dist/providers/cursor/print.js +2 -1
  123. package/server/dist/providers/cursor/worker.js +2 -1
  124. package/server/dist/providers/llamacpp.js +17 -8
  125. package/server/dist/providers/ollamaRecovery.js +6 -6
  126. package/server/dist/providers/ollamaResilience.js +3 -3
  127. package/server/dist/providers/ollamaTokens.js +1 -1
  128. package/server/dist/quota.d.ts +0 -18
  129. package/server/dist/quota.js +0 -44
  130. package/server/dist/replacementHistory.d.ts +19 -0
  131. package/server/dist/replacementHistory.js +49 -0
  132. package/server/dist/server/broadcast.d.ts +2 -1
  133. package/server/dist/server/broadcast.js +1 -0
  134. package/server/dist/server/prompts.d.ts +1 -0
  135. package/server/dist/server/prompts.js +6 -1
  136. package/server/dist/sessionJsonl.d.ts +1 -1
  137. package/server/dist/sessionJsonl.js +115 -40
  138. package/server/dist/smartPickup.d.ts +2 -1
  139. package/server/dist/smartPickup.js +28 -1
  140. package/server/dist/smartPickupAdapters.js +15 -2
  141. package/server/dist/smartPickupLedger.js +6 -4
  142. package/server/dist/smartPickupObserver.d.ts +1 -0
  143. package/server/dist/smartPickupObserver.js +24 -15
  144. package/server/dist/transcriptWorker.d.ts +34 -0
  145. package/server/dist/transcriptWorker.js +201 -0
  146. package/server/dist/workflowStore.d.ts +1 -0
  147. package/server/dist/workflowStore.js +31 -0
  148. package/server/dist/ws/clusterHandlers.d.ts +2 -0
  149. package/server/dist/ws/clusterHandlers.js +64 -27
  150. package/server/dist/ws/handoffHandlers.js +5 -2
  151. package/server/dist/ws/transcriptWorkerHandlers.d.ts +25 -0
  152. package/server/dist/ws/transcriptWorkerHandlers.js +139 -0
  153. package/server/dist/ws/turnEngine.js +23 -9
  154. package/server/dist/ws/updatePrimaryConfig.js +27 -8
  155. package/server/dist/ws/workflowHandlers.d.ts +4 -1
  156. package/server/dist/ws/workflowHandlers.js +3 -1
  157. package/server/package.json +1 -1
  158. package/server/src/atomicFile.ts +1 -2
  159. package/server/src/capabilities.ts +58 -17
  160. package/server/src/cliUpdateDecision.ts +5 -4
  161. package/server/src/clusterAutoTurn.ts +26 -21
  162. package/server/src/clusterBusyReminder.ts +1 -1
  163. package/server/src/clusterDirector.ts +1 -1
  164. package/server/src/clusterPeerOps.ts +11 -8
  165. package/server/src/clusterProgress.ts +1 -1
  166. package/server/src/clusterSkills.ts +79 -0
  167. package/server/src/clusterSnapshots.ts +1 -0
  168. package/server/src/clusterStore.ts +64 -1
  169. package/server/src/diagnostics/codeSkew.ts +1 -0
  170. package/server/src/eventLog.ts +73 -13
  171. package/server/src/historyLimits.ts +2 -0
  172. package/server/src/http/router.ts +1 -1
  173. package/server/src/index.ts +23 -0
  174. package/server/src/jsonlLines.ts +52 -0
  175. package/server/src/management/identity.ts +1 -0
  176. package/server/src/mcp/clusterMcpTools.ts +4 -4
  177. package/server/src/project/taskLedger.ts +7 -5
  178. package/server/src/providerConversation.ts +15 -0
  179. package/server/src/providers/claude-native/resumeSummary.ts +98 -50
  180. package/server/src/providers/claude-native/worker.ts +8 -4
  181. package/server/src/providers/claude.ts +2 -1
  182. package/server/src/providers/clusterTaskToolDefinitions.ts +4 -4
  183. package/server/src/providers/codex-appserver/catalog.ts +14 -1
  184. package/server/src/providers/codex.ts +2 -1
  185. package/server/src/providers/codexCodeMode.ts +4 -4
  186. package/server/src/providers/cursor/print.ts +2 -1
  187. package/server/src/providers/cursor/worker.ts +2 -1
  188. package/server/src/providers/llamacpp.ts +18 -7
  189. package/server/src/providers/llamacppRecovery.ts +2 -0
  190. package/server/src/providers/ollamaRecovery.ts +6 -6
  191. package/server/src/providers/ollamaResilience.ts +3 -3
  192. package/server/src/providers/ollamaTokens.ts +1 -1
  193. package/server/src/providers/ollamaToolSubset.ts +3 -3
  194. package/server/src/quota.ts +0 -50
  195. package/server/src/replacementHistory.ts +44 -0
  196. package/server/src/server/broadcast.ts +2 -0
  197. package/server/src/server/prompts.ts +8 -1
  198. package/server/src/sessionJsonl.ts +92 -32
  199. package/server/src/smartPickup.ts +27 -3
  200. package/server/src/smartPickupAdapters.ts +17 -3
  201. package/server/src/smartPickupLedger.ts +6 -4
  202. package/server/src/smartPickupObserver.ts +20 -11
  203. package/server/src/transcriptWorker.ts +182 -0
  204. package/server/src/workflowStore.ts +21 -0
  205. package/server/src/ws/clusterHandlers.ts +46 -27
  206. package/server/src/ws/handoffHandlers.ts +5 -1
  207. package/server/src/ws/transcriptWorkerHandlers.ts +126 -0
  208. package/server/src/ws/turnEngine.ts +20 -8
  209. package/server/src/ws/updatePrimaryConfig.ts +25 -6
  210. package/server/src/ws/workflowHandlers.ts +3 -1
  211. package/shared/dist/clusterCoordination.d.ts +2 -0
  212. package/shared/dist/clusterCoordination.js +5 -1
  213. package/shared/dist/protocol/autoPickup.d.ts +3 -0
  214. package/shared/dist/protocol/clientMessages.d.ts +3 -2
  215. package/shared/dist/protocol/clusters.d.ts +13 -1
  216. package/shared/dist/protocol/index.d.ts +1 -0
  217. package/shared/dist/protocol/index.js +1 -0
  218. package/shared/dist/protocol/models.d.ts +4 -3
  219. package/shared/dist/protocol/models.js +26 -2
  220. package/shared/dist/protocol/serverMessages.d.ts +2 -1
  221. package/shared/dist/protocol/tasks.d.ts +4 -0
  222. package/shared/dist/protocol/transcriptWorker.d.ts +47 -0
  223. package/shared/dist/protocol/transcriptWorker.js +2 -0
  224. package/shared/dist/runtimeVersions.d.ts +1 -0
  225. package/shared/dist/runtimeVersions.js +14 -0
  226. package/shared/src/clusterCoordination.ts +7 -1
  227. package/shared/src/protocol/autoPickup.ts +5 -0
  228. package/shared/src/protocol/clientMessages.ts +5 -0
  229. package/shared/src/protocol/clusters.ts +16 -1
  230. package/shared/src/protocol/index.ts +1 -0
  231. package/shared/src/protocol/models.ts +31 -5
  232. package/shared/src/protocol/serverMessages.ts +2 -0
  233. package/shared/src/protocol/settings.ts +2 -3
  234. package/shared/src/protocol/tasks.ts +4 -7
  235. package/shared/src/protocol/transcriptWorker.ts +49 -0
  236. package/shared/src/runtimeVersions.ts +14 -0
@@ -0,0 +1,79 @@
1
+ import { normalizeClusterRoleText, type ArcoSkillRef, type ClusterSkillPin } from '@arco/shared';
2
+ import { ClusterValidationError, MEMBER_ROLE_MAX, getClusterIdForWorkflow, readCluster, type ClusterState } from './clusterStore.js';
3
+ import { MAX_PINNED_SKILLS, isValidSlug, resolvePinnedSkills } from './skills.js';
4
+ import { workflows } from './server/state.js';
5
+ import { readMeta } from './workflowMeta.js';
6
+
7
+ const key = (ref: ArcoSkillRef) => `${ref.scope}:${ref.slug}`;
8
+ const pinKey = (pin: ClusterSkillPin) => JSON.stringify([pin.scope, pin.slug, pin.role ?? null]);
9
+ export function uniqueSkillRefs(refs: ArcoSkillRef[]): ArcoSkillRef[] {
10
+ return [...new Map(refs.map(ref => [key(ref), { scope: ref.scope, slug: ref.slug }])).values()];
11
+ }
12
+
13
+ export function parseClusterSkillPins(value: unknown): ClusterSkillPin[] {
14
+ if (!Array.isArray(value)) throw new ClusterValidationError('skill_pins', 'Skills must be a list.');
15
+ const pins: ClusterSkillPin[] = value.map(pin => {
16
+ if (!pin || (pin.scope !== 'project' && pin.scope !== 'global') || !isValidSlug(pin.slug)
17
+ || (pin.role !== undefined && (typeof pin.role !== 'string' || !pin.role.trim() || pin.role.trim().length > MEMBER_ROLE_MAX))) {
18
+ throw new ClusterValidationError('skill_pins', 'Choose an installed project/global skill and a saved role of at most 120 characters.');
19
+ }
20
+ return { scope: pin.scope, slug: pin.slug, ...(pin.role !== undefined ? { role: pin.role.trim() } : {}) };
21
+ });
22
+ return [...new Map(pins.map(pin => [pinKey(pin), pin])).values()];
23
+ }
24
+
25
+ export function skillRefsForRole(state: Pick<ClusterState, 'skillPins'>, role: string | undefined, own: ArcoSkillRef[] = []): ArcoSkillRef[] {
26
+ const savedRole = role ? normalizeClusterRoleText(role) : undefined;
27
+ return uniqueSkillRefs([
28
+ ...(state.skillPins ?? []).filter(pin => pin.role === undefined),
29
+ ...(state.skillPins ?? []).filter(pin => pin.role !== undefined && pin.role === savedRole),
30
+ ...own,
31
+ ]);
32
+ }
33
+
34
+ export async function assertSkillUnion(state: Pick<ClusterState, 'skillPins' | 'cwd'>, role: string | undefined, own: ArcoSkillRef[], label: string): Promise<void> {
35
+ const refs = skillRefsForRole(state, role, own);
36
+ if (refs.length > MAX_PINNED_SKILLS) throw new ClusterValidationError('skill_limit', `${label}: tab, cluster and role pins together exceed 12 unique skills.`);
37
+ const resolved = await resolvePinnedSkills(refs, state.cwd);
38
+ if (resolved.truncated.length) throw new ClusterValidationError('skill_limit', `${label}: tab, cluster and role pins together exceed 64 KiB of skill text.`);
39
+ }
40
+
41
+ export async function assertClusterSkillLimits(state: ClusterState): Promise<void> {
42
+ // Check role targets even when no current member has that role. New workers
43
+ // must inherit a usable set rather than discovering an over-limit role later.
44
+ const roles = new Set([undefined, ...(state.skillPins ?? []).map(pin => pin.role)]);
45
+ for (const role of roles) await assertSkillUnion(state, role, [], role ? `Role ${role}` : 'All members');
46
+ for (const id of state.members) {
47
+ const wf = workflows.get(id);
48
+ const own = wf?.config.pinnedSkills ?? (await readMeta(state.cwd, id).catch(() => null))?.pinnedSkills ?? [];
49
+ await assertSkillUnion(state, state.memberRoles?.[id], own, wf?.config.name ?? `Member ${id.slice(0, 8)}`);
50
+ }
51
+ }
52
+
53
+ export async function validateNewClusterPins(state: ClusterState, pins: ClusterSkillPin[]): Promise<void> {
54
+ const previous = new Set((state.skillPins ?? []).map(pinKey));
55
+ // Removing a pin must stay possible after an edited skill grows over budget.
56
+ if (pins.every(pin => previous.has(pinKey(pin)))) return;
57
+ for (const pin of pins) {
58
+ if (previous.has(pinKey(pin))) continue;
59
+ const resolved = await resolvePinnedSkills([pin], state.cwd);
60
+ if (resolved.missing.length) throw new ClusterValidationError('skill_pins', `Skill ${pin.slug} is missing, off or unreadable. Choose an available skill.`);
61
+ if (resolved.truncated.length) throw new ClusterValidationError('skill_limit', `Skill ${pin.slug} exceeds 64 KiB of text.`);
62
+ }
63
+ await assertClusterSkillLimits({ ...state, skillPins: pins });
64
+ }
65
+
66
+ export async function resolveWorkflowSkillPins(workflowId: string, cwd: string, own: ArcoSkillRef[]) {
67
+ const clusterId = getClusterIdForWorkflow(workflowId);
68
+ const cluster = clusterId ? await readCluster(clusterId) : null;
69
+ const refs = cluster ? skillRefsForRole(cluster, cluster.memberRoles?.[workflowId], own) : uniqueSkillRefs(own);
70
+ return { refs, resolved: await resolvePinnedSkills(refs, cluster?.cwd ?? cwd) };
71
+ }
72
+
73
+ export async function assertWorkflowSkillPins(workflowId: string, cwd: string, refs: ArcoSkillRef[]): Promise<void> {
74
+ const previous = new Set((workflows.get(workflowId)?.config.pinnedSkills ?? []).map(key));
75
+ if (refs.every(ref => previous.has(key(ref)))) return;
76
+ const clusterId = getClusterIdForWorkflow(workflowId);
77
+ const cluster = clusterId ? await readCluster(clusterId) : null;
78
+ await assertSkillUnion(cluster ?? { cwd }, cluster?.memberRoles?.[workflowId], refs, 'This tab');
79
+ }
@@ -875,6 +875,7 @@ export async function restoreSnapshot(snapshotId: string, targetCwdInput?: strin
875
875
  // Passive cluster configuration is portable. Runtime arming is not:
876
876
  // idle-nudger, auto-turn, dispatcher enabled, REMOTE, and remote gates stay
877
877
  // OFF on every restore so importing a cluster cannot start work or expose it.
878
+ if (src.skillPins?.length) await clusterStore.setSkillPins(cluster.clusterId, src.skillPins, { restoringSnapshot: true });
878
879
  if (src.autoCompaction) await clusterStore.setAutoCompaction(cluster.clusterId, src.autoCompaction);
879
880
  await clusterStore.setEfficiency(
880
881
  cluster.clusterId,
@@ -36,6 +36,7 @@ import {
36
36
  resolveClusterMessageGuard,
37
37
  type ClusterMessageGuard,
38
38
  type ClusterCreationSettings,
39
+ type ClusterSkillPin,
39
40
  type ClusterDispatcherSettingsPatch,
40
41
  type ClusterDispatcherState,
41
42
  type ClusterEfficiencyLevel,
@@ -64,6 +65,7 @@ const ARCO_HOME = arcoHome();
64
65
  const CLUSTERS_DIR = join(ARCO_HOME, 'clusters');
65
66
 
66
67
  export interface ClusterState {
68
+ skillPins?: ClusterSkillPin[];
67
69
  autoCompaction?: AutoCompactionPolicy;
68
70
  clusterId: string;
69
71
  cwd: string;
@@ -112,6 +114,9 @@ export interface ClusterState {
112
114
  // Rule-based), so clusters saved before the modes existed keep their
113
115
  // behavior. autoTurnOnMailboxEnabled is kept equal to "mode is rule".
114
116
  autoPickupMode?: AutoPickupMode;
117
+ // Operator pause timestamp, independent of the Rule-based wake-budget stop.
118
+ // The timestamp freezes Smart's remaining session time across restart.
119
+ autoPickupPausedAt?: number;
115
120
  remindBusy?: boolean;
116
121
  rulePickupLimits?: Partial<RulePickupLimits>;
117
122
  // Smart pickup choices kept across disarm: the active evaluator, the last
@@ -272,6 +277,29 @@ function withClusterMetaLock<T>(clusterId: string, fn: () => Promise<T>): Promis
272
277
  return withFileLock(clusterMetaPath(clusterId), fn);
273
278
  }
274
279
 
280
+ // Direct tab-pin edits share the cluster lock with role and cluster-pin edits,
281
+ // so concurrent edits cannot each pass against an outdated effective union.
282
+ export function withClusterSkillLock<T>(workflowId: string, fn: () => Promise<T>): Promise<T> {
283
+ const clusterId = getClusterIdForWorkflow(workflowId);
284
+ return clusterId ? withClusterMetaLock(clusterId, fn) : fn();
285
+ }
286
+
287
+ export async function setSkillPins(clusterId: string, value: unknown, options: { restoringSnapshot?: boolean } = {}): Promise<ClusterState | null> {
288
+ return withClusterMetaLock(clusterId, async () => {
289
+ const state = await readCluster(clusterId);
290
+ if (!state) return null;
291
+ const { parseClusterSkillPins, validateNewClusterPins } = await import('./clusterSkills.js');
292
+ const pins = parseClusterSkillPins(value);
293
+ // A saved snapshot has the same missing/off/grown-file behavior as restart.
294
+ // Current turn resolution still enforces the standing prompt limits.
295
+ if (!options.restoringSnapshot) await validateNewClusterPins(state, pins);
296
+ const next = { ...state, skillPins: pins.length ? pins : undefined };
297
+ await writeMetaAtomic(next);
298
+ rebuildIndexFor(next);
299
+ return next;
300
+ });
301
+ }
302
+
275
303
  async function writeMetaAtomic(state: ClusterState): Promise<void> {
276
304
  const path = clusterMetaPath(state.clusterId);
277
305
  // proper-lockfile needs the file to exist before lock(); seed an empty
@@ -443,6 +471,7 @@ export async function addMember(
443
471
  );
444
472
  }
445
473
  const next: ClusterState = { ...state, members: [...state.members, workflowId] };
474
+ if (next.skillPins?.length) await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
446
475
  await writeMetaAtomic(next);
447
476
  rebuildIndexFor(next);
448
477
  memberJoined?.(clusterId, workflowId);
@@ -535,6 +564,7 @@ export async function replaceMember(
535
564
  oldWorkflowId: string,
536
565
  newWorkflowId: string,
537
566
  accessMode?: ClusterMemberAccessMode,
567
+ role?: string,
538
568
  ): Promise<ClusterState | null> {
539
569
  return withClusterMetaLock(clusterId, async () => {
540
570
  const state = await readCluster(clusterId);
@@ -563,6 +593,16 @@ export async function replaceMember(
563
593
  memberFocuses: remapSparse(state.memberFocuses, oldWorkflowId, newWorkflowId),
564
594
  memberAccessModes: Object.keys(nextModes).length > 0 ? nextModes : undefined,
565
595
  };
596
+ if (role !== undefined) {
597
+ const roles = { ...next.memberRoles };
598
+ const savedRole = normalizeClusterRoleText(role).slice(0, MEMBER_ROLE_MAX);
599
+ if (savedRole) roles[newWorkflowId] = savedRole;
600
+ else delete roles[newWorkflowId];
601
+ const problem = clusterDirectorProblem(next.members.map(id => roles[id]));
602
+ if (problem) throw new ClusterValidationError('multiple_directors', problem);
603
+ next.memberRoles = Object.keys(roles).length ? roles : undefined;
604
+ }
605
+ if (next.skillPins?.length) await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
566
606
  if (nextMode === 'isolated') {
567
607
  await fs.mkdir(isolatedWorkspaceFor(clusterId, newWorkflowId), { recursive: true, mode: 0o700 });
568
608
  }
@@ -683,6 +723,7 @@ export async function setMemberRole(
683
723
  const next: ClusterState = Object.keys(nextRoles).length === 0
684
724
  ? { ...state, memberRoles: undefined }
685
725
  : { ...state, memberRoles: nextRoles };
726
+ if (!options.restoringSnapshot && next.skillPins?.length) await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
686
727
  await writeMetaAtomic(next);
687
728
  rebuildIndexFor(next);
688
729
  return next;
@@ -1001,13 +1042,28 @@ export async function setAutoTurnOnMailbox(
1001
1042
  // its own id and expiry; any other mode clears the session, which makes any
1002
1043
  // outstanding Smart work stale. The evaluator, last explicit choice and
1003
1044
  // limits persist across disarm so re-arming can offer them again.
1045
+ // Pause-only updates preserve session identity and remaining running time;
1046
+ // resume moves its expiry forward by the saved pause duration.
1004
1047
  export async function setAutoPickup(
1005
1048
  clusterId: string,
1006
- opts: { mode: AutoPickupMode; evaluator?: SmartPickupEvaluator; limits?: Partial<SmartPickupLimits>; ruleLimits?: Partial<RulePickupLimits>; remindBusy?: boolean; now?: number },
1049
+ opts: { mode: AutoPickupMode; paused?: boolean; evaluator?: SmartPickupEvaluator; limits?: Partial<SmartPickupLimits>; ruleLimits?: Partial<RulePickupLimits>; remindBusy?: boolean; now?: number },
1007
1050
  ): Promise<ClusterState | null> {
1008
1051
  return withClusterMetaLock(clusterId, async () => {
1009
1052
  const state = await readCluster(clusterId);
1010
1053
  if (!state) return null;
1054
+ if (typeof opts.paused === 'boolean') {
1055
+ if (opts.mode === 'off' || opts.mode !== autoPickupModeOf(state)) return null;
1056
+ const now = opts.now ?? Date.now();
1057
+ const pausedAt = state.autoPickupPausedAt;
1058
+ const session = state.smartPickup?.session;
1059
+ const smartPickup = !opts.paused && pausedAt !== undefined && session && isSmartPickupMode(opts.mode)
1060
+ ? { ...state.smartPickup, session: { ...session, expiresAt: session.expiresAt + Math.max(0, now - pausedAt) } }
1061
+ : state.smartPickup;
1062
+ const next = { ...state, autoPickupPausedAt: opts.paused ? pausedAt ?? now : undefined, smartPickup };
1063
+ await writeMetaAtomic(next);
1064
+ rebuildIndexFor(next);
1065
+ return next;
1066
+ }
1011
1067
  const now = opts.now ?? Date.now();
1012
1068
  const prior = state.smartPickup ?? {};
1013
1069
  const limits = opts.limits ? sanitizeSmartPickupLimits({ ...sanitizeSmartPickupLimits(prior.limits), ...opts.limits }) : prior.limits;
@@ -1033,6 +1089,9 @@ export async function setAutoPickup(
1033
1089
  rulePickupLimits: opts.ruleLimits ? sanitizeRulePickupLimits({ ...sanitizeRulePickupLimits(state.rulePickupLimits), ...opts.ruleLimits }) : state.rulePickupLimits,
1034
1090
  remindBusy: typeof opts.remindBusy === 'boolean' ? opts.remindBusy : state.remindBusy,
1035
1091
  autoPickupMode: opts.mode === 'off' ? undefined : opts.mode,
1092
+ autoPickupPausedAt: opts.mode !== 'off' && opts.mode === autoPickupModeOf(state) && state.autoPickupPausedAt !== undefined
1093
+ ? isSmartPickupMode(opts.mode) ? now : state.autoPickupPausedAt
1094
+ : undefined,
1036
1095
  autoTurnOnMailboxEnabled: opts.mode === 'rule' ? true : undefined,
1037
1096
  smartPickup: hasSmart ? smartPickup : undefined,
1038
1097
  };
@@ -1047,6 +1106,10 @@ export function getAutoPickupMode(clusterId: string): AutoPickupMode {
1047
1106
  return resolveAutoPickupMode(state?.autoPickupMode, state?.autoTurnOnMailboxEnabled);
1048
1107
  }
1049
1108
 
1109
+ export function isAutoPickupPaused(clusterId: string): boolean {
1110
+ return cache.get(clusterId)?.autoPickupPausedAt !== undefined;
1111
+ }
1112
+
1050
1113
  export function autoPickupModeOf(state: Pick<ClusterState, 'autoPickupMode' | 'autoTurnOnMailboxEnabled'>): AutoPickupMode {
1051
1114
  return resolveAutoPickupMode(state.autoPickupMode, state.autoTurnOnMailboxEnabled);
1052
1115
  }
@@ -46,6 +46,7 @@ function readHeadSync(): string | null {
46
46
  cwd: REPO_ROOT,
47
47
  timeout: 2000,
48
48
  encoding: 'utf8',
49
+ stdio: 'pipe',
49
50
  });
50
51
  const rev = out.trim();
51
52
  return /^[0-9a-f]{40}$/i.test(rev) ? rev : null;
@@ -20,7 +20,7 @@
20
20
  // a segment, or that a checked segment holds.
21
21
 
22
22
  import { promises as fs, createReadStream, closeSync, fstatSync, openSync, readFileSync, readSync, readdirSync, statSync, constants as fsConstants } from 'node:fs';
23
- import { createInterface } from 'node:readline';
23
+ import { jsonlLines } from './jsonlLines.js';
24
24
  import { brotliCompress, brotliDecompress, brotliDecompressSync, createBrotliDecompress, constants as zc } from 'node:zlib';
25
25
  import { promisify } from 'node:util';
26
26
  import { randomUUID } from 'node:crypto';
@@ -225,7 +225,7 @@ async function firstLiveSeq(file: string): Promise<number | null> {
225
225
  const fh = await openLive(file);
226
226
  if (!fh) return null;
227
227
  try {
228
- for await (const line of handleLines(fh)) { const seq = lineSeq(line); if (seq !== null) return seq; }
228
+ for await (const line of handleLines(fh, file)) { const seq = lineSeq(line); if (seq !== null) return seq; }
229
229
  return null;
230
230
  } finally { await fh.close(); }
231
231
  }
@@ -241,18 +241,17 @@ function reportUnreadable(err: unknown): void {
241
241
  }
242
242
 
243
243
  async function* segmentLines(seg: Segment): AsyncGenerator<string> {
244
- const input = createReadStream(seg.file);
244
+ const input = createReadStream(seg.file, { highWaterMark: 64 * 1024 });
245
245
  const decompressed = createBrotliDecompress();
246
246
  // An error opening or reading the file (a segment removed or replaced since
247
247
  // it was listed) reaches the reader below instead of going unhandled.
248
248
  input.on('error', (err) => decompressed.destroy(err));
249
- const rl = createInterface({ input: input.pipe(decompressed), crlfDelay: Infinity });
250
249
  try {
251
- for await (const line of rl) if (line) yield line;
250
+ for await (const line of jsonlLines(input.pipe(decompressed), seg.file)) if (line) yield line;
252
251
  } catch (err) {
253
252
  throw new SegmentReadError(seg.file, err);
254
253
  } finally {
255
- rl.close(); input.destroy();
254
+ input.destroy(); decompressed.destroy();
256
255
  }
257
256
  }
258
257
 
@@ -261,17 +260,16 @@ async function openLive(file: string): Promise<FileHandle | null> {
261
260
  catch (err) { if ((err as NodeJS.ErrnoException).code === 'ENOENT') return null; throw err; }
262
261
  }
263
262
 
264
- async function* handleLines(fh: FileHandle): AsyncGenerator<string> {
265
- const input = fh.createReadStream({ autoClose: false });
266
- const rl = createInterface({ input, crlfDelay: Infinity });
267
- try { for await (const line of rl) if (line) yield line; }
268
- finally { rl.close(); input.destroy(); }
263
+ async function* handleLines(fh: FileHandle, source: string): AsyncGenerator<string> {
264
+ const input = fh.createReadStream({ autoClose: false, highWaterMark: 64 * 1024 });
265
+ try { for await (const line of jsonlLines(input, source)) if (line) yield line; }
266
+ finally { input.destroy(); }
269
267
  }
270
268
 
271
269
  async function* liveLines(file: string): AsyncGenerator<string> {
272
270
  const fh = await openLive(file);
273
271
  if (!fh) return;
274
- try { yield* handleLines(fh); } finally { await fh.close(); }
272
+ try { yield* handleLines(fh, file); } finally { await fh.close(); }
275
273
  }
276
274
 
277
275
  // Every record line in sequence order: sealed segments, then the live file.
@@ -319,7 +317,7 @@ export async function* readLogLines(dir: string, opts: { fromSeq?: number } = {}
319
317
  try {
320
318
  yield* drainSegments();
321
319
  if (!fh) return;
322
- for await (const line of handleLines(fh)) if (!copies.drop(line)) yield line;
320
+ for await (const line of handleLines(fh, path.join(dir, LIVE_LOG))) if (!copies.drop(line)) yield line;
323
321
  } finally { await fh?.close(); }
324
322
  }
325
323
 
@@ -331,6 +329,68 @@ export async function readLogText(dir: string): Promise<string> {
331
329
  return parts.length ? parts.join('\n') + '\n' : '';
332
330
  }
333
331
 
332
+ // Byte offsets retain the old resume reader's accounting: raw file bytes for
333
+ // a plain log, or the newline-normalized, overlap-filtered readLogText bytes
334
+ // when segments exist. Ranges stream without concatenating the whole log.
335
+ export interface LogByteSource {
336
+ size: number;
337
+ chunks(start: number, length: number): AsyncGenerator<Buffer>;
338
+ read(start: number, length: number): Promise<string>;
339
+ close(): Promise<void>;
340
+ }
341
+ export async function openLogByteSource(dir: string): Promise<LogByteSource | null> {
342
+ let size = 0;
343
+ let chunks: LogByteSource['chunks'];
344
+ let close: LogByteSource['close'] = async () => {};
345
+ if ((await listSegments(dir)).length) {
346
+ for await (const line of readLogLines(dir)) size += Buffer.byteLength(line, 'utf8') + 1;
347
+ chunks = async function* (start, length) {
348
+ const end = Math.min(size, start + length);
349
+ let position = 0;
350
+ for await (const line of readLogLines(dir)) {
351
+ const next = position + Buffer.byteLength(line, 'utf8') + 1;
352
+ if (next > start && position < end) {
353
+ const buffer = Buffer.from(line + '\n', 'utf8');
354
+ const from = Math.max(0, start - position), through = Math.min(buffer.length, end - position);
355
+ for (let offset = from; offset < through; offset += 64 * 1024) {
356
+ yield buffer.subarray(offset, Math.min(through, offset + 64 * 1024));
357
+ }
358
+ }
359
+ position = next;
360
+ if (position >= end) break;
361
+ }
362
+ };
363
+ } else {
364
+ const file = path.join(dir, LIVE_LOG);
365
+ const fh = await openLive(file);
366
+ if (!fh) return null;
367
+ try {
368
+ const stat = await fh.stat();
369
+ if (!stat.isFile()) throw new Error(`Expected a history file at ${file}`);
370
+ size = stat.size;
371
+ } catch (err) {
372
+ await fh.close();
373
+ throw err;
374
+ }
375
+ close = () => fh.close();
376
+ chunks = async function* (start, length) {
377
+ const end = Math.min(size, start + length);
378
+ for (let position = start; position < end;) {
379
+ const buffer = Buffer.alloc(Math.min(64 * 1024, end - position));
380
+ const { bytesRead } = await fh.read(buffer, 0, buffer.length, position);
381
+ if (!bytesRead) break;
382
+ position += bytesRead;
383
+ yield buffer.subarray(0, bytesRead);
384
+ }
385
+ };
386
+ }
387
+ return { size, chunks, close, read: async (start, length) => {
388
+ const parts: Buffer[] = [];
389
+ for await (const chunk of chunks(start, length)) parts.push(chunk);
390
+ return Buffer.concat(parts).toString('utf8');
391
+ } };
392
+ }
393
+
334
394
  function decompressSegmentSync(seg: Segment): string {
335
395
  try { return brotliDecompressSync(readFileSync(seg.file)).toString('utf8'); }
336
396
  catch (err) { throw new SegmentReadError(seg.file, err); }
@@ -0,0 +1,2 @@
1
+ // Shared byte budget for recent replacement history and Native resume digests.
2
+ export const RECENT_HISTORY_MAX_BYTES = 128 * 1024;
@@ -1893,7 +1893,7 @@ export async function handleHttpRequest(
1893
1893
  res.end(JSON.stringify({ error: retired }));
1894
1894
  return;
1895
1895
  }
1896
- const provider: CliProvider = providerParam === 'codex'
1896
+ const provider: CliProvider = providerParam === 'codex' || providerParam === 'cursor'
1897
1897
  ? providerParam
1898
1898
  : 'claude';
1899
1899
  const result = await runCliUpdate(deps.getCapabilities(), provider);
@@ -1,4 +1,5 @@
1
1
  import { releaseProjectSettingsWatcher } from './settings.js';
2
+ import { initTranscriptWorkerHandlers, handleTranscriptWorkerPreview, handleTranscriptWorkerCreate } from './ws/transcriptWorkerHandlers.js';
2
3
  import { NativeTaskAdmission, assertNativeTaskAllowed } from './providers/claude-native/taskAdmission.js';
3
4
  import { resolveNativeSubagents, CLAUDE_MODELS } from '@arco/shared';
4
5
  import { getCatalog as getNativeTaskCatalog } from './providers/claude-native/catalog.js';
@@ -163,6 +164,7 @@ handleClusterOrchestrationProposalList,
163
164
  handleClusterOrchestrationProposalReject,
164
165
  handleClusterIdleNudgerToggle,
165
166
  handleClusterEfficiencySet,
167
+ handleClusterSkillsSet,
166
168
  handleClusterAutoCompactionSet,
167
169
  handleClusterRemoteSet,
168
170
  handleClusterGatesSet,
@@ -621,6 +623,18 @@ const previewAutoDetect = new PreviewAutoDetect({
621
623
 
622
624
  initTurnEngine({ previewAutoDetect, handleCreateWorkflow, handleHandoffRequest, handleCompactWorkflow });
623
625
  initWorkflowHandlers({ previewAutoDetect, handleRehydrateWorkflows });
626
+ initTranscriptWorkerHandlers({
627
+ create: async (ws, session, config) => {
628
+ let id: string | undefined;
629
+ await handleCreateWorkflow(ws, session, config, { backgroundCreated: true, onCreated: created => { id = created; } });
630
+ if (!id) throw new Error('The new worker could not be created. Review its settings and try again.');
631
+ return id;
632
+ },
633
+ seed: (ws, session, workflowId, content) => {
634
+ void handleUserMessage(ws, session, workflowId, content, crypto.randomUUID(), undefined, false, undefined, undefined)
635
+ .catch(() => send(ws, { type: 'error', workflowId, message: 'Could not start the new worker. Open its tab to review the request and retry.' }));
636
+ },
637
+ });
624
638
  setStrataSwitchActivityCheck(() => [...workflows.values()].some((wf) =>
625
639
  (wf.busy && ['ollama', 'llamacpp', 'lmstudio', 'deepseek'].includes(wf.primary.provider)) ||
626
640
  Object.values(wf.manager.snapshotWorkers()).some((w) => ['ollama', 'llamacpp', 'lmstudio', 'deepseek'].includes(w.provider ?? '') && (w.status === 'running' || w.status === 'spawning'))));
@@ -730,6 +744,12 @@ wss.on('connection', (ws: WebSocket) => {
730
744
  }
731
745
 
732
746
  switch (msg.type) {
747
+ case 'transcript_worker_preview':
748
+ void handleTranscriptWorkerPreview(ws, msg);
749
+ break;
750
+ case 'transcript_worker_create':
751
+ void handleTranscriptWorkerCreate(ws, session, msg);
752
+ break;
733
753
  case 'create_workflow':
734
754
  (msg.config.incognito ? withoutOperationalLogging : <T>(fn: () => T) => fn())(() =>
735
755
  handleCreateWorkflow(ws, session, msg.config).catch((err) => {
@@ -1313,6 +1333,9 @@ wss.on('connection', (ws: WebSocket) => {
1313
1333
  console.error('[arco] cluster_efficiency_set handler failed:', err);
1314
1334
  });
1315
1335
  break;
1336
+ case 'cluster_skills_set':
1337
+ void handleClusterSkillsSet(ws, msg.clusterId, msg.pins);
1338
+ break;
1316
1339
  case 'cluster_remote_set':
1317
1340
  handleClusterRemoteSet(ws, msg.clusterId, msg.enabled).catch((err) => {
1318
1341
  console.error('[arco] cluster_remote_set handler failed:', err);
@@ -0,0 +1,52 @@
1
+ import { basename } from 'node:path';
2
+
3
+ const LARGE_RECORD_BYTES = 16 * 1024 * 1024;
4
+ const warnedSources = new Set<string>();
5
+
6
+ // Retain only the current record's bytes. Decode once at its boundary so a
7
+ // split UTF-8 character is never replaced and a long record does not build a
8
+ // chain of decoded string fragments. Large records stay readable as before.
9
+ export async function* jsonlLines(
10
+ input: AsyncIterable<Buffer>,
11
+ source: string,
12
+ options: { finalLine?: boolean; carriageReturns?: boolean } = {},
13
+ ): AsyncGenerator<string> {
14
+ let parts: Buffer[] = [];
15
+ let bytes = 0;
16
+ let afterCr = false;
17
+ const add = (part: Buffer): void => {
18
+ if (!part.length) return;
19
+ parts.push(part);
20
+ bytes += part.length;
21
+ if (bytes > LARGE_RECORD_BYTES && !warnedSources.has(source)) {
22
+ warnedSources.add(source);
23
+ console.warn(`[arco] A record in ${basename(source)} exceeds 16 MiB; reading it in full.`);
24
+ }
25
+ };
26
+ const take = (): string => {
27
+ const line = parts.length === 1 ? parts[0].toString('utf8') : Buffer.concat(parts, bytes).toString('utf8');
28
+ parts = [];
29
+ bytes = 0;
30
+ return line;
31
+ };
32
+ for await (const chunk of input) {
33
+ let start = 0;
34
+ const hasCr = options.carriageReturns !== false && chunk.includes(0x0d);
35
+ while (start < chunk.length) {
36
+ if (afterCr) {
37
+ afterCr = false;
38
+ if (chunk[start] === 0x0a) { start++; continue; }
39
+ }
40
+ const lf = chunk.indexOf(0x0a, start);
41
+ const cr = hasCr ? chunk.indexOf(0x0d, start) : -1;
42
+ const end = lf < 0 ? cr : cr < 0 ? lf : Math.min(lf, cr);
43
+ if (end < 0) break;
44
+ add(chunk.subarray(start, end));
45
+ yield take();
46
+ afterCr = chunk[end] === 0x0d;
47
+ start = end + 1;
48
+ }
49
+ add(chunk.subarray(start));
50
+ }
51
+ if (bytes && options.finalLine !== false) yield take();
52
+ }
@@ -63,6 +63,7 @@ function shortGitRevision(repoRoot: string): string {
63
63
  return execFileSync('git', ['rev-parse', '--short', 'HEAD'], {
64
64
  cwd: repoRoot,
65
65
  encoding: 'utf8',
66
+ stdio: 'pipe',
66
67
  }).trim();
67
68
  } catch {
68
69
  return 'unknown';
@@ -465,7 +465,7 @@ export function registerClusterTools(server: McpServer, ctx: ClusterMcpToolCtx):
465
465
  'cluster_task_create',
466
466
  {
467
467
  description:
468
- 'Create a non-terminal task on the shared cluster board. New tasks start as todo; done/archived remain operator-only. Use title plus optional body/notes, assignee, priority, parentIds, links, reviewRequired, goalMode, and goalMaxTurns. parentIds must refer to existing tasks. When the task implements a plan item, start the title with that item\'s id or text (e.g. \'P6.9 Live tab drag follow on X11\'): cluster_task_show then resolves the item\'s reference docs (its own ref links, its sub-bullets, its phase intro) for whoever works it. Add any extra ref:slug links the task needs to notes.',
468
+ 'Create a non-terminal task on the shared cluster board. New tasks start as todo; terminal statuses cannot be set when creating a task. Use title plus optional body/notes, assignee, priority, parentIds, links, reviewRequired, goalMode, and goalMaxTurns. parentIds must refer to existing tasks. When the task implements a plan item, start the title with that item\'s id or text (e.g. \'P6.9 Live tab drag follow on X11\'): cluster_task_show then resolves the item\'s reference docs (its own ref links, its sub-bullets, its phase intro) for whoever works it. Add any extra ref:slug links the task needs to notes.',
469
469
  inputSchema: {
470
470
  title: z.string().min(1).describe('Task title. Required and non-empty.'),
471
471
  body: z.string().optional().describe('Initial task body. Alias for notes when notes is absent.'),
@@ -563,7 +563,7 @@ export function registerClusterTools(server: McpServer, ctx: ClusterMcpToolCtx):
563
563
  'cluster_task_update',
564
564
  {
565
565
  description:
566
- "Update a task on the shared cluster board. Change its `status` (triage / todo / ready / in_progress / blocked / review), replace `notes`, and/or record a `signoff` verdict. IMPORTANT: `done` and `archived` are OPERATOR-ONLY — those statuses are REJECTED here (operator_gated). When you finish work, move the task to review or report completion via peer_send to the director; the operator marks done from the LEDGER tab.\n\nSIGN-OFF (director): when you review a peer's completed task, set `signoff` to your verdict — `met`, `not_met`, or `partial` — with a one-line `summary`. ADVISORY only: it does NOT mark the task done; it surfaces a recommendation on the board so the operator can accept at a glance. Only the reviewing member (the director) should set this.",
566
+ "Update a task on the shared cluster board. Workers move completed work to review. Only the director signs off: set signoff to met, partial, or not_met with a plain one-line summary for the operator, without commit hashes. A director's met sign-off closes the task unless Board auto-done is off in Settings; partial and not_met leave the task status unchanged unless you set a status. Tell the operator in chat what to try. Direct status changes to done or archived remain operator-only.",
567
567
  inputSchema: {
568
568
  id: z.string().min(1).describe('Task id from cluster_task_list.'),
569
569
  status: z.enum(['triage', 'todo', 'ready', 'in_progress', 'blocked', 'review']).optional().describe("New status. 'done' and 'archived' are rejected — operator-only."),
@@ -572,7 +572,7 @@ export function registerClusterTools(server: McpServer, ctx: ClusterMcpToolCtx):
572
572
  signoff: z.object({
573
573
  state: z.enum(['met', 'not_met', 'partial']).describe('Your verdict: met / not_met / partial.'),
574
574
  summary: z.string().optional().describe('One-line reason shown on the board card.'),
575
- }).optional().describe('Advisory director verdict on whether the task met its target. Does NOT mark it done.'),
575
+ }).optional().describe('Director verdict: met closes the task unless Board auto-done is off.'),
576
576
  },
577
577
  },
578
578
  async (args) => {
@@ -699,7 +699,7 @@ export function registerClusterTools(server: McpServer, ctx: ClusterMcpToolCtx):
699
699
  'cluster_task_complete',
700
700
  {
701
701
  description:
702
- "Submit a completion report for a task. Moves the task to review and appends a durable COMPLETION REPORT comment. It does NOT mark done; done remains operator-only.",
702
+ "Submit a completion report for a task. Moves the task to review and appends a durable COMPLETION REPORT comment. It does not mark done; the director reviews the report.",
703
703
  inputSchema: {
704
704
  id: z.string().min(1).describe('Task id from cluster_task_list.'),
705
705
  summary: z.string().min(1).describe('What changed, tests run, files touched, and follow-ups.'),
@@ -14,10 +14,9 @@ import { ensureProjectStateIgnore } from '../projectStateIgnore.js';
14
14
  // need — is documented in docs/TASK_LEDGER.md, not assumed). The working set is
15
15
  // small + single-writer, so query() is load-all + filter-in-JS.
16
16
  //
17
- // LOAD-BEARING INVARIANT (§D1 acceptance): there is NO code path that sets
18
- // status: 'done' except an explicit operator-originated update (applyUpdate
19
- // below). create() never accepts a status; rebuildFromEvents only replays
20
- // recorded operator events; there is no auto-done / no inference anywhere.
17
+ // Direct terminal-status updates are operator-controlled. A director's met
18
+ // sign-off may close a task when Board auto-done is enabled; replay uses the
19
+ // recorded result and never infers a new status.
21
20
 
22
21
  import { promises as fs, existsSync } from 'fs';
23
22
  import path from 'path';
@@ -748,9 +747,10 @@ export function applyUpdate(
748
747
  // Release label; '' clears it, undefined leaves it untouched.
749
748
  release?: string;
750
749
  worktree?: TaskWorktree | null;
751
- // §D3 — director's advisory verdict. An object sets it (caller stamps
750
+ // Director verdict. An object sets it (caller stamps
752
751
  // byWorkflowId/at); `null` clears it; `undefined` leaves it untouched.
753
752
  signoff?: TaskSignoff | null;
753
+ directorClosure?: { byWorkflowId: string; at: number };
754
754
  updatedBy?: string;
755
755
  },
756
756
  ): { tasks: LedgerTask[]; updated: LedgerTask } | null {
@@ -809,6 +809,8 @@ export function applyUpdate(
809
809
  if (clean) next.signoff = clean;
810
810
  else delete next.signoff;
811
811
  }
812
+ if (patch.directorClosure) next.directorClosure = patch.directorClosure;
813
+ else if (patch.status && patch.status !== 'done') delete next.directorClosure;
812
814
  const out = [...tasks];
813
815
  out[i] = next;
814
816
  return { tasks: out, updated: next };
@@ -5,6 +5,21 @@ import { readMeta, persistInitialMeta, reconcileLatestCliSession, workflowMetaSe
5
5
  import { scanEventsOfTypes } from './workflowStore.js';
6
6
  import { broadcastWorkflow, broadcastTransient } from './server/broadcast.js';
7
7
 
8
+ const historyLoadNotices = new WeakMap<object, Set<string>>();
9
+ export function reportHistoryLoadFailure(workflowId: string, owner: object, provider: 'native' | 'cli', emit?: (content: string) => void, nativeLimitBytes?: number): void {
10
+ const shown = historyLoadNotices.get(owner) ?? new Set<string>();
11
+ if (shown.has(provider)) return;
12
+ shown.add(provider);
13
+ historyLoadNotices.set(owner, shown);
14
+ const content = provider === 'native'
15
+ ? nativeLimitBytes !== undefined
16
+ ? `Earlier context could not be rebuilt within the ${nativeLimitBytes / (1024 * 1024)} MiB reconstruction limit, so the agent continues without it. Earlier messages remain in this tab.`
17
+ : 'Earlier context could not be rebuilt for this conversation, so the agent continues without it. Earlier messages remain in this tab.'
18
+ : 'Earlier Claude CLI session history could not be loaded in this tab. The saved conversation is intact; new session messages will appear when the file can be read.';
19
+ if (emit) emit(content);
20
+ else broadcastWorkflow(workflowId, { type: 'system_notice', workflowId, content });
21
+ }
22
+
8
23
  export async function hasConversationHistory(cwd: string, workflowId: string, afterSeq = 0): Promise<boolean> {
9
24
  let found = false;
10
25
  await scanEventsOfTypes(cwd, workflowId, ['primary_complete', 'primary_text'], event => { if ((('seq' in event && typeof event.seq === 'number') ? event.seq : 0) > afterSeq) found = true; });