arco-workbench 0.1.5 → 0.1.7

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 (188) hide show
  1. package/CONTRIBUTING.md +9 -0
  2. package/README.md +17 -5
  3. package/client/dist/assets/{PhosphorBackdrop-D6cbmLNY.js → PhosphorBackdrop-DVQdBrTw.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-2dyerOi4.js → ThemedBackgroundShaderImpl-BfSs2tB4.js} +1 -1
  5. package/client/dist/assets/{XtermView-AIwo7O3D.js → XtermView-DaMjC8Ny.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-DXAuxS8D.js → galleryEditor-BCQnXj7R.js} +1 -1
  7. package/client/dist/assets/{index-8j6p-pmQ.js → index-COfbHCYv.js} +245 -243
  8. package/client/dist/index.html +1 -1
  9. package/client/src/alerts/desktopAlerts.ts +13 -0
  10. package/client/src/buildCheck.ts +3 -1
  11. package/client/src/components/AppUpdateNotice.tsx +2 -1
  12. package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +46 -11
  13. package/client/src/components/ClusterRightPanel/MemberRow.tsx +1 -1
  14. package/client/src/components/ClusterRightPanel/index.tsx +2 -1
  15. package/client/src/components/ClusterTaskBoardTab.tsx +54 -3
  16. package/client/src/components/ContextMeter.tsx +7 -0
  17. package/client/src/components/HeaderVersionBox.tsx +7 -4
  18. package/client/src/components/Home/HomeView.tsx +1 -1
  19. package/client/src/components/NeedsYouBadge.tsx +31 -16
  20. package/client/src/components/OperatorQuestionNotice.tsx +10 -1
  21. package/client/src/components/ProvidersPopover.tsx +23 -12
  22. package/client/src/components/TabBar.tsx +11 -8
  23. package/client/src/components/TabStatusChip.tsx +8 -7
  24. package/client/src/components/UpdateAction.tsx +18 -4
  25. package/client/src/components/UpdateResultNotice.tsx +3 -1
  26. package/client/src/components/clusterNeedsYou.ts +27 -8
  27. package/client/src/help/content/cluster.tsx +50 -27
  28. package/client/src/help/content/composer.tsx +8 -1
  29. package/client/src/help/content/header.tsx +25 -14
  30. package/client/src/help/content/misc.tsx +8 -0
  31. package/client/src/help/content/rightPanel.tsx +1 -1
  32. package/client/src/help/content/settings.tsx +1 -1
  33. package/client/src/help/content/tabbar.tsx +2 -1
  34. package/client/src/help/manualSections/clusters.tsx +78 -19
  35. package/client/src/help/manualSections/configuration.tsx +20 -4
  36. package/client/src/help/manualSections/gettingStarted.tsx +10 -0
  37. package/client/src/help/manualSections/maintenance.tsx +50 -8
  38. package/client/src/help/manualSections/plans.tsx +5 -1
  39. package/client/src/help/manualSections/providers.tsx +10 -3
  40. package/client/src/help/manualSections/reference.tsx +1 -1
  41. package/client/src/help/manualSections/workflows.tsx +20 -0
  42. package/client/src/help/manualSections/workspace.tsx +7 -1
  43. package/client/src/questions/waitingQuestion.ts +3 -2
  44. package/client/src/stores/appStore.ts +1 -1
  45. package/client/src/stores/appStore.types.ts +1 -0
  46. package/client/src/stores/appUpdateStore.ts +29 -8
  47. package/client/src/stores/notificationStore.ts +2 -0
  48. package/client/src/utils/activityPresentation.ts +1 -1
  49. package/client/src/utils/tabStatus.ts +8 -0
  50. package/client/src/utils/wsSession.ts +2 -1
  51. package/client/src/voice/commands.ts +4 -3
  52. package/client/src/voice/executor.ts +3 -3
  53. package/client/src/ws/handleServerMessage.ts +22 -2
  54. package/client/src/ws/operatorQuestions.ts +2 -0
  55. package/docs/CLIENT.md +3 -3
  56. package/docs/FEATURES.md +1 -1
  57. package/docs/GETTING_STARTED.md +16 -6
  58. package/docs/GLOSSARY.md +6 -2
  59. package/docs/GOTCHAS.md +17 -5
  60. package/docs/OPERATIONS.md +207 -5
  61. package/docs/PERSISTENCE.md +22 -1
  62. package/docs/PRIMITIVES.md +1 -1
  63. package/docs/PROTOCOL.md +1 -1
  64. package/docs/PROTOCOL_CLUSTER.md +18 -7
  65. package/docs/PROVIDERS.md +10 -5
  66. package/docs/SETTINGS.md +4 -2
  67. package/docs/TASK_LEDGER.md +6 -0
  68. package/docs/VOICE.md +2 -0
  69. package/native/darwin-arm64/manifest.json +1 -1
  70. package/native/win32-arm64/manifest.json +1 -1
  71. package/node_modules/@arco/shared/dist/clusterRolePresets.d.ts +1 -1
  72. package/node_modules/@arco/shared/dist/clusterRolePresets.js +10 -0
  73. package/node_modules/@arco/shared/dist/protocol/autoPickup.d.ts +3 -0
  74. package/node_modules/@arco/shared/dist/protocol/autoPickup.js +9 -1
  75. package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +2 -2
  76. package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -0
  77. package/node_modules/@arco/shared/dist/protocol/notifications.d.ts +4 -0
  78. package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +12 -0
  79. package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +9 -3
  80. package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
  81. package/node_modules/@arco/shared/package.json +1 -1
  82. package/package.json +2 -2
  83. package/scripts/packaging/arco.mjs +1 -0
  84. package/scripts/packaging/native-repair.mjs +46 -8
  85. package/scripts/packaging/update.mjs +5 -1
  86. package/server/dist/attention.d.ts +1 -1
  87. package/server/dist/attention.js +6 -4
  88. package/server/dist/capabilities.d.ts +9 -8
  89. package/server/dist/capabilities.js +71 -102
  90. package/server/dist/cliUpdateDecision.d.ts +34 -0
  91. package/server/dist/cliUpdateDecision.js +152 -0
  92. package/server/dist/clusterAutoTurn.d.ts +4 -0
  93. package/server/dist/clusterAutoTurn.js +29 -25
  94. package/server/dist/clusterBusyReminder.js +1 -1
  95. package/server/dist/clusterDirector.js +1 -0
  96. package/server/dist/clusterPeerOps.js +2 -2
  97. package/server/dist/clusterStore.d.ts +3 -0
  98. package/server/dist/clusterStore.js +22 -0
  99. package/server/dist/defaults/models.md +1 -1
  100. package/server/dist/fileAccessPolicy.js +7 -5
  101. package/server/dist/http/workflowDataRoutes.js +1 -1
  102. package/server/dist/index.js +5 -1
  103. package/server/dist/primitives/seedWorker.d.ts +1 -0
  104. package/server/dist/primitives/seedWorker.js +2 -1
  105. package/server/dist/providerConversation.d.ts +9 -0
  106. package/server/dist/providerConversation.js +80 -0
  107. package/server/dist/providers/claude-native/retainedContext.d.ts +4 -0
  108. package/server/dist/providers/claude-native/retainedContext.js +20 -0
  109. package/server/dist/providers/claude-native/worker.d.ts +1 -0
  110. package/server/dist/providers/claude-native/worker.js +34 -6
  111. package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -0
  112. package/server/dist/providers/codex-appserver/operatorQuestions.js +30 -0
  113. package/server/dist/providers/codex-appserver/worker.js +9 -4
  114. package/server/dist/providers/ollama.js +2 -3
  115. package/server/dist/server/broadcast.d.ts +1 -1
  116. package/server/dist/smartPickup.d.ts +2 -1
  117. package/server/dist/smartPickup.js +28 -1
  118. package/server/dist/smartPickupAdapters.d.ts +1 -0
  119. package/server/dist/smartPickupAdapters.js +18 -5
  120. package/server/dist/smartPickupLedger.js +6 -4
  121. package/server/dist/smartPickupObserver.d.ts +1 -0
  122. package/server/dist/smartPickupObserver.js +69 -23
  123. package/server/dist/workers/WorkerManager.d.ts +1 -0
  124. package/server/dist/workers/WorkerManager.js +1 -0
  125. package/server/dist/workers/limits.js +6 -2
  126. package/server/dist/workflowMeta.d.ts +11 -1
  127. package/server/dist/workflowMeta.js +132 -6
  128. package/server/dist/workflows/types.d.ts +1 -0
  129. package/server/dist/ws/clusterHandlers.d.ts +1 -0
  130. package/server/dist/ws/clusterHandlers.js +2 -1
  131. package/server/dist/ws/compactHandlers.d.ts +1 -1
  132. package/server/dist/ws/compactHandlers.js +11 -4
  133. package/server/dist/ws/handoffHandlers.js +16 -6
  134. package/server/dist/ws/operatorQuestionHandlers.d.ts +2 -1
  135. package/server/dist/ws/operatorQuestionHandlers.js +9 -1
  136. package/server/dist/ws/turnEngine.d.ts +2 -4
  137. package/server/dist/ws/turnEngine.js +88 -129
  138. package/server/package.json +1 -1
  139. package/server/src/attention.ts +5 -4
  140. package/server/src/capabilities.ts +70 -111
  141. package/server/src/cliUpdateDecision.ts +159 -0
  142. package/server/src/clusterAutoTurn.ts +26 -21
  143. package/server/src/clusterBusyReminder.ts +1 -1
  144. package/server/src/clusterDirector.ts +1 -0
  145. package/server/src/clusterPeerOps.ts +2 -2
  146. package/server/src/clusterStore.ts +26 -1
  147. package/server/src/defaults/models.md +1 -1
  148. package/server/src/fileAccessPolicy.ts +7 -5
  149. package/server/src/http/workflowDataRoutes.ts +1 -1
  150. package/server/src/index.ts +5 -1
  151. package/server/src/primitives/seedWorker.ts +3 -1
  152. package/server/src/providerConversation.ts +71 -0
  153. package/server/src/providers/claude-native/retainedContext.ts +22 -0
  154. package/server/src/providers/claude-native/worker.ts +33 -5
  155. package/server/src/providers/codex-appserver/operatorQuestions.ts +24 -0
  156. package/server/src/providers/codex-appserver/worker.ts +8 -4
  157. package/server/src/providers/ollama.ts +2 -3
  158. package/server/src/smartPickup.ts +27 -3
  159. package/server/src/smartPickupAdapters.ts +19 -5
  160. package/server/src/smartPickupLedger.ts +6 -4
  161. package/server/src/smartPickupObserver.ts +51 -17
  162. package/server/src/workers/WorkerManager.ts +2 -0
  163. package/server/src/workers/limits.ts +7 -2
  164. package/server/src/workflowMeta.ts +139 -5
  165. package/server/src/workflows/types.ts +1 -0
  166. package/server/src/ws/clusterHandlers.ts +3 -2
  167. package/server/src/ws/compactHandlers.ts +9 -3
  168. package/server/src/ws/handoffHandlers.ts +13 -6
  169. package/server/src/ws/operatorQuestionHandlers.ts +10 -2
  170. package/server/src/ws/turnEngine.ts +80 -135
  171. package/shared/dist/clusterRolePresets.d.ts +1 -1
  172. package/shared/dist/clusterRolePresets.js +10 -0
  173. package/shared/dist/protocol/autoPickup.d.ts +3 -0
  174. package/shared/dist/protocol/autoPickup.js +9 -1
  175. package/shared/dist/protocol/clientMessages.d.ts +2 -2
  176. package/shared/dist/protocol/models.d.ts +6 -0
  177. package/shared/dist/protocol/notifications.d.ts +4 -0
  178. package/shared/dist/protocol/operatorQuestions.d.ts +12 -0
  179. package/shared/dist/protocol/serverMessages.d.ts +9 -3
  180. package/shared/dist/protocol/workflows.d.ts +1 -0
  181. package/shared/src/clusterRolePresets.ts +11 -1
  182. package/shared/src/protocol/autoPickup.ts +14 -1
  183. package/shared/src/protocol/clientMessages.ts +2 -1
  184. package/shared/src/protocol/models.ts +5 -2
  185. package/shared/src/protocol/notifications.ts +5 -0
  186. package/shared/src/protocol/operatorQuestions.ts +13 -0
  187. package/shared/src/protocol/serverMessages.ts +12 -2
  188. package/shared/src/protocol/workflows.ts +4 -0
