arco-workbench 0.2.2 → 0.2.5

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 (276) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/THIRD_PARTY_NOTICES +2 -2
  3. package/client/dist/assets/{PhosphorBackdrop-BbR3xmfD.js → PhosphorBackdrop-CLILIwOQ.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-UMjbs9ZN.js → ThemedBackgroundShaderImpl-B87chcb5.js} +1 -1
  5. package/client/dist/assets/{XtermView-n135qz-f.js → XtermView-BP_j7WSN.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-CFSke4by.js → galleryEditor-B90phoBI.js} +1 -1
  7. package/client/dist/assets/{index-DeoJbjI3.js → index-BfPp1Oup.js} +270 -270
  8. package/client/dist/index.html +1 -1
  9. package/client/dist/manifest-mobile.webmanifest +1 -0
  10. package/client/src/App.tsx +2 -2
  11. package/client/src/components/AuthReloginNotice.tsx +7 -6
  12. package/client/src/components/ChatMessage.tsx +41 -29
  13. package/client/src/components/ChatPanel.tsx +17 -4
  14. package/client/src/components/ClaudeNativeAccountPicker.tsx +32 -0
  15. package/client/src/components/ClaudeNativeAuthRow.tsx +71 -19
  16. package/client/src/components/ClusterRightPanel/AddWorkerSection.tsx +11 -281
  17. package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +1 -1
  18. package/client/src/components/ClusterRightPanel/FreshMemberForm.tsx +315 -0
  19. package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +17 -7
  20. package/client/src/components/ClusterRightPanel/index.tsx +1 -1
  21. package/client/src/components/ClusterRightPanel/useFreshMemberPicker.ts +6 -4
  22. package/client/src/components/ClusterTab.tsx +2 -2
  23. package/client/src/components/Connections/Connections.tsx +7 -11
  24. package/client/src/components/Connections/model.ts +3 -1
  25. package/client/src/components/FileViewerModal.tsx +54 -17
  26. package/client/src/components/GitHubPanel/index.tsx +9 -5
  27. package/client/src/components/HandoffDialog.tsx +5 -3
  28. package/client/src/components/MobileShell.tsx +1 -33
  29. package/client/src/components/OperatorQuestionNotice.tsx +5 -4
  30. package/client/src/components/ProvidersPopover.tsx +6 -2
  31. package/client/src/components/RightPanel/ActivityTab.tsx +2 -1
  32. package/client/src/components/RightPanel/ConfigTab.tsx +23 -5
  33. package/client/src/components/RightPanel/OutputsPanel.tsx +21 -9
  34. package/client/src/components/RightPanel/outputsReconcile.ts +31 -0
  35. package/client/src/components/SettingsPanel.tsx +7 -10
  36. package/client/src/components/SpawnDialog.tsx +14 -3
  37. package/client/src/components/TabBar.tsx +2 -2
  38. package/client/src/components/TabContextMenu.tsx +73 -133
  39. package/client/src/components/TerminalInput.tsx +4 -3
  40. package/client/src/components/TranscriptWorkerDialog.tsx +14 -4
  41. package/client/src/components/UsageBar.tsx +37 -18
  42. package/client/src/components/WorkflowCreator/ClusterMembersSection.tsx +29 -3
  43. package/client/src/components/WorkflowCreator/index.tsx +29 -15
  44. package/client/src/components/WorkflowView.tsx +1 -1
  45. package/client/src/components/providerIndicator.ts +7 -3
  46. package/client/src/components/research/QuickResearchOverview.tsx +7 -3
  47. package/client/src/components/research/SavedQuickKeep.tsx +7 -3
  48. package/client/src/components/settings/GitHubAuthRow.tsx +34 -0
  49. package/client/src/explorer/ArtifactsLens.tsx +17 -8
  50. package/client/src/explorer/ExplorerApp.tsx +3 -3
  51. package/client/src/explorer/types.ts +3 -1
  52. package/client/src/help/content/cluster.tsx +10 -4
  53. package/client/src/help/content/composer.tsx +3 -2
  54. package/client/src/help/content/header.tsx +6 -3
  55. package/client/src/help/content/misc.tsx +9 -7
  56. package/client/src/help/content/rightPanel.tsx +11 -6
  57. package/client/src/help/content/settings.tsx +14 -3
  58. package/client/src/help/content/tabbar.tsx +1 -1
  59. package/client/src/help/manualSections/actions.tsx +5 -1
  60. package/client/src/help/manualSections/clusters.tsx +21 -15
  61. package/client/src/help/manualSections/configuration.tsx +6 -4
  62. package/client/src/help/manualSections/gettingStarted.tsx +4 -2
  63. package/client/src/help/manualSections/maintenance.tsx +24 -0
  64. package/client/src/help/manualSections/powerFeatures.tsx +4 -2
  65. package/client/src/help/manualSections/providers.tsx +11 -4
  66. package/client/src/help/manualSections/workspace.tsx +3 -3
  67. package/client/src/hooks/useClaudeNativeCatalog.ts +26 -0
  68. package/client/src/hooks/useClaudeNativeLogin.ts +16 -11
  69. package/client/src/hooks/useWebSocket.ts +4 -2
  70. package/client/src/layout/layoutRange.ts +14 -5
  71. package/client/src/main.tsx +2 -0
  72. package/client/src/questions/waitingQuestion.ts +2 -0
  73. package/client/src/stores/appStore.ts +5 -1
  74. package/client/src/stores/appStore.types.ts +2 -0
  75. package/client/src/stores/replayContext.ts +20 -0
  76. package/client/src/utils/chatFileLinks.ts +34 -3
  77. package/client/src/utils/claudeAuth.ts +9 -1
  78. package/client/src/ws/handleServerMessage.ts +11 -3
  79. package/docs/ARCHITECTURE.md +3 -3
  80. package/docs/BACKUP.md +1 -1
  81. package/docs/CHECKPOINTS.md +67 -3
  82. package/docs/CLIENT.md +11 -6
  83. package/docs/EXTENDING.md +1 -1
  84. package/docs/FEATURES.md +3 -3
  85. package/docs/GETTING_STARTED.md +5 -4
  86. package/docs/GIT_WORKBENCH.md +8 -0
  87. package/docs/GLOSSARY.md +2 -2
  88. package/docs/GOTCHAS.md +4 -4
  89. package/docs/HTTP_API.md +63 -30
  90. package/docs/OPERATIONS.md +11 -0
  91. package/docs/OPERATOR_ACTIONS.md +2 -2
  92. package/docs/OUTPUTS.md +48 -6
  93. package/docs/PERSISTENCE.md +1 -1
  94. package/docs/PRIMITIVES.md +4 -2
  95. package/docs/PROTOCOL_CLUSTER.md +12 -6
  96. package/docs/PROTOCOL_PRIMITIVES.md +1 -1
  97. package/docs/PROVIDERS.md +47 -10
  98. package/docs/RESEARCH.md +3 -3
  99. package/docs/SETTINGS.md +9 -4
  100. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -3
  101. package/node_modules/@arco/shared/dist/protocol/clusters.js +1 -1
  102. package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -1
  103. package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +2 -1
  104. package/node_modules/@arco/shared/dist/protocol/settings.d.ts +3 -0
  105. package/node_modules/@arco/shared/dist/protocol/settings.js +5 -0
  106. package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
  107. package/node_modules/@arco/shared/dist/protocol/workflows.js +0 -2
  108. package/node_modules/@arco/shared/package.json +1 -1
  109. package/package.json +2 -2
  110. package/scripts/packaging/services.mjs +20 -1
  111. package/scripts/packaging/update.mjs +37 -2
  112. package/server/dist/attention.d.ts +6 -0
  113. package/server/dist/attention.js +6 -0
  114. package/server/dist/auth.d.ts +5 -0
  115. package/server/dist/auth.js +31 -20
  116. package/server/dist/clusterAutoTurn.d.ts +5 -1
  117. package/server/dist/clusterAutoTurn.js +31 -9
  118. package/server/dist/clusterPresets.js +3 -3
  119. package/server/dist/effortValidation.d.ts +2 -2
  120. package/server/dist/effortValidation.js +4 -4
  121. package/server/dist/explorerArtifacts.d.ts +1 -0
  122. package/server/dist/explorerArtifacts.js +12 -1
  123. package/server/dist/explorerDocs.d.ts +1 -0
  124. package/server/dist/explorerDocs.js +4 -4
  125. package/server/dist/geminiMembers.d.ts +7 -1
  126. package/server/dist/geminiMembers.js +28 -14
  127. package/server/dist/gitSnapshots.d.ts +1 -0
  128. package/server/dist/gitSnapshots.js +547 -83
  129. package/server/dist/http/clusterRoutes.js +9 -3
  130. package/server/dist/http/conversationFiles.d.ts +36 -0
  131. package/server/dist/http/conversationFiles.js +222 -0
  132. package/server/dist/http/fileBytes.d.ts +3 -0
  133. package/server/dist/http/fileBytes.js +33 -0
  134. package/server/dist/http/fileContentRoute.d.ts +2 -0
  135. package/server/dist/http/fileContentRoute.js +139 -0
  136. package/server/dist/http/fileRead.d.ts +54 -2
  137. package/server/dist/http/fileRead.js +31 -24
  138. package/server/dist/http/outputRoutes.js +14 -21
  139. package/server/dist/http/readConfinement.d.ts +0 -11
  140. package/server/dist/http/readConfinement.js +4 -30
  141. package/server/dist/http/router.js +41 -66
  142. package/server/dist/index.js +26 -12
  143. package/server/dist/management/initHubLink.js +1 -1
  144. package/server/dist/outputs.js +8 -0
  145. package/server/dist/primitives/exportContext.d.ts +2 -0
  146. package/server/dist/primitives/exportContext.js +13 -2
  147. package/server/dist/primitives/runCompare.d.ts +7 -1
  148. package/server/dist/primitives/runCompare.js +44 -20
  149. package/server/dist/project/taskLedger.js +46 -34
  150. package/server/dist/providerAccounts.d.ts +4 -0
  151. package/server/dist/providerAccounts.js +20 -1
  152. package/server/dist/providers/antigravity/artifacts.d.ts +23 -0
  153. package/server/dist/providers/antigravity/artifacts.js +140 -0
  154. package/server/dist/providers/antigravity/index.js +85 -7
  155. package/server/dist/providers/antigravity/questions.d.ts +2 -0
  156. package/server/dist/providers/antigravity/questions.js +58 -0
  157. package/server/dist/providers/claude-native/auth.d.ts +9 -8
  158. package/server/dist/providers/claude-native/auth.js +50 -58
  159. package/server/dist/providers/claude-native/authStatus.d.ts +2 -2
  160. package/server/dist/providers/claude-native/authStatus.js +9 -7
  161. package/server/dist/providers/claude-native/catalog.d.ts +6 -5
  162. package/server/dist/providers/claude-native/catalog.js +50 -39
  163. package/server/dist/providers/claude-native/oauth.d.ts +10 -9
  164. package/server/dist/providers/claude-native/oauth.js +120 -96
  165. package/server/dist/providers/claude-native/worker.d.ts +1 -0
  166. package/server/dist/providers/claude-native/worker.js +38 -23
  167. package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -3
  168. package/server/dist/providers/codex-appserver/operatorQuestions.js +27 -13
  169. package/server/dist/providers/codexChatBoundary.js +6 -1
  170. package/server/dist/research/quickPromotion.d.ts +3 -0
  171. package/server/dist/research/quickPromotion.js +26 -9
  172. package/server/dist/research/savedQuickPromotion.js +2 -11
  173. package/server/dist/server/broadcast.js +6 -0
  174. package/server/dist/settings.d.ts +1 -0
  175. package/server/dist/settings.js +39 -7
  176. package/server/dist/skills.js +1 -1
  177. package/server/dist/smartPickupAdapters.d.ts +1 -0
  178. package/server/dist/smartPickupAdapters.js +2 -2
  179. package/server/dist/smartPickupObserver.js +8 -5
  180. package/server/dist/thirdPartySkills.js +11 -5
  181. package/server/dist/turnChanges.d.ts +1 -1
  182. package/server/dist/turnChanges.js +5 -4
  183. package/server/dist/usage.d.ts +1 -1
  184. package/server/dist/usage.js +39 -27
  185. package/server/dist/workers/WorkerManager.d.ts +1 -0
  186. package/server/dist/workers/WorkerManager.js +1 -0
  187. package/server/dist/workers/processKill.js +37 -24
  188. package/server/dist/workflowMeta.js +2 -2
  189. package/server/dist/ws/clusterHandlers.d.ts +2 -2
  190. package/server/dist/ws/clusterHandlers.js +127 -113
  191. package/server/dist/ws/clusterMembers.d.ts +1 -1
  192. package/server/dist/ws/clusterMembers.js +34 -4
  193. package/server/dist/ws/compactHandlers.js +30 -14
  194. package/server/dist/ws/compareHandlers.js +53 -21
  195. package/server/dist/ws/gateHandlers.js +2 -0
  196. package/server/dist/ws/genesisHandlers.js +5 -3
  197. package/server/dist/ws/handoffHandlers.d.ts +1 -1
  198. package/server/dist/ws/handoffHandlers.js +115 -39
  199. package/server/dist/ws/transcriptWorkerHandlers.js +7 -2
  200. package/server/dist/ws/turnEngine.js +37 -19
  201. package/server/dist/ws/updatePrimaryConfig.d.ts +3 -2
  202. package/server/dist/ws/updatePrimaryConfig.js +236 -133
  203. package/server/dist/ws/workflowHandlers.js +21 -4
  204. package/server/package.json +1 -1
  205. package/server/src/attention.ts +7 -0
  206. package/server/src/auth.ts +33 -20
  207. package/server/src/clusterAutoTurn.ts +31 -11
  208. package/server/src/clusterPresets.ts +2 -2
  209. package/server/src/effortValidation.ts +4 -4
  210. package/server/src/explorerArtifacts.ts +12 -1
  211. package/server/src/explorerDocs.ts +5 -5
  212. package/server/src/geminiMembers.ts +26 -15
  213. package/server/src/gitSnapshots.ts +538 -82
  214. package/server/src/http/clusterRoutes.ts +10 -3
  215. package/server/src/http/conversationFiles.ts +231 -0
  216. package/server/src/http/fileBytes.ts +34 -0
  217. package/server/src/http/fileContentRoute.ts +123 -0
  218. package/server/src/http/fileRead.ts +30 -25
  219. package/server/src/http/outputRoutes.ts +13 -13
  220. package/server/src/http/readConfinement.ts +3 -30
  221. package/server/src/http/router.ts +39 -62
  222. package/server/src/index.ts +27 -18
  223. package/server/src/management/initHubLink.ts +1 -1
  224. package/server/src/outputs.ts +8 -0
  225. package/server/src/primitives/exportContext.ts +14 -2
  226. package/server/src/primitives/runCompare.ts +73 -46
  227. package/server/src/project/taskLedger.ts +47 -30
  228. package/server/src/providerAccounts.ts +20 -1
  229. package/server/src/providers/antigravity/artifacts.ts +121 -0
  230. package/server/src/providers/antigravity/index.ts +64 -6
  231. package/server/src/providers/antigravity/questions.ts +52 -0
  232. package/server/src/providers/claude-native/auth.ts +45 -60
  233. package/server/src/providers/claude-native/authStatus.ts +9 -8
  234. package/server/src/providers/claude-native/catalog.ts +52 -35
  235. package/server/src/providers/claude-native/oauth.ts +101 -77
  236. package/server/src/providers/claude-native/worker.ts +38 -22
  237. package/server/src/providers/codex-appserver/operatorQuestions.ts +26 -12
  238. package/server/src/providers/codexChatBoundary.ts +6 -1
  239. package/server/src/research/quickPromotion.ts +24 -6
  240. package/server/src/research/savedQuickPromotion.ts +2 -8
  241. package/server/src/server/broadcast.ts +4 -0
  242. package/server/src/settings.ts +36 -8
  243. package/server/src/skills.ts +1 -1
  244. package/server/src/smartPickupAdapters.ts +3 -2
  245. package/server/src/smartPickupObserver.ts +8 -5
  246. package/server/src/thirdPartySkills.ts +11 -5
  247. package/server/src/turnChanges.ts +5 -4
  248. package/server/src/usage.ts +30 -22
  249. package/server/src/workers/WorkerManager.ts +2 -0
  250. package/server/src/workers/processKill.ts +37 -23
  251. package/server/src/workflowMeta.ts +2 -2
  252. package/server/src/ws/clusterHandlers.ts +107 -104
  253. package/server/src/ws/clusterMembers.ts +25 -6
  254. package/server/src/ws/compactHandlers.ts +29 -15
  255. package/server/src/ws/compareHandlers.ts +59 -25
  256. package/server/src/ws/gateHandlers.ts +2 -0
  257. package/server/src/ws/genesisHandlers.ts +5 -4
  258. package/server/src/ws/handoffHandlers.ts +105 -37
  259. package/server/src/ws/transcriptWorkerHandlers.ts +6 -2
  260. package/server/src/ws/turnEngine.ts +36 -18
  261. package/server/src/ws/updatePrimaryConfig.ts +230 -132
  262. package/server/src/ws/workflowHandlers.ts +20 -4
  263. package/shared/dist/protocol/clusters.d.ts +15 -3
  264. package/shared/dist/protocol/clusters.js +1 -1
  265. package/shared/dist/protocol/models.d.ts +6 -1
  266. package/shared/dist/protocol/operatorQuestions.d.ts +2 -1
  267. package/shared/dist/protocol/settings.d.ts +3 -0
  268. package/shared/dist/protocol/settings.js +5 -0
  269. package/shared/dist/protocol/workflows.d.ts +1 -0
  270. package/shared/dist/protocol/workflows.js +0 -2
  271. package/shared/src/protocol/clusters.ts +23 -5
  272. package/shared/src/protocol/compare.ts +2 -2
  273. package/shared/src/protocol/models.ts +8 -4
  274. package/shared/src/protocol/operatorQuestions.ts +2 -1
  275. package/shared/src/protocol/settings.ts +8 -1
  276. package/shared/src/protocol/workflows.ts +1 -1
