arco-workbench 0.2.4 → 0.2.6

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 (254) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/THIRD_PARTY_NOTICES +2 -2
  3. package/client/dist/assets/{PhosphorBackdrop-CHXVFLGT.js → PhosphorBackdrop-YsHTmZJh.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-Bhs4I9jA.js → ThemedBackgroundShaderImpl-BEjpgoBW.js} +1 -1
  5. package/client/dist/assets/{XtermView-CdfurwFx.js → XtermView-wh7jNKvk.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-DYjZZ4cf.js → galleryEditor-CaOS2mmM.js} +1 -1
  7. package/client/dist/assets/{index-BjDmFvqG.js → index-j68SfA-l.js} +271 -271
  8. package/client/dist/index.html +1 -1
  9. package/client/src/App.tsx +2 -2
  10. package/client/src/components/AuthReloginNotice.tsx +7 -6
  11. package/client/src/components/ChatMessage.tsx +41 -29
  12. package/client/src/components/ChatPanel.tsx +17 -4
  13. package/client/src/components/ClaudeNativeAccountPicker.tsx +32 -0
  14. package/client/src/components/ClaudeNativeAuthRow.tsx +71 -19
  15. package/client/src/components/ClusterRightPanel/AddWorkerSection.tsx +11 -281
  16. package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +1 -1
  17. package/client/src/components/ClusterRightPanel/FreshMemberForm.tsx +315 -0
  18. package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +17 -7
  19. package/client/src/components/ClusterRightPanel/index.tsx +1 -1
  20. package/client/src/components/ClusterRightPanel/useFreshMemberPicker.ts +6 -4
  21. package/client/src/components/ClusterTab.tsx +2 -2
  22. package/client/src/components/Connections/Connections.tsx +5 -9
  23. package/client/src/components/Connections/model.ts +3 -1
  24. package/client/src/components/FileViewerModal.tsx +54 -17
  25. package/client/src/components/GitHubPanel/index.tsx +9 -5
  26. package/client/src/components/HandoffDialog.tsx +5 -3
  27. package/client/src/components/MobileShell.tsx +1 -33
  28. package/client/src/components/OperatorQuestionNotice.tsx +5 -4
  29. package/client/src/components/ProvidersPopover.tsx +6 -2
  30. package/client/src/components/RightPanel/ActivityTab.tsx +2 -1
  31. package/client/src/components/RightPanel/ConfigTab.tsx +23 -5
  32. package/client/src/components/RightPanel/OutputsPanel.tsx +21 -9
  33. package/client/src/components/RightPanel/outputsReconcile.ts +31 -0
  34. package/client/src/components/SettingsPanel.tsx +7 -10
  35. package/client/src/components/SpawnDialog.tsx +14 -3
  36. package/client/src/components/TabBar.tsx +2 -2
  37. package/client/src/components/TabContextMenu.tsx +73 -133
  38. package/client/src/components/TerminalInput.tsx +4 -3
  39. package/client/src/components/TranscriptWorkerDialog.tsx +14 -4
  40. package/client/src/components/UpdateAction.tsx +30 -7
  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/settings/GitHubAuthRow.tsx +34 -0
  47. package/client/src/explorer/ArtifactsLens.tsx +17 -8
  48. package/client/src/explorer/ExplorerApp.tsx +3 -3
  49. package/client/src/explorer/types.ts +3 -1
  50. package/client/src/help/content/cluster.tsx +10 -4
  51. package/client/src/help/content/composer.tsx +3 -2
  52. package/client/src/help/content/header.tsx +11 -4
  53. package/client/src/help/content/misc.tsx +7 -5
  54. package/client/src/help/content/rightPanel.tsx +8 -4
  55. package/client/src/help/content/settings.tsx +15 -4
  56. package/client/src/help/content/tabbar.tsx +1 -1
  57. package/client/src/help/manualSections/actions.tsx +5 -1
  58. package/client/src/help/manualSections/clusters.tsx +20 -14
  59. package/client/src/help/manualSections/configuration.tsx +6 -4
  60. package/client/src/help/manualSections/gettingStarted.tsx +4 -2
  61. package/client/src/help/manualSections/maintenance.tsx +31 -0
  62. package/client/src/help/manualSections/powerFeatures.tsx +1 -0
  63. package/client/src/help/manualSections/providers.tsx +11 -4
  64. package/client/src/help/manualSections/workspace.tsx +3 -3
  65. package/client/src/hooks/useClaudeNativeCatalog.ts +26 -0
  66. package/client/src/hooks/useClaudeNativeLogin.ts +16 -11
  67. package/client/src/hooks/useWebSocket.ts +4 -2
  68. package/client/src/layout/layoutRange.ts +4 -5
  69. package/client/src/questions/waitingQuestion.ts +2 -0
  70. package/client/src/stores/appStore.ts +5 -1
  71. package/client/src/stores/appStore.types.ts +2 -0
  72. package/client/src/stores/replayContext.ts +20 -0
  73. package/client/src/utils/chatFileLinks.ts +34 -3
  74. package/client/src/utils/claudeAuth.ts +9 -1
  75. package/client/src/ws/handleServerMessage.ts +11 -3
  76. package/docs/ARCHITECTURE.md +3 -3
  77. package/docs/BACKUP.md +1 -1
  78. package/docs/CLIENT.md +10 -5
  79. package/docs/EXTENDING.md +1 -1
  80. package/docs/FEATURES.md +3 -3
  81. package/docs/GETTING_STARTED.md +5 -4
  82. package/docs/GIT_WORKBENCH.md +8 -0
  83. package/docs/GLOSSARY.md +2 -2
  84. package/docs/GOTCHAS.md +4 -4
  85. package/docs/HTTP_API.md +54 -23
  86. package/docs/OPERATIONS.md +17 -1
  87. package/docs/OPERATOR_ACTIONS.md +2 -2
  88. package/docs/OUTPUTS.md +48 -6
  89. package/docs/PERSISTENCE.md +1 -1
  90. package/docs/PRIMITIVES.md +4 -2
  91. package/docs/PROTOCOL_CLUSTER.md +12 -6
  92. package/docs/PROTOCOL_PRIMITIVES.md +1 -1
  93. package/docs/PROVIDERS.md +46 -9
  94. package/docs/RESEARCH.md +1 -1
  95. package/docs/SETTINGS.md +9 -4
  96. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -3
  97. package/node_modules/@arco/shared/dist/protocol/clusters.js +1 -1
  98. package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -1
  99. package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +2 -1
  100. package/node_modules/@arco/shared/dist/protocol/settings.d.ts +3 -0
  101. package/node_modules/@arco/shared/dist/protocol/settings.js +5 -0
  102. package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
  103. package/node_modules/@arco/shared/dist/protocol/workflows.js +0 -2
  104. package/node_modules/@arco/shared/package.json +1 -1
  105. package/package.json +2 -2
  106. package/scripts/packaging/services.mjs +20 -1
  107. package/scripts/packaging/update.mjs +37 -2
  108. package/server/dist/attention.d.ts +6 -0
  109. package/server/dist/attention.js +6 -0
  110. package/server/dist/auth.d.ts +5 -0
  111. package/server/dist/auth.js +31 -20
  112. package/server/dist/clusterAutoTurn.d.ts +5 -1
  113. package/server/dist/clusterAutoTurn.js +31 -9
  114. package/server/dist/clusterPresets.js +3 -3
  115. package/server/dist/effortValidation.d.ts +2 -2
  116. package/server/dist/effortValidation.js +4 -4
  117. package/server/dist/explorerArtifacts.d.ts +1 -0
  118. package/server/dist/explorerArtifacts.js +12 -1
  119. package/server/dist/geminiMembers.d.ts +7 -1
  120. package/server/dist/geminiMembers.js +28 -14
  121. package/server/dist/http/conversationFiles.d.ts +36 -0
  122. package/server/dist/http/conversationFiles.js +222 -0
  123. package/server/dist/http/fileBytes.d.ts +3 -0
  124. package/server/dist/http/fileBytes.js +33 -0
  125. package/server/dist/http/fileContentRoute.d.ts +2 -0
  126. package/server/dist/http/fileContentRoute.js +139 -0
  127. package/server/dist/http/fileRead.d.ts +54 -2
  128. package/server/dist/http/fileRead.js +31 -24
  129. package/server/dist/http/outputRoutes.js +14 -21
  130. package/server/dist/http/readConfinement.d.ts +0 -11
  131. package/server/dist/http/readConfinement.js +4 -30
  132. package/server/dist/http/router.js +40 -66
  133. package/server/dist/index.js +26 -12
  134. package/server/dist/management/initHubLink.js +1 -1
  135. package/server/dist/outputs.js +8 -0
  136. package/server/dist/primitives/exportContext.d.ts +2 -0
  137. package/server/dist/primitives/exportContext.js +13 -2
  138. package/server/dist/primitives/runCompare.d.ts +7 -1
  139. package/server/dist/primitives/runCompare.js +44 -20
  140. package/server/dist/project/taskLedger.js +46 -34
  141. package/server/dist/providerAccounts.d.ts +4 -0
  142. package/server/dist/providerAccounts.js +20 -1
  143. package/server/dist/providers/antigravity/artifacts.d.ts +23 -0
  144. package/server/dist/providers/antigravity/artifacts.js +140 -0
  145. package/server/dist/providers/antigravity/index.js +85 -7
  146. package/server/dist/providers/antigravity/questions.d.ts +2 -0
  147. package/server/dist/providers/antigravity/questions.js +58 -0
  148. package/server/dist/providers/claude-native/auth.d.ts +9 -8
  149. package/server/dist/providers/claude-native/auth.js +50 -58
  150. package/server/dist/providers/claude-native/authStatus.d.ts +2 -2
  151. package/server/dist/providers/claude-native/authStatus.js +9 -7
  152. package/server/dist/providers/claude-native/catalog.d.ts +6 -5
  153. package/server/dist/providers/claude-native/catalog.js +50 -39
  154. package/server/dist/providers/claude-native/oauth.d.ts +10 -9
  155. package/server/dist/providers/claude-native/oauth.js +120 -96
  156. package/server/dist/providers/claude-native/worker.d.ts +1 -0
  157. package/server/dist/providers/claude-native/worker.js +38 -23
  158. package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -3
  159. package/server/dist/providers/codex-appserver/operatorQuestions.js +27 -13
  160. package/server/dist/server/broadcast.js +6 -0
  161. package/server/dist/settings.d.ts +1 -0
  162. package/server/dist/settings.js +39 -7
  163. package/server/dist/skills.js +1 -1
  164. package/server/dist/smartPickupAdapters.d.ts +1 -0
  165. package/server/dist/smartPickupAdapters.js +2 -2
  166. package/server/dist/smartPickupObserver.js +8 -5
  167. package/server/dist/thirdPartySkills.js +11 -5
  168. package/server/dist/usage.d.ts +1 -1
  169. package/server/dist/usage.js +39 -27
  170. package/server/dist/workers/WorkerManager.d.ts +1 -0
  171. package/server/dist/workers/WorkerManager.js +1 -0
  172. package/server/dist/workers/processKill.js +37 -24
  173. package/server/dist/workflowMeta.js +2 -2
  174. package/server/dist/ws/clusterHandlers.d.ts +2 -2
  175. package/server/dist/ws/clusterHandlers.js +127 -113
  176. package/server/dist/ws/clusterMembers.d.ts +1 -1
  177. package/server/dist/ws/clusterMembers.js +34 -4
  178. package/server/dist/ws/compactHandlers.js +30 -14
  179. package/server/dist/ws/compareHandlers.js +53 -21
  180. package/server/dist/ws/gateHandlers.js +2 -0
  181. package/server/dist/ws/genesisHandlers.js +5 -3
  182. package/server/dist/ws/handoffHandlers.d.ts +1 -1
  183. package/server/dist/ws/handoffHandlers.js +115 -39
  184. package/server/dist/ws/transcriptWorkerHandlers.js +7 -2
  185. package/server/dist/ws/turnEngine.js +33 -18
  186. package/server/dist/ws/updatePrimaryConfig.d.ts +3 -2
  187. package/server/dist/ws/updatePrimaryConfig.js +236 -133
  188. package/server/dist/ws/workflowHandlers.js +21 -4
  189. package/server/package.json +1 -1
  190. package/server/src/attention.ts +7 -0
  191. package/server/src/auth.ts +33 -20
  192. package/server/src/clusterAutoTurn.ts +31 -11
  193. package/server/src/clusterPresets.ts +2 -2
  194. package/server/src/effortValidation.ts +4 -4
  195. package/server/src/explorerArtifacts.ts +12 -1
  196. package/server/src/geminiMembers.ts +26 -15
  197. package/server/src/http/conversationFiles.ts +231 -0
  198. package/server/src/http/fileBytes.ts +34 -0
  199. package/server/src/http/fileContentRoute.ts +123 -0
  200. package/server/src/http/fileRead.ts +30 -25
  201. package/server/src/http/outputRoutes.ts +13 -13
  202. package/server/src/http/readConfinement.ts +3 -30
  203. package/server/src/http/router.ts +38 -62
  204. package/server/src/index.ts +27 -18
  205. package/server/src/management/initHubLink.ts +1 -1
  206. package/server/src/outputs.ts +8 -0
  207. package/server/src/primitives/exportContext.ts +14 -2
  208. package/server/src/primitives/runCompare.ts +73 -46
  209. package/server/src/project/taskLedger.ts +47 -30
  210. package/server/src/providerAccounts.ts +20 -1
  211. package/server/src/providers/antigravity/artifacts.ts +121 -0
  212. package/server/src/providers/antigravity/index.ts +64 -6
  213. package/server/src/providers/antigravity/questions.ts +52 -0
  214. package/server/src/providers/claude-native/auth.ts +45 -60
  215. package/server/src/providers/claude-native/authStatus.ts +9 -8
  216. package/server/src/providers/claude-native/catalog.ts +52 -35
  217. package/server/src/providers/claude-native/oauth.ts +101 -77
  218. package/server/src/providers/claude-native/worker.ts +38 -22
  219. package/server/src/providers/codex-appserver/operatorQuestions.ts +26 -12
  220. package/server/src/server/broadcast.ts +4 -0
  221. package/server/src/settings.ts +36 -8
  222. package/server/src/skills.ts +1 -1
  223. package/server/src/smartPickupAdapters.ts +3 -2
  224. package/server/src/smartPickupObserver.ts +8 -5
  225. package/server/src/thirdPartySkills.ts +11 -5
  226. package/server/src/usage.ts +30 -22
  227. package/server/src/workers/WorkerManager.ts +2 -0
  228. package/server/src/workers/processKill.ts +37 -23
  229. package/server/src/workflowMeta.ts +2 -2
  230. package/server/src/ws/clusterHandlers.ts +107 -104
  231. package/server/src/ws/clusterMembers.ts +25 -6
  232. package/server/src/ws/compactHandlers.ts +29 -15
  233. package/server/src/ws/compareHandlers.ts +59 -25
  234. package/server/src/ws/gateHandlers.ts +2 -0
  235. package/server/src/ws/genesisHandlers.ts +5 -4
  236. package/server/src/ws/handoffHandlers.ts +105 -37
  237. package/server/src/ws/transcriptWorkerHandlers.ts +6 -2
  238. package/server/src/ws/turnEngine.ts +32 -17
  239. package/server/src/ws/updatePrimaryConfig.ts +230 -132
  240. package/server/src/ws/workflowHandlers.ts +20 -4
  241. package/shared/dist/protocol/clusters.d.ts +15 -3
  242. package/shared/dist/protocol/clusters.js +1 -1
  243. package/shared/dist/protocol/models.d.ts +6 -1
  244. package/shared/dist/protocol/operatorQuestions.d.ts +2 -1
  245. package/shared/dist/protocol/settings.d.ts +3 -0
  246. package/shared/dist/protocol/settings.js +5 -0
  247. package/shared/dist/protocol/workflows.d.ts +1 -0
  248. package/shared/dist/protocol/workflows.js +0 -2
  249. package/shared/src/protocol/clusters.ts +23 -5
  250. package/shared/src/protocol/compare.ts +2 -2
  251. package/shared/src/protocol/models.ts +8 -4
  252. package/shared/src/protocol/operatorQuestions.ts +2 -1
  253. package/shared/src/protocol/settings.ts +8 -1
  254. package/shared/src/protocol/workflows.ts +1 -1