@@ -8,7 +8,8 @@ import { getStrataBase } from './providers/strata.js';
8
8
  import { getDeepSeekBase } from './providers/deepseek.js';
9
9
  import { probeStrataVersion, installedXolotlRevision, strataEngineReleaseVersion } from './providers/runtimeVersions.js';
10
10
  import { atomicWriteFile } from './atomicFile.js';
11
- import { resolveInstallableVersion } from './npmPlatformResolve.js';
11
+ import { probeCodexUpdate, describeCliUpdate } from './cliUpdateDecision.js';
12
+ import { compareVersions } from './updateCheck.js';
12
13
  import { arcoHome } from './arcoHome.js';
13
14
  import { commandArgs } from './windowsCommand.js';
14
15
  const execFileAsync = promisify(execFile);
@@ -67,21 +68,24 @@ export async function probeCapabilities() {
67
68
  catch {
68
69
  // Keep fallback
69
70
  }
70
- const [cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions] = await Promise.all([
71
+ const codexDecision = npmLatest('@openai/codex').then(probeCodexUpdate);
72
+ const [cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions, codexUpdate] = await Promise.all([
71
73
  probeVersion('claude'),
72
74
  probeVersion('codex'),
73
75
  probeVersion('cursor-agent'),
74
76
  probeStrataVersion(await getStrataBase()),
75
77
  installedXolotlRevision(await getDeepSeekBase()),
76
- probeLatestVersions(),
78
+ probeLatestVersions(codexDecision),
79
+ codexDecision,
77
80
  ]);
78
- return { efforts, models: MODELS, cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions };
81
+ return { efforts, models: MODELS, cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions,
82
+ codexUpdate: { kind: codexUpdate.kind, updateAvailable: !!codexUpdate.targetVersion && (compareVersions(codexVersion, codexUpdate.targetVersion) ?? 0) < 0, instruction: codexUpdate.message ?? codexUpdate.notice } };
79
83
  }
80
84
  // ── Upstream latest-version probes ──
81
85
  //
82
- // Source of truth for "is the operator running the latest CLI?" The three
83
- // npm-installed CLIs query the registry directly; Ollama queries GitHub
84
- // Releases since it's not npm-installed. All four are best-effort: any
86
+ // Source of truth for "is the operator running the latest CLI?" Claude reads
87
+ // npm; Codex uses its installation decision and npm publication metadata;
88
+ // Ollama queries GitHub Releases since it's not npm-installed. All are best-effort: any
85
89
  // failure (offline, rate-limited, schema drift) leaves that key undefined
86
90
  // and the UI falls back to displaying the installed version with no
87
91
  // outdated indicator. Caller decides cadence — boot + the existing 4h
@@ -130,10 +134,10 @@ async function strataLatestRelease() {
130
134
  ]);
131
135
  return strataEngineReleaseVersion(feed, release);
132
136
  }