@@ -7,6 +7,7 @@ import { stopTurnSizes } from '../storageTurnWatch.js';
7
7
  import { noteSmartPickupStop } from '../smartPickupObserver.js';
8
8
  import { isKnownProvider } from '../providers/index.js';
9
9
  import { publishWorkerActivity } from './turnEngine.js';
10
+ import { isUpdatingNativeAccount } from './updatePrimaryConfig.js';
10
11
  import { clearPrivateWatches } from '../voice/watches.js';
11
12
  // server/src/ws/workflowHandlers.ts — workflow-lifecycle WS handler region
12
13
  // extracted from index.ts (docs/ARCHITECTURE.md). Behavior-
@@ -44,7 +45,7 @@ import { getRecallIndex } from '../recall/index.js';
44
45
  import { promises as fsPromises } from 'fs';
45
46
  import path from 'path';
46
47
  import { artifactsDir } from '../workers/limits.js';
47
- import { resolveProviderAccount } from '../providerAccounts.js';
48
+ import { requireClaudeNativeAccount, resolveProviderAccount } from '../providerAccounts.js';
48
49
  import { destroySandbox } from '../providers/claude-native/sandboxStore.js';
49
50
  import { disposeProviderResources } from '../providers/index.js';
50
51
  import { cancelClaudeNativeCompaction } from '../providers/claude-native/index.js';
