arco-workbench 0.1.7 → 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 (210) hide show
  1. package/CONTRIBUTING.md +52 -12
  2. package/README.md +14 -12
  3. package/client/dist/assets/{PhosphorBackdrop-DVQdBrTw.js → PhosphorBackdrop-D7jdAV_G.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-BfSs2tB4.js → ThemedBackgroundShaderImpl-DrDm60h8.js} +1 -1
  5. package/client/dist/assets/{XtermView-DaMjC8Ny.js → XtermView-BGFujb1e.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-BCQnXj7R.js → galleryEditor-D951A2sE.js} +1 -1
  7. package/client/dist/assets/{index-COfbHCYv.js → index-CsVy3eZm.js} +246 -246
  8. package/client/dist/index.html +1 -1
  9. package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +65 -15
  10. package/client/src/components/ClusterRightPanel/SkillsControl.tsx +107 -0
  11. package/client/src/components/ClusterRightPanel/index.tsx +4 -0
  12. package/client/src/components/ClusterTaskBoardTab.tsx +9 -22
  13. package/client/src/components/NeedsYouBadge.tsx +3 -3
  14. package/client/src/components/ProviderReleasesModal.tsx +8 -4
  15. package/client/src/components/ProvidersPopover.tsx +28 -23
  16. package/client/src/components/SettingsPanel.tsx +2 -2
  17. package/client/src/components/SkillsSettings.tsx +5 -0
  18. package/client/src/components/TabBar.tsx +91 -9
  19. package/client/src/components/TerminalInput.tsx +12 -10
  20. package/client/src/components/TranscriptSendDialog.tsx +12 -8
  21. package/client/src/components/TranscriptWorkerDialog.tsx +119 -0
  22. package/client/src/components/clusterNeedsYou.ts +11 -18
  23. package/client/src/help/content/cluster.tsx +38 -17
  24. package/client/src/help/content/composer.tsx +22 -0
  25. package/client/src/help/content/header.tsx +16 -0
  26. package/client/src/help/content/misc.tsx +8 -0
  27. package/client/src/help/content/settings.tsx +18 -4
  28. package/client/src/help/content/tabbar.tsx +5 -0
  29. package/client/src/help/manualSections/actions.tsx +31 -0
  30. package/client/src/help/manualSections/clusters.tsx +41 -20
  31. package/client/src/help/manualSections/configuration.tsx +18 -0
  32. package/client/src/help/manualSections/maintenance.tsx +18 -0
  33. package/client/src/help/manualSections/providers.tsx +32 -8
  34. package/client/src/help/manualSections/troubleshooting.tsx +2 -1
  35. package/client/src/help/manualSections/workflows.tsx +12 -0
  36. package/client/src/help/manualSections/workspace.tsx +6 -0
  37. package/client/src/utils/transcriptWorkerRequest.ts +24 -0
  38. package/client/src/ws/handleServerMessage.ts +8 -2
  39. package/docs/ARCHITECTURE.md +1 -1
  40. package/docs/CLIENT.md +9 -8
  41. package/docs/FEATURES.md +8 -5
  42. package/docs/GETTING_STARTED.md +4 -3
  43. package/docs/GOTCHAS.md +2 -1
  44. package/docs/OPERATIONS.md +14 -4
  45. package/docs/PERSISTENCE.md +7 -2
  46. package/docs/PRIMITIVES.md +42 -0
  47. package/docs/PROTOCOL_CLUSTER.md +42 -3
  48. package/docs/PROTOCOL_PRIMITIVES.md +39 -0
  49. package/docs/PROVIDERS.md +50 -13
  50. package/docs/SETTINGS.md +27 -3
  51. package/docs/TASK_LEDGER.md +7 -15
  52. package/native/darwin-arm64/manifest.json +1 -1
  53. package/node_modules/@arco/shared/dist/clusterCoordination.d.ts +2 -0
  54. package/node_modules/@arco/shared/dist/clusterCoordination.js +5 -1
  55. package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +3 -2
  56. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +13 -1
  57. package/node_modules/@arco/shared/dist/protocol/index.d.ts +1 -0
  58. package/node_modules/@arco/shared/dist/protocol/index.js +1 -0
  59. package/node_modules/@arco/shared/dist/protocol/models.d.ts +4 -3
  60. package/node_modules/@arco/shared/dist/protocol/models.js +26 -2
  61. package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +2 -1
  62. package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +4 -0
  63. package/node_modules/@arco/shared/dist/protocol/transcriptWorker.d.ts +47 -0
  64. package/node_modules/@arco/shared/dist/protocol/transcriptWorker.js +2 -0
  65. package/node_modules/@arco/shared/dist/runtimeVersions.d.ts +1 -0
  66. package/node_modules/@arco/shared/dist/runtimeVersions.js +14 -0
  67. package/node_modules/@arco/shared/package.json +1 -1
  68. package/package.json +2 -2
  69. package/scripts/packaging/arco.mjs +1 -1
  70. package/scripts/packaging/native-repair.mjs +32 -4
  71. package/server/dist/atomicFile.js +1 -2
  72. package/server/dist/capabilities.d.ts +5 -2
  73. package/server/dist/capabilities.js +59 -9
  74. package/server/dist/cliUpdateDecision.d.ts +1 -1
  75. package/server/dist/cliUpdateDecision.js +5 -3
  76. package/server/dist/clusterDirector.js +1 -1
  77. package/server/dist/clusterPeerOps.js +10 -7
  78. package/server/dist/clusterProgress.js +1 -1
  79. package/server/dist/clusterSkills.d.ts +13 -0
  80. package/server/dist/clusterSkills.js +81 -0
  81. package/server/dist/clusterSnapshots.js +2 -0
  82. package/server/dist/clusterStore.d.ts +7 -2
  83. package/server/dist/clusterStore.js +42 -1
  84. package/server/dist/diagnostics/codeSkew.js +1 -0
  85. package/server/dist/eventLog.d.ts +7 -0
  86. package/server/dist/eventLog.js +70 -13
  87. package/server/dist/historyLimits.d.ts +1 -0
  88. package/server/dist/historyLimits.js +3 -0
  89. package/server/dist/http/router.js +1 -1
  90. package/server/dist/index.js +24 -1
  91. package/server/dist/jsonlLines.d.ts +4 -0
  92. package/server/dist/jsonlLines.js +53 -0
  93. package/server/dist/management/identity.js +1 -0
  94. package/server/dist/mcp/clusterMcpTools.js +4 -4
  95. package/server/dist/project/taskLedger.d.ts +4 -0
  96. package/server/dist/project/taskLedger.js +7 -4
  97. package/server/dist/providerConversation.d.ts +1 -0
  98. package/server/dist/providerConversation.js +17 -0
  99. package/server/dist/providers/claude-native/resumeSummary.d.ts +9 -0
  100. package/server/dist/providers/claude-native/resumeSummary.js +102 -49
  101. package/server/dist/providers/claude-native/worker.js +8 -4
  102. package/server/dist/providers/claude.js +2 -1
  103. package/server/dist/providers/clusterTaskToolDefinitions.js +4 -4
  104. package/server/dist/providers/codex-appserver/catalog.js +16 -1
  105. package/server/dist/providers/codex.js +2 -1
  106. package/server/dist/providers/codexCodeMode.d.ts +1 -1
  107. package/server/dist/providers/codexCodeMode.js +4 -3
  108. package/server/dist/providers/cursor/print.js +2 -1
  109. package/server/dist/providers/cursor/worker.js +2 -1
  110. package/server/dist/providers/llamacpp.js +17 -8
  111. package/server/dist/providers/ollamaRecovery.js +6 -6
  112. package/server/dist/providers/ollamaResilience.js +3 -3
  113. package/server/dist/providers/ollamaTokens.js +1 -1
  114. package/server/dist/quota.d.ts +0 -18
  115. package/server/dist/quota.js +0 -44
  116. package/server/dist/replacementHistory.d.ts +19 -0
  117. package/server/dist/replacementHistory.js +49 -0
  118. package/server/dist/server/broadcast.d.ts +2 -1
  119. package/server/dist/server/broadcast.js +1 -0
  120. package/server/dist/server/prompts.d.ts +1 -0
  121. package/server/dist/server/prompts.js +6 -1
  122. package/server/dist/sessionJsonl.d.ts +1 -1
  123. package/server/dist/sessionJsonl.js +115 -40
  124. package/server/dist/smartPickupAdapters.js +15 -2
  125. package/server/dist/transcriptWorker.d.ts +34 -0
  126. package/server/dist/transcriptWorker.js +201 -0
  127. package/server/dist/workflowStore.d.ts +1 -0
  128. package/server/dist/workflowStore.js +31 -0
  129. package/server/dist/ws/clusterHandlers.d.ts +1 -0
  130. package/server/dist/ws/clusterHandlers.js +62 -26
  131. package/server/dist/ws/handoffHandlers.js +5 -2
  132. package/server/dist/ws/transcriptWorkerHandlers.d.ts +25 -0
  133. package/server/dist/ws/transcriptWorkerHandlers.js +139 -0
  134. package/server/dist/ws/turnEngine.js +23 -9
  135. package/server/dist/ws/updatePrimaryConfig.js +27 -8
  136. package/server/dist/ws/workflowHandlers.d.ts +4 -1
  137. package/server/dist/ws/workflowHandlers.js +3 -1
  138. package/server/package.json +1 -1
  139. package/server/src/atomicFile.ts +1 -2
  140. package/server/src/capabilities.ts +58 -17
  141. package/server/src/cliUpdateDecision.ts +5 -4
  142. package/server/src/clusterDirector.ts +1 -1
  143. package/server/src/clusterPeerOps.ts +11 -8
  144. package/server/src/clusterProgress.ts +1 -1
  145. package/server/src/clusterSkills.ts +79 -0
  146. package/server/src/clusterSnapshots.ts +1 -0
  147. package/server/src/clusterStore.ts +38 -0
  148. package/server/src/diagnostics/codeSkew.ts +1 -0
  149. package/server/src/eventLog.ts +73 -13
  150. package/server/src/historyLimits.ts +2 -0
  151. package/server/src/http/router.ts +1 -1
  152. package/server/src/index.ts +23 -0
  153. package/server/src/jsonlLines.ts +52 -0
  154. package/server/src/management/identity.ts +1 -0
  155. package/server/src/mcp/clusterMcpTools.ts +4 -4
  156. package/server/src/project/taskLedger.ts +7 -5
  157. package/server/src/providerConversation.ts +15 -0
  158. package/server/src/providers/claude-native/resumeSummary.ts +98 -50
  159. package/server/src/providers/claude-native/worker.ts +8 -4
  160. package/server/src/providers/claude.ts +2 -1
  161. package/server/src/providers/clusterTaskToolDefinitions.ts +4 -4
  162. package/server/src/providers/codex-appserver/catalog.ts +14 -1
  163. package/server/src/providers/codex.ts +2 -1
  164. package/server/src/providers/codexCodeMode.ts +4 -4
  165. package/server/src/providers/cursor/print.ts +2 -1
  166. package/server/src/providers/cursor/worker.ts +2 -1
  167. package/server/src/providers/llamacpp.ts +18 -7
  168. package/server/src/providers/llamacppRecovery.ts +2 -0
  169. package/server/src/providers/ollamaRecovery.ts +6 -6
  170. package/server/src/providers/ollamaResilience.ts +3 -3
  171. package/server/src/providers/ollamaTokens.ts +1 -1
  172. package/server/src/providers/ollamaToolSubset.ts +3 -3
  173. package/server/src/quota.ts +0 -50
  174. package/server/src/replacementHistory.ts +44 -0
  175. package/server/src/server/broadcast.ts +2 -0
  176. package/server/src/server/prompts.ts +8 -1
  177. package/server/src/sessionJsonl.ts +92 -32
  178. package/server/src/smartPickupAdapters.ts +17 -3
  179. package/server/src/transcriptWorker.ts +182 -0
  180. package/server/src/workflowStore.ts +21 -0
  181. package/server/src/ws/clusterHandlers.ts +43 -25
  182. package/server/src/ws/handoffHandlers.ts +5 -1
  183. package/server/src/ws/transcriptWorkerHandlers.ts +126 -0
  184. package/server/src/ws/turnEngine.ts +20 -8
  185. package/server/src/ws/updatePrimaryConfig.ts +25 -6
  186. package/server/src/ws/workflowHandlers.ts +3 -1
  187. package/shared/dist/clusterCoordination.d.ts +2 -0
  188. package/shared/dist/clusterCoordination.js +5 -1
  189. package/shared/dist/protocol/clientMessages.d.ts +3 -2
  190. package/shared/dist/protocol/clusters.d.ts +13 -1
  191. package/shared/dist/protocol/index.d.ts +1 -0
  192. package/shared/dist/protocol/index.js +1 -0
  193. package/shared/dist/protocol/models.d.ts +4 -3
  194. package/shared/dist/protocol/models.js +26 -2
  195. package/shared/dist/protocol/serverMessages.d.ts +2 -1
  196. package/shared/dist/protocol/tasks.d.ts +4 -0
  197. package/shared/dist/protocol/transcriptWorker.d.ts +47 -0
  198. package/shared/dist/protocol/transcriptWorker.js +2 -0
  199. package/shared/dist/runtimeVersions.d.ts +1 -0
  200. package/shared/dist/runtimeVersions.js +14 -0
  201. package/shared/src/clusterCoordination.ts +7 -1
  202. package/shared/src/protocol/clientMessages.ts +5 -0
  203. package/shared/src/protocol/clusters.ts +16 -1
  204. package/shared/src/protocol/index.ts +1 -0
  205. package/shared/src/protocol/models.ts +31 -5
  206. package/shared/src/protocol/serverMessages.ts +2 -0
  207. package/shared/src/protocol/settings.ts +2 -3
  208. package/shared/src/protocol/tasks.ts +4 -7
  209. package/shared/src/protocol/transcriptWorker.ts +49 -0
  210. package/shared/src/runtimeVersions.ts +14 -0
@@ -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;
@@ -275,6 +277,29 @@ function withClusterMetaLock<T>(clusterId: string, fn: () => Promise<T>): Promis
275
277
  return withFileLock(clusterMetaPath(clusterId), fn);
276
278
  }
277
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
+
278
303
  async function writeMetaAtomic(state: ClusterState): Promise<void> {
279
304
  const path = clusterMetaPath(state.clusterId);
280
305
  // proper-lockfile needs the file to exist before lock(); seed an empty
@@ -446,6 +471,7 @@ export async function addMember(
446
471
  );
447
472
  }
448
473
  const next: ClusterState = { ...state, members: [...state.members, workflowId] };
474
+ if (next.skillPins?.length) await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
449
475
  await writeMetaAtomic(next);
450
476
  rebuildIndexFor(next);
451
477
  memberJoined?.(clusterId, workflowId);
@@ -538,6 +564,7 @@ export async function replaceMember(
538
564
  oldWorkflowId: string,
539
565
  newWorkflowId: string,
540
566
  accessMode?: ClusterMemberAccessMode,
567
+ role?: string,
541
568
  ): Promise<ClusterState | null> {
542
569
  return withClusterMetaLock(clusterId, async () => {
543
570
  const state = await readCluster(clusterId);
@@ -566,6 +593,16 @@ export async function replaceMember(
566
593
  memberFocuses: remapSparse(state.memberFocuses, oldWorkflowId, newWorkflowId),
567
594
  memberAccessModes: Object.keys(nextModes).length > 0 ? nextModes : undefined,
568
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);
569
606
  if (nextMode === 'isolated') {
570
607
  await fs.mkdir(isolatedWorkspaceFor(clusterId, newWorkflowId), { recursive: true, mode: 0o700 });
571
608
  }
@@ -686,6 +723,7 @@ export async function setMemberRole(
686
723
  const next: ClusterState = Object.keys(nextRoles).length === 0
687
724
  ? { ...state, memberRoles: undefined }
688
725
  : { ...state, memberRoles: nextRoles };
726
+ if (!options.restoringSnapshot && next.skillPins?.length) await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
689
727
  await writeMetaAtomic(next);
690
728
  rebuildIndexFor(next);
691
729
  return next;
@@ -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; });