@@ -31,7 +31,7 @@ import path from 'path';
31
31
  import { runPrimaryTurn } from './seedWorker.js';
32
32
  import { loadEffectivePrompt, renderPrompt } from '../handoffPrompts.js';
33
33
  import { probeProjectFacts } from '../providers/claude-native/workspaceFacts.js';
34
- import { seedClaudeNativeWorkerFromForeignEvents } from '../providers/claude-native/index.js';
34
+ import { disposeClaudeNativeWorker, seedClaudeNativeWorkerFromForeignEvents } from '../providers/claude-native/index.js';
35
35
  import { releaseCodexAppServerWorker } from '../providers/codex-appserver/index.js';
36
36
  import { buildQuickHandoff } from './quickHandoff.js';
37
37
  import { isShellToolName } from '@arco/shared';
@@ -254,6 +254,7 @@ async function runOriginalWorkerNative(ctx, original, handoffId, artifactName, a
254
254
  cwd: ctx.cwd,
255
255
  workflowId: ctx.workflowId,
256
256
  claudeTransport: 'native',
257
+ providerAccountRef: original.providerAccountRef,
257
258
  };
258
259
  await seedClaudeNativeWorkerFromForeignEvents(ctx.workflowId, baseConfig, original.nativeReplaySource, original.nativeReplaySource.maxSeq);
259
260
  }
@@ -284,6 +285,7 @@ async function runOriginalWorkerNative(ctx, original, handoffId, artifactName, a
284
285
  // messages[] (seeded above for Spawn; in-memory for Handoff).
285
286
  resumeSessionId: undefined,
286
287
  claudeTransport: 'native',
288
+ providerAccountRef: original.providerAccountRef,
287
289
  interactionMode: 'chat',
288
290
  disableProviderHooks: true,
289
291
  // docs/PROVIDERS.md - handoff seed output feeds the next
@@ -411,6 +413,13 @@ function runFreshSummarizer(ctx, args, handoffId, artifactName, ab) {
411
413
  }, {
412
414
  cwd: ctx.cwd,
413
415
  workflowId: ctx.workflowId,
416
+ ...(args.summarizer.provider === 'claude' && args.summarizer.claudeTransport === 'native' ? {
417
+ providerAccountRef: args.summarizer.providerAccountRef,
418
+ claudeTransport: 'native',
419
+ sessionScopeId: handoffId,
420
+ interactionMode: 'chat',
421
+ disableProviderHooks: true,
422
+ } : {}),
414
423
  skipPermissions: false,
415
424
  // The summarizer only reads a transcript and returns prose — the artifact
416
425
  // is written by the handoff machinery, not the worker. Marking it
@@ -422,6 +431,7 @@ function runFreshSummarizer(ctx, args, handoffId, artifactName, ab) {
422
431
  // workflowId — would otherwise run the summary INSIDE the operator's live
423
432
  // Cursor session. See providers/index.ts (Phase 5 routing).
424
433
  sandbox: 'read-only',
434
+ antigravityHandoffWriter: args.summarizer.provider === 'antigravity-cli' && ctx.allowGeminiHandoffWriter === true,
425
435
  // docs/PROVIDERS.md - fresh-summarizer output becomes the
426
436
  // *input* to the next worker; forced normal regardless of source
427
437
  // tab's outputStyle.
@@ -432,7 +442,8 @@ function runFreshSummarizer(ctx, args, handoffId, artifactName, ab) {
432
442
  ...(args.summarizer.provider === 'codex' && args.summarizer.codexHome
433
443
  ? { providerAccountRef: args.summarizer.providerAccountRef, codexHome: args.summarizer.codexHome }
434
444
  : {}),
435
- });
445
+ }).finally(() => { if (args.summarizer.claudeTransport === 'native')
446
+ disposeClaudeNativeWorker(handoffId); });
436
447
  }).then(async (r) => {
437
448
  if (ab.killed)
438
449
  return { error: 'cancelled' };
@@ -1,4 +1,4 @@
1
- import { WorkerManager } from '../workers/WorkerManager.js';
1
+ import type { WorkerManager, WorkerManagerEvent, WorkerResult } from '../workers/WorkerManager.js';
2
2
  import type { ServerMessage, CompareLegConfig } from '@arco/shared';
3
3
  export interface CompareContext {
4
4
  workflowId: string;
@@ -24,6 +24,12 @@ export interface CompareRecord {
24
24
  export declare function readOnlyFileTools(provider: string): string[];
25
25
  /** The task each SECOND OPINION leg receives. */
26
26
  export declare function buildReplyDraftTask(question: string, context: string, fileAccess: boolean): string;
27
+ export declare function spawnCompareLeg(ctx: Pick<CompareContext, 'workflowId' | 'cwd' | 'manager'>, leg: CompareLegConfig, request: {
28
+ id: string;
29
+ task: string;
30
+ fileAccess?: boolean;
31
+ codexHome?: string;
32
+ }, onEvent: (event: WorkerManagerEvent) => void): Promise<WorkerResult>;
27
33
  export declare function runCompare(ctx: CompareContext, args: {
28
34
  prompt: string;
29
35
  legs: CompareLegConfig[];
@@ -15,6 +15,8 @@
15
15
  // (handled in the WS layer, recorded to events.jsonl). The optional synthesize
16
16
  // step is one more bounded leg the operator explicitly asks for. Never wired
17
17
  // into the primary turn loop. Clears the four-question test.
18
+ import { randomUUID } from 'node:crypto';
19
+ import { disposeClaudeNativeWorker } from '../providers/claude-native/index.js';
18
20
  // Read-only, no-TOOLS-by-default contract. A compare leg answers a prompt from
19
21
  // its own knowledge; it does not edit, write, or even read the repo by default
20
22
  // (that's what makes the race cheap and side-effect-free). Claude gets an EMPTY
@@ -46,6 +48,44 @@ export function buildReplyDraftTask(question, context, fileAccess) {
46
48
  lines.push('', '--- THE OPERATOR\'S QUESTION OR INTENT ---', '', question.trim() || '(none given: draft the most useful reply to the material above)');
47
49
  return lines.join('\n');
48
50
  }
51
+ // A resolved Claude account is a Native leg. Use the existing tool-free
52
+ // Chat surface and a fresh session, including when the leg synthesizes.
53
+ export async function spawnCompareLeg(ctx, leg, request, onEvent) {
54
+ const sessionScopeId = leg.provider === 'claude' && leg.providerAccountRef ? randomUUID() : undefined;
55
+ try {
56
+ return await ctx.manager.spawn({
57
+ id: request.id,
58
+ task: request.task,
59
+ model: leg.model,
60
+ effort: leg.effort,
61
+ provider: leg.provider,
62
+ tools: request.fileAccess ? readOnlyFileTools(leg.provider) : NO_TOOLS,
63
+ }, onEvent, {
64
+ cwd: ctx.cwd,
65
+ workflowId: ctx.workflowId,
66
+ // Read-only, no-tools. Claude gates via the empty `tools` allowlist;
67
+ // Codex gates via `-s read-only`; Ollama gates via the empty allowlist
68
+ // (its SAFE mode also refuses tools). skipPermissions=true for Ollama so
69
+ // SAFE mode doesn't emit denial strings for a prompt that needs none.
70
+ skipPermissions: leg.provider === 'ollama',
71
+ sandbox: 'read-only',
72
+ // docs/PROVIDERS.md - compared answers are read carefully by the
73
+ // operator; never plain/terse. Forced regardless of source-tab style.
74
+ outputStyle: 'normal',
75
+ ...(leg.provider === 'codex' && request.codexHome
76
+ ? { providerAccountRef: leg.providerAccountRef, codexHome: request.codexHome }
77
+ : {}),
78
+ ...(sessionScopeId ? {
79
+ sessionScopeId, claudeTransport: 'native', providerAccountRef: leg.providerAccountRef,
80
+ interactionMode: 'chat', chatWebAccess: false, incognito: true,
81
+ } : {}),
82
+ });
83
+ }
84
+ finally {
85
+ if (sessionScopeId)
86
+ disposeClaudeNativeWorker(sessionScopeId);
87
+ }
88
+ }
49
89
  // Per-compare synthesizer framing builder lives in the WS handler (it needs the
50
90
  // collected answers); runCompare itself just spawns whatever task it's handed.
51
91
  export function runCompare(ctx, args) {
@@ -69,13 +109,11 @@ export function runCompare(ctx, args) {
69
109
  const legId = legWorkerIds[legIndex];
70
110
  let collected = '';
71
111
  const legStartedAt = Date.now();
72
- const spawnP = ctx.manager.spawn({
112
+ const spawnP = spawnCompareLeg(ctx, leg, {
73
113
  id: legId,
74
114
  task: args.task ?? args.prompt,
75
- model: leg.model,
76
- effort: leg.effort,
77
- provider: leg.provider,
78
- tools: args.fileAccess ? readOnlyFileTools(leg.provider) : NO_TOOLS,
115
+ fileAccess: args.fileAccess,
116
+ codexHome: args.codexHomes?.[legIndex],
79
117
  }, (ev) => {
80
118
  if (ev.type === 'worker_text') {
81
119
  collected += ev.text;
@@ -92,23 +130,9 @@ export function runCompare(ctx, args) {
92
130
  type: 'system_notice',
93
131
  workflowId: ctx.workflowId,
94
132
  content: ev.notice,
133
+ authRecovery: ev.authRecovery,
95
134
  });
96
135
  }
97
- }, {
98
- cwd: ctx.cwd,
99
- workflowId: ctx.workflowId,
100
- // Read-only, no-tools. Claude gates via the empty `tools` allowlist;
101
- // Codex gates via `-s read-only`; Ollama gates via the empty allowlist
102
- // (its SAFE mode also refuses tools). skipPermissions=true for Ollama so
103
- // SAFE mode doesn't emit denial strings for a prompt that needs none.
104
- skipPermissions: leg.provider === 'ollama',
105
- sandbox: 'read-only',
106
- // docs/PROVIDERS.md - compared answers are read carefully by the
107
- // operator; never plain/terse. Forced regardless of source-tab style.
108
- outputStyle: 'normal',
109
- ...(leg.provider === 'codex' && args.codexHomes?.[legIndex]
110
- ? { providerAccountRef: leg.providerAccountRef, codexHome: args.codexHomes[legIndex] }
111
- : {}),
112
136
  });
113
137
  return spawnP.then((r) => {
114
138
  const completedAt = Date.now();
@@ -338,17 +338,36 @@ export async function loadKernel(cwd, boardKey) {
338
338
  const snapshot = await readKernelSnapshot(cwd, boardKey);
339
339
  if (snapshot !== null)
340
340
  return snapshot;
341
- const tasks = await rebuildFromEvents(cwd, boardKey);
342
- const comments = await rebuildCommentsFromEvents(cwd, boardKey);
343
- const runs = await rebuildRunsFromEvents(cwd, boardKey);
344
- const proposalReceipts = {};
345
- for (const event of await taskLedgerEvents(cwd, boardKey)) {
346
- const receipt = event.payload?.proposalReceipt;
347
- if (typeof receipt?.key === 'string' && typeof receipt.taskId === 'string')
348
- proposalReceipts[receipt.key] = receipt.taskId;
349
- }
350
- await saveKernel(cwd, { tasks, comments, runs, proposalReceipts }, boardKey).catch(() => { });
351
- return { tasks, comments, runs, proposalReceipts };
341
+ return rebuildKernelOnce(cwd, boardKey);
342
+ }
343
+ // Without a snapshot the board is folded from every conversation's log in the
344
+ // project. Reconnecting tabs of one project each ask for the board at once, so
345
+ // concurrent requests share one rebuild: N tabs used to start N rebuilds, each
346
+ // reading all N logs again, and the server answered none of them for many
347
+ // seconds on a project with long histories.
348
+ const kernelRebuilds = new Map();
349
+ function rebuildKernelOnce(cwd, boardKey) {
350
+ const key = `${cwd}\0${sanitizeBoardKey(boardKey) ?? ''}`;
351
+ const running = kernelRebuilds.get(key);
352
+ if (running)
353
+ return running;
354
+ const started = (async () => {
355
+ // One pass over the logs gives the tasks, comments, runs and receipts.
356
+ const events = await taskLedgerEvents(cwd, boardKey);
357
+ const tasks = foldTasks(events);
358
+ const comments = foldComments(events);
359
+ const runs = foldRuns(events);
360
+ const proposalReceipts = {};
361
+ for (const event of events) {
362
+ const receipt = event.payload?.proposalReceipt;
363
+ if (typeof receipt?.key === 'string' && typeof receipt.taskId === 'string')
364
+ proposalReceipts[receipt.key] = receipt.taskId;
365
+ }
366
+ await saveKernel(cwd, { tasks, comments, runs, proposalReceipts }, boardKey).catch(() => { });
367
+ return { tasks, comments, runs, proposalReceipts };
368
+ })().finally(() => { kernelRebuilds.delete(key); });
369
+ kernelRebuilds.set(key, started);
370
+ return started;
352
371
  }
353
372
  export async function saveKernel(cwd, state, boardKey) {
354
373
  if (!cwd)
@@ -461,25 +480,7 @@ export function formatBoardForModel(tasks) {
461
480
  function eventBelongsToBoard(ev, boardKey) {
462
481
  return sanitizeBoardKey(ev.boardKey) === sanitizeBoardKey(boardKey);
463
482
  }
464
- export async function rebuildFromEvents(cwd, boardKey) {
465
- if (!cwd)
466
- return [];
467
- const metas = await listWorkflowMetas(cwd).catch(() => []);
468
- const events = [];
469
- for (const meta of metas) {
470
- const msgs = await replayEvents(cwd, meta.workflowId, 0).catch(() => []);
471
- for (const m of msgs) {
472
- if (m.type !== 'task_ledger_event')
473
- continue;
474
- const ev = m;
475
- // Only fold events for THIS cwd (a workflow's log is cwd-local, but the
476
- // event carries cwd explicitly — guard against a moved log).
477
- if (ev.cwd !== cwd || !eventBelongsToBoard(ev, boardKey))
478
- continue;
479
- events.push({ ...ev, seq: ev.seq ?? 0 });
480
- }
481
- }
482
- events.sort((a, b) => (a.at - b.at) || (a.seq - b.seq));
483
+ function foldTasks(events) {
483
484
  const byId = new Map();
484
485
  for (const ev of events) {
485
486
  if (ev.op === 'delete') {
@@ -492,6 +493,11 @@ export async function rebuildFromEvents(cwd, boardKey) {
492
493
  }
493
494
  return [...byId.values()].sort((a, b) => a.createdAt - b.createdAt);
494
495
  }
496
+ export async function rebuildFromEvents(cwd, boardKey) {
497
+ if (!cwd)
498
+ return [];
499
+ return foldTasks(await taskLedgerEvents(cwd, boardKey));
500
+ }
495
501
  async function taskLedgerEvents(cwd, boardKey) {
496
502
  if (!cwd)
497
503
  return [];
@@ -511,9 +517,9 @@ async function taskLedgerEvents(cwd, boardKey) {
511
517
  events.sort((a, b) => (a.at - b.at) || (a.seq - b.seq));
512
518
  return events;
513
519
  }
514
- export async function rebuildCommentsFromEvents(cwd, boardKey) {
520
+ function foldComments(events) {
515
521
  const comments = [];
516
- for (const ev of await taskLedgerEvents(cwd, boardKey)) {
522
+ for (const ev of events) {
517
523
  const comment = ev.payload?.comment;
518
524
  if (isTaskComment(comment)) {
519
525
  comments.push(normalizeComment(comment));
@@ -522,9 +528,12 @@ export async function rebuildCommentsFromEvents(cwd, boardKey) {
522
528
  comments.sort((a, b) => a.createdAt - b.createdAt);
523
529
  return comments;
524
530
  }
525
- export async function rebuildRunsFromEvents(cwd, boardKey) {
531
+ export async function rebuildCommentsFromEvents(cwd, boardKey) {
532
+ return foldComments(await taskLedgerEvents(cwd, boardKey));
533
+ }
534
+ function foldRuns(events) {
526
535
  const byId = new Map();
527
- for (const ev of await taskLedgerEvents(cwd, boardKey)) {
536
+ for (const ev of events) {
528
537
  const run = ev.payload?.run;
529
538
  if ((ev.op === 'run_started'
530
539
  || ev.op === 'run_completed'
@@ -539,6 +548,9 @@ export async function rebuildRunsFromEvents(cwd, boardKey) {
539
548
  }
540
549
  return [...byId.values()].sort((a, b) => a.startedAt - b.startedAt);
541
550
  }
551
+ export async function rebuildRunsFromEvents(cwd, boardKey) {
552
+ return foldRuns(await taskLedgerEvents(cwd, boardKey));
553
+ }
542
554
  // ── mutation helpers (pure — caller persists + emits the event) ──────────────
543
555
  export function newTask(input) {
544
556
  const now = Date.now();
@@ -7,5 +7,9 @@ export interface ResolvedProviderAccount {
7
7
  export declare function expandHomePath(p: string): string;
8
8
  export declare function accountShortLabel(profile: ProviderAccountProfile): string;
9
9
  export declare function configuredAccounts(provider: 'codex' | 'claude', cwd?: string): Promise<ProviderAccountProfile[]>;
10
+ export declare class ClaudeNativeAccountUnavailableError extends Error {
11
+ constructor();
12
+ }
13
+ export declare function requireClaudeNativeAccount(accountRef?: string): Promise<string>;
10
14
  export declare function resolveProviderAccount(provider: ProviderName, accountRef: string | undefined, cwd?: string): Promise<ResolvedProviderAccount | null>;
11
15
  export declare function ensureCodexAccountHome(codexHome: string): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import { mkdir, readFile, writeFile } from 'fs/promises';
2
2
  import { dirname, join, resolve } from 'path';
3
3
  import { homedir } from 'os';
4
- import { TERMINAL_CODEX_ACCOUNT } from '@arco/shared';
4
+ import { DEFAULT_CLAUDE_NATIVE_ACCOUNT, isClaudeNativeProfileId, TERMINAL_CODEX_ACCOUNT } from '@arco/shared';
5
5
  import { readSettings } from './settings.js';
6
6
  import { arcoHome } from './arcoHome.js';
7
7
  export function expandHomePath(p) {
@@ -22,6 +22,25 @@ export async function configuredAccounts(provider, cwd) {
22
22
  const settings = await readSettings(cwd).catch(() => null);
23
23
  return settings?.providerAccounts?.[provider] ?? [];
24
24
  }
25
+ export class ClaudeNativeAccountUnavailableError extends Error {
26
+ constructor() {
27
+ super('The saved Claude Native account is unavailable. Choose an account in CONFIG before sending again.');
28
+ this.name = 'ClaudeNativeAccountUnavailableError';
29
+ }
30
+ }
31
+ // Native keeps the original store for unbound workflows. Legacy Claude labels
32
+ // were never credential bindings and cannot opt an old tab into a new sign-in.
33
+ export async function requireClaudeNativeAccount(accountRef) {
34
+ if (accountRef === undefined || accountRef === DEFAULT_CLAUDE_NATIVE_ACCOUNT)
35
+ return DEFAULT_CLAUDE_NATIVE_ACCOUNT;
36
+ if (isClaudeNativeProfileId(accountRef)) {
37
+ const settings = await readSettings();
38
+ if (settings.providerAccounts?.claudeNative?.some(profile => profile.id === accountRef)
39
+ && !settings.providerAccounts.claude?.some(profile => profile.id === accountRef))
40
+ return accountRef;
41
+ }
42
+ throw new ClaudeNativeAccountUnavailableError();
43
+ }
25
44
  export async function resolveProviderAccount(provider, accountRef, cwd) {
26
45
  if (provider !== 'codex' && provider !== 'claude')
27
46
  return null;
@@ -0,0 +1,23 @@
1
+ export declare function geminiSessionKey(file: string): string | null | undefined;
2
+ export declare function collectGeminiArtifacts(opts: {
3
+ sessionId: string;
4
+ storeCwd: string;
5
+ workflowId: string;
6
+ }): Promise<void>;
7
+ export declare function listGeminiArtifacts(cwd: string, workflowId: string): Promise<{
8
+ id: string;
9
+ path: string;
10
+ name: string;
11
+ size: number;
12
+ mtime: number;
13
+ }[]>;
14
+ export declare function openGeminiArtifact(cwd: string, workflowId: string, selector: {
15
+ key: string;
16
+ } | {
17
+ id: string;
18
+ }): Promise<{
19
+ id: string;
20
+ handle: import("fs/promises").FileHandle;
21
+ info: import("fs").Stats;
22
+ file: string;
23
+ }>;
@@ -0,0 +1,140 @@
1
+ // The CLI owns its session files. Only names observed at turn completion are
2
+ // recorded, independently of writable project metadata. No Gemini directory
3
+ // becomes a general file, media, editor or download root.
4
+ import { createHash } from 'node:crypto';
5
+ import { homedir } from 'node:os';
6
+ import path from 'node:path';
7
+ import { readdir, realpath } from 'node:fs/promises';
8
+ import { arcoHome } from '../../arcoHome.js';
9
+ import { atomicWriteFile, withFileLock } from '../../atomicFile.js';
10
+ import { openCheckedFile } from '../../checkedFile.js';
11
+ import { assertSpellingSafe, FileAccessError } from '../../fileAccessPolicy.js';
12
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
13
+ const MAX_BYTES = 25 * 1024 * 1024;
14
+ const skipped = new Set(['scratch', 'logs', 'worktrees', 'raw-tools']);
15
+ const digest = (value) => createHash('sha256').update(value).digest('hex');
16
+ function validName(key) {
17
+ const [session, ...parts] = key.split('/');
18
+ // Apply ordinary browser filename rules below the one authorized provider
19
+ // directory. Its parent is deliberately outside the general browser roots.
20
+ try {
21
+ assertSpellingSafe('/' + key, path.posix);
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ return UUID.test(session) && parts.length >= 1 && parts.length <= 4 && parts.every(part => part.length > 0 && !part.startsWith('.') && !/[\\:\x00-\x1f]/.test(part)
27
+ && !/[. ]$/.test(part) && !/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(part)
28
+ && !/\.metadata\.json$|\.resolved(?:\.\d+)?$/i.test(part))
29
+ && parts.slice(0, -1).every(part => !skipped.has(part.toLowerCase()));
30
+ }
31
+ export function geminiSessionKey(file) {
32
+ const match = /[\\/]\.gemini[\\/]antigravity-cli[\\/]brain[\\/](.*)$/i.exec(file);
33
+ if (!match)
34
+ return undefined;
35
+ const [session, ...parts] = match[1].split(/[\\/]/);
36
+ const key = [session.toLowerCase(), ...parts].join('/');
37
+ return validName(key) ? key : null;
38
+ }
39
+ async function manifest(cwd, workflowId) {
40
+ return path.join(arcoHome(), 'gemini-artifacts-' + digest(JSON.stringify([await realpath(cwd), workflowId])) + '.json');
41
+ }
42
+ async function names(file) {
43
+ const handle = await openCheckedFile(file).catch(error => {
44
+ if (error.code !== 'ENOENT')
45
+ throw error;
46
+ return null;
47
+ });
48
+ if (!handle)
49
+ return [];
50
+ try {
51
+ if ((await handle.stat()).size > 8 * 1024 * 1024)
52
+ throw new FileAccessError();
53
+ const rows = JSON.parse(await handle.readFile('utf8'));
54
+ if (!Array.isArray(rows) || rows.length > 2000 || !rows.every(row => typeof row === 'string' && validName(row)))
55
+ throw new FileAccessError();
56
+ return rows;
57
+ }
58
+ finally {
59
+ await handle.close();
60
+ }
61
+ }
62
+ async function brainRoot() {
63
+ return path.join(await realpath(homedir()), '.gemini', 'antigravity-cli', 'brain');
64
+ }
65
+ // Recheck the spelling, link count and size for each listing and each read.
66
+ // Callers serve bytes from this same handle, up to the checked size.
67
+ async function openArtifact(root, key) {
68
+ const file = path.join(root, ...key.split('/'));
69
+ const handle = await openCheckedFile(file);
70
+ try {
71
+ const info = await handle.stat();
72
+ if (info.nlink !== 1 || info.size > MAX_BYTES)
73
+ throw new FileAccessError();
74
+ return { handle, info, file };
75
+ }
76
+ catch (error) {
77
+ await handle.close();
78
+ throw error;
79
+ }
80
+ }
81
+ export async function collectGeminiArtifacts(opts) {
82
+ const session = opts.sessionId.toLowerCase();
83
+ if (!UUID.test(session))
84
+ return;
85
+ const root = await brainRoot();
86
+ const found = [];
87
+ async function walk(prefix, depth) {
88
+ const dir = path.join(root, ...prefix.split('/'));
89
+ if (await realpath(dir).catch(() => '') !== dir)
90
+ return;
91
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
92
+ if (found.length >= 200)
93
+ break;
94
+ const key = prefix + '/' + entry.name;
95
+ if (!validName(key))
96
+ continue;
97
+ if (entry.isDirectory() && depth < 3 && !skipped.has(entry.name.toLowerCase()))
98
+ await walk(key, depth + 1);
99
+ else if (entry.isFile()) {
100
+ const opened = await openArtifact(root, key).catch(() => null);
101
+ if (opened) {
102
+ await opened.handle.close();
103
+ found.push(key);
104
+ }
105
+ }
106
+ }
107
+ }
108
+ await walk(session, 0);
109
+ const file = await manifest(opts.storeCwd, opts.workflowId);
110
+ await withFileLock(file, async () => {
111
+ const previous = await names(file);
112
+ const next = previous.filter(key => !key.startsWith(session + '/')).concat(found).slice(-2000);
113
+ if (JSON.stringify(next) !== JSON.stringify(previous))
114
+ await atomicWriteFile(file, JSON.stringify(next), { mode: 0o600, skipMkdir: true });
115
+ });
116
+ }
117
+ const idFor = (key) => 'gemini-' + digest(key);
118
+ export async function listGeminiArtifacts(cwd, workflowId) {
119
+ const keys = await names(await manifest(cwd, workflowId));
120
+ const rows = [];
121
+ if (keys.length) {
122
+ const root = await brainRoot();
123
+ for (const key of keys) {
124
+ const opened = await openArtifact(root, key).catch(() => null);
125
+ if (!opened)
126
+ continue;
127
+ await opened.handle.close();
128
+ rows.push({ id: idFor(key), path: opened.file, name: path.basename(opened.file), size: opened.info.size, mtime: opened.info.mtimeMs });
129
+ }
130
+ }
131
+ return rows;
132
+ }
133
+ export async function openGeminiArtifact(cwd, workflowId, selector) {
134
+ const keys = await names(await manifest(cwd, workflowId));
135
+ const key = keys.find(item => 'key' in selector ? item === selector.key : idFor(item) === selector.id);
136
+ if (!key)
137
+ throw new FileAccessError();
138
+ return { ...await openArtifact(await brainRoot(), key), id: idFor(key) };
139
+ }
140
+ //# sourceMappingURL=artifacts.js.map