@@ -111,7 +112,7 @@ export async function handleCreateWorkflow(ws, session, config, options) {
111
112
  primaryEffort: saved.primaryEffort,
112
113
  ...(saved.primaryProvider === 'antigravity-cli' ? { skipPermissions: saved.antigravitySkipPermissions === true } : {}),
113
114
  autoCompaction: resolveAutoCompactionPolicy(saved.autoCompaction, undefined) ?? (saved.efficiencyAutoCompact === 'conservative' ? { enabled: true, thresholdPercent: 80 } : saved.efficiencyAutoCompact === 'aggressive' ? { enabled: true, thresholdPercent: 70 } : undefined),
114
- ...(saved.providerAccountRef ? { providerAccountRef: saved.providerAccountRef } : {}),
115
+ providerAccountRef: saved.providerAccountRef,
115
116
  ...(saved.claudeTransport
116
117
  ? { claudeTransport: saved.claudeTransport }
117
118
  : saved.primaryProvider === 'claude' && !hasClaudeCliSession
@@ -152,11 +153,11 @@ export async function handleCreateWorkflow(ws, session, config, options) {
152
153
  return;
153
154
  }
154
155
  if (!config.resumeWorkflowId && config.primaryEffort !== undefined &&
155
- !allowedWorkflowEfforts(provider, config.primaryModel).includes(config.primaryEffort)) {
156
+ !allowedWorkflowEfforts(provider, config.primaryModel, config.providerAccountRef).includes(config.primaryEffort)) {
156
157
  send(ws, { type: 'error', message: 'The selected effort is not supported by this provider and model.' });
157
158
  return;
158
159
  }
159
- config.primaryEffort = normalizedWorkflowEffort(provider, config.primaryModel, config.primaryEffort);
160
+ config.primaryEffort = normalizedWorkflowEffort(provider, config.primaryModel, config.primaryEffort, config.providerAccountRef);
160
161
  const primary = derivePrimaryConfig(config);
161
162
  const manager = new WorkerManager();
162
163
  // docs/PROVIDERS.md - fact-force defaults OFF for new tabs.
@@ -278,6 +279,18 @@ export async function handleCreateWorkflow(ws, session, config, options) {
278
279
  }
279
280
  }
280
281
  }
