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
@@ -5,12 +5,13 @@ import { join } from 'path';
5
5
  import { homedir } from 'os';
6
6
  import { createHash } from 'crypto';
7
7
  import { CLAUDE_MODELS } from '@arco/shared';
8
- import type { Capabilities, EffortLevel, ModelName } from '@arco/shared';
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';
11
11
  import { probeStrataVersion, installedXolotlRevision, strataEngineReleaseVersion } from './providers/runtimeVersions.js';
12
12
  import { atomicWriteFile } from './atomicFile.js';
13
- import { resolveInstallableVersion } from './npmPlatformResolve.js';
13
+ import { probeCodexUpdate, describeCliUpdate, type CliUpdateDecision, type UpdateCommandResult } from './cliUpdateDecision.js';
14
+ import { compareVersions } from './updateCheck.js';
14
15
  import { arcoHome } from './arcoHome.js';
15
16
  import { commandArgs } from './windowsCommand.js';
16
17
 
@@ -76,23 +77,26 @@ export async function probeCapabilities(): Promise<Capabilities> {
76
77
  // Keep fallback
77
78
  }
78
79
 
79
- const [cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions] = await Promise.all([
80
+ const codexDecision = npmLatest('@openai/codex').then(probeCodexUpdate);
81
+ const [cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions, codexUpdate] = await Promise.all([
80
82
  probeVersion('claude'),
81
83
  probeVersion('codex'),
82
84
  probeVersion('cursor-agent'),
83
85
  probeStrataVersion(await getStrataBase()),
84
86
  installedXolotlRevision(await getDeepSeekBase()),
85
- probeLatestVersions(),
87
+ probeLatestVersions(codexDecision),
88
+ codexDecision,
86
89
  ]);
87
90
 
88
- return { efforts, models: MODELS, cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions };
91
+ return { efforts, models: MODELS, cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions,
92
+ codexUpdate: { kind: codexUpdate.kind, updateAvailable: !!codexUpdate.targetVersion && (compareVersions(codexVersion, codexUpdate.targetVersion) ?? 0) < 0, instruction: codexUpdate.message ?? codexUpdate.notice } };
89
93
  }
90
94
 
91
95
  // ── Upstream latest-version probes ──
92
96
  //
93
- // Source of truth for "is the operator running the latest CLI?" The three
94
- // npm-installed CLIs query the registry directly; Ollama queries GitHub
95
- // Releases since it's not npm-installed. All four are best-effort: any
97
+ // Source of truth for "is the operator running the latest CLI?" Claude reads
98
+ // 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
96
100
  // failure (offline, rate-limited, schema drift) leaves that key undefined
97
101
  // and the UI falls back to displaying the installed version with no
98
102
  // outdated indicator. Caller decides cadence — boot + the existing 4h
@@ -144,10 +148,10 @@ async function strataLatestRelease(): Promise<string | undefined> {
144
148
  return strataEngineReleaseVersion(feed, release);
145
149
  }
146
150
 
147
- export async function probeLatestVersions(): Promise<Capabilities['latestVersions']> {
151
+ export async function probeLatestVersions(codexDecision = npmLatest('@openai/codex').then(probeCodexUpdate)): Promise<Capabilities['latestVersions']> {
148
152
  const [claude, codex, ollama, strata, xolotl] = await Promise.all([
149
153
  npmLatest('@anthropic-ai/claude-code'),
150
- npmLatest('@openai/codex'),
154
+ codexDecision.then((decision) => decision.targetVersion),
151
155
  ollamaLatestRelease(),
152
156
  strataLatestRelease(),
153
157
  fetchJson('https://api.github.com/repos/Indras-Mirror/Xolotl/commits/HEAD').then((data) => {
@@ -165,6 +169,8 @@ export interface UpdateResult {
165
169
  currentVersion: string;
166
170
  capabilities: Capabilities;
167
171
  output: string;
172
+ outcome: CliUpdateOutcome;
173
+ message: string;
168
174
  // Set when preflight refuses the install or the command leaves no working binary.
169
175
  // The client renders this instead of a bogus version transition.
170
176
  error?: string;
@@ -174,136 +180,89 @@ export interface UpdateResult {
174
180
  notice?: string;
175
181
  }
176
182
 
177
- const UPDATE_COMMAND: Record<CliProvider, { cmd: string; args: string[] }> = {
178
- claude: { cmd: 'claude', args: ['update'] },
179
-
180
- codex: { cmd: 'npm', args: ['install', '-g', '@openai/codex@latest'] },
181
- };
182
-
183
- // npm package behind each CLI, for the pre-flight platform-build check. Claude
184
- // is absent on purpose: it self-updates via `claude update`, so there is no
185
- // `npm install` for us to aim at a specific version.
186
- const NPM_PACKAGE: Partial<Record<CliProvider, string>> = {
187
-
188
- codex: '@openai/codex',
189
- };
190
-
191
183
  function versionForProvider(caps: Capabilities, provider: CliProvider): string {
192
- if (provider === 'claude') return caps.cliVersion;
193
-
194
- return caps.codexVersion ?? 'unknown';
184
+ return provider === 'claude' ? caps.cliVersion : caps.codexVersion ?? 'unknown';
195
185
  }
196
186
 
197
187
  /**
198
- * Run the update command for the given CLI provider. Claude uses its built-in
199
- * self-updater; Codex falls back to `npm install -g …@latest`. Re-probes
200
- * capabilities after so callers get the refreshed version strings.
188
+ * Run the updater for the installation Arco actually launches. Claude uses its
189
+ * built-in updater; Codex shares one installation decision with its version flag.
190
+ * Re-probe afterwards: a successful command alone does not prove a working CLI.
201
191
  */
202
- export async function runCliUpdate(previous: Capabilities, provider: CliProvider = 'claude', runCommand = runUpdateCommand): Promise<UpdateResult> {
203
- const previousVersion = versionForProvider(previous, provider);
204
-
192
+ 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);
205
194
  // Pre-flight: for npm-installed CLIs, work out which version can actually run
206
195
  // on this machine before installing anything. `@latest` is not automatically
207
196
  // installable — a package whose binary ships as a platform-specific
208
197
  // optionalDependency is broken-on-arrival during the window between the
209
198
  // wrapper being tagged `latest` and that platform's tarball being published,
210
199
  // and npm reports that as success. See npmPlatformResolve.ts.
211
- const pkg = NPM_PACKAGE[provider];
212
- let notice: string | null = null;
213
- let { cmd, args } = UPDATE_COMMAND[provider];
214
-
215
- if (pkg) {
216
- // A null resolution means the registry was unreachable; fall through to the
217
- // plain `@latest` command rather than blocking an update on a network blip.
218
- const resolved = await resolveInstallableVersion(pkg);
219
- if (resolved) {
220
- notice = resolved.notice;
221
- if (resolved.blocked) {
222
- return {
223
- provider,
224
- updated: false,
225
- previousVersion,
226
- currentVersion: previousVersion,
227
- capabilities: previous,
228
- output: notice ?? 'Update deferred; the current CLI was not changed.',
229
- error: notice ?? 'Update deferred: no installable platform build was found.',
230
- ...(notice ? { notice } : {}),
231
- };
232
- }
233
- args = ['install', '-g', `${pkg}@${resolved.version}`];
234
- // Already on the version we would install, and it runs — skip the install
235
- // entirely so a no-op click can't churn a working CLI into a broken one.
236
- if (resolved.version === previousVersion && previousVersion !== 'broken' && previousVersion !== 'unknown') {
237
- return {
238
- provider,
239
- updated: false,
240
- previousVersion,
241
- currentVersion: previousVersion,
242
- capabilities: previous,
243
- output: `${pkg}@${previousVersion} is already installed`,
244
- ...(notice ? { notice } : {}),
245
- };
246
- }
247
- }
200
+ const decision: CliUpdateDecision = provider === 'codex'
201
+ ? await probeCodexUpdate(await npmLatest('@openai/codex'))
202
+ : { kind: 'unknown' as const, command: { cmd: 'claude', args: ['update'] }, targetVersion: previous.latestVersions?.claude };
203
+ const notice = decision.notice;
204
+ const capabilities = provider === 'codex'
205
+ ? { ...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 } }
206
+ : previous;
207
+ if (!decision.command) {
208
+ const message = decision.message ?? 'Update deferred; the current CLI was not changed.';
209
+ return { provider, previousVersion, currentVersion: previousVersion, capabilities, updated: false,
210
+ outcome: decision.outcome ?? 'deferred', message, output: message, notice: message };
248
211
  }
249
-
250
- let output = await runCommand(cmd, args);
212
+ // Already on the version we would install, and it runs — skip the install
213
+ // entirely so a no-op click can't churn a working CLI into a broken one.
214
+ if (provider === 'codex' && decision.targetVersion && (compareVersions(previousVersion, decision.targetVersion) ?? -1) >= 0) {
215
+ return { provider, previousVersion, currentVersion: previousVersion, capabilities, output: '',
216
+ ...describeCliUpdate(provider, previousVersion, previousVersion, decision.targetVersion, { exitCode: 0, output: '' }, notice),
217
+ ...(notice ? { notice } : {}) };
218
+ }
219
+ const { cmd, args } = decision.command;
220
+ let commandResult = await runCommand(cmd, args);
251
221
  let next = await probeCapabilities();
252
222
  let currentVersion = versionForProvider(next, provider);
253
223
 
254
224
  // Post-flight repair. The pre-flight check closes the common case, but npm can
255
225
  // still skip an optional dep that does exist (a mid-install network failure,
256
226
  // a poisoned cache), and that also exits 0. One retry with a clean cache is
257
- // cheap next to leaving the operator's CLI dead.
258
- if ((currentVersion === 'broken' || currentVersion === 'unknown') && pkg) {
259
- const repairArgs = [...args, '--force'];
260
- output += `\n\n[arco] ${provider} did not run after the update — retrying: npm ${repairArgs.join(' ')}`;
261
- output += `\n${await runCommand('npm', repairArgs)}`;
227
+ // cheap next to leaving the operator's CLI dead. Only a proven npm install
228
+ // with a successful updater exit can reach this npm repair path.
229
+ if (commandResult.exitCode === 0 && (currentVersion === 'broken' || currentVersion === 'unknown') && decision.repairArgs) {
230
+ const repairArgs = [...decision.repairArgs, '--force'];
231
+ const repaired = await runCommand('npm', repairArgs);
232
+ commandResult = { exitCode: repaired.exitCode, output: `${commandResult.output}\n\n[arco] ${provider} did not run after the update — retrying: npm ${repairArgs.join(' ')}\n${repaired.output}` };
262
233
  next = await probeCapabilities();
263
234
  currentVersion = versionForProvider(next, provider);
264
235
  }
265
236
 
266
237
  // A post-update probe that can't report a version means the command left the
267
238
  // CLI unusable, however cleanly it exited. Deciding `updated` purely on the
268
- // version string differing is how a silently-failed `npm install -g` surfaced
269
- // in the popover as a cheerful "→ vunknown" (2026-09-03, codex): npm skipped
270
- // the platform binary, exited 0, and 'unknown' !== '0.153.1' read as success.
271
- if (currentVersion === 'broken' || currentVersion === 'unknown') {
272
- return {
273
- provider,
274
- updated: false,
275
- previousVersion,
276
- currentVersion,
277
- capabilities: next,
278
- output,
279
- error: (await probeFailureReason(provider)) ?? `${provider} did not run after the update`,
280
- ...(notice ? { notice } : {}),
281
- };
239
+ // version string differing is how a silently-failed npm install surfaced
240
+ // as a cheerful "→ vunknown". Nonzero exits are also failures, even when
241
+ // the previous executable still runs and reports the same version.
242
+ const report = describeCliUpdate(provider, previousVersion, currentVersion, next.latestVersions?.[provider], commandResult, notice);
243
+ if (report.outcome === 'failed' && commandResult.exitCode === 0) {
244
+ const reason = await probeFailureReason(provider);
245
+ if (reason) { report.error = reason; report.message = reason; }
282
246
  }
283
-
284
- return {
285
- provider,
286
- updated: currentVersion !== previousVersion,
287
- previousVersion,
288
- currentVersion,
289
- capabilities: next,
290
- output,
291
- ...(notice ? { notice } : {}),
292
- };
247
+ return { provider, previousVersion, currentVersion, capabilities: next, output: commandResult.output,
248
+ ...report, ...(notice ? { notice } : {}) };
293
249
  }
294
250
 
295
- // Run an update command, folding a non-zero exit into the captured output — the
296
- // caller decides success from whether the CLI runs afterwards, never from the
297
- // exit code (npm exits 0 on a skipped optional dep).
298
- async function runUpdateCommand(cmd: string, args: string[]): Promise<string> {
251
+ // Keep the command status as well as its captured output. npm can exit zero
252
+ // after skipping an optional dep, but a nonzero updater exit is always failure.
253
+ async function runUpdateCommand(cmd: string, args: string[], provider: CliProvider): Promise<UpdateCommandResult> {
254
+ const env = { ...process.env };
255
+ if (provider === 'codex') {
256
+ // Native Codex must detect its own install; an enclosing agent's package
257
+ // manager provenance must not turn a standalone update into an npm install.
258
+ 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']) delete env[name];
259
+ }
299
260
  try {
300
- const { stdout, stderr } = await execFileAsync(...commandArgs(cmd, args), {
301
- maxBuffer: 4 * 1024 * 1024,
302
- timeout: 180_000,
303
- });
304
- return (stdout + stderr).trim();
261
+ const { stdout, stderr } = await execFileAsync(...commandArgs(cmd, args), { env, maxBuffer: 4 * 1024 * 1024, timeout: 180_000 });
262
+ return { output: (stdout + stderr).trim(), exitCode: 0 };
305
263
  } catch (err) {
306
- return err instanceof Error ? err.message : String(err);
264
+ const error = err as { code?: number | string; stdout?: string; stderr?: string; message?: string };
265
+ return { output: (error.stderr || error.stdout || error.message || String(err)).trim(), exitCode: typeof error.code === 'number' ? error.code : 1 };
307
266
  }
308
267
  }
309
268
 
@@ -0,0 +1,159 @@
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 type { CliUpdateOutcome } from '@arco/shared';
7
+ import { commandArgs, findWindowsCommand, npmShimTarget } from './windowsCommand.js';
8
+ import { resolveInstallableVersion, type ResolvedInstall } from './npmPlatformResolve.js';
9
+ import { compareVersions } from './updateCheck.js';
10
+
11
+ const exec = promisify(execFile);
12
+ const options = { timeout: 5_000, maxBuffer: 256 * 1024, killSignal: 'SIGKILL' as const };
13
+
14
+ export interface CodexInstallation {
15
+ kind: 'standalone' | 'npm' | 'unknown';
16
+ launcher?: string;
17
+ supportsUpdate: boolean;
18
+ npmRootMatches?: boolean;
19
+ instruction?: string;
20
+ }
21
+
22
+ export interface CliUpdateDecision {
23
+ kind: CodexInstallation['kind'];
24
+ targetVersion?: string;
25
+ command?: { cmd: string; args: string[] };
26
+ repairArgs?: string[];
27
+ outcome?: 'manual' | 'deferred';
28
+ message?: string;
29
+ notice?: string;
30
+ }
31
+
32
+ function inside(root: string, file: string): boolean {
33
+ const relative = path.relative(root, file);
34
+ return relative !== '' && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
35
+ }
36
+
37
+ async function canonical(file: string): Promise<string | undefined> {
38
+ try { return await fs.realpath(file); } catch { return undefined; }
39
+ }
40
+
41
+ async function launcherOnPath(): Promise<string | undefined> {
42
+ if (process.platform === 'win32') {
43
+ return findWindowsCommand('codex', process.env, (file) => {
44
+ try { return requireFile(file); } catch { return false; }
45
+ }) ?? undefined;
46
+ }
47
+ for (const dir of (process.env.PATH ?? '').split(path.delimiter).filter(Boolean)) {
48
+ const file = path.resolve(dir, 'codex');
49
+ try { await fs.access(file, constants.X_OK); if ((await fs.stat(file)).isFile()) return file; } catch { /* try the next PATH entry */ }
50
+ }
51
+ return undefined;
52
+ }
53
+
54
+ // Windows command lookup is synchronous so it can use the same PATH/PATHEXT
55
+ // selection as the provider launcher, including npm's .cmd wrapper.
56
+ function requireFile(file: string): boolean { return statSync(file).isFile(); }
57
+
58
+ export async function inspectCodexInstallation(): Promise<CodexInstallation> {
59
+ const launcher = await launcherOnPath();
60
+ if (!launcher) return { kind: 'unknown', supportsUpdate: false };
61
+ let entry = launcher;
62
+ if (process.platform === 'win32' && /\.(?:cmd|bat)$/i.test(launcher)) {
63
+ try { entry = npmShimTarget(launcher, await fs.readFile(launcher, 'utf8')) ?? launcher; } catch { /* leave an unreadable wrapper unknown */ }
64
+ }
65
+ const real = await canonical(entry);
66
+ if (!real) return { kind: 'unknown', launcher, supportsUpdate: false };
67
+ let supportsUpdate = false;
68
+ try {
69
+ const { stdout } = await exec(...commandArgs(launcher, ['--help']), options);
70
+ supportsUpdate = /^\s+update\s+/m.test(stdout);
71
+ } catch { /* an older or broken CLI can still have a proven npm repair path */ }
72
+
73
+ if (path.basename(real) === 'codex.js') {
74
+ const packageRoot = path.dirname(path.dirname(real));
75
+ try {
76
+ const manifest = JSON.parse(await fs.readFile(path.join(packageRoot, 'package.json'), 'utf8'));
77
+ if (manifest.name === '@openai/codex') {
78
+ const { stdout } = await exec(...commandArgs('npm', ['root', '-g']), options);
79
+ const target = await canonical(path.join(stdout.trim(), '@openai', 'codex'));
80
+ return { kind: 'npm', launcher, supportsUpdate, npmRootMatches: !!target && path.relative(target, packageRoot) === '' };
81
+ }
82
+ } catch { /* ownership could not be proved; never guess a global npm target */ }
83
+ 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.' };
84
+ }
85
+
86
+ const home = process.env.CODEX_HOME || path.join(homedir(), '.codex');
87
+ const releases = await canonical(path.join(home, 'packages', 'standalone', 'releases'));
88
+ if (releases && inside(releases, real)) {
89
+ const defaultBin = process.platform === 'win32'
90
+ ? process.env.LOCALAPPDATA && path.join(process.env.LOCALAPPDATA, 'Programs', 'OpenAI', 'Codex', 'bin')
91
+ : path.join(homedir(), '.local', 'bin');
92
+ const installBin = process.env.CODEX_INSTALL_DIR || defaultBin;
93
+ // The updater reruns the installer. Its destination must still be the
94
+ // active command directory, including a retained custom install directory.
95
+ if (!installBin || path.relative(path.resolve(path.dirname(launcher)), path.resolve(installBin)) !== '') {
96
+ 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.' };
97
+ }
98
+ return { kind: 'standalone', launcher, supportsUpdate };
99
+ }
100
+ return { kind: 'unknown', launcher, supportsUpdate };
101
+ }
102
+
103
+ export function decideCodexUpdate(installation: CodexInstallation, published?: string, resolved?: ResolvedInstall | null): CliUpdateDecision {
104
+ const base = { kind: installation.kind };
105
+ if (installation.kind === 'unknown' || !installation.launcher) {
106
+ 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.' };
107
+ }
108
+ if (installation.kind === 'standalone') {
109
+ return installation.supportsUpdate
110
+ ? { ...base, targetVersion: published, command: { cmd: installation.launcher, args: ['update'] } }
111
+ : { ...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.' };
112
+ }
113
+ if (!installation.npmRootMatches) {
114
+ 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.' };
115
+ }
116
+ if (!resolved) {
117
+ return { ...base, outcome: 'deferred', message: 'Arco could not confirm an installable Codex npm build. The current installation was not changed.' };
118
+ }
119
+ if (resolved.blocked || (installation.supportsUpdate && resolved.degraded)) {
120
+ return { ...base, outcome: 'deferred', message: `Codex v${resolved.latest} has no ${process.platform}-${process.arch} build available yet. The current installation was not changed.` };
121
+ }
122
+ const args = ['install', '-g', `@openai/codex@${resolved.version}`];
123
+ return {
124
+ ...base, targetVersion: resolved.version,
125
+ command: installation.supportsUpdate ? { cmd: installation.launcher, args: ['update'] } : { cmd: 'npm', args },
126
+ repairArgs: args,
127
+ ...(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}.` } : {}),
128
+ };
129
+ }
130
+
131
+ export async function probeCodexUpdate(published?: string): Promise<CliUpdateDecision> {
132
+ const installation = await inspectCodexInstallation();
133
+ const resolved = installation.kind === 'npm' && installation.npmRootMatches
134
+ ? await resolveInstallableVersion('@openai/codex') : undefined;
135
+ return decideCodexUpdate(installation, published, resolved);
136
+ }
137
+
138
+ export interface UpdateCommandResult { output: string; exitCode: number; }
139
+
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';
142
+ if (command.exitCode !== 0) {
143
+ const error = `${name} update failed: ${command.output.trim().slice(0, 2000) || `exit code ${command.exitCode}`}`;
144
+ return { outcome: 'failed', message: error, updated: false, error };
145
+ }
146
+ if (current === 'unknown' || current === 'broken') {
147
+ const error = `${name} did not run after the update.`;
148
+ return { outcome: 'failed', message: error, updated: false, error };
149
+ }
150
+ if (previous !== current && (compareVersions(current, previous) ?? 1) > 0) {
151
+ return { outcome: 'updated', message: `Updated ${name} from v${previous} to v${current}.${notice ? ` ${notice}` : ''}`, updated: true };
152
+ }
153
+ if (notice) return { outcome: 'deferred', message: notice, updated: false };
154
+ const comparison = target ? compareVersions(current, target) : null;
155
+ if (comparison !== null && comparison >= 0) return { outcome: 'current', message: `${name} v${current} is up to date for this installation.`, updated: false };
156
+ return { outcome: 'unchanged', updated: false, message: comparison !== null
157
+ ? `${name} did not change; v${target} is still available.`
158
+ : `The ${name} version did not change. Arco could not check whether it is up to date.` };
159
+ }
@@ -197,24 +197,28 @@ async function sweep(): Promise<void> {
197
197
  const membersByCluster = resolveMembersFn();
198
198
  if (!membersByCluster) return;
199
199
  for (const clusterId of clusterStore.listKnownClusterIds()) {
200
- if (!clusterStore.isAutoPickupWaking(clusterId)) continue;
201
- const liveMembers = membersByCluster.get(clusterId);
202
- if (!liveMembers || liveMembers.length === 0) continue;
203
- for (const m of liveMembers) {
204
- if (m.busy) {
205
- if (dispatchBusyReminderFn) await remindBusyMember(clusterId,m.workflowId,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
206
- continue;
207
- }
208
- if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId)) continue;
209
- const pending = await clusterMailbox.peek(m.workflowId).catch(() => []);
210
- if (pending.length === 0) continue;
211
- onPeerMessageSent({
212
- clusterId,
213
- senderWfid: pending[0].fromWorkflowId,
214
- recipientWfid: m.workflowId,
215
- incomingChainDepth: heldMailDepth(m.workflowId, pending),
216
- });
200
+ await pickupWaitingMail(clusterId, membersByCluster.get(clusterId));
201
+ }
202
+ }
203
+
204
+ // Resume uses the same scan as the periodic sweep, including every normal
205
+ // guard and budget. Never reset the Rule-based ledger to resume an operator pause.
206
+ export async function pickupWaitingMail(clusterId: string, liveMembers = resolveMembersFn?.()?.get(clusterId)): Promise<void> {
207
+ if (!isBusyFn || !clusterStore.isAutoPickupWaking(clusterId) || clusterStore.isAutoPickupPaused(clusterId) || !liveMembers) return;
208
+ for (const m of liveMembers) {
209
+ if (m.busy) {
210
+ if (dispatchBusyReminderFn) await remindBusyMember(clusterId,m.workflowId,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
211
+ continue;
217
212
  }
213
+ if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId)) continue;
214
+ const pending = await clusterMailbox.peek(m.workflowId).catch(() => []);
215
+ if (pending.length === 0) continue;
216
+ onPeerMessageSent({
217
+ clusterId,
218
+ senderWfid: pending[0].fromWorkflowId,
219
+ recipientWfid: m.workflowId,
220
+ incomingChainDepth: heldMailDepth(m.workflowId, pending),
221
+ });
218
222
  }
219
223
  }
220
224
 
@@ -346,6 +350,7 @@ export function onPeerMessageSent(opts: {
346
350
  if (isBusyFn && dispatchBusyReminderFn) void remindBusyMember(opts.clusterId,opts.recipientWfid,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
347
351
  if (!clusterStore.isAutoTurnOnMailboxEnabled(opts.clusterId)) return;
348
352
  if (opts.incomingChainDepth > pendingChainDepth(opts.recipientWfid)) pendingDepth.set(opts.recipientWfid, opts.incomingChainDepth);
353
+ if (clusterStore.isAutoPickupPaused(opts.clusterId)) return;
349
354
  try { ruleGuard.mail(opts.clusterId, opts.senderWfid, opts.recipientWfid); } catch (error) { console.error('[arco] Rule-based pickup ledger unavailable:', error); return; }
350
355
  const key = `${opts.clusterId}:${opts.recipientWfid}`;
351
356
  if (pendingChecks.has(key)) return;
@@ -369,7 +374,7 @@ function fireRulePickup(opts: { clusterId: string; senderWfid: string; recipient
369
374
 
370
375
  // Guard 0: cluster toggle armed. Most clusters won't have this on; the
371
376
  // gate is the first check so the hot path is one map lookup when off.
372
- if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId)) return;
377
+ if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || clusterStore.isAutoPickupPaused(clusterId)) return;
373
378
 
374
379
  // Guard 1: depth cap. An incoming chainDepth of (cap - 1) is the last one
375
380
  // we'll auto-turn on; the auto-turn it produces will land at cap, so the
@@ -406,12 +411,12 @@ function fireRulePickup(opts: { clusterId: string; senderWfid: string; recipient
406
411
  const wasBudgetPaused = ruleGuard.snapshot(clusterId).budgetPaused;
407
412
  const problem = ruleGuard.admit(clusterId, senderWfid, recipientWfid, limits, now);
408
413
  if (problem) {
409
- const notice = problem === 'budget_paused' && !wasBudgetPaused ? 'Wake budget reached. Open AUTO-PICKUP and select RESUME.' : undefined;
414
+ const notice = problem === 'budget_paused' && !wasBudgetPaused ? 'Wake budget reached. Select RESET BUDGET beside AUTO-PICKUP.' : undefined;
410
415
  emitSkip(clusterId, recipientWfid, senderWfid, incomingChainDepth, problem, now, notice); return;
411
416
  }
412
417
  const pauses = ruleGuard.stamp(clusterId, senderWfid, recipientWfid, limits, now);
413
418
  const notices = [
414
- ...(pauses.budgetPaused ? ['Wake budget reached. Open AUTO-PICKUP and select RESUME.'] : []),
419
+ ...(pauses.budgetPaused ? ['Wake budget reached. Select RESET BUDGET beside AUTO-PICKUP.'] : []),
415
420
  ...(pauses.pairPaused ? [`Alternating wakes paused between ${clusterStore.displayNameFor(senderWfid)} and ${clusterStore.displayNameFor(recipientWfid)}.`] : []),
416
421
  ];
417
422
 
@@ -453,7 +458,7 @@ function fireRulePickup(opts: { clusterId: string; senderWfid: string; recipient
453
458
  const dispatch = dispatchAutoTurnFn;
454
459
  setImmediate(() => {
455
460
  try {
456
- if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || isBusyFn?.(recipientWfid)) return;
461
+ if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || clusterStore.isAutoPickupPaused(clusterId) || isBusyFn?.(recipientWfid)) return;
457
462
  dispatch(recipientWfid, prompt);
458
463
  } catch (err) {
459
464
  // Dispatch failure leaves the cooldown + rate-cap entries in place
@@ -14,7 +14,7 @@ export interface BusyReminderDeps {
14
14
  }
15
15
  function enabled(clusterId: string, workflowId: string, now: number): boolean {
16
16
  const state = store.getClusterCached(clusterId);
17
- if (state?.remindBusy !== true || !state.members.includes(workflowId)) return false;
17
+ if (state?.remindBusy !== true || state.autoPickupPausedAt !== undefined || !state.members.includes(workflowId)) return false;
18
18
  const mode = store.autoPickupModeOf(state);
19
19
  return mode === 'rule' || (mode === 'smart-auto' && (state.smartPickup?.session?.expiresAt ?? 0) > now);
20
20
  }
@@ -14,6 +14,7 @@ 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
+ 'When this cluster has an Advisor, consult it before a design decision or when the evidence is thin; the decision remains yours.',
17
18
  'Delegate implementation, builds, and test runs only through peer_send and track them on the board. Do not write or edit product code or tests yourself.',
18
19
  'Stay available to the operator. Hand long-running work to peers: the project\'s checks to the tester (or a builder when there is no tester), CI watching to the change\'s author. Use their reports of what was done, run and not covered; do not run builds, test suites or CI waits yourself.',
19
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.',
@@ -44,7 +44,7 @@ import * as clusterPlanStore from './clusterPlanStore.js';
44
44
  import * as clusterPlanBridge from './clusterPlanBridge.js';
45
45
  import * as taskLedger from './project/taskLedger.js';
46
46
  import { appendLedgerComment, persistLedgerKernelMutation, persistLedgerMutation } from './ws/taskLedgerHandlers.js';
47
- import { isClusterDirector } from '@arco/shared';
47
+ import { isClusterDirector, presetForText } from '@arco/shared';
48
48
  import type { ServerMessage, MemberTier, LedgerTask, LedgerTaskStatus, TaskComment, TaskDetails, TaskLink, TaskRun, TaskSignoff, TaskSignoffState } from '@arco/shared';
49
49
 
50
50
  // peer_send dedupe — guards against the orphan-tool-use retry pattern:
@@ -210,7 +210,7 @@ export async function peerSend(
210
210
  if (rolePrefix.length === 1) {
211
211
  resolved = rolePrefix[0].wfid;
212
212
  } else if (rolePrefix.length === 0) {
213
- const roleWord = withRole.filter((r) => r.roleLc.split(/[^a-z0-9]+/).some((part) => part === ref));
213
+ const roleWord = withRole.filter((r) => (presetForText(r.role!)?.label.toLowerCase() ?? r.roleLc).split(/[^a-z0-9]+/).some((part) => part === ref));
214
214
  if (roleWord.length === 1) resolved = roleWord[0].wfid;
215
215
  }
216
216
  }
@@ -112,6 +112,9 @@ export interface ClusterState {
112
112
  // Rule-based), so clusters saved before the modes existed keep their
113
113
  // behavior. autoTurnOnMailboxEnabled is kept equal to "mode is rule".
114
114
  autoPickupMode?: AutoPickupMode;
115
+ // Operator pause timestamp, independent of the Rule-based wake-budget stop.
116
+ // The timestamp freezes Smart's remaining session time across restart.
117
+ autoPickupPausedAt?: number;
115
118
  remindBusy?: boolean;
116
119
  rulePickupLimits?: Partial<RulePickupLimits>;
117
120
  // Smart pickup choices kept across disarm: the active evaluator, the last
@@ -1001,13 +1004,28 @@ export async function setAutoTurnOnMailbox(
1001
1004
  // its own id and expiry; any other mode clears the session, which makes any
1002
1005
  // outstanding Smart work stale. The evaluator, last explicit choice and
1003
1006
  // limits persist across disarm so re-arming can offer them again.
1007
+ // Pause-only updates preserve session identity and remaining running time;
1008
+ // resume moves its expiry forward by the saved pause duration.
1004
1009
  export async function setAutoPickup(
1005
1010
  clusterId: string,
1006
- opts: { mode: AutoPickupMode; evaluator?: SmartPickupEvaluator; limits?: Partial<SmartPickupLimits>; ruleLimits?: Partial<RulePickupLimits>; remindBusy?: boolean; now?: number },
1011
+ opts: { mode: AutoPickupMode; paused?: boolean; evaluator?: SmartPickupEvaluator; limits?: Partial<SmartPickupLimits>; ruleLimits?: Partial<RulePickupLimits>; remindBusy?: boolean; now?: number },
1007
1012
  ): Promise<ClusterState | null> {
1008
1013
  return withClusterMetaLock(clusterId, async () => {
1009
1014
  const state = await readCluster(clusterId);
1010
1015
  if (!state) return null;
1016
+ if (typeof opts.paused === 'boolean') {
1017
+ if (opts.mode === 'off' || opts.mode !== autoPickupModeOf(state)) return null;
1018
+ const now = opts.now ?? Date.now();
1019
+ const pausedAt = state.autoPickupPausedAt;
1020
+ const session = state.smartPickup?.session;
1021
+ const smartPickup = !opts.paused && pausedAt !== undefined && session && isSmartPickupMode(opts.mode)
1022
+ ? { ...state.smartPickup, session: { ...session, expiresAt: session.expiresAt + Math.max(0, now - pausedAt) } }
1023
+ : state.smartPickup;
1024
+ const next = { ...state, autoPickupPausedAt: opts.paused ? pausedAt ?? now : undefined, smartPickup };
1025
+ await writeMetaAtomic(next);
1026
+ rebuildIndexFor(next);
1027
+ return next;
1028
+ }
1011
1029
  const now = opts.now ?? Date.now();
1012
1030
  const prior = state.smartPickup ?? {};
1013
1031
  const limits = opts.limits ? sanitizeSmartPickupLimits({ ...sanitizeSmartPickupLimits(prior.limits), ...opts.limits }) : prior.limits;
@@ -1033,6 +1051,9 @@ export async function setAutoPickup(
1033
1051
  rulePickupLimits: opts.ruleLimits ? sanitizeRulePickupLimits({ ...sanitizeRulePickupLimits(state.rulePickupLimits), ...opts.ruleLimits }) : state.rulePickupLimits,
1034
1052
  remindBusy: typeof opts.remindBusy === 'boolean' ? opts.remindBusy : state.remindBusy,
1035
1053
  autoPickupMode: opts.mode === 'off' ? undefined : opts.mode,
1054
+ autoPickupPausedAt: opts.mode !== 'off' && opts.mode === autoPickupModeOf(state) && state.autoPickupPausedAt !== undefined
1055
+ ? isSmartPickupMode(opts.mode) ? now : state.autoPickupPausedAt
1056
+ : undefined,
1036
1057
  autoTurnOnMailboxEnabled: opts.mode === 'rule' ? true : undefined,
1037
1058
  smartPickup: hasSmart ? smartPickup : undefined,
1038
1059
  };
@@ -1047,6 +1068,10 @@ export function getAutoPickupMode(clusterId: string): AutoPickupMode {
1047
1068
  return resolveAutoPickupMode(state?.autoPickupMode, state?.autoTurnOnMailboxEnabled);
1048
1069
  }
1049
1070
 
1071
+ export function isAutoPickupPaused(clusterId: string): boolean {
1072
+ return cache.get(clusterId)?.autoPickupPausedAt !== undefined;
1073
+ }
1074
+
1050
1075
  export function autoPickupModeOf(state: Pick<ClusterState, 'autoPickupMode' | 'autoTurnOnMailboxEnabled'>): AutoPickupMode {
1051
1076
  return resolveAutoPickupMode(state.autoPickupMode, state.autoTurnOnMailboxEnabled);
1052
1077
  }
@@ -36,7 +36,7 @@ The operator can set a per-workflow Claude effort floor via `minClaudeWorkerEffo
36
36
 
37
37
  ## Artifact references
38
38
 
39
- When a worker writes a report file (the server-appended footer points it at the workflow artifacts directory), reference the file in chat as `[artifact:<name>]` — e.g. `[artifact:audit-spawns.md]`. Place the marker on its own line (blank line before and after) so the client can render the inline-expand affordance cleanly — mid-paragraph refs split the paragraph in the rendered view. Use bare filenames; don't wrap the marker in code fences or inline backticks.
39
+ When a worker writes a conversation report in the workflow artifacts directory, reference the file in chat as `[artifact:<name>]` - e.g. `[artifact:audit-spawns.md]`. Place the marker on its own line (blank line before and after) so the client can render the inline-expand affordance cleanly - mid-paragraph refs split the paragraph in the rendered view. Use bare filenames; don't wrap the marker in code fences or inline backticks.
40
40
 
41
41
  **Open-ended asks are not opus signals.** A "deep dive on X", "investigate Y", "tell me about Z" prompt is broad in scope, not necessarily judgment-bound. Sonnet at `max` or GPT-5.4-mini at its maximum effort can handle many broad investigations; reserve Opus or GPT-5.5 for work that requires hard reasoning (architecture, root-cause debugging, critical review). Prompt breadth does not imply judgment depth.
42
42