arco-workbench 0.1.7 → 0.1.9

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 (301) hide show
  1. package/CONTRIBUTING.md +63 -12
  2. package/README.md +21 -17
  3. package/client/dist/assets/{PhosphorBackdrop-DVQdBrTw.js → PhosphorBackdrop-DRu16-Is.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-BfSs2tB4.js → ThemedBackgroundShaderImpl-BLdwwQ4D.js} +1 -1
  5. package/client/dist/assets/{XtermView-DaMjC8Ny.js → XtermView-Xk7_9JaH.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-BCQnXj7R.js → galleryEditor-CI8ClzBa.js} +1 -1
  7. package/client/dist/assets/{index-DD9kFGsF.css → index-BEFgrUJJ.css} +1 -1
  8. package/client/dist/assets/{index-COfbHCYv.js → index-C7WzZfsr.js} +257 -255
  9. package/client/dist/index.html +2 -2
  10. package/client/src/App.tsx +2 -0
  11. package/client/src/components/ChatMessage.tsx +33 -8
  12. package/client/src/components/ChatModeView.tsx +2 -0
  13. package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +65 -15
  14. package/client/src/components/ClusterRightPanel/SkillsControl.tsx +124 -0
  15. package/client/src/components/ClusterRightPanel/index.tsx +4 -0
  16. package/client/src/components/ClusterTaskBoardTab.tsx +9 -22
  17. package/client/src/components/CodexLateCommand.tsx +34 -0
  18. package/client/src/components/DialogShell.tsx +2 -0
  19. package/client/src/components/MemberCard.tsx +4 -1
  20. package/client/src/components/MemberPane.tsx +3 -1
  21. package/client/src/components/NeedsYouBadge.tsx +3 -3
  22. package/client/src/components/PhoneUpload.tsx +288 -0
  23. package/client/src/components/PrimaryStatus.tsx +14 -6
  24. package/client/src/components/ProviderReleasesModal.tsx +8 -4
  25. package/client/src/components/ProvidersPopover.tsx +28 -23
  26. package/client/src/components/RuntimeStateBanner.tsx +5 -0
  27. package/client/src/components/SettingsPanel.tsx +2 -2
  28. package/client/src/components/SkillEditorDialog.tsx +2 -2
  29. package/client/src/components/SkillsSettings.tsx +21 -4
  30. package/client/src/components/TabBar.tsx +91 -9
  31. package/client/src/components/TerminalInput.tsx +15 -11
  32. package/client/src/components/TranscriptSendDialog.tsx +12 -8
  33. package/client/src/components/TranscriptWorkerDialog.tsx +119 -0
  34. package/client/src/components/WorkflowView.tsx +2 -0
  35. package/client/src/components/clusterNeedsYou.ts +11 -18
  36. package/client/src/explorer/ArtifactsLens.tsx +37 -28
  37. package/client/src/explorer/ExplorerApp.tsx +5 -4
  38. package/client/src/explorer/types.ts +8 -3
  39. package/client/src/help/content/cluster.tsx +48 -17
  40. package/client/src/help/content/composer.tsx +40 -1
  41. package/client/src/help/content/header.tsx +18 -1
  42. package/client/src/help/content/misc.tsx +9 -1
  43. package/client/src/help/content/settings.tsx +18 -4
  44. package/client/src/help/content/tabbar.tsx +5 -0
  45. package/client/src/help/manualSections/actions.tsx +31 -0
  46. package/client/src/help/manualSections/clusters.tsx +44 -20
  47. package/client/src/help/manualSections/configuration.tsx +20 -0
  48. package/client/src/help/manualSections/gettingStarted.tsx +4 -4
  49. package/client/src/help/manualSections/maintenance.tsx +25 -6
  50. package/client/src/help/manualSections/powerFeatures.tsx +3 -2
  51. package/client/src/help/manualSections/providers.tsx +32 -8
  52. package/client/src/help/manualSections/troubleshooting.tsx +2 -1
  53. package/client/src/help/manualSections/workflows.tsx +12 -0
  54. package/client/src/help/manualSections/workspace.tsx +36 -0
  55. package/client/src/stores/appStore.ts +7 -0
  56. package/client/src/stores/appStore.types.ts +4 -0
  57. package/client/src/styles/global.css +109 -0
  58. package/client/src/utils/phoneTheme.ts +38 -0
  59. package/client/src/utils/phoneUploadApi.ts +10 -0
  60. package/client/src/utils/transcriptWorkerRequest.ts +24 -0
  61. package/client/src/ws/handleServerMessage.ts +31 -8
  62. package/docs/ARCHITECTURE.md +1 -1
  63. package/docs/CLIENT.md +16 -9
  64. package/docs/FEATURES.md +13 -7
  65. package/docs/GETTING_STARTED.md +12 -6
  66. package/docs/GOTCHAS.md +2 -1
  67. package/docs/INDEX.md +1 -1
  68. package/docs/OPERATIONS.md +213 -52
  69. package/docs/PERSISTENCE.md +7 -2
  70. package/docs/PRIMITIVES.md +42 -0
  71. package/docs/PROTOCOL_CLUSTER.md +51 -4
  72. package/docs/PROTOCOL_PRIMITIVES.md +39 -0
  73. package/docs/PROVIDERS.md +84 -13
  74. package/docs/SETTINGS.md +29 -3
  75. package/docs/TASK_LEDGER.md +7 -15
  76. package/native/linux-x64/manifest.json +1 -1
  77. package/native/win32-x64/manifest.json +1 -1
  78. package/node_modules/@arco/shared/dist/clusterCoordination.d.ts +2 -0
  79. package/node_modules/@arco/shared/dist/clusterCoordination.js +5 -1
  80. package/node_modules/@arco/shared/dist/protocol/chat.d.ts +1 -0
  81. package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +3 -2
  82. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -1
  83. package/node_modules/@arco/shared/dist/protocol/index.d.ts +1 -0
  84. package/node_modules/@arco/shared/dist/protocol/index.js +1 -0
  85. package/node_modules/@arco/shared/dist/protocol/models.d.ts +4 -3
  86. package/node_modules/@arco/shared/dist/protocol/models.js +26 -2
  87. package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +13 -1
  88. package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +4 -0
  89. package/node_modules/@arco/shared/dist/protocol/transcriptWorker.d.ts +47 -0
  90. package/node_modules/@arco/shared/dist/protocol/transcriptWorker.js +2 -0
  91. package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
  92. package/node_modules/@arco/shared/dist/runtimeVersions.d.ts +1 -0
  93. package/node_modules/@arco/shared/dist/runtimeVersions.js +14 -0
  94. package/node_modules/@arco/shared/package.json +1 -1
  95. package/package.json +2 -2
  96. package/scripts/packaging/arco.mjs +1 -1
  97. package/scripts/packaging/native-repair.mjs +32 -4
  98. package/server/dist/atomicFile.js +1 -2
  99. package/server/dist/capabilities.d.ts +5 -2
  100. package/server/dist/capabilities.js +59 -9
  101. package/server/dist/cliUpdateDecision.d.ts +1 -1
  102. package/server/dist/cliUpdateDecision.js +5 -3
  103. package/server/dist/clusterDirector.js +2 -1
  104. package/server/dist/clusterPeerOps.js +14 -8
  105. package/server/dist/clusterProgress.js +1 -1
  106. package/server/dist/clusterRehydrate.js +2 -0
  107. package/server/dist/clusterSkills.d.ts +13 -0
  108. package/server/dist/clusterSkills.js +81 -0
  109. package/server/dist/clusterSnapshots.js +2 -0
  110. package/server/dist/clusterStore.d.ts +7 -2
  111. package/server/dist/clusterStore.js +42 -1
  112. package/server/dist/diagnostics/codeSkew.js +1 -0
  113. package/server/dist/eventLog.d.ts +7 -0
  114. package/server/dist/eventLog.js +70 -13
  115. package/server/dist/explorerDocs.d.ts +10 -6
  116. package/server/dist/explorerDocs.js +75 -34
  117. package/server/dist/historyLimits.d.ts +1 -0
  118. package/server/dist/historyLimits.js +3 -0
  119. package/server/dist/http/attachmentUpload.d.ts +13 -0
  120. package/server/dist/http/attachmentUpload.js +38 -0
  121. package/server/dist/http/browserWorktrees.d.ts +23 -0
  122. package/server/dist/http/browserWorktrees.js +120 -0
  123. package/server/dist/http/phoneUploadDrafts.d.ts +13 -0
  124. package/server/dist/http/phoneUploadDrafts.js +125 -0
  125. package/server/dist/http/phoneUploadListener.d.ts +17 -0
  126. package/server/dist/http/phoneUploadListener.js +81 -0
  127. package/server/dist/http/phoneUploadNetwork.d.ts +9 -0
  128. package/server/dist/http/phoneUploadNetwork.js +106 -0
  129. package/server/dist/http/phoneUploadPage.d.ts +2 -0
  130. package/server/dist/http/phoneUploadPage.js +136 -0
  131. package/server/dist/http/phoneUploadRouteHistory.d.ts +4 -0
  132. package/server/dist/http/phoneUploadRouteHistory.js +72 -0
  133. package/server/dist/http/phoneUploadRoutes.d.ts +4 -0
  134. package/server/dist/http/phoneUploadRoutes.js +419 -0
  135. package/server/dist/http/phoneUploadTheme.d.ts +17 -0
  136. package/server/dist/http/phoneUploadTheme.js +96 -0
  137. package/server/dist/http/projectBinding.d.ts +1 -0
  138. package/server/dist/http/projectBinding.js +3 -2
  139. package/server/dist/http/readConfinement.js +5 -1
  140. package/server/dist/http/router.js +14 -25
  141. package/server/dist/http/writeConfinement.js +19 -2
  142. package/server/dist/index.js +24 -1
  143. package/server/dist/jsonlLines.d.ts +4 -0
  144. package/server/dist/jsonlLines.js +53 -0
  145. package/server/dist/management/identity.js +1 -0
  146. package/server/dist/mcp/clusterMcpTools.js +4 -4
  147. package/server/dist/primitives/seedWorker.d.ts +1 -0
  148. package/server/dist/primitives/seedWorker.js +2 -1
  149. package/server/dist/project/taskLedger.d.ts +4 -0
  150. package/server/dist/project/taskLedger.js +7 -4
  151. package/server/dist/providerConversation.d.ts +1 -0
  152. package/server/dist/providerConversation.js +17 -0
  153. package/server/dist/providers/claude-native/resumeSummary.d.ts +9 -0
  154. package/server/dist/providers/claude-native/resumeSummary.js +102 -49
  155. package/server/dist/providers/claude-native/worker.js +8 -4
  156. package/server/dist/providers/claude.js +2 -1
  157. package/server/dist/providers/clusterTaskToolDefinitions.js +4 -4
  158. package/server/dist/providers/codex-appserver/catalog.js +16 -1
  159. package/server/dist/providers/codex-appserver/heldCommands.d.ts +14 -0
  160. package/server/dist/providers/codex-appserver/heldCommands.js +54 -0
  161. package/server/dist/providers/codex-appserver/index.d.ts +52 -2
  162. package/server/dist/providers/codex-appserver/index.js +239 -21
  163. package/server/dist/providers/codex-appserver/lateCommands.d.ts +62 -0
  164. package/server/dist/providers/codex-appserver/lateCommands.js +195 -0
  165. package/server/dist/providers/codex-appserver/worker.d.ts +23 -1
  166. package/server/dist/providers/codex-appserver/worker.js +89 -20
  167. package/server/dist/providers/codex.js +2 -1
  168. package/server/dist/providers/codexCodeMode.d.ts +2 -1
  169. package/server/dist/providers/codexCodeMode.js +8 -3
  170. package/server/dist/providers/cursor/print.js +2 -1
  171. package/server/dist/providers/cursor/worker.js +2 -1
  172. package/server/dist/providers/llamacpp.js +17 -8
  173. package/server/dist/providers/ollamaRecovery.js +6 -6
  174. package/server/dist/providers/ollamaResilience.js +3 -3
  175. package/server/dist/providers/ollamaTokens.js +1 -1
  176. package/server/dist/quota.d.ts +0 -18
  177. package/server/dist/quota.js +0 -44
  178. package/server/dist/replacementHistory.d.ts +19 -0
  179. package/server/dist/replacementHistory.js +49 -0
  180. package/server/dist/server/broadcast.d.ts +2 -1
  181. package/server/dist/server/broadcast.js +1 -0
  182. package/server/dist/server/prompts.d.ts +1 -0
  183. package/server/dist/server/prompts.js +6 -1
  184. package/server/dist/sessionJsonl.d.ts +1 -1
  185. package/server/dist/sessionJsonl.js +115 -40
  186. package/server/dist/smartPickupAdapters.js +15 -2
  187. package/server/dist/transcriptWorker.d.ts +34 -0
  188. package/server/dist/transcriptWorker.js +201 -0
  189. package/server/dist/workers/WorkerManager.d.ts +1 -0
  190. package/server/dist/workers/WorkerManager.js +1 -0
  191. package/server/dist/workers/processKill.d.ts +9 -1
  192. package/server/dist/workers/processKill.js +26 -10
  193. package/server/dist/workflowStore.d.ts +1 -0
  194. package/server/dist/workflowStore.js +31 -0
  195. package/server/dist/ws/clusterHandlers.d.ts +1 -0
  196. package/server/dist/ws/clusterHandlers.js +62 -26
  197. package/server/dist/ws/handoffHandlers.js +7 -2
  198. package/server/dist/ws/transcriptWorkerHandlers.d.ts +25 -0
  199. package/server/dist/ws/transcriptWorkerHandlers.js +139 -0
  200. package/server/dist/ws/turnEngine.js +40 -9
  201. package/server/dist/ws/updatePrimaryConfig.js +27 -8
  202. package/server/dist/ws/workflowHandlers.d.ts +4 -1
  203. package/server/dist/ws/workflowHandlers.js +3 -1
  204. package/server/package.json +1 -1
  205. package/server/src/atomicFile.ts +1 -2
  206. package/server/src/capabilities.ts +58 -17
  207. package/server/src/cliUpdateDecision.ts +5 -4
  208. package/server/src/clusterDirector.ts +2 -1
  209. package/server/src/clusterPeerOps.ts +15 -9
  210. package/server/src/clusterProgress.ts +1 -1
  211. package/server/src/clusterRehydrate.ts +2 -0
  212. package/server/src/clusterSkills.ts +79 -0
  213. package/server/src/clusterSnapshots.ts +1 -0
  214. package/server/src/clusterStore.ts +38 -0
  215. package/server/src/diagnostics/codeSkew.ts +1 -0
  216. package/server/src/eventLog.ts +73 -13
  217. package/server/src/explorerDocs.ts +75 -34
  218. package/server/src/historyLimits.ts +2 -0
  219. package/server/src/http/attachmentUpload.ts +49 -0
  220. package/server/src/http/browserWorktrees.ts +124 -0
  221. package/server/src/http/phoneUploadDrafts.ts +118 -0
  222. package/server/src/http/phoneUploadListener.ts +96 -0
  223. package/server/src/http/phoneUploadNetwork.ts +117 -0
  224. package/server/src/http/phoneUploadPage.ts +137 -0
  225. package/server/src/http/phoneUploadRouteHistory.ts +73 -0
  226. package/server/src/http/phoneUploadRoutes.ts +398 -0
  227. package/server/src/http/phoneUploadTheme.ts +97 -0
  228. package/server/src/http/projectBinding.ts +3 -2
  229. package/server/src/http/readConfinement.ts +5 -1
  230. package/server/src/http/router.ts +12 -26
  231. package/server/src/http/writeConfinement.ts +13 -2
  232. package/server/src/index.ts +23 -0
  233. package/server/src/jsonlLines.ts +52 -0
  234. package/server/src/management/identity.ts +1 -0
  235. package/server/src/mcp/clusterMcpTools.ts +4 -4
  236. package/server/src/primitives/seedWorker.ts +3 -1
  237. package/server/src/project/taskLedger.ts +7 -5
  238. package/server/src/providerConversation.ts +15 -0
  239. package/server/src/providers/claude-native/resumeSummary.ts +98 -50
  240. package/server/src/providers/claude-native/worker.ts +8 -4
  241. package/server/src/providers/claude.ts +2 -1
  242. package/server/src/providers/clusterTaskToolDefinitions.ts +4 -4
  243. package/server/src/providers/codex-appserver/catalog.ts +14 -1
  244. package/server/src/providers/codex-appserver/heldCommands.ts +58 -0
  245. package/server/src/providers/codex-appserver/index.ts +222 -20
  246. package/server/src/providers/codex-appserver/lateCommands.ts +225 -0
  247. package/server/src/providers/codex-appserver/worker.ts +85 -21
  248. package/server/src/providers/codex.ts +2 -1
  249. package/server/src/providers/codexCodeMode.ts +9 -4
  250. package/server/src/providers/cursor/print.ts +2 -1
  251. package/server/src/providers/cursor/worker.ts +2 -1
  252. package/server/src/providers/llamacpp.ts +18 -7
  253. package/server/src/providers/llamacppRecovery.ts +2 -0
  254. package/server/src/providers/ollamaRecovery.ts +6 -6
  255. package/server/src/providers/ollamaResilience.ts +3 -3
  256. package/server/src/providers/ollamaTokens.ts +1 -1
  257. package/server/src/providers/ollamaToolSubset.ts +3 -3
  258. package/server/src/quota.ts +0 -50
  259. package/server/src/replacementHistory.ts +44 -0
  260. package/server/src/server/broadcast.ts +2 -0
  261. package/server/src/server/prompts.ts +8 -1
  262. package/server/src/sessionJsonl.ts +92 -32
  263. package/server/src/smartPickupAdapters.ts +17 -3
  264. package/server/src/transcriptWorker.ts +182 -0
  265. package/server/src/workers/WorkerManager.ts +2 -0
  266. package/server/src/workers/processKill.ts +35 -7
  267. package/server/src/workflowStore.ts +21 -0
  268. package/server/src/ws/clusterHandlers.ts +43 -25
  269. package/server/src/ws/handoffHandlers.ts +7 -1
  270. package/server/src/ws/transcriptWorkerHandlers.ts +126 -0
  271. package/server/src/ws/turnEngine.ts +35 -8
  272. package/server/src/ws/updatePrimaryConfig.ts +25 -6
  273. package/server/src/ws/workflowHandlers.ts +3 -1
  274. package/shared/dist/clusterCoordination.d.ts +2 -0
  275. package/shared/dist/clusterCoordination.js +5 -1
  276. package/shared/dist/protocol/chat.d.ts +1 -0
  277. package/shared/dist/protocol/clientMessages.d.ts +3 -2
  278. package/shared/dist/protocol/clusters.d.ts +15 -1
  279. package/shared/dist/protocol/index.d.ts +1 -0
  280. package/shared/dist/protocol/index.js +1 -0
  281. package/shared/dist/protocol/models.d.ts +4 -3
  282. package/shared/dist/protocol/models.js +26 -2
  283. package/shared/dist/protocol/serverMessages.d.ts +13 -1
  284. package/shared/dist/protocol/tasks.d.ts +4 -0
  285. package/shared/dist/protocol/transcriptWorker.d.ts +47 -0
  286. package/shared/dist/protocol/transcriptWorker.js +2 -0
  287. package/shared/dist/protocol/workflows.d.ts +1 -0
  288. package/shared/dist/runtimeVersions.d.ts +1 -0
  289. package/shared/dist/runtimeVersions.js +14 -0
  290. package/shared/src/clusterCoordination.ts +7 -1
  291. package/shared/src/protocol/chat.ts +1 -0
  292. package/shared/src/protocol/clientMessages.ts +5 -0
  293. package/shared/src/protocol/clusters.ts +20 -6
  294. package/shared/src/protocol/index.ts +1 -0
  295. package/shared/src/protocol/models.ts +31 -5
  296. package/shared/src/protocol/serverMessages.ts +13 -0
  297. package/shared/src/protocol/settings.ts +2 -3
  298. package/shared/src/protocol/tasks.ts +4 -7
  299. package/shared/src/protocol/transcriptWorker.ts +49 -0
  300. package/shared/src/protocol/workflows.ts +4 -0
  301. package/shared/src/runtimeVersions.ts +14 -0