282
+ if (!resumed && (config.primaryProvider ?? 'claude') === 'claude' && config.providerAccountRef !== undefined) {
283
+ try {
284
+ await requireClaudeNativeAccount(config.providerAccountRef);
285
+ if (config.claudeTransport === 'cli' || config.ultracode)
286
+ throw new Error('Select Claude Native to use a Native account.');
287
+ config.claudeTransport = 'native';
288
+ }
289
+ catch (err) {
290
+ send(ws, { type: 'error', message: err instanceof Error ? err.message : 'Claude Native account unavailable.' });
291
+ return;
292
+ }
293
+ }
281
294
  // docs/ARCHITECTURE.md - from-nothing Genesis. A workflow created with a
282
295
  // genesis seed and no working directory runs the staged conversation in a
283
296
  // hidden scratch dir until `genesis_scaffold` creates the real project and
@@ -776,6 +789,10 @@ export function handleCancel(ws, workflowId) {
776
789
  send(ws, { type: 'error', message: 'Workflow storage is moving. Wait for the scaffold to finish before stopping this conversation.' });
777
790
  return;
778
791
  }
792
+ if (isUpdatingNativeAccount(wf)) {
793
+ send(ws, { type: 'error', message: 'Wait for the account change to finish before stopping this conversation.' });
794
+ return;
795
+ }
779
796
  // Smart: Automatic leaves the mail this member has now alone after STOP.
780
797
  void noteSmartPickupStop(workflowId).catch(() => undefined);
781
798
  wf.manager.killAll();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco/server",
3
- "version": "0.2.2",
3
+ "version": "0.2.5",
4
4
  "private": true,
5
5
  "type": "module"
6
6
  }
@@ -40,6 +40,13 @@ function firstSighting(id: string): boolean {
40
40
  return true;
41
41
  }
42
42
 
43
+ /**
44
+ * A question or gate Arco announced before a restart and shows again now. It is
45
+ * marked seen so the restored card does not raise a second desktop or phone
46
+ * alert (the BELL entry and the phone message went out the first time).
47
+ */
48
+ export function acknowledgeSighting(id: string): void { firstSighting(id); }
49
+
43
50
  export async function loadChannels(): Promise<NotificationChannels> {
44
51
  try {
45
52
  const parsed = JSON.parse(await readFile(channelsPath, 'utf-8'));
@@ -1,3 +1,4 @@
1
+ import { readSettings } from './settings.js';
1
2
  import { antigravityStatus } from './providers/antigravity/status.js';
2
3
  import { authLoginInstructions } from './authLoginInstructions.js';
3
4
  import { execFile } from 'child_process';
@@ -30,8 +31,10 @@ const CURSOR_KEYRING_UNREACHABLE = 'Cursor keeps its sign-in in the desktop keyr
30
31
  export interface AuthStatus {
31
32
  loggedIn: boolean;
32
33
  native?: ClaudeNativeAuthStatus;
34
+ nativeAccounts?: Record<string, ClaudeNativeAuthStatus>;
33
35
  cli?: ClaudeCliAuthStatus;
34
36
  probeFailed?: boolean;
37
+ githubState?: 'missing' | 'signed-out' | 'probe-failed';
35
38
  email?: string;
36
39
  subscriptionType?: string;
37
40
  orgName?: string;
@@ -125,10 +128,15 @@ async function probeClaudeAuthStatus(): Promise<AuthStatus | null> {
125
128
  }
126
129
 
127
130
  export async function getClaudeAuthStatus(): Promise<AuthStatus> {
128
- const [status, native] = await Promise.all([
131
+ const [status, native, settings] = await Promise.all([
129
132
  probeClaudeAuthStatus().then(async result => result ?? await probeClaudeAuthStatus()),
130
133
  getClaudeNativeAuthStatus(),
134
+ readSettings(),
131
135
  ]);
136
+ const legacyIds = new Set(settings.providerAccounts?.claude?.map(profile => profile.id));
137
+ const nativeAccounts = Object.fromEntries(await Promise.all((settings.providerAccounts?.claudeNative ?? [])
138
+ .filter(profile => !legacyIds.has(profile.id))
139
+ .map(async profile => [profile.id, await getClaudeNativeAuthStatus(profile.id)] as const)));
132
140
  const binding = await getCliUsageBinding();
133
141
  const cli: ClaudeCliAuthStatus = status
134
142
  ? { ...status, binding, checkedAt: Date.now() }
@@ -136,10 +144,10 @@ export async function getClaudeAuthStatus(): Promise<AuthStatus> {
136
144
  cli.binding = binding;
137
145
  cli.bindingCheckedAt = Date.now();
138
146
  if (status) lastClaudeStatus = cli;
139
- const nativeAvailable = native.credentialsPresent && native.state !== 'needs-attention';
147
+ const nativeAvailable = [native, ...Object.values(nativeAccounts)].some(account => account.credentialsPresent && account.state !== 'needs-attention');
140
148
  const probeFailed = (cli.probeFailed && !nativeAvailable) || (native.probeFailed && !cli.loggedIn);
141
149
  return {
142
- native, cli,
150
+ native, cli, ...(Object.keys(nativeAccounts).length ? { nativeAccounts } : {}),
143
151
  email: cli.email, subscriptionType: cli.subscriptionType, orgName: cli.orgName, apiProvider: cli.apiProvider,
144
152
  loggedIn: cli.loggedIn || nativeAvailable,
145
153
  probeFailed: probeFailed || undefined,
@@ -147,29 +155,34 @@ export async function getClaudeAuthStatus(): Promise<AuthStatus> {
147
155
  };
148
156
  }
149
157
 
150
- // `gh auth status` exits non-zero when not logged in and prints to stderr.
151
- // We shell out, then parse the active account / scopes. The `--active` flag
152
- // restricts to the currently-active host/account so multi-host users don't
153
- // produce ambiguous status.
158
+ // Human-readable gh status has appeared on either stream in supported versions.
159
+ // Never turn an unrecognized error or output into a signed-out verdict.
160
+ export function githubStatusFromProbe(stdout: string, stderr: string, failure?: { code?: unknown }): AuthStatus {
161
+ if (failure?.code === 'ENOENT') return { loggedIn: false, githubState: 'missing', error: 'GitHub CLI was not found. Install gh in the Arco server environment, then check again.' };
162
+ const output = `${stdout}\n${stderr}`;
163
+ if (!failure) {
164
+ const account = output.match(/Logged in to \S+ (?:account|as) (\S+)/)?.[1];
165
+ if (account) {
166
+ const scopes = output.match(/Token scopes: (.+)/)?.[1];
167
+ return { loggedIn: true, email: account, apiProvider: 'github-cli', subscriptionType: scopes ? `gh (${scopes.replace(/'/g, '')})` : 'gh' };
168
+ }
169
+ }
170
+ if (/You are not logged into any (?:GitHub hosts|accounts)/i.test(output) || /Failed to log in to \S+ (?:account|using token)/i.test(output) && /token .* invalid/i.test(output)) {
171
+ return { loggedIn: false, githubState: 'signed-out', error: 'GitHub CLI is not signed in. Sign in, then check again.' };
172
+ }
173
+ return { loggedIn: false, githubState: 'probe-failed', probeFailed: true, error: 'GitHub CLI status could not be checked. Run gh auth status in the Arco server environment, then check again.' };
174
+ }
175
+
154
176
  async function getGithubAuthStatus(): Promise<AuthStatus> {
155
177
  try {
156
- const { stdout } = await execFileAsync('gh', ['auth', 'status', '--active'], {
178
+ const { stdout, stderr } = await execFileAsync('gh', ['auth', 'status', '--active'], {
157
179
  maxBuffer: 256 * 1024,
158
180
  timeout: 10_000,
159
181
  });
160
- const account = stdout.match(/Logged in to \S+ account (\S+)/)?.[1];
161
- const scopes = stdout.match(/Token scopes: (.+)/)?.[1];
162
- return {
163
- loggedIn: Boolean(account),
164
- email: account,
165
- apiProvider: 'github-cli',
166
- subscriptionType: scopes ? `gh (${scopes.replace(/'/g, '')})` : 'gh',
167
- };
182
+ return githubStatusFromProbe(stdout, stderr);
168
183
  } catch (err) {
169
- return {
170
- loggedIn: false,
171
- error: err instanceof Error && 'stderr' in err ? String((err as { stderr: string }).stderr).slice(0, 200) : 'gh auth status failed',
172
- };
184
+ const failure = err as { code?: unknown; stdout?: string; stderr?: string };
185
+ return githubStatusFromProbe(failure.stdout ?? '', failure.stderr ?? '', failure);
173
186
  }
174
187
  }
175
188
 
@@ -45,7 +45,7 @@ import { join } from 'node:path';
45
45
  import * as clusterStore from './clusterStore.js';
46
46
  import * as clusterMailbox from './clusterMailbox.js';
47
47
  import type { ServerMessage } from '@arco/shared';
48
- import { isGeminiMember } from './geminiMembers.js';
48
+ import { geminiPickupAllowed, isGeminiMember } from './geminiMembers.js';
49
49
 
50
50
  export const GEMINI_AUTO_PICKUP_SKIP = 'Skipped a Gemini member: its mail waits for your NUDGE.';
51
51
  export const GEMINI_MAIL_SKIP = 'Mail from a Gemini member waits for your NUDGE.';
@@ -109,6 +109,21 @@ const ruleGuard = new RulePickupGuard(
109
109
  (cluster, content) => { atomicWriteFileSync(join(clusterStore.clusterDir(cluster), 'rule-pickup-ledger.json'), content, { mode: 0o600 }); },
110
110
  );
111
111
  const pendingChecks = new Set<string>();
112
+ // Members whose last turn ended in a terminal request_too_large. Automatic
113
+ // pickup stops waking them (their mail stays unread) until a turn succeeds or
114
+ // the member is dropped; a wake only adds to a history that is already too big.
115
+ const tooLargeMembers = new Set<string>();
116
+ export const MEMBER_BLOCKED_NOTICE = 'Its conversation is too large for the provider. Hand off or replace this member, then NUDGE it; its mail is kept.';
117
+ // Provider rejections that repeat for as long as the stored conversation stays
118
+ // the same size: Anthropic's request_too_large (413), its total-text-bytes
119
+ // limit (400 invalid_request_error), and context-window overflows.
120
+ const OVERSIZE_ERROR = /request_too_large|too many total text bytes|prompt is too long|context[ _]length|exceeds? the (?:maximum )?context/i;
121
+ export function isOversizeError(error: string): boolean { return OVERSIZE_ERROR.test(error); }
122
+ export function noteTurnOutcome(workflowId: string, error?: string | null): void {
123
+ if (error && isOversizeError(error)) tooLargeMembers.add(workflowId);
124
+ else if (!error) tooLargeMembers.delete(workflowId);
125
+ }
126
+ export function isMemberBlocked(workflowId: string): boolean { return tooLargeMembers.has(workflowId); }
112
127
  export function resumeRulePickup(clusterId: string): void { ruleGuard.resume(clusterId); }
113
128
  export function resetRulePickup(clusterId: string): void { ruleGuard.reset(clusterId); }
114
129
  export function interruptRulePickup(clusterId: string, member?: string): void { if (clusterStore.isAutoTurnOnMailboxEnabled(clusterId)) { try { ruleGuard.interrupt(clusterId, member); } catch (error) { console.error('[arco] Rule-based pickup ledger unavailable:', error); } } }
@@ -211,7 +226,7 @@ export async function pickupWaitingMail(clusterId: string, liveMembers = resolve
211
226
  if (!isBusyFn || !clusterStore.isAutoPickupWaking(clusterId) || clusterStore.isAutoPickupPaused(clusterId) || !liveMembers) return;
212
227
  for (const m of liveMembers) {
213
228
  if (m.busy) {
214
- if (dispatchBusyReminderFn) await remindBusyMember(clusterId,m.workflowId,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
229
+ if (!isGeminiMember(m.workflowId) && dispatchBusyReminderFn) await remindBusyMember(clusterId,m.workflowId,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
215
230
  continue;
216
231
  }
217
232
  if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId)) continue;
@@ -274,6 +289,7 @@ export function clearAutoTurnDepth(workflowId: string): void {
274
289
  export function dropMember(workflowId: string): void {
275
290
  memberState.delete(workflowId);
276
291
  pendingDepth.delete(workflowId);
292
+ tooLargeMembers.delete(workflowId);
277
293
  }
278
294
 
279
295
  // Chain depth the resume sweeps use for a member's pending mail.
@@ -314,7 +330,7 @@ function emitSkip(
314
330
  recipientWfid: string,
315
331
  senderWfid: string,
316
332
  chainDepth: number,
317
- reason: 'rate_capped' | 'depth_capped' | 'cooldown' | 'recipient_busy' | 'disabled' | 'ack_only' | 'budget_paused' | 'member_capped' | 'pair_paused' | 'operator_send_only' | 'gemini_mail',
333
+ reason: 'rate_capped' | 'depth_capped' | 'cooldown' | 'recipient_busy' | 'disabled' | 'ack_only' | 'budget_paused' | 'member_capped' | 'pair_paused' | 'operator_send_only' | 'gemini_mail' | 'member_blocked',
318
334
  now: number,
319
335
  notice?: string,
320
336
  ): void {
@@ -351,17 +367,15 @@ export function onPeerMessageSent(opts: {
351
367
  recipientWfid: string;
352
368
  incomingChainDepth: number;
353
369
  }): void {
354
- // docs/PROTOCOL_CLUSTER.md "Gemini members": mail to or from a Gemini
355
- // member waits for the operator's NUDGE on the recipient; no automatic
356
- // wake or busy reminder.
357
370
  const geminiRecipient = isGeminiMember(opts.recipientWfid);
358
- if (geminiRecipient || isGeminiMember(opts.senderWfid)) {
371
+ const recipientHeld = geminiRecipient && !geminiPickupAllowed(opts.recipientWfid);
372
+ if (recipientHeld || isGeminiMember(opts.senderWfid)) {
359
373
  if (clusterStore.isAutoTurnOnMailboxEnabled(opts.clusterId) && !clusterStore.isAutoPickupPaused(opts.clusterId)) {
360
- emitSkip(opts.clusterId, opts.recipientWfid, opts.senderWfid, opts.incomingChainDepth, geminiRecipient ? 'operator_send_only' : 'gemini_mail', Date.now(), geminiRecipient ? GEMINI_AUTO_PICKUP_SKIP : GEMINI_MAIL_SKIP);
374
+ emitSkip(opts.clusterId, opts.recipientWfid, opts.senderWfid, opts.incomingChainDepth, recipientHeld ? 'operator_send_only' : 'gemini_mail', Date.now(), recipientHeld ? GEMINI_AUTO_PICKUP_SKIP : GEMINI_MAIL_SKIP);
361
375
  }
362
376
  return;
363
377
  }
364
- if (isBusyFn && dispatchBusyReminderFn) void remindBusyMember(opts.clusterId,opts.recipientWfid,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
378
+ if (!geminiRecipient && isBusyFn && dispatchBusyReminderFn) void remindBusyMember(opts.clusterId,opts.recipientWfid,{isBusy:isBusyFn,hasClusterTools:hasClusterToolsFn,dispatch:dispatchBusyReminderFn});
365
379
  if (!clusterStore.isAutoTurnOnMailboxEnabled(opts.clusterId)) return;
366
380
  if (opts.incomingChainDepth > pendingChainDepth(opts.recipientWfid)) pendingDepth.set(opts.recipientWfid, opts.incomingChainDepth);
367
381
  if (clusterStore.isAutoPickupPaused(opts.clusterId)) return;
@@ -387,11 +401,16 @@ function fireRulePickup(opts: { clusterId: string; senderWfid: string; recipient
387
401
  const { clusterId, senderWfid, recipientWfid, incomingChainDepth } = opts;
388
402
  const now = Date.now();
389
403
 
390
- if (isGeminiMember(recipientWfid)) {
404
+ if (isGeminiMember(recipientWfid) && !geminiPickupAllowed(recipientWfid)) {
391
405
  emitSkip(clusterId, recipientWfid, senderWfid, incomingChainDepth, 'operator_send_only', now, GEMINI_AUTO_PICKUP_SKIP);
392
406
  return;
393
407
  }
394
408
 
409
+ if (isMemberBlocked(recipientWfid)) {
410
+ emitSkip(clusterId, recipientWfid, senderWfid, incomingChainDepth, 'member_blocked', now, MEMBER_BLOCKED_NOTICE);
411
+ return;
412
+ }
413
+
395
414
  // Guard 0: cluster toggle armed. Most clusters won't have this on; the
396
415
  // gate is the first check so the hot path is one map lookup when off.
397
416
  if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || clusterStore.isAutoPickupPaused(clusterId)) return;
@@ -497,7 +516,8 @@ export function smartChainDepthLimit(configured: number): number {
497
516
  return process.env.ARCO_CLUSTER_AUTO_TURN_MAX_CHAIN_DEPTH ? AUTO_TURN_MAX_CHAIN_DEPTH : configured;
498
517
  }
499
518
 
500
- export function sharedGuardProblem(clusterId: string, recipientWfid: string, incomingChainDepth: number, now = Date.now(), depthLimit = AUTO_TURN_MAX_CHAIN_DEPTH): 'depth_capped' | 'cooldown' | 'rate_capped' | null {
519
+ export function sharedGuardProblem(clusterId: string, recipientWfid: string, incomingChainDepth: number, now = Date.now(), depthLimit = AUTO_TURN_MAX_CHAIN_DEPTH): 'depth_capped' | 'cooldown' | 'rate_capped' | 'member_blocked' | null {
520
+ if (isMemberBlocked(recipientWfid)) return 'member_blocked';
501
521
  if (incomingChainDepth >= depthLimit) return 'depth_capped';
502
522
  const ms = getMemberState(recipientWfid);
503
523
  if (ms.lastFiredAt !== undefined && now - ms.lastFiredAt < AUTO_TURN_COOLDOWN_MS) return 'cooldown';
@@ -112,7 +112,7 @@ function normalizeMember(raw: unknown, idx: number): ClusterPresetMember {
112
112
  }
113
113
  const out: ClusterPresetMember = { provider, model };
114
114
  if (typeof r.effort === 'string' && r.effort.trim().length > 0) out.effort = r.effort.trim();
115
- if (provider === 'codex' && typeof r.providerAccountRef === 'string' && r.providerAccountRef.trim().length > 0) {
115
+ if ((provider === 'codex' || provider === 'claude') && typeof r.providerAccountRef === 'string' && r.providerAccountRef.trim().length > 0) {
116
116
  out.providerAccountRef = r.providerAccountRef.trim();
117
117
  }
118
118
  if (typeof r.role === 'string') {
@@ -164,8 +164,8 @@ function normalizeMember(raw: unknown, idx: number): ClusterPresetMember {
164
164
  }
165
165
  if (out.accessMode === 'isolated') {
166
166
  if (r.webAccess === false) out.webAccess = false;
167
- if (provider === 'claude' && (r.claudeTransport === 'native' || r.claudeTransport === 'cli')) out.claudeTransport = r.claudeTransport;
168
167
  }
168
+ if (provider === 'claude' && (r.claudeTransport === 'native' || r.claudeTransport === 'cli')) out.claudeTransport = r.claudeTransport;
169
169
  // Research panels keep each researcher's ADVANCED limits (docs/RESEARCH.md).
170
170
  if (out.accessMode === 'researcher') {
171
171
  if (r.webAccess === false) out.webAccess = false;
@@ -3,10 +3,10 @@ import { getCachedClaudeModelEfforts } from './providers/claude-native/catalog.j
3
3
  import { getCachedCodexModelCapabilities } from './providers/codex-appserver/catalog.js';
4
4
 
5
5
  // Follow the model catalog and the same static overrides as the picker.
6
- export function allowedWorkflowEfforts(provider: ProviderName | undefined, model: string): EffortLevel[] {
6
+ export function allowedWorkflowEfforts(provider: ProviderName | undefined, model: string, providerAccountRef?: string): EffortLevel[] {
7
7
  if (!provider || provider === 'claude') {
8
8
  const known = CLAUDE_MODEL_EFFORTS[model];
9
- const live = getCachedClaudeModelEfforts(model);
9
+ const live = getCachedClaudeModelEfforts(model, providerAccountRef);
10
10
  if (live?.length) return known ? CLAUDE_EFFORTS.filter((level) => known.includes(level) || live.includes(level)) : live;
11
11
  return known ?? CLAUDE_EFFORTS;
12
12
  }
@@ -20,8 +20,8 @@ export function allowedWorkflowEfforts(provider: ProviderName | undefined, model
20
20
  return Object.keys(EFFORT_RANK) as EffortLevel[];
21
21
  }
22
22
 
23
- export function normalizedWorkflowEffort(provider: ProviderName | undefined, model: string, effort: unknown): EffortLevel {
24
- const levels = allowedWorkflowEfforts(provider, model);
23
+ export function normalizedWorkflowEffort(provider: ProviderName | undefined, model: string, effort: unknown, providerAccountRef?: string): EffortLevel {
24
+ const levels = allowedWorkflowEfforts(provider, model, providerAccountRef);
25
25
  if (typeof effort === 'string' && levels.includes(effort as EffortLevel)) return effort as EffortLevel;
26
26
  if (typeof effort === 'string' && Object.hasOwn(EFFORT_RANK, effort)) {
27
27
  const rank = EFFORT_RANK[effort as EffortLevel];
@@ -18,10 +18,12 @@ import { constants } from 'fs';
18
18
  import { lstat, open, readFile, readdir, realpath, stat } from 'fs/promises';
19
19
  import { basename, join, resolve, sep } from 'path';
20
20
  import { homedir } from 'os';
21
+ import { listGeminiArtifacts } from './providers/antigravity/artifacts.js';
21
22
  import { arcoHome } from './arcoHome.js';
22
23
  import { assertSafePath, confinedPath } from './fileAccessPolicy.js';
23
24
 
24
25
  export interface ArtifactEntry {
26
+ id?: string; // registered Gemini output, opened by workflow and id
25
27
  path: string; // absolute, realpath-resolved, ⊆ $HOME
26
28
  name: string; // basename
27
29
  size: number; // bytes
@@ -134,8 +136,17 @@ async function collectForCwd(cwd: string): Promise<ArtifactEntry[]> {
134
136
  const wfid = wf.name;
135
137
  const files: string[] = [];
136
138
  await walkArtifactFiles(join(workflowsDir, wfid, 'artifacts'), 0, files);
137
- if (files.length === 0) continue; // empty artifact dir → skipped (the ~90%)
139
+ let gemini = await listGeminiArtifacts(cwd, wfid);
140
+ if (gemini.length) {
141
+ const { outputContext } = await import('./outputs.js');
142
+ const ctx = await outputContext(cwd, wfid).catch(() => null);
143
+ if (!ctx || await realpath(ctx.cwd) !== cwd) gemini = [];
144
+ }
145
+ if (files.length + gemini.length === 0) continue; // empty artifact dir → skipped (the ~90%)
138
146
  const meta = await readWorkflowMeta(cwd, wfid);
147
+ for (const file of gemini) {
148
+ results.push({ ...file, workflowId: wfid, ...meta, project, cwd });
149
+ }
139
150
  for (const f of files) {
140
151
  const rp = await realpathWithinHome(f);
141
152
  if (!rp) continue; // escaped $HOME or vanished — drop
@@ -89,8 +89,7 @@ export async function collectProjectDocs(project: string, limit = 1000): Promise
89
89
  return (await collectProjectDocsPage(project, limit)).entries;
90
90
  }
91
91
 
92
- async function collectScopedDocs(project: string): Promise<DocsPage> {
93
- const budget = scanBudget();
92
+ async function collectScopedDocs(project: string, budget = scanBudget()): Promise<DocsPage> {
94
93
  const out: DocEntry[] = [];
95
94
  const root = await scanBeforeDeadline(realpathWithinHome(project), budget);
96
95
  if (root) await scanDocuments(root, root, budget, out, file => confinedPath(file, [root], 'file'));
@@ -120,9 +119,10 @@ async function collectScopedDocs(project: string): Promise<DocsPage> {
120
119
 
121
120
  // Global doc scan across known projects, bounded per-project so a home load over
122
121
  // dozens of projects stays responsive. `project` scopes to one (full limit).
123
- export async function collectDocsPage(opts: { project?: string } = {}): Promise<DocsPage> {
124
- if (opts.project) return collectScopedDocs(opts.project);
125
- const global = scanBudget(50_000, 650);
122
+ // `budget` replaces the default scan budget; routes always use the defaults.
123
+ export async function collectDocsPage(opts: { project?: string; budget?: ScanBudget } = {}): Promise<DocsPage> {
124
+ if (opts.project) return collectScopedDocs(opts.project, opts.budget);
125
+ const global = opts.budget ?? scanBudget(50_000, 650);
126
126
  const known = await scanBeforeDeadline(readKnownCwds(), global);
127
127
  if (!known) return { entries: [], partial: true };
128
128
  const cwds = [...new Set(known)];
@@ -1,15 +1,5 @@
1
- // docs/PROTOCOL_CLUSTER.md "Gemini members". A Gemini (Antigravity) cluster
2
- // member takes a turn only from the operator's own action: NUDGE, or a message
3
- // typed in its composer. Mail to it waits in its mailbox, where the operator
4
- // may read, edit or cancel it before pressing NUDGE; the member then reads it
5
- // with peer_read like any other member. Each operator action gets a
6
- // single-use ticket bound to the member and the exact text, and
7
- // handleUserMessage (ws/turnEngine.ts) starts a Gemini member turn only with
8
- // a valid ticket, checked again when a queued message is taken. Automatic
9
- // turns (AUTO-PICKUP, Smart pickup, busy reminders, task dispatch,
10
- // broadcasts, CONTINUE DIRECTOR, timers, retries) carry no ticket and never
11
- // start one.
12
-
1
+ // Gemini member turns require a single-use ticket for the exact input.
2
+ // Operator input, previewed replacement history and an admitted AUTO-PICKUP wake can obtain one.
13
3
  import { createHash, randomUUID } from 'node:crypto';
14
4
  import { buildMessageGuardPolicy } from '@arco/shared';
15
5
  import * as clusterStore from './clusterStore.js';
@@ -25,13 +15,22 @@ import { listSkills, buildSkillsManifest } from './skills.js';
25
15
  import { gateProjectResources } from './projectTrust.js';
26
16
 
27
17
  export const GEMINI_PROVIDER = 'antigravity-cli';
28
- export const GEMINI_OPERATOR_ONLY_REFUSAL = 'A Gemini member turn starts only from your NUDGE or a message you type in its composer.';
18
+ export const GEMINI_OPERATOR_ONLY_REFUSAL = "Use NUDGE or the member's composer to start a Gemini turn, or enable AUTO-PICKUP for eligible cluster mail.";
29
19
 
30
20
  export function isGeminiMember(workflowId: string): boolean {
31
21
  return workflows.get(workflowId)?.config.primaryProvider === GEMINI_PROVIDER
32
22
  && clusterStore.getClusterIdForWorkflow(workflowId) !== undefined;
33
23
  }
34
24
 
25
+ // Research has a separate mailbox and wake policy. Ordinary pickup cannot
26
+ // cross into it or into a member with an isolated access mode.
27
+ export function geminiPickupAllowed(workflowId: string): boolean {
28
+ const clusterId = clusterStore.getClusterIdForWorkflow(workflowId);
29
+ if (!clusterId || !isGeminiMember(workflowId)) return false;
30
+ const cluster = clusterStore.getClusterCached(clusterId);
31
+ return !!cluster && !cluster.research && clusterStore.getMemberAccessMode(clusterId, workflowId) === 'standard';
32
+ }
33
+
35
34
  // A queued message may wait behind a long turn; six hours bounds memory
36
35
  // without expiring an operator message that is still waiting its turn.
37
36
  const TICKET_TTL_MS = 6 * 60 * 60 * 1000;
@@ -45,8 +44,7 @@ function prune(now: number): void {
45
44
  for (const [id, t] of tickets) if (t.expiresAt <= now) tickets.delete(id);
46
45
  }
47
46
 
48
- // Called only from the operator's WebSocket user_message (NUDGE or typed
49
- // message) for a Gemini member.
47
+ // Issued by the server for Gemini operator input, previewed replacement history or an eligible AUTO-PICKUP wake.
50
48
  export function issueGeminiSend(workflowId: string, content: string, now = Date.now()): string {
51
49
  prune(now);
52
50
  const id = randomUUID();
@@ -114,3 +112,16 @@ export async function geminiNudgeText(workflowId: string, nudge: string): Promis
114
112
  }
115
113
  return [instructions, skills, reminder, nudge].filter(part => part.trim()).join('\n\n---\n\n');
116
114
  }
115
+
116
+ export async function prepareGeminiPickup(workflowId: string, prompt: string, mode: 'rule' | 'smart-auto') {
117
+ const clusterId = clusterStore.getClusterIdForWorkflow(workflowId);
118
+ if (!clusterId) return undefined;
119
+ const isCurrent = () => geminiPickupAllowed(workflowId)
120
+ && clusterStore.getClusterIdForWorkflow(workflowId) === clusterId
121
+ && clusterStore.getAutoPickupMode(clusterId) === mode
122
+ && !clusterStore.isAutoPickupPaused(clusterId);
123
+ if (!isCurrent()) return undefined;
124
+ const content = await geminiNudgeText(workflowId, prompt);
125
+ if (!isCurrent()) return undefined;
126
+ return { content, ticket: issueGeminiSend(workflowId, content), isCurrent };
127
+ }