133
- export async function probeLatestVersions() {
137
+ export async function probeLatestVersions(codexDecision = npmLatest('@openai/codex').then(probeCodexUpdate)) {
134
138
  const [claude, codex, ollama, strata, xolotl] = await Promise.all([
135
139
  npmLatest('@anthropic-ai/claude-code'),
136
- npmLatest('@openai/codex'),
140
+ codexDecision.then((decision) => decision.targetVersion),
137
141
  ollamaLatestRelease(),
138
142
  strataLatestRelease(),
139
143
  fetchJson('https://api.github.com/repos/Indras-Mirror/Xolotl/commits/HEAD').then((data) => {
@@ -143,125 +147,90 @@ export async function probeLatestVersions() {
143
147
  ]);
144
148
  return { claude, codex, ollama, strata, xolotl };
145
149
  }
146
- const UPDATE_COMMAND = {
147
- claude: { cmd: 'claude', args: ['update'] },
148
- codex: { cmd: 'npm', args: ['install', '-g', '@openai/codex@latest'] },
149
- };
150
- // npm package behind each CLI, for the pre-flight platform-build check. Claude
151
- // is absent on purpose: it self-updates via `claude update`, so there is no
152
- // `npm install` for us to aim at a specific version.
153
- const NPM_PACKAGE = {
154
- codex: '@openai/codex',
155
- };
156
150
  function versionForProvider(caps, provider) {
157
- if (provider === 'claude')
158
- return caps.cliVersion;
159
- return caps.codexVersion ?? 'unknown';
151
+ return provider === 'claude' ? caps.cliVersion : caps.codexVersion ?? 'unknown';
160
152
  }
161
153
  /**
162
- * Run the update command for the given CLI provider. Claude uses its built-in
163
- * self-updater; Codex falls back to `npm install -g …@latest`. Re-probes
164
- * capabilities after so callers get the refreshed version strings.
154
+ * Run the updater for the installation Arco actually launches. Claude uses its
155
+ * built-in updater; Codex shares one installation decision with its version flag.
156
+ * Re-probe afterwards: a successful command alone does not prove a working CLI.
165
157
  */
166
- export async function runCliUpdate(previous, provider = 'claude', runCommand = runUpdateCommand) {
167
- const previousVersion = versionForProvider(previous, provider);
158
+ export async function runCliUpdate(previous, provider = 'claude', runCommand = (cmd, args) => runUpdateCommand(cmd, args, provider)) {
159
+ const previousVersion = provider === 'codex' ? await probeVersion('codex') : versionForProvider(previous, provider);
168
160
  // Pre-flight: for npm-installed CLIs, work out which version can actually run
169
161
  // on this machine before installing anything. `@latest` is not automatically
170
162
  // installable — a package whose binary ships as a platform-specific
171
163
  // optionalDependency is broken-on-arrival during the window between the
172
164
  // wrapper being tagged `latest` and that platform's tarball being published,
173
165
  // and npm reports that as success. See npmPlatformResolve.ts.
174
- const pkg = NPM_PACKAGE[provider];
175
- let notice = null;
176
- let { cmd, args } = UPDATE_COMMAND[provider];
177
- if (pkg) {
178
- // A null resolution means the registry was unreachable; fall through to the
179
- // plain `@latest` command rather than blocking an update on a network blip.
180
- const resolved = await resolveInstallableVersion(pkg);
181
- if (resolved) {
182
- notice = resolved.notice;
183
- if (resolved.blocked) {
184
- return {
185
- provider,
186
- updated: false,
187
- previousVersion,
188
- currentVersion: previousVersion,
189
- capabilities: previous,
190
- output: notice ?? 'Update deferred; the current CLI was not changed.',
191
- error: notice ?? 'Update deferred: no installable platform build was found.',
192
- ...(notice ? { notice } : {}),
193
- };
194
- }
195
- args = ['install', '-g', `${pkg}@${resolved.version}`];
196
- // Already on the version we would install, and it runs — skip the install
197
- // entirely so a no-op click can't churn a working CLI into a broken one.
198
- if (resolved.version === previousVersion && previousVersion !== 'broken' && previousVersion !== 'unknown') {
199
- return {
200
- provider,
201
- updated: false,
202
- previousVersion,
203
- currentVersion: previousVersion,
204
- capabilities: previous,
205
- output: `${pkg}@${previousVersion} is already installed`,
206
- ...(notice ? { notice } : {}),
207
- };
208
- }
209
- }
166
+ const decision = provider === 'codex'
167
+ ? await probeCodexUpdate(await npmLatest('@openai/codex'))
168
+ : { kind: 'unknown', command: { cmd: 'claude', args: ['update'] }, targetVersion: previous.latestVersions?.claude };
169
+ const notice = decision.notice;
170
+ const capabilities = provider === 'codex'
171
+ ? { ...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 } }
172
+ : previous;
173
+ if (!decision.command) {
174
+ const message = decision.message ?? 'Update deferred; the current CLI was not changed.';
175
+ return { provider, previousVersion, currentVersion: previousVersion, capabilities, updated: false,
176
+ outcome: decision.outcome ?? 'deferred', message, output: message, notice: message };
177
+ }
178
+ // Already on the version we would install, and it runs — skip the install
179
+ // entirely so a no-op click can't churn a working CLI into a broken one.
180
+ if (provider === 'codex' && decision.targetVersion && (compareVersions(previousVersion, decision.targetVersion) ?? -1) >= 0) {
181
+ return { provider, previousVersion, currentVersion: previousVersion, capabilities, output: '',
182
+ ...describeCliUpdate(provider, previousVersion, previousVersion, decision.targetVersion, { exitCode: 0, output: '' }, notice),
183
+ ...(notice ? { notice } : {}) };
210
184
  }
211
- let output = await runCommand(cmd, args);
185
+ const { cmd, args } = decision.command;
186
+ let commandResult = await runCommand(cmd, args);
212
187
  let next = await probeCapabilities();
213
188
  let currentVersion = versionForProvider(next, provider);
214
189
  // Post-flight repair. The pre-flight check closes the common case, but npm can
215
190
  // still skip an optional dep that does exist (a mid-install network failure,
216
191
  // a poisoned cache), and that also exits 0. One retry with a clean cache is
217
- // cheap next to leaving the operator's CLI dead.
218
- if ((currentVersion === 'broken' || currentVersion === 'unknown') && pkg) {
219
- const repairArgs = [...args, '--force'];
220
- output += `\n\n[arco] ${provider} did not run after the update — retrying: npm ${repairArgs.join(' ')}`;
221
- output += `\n${await runCommand('npm', repairArgs)}`;
192
+ // cheap next to leaving the operator's CLI dead. Only a proven npm install
193
+ // with a successful updater exit can reach this npm repair path.
194
+ if (commandResult.exitCode === 0 && (currentVersion === 'broken' || currentVersion === 'unknown') && decision.repairArgs) {
195
+ const repairArgs = [...decision.repairArgs, '--force'];
196
+ const repaired = await runCommand('npm', repairArgs);
197
+ commandResult = { exitCode: repaired.exitCode, output: `${commandResult.output}\n\n[arco] ${provider} did not run after the update — retrying: npm ${repairArgs.join(' ')}\n${repaired.output}` };
222
198
  next = await probeCapabilities();
223
199
  currentVersion = versionForProvider(next, provider);
224
200
  }
225
201
  // A post-update probe that can't report a version means the command left the
226
202
  // CLI unusable, however cleanly it exited. Deciding `updated` purely on the
227
- // version string differing is how a silently-failed `npm install -g` surfaced
228
- // in the popover as a cheerful "→ vunknown" (2026-09-03, codex): npm skipped
229
- // the platform binary, exited 0, and 'unknown' !== '0.153.1' read as success.
230
- if (currentVersion === 'broken' || currentVersion === 'unknown') {
231
- return {
232
- provider,
233
- updated: false,
234
- previousVersion,
235
- currentVersion,
236
- capabilities: next,
237
- output,
238
- error: (await probeFailureReason(provider)) ?? `${provider} did not run after the update`,
239
- ...(notice ? { notice } : {}),
240
- };
203
+ // version string differing is how a silently-failed npm install surfaced
204
+ // as a cheerful "→ vunknown". Nonzero exits are also failures, even when
205
+ // the previous executable still runs and reports the same version.
206
+ const report = describeCliUpdate(provider, previousVersion, currentVersion, next.latestVersions?.[provider], commandResult, notice);
207
+ if (report.outcome === 'failed' && commandResult.exitCode === 0) {
208
+ const reason = await probeFailureReason(provider);
209
+ if (reason) {
210
+ report.error = reason;
211
+ report.message = reason;
212
+ }
241
213
  }
242
- return {
243
- provider,
244
- updated: currentVersion !== previousVersion,
245
- previousVersion,
246
- currentVersion,
247
- capabilities: next,
248
- output,
249
- ...(notice ? { notice } : {}),
250
- };
214
+ return { provider, previousVersion, currentVersion, capabilities: next, output: commandResult.output,
215
+ ...report, ...(notice ? { notice } : {}) };
251
216
  }
252
- // Run an update command, folding a non-zero exit into the captured output — the
253
- // caller decides success from whether the CLI runs afterwards, never from the
254
- // exit code (npm exits 0 on a skipped optional dep).
255
- async function runUpdateCommand(cmd, args) {
217
+ // Keep the command status as well as its captured output. npm can exit zero
218
+ // after skipping an optional dep, but a nonzero updater exit is always failure.
219
+ async function runUpdateCommand(cmd, args, provider) {
220
+ const env = { ...process.env };
221
+ if (provider === 'codex') {
222
+ // Native Codex must detect its own install; an enclosing agent's package
223
+ // manager provenance must not turn a standalone update into an npm install.
224
+ for (const name of ['CODEX_MANAGED_BY_NPM', 'CODEX_MANAGED_BY_BUN', 'CODEX_MANAGED_BY_PNPM', 'CODEX_MANAGED_BY_VITE_PLUS', 'CODEX_MANAGED_PACKAGE_ROOT', 'npm_config_user_agent', 'npm_execpath'])
225
+ delete env[name];
226
+ }
256
227
  try {
257
- const { stdout, stderr } = await execFileAsync(...commandArgs(cmd, args), {
258
- maxBuffer: 4 * 1024 * 1024,
259
- timeout: 180_000,
260
- });
261
- return (stdout + stderr).trim();
228
+ const { stdout, stderr } = await execFileAsync(...commandArgs(cmd, args), { env, maxBuffer: 4 * 1024 * 1024, timeout: 180_000 });
229
+ return { output: (stdout + stderr).trim(), exitCode: 0 };
262
230
  }
263
231
  catch (err) {
264
- return err instanceof Error ? err.message : String(err);
232
+ const error = err;
233
+ return { output: (error.stderr || error.stdout || error.message || String(err)).trim(), exitCode: typeof error.code === 'number' ? error.code : 1 };
265
234
  }
266
235
  }
267
236
  // ── CLI help snapshots + change detection ──
@@ -0,0 +1,34 @@
1
+ import type { CliUpdateOutcome } from '@arco/shared';
2
+ import { type ResolvedInstall } from './npmPlatformResolve.js';
3
+ export interface CodexInstallation {
4
+ kind: 'standalone' | 'npm' | 'unknown';
5
+ launcher?: string;
6
+ supportsUpdate: boolean;
7
+ npmRootMatches?: boolean;
8
+ instruction?: string;
9
+ }
10
+ export interface CliUpdateDecision {
11
+ kind: CodexInstallation['kind'];
12
+ targetVersion?: string;
13
+ command?: {
14
+ cmd: string;
15
+ args: string[];
16
+ };
17
+ repairArgs?: string[];
18
+ outcome?: 'manual' | 'deferred';
19
+ message?: string;
20
+ notice?: string;
21
+ }
22
+ export declare function inspectCodexInstallation(): Promise<CodexInstallation>;
23
+ export declare function decideCodexUpdate(installation: CodexInstallation, published?: string, resolved?: ResolvedInstall | null): CliUpdateDecision;
24
+ export declare function probeCodexUpdate(published?: string): Promise<CliUpdateDecision>;
25
+ export interface UpdateCommandResult {
26
+ output: string;
27
+ exitCode: number;
28
+ }
29
+ export declare function describeCliUpdate(provider: string, previous: string, current: string, target: string | undefined, command: UpdateCommandResult, notice?: string): {
30
+ outcome: CliUpdateOutcome;
31
+ message: string;
32
+ updated: boolean;
33
+ error?: string;
34
+ };
@@ -0,0 +1,152 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { promises as fs, constants, statSync } from 'node:fs';
3
+ import { homedir } from 'node:os';
4
+ import path from 'node:path';
5
+ import { promisify } from 'node:util';
6
+ import { commandArgs, findWindowsCommand, npmShimTarget } from './windowsCommand.js';
7
+ import { resolveInstallableVersion } from './npmPlatformResolve.js';
8
+ import { compareVersions } from './updateCheck.js';
9
+ const exec = promisify(execFile);
10
+ const options = { timeout: 5_000, maxBuffer: 256 * 1024, killSignal: 'SIGKILL' };
11
+ function inside(root, file) {
12
+ const relative = path.relative(root, file);
13
+ return relative !== '' && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
14
+ }
15
+ async function canonical(file) {
16
+ try {
17
+ return await fs.realpath(file);
18
+ }
19
+ catch {
20
+ return undefined;
21
+ }
22
+ }
23
+ async function launcherOnPath() {
24
+ if (process.platform === 'win32') {
25
+ return findWindowsCommand('codex', process.env, (file) => {
26
+ try {
27
+ return requireFile(file);
28
+ }
29
+ catch {
30
+ return false;
31
+ }
32
+ }) ?? undefined;
33
+ }
34
+ for (const dir of (process.env.PATH ?? '').split(path.delimiter).filter(Boolean)) {
35
+ const file = path.resolve(dir, 'codex');
36
+ try {
37
+ await fs.access(file, constants.X_OK);
38
+ if ((await fs.stat(file)).isFile())
39
+ return file;
40
+ }
41
+ catch { /* try the next PATH entry */ }
42
+ }
43
+ return undefined;
44
+ }
45
+ // Windows command lookup is synchronous so it can use the same PATH/PATHEXT
46
+ // selection as the provider launcher, including npm's .cmd wrapper.
47
+ function requireFile(file) { return statSync(file).isFile(); }
48
+ export async function inspectCodexInstallation() {
49
+ const launcher = await launcherOnPath();
50
+ if (!launcher)
51
+ return { kind: 'unknown', supportsUpdate: false };
52
+ let entry = launcher;
53
+ if (process.platform === 'win32' && /\.(?:cmd|bat)$/i.test(launcher)) {
54
+ try {
55
+ entry = npmShimTarget(launcher, await fs.readFile(launcher, 'utf8')) ?? launcher;
56
+ }
57
+ catch { /* leave an unreadable wrapper unknown */ }
58
+ }
59
+ const real = await canonical(entry);
60
+ if (!real)
61
+ return { kind: 'unknown', launcher, supportsUpdate: false };
62
+ let supportsUpdate = false;
63
+ try {
64
+ const { stdout } = await exec(...commandArgs(launcher, ['--help']), options);
65
+ supportsUpdate = /^\s+update\s+/m.test(stdout);
66
+ }
67
+ catch { /* an older or broken CLI can still have a proven npm repair path */ }
68
+ if (path.basename(real) === 'codex.js') {
69
+ const packageRoot = path.dirname(path.dirname(real));
70
+ try {
71
+ const manifest = JSON.parse(await fs.readFile(path.join(packageRoot, 'package.json'), 'utf8'));
72
+ if (manifest.name === '@openai/codex') {
73
+ const { stdout } = await exec(...commandArgs('npm', ['root', '-g']), options);
74
+ const target = await canonical(path.join(stdout.trim(), '@openai', 'codex'));
75
+ return { kind: 'npm', launcher, supportsUpdate, npmRootMatches: !!target && path.relative(target, packageRoot) === '' };
76
+ }
77
+ }
78
+ catch { /* ownership could not be proved; never guess a global npm target */ }
79
+ return { kind: 'unknown', launcher, supportsUpdate, instruction: 'Arco could not confirm the npm update target. No update was run. Use the package manager that installed this Codex.' };
80
+ }
81
+ const home = process.env.CODEX_HOME || path.join(homedir(), '.codex');
82
+ const releases = await canonical(path.join(home, 'packages', 'standalone', 'releases'));
83
+ if (releases && inside(releases, real)) {
84
+ const defaultBin = process.platform === 'win32'
85
+ ? process.env.LOCALAPPDATA && path.join(process.env.LOCALAPPDATA, 'Programs', 'OpenAI', 'Codex', 'bin')
86
+ : path.join(homedir(), '.local', 'bin');
87
+ const installBin = process.env.CODEX_INSTALL_DIR || defaultBin;
88
+ // The updater reruns the installer. Its destination must still be the
89
+ // active command directory, including a retained custom install directory.
90
+ if (!installBin || path.relative(path.resolve(path.dirname(launcher)), path.resolve(installBin)) !== '') {
91
+ return { kind: 'unknown', launcher, supportsUpdate, instruction: 'This Codex was not installed through npm. No update was run because its installer destination could not be confirmed. Open codex in a terminal and use its update prompt with the original install directory.' };
92
+ }
93
+ return { kind: 'standalone', launcher, supportsUpdate };
94
+ }
95
+ return { kind: 'unknown', launcher, supportsUpdate };
96
+ }
97
+ export function decideCodexUpdate(installation, published, resolved) {
98
+ const base = { kind: installation.kind };
99
+ if (installation.kind === 'unknown' || !installation.launcher) {
100
+ return { ...base, outcome: 'manual', message: installation.instruction ?? 'Arco could not identify how this Codex was installed. No update was run. Open codex in a terminal and use its update prompt or the package manager that installed it.' };
101
+ }
102
+ if (installation.kind === 'standalone') {
103
+ return installation.supportsUpdate
104
+ ? { ...base, targetVersion: published, command: { cmd: installation.launcher, args: ['update'] } }
105
+ : { ...base, targetVersion: published, outcome: 'manual', message: 'This Codex was not installed through npm and does not support codex update. No update was run. Open codex in a terminal and use its update prompt.' };
106
+ }
107
+ if (!installation.npmRootMatches) {
108
+ return { ...base, outcome: 'manual', message: 'The npm update would target a different Codex installation. No update was run. Use the package manager that installed this Codex.' };
109
+ }
110
+ if (!resolved) {
111
+ return { ...base, outcome: 'deferred', message: 'Arco could not confirm an installable Codex npm build. The current installation was not changed.' };
112
+ }
113
+ if (resolved.blocked || (installation.supportsUpdate && resolved.degraded)) {
114
+ return { ...base, outcome: 'deferred', message: `Codex v${resolved.latest} has no ${process.platform}-${process.arch} build available yet. The current installation was not changed.` };
115
+ }
116
+ const args = ['install', '-g', `@openai/codex@${resolved.version}`];
117
+ return {
118
+ ...base, targetVersion: resolved.version,
119
+ command: installation.supportsUpdate ? { cmd: installation.launcher, args: ['update'] } : { cmd: 'npm', args },
120
+ repairArgs: args,
121
+ ...(resolved.degraded ? { notice: `Codex v${resolved.latest} has no ${process.platform}-${process.arch} build available yet. The newest installable npm version is v${resolved.version}.` } : {}),
122
+ };
123
+ }
124
+ export async function probeCodexUpdate(published) {
125
+ const installation = await inspectCodexInstallation();
126
+ const resolved = installation.kind === 'npm' && installation.npmRootMatches
127
+ ? await resolveInstallableVersion('@openai/codex') : undefined;
128
+ return decideCodexUpdate(installation, published, resolved);
129
+ }
130
+ export function describeCliUpdate(provider, previous, current, target, command, notice) {
131
+ const name = provider === 'codex' ? 'Codex' : 'Claude CLI';
132
+ if (command.exitCode !== 0) {
133
+ const error = `${name} update failed: ${command.output.trim().slice(0, 2000) || `exit code ${command.exitCode}`}`;
134
+ return { outcome: 'failed', message: error, updated: false, error };
135
+ }
136
+ if (current === 'unknown' || current === 'broken') {
137
+ const error = `${name} did not run after the update.`;
138
+ return { outcome: 'failed', message: error, updated: false, error };
139
+ }
140
+ if (previous !== current && (compareVersions(current, previous) ?? 1) > 0) {
141
+ return { outcome: 'updated', message: `Updated ${name} from v${previous} to v${current}.${notice ? ` ${notice}` : ''}`, updated: true };
142
+ }
143
+ if (notice)
144
+ return { outcome: 'deferred', message: notice, updated: false };
145
+ const comparison = target ? compareVersions(current, target) : null;
146
+ if (comparison !== null && comparison >= 0)
147
+ return { outcome: 'current', message: `${name} v${current} is up to date for this installation.`, updated: false };
148
+ return { outcome: 'unchanged', updated: false, message: comparison !== null
149
+ ? `${name} did not change; v${target} is still available.`
150
+ : `The ${name} version did not change. Arco could not check whether it is up to date.` };
151
+ }
152
+ //# sourceMappingURL=cliUpdateDecision.js.map
@@ -28,6 +28,10 @@ export declare function configure(opts: {
28
28
  }): void;
29
29
  export declare function start(): void;
30
30
  export declare function stop(): void;
31
+ export declare function pickupWaitingMail(clusterId: string, liveMembers?: {
32
+ workflowId: string;
33
+ busy: boolean;
34
+ }[] | undefined): Promise<void>;
31
35
  export declare function currentAutoTurnDepth(workflowId: string): number;
32
36
  export declare function clearAutoTurnDepth(workflowId: string): void;
33
37
  export declare function dropMember(workflowId: string): void;
@@ -191,29 +191,31 @@ async function sweep() {
191
191
  if (!membersByCluster)
192
192
  return;
193
193
  for (const clusterId of clusterStore.listKnownClusterIds()) {
194
- if (!clusterStore.isAutoPickupWaking(clusterId))
195
- continue;
196
- const liveMembers = membersByCluster.get(clusterId);
197
- if (!liveMembers || liveMembers.length === 0)
194
+ await pickupWaitingMail(clusterId, membersByCluster.get(clusterId));
195
+ }
196
+ }
197
+ // Resume uses the same scan as the periodic sweep, including every normal
198
+ // guard and budget. Never reset the Rule-based ledger to resume an operator pause.
199
+ export async function pickupWaitingMail(clusterId, liveMembers = resolveMembersFn?.()?.get(clusterId)) {
200
+ if (!isBusyFn || !clusterStore.isAutoPickupWaking(clusterId) || clusterStore.isAutoPickupPaused(clusterId) || !liveMembers)
201
+ return;
202
+ for (const m of liveMembers) {
203
+ if (m.busy) {
204
+ if (dispatchBusyReminderFn)
205
+ await remindBusyMember(clusterId, m.workflowId, { isBusy: isBusyFn, hasClusterTools: hasClusterToolsFn, dispatch: dispatchBusyReminderFn });
198
206
  continue;
199
- for (const m of liveMembers) {
200
- if (m.busy) {
201
- if (dispatchBusyReminderFn)
202
- await remindBusyMember(clusterId, m.workflowId, { isBusy: isBusyFn, hasClusterTools: hasClusterToolsFn, dispatch: dispatchBusyReminderFn });
203
- continue;
204
- }
205
- if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId))
206
- continue;
207
- const pending = await clusterMailbox.peek(m.workflowId).catch(() => []);
208
- if (pending.length === 0)
209
- continue;
210
- onPeerMessageSent({
211
- clusterId,
212
- senderWfid: pending[0].fromWorkflowId,
213
- recipientWfid: m.workflowId,
214
- incomingChainDepth: heldMailDepth(m.workflowId, pending),
215
- });
216
207
  }
208
+ if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId))
209
+ continue;
210
+ const pending = await clusterMailbox.peek(m.workflowId).catch(() => []);
211
+ if (pending.length === 0)
212
+ continue;
213
+ onPeerMessageSent({
214
+ clusterId,
215
+ senderWfid: pending[0].fromWorkflowId,
216
+ recipientWfid: m.workflowId,
217
+ incomingChainDepth: heldMailDepth(m.workflowId, pending),
218
+ });
217
219
  }
218
220
  }
219
221
  function getClusterState(clusterId) {
@@ -327,6 +329,8 @@ export function onPeerMessageSent(opts) {
327
329
  return;
328
330
  if (opts.incomingChainDepth > pendingChainDepth(opts.recipientWfid))
329
331
  pendingDepth.set(opts.recipientWfid, opts.incomingChainDepth);
332
+ if (clusterStore.isAutoPickupPaused(opts.clusterId))
333
+ return;
330
334
  try {
331
335
  ruleGuard.mail(opts.clusterId, opts.senderWfid, opts.recipientWfid);
332
336
  }
@@ -356,7 +360,7 @@ function fireRulePickup(opts) {
356
360
  const now = Date.now();
357
361
  // Guard 0: cluster toggle armed. Most clusters won't have this on; the
358
362
  // gate is the first check so the hot path is one map lookup when off.
359
- if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId))
363
+ if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || clusterStore.isAutoPickupPaused(clusterId))
360
364
  return;
361
365
  // Guard 1: depth cap. An incoming chainDepth of (cap - 1) is the last one
362
366
  // we'll auto-turn on; the auto-turn it produces will land at cap, so the
@@ -389,13 +393,13 @@ function fireRulePickup(opts) {
389
393
  const wasBudgetPaused = ruleGuard.snapshot(clusterId).budgetPaused;
390
394
  const problem = ruleGuard.admit(clusterId, senderWfid, recipientWfid, limits, now);
391
395
  if (problem) {
392
- const notice = problem === 'budget_paused' && !wasBudgetPaused ? 'Wake budget reached. Open AUTO-PICKUP and select RESUME.' : undefined;
396
+ const notice = problem === 'budget_paused' && !wasBudgetPaused ? 'Wake budget reached. Select RESET BUDGET beside AUTO-PICKUP.' : undefined;
393
397
  emitSkip(clusterId, recipientWfid, senderWfid, incomingChainDepth, problem, now, notice);
394
398
  return;
395
399
  }
396
400
  const pauses = ruleGuard.stamp(clusterId, senderWfid, recipientWfid, limits, now);
397
401
  const notices = [
398
- ...(pauses.budgetPaused ? ['Wake budget reached. Open AUTO-PICKUP and select RESUME.'] : []),
402
+ ...(pauses.budgetPaused ? ['Wake budget reached. Select RESET BUDGET beside AUTO-PICKUP.'] : []),
399
403
  ...(pauses.pairPaused ? [`Alternating wakes paused between ${clusterStore.displayNameFor(senderWfid)} and ${clusterStore.displayNameFor(recipientWfid)}.`] : []),
400
404
  ];
401
405
  // All guards pass — fire. Mark the new depth BEFORE dispatch so the
@@ -434,7 +438,7 @@ function fireRulePickup(opts) {
434
438
  const dispatch = dispatchAutoTurnFn;
435
439
  setImmediate(() => {
436
440
  try {
437
- if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || isBusyFn?.(recipientWfid))
441
+ if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || clusterStore.isAutoPickupPaused(clusterId) || isBusyFn?.(recipientWfid))
438
442
  return;
439
443
  dispatch(recipientWfid, prompt);
440
444
  }
@@ -6,7 +6,7 @@ const states = new Map();
6
6
  const pending = new Set();
7
7
  function enabled(clusterId, workflowId, now) {
8
8
  const state = store.getClusterCached(clusterId);
9
- if (state?.remindBusy !== true || !state.members.includes(workflowId))
9
+ if (state?.remindBusy !== true || state.autoPickupPausedAt !== undefined || !state.members.includes(workflowId))
10
10
  return false;
11
11
  const mode = store.autoPickupModeOf(state);
12
12
  return mode === 'rule' || (mode === 'smart-auto' && (state.smartPickup?.session?.expiresAt ?? 0) > now);
@@ -12,6 +12,7 @@ export function buildClusterDirectorDoctrine(role) {
12
12
  'You are the operator-assigned Director of THIS Arco cluster: you coordinate, read the diff, and land. Peers implement, build, and test.',
13
13
  '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.',
14
14
  '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.',
15
+ 'When this cluster has an Advisor, consult it before a design decision or when the evidence is thin; the decision remains yours.',
15
16
  '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.',
16
17
  '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.',
17
18
  '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.',
@@ -43,7 +43,7 @@ import * as clusterPlanStore from './clusterPlanStore.js';
43
43
  import * as clusterPlanBridge from './clusterPlanBridge.js';
44
44
  import * as taskLedger from './project/taskLedger.js';
45
45
  import { appendLedgerComment, persistLedgerKernelMutation, persistLedgerMutation } from './ws/taskLedgerHandlers.js';
46
- import { isClusterDirector } from '@arco/shared';
46
+ import { isClusterDirector, presetForText } from '@arco/shared';
47
47
  // peer_send dedupe — guards against the orphan-tool-use retry pattern:
48
48
  // a previous turn aborted mid-tool, leaving the model with no memory of
49
49
  // having sent (pruneOrphanToolUse drops the orphan assistant block); on
@@ -145,7 +145,7 @@ export async function peerSend(ctx, args, opts) {
145
145
  resolved = rolePrefix[0].wfid;
146
146
  }
147
147
  else if (rolePrefix.length === 0) {
148
- const roleWord = withRole.filter((r) => r.roleLc.split(/[^a-z0-9]+/).some((part) => part === ref));
148
+ const roleWord = withRole.filter((r) => (presetForText(r.role)?.label.toLowerCase() ?? r.roleLc).split(/[^a-z0-9]+/).some((part) => part === ref));
149
149
  if (roleWord.length === 1)
150
150
  resolved = roleWord[0].wfid;
151
151
  }
@@ -14,6 +14,7 @@ export interface ClusterState {
14
14
  idleNudgerEnabled?: boolean;
15
15
  autoTurnOnMailboxEnabled?: boolean;
16
16
  autoPickupMode?: AutoPickupMode;
17
+ autoPickupPausedAt?: number;
17
18
  remindBusy?: boolean;
18
19
  rulePickupLimits?: Partial<RulePickupLimits>;
19
20
  smartPickup?: {
@@ -102,6 +103,7 @@ export declare function setProgressTracking(clusterId: string, mode: ClusterProg
102
103
  export declare function setAutoTurnOnMailbox(clusterId: string, enabled: boolean): Promise<ClusterState | null>;
103
104
  export declare function setAutoPickup(clusterId: string, opts: {
104
105
  mode: AutoPickupMode;
106
+ paused?: boolean;
105
107
  evaluator?: SmartPickupEvaluator;
106
108
  limits?: Partial<SmartPickupLimits>;
107
109
  ruleLimits?: Partial<RulePickupLimits>;
@@ -109,6 +111,7 @@ export declare function setAutoPickup(clusterId: string, opts: {
109
111
  now?: number;
110
112
  }): Promise<ClusterState | null>;
111
113
  export declare function getAutoPickupMode(clusterId: string): AutoPickupMode;
114
+ export declare function isAutoPickupPaused(clusterId: string): boolean;
112
115
  export declare function autoPickupModeOf(state: Pick<ClusterState, 'autoPickupMode' | 'autoTurnOnMailboxEnabled'>): AutoPickupMode;
113
116
  export declare function isAutoTurnOnMailboxEnabled(clusterId: string): boolean;
114
117
  export declare function isAutoPickupWaking(clusterId: string): boolean;