@@ -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.`
@@ -14,11 +14,12 @@ export function buildClusterDirectorDoctrine(role: string | undefined): string |
14
14
  'You are the operator-assigned Director of THIS Arco cluster: you coordinate, read the diff, and land. Peers implement, build, and test.',
15
15
  'At the start of each turn, inspect pending peer mail. If the injected shared plan is marked OUTLINE, call cluster_plan_read before deciding what to do.',
16
16
  'Reconcile relevant tasks, new peer evidence, repository state and applicable project instructions before reporting status. Read the broader plan or history when relevant or stale. Check an operator problem against the affected priorities and open items before asking them anything.',
17
+ 'Answer the operator first. If an issue remains open, recommend the next step, name who owns the work, and say what the operator needs to decide or do and when, if anything. You own coordination with workers. When a worker already owns the follow-up and the operator has nothing to do, say so. Promise later follow-up only when an available trigger can wake you; otherwise explain who must act and when. Ask the operator to nudge the Director only when progress depends on it. New work waits for the operator\'s approval; continue already approved work as usual.',
17
18
  'When this cluster has an Advisor, consult it before a design decision or when the evidence is thin; the decision remains yours.',
18
19
  '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
20
  '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
21
  '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.',
22
+ '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
23
  '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
24
  '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
25
  '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';
@@ -362,6 +363,7 @@ export async function peerSend(
362
363
  artifacts.push({ name: basename(abs), contentBase64: data.toString('base64'), byteLength: data.byteLength });
363
364
  }
364
365
  }
366
+ const createdAt = new Date().toISOString();
365
367
  try {
366
368
  await clusterMailbox.enqueue(resolved, {
367
369
  msgId,
@@ -369,7 +371,7 @@ export async function peerSend(
369
371
  fromDisplayName,
370
372
  toWorkflowId: resolved,
371
373
  content: args.content,
372
- createdAt: new Date().toISOString(),
374
+ createdAt,
373
375
  delivered: false,
374
376
  ...(artifacts?.length ? { artifacts } : {}),
375
377
  }, opts?.maxContentBytes !== undefined ? { maxContentBytes: opts.maxContentBytes } : undefined);
@@ -397,6 +399,8 @@ export async function peerSend(
397
399
  from: ctx.workflowId,
398
400
  to: resolved,
399
401
  contentPreview: args.content.length > 200 ? `${args.content.slice(0, 200)}…` : args.content,
402
+ content: args.content,
403
+ ts: Date.parse(createdAt),
400
404
  });
401
405
  const warning = guard && clusterBudget.takeWarning(ctx.workflowId, guard, guardDecision!.count)
402
406
  ? `Warn-only threshold exceeded: ${guardDecision!.count}/${guard.threshold} peer messages this primary turn. Mail accepted. Consolidate related same-recipient information; required work and review still apply.`
@@ -968,11 +972,8 @@ function taskDependsOn(tasks: LedgerTask[], fromId: string, targetId: string, se
968
972
  return task.parentIds.some((parentId) => taskDependsOn(tasks, parentId, targetId, seen));
969
973
  }
970
974
 
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.
975
+ // Workers may set non-terminal statuses. Direct done / archived requests are
976
+ // rejected; a director met sign-off may close the task when auto-done is on.
976
977
  const SIGNOFF_STATES: ReadonlySet<TaskSignoffState> = new Set(['met', 'not_met', 'partial']);
977
978
 
978
979
  export async function peerTaskUpdate(
@@ -983,7 +984,7 @@ export async function peerTaskUpdate(
983
984
  notes?: string;
984
985
  // Release label such as "0.1.4"; an empty string clears it.
985
986
  release?: string;
986
- // §D3 — the director's advisory verdict. The model passes `{ state, summary }`;
987
+ // The director verdict. The model passes `{ state, summary }`;
987
988
  // the server stamps `byWorkflowId`/`at` so it's attributable and unspoofable.
988
989
  // `null` explicitly clears a prior sign-off (back to PENDING).
989
990
  signoff?: { state?: string; summary?: string } | null;
@@ -998,7 +999,7 @@ export async function peerTaskUpdate(
998
999
  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
1000
  };
1000
1001
  }
1001
- // Build the server-stamped sign-off (advisory; never a terminal status).
1002
+ // Stamp the sign-off at the peer boundary so its author cannot be spoofed.
1002
1003
  let signoffPatch: TaskSignoff | null | undefined;
1003
1004
  if (args.signoff === null) {
1004
1005
  signoffPatch = null;
@@ -1031,10 +1032,15 @@ export async function peerTaskUpdate(
1031
1032
  if (!board) {
1032
1033
  return { ok: false, code: 'board_detached', message: 'no task board is enabled for this cluster.' };
1033
1034
  }
1035
+ const director = isClusterDirector(clusterStore.getMemberRole(ctx.clusterId, ctx.workflowId));
1036
+ const autoMarkDone = director && signoffPatch?.state === 'met' && (await readSettings()).autoMarkDoneOnMetSignoff !== false;
1034
1037
  let rejection: PeerTaskRejection | null = null;
1035
1038
  const result = await persistLedgerMutation(ctx.workflowId, board.cwd, 'update', (tasks) => {
1039
+ const previous = tasks.find((task) => task.id === args.id);
1040
+ const close = director && autoMarkDone && signoffPatch?.state === 'met' && previous?.status !== 'done' && previous?.status !== 'archived';
1036
1041
  const applied = taskLedger.applyUpdate(tasks, args.id, {
1037
- ...(args.status ? { status: args.status } : {}),
1042
+ ...(close ? { directorClosure: { byWorkflowId: ctx.workflowId, at: signoffPatch!.at } } : {}),
1043
+ ...(close ? { status: 'done' as const } : args.status ? { status: args.status } : {}),
1038
1044
  ...(typeof args.notes === 'string' ? { notes: args.notes } : {}),
1039
1045
  ...(typeof args.release === 'string' ? { release: args.release } : {}),
1040
1046
  ...(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
 
@@ -53,6 +53,8 @@ export async function rehydrateClusterOnce(
53
53
  from: m.fromWorkflowId,
54
54
  to: m.toWorkflowId,
55
55
  contentPreview: m.content.length > 200 ? `${m.content.slice(0, 200)}…` : m.content,
56
+ content: m.content,
57
+ ...(Number.isFinite(Date.parse(m.createdAt)) ? { ts: Date.parse(m.createdAt) } : {}),
56
58
  };
57
59
  // broadcastWorkflow stamps the event into the SENDER's events.jsonl
58
60
  // and fans out to that workflow's live observers. The cluster
@@ -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;
@@ -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;