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
@@ -1,4 +1,5 @@
1
- import { ensureWorkflowMetadata, providerConversationState, saveProviderSession, announceReplacementConversation, markConversationReading } from '../providerConversation.js';
1
+ import { resolveWorkflowSkillPins } from '../clusterSkills.js';
2
+ import { ensureWorkflowMetadata, providerConversationState, saveProviderSession, announceReplacementConversation, markConversationReading, reportHistoryLoadFailure } from '../providerConversation.js';
2
3
  import { mintHandoffHistoryCapability } from '../http/handoffHistoryRoutes.js';
3
4
  import { deliverAfterTurnRevoked } from './taskLifecycle.js';
4
5
  import { resolveClaudeTransport } from '../claudeTransport.js';
@@ -55,7 +56,7 @@ import { isAvailable } from '../quota.js';
55
56
  import { resolveProviderAccount } from '../providerAccounts.js';
56
57
  import { broadcastTransient, broadcastWorkflow, notifyClusterStateForWorkflow, send } from '../server/broadcast.js';
57
58
  import { FOREIGN_WARN_DEBOUNCE_MS, FOREIGN_WRITE_BLOCK_MS, PORT, SESSION_HISTORY_PAGE_SIZE } from '../server/constants.js';
58
- import { buildLocalClusterSystemPrompt, LLAMACPP_PRIMARY_SYSTEM_PROMPT, OLLAMA_PRIMARY_SYSTEM_PROMPT } from '../server/prompts.js';
59
+ import { buildLocalClusterSystemPrompt, withLocalTurnWaitInstructions, LLAMACPP_PRIMARY_SYSTEM_PROMPT, OLLAMA_PRIMARY_SYSTEM_PROMPT } from '../server/prompts.js';
59
60
  import { buildGenesisSystemBlock } from '../genesis/prompts.js';
60
61
  import { CHAT_PROVIDERS, chatSystemPrompt, chatWebArmed, isChatWorkflow } from '../chatMode.js';
61
62
  import { resolveNativeInTurnCompactPercent, resolveTurnSettings } from './turnSettings.js';
@@ -65,7 +66,7 @@ import { sessions, workflows } from '../server/state.js';
65
66
  import { loadSessionJsonl, resolveSessionJsonlPath, watchSessionJsonl } from '../sessionJsonl.js';
66
67
  import { startUltracodeFleetWatcher } from '../ultracodeFleetWatcher.js';
67
68
  import { readSettings } from '../settings.js';
68
- import { buildPickedSkillsBlock, buildPinnedSkillsBlock, resolvePinnedSkills, buildSkillsManifest, listSkills, readSkillBody, readBuiltinSkill, } from '../skills.js';
69
+ import { buildPickedSkillsBlock, buildPinnedSkillsBlock, buildSkillsManifest, listSkills, readSkillBody, readBuiltinSkill, } from '../skills.js';
69
70
  import { ARCHITECTURE_REVIEW_SLUG, architectureReviewFacts } from '../architectureReview.js';
70
71
  import { artifactsDir } from '../workers/limits.js';
71
72
  import { readMeta, updateMeta, workflowDir } from '../workflowMeta.js';
@@ -239,10 +240,19 @@ export function startSessionWatcher(workflowId, wf, cwd, initialWs) {
239
240
  const current = () => workflows.get(workflowId) === wf && wf.primarySessionId === sessionId
240
241
  && sessionWatcherEpochs.get(wf) === epoch && wf.primary.provider === 'claude';
241
242
  const path = resolveSessionJsonlPath(cwd, sessionId);
242
- resolveClaudeTransport(wf, cwd).then((transport) => {
243
+ resolveClaudeTransport(wf, cwd).then(async (transport) => {
243
244
  if (!current() || transport === 'native')
244
245
  return null;
245
- return loadSessionJsonl(path);
246
+ try {
247
+ return await loadSessionJsonl(path);
248
+ }
249
+ catch (err) {
250
+ console.error(`[arco] [${workflowId.slice(0, 8)}] session history load failed:`, err);
251
+ if (!current())
252
+ return null;
253
+ reportHistoryLoadFailure(workflowId, wf, 'cli');
254
+ return { entries: [], byteLength: null };
255
+ }
246
256
  }).then((loaded) => {
247
257
  if (!loaded || !current())
248
258
  return;
@@ -314,7 +324,7 @@ export function startSessionWatcher(workflowId, wf, cwd, initialWs) {
314
324
  else {
315
325
  dispose(); // workflow gone — clean up immediately
316
326
  }
317
- console.log(`[arco] [${workflowId.slice(0, 8)}] session watcher started (${tail.length} emitted / ${earlier.length} deferred / ${entries.length} total, ${byteLength}B)`);
327
+ console.log(`[arco] [${workflowId.slice(0, 8)}] session watcher started (${tail.length} emitted / ${earlier.length} deferred / ${entries.length} total, ${byteLength === null ? 'offset pending' : `${byteLength}B`})`);
318
328
  }).catch((err) => {
319
329
  console.error(`[arco] [${workflowId.slice(0, 8)}] session watcher init failed:`, err);
320
330
  });
@@ -1762,8 +1772,9 @@ opts) {
1762
1772
  // pick, a project pin is an explicit operator vouch and bypasses discovery's
1763
1773
  // project-trust suppression. Missing files fail safe and stay visible.
1764
1774
  let pinnedSkillsBlock = '';
1765
- if (projectContextEnabled && wf.config.pinnedSkills?.length) {
1766
- const resolved = await resolvePinnedSkills(wf.config.pinnedSkills, cwd);
1775
+ const effectivePins = projectContextEnabled ? await resolveWorkflowSkillPins(workflowId, cwd, wf.config.pinnedSkills ?? []) : undefined;
1776
+ if (effectivePins?.refs.length) {
1777
+ const { resolved } = effectivePins;
1767
1778
  const built = buildPinnedSkillsBlock(resolved.skills);
1768
1779
  pinnedSkillsBlock = built.text;
1769
1780
  const skipped = [...resolved.missing, ...resolved.truncated];
@@ -1963,7 +1974,7 @@ opts) {
1963
1974
  const catalog = await listSkills(cwd, { includeProject });
1964
1975
  // A pinned body is already present in full; omit its progressive-
1965
1976
  // disclosure metadata to avoid duplicate/conflicting instructions.
1966
- const pinnedKeys = new Set((wf.config.pinnedSkills ?? []).map((s) => `${s.scope}:${s.slug}`));
1977
+ const pinnedKeys = new Set((effectivePins?.refs ?? []).map((s) => `${s.scope}:${s.slug}`));
1967
1978
  primarySkillsManifest = buildSkillsManifest({
1968
1979
  project: catalog.project.filter((s) => !pinnedKeys.has(`project:${s.slug}`)),
1969
1980
  global: catalog.global.filter((s) => !pinnedKeys.has(`global:${s.slug}`)),
@@ -2213,6 +2224,9 @@ opts) {
2213
2224
  turnClusterEfficiencyDoctrine = clusterEfficiency.buildDoctrine(turnClusterEfficiencyLevel, clusterStore.getEfficiencyAddendum(turnClusterId), turnClusterRole, clusterStore.getMessageGuard(turnClusterId));
2214
2225
  turnClusterProgressDoctrine = joinClusterDoctrines(buildClusterDirectorDoctrine(turnClusterRole), buildProgressDoctrine(clusterStore.getProgressTracking(turnClusterId), !!turnClusterPlan && turnClusterPlan.trim().length > 0, turnClusterTaskBoardAttached));
2215
2226
  }
2227
+ if (!chatMode && (wf.primary.provider === 'ollama' || wf.primary.provider === 'llamacpp' || wf.primary.provider === 'lmstudio' || wf.primary.provider === 'strata' || wf.primary.provider === 'deepseek')) {
2228
+ finalSystemPrompt = withLocalTurnWaitInstructions(finalSystemPrompt, turnClusterRole);
2229
+ }
2216
2230
  if (turnClusterId && (wf.primary.provider === 'ollama' || wf.primary.provider === 'llamacpp' || wf.primary.provider === 'lmstudio' || wf.primary.provider === 'strata' || wf.primary.provider === 'deepseek')) {
2217
2231
  if (clusterAccessMode === 'standard') {
2218
2232
  finalSystemPrompt = buildLocalClusterSystemPrompt({
@@ -9,13 +9,21 @@ import { updateMeta } from '../workflowMeta.js';
9
9
  import { withFileLock } from '../atomicFile.js';
10
10
  import { disposeProviderResources } from '../providers/index.js';
11
11
  import { refreshHubReporting } from '../management/initHubLink.js';
12
- import { buildPinnedSkillsBlock, resolvePinnedSkills } from '../skills.js';
12
+ import { buildPinnedSkillsBlock, resolvePinnedSkills, isValidSlug } from '../skills.js';
13
+ import { withClusterSkillLock } from '../clusterStore.js';
14
+ import { assertWorkflowSkillPins, uniqueSkillRefs } from '../clusterSkills.js';
13
15
  export async function handleUpdatePrimaryConfig(ws, session, msg) {
14
16
  const wf = workflows.get(msg.workflowId);
15
17
  if (!wf) {
16
18
  send(ws, { type: 'error', message: `Unknown workflow ${msg.workflowId.slice(0, 8)}` });
17
19
  return;
18
20
  }
21
+ if (wf.primary.provider === 'claude' && msg.effort !== undefined
22
+ && !['low', 'medium', 'high', 'xhigh', 'max'].includes(msg.effort)) {
23
+ send(ws, { type: 'error', workflowId: msg.workflowId,
24
+ message: 'Claude effort must be low, medium, high, xhigh or max; no settings were changed.' });
25
+ return;
26
+ }
19
27
  const proposedGoal = msg.goal === undefined ? wf.config.goal : capGoal(msg.goal);
20
28
  const proposedGoalRun = msg.goalRun === undefined ? undefined : normalizeGoalRunArm(msg.goalRun, !!proposedGoal?.trim());
21
29
  if (typeof proposedGoalRun === 'string') {
@@ -270,13 +278,24 @@ export async function handleUpdatePrimaryConfig(ws, session, msg) {
270
278
  // re-read at every turn; this snapshot is only the pin acknowledgement.
271
279
  let pinnedSkillsBroadcast;
272
280
  if (msg.pinnedSkills !== undefined) {
273
- const requested = Array.isArray(msg.pinnedSkills) ? msg.pinnedSkills : [];
274
- const resolved = await resolvePinnedSkills(requested, wf.config.workingDirectory);
275
- const refs = resolved.skills.map((s) => ({ scope: s.scope, slug: s.slug }));
276
- if (refs.length > 0)
277
- wf.config.pinnedSkills = refs;
278
- else
279
- delete wf.config.pinnedSkills;
281
+ const requested = uniqueSkillRefs((Array.isArray(msg.pinnedSkills) ? msg.pinnedSkills : []).filter(ref => ref && (ref.scope === 'project' || ref.scope === 'global') && isValidSlug(ref.slug)));
282
+ let resolved;
283
+ try {
284
+ resolved = await withClusterSkillLock(msg.workflowId, async () => {
285
+ await assertWorkflowSkillPins(msg.workflowId, wf.config.workingDirectory, requested);
286
+ const result = await resolvePinnedSkills(requested, wf.config.workingDirectory);
287
+ const refs = result.skills.map(s => ({ scope: s.scope, slug: s.slug }));
288
+ if (refs.length)
289
+ wf.config.pinnedSkills = refs;
290
+ else
291
+ delete wf.config.pinnedSkills;
292
+ return result;
293
+ });
294
+ }
295
+ catch (err) {
296
+ send(ws, { type: 'error', workflowId: msg.workflowId, message: err instanceof Error ? err.message : String(err) });
297
+ return;
298
+ }
280
299
  const block = buildPinnedSkillsBlock(resolved.skills);
281
300
  pinnedSkillsBroadcast = {
282
301
  skills: resolved.skills.map((s) => ({ scope: s.scope, slug: s.slug, name: s.name })),
@@ -12,7 +12,10 @@ export interface WorkflowHandlerDeps {
12
12
  }>) => Promise<void>;
13
13
  }
14
14
  export declare function initWorkflowHandlers(d: WorkflowHandlerDeps): void;
15
- export declare function handleCreateWorkflow(ws: WebSocket, session: Session, config: WorkflowConfig): Promise<void>;
15
+ export declare function handleCreateWorkflow(ws: WebSocket, session: Session, config: WorkflowConfig, options?: {
16
+ onCreated?: (workflowId: string) => void;
17
+ backgroundCreated?: boolean;
18
+ }): Promise<void>;
16
19
  export declare function appendPreviewHistory(arr: PreviewHistoryEntry[], entry: PreviewHistoryEntry): PreviewHistoryEntry[];
17
20
  export declare function handleSetPreviewPort(workflowId: string, port: number, framework: string | undefined, manual: boolean): Promise<void>;
18
21
  export declare function handleClearPreviewPort(workflowId: string): Promise<void>;
@@ -62,7 +62,7 @@ import { applyAutoHandoffDefault, applyClaudeNativeCompactDefault, broadcastQueu
62
62
  import { restoreCompactions } from '../compactionCounter.js';
63
63
  let deps;
64
64
  export function initWorkflowHandlers(d) { deps = d; }
65
- export async function handleCreateWorkflow(ws, session, config) {
65
+ export async function handleCreateWorkflow(ws, session, config, options) {
66
66
  let workflowId;
67
67
  let resumed = false;
68
68
  let resumeWorkflowMeta = null;
@@ -590,10 +590,12 @@ export async function handleCreateWorkflow(ws, session, config) {
590
590
  workflowId,
591
591
  config,
592
592
  ...hints,
593
+ ...(options?.backgroundCreated ? { backgroundCreated: true } : {}),
593
594
  ...(wfNowForCreate?.primary.provider === 'claude' && wfNowForCreate.primarySessionId
594
595
  ? { claudeSessionId: wfNowForCreate.primarySessionId }
595
596
  : {}),
596
597
  });
598
+ options?.onCreated?.(workflowId);
597
599
  // Genesis creation starts with the seed on config, but the right-panel UI
598
600
  // reads the normalized seed/readiness fields populated by genesis_seed_updated.
599
601
  // Echo it immediately so a fresh Genesis tab does not look like an ordinary
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco/server",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "private": true,
5
5
  "type": "module"
6
6
  }
@@ -2,8 +2,7 @@
2
2
  //
3
3
  // Before this module, ~20 call sites hand-rolled `write tmp -> rename`, 11 of
4
4
  // them via byte-identical private `atomicWrite` helpers. They shared three
5
- // defects (Odysseus delta audit, 2026-08-30 — docs/PERSISTENCE.md § Atomic
6
- // writes):
5
+ // defects (see docs/PERSISTENCE.md, Atomic writes):
7
6
  //
8
7
  // 1. NO fsync. `rename` is atomic for the directory entry, but the bytes may
9
8
  // still be in the page cache. A crash between write and flush can leave a
@@ -4,7 +4,7 @@ import { promises as fs } from 'fs';
4
4
  import { join } from 'path';
5
5
  import { homedir } from 'os';
6
6
  import { createHash } from 'crypto';
7
- import { CLAUDE_MODELS } from '@arco/shared';
7
+ import { CLAUDE_MODELS, compareCursorVersions } from '@arco/shared';
8
8
  import type { Capabilities, CliUpdateOutcome, EffortLevel, ModelName } from '@arco/shared';
9
9
  import { getStrataBase } from './providers/strata.js';
10
10
  import { getDeepSeekBase } from './providers/deepseek.js';
@@ -28,7 +28,8 @@ const MODELS: ModelName[] = [...CLAUDE_MODELS] as ModelName[];
28
28
  // Provider we know how to check/update from Arco. Not a union with
29
29
  // ProviderName because Ollama isn't a CLI and doesn't ship with a version
30
30
  // flag in the same sense.
31
- export type CliProvider = 'claude' | 'codex';
31
+ export type CliProvider = 'claude' | 'codex' | 'cursor';
32
+ const cliBinary = (provider: CliProvider): string => provider === 'cursor' ? 'cursor-agent' : provider;
32
33
 
33
34
  // 'unknown' = the CLI isn't installed (the PROVIDERS popover hides those rows).
34
35
  // 'broken' = it IS installed but the version probe failed. Keeping them distinct
@@ -96,7 +97,8 @@ export async function probeCapabilities(): Promise<Capabilities> {
96
97
  //
97
98
  // Source of truth for "is the operator running the latest CLI?" Claude reads
98
99
  // npm; Codex uses its installation decision and npm publication metadata;
99
- // Ollama queries GitHub Releases since it's not npm-installed. All are best-effort: any
100
+ // Ollama and llama.cpp query GitHub Releases since they are not npm-installed.
101
+ // Cursor reads the version embedded in its public installer as text. All are best-effort: any
100
102
  // failure (offline, rate-limited, schema drift) leaves that key undefined
101
103
  // and the UI falls back to displaying the installed version with no
102
104
  // outdated indicator. Caller decides cadence — boot + the existing 4h
@@ -130,6 +132,41 @@ async function ollamaLatestRelease(): Promise<string | undefined> {
130
132
  return undefined;
131
133
  }
132
134
 
135
+ async function llamacppLatestRelease(): Promise<string | undefined> {
136
+ // /releases/latest can be a semantic milestone older than the daily builds.
137
+ // Only numeric build tags can be compared to the installed binary's build.
138
+ const data = await fetchJson('https://api.github.com/repos/ggml-org/llama.cpp/releases?per_page=20');
139
+ if (!Array.isArray(data)) return undefined;
140
+ const builds = data.filter((release) => release && !release.draft)
141
+ .map((release) => typeof release.tag_name === 'string' && /^b[1-9]\d*$/.test(release.tag_name) ? Number(release.tag_name.slice(1)) : NaN)
142
+ .filter(Number.isSafeInteger);
143
+ return builds.length ? `b${Math.max(...builds)}` : undefined;
144
+ }
145
+
146
+ async function cursorLatestRelease(): Promise<string | undefined> {
147
+ try {
148
+ // Read the installer as bounded metadata only; never run fetched shell text.
149
+ const response = await fetch('https://cursor.com/install', { signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS) });
150
+ if (!response.ok || !response.body) return undefined;
151
+ const reader = response.body.getReader();
152
+ const chunks: Uint8Array[] = [];
153
+ let size = 0;
154
+ try {
155
+ while (true) {
156
+ const { done, value } = await reader.read();
157
+ if (done) break;
158
+ size += value.byteLength;
159
+ if (size > 64 * 1024) { await reader.cancel(); return undefined; }
160
+ chunks.push(value);
161
+ }
162
+ } finally { reader.releaseLock(); }
163
+ const script = Buffer.concat(chunks).toString('utf8');
164
+ const versions = new Set([...script.matchAll(/https:\/\/downloads\.cursor\.com\/(?:lab|stable)\/(\d{4}\.\d{2}\.\d{2}-[a-f0-9]{6,40})\//gi)].map(match => match[1]));
165
+ const version = versions.size === 1 ? [...versions][0] : undefined;
166
+ return version && compareCursorVersions(version, version) === 0 ? version : undefined;
167
+ } catch { return undefined; }
168
+ }
169
+
133
170
  export async function refreshRuntimeVersions(previous: Capabilities): Promise<Capabilities> {
134
171
  // Installed runtimes can change outside Arco. Refresh on demand without
135
172
  // probing every CLI/upstream registry or starting an inference service.
@@ -149,7 +186,7 @@ async function strataLatestRelease(): Promise<string | undefined> {
149
186
  }
150
187
 
151
188
  export async function probeLatestVersions(codexDecision = npmLatest('@openai/codex').then(probeCodexUpdate)): Promise<Capabilities['latestVersions']> {
152
- const [claude, codex, ollama, strata, xolotl] = await Promise.all([
189
+ const [claude, codex, ollama, strata, xolotl, llamacpp, cursor] = await Promise.all([
153
190
  npmLatest('@anthropic-ai/claude-code'),
154
191
  codexDecision.then((decision) => decision.targetVersion),
155
192
  ollamaLatestRelease(),
@@ -158,8 +195,10 @@ export async function probeLatestVersions(codexDecision = npmLatest('@openai/cod
158
195
  const sha = (data as { sha?: unknown } | null)?.sha;
159
196
  return typeof sha === 'string' && /^[a-f0-9]{40}$/.test(sha) ? sha : undefined;
160
197
  }),
198
+ llamacppLatestRelease(),
199
+ cursorLatestRelease(),
161
200
  ]);
162
- return { claude, codex, ollama, strata, xolotl };
201
+ return { claude, codex, ollama, strata, xolotl, llamacpp, cursor };
163
202
  }
164
203
 
165
204
  export interface UpdateResult {
@@ -181,16 +220,17 @@ export interface UpdateResult {
181
220
  }
182
221
 
183
222
  function versionForProvider(caps: Capabilities, provider: CliProvider): string {
184
- return provider === 'claude' ? caps.cliVersion : caps.codexVersion ?? 'unknown';
223
+ return provider === 'claude' ? caps.cliVersion : provider === 'cursor' ? caps.cursorVersion ?? 'unknown' : caps.codexVersion ?? 'unknown';
185
224
  }
186
225
 
187
226
  /**
188
227
  * Run the updater for the installation Arco actually launches. Claude uses its
189
228
  * built-in updater; Codex shares one installation decision with its version flag.
229
+ * Cursor also uses its own updater, with no installer or npm fallback.
190
230
  * Re-probe afterwards: a successful command alone does not prove a working CLI.
191
231
  */
192
232
  export async function runCliUpdate(previous: Capabilities, provider: CliProvider = 'claude', runCommand: (cmd: string, args: string[]) => Promise<UpdateCommandResult> = (cmd, args) => runUpdateCommand(cmd, args, provider)): Promise<UpdateResult> {
193
- const previousVersion = provider === 'codex' ? await probeVersion('codex') : versionForProvider(previous, provider);
233
+ const previousVersion = provider === 'claude' ? versionForProvider(previous, provider) : await probeVersion(cliBinary(provider));
194
234
  // Pre-flight: for npm-installed CLIs, work out which version can actually run
195
235
  // on this machine before installing anything. `@latest` is not automatically
196
236
  // installable — a package whose binary ships as a platform-specific
@@ -199,7 +239,7 @@ export async function runCliUpdate(previous: Capabilities, provider: CliProvider
199
239
  // and npm reports that as success. See npmPlatformResolve.ts.
200
240
  const decision: CliUpdateDecision = provider === 'codex'
201
241
  ? await probeCodexUpdate(await npmLatest('@openai/codex'))
202
- : { kind: 'unknown' as const, command: { cmd: 'claude', args: ['update'] }, targetVersion: previous.latestVersions?.claude };
242
+ : { kind: 'unknown' as const, command: { cmd: cliBinary(provider), args: ['update'] }, targetVersion: previous.latestVersions?.[provider] };
203
243
  const notice = decision.notice;
204
244
  const capabilities = provider === 'codex'
205
245
  ? { ...previous, codexVersion: previousVersion, latestVersions: { ...previous.latestVersions, codex: decision.targetVersion }, codexUpdate: { kind: decision.kind, updateAvailable: !!decision.targetVersion && (compareVersions(previousVersion, decision.targetVersion) ?? 0) < 0, instruction: decision.message ?? decision.notice } }
@@ -241,7 +281,7 @@ export async function runCliUpdate(previous: Capabilities, provider: CliProvider
241
281
  // the previous executable still runs and reports the same version.
242
282
  const report = describeCliUpdate(provider, previousVersion, currentVersion, next.latestVersions?.[provider], commandResult, notice);
243
283
  if (report.outcome === 'failed' && commandResult.exitCode === 0) {
244
- const reason = await probeFailureReason(provider);
284
+ const reason = await probeFailureReason(cliBinary(provider));
245
285
  if (reason) { report.error = reason; report.message = reason; }
246
286
  }
247
287
  return { provider, previousVersion, currentVersion, capabilities: next, output: commandResult.output,
@@ -275,14 +315,15 @@ async function runUpdateCommand(cmd: string, args: string[], provider: CliProvid
275
315
 
276
316
  const SNAPSHOT_DIR = join(arcoHome(), 'cli-snapshots');
277
317
 
278
- const HELP_PROBES: Record<CliProvider, string[][]> = {
318
+ type HelpProvider = Exclude<CliProvider, 'cursor'>;
319
+ const HELP_PROBES: Record<HelpProvider, string[][]> = {
279
320
  claude: [['--help'], ['config', '--help'], ['mcp', '--help']],
280
321
 
281
322
  codex: [['--help'], ['exec', '--help']],
282
323
  };
283
324
 
284
325
  export interface CliChange {
285
- provider: CliProvider;
326
+ provider: HelpProvider;
286
327
  fromVersion: string;
287
328
  toVersion: string;
288
329
  newFlags: string[];
@@ -296,16 +337,16 @@ interface SnapshotMeta {
296
337
  seenAt: number;
297
338
  }
298
339
 
299
- async function runHelpProbe(bin: CliProvider, args: string[]): Promise<string | null> {
340
+ async function runHelpProbe(bin: HelpProvider, args: string[]): Promise<string | null> {
300
341
  try {
301
- const { stdout } = await execFileAsync(...commandArgs(bin, args), CLI_PROBE_OPTIONS);
342
+ const { stdout } = await execFileAsync(...commandArgs(cliBinary(bin), args), CLI_PROBE_OPTIONS);
302
343
  return stdout;
303
344
  } catch {
304
345
  return null; // flag not supported on this version — skip silently
305
346
  }
306
347
  }
307
348
 
308
- async function snapshotHelp(provider: CliProvider): Promise<{ text: string; hash: string }> {
349
+ async function snapshotHelp(provider: HelpProvider): Promise<{ text: string; hash: string }> {
309
350
  const chunks: string[] = [];
310
351
  for (const args of HELP_PROBES[provider]) {
311
352
  const out = await runHelpProbe(provider, args);
@@ -324,7 +365,7 @@ function extractFlags(helpText: string): Set<string> {
324
365
  return flags;
325
366
  }
326
367
 
327
- async function readPriorSnapshot(provider: CliProvider): Promise<{ text: string; meta: SnapshotMeta } | null> {
368
+ async function readPriorSnapshot(provider: HelpProvider): Promise<{ text: string; meta: SnapshotMeta } | null> {
328
369
  try {
329
370
  const text = await fs.readFile(join(SNAPSHOT_DIR, `${provider}.txt`), 'utf8');
330
371
  const meta = JSON.parse(await fs.readFile(join(SNAPSHOT_DIR, `${provider}.meta.json`), 'utf8')) as SnapshotMeta;
@@ -334,7 +375,7 @@ async function readPriorSnapshot(provider: CliProvider): Promise<{ text: string;
334
375
  }
335
376
  }
336
377
 
337
- async function writeSnapshot(provider: CliProvider, text: string, meta: SnapshotMeta): Promise<void> {
378
+ async function writeSnapshot(provider: HelpProvider, text: string, meta: SnapshotMeta): Promise<void> {
338
379
  await fs.mkdir(SNAPSHOT_DIR, { recursive: true });
339
380
  // Both files atomically: a truncated `.txt` paired with a valid `.meta.json`
340
381
  // reads back as a real snapshot and renders a large bogus capability diff to
@@ -362,7 +403,7 @@ function simpleDiff(oldText: string, newText: string): string {
362
403
  * baseline silently and are NOT reported as changes.
363
404
  */
364
405
  export async function detectCliChanges(caps: Capabilities): Promise<CliChange[]> {
365
- const providers: CliProvider[] = ['claude', 'codex'];
406
+ const providers: HelpProvider[] = ['claude', 'codex'];
366
407
  const changes: CliChange[] = [];
367
408
  for (const p of providers) {
368
409
  const currentVersion = versionForProvider(caps, p);
@@ -3,7 +3,7 @@ import { promises as fs, constants, statSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { promisify } from 'node:util';
6
- import type { CliUpdateOutcome } from '@arco/shared';
6
+ import { compareCursorVersions, type CliUpdateOutcome } from '@arco/shared';
7
7
  import { commandArgs, findWindowsCommand, npmShimTarget } from './windowsCommand.js';
8
8
  import { resolveInstallableVersion, type ResolvedInstall } from './npmPlatformResolve.js';
9
9
  import { compareVersions } from './updateCheck.js';
@@ -138,7 +138,8 @@ export async function probeCodexUpdate(published?: string): Promise<CliUpdateDec
138
138
  export interface UpdateCommandResult { output: string; exitCode: number; }
139
139
 
140
140
  export function describeCliUpdate(provider: string, previous: string, current: string, target: string | undefined, command: UpdateCommandResult, notice?: string): { outcome: CliUpdateOutcome; message: string; updated: boolean; error?: string } {
141
- const name = provider === 'codex' ? 'Codex' : 'Claude CLI';
141
+ const name = provider === 'codex' ? 'Codex' : provider === 'cursor' ? 'Cursor' : 'Claude CLI';
142
+ const compare = provider === 'cursor' ? (a: string, b: string) => compareCursorVersions(a, b) ?? null : compareVersions;
142
143
  if (command.exitCode !== 0) {
143
144
  const error = `${name} update failed: ${command.output.trim().slice(0, 2000) || `exit code ${command.exitCode}`}`;
144
145
  return { outcome: 'failed', message: error, updated: false, error };
@@ -147,11 +148,11 @@ export function describeCliUpdate(provider: string, previous: string, current: s
147
148
  const error = `${name} did not run after the update.`;
148
149
  return { outcome: 'failed', message: error, updated: false, error };
149
150
  }
150
- if (previous !== current && (compareVersions(current, previous) ?? 1) > 0) {
151
+ if (previous !== current && (compare(current, previous) ?? 1) > 0) {
151
152
  return { outcome: 'updated', message: `Updated ${name} from v${previous} to v${current}.${notice ? ` ${notice}` : ''}`, updated: true };
152
153
  }
153
154
  if (notice) return { outcome: 'deferred', message: notice, updated: false };
154
- const comparison = target ? compareVersions(current, target) : null;
155
+ const comparison = target ? compare(current, target) : null;
155
156
  if (comparison !== null && comparison >= 0) return { outcome: 'current', message: `${name} v${current} is up to date for this installation.`, updated: false };
156
157
  return { outcome: 'unchanged', updated: false, message: comparison !== null
157
158
  ? `${name} did not change; v${target} is still available.`
@@ -17,8 +17,8 @@ export function buildClusterDirectorDoctrine(role: string | undefined): string |
17
17
  'When this cluster has an Advisor, consult it before a design decision or when the evidence is thin; the decision remains yours.',
18
18
  'Delegate implementation, builds, and test runs only through peer_send and track them on the board. Do not write or edit product code or tests yourself.',
19
19
  'Stay available to the operator. Hand long-running work to peers: the project\'s checks to the tester (or a builder when there is no tester), CI watching to the change\'s author. Use their reports of what was done, run and not covered; do not run builds, test suites or CI waits yourself.',
20
- 'Never wait inside a turn: no sleep or polling longer than 60 seconds at a time. When the next step depends on a peer or on CI, say what is pending and end the turn; reports arrive as mail.',
21
20
  'Landing is yours: read the complete accepted diff, check that what the project requires was run, then commit and push per project rules. Ask the peer for missing or stale results rather than regenerating them yourself. Do not invent a gate where the project has none. Do not turn a one-off incident into a standing rule or permanent test without the operator.',
21
+ 'When a task is met, sign it off with a plain operator-facing summary without commit hashes. A met sign-off closes it unless Board auto-done is off in Settings. Tell the operator in chat what to try.',
22
22
  'Before a failure holds work up, say what a user would lose if it were real; note cosmetic or momentary faults and carry on.',
23
23
  'A red check must mean something. Sort each failure first: a fault in the product, or a fault in a test, a housekeeping rule or the CI service. Fix product faults. When the test or rule is at fault, fix it, skip it on that system with a stated reason, or delete it, so the check goes green and can be trusted; do not release over a red check and do not leave one red. Rerun alone a job the CI service dropped. Keep CI to checks whose failure tells the operator something about the product, and small enough to pass in one run; housekeeping findings warn, they do not fail a run.',
24
24
  'When reading a diff, also check its shape: a second implementation of existing logic, a wrapper that only passes calls through, tests that miss the module\'s interface, or one change spread over many places. These findings are advisory unless they meet the blocking rules; record them as tasks.',
@@ -30,6 +30,7 @@
30
30
  // `broadcastWorkflow` so persistAndStampSeq stamps every event into the
31
31
  // recipient's events.jsonl.
32
32
 
33
+ import { readSettings } from './settings.js';
33
34
  import { recipientContext, type RecipientContext } from './peerRecipientContext.js';
34
35
  import { createHash } from 'node:crypto';
35
36
  import { promises as fs } from 'node:fs';
@@ -968,11 +969,8 @@ function taskDependsOn(tasks: LedgerTask[], fromId: string, targetId: string, se
968
969
  return task.parentIds.some((parentId) => taskDependsOn(tasks, parentId, targetId, seen));
969
970
  }
970
971
 
971
- // Update a task's status and/or notes. Workers may set non-terminal workflow
972
- // statuses. `done` / `archived` are REJECTED here — the
973
- // operator-confirmed-done invariant (§D1) is re-enforced at the peer layer:
974
- // only the operator's WS task_ledger_update may reach applyUpdate with those
975
- // terminal statuses.
972
+ // Workers may set non-terminal statuses. Direct done / archived requests are
973
+ // rejected; a director met sign-off may close the task when auto-done is on.
976
974
  const SIGNOFF_STATES: ReadonlySet<TaskSignoffState> = new Set(['met', 'not_met', 'partial']);
977
975
 
978
976
  export async function peerTaskUpdate(
@@ -983,7 +981,7 @@ export async function peerTaskUpdate(
983
981
  notes?: string;
984
982
  // Release label such as "0.1.4"; an empty string clears it.
985
983
  release?: string;
986
- // §D3 — the director's advisory verdict. The model passes `{ state, summary }`;
984
+ // The director verdict. The model passes `{ state, summary }`;
987
985
  // the server stamps `byWorkflowId`/`at` so it's attributable and unspoofable.
988
986
  // `null` explicitly clears a prior sign-off (back to PENDING).
989
987
  signoff?: { state?: string; summary?: string } | null;
@@ -998,7 +996,7 @@ export async function peerTaskUpdate(
998
996
  message: 'done/archived can only be set by the operator from the LEDGER tab. Move the task to review, set blocked, or report completion via peer_send to the director.',
999
997
  };
1000
998
  }
1001
- // Build the server-stamped sign-off (advisory; never a terminal status).
999
+ // Stamp the sign-off at the peer boundary so its author cannot be spoofed.
1002
1000
  let signoffPatch: TaskSignoff | null | undefined;
1003
1001
  if (args.signoff === null) {
1004
1002
  signoffPatch = null;
@@ -1031,10 +1029,15 @@ export async function peerTaskUpdate(
1031
1029
  if (!board) {
1032
1030
  return { ok: false, code: 'board_detached', message: 'no task board is enabled for this cluster.' };
1033
1031
  }
1032
+ const director = isClusterDirector(clusterStore.getMemberRole(ctx.clusterId, ctx.workflowId));
1033
+ const autoMarkDone = director && signoffPatch?.state === 'met' && (await readSettings()).autoMarkDoneOnMetSignoff !== false;
1034
1034
  let rejection: PeerTaskRejection | null = null;
1035
1035
  const result = await persistLedgerMutation(ctx.workflowId, board.cwd, 'update', (tasks) => {
1036
+ const previous = tasks.find((task) => task.id === args.id);
1037
+ const close = director && autoMarkDone && signoffPatch?.state === 'met' && previous?.status !== 'done' && previous?.status !== 'archived';
1036
1038
  const applied = taskLedger.applyUpdate(tasks, args.id, {
1037
- ...(args.status ? { status: args.status } : {}),
1039
+ ...(close ? { directorClosure: { byWorkflowId: ctx.workflowId, at: signoffPatch!.at } } : {}),
1040
+ ...(close ? { status: 'done' as const } : args.status ? { status: args.status } : {}),
1038
1041
  ...(typeof args.notes === 'string' ? { notes: args.notes } : {}),
1039
1042
  ...(typeof args.release === 'string' ? { release: args.release } : {}),
1040
1043
  ...(signoffPatch !== undefined ? { signoff: signoffPatch } : {}),
@@ -40,7 +40,7 @@ const PLAN_CLAUSE = [
40
40
 
41
41
  const BOARD_CLAUSE = [
42
42
  'Keep the task board current.',
43
- 'Move each task through its statuses (todo → in_progress → review) as the work actually progresses, and report completion so the operator can mark it done (done/archived stay operator-only).',
43
+ 'Move each task through its statuses (todo → in_progress → review) as the work actually progresses, and report completion for director review; a met sign-off closes the task unless Board auto-done is off in Settings. Direct done/archived status changes stay operator-only.',
44
44
  'Do not leave finished work sitting in an earlier status.',
45
45
  ].join(' ');
46
46
 
@@ -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,