arco-workbench 0.2.4 → 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 (253) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/THIRD_PARTY_NOTICES +2 -2
  3. package/client/dist/assets/{PhosphorBackdrop-CHXVFLGT.js → PhosphorBackdrop-CLILIwOQ.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-Bhs4I9jA.js → ThemedBackgroundShaderImpl-B87chcb5.js} +1 -1
  5. package/client/dist/assets/{XtermView-CdfurwFx.js → XtermView-BP_j7WSN.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-DYjZZ4cf.js → galleryEditor-B90phoBI.js} +1 -1
  7. package/client/dist/assets/{index-BjDmFvqG.js → index-BfPp1Oup.js} +269 -269
  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/UsageBar.tsx +37 -18
  41. package/client/src/components/WorkflowCreator/ClusterMembersSection.tsx +29 -3
  42. package/client/src/components/WorkflowCreator/index.tsx +29 -15
  43. package/client/src/components/WorkflowView.tsx +1 -1
  44. package/client/src/components/providerIndicator.ts +7 -3
  45. package/client/src/components/settings/GitHubAuthRow.tsx +34 -0
  46. package/client/src/explorer/ArtifactsLens.tsx +17 -8
  47. package/client/src/explorer/ExplorerApp.tsx +3 -3
  48. package/client/src/explorer/types.ts +3 -1
  49. package/client/src/help/content/cluster.tsx +10 -4
  50. package/client/src/help/content/composer.tsx +3 -2
  51. package/client/src/help/content/header.tsx +6 -3
  52. package/client/src/help/content/misc.tsx +7 -5
  53. package/client/src/help/content/rightPanel.tsx +8 -4
  54. package/client/src/help/content/settings.tsx +14 -3
  55. package/client/src/help/content/tabbar.tsx +1 -1
  56. package/client/src/help/manualSections/actions.tsx +5 -1
  57. package/client/src/help/manualSections/clusters.tsx +20 -14
  58. package/client/src/help/manualSections/configuration.tsx +6 -4
  59. package/client/src/help/manualSections/gettingStarted.tsx +4 -2
  60. package/client/src/help/manualSections/maintenance.tsx +24 -0
  61. package/client/src/help/manualSections/powerFeatures.tsx +1 -0
  62. package/client/src/help/manualSections/providers.tsx +11 -4
  63. package/client/src/help/manualSections/workspace.tsx +3 -3
  64. package/client/src/hooks/useClaudeNativeCatalog.ts +26 -0
  65. package/client/src/hooks/useClaudeNativeLogin.ts +16 -11
  66. package/client/src/hooks/useWebSocket.ts +4 -2
  67. package/client/src/layout/layoutRange.ts +4 -5
  68. package/client/src/questions/waitingQuestion.ts +2 -0
  69. package/client/src/stores/appStore.ts +5 -1
  70. package/client/src/stores/appStore.types.ts +2 -0
  71. package/client/src/stores/replayContext.ts +20 -0
  72. package/client/src/utils/chatFileLinks.ts +34 -3
  73. package/client/src/utils/claudeAuth.ts +9 -1
  74. package/client/src/ws/handleServerMessage.ts +11 -3
  75. package/docs/ARCHITECTURE.md +3 -3
  76. package/docs/BACKUP.md +1 -1
  77. package/docs/CLIENT.md +10 -5
  78. package/docs/EXTENDING.md +1 -1
  79. package/docs/FEATURES.md +3 -3
  80. package/docs/GETTING_STARTED.md +5 -4
  81. package/docs/GIT_WORKBENCH.md +8 -0
  82. package/docs/GLOSSARY.md +2 -2
  83. package/docs/GOTCHAS.md +4 -4
  84. package/docs/HTTP_API.md +54 -23
  85. package/docs/OPERATIONS.md +11 -0
  86. package/docs/OPERATOR_ACTIONS.md +2 -2
  87. package/docs/OUTPUTS.md +48 -6
  88. package/docs/PERSISTENCE.md +1 -1
  89. package/docs/PRIMITIVES.md +4 -2
  90. package/docs/PROTOCOL_CLUSTER.md +12 -6
  91. package/docs/PROTOCOL_PRIMITIVES.md +1 -1
  92. package/docs/PROVIDERS.md +46 -9
  93. package/docs/RESEARCH.md +1 -1
  94. package/docs/SETTINGS.md +9 -4
  95. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -3
  96. package/node_modules/@arco/shared/dist/protocol/clusters.js +1 -1
  97. package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -1
  98. package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +2 -1
  99. package/node_modules/@arco/shared/dist/protocol/settings.d.ts +3 -0
  100. package/node_modules/@arco/shared/dist/protocol/settings.js +5 -0
  101. package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
  102. package/node_modules/@arco/shared/dist/protocol/workflows.js +0 -2
  103. package/node_modules/@arco/shared/package.json +1 -1
  104. package/package.json +2 -2
  105. package/scripts/packaging/services.mjs +20 -1
  106. package/scripts/packaging/update.mjs +37 -2
  107. package/server/dist/attention.d.ts +6 -0
  108. package/server/dist/attention.js +6 -0
  109. package/server/dist/auth.d.ts +5 -0
  110. package/server/dist/auth.js +31 -20
  111. package/server/dist/clusterAutoTurn.d.ts +5 -1
  112. package/server/dist/clusterAutoTurn.js +31 -9
  113. package/server/dist/clusterPresets.js +3 -3
  114. package/server/dist/effortValidation.d.ts +2 -2
  115. package/server/dist/effortValidation.js +4 -4
  116. package/server/dist/explorerArtifacts.d.ts +1 -0
  117. package/server/dist/explorerArtifacts.js +12 -1
  118. package/server/dist/geminiMembers.d.ts +7 -1
  119. package/server/dist/geminiMembers.js +28 -14
  120. package/server/dist/http/conversationFiles.d.ts +36 -0
  121. package/server/dist/http/conversationFiles.js +222 -0
  122. package/server/dist/http/fileBytes.d.ts +3 -0
  123. package/server/dist/http/fileBytes.js +33 -0
  124. package/server/dist/http/fileContentRoute.d.ts +2 -0
  125. package/server/dist/http/fileContentRoute.js +139 -0
  126. package/server/dist/http/fileRead.d.ts +54 -2
  127. package/server/dist/http/fileRead.js +31 -24
  128. package/server/dist/http/outputRoutes.js +14 -21
  129. package/server/dist/http/readConfinement.d.ts +0 -11
  130. package/server/dist/http/readConfinement.js +4 -30
  131. package/server/dist/http/router.js +40 -66
  132. package/server/dist/index.js +26 -12
  133. package/server/dist/management/initHubLink.js +1 -1
  134. package/server/dist/outputs.js +8 -0
  135. package/server/dist/primitives/exportContext.d.ts +2 -0
  136. package/server/dist/primitives/exportContext.js +13 -2
  137. package/server/dist/primitives/runCompare.d.ts +7 -1
  138. package/server/dist/primitives/runCompare.js +44 -20
  139. package/server/dist/project/taskLedger.js +46 -34
  140. package/server/dist/providerAccounts.d.ts +4 -0
  141. package/server/dist/providerAccounts.js +20 -1
  142. package/server/dist/providers/antigravity/artifacts.d.ts +23 -0
  143. package/server/dist/providers/antigravity/artifacts.js +140 -0
  144. package/server/dist/providers/antigravity/index.js +85 -7
  145. package/server/dist/providers/antigravity/questions.d.ts +2 -0
  146. package/server/dist/providers/antigravity/questions.js +58 -0
  147. package/server/dist/providers/claude-native/auth.d.ts +9 -8
  148. package/server/dist/providers/claude-native/auth.js +50 -58
  149. package/server/dist/providers/claude-native/authStatus.d.ts +2 -2
  150. package/server/dist/providers/claude-native/authStatus.js +9 -7
  151. package/server/dist/providers/claude-native/catalog.d.ts +6 -5
  152. package/server/dist/providers/claude-native/catalog.js +50 -39
  153. package/server/dist/providers/claude-native/oauth.d.ts +10 -9
  154. package/server/dist/providers/claude-native/oauth.js +120 -96
  155. package/server/dist/providers/claude-native/worker.d.ts +1 -0
  156. package/server/dist/providers/claude-native/worker.js +38 -23
  157. package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -3
  158. package/server/dist/providers/codex-appserver/operatorQuestions.js +27 -13
  159. package/server/dist/server/broadcast.js +6 -0
  160. package/server/dist/settings.d.ts +1 -0
  161. package/server/dist/settings.js +39 -7
  162. package/server/dist/skills.js +1 -1
  163. package/server/dist/smartPickupAdapters.d.ts +1 -0
  164. package/server/dist/smartPickupAdapters.js +2 -2
  165. package/server/dist/smartPickupObserver.js +8 -5
  166. package/server/dist/thirdPartySkills.js +11 -5
  167. package/server/dist/usage.d.ts +1 -1
  168. package/server/dist/usage.js +39 -27
  169. package/server/dist/workers/WorkerManager.d.ts +1 -0
  170. package/server/dist/workers/WorkerManager.js +1 -0
  171. package/server/dist/workers/processKill.js +37 -24
  172. package/server/dist/workflowMeta.js +2 -2
  173. package/server/dist/ws/clusterHandlers.d.ts +2 -2
  174. package/server/dist/ws/clusterHandlers.js +127 -113
  175. package/server/dist/ws/clusterMembers.d.ts +1 -1
  176. package/server/dist/ws/clusterMembers.js +34 -4
  177. package/server/dist/ws/compactHandlers.js +30 -14
  178. package/server/dist/ws/compareHandlers.js +53 -21
  179. package/server/dist/ws/gateHandlers.js +2 -0
  180. package/server/dist/ws/genesisHandlers.js +5 -3
  181. package/server/dist/ws/handoffHandlers.d.ts +1 -1
  182. package/server/dist/ws/handoffHandlers.js +115 -39
  183. package/server/dist/ws/transcriptWorkerHandlers.js +7 -2
  184. package/server/dist/ws/turnEngine.js +33 -18
  185. package/server/dist/ws/updatePrimaryConfig.d.ts +3 -2
  186. package/server/dist/ws/updatePrimaryConfig.js +236 -133
  187. package/server/dist/ws/workflowHandlers.js +21 -4
  188. package/server/package.json +1 -1
  189. package/server/src/attention.ts +7 -0
  190. package/server/src/auth.ts +33 -20
  191. package/server/src/clusterAutoTurn.ts +31 -11
  192. package/server/src/clusterPresets.ts +2 -2
  193. package/server/src/effortValidation.ts +4 -4
  194. package/server/src/explorerArtifacts.ts +12 -1
  195. package/server/src/geminiMembers.ts +26 -15
  196. package/server/src/http/conversationFiles.ts +231 -0
  197. package/server/src/http/fileBytes.ts +34 -0
  198. package/server/src/http/fileContentRoute.ts +123 -0
  199. package/server/src/http/fileRead.ts +30 -25
  200. package/server/src/http/outputRoutes.ts +13 -13
  201. package/server/src/http/readConfinement.ts +3 -30
  202. package/server/src/http/router.ts +38 -62
  203. package/server/src/index.ts +27 -18
  204. package/server/src/management/initHubLink.ts +1 -1
  205. package/server/src/outputs.ts +8 -0
  206. package/server/src/primitives/exportContext.ts +14 -2
  207. package/server/src/primitives/runCompare.ts +73 -46
  208. package/server/src/project/taskLedger.ts +47 -30
  209. package/server/src/providerAccounts.ts +20 -1
  210. package/server/src/providers/antigravity/artifacts.ts +121 -0
  211. package/server/src/providers/antigravity/index.ts +64 -6
  212. package/server/src/providers/antigravity/questions.ts +52 -0
  213. package/server/src/providers/claude-native/auth.ts +45 -60
  214. package/server/src/providers/claude-native/authStatus.ts +9 -8
  215. package/server/src/providers/claude-native/catalog.ts +52 -35
  216. package/server/src/providers/claude-native/oauth.ts +101 -77
  217. package/server/src/providers/claude-native/worker.ts +38 -22
  218. package/server/src/providers/codex-appserver/operatorQuestions.ts +26 -12
  219. package/server/src/server/broadcast.ts +4 -0
  220. package/server/src/settings.ts +36 -8
  221. package/server/src/skills.ts +1 -1
  222. package/server/src/smartPickupAdapters.ts +3 -2
  223. package/server/src/smartPickupObserver.ts +8 -5
  224. package/server/src/thirdPartySkills.ts +11 -5
  225. package/server/src/usage.ts +30 -22
  226. package/server/src/workers/WorkerManager.ts +2 -0
  227. package/server/src/workers/processKill.ts +37 -23
  228. package/server/src/workflowMeta.ts +2 -2
  229. package/server/src/ws/clusterHandlers.ts +107 -104
  230. package/server/src/ws/clusterMembers.ts +25 -6
  231. package/server/src/ws/compactHandlers.ts +29 -15
  232. package/server/src/ws/compareHandlers.ts +59 -25
  233. package/server/src/ws/gateHandlers.ts +2 -0
  234. package/server/src/ws/genesisHandlers.ts +5 -4
  235. package/server/src/ws/handoffHandlers.ts +105 -37
  236. package/server/src/ws/transcriptWorkerHandlers.ts +6 -2
  237. package/server/src/ws/turnEngine.ts +32 -17
  238. package/server/src/ws/updatePrimaryConfig.ts +230 -132
  239. package/server/src/ws/workflowHandlers.ts +20 -4
  240. package/shared/dist/protocol/clusters.d.ts +15 -3
  241. package/shared/dist/protocol/clusters.js +1 -1
  242. package/shared/dist/protocol/models.d.ts +6 -1
  243. package/shared/dist/protocol/operatorQuestions.d.ts +2 -1
  244. package/shared/dist/protocol/settings.d.ts +3 -0
  245. package/shared/dist/protocol/settings.js +5 -0
  246. package/shared/dist/protocol/workflows.d.ts +1 -0
  247. package/shared/dist/protocol/workflows.js +0 -2
  248. package/shared/src/protocol/clusters.ts +23 -5
  249. package/shared/src/protocol/compare.ts +2 -2
  250. package/shared/src/protocol/models.ts +8 -4
  251. package/shared/src/protocol/operatorQuestions.ts +2 -1
  252. package/shared/src/protocol/settings.ts +8 -1
  253. package/shared/src/protocol/workflows.ts +1 -1
@@ -1,14 +1,15 @@
1
1
  import { openCheckedFile } from '../checkedFile.js';
2
2
  import { lstat } from 'node:fs/promises';
3
- import { pipeline } from 'node:stream/promises';
4
3
  import { getClusterCached, displayNameFor } from '../clusterStore.js';
5
4
  import { listOutputs, outputContext, readOutput, saveOutputText, transferOutput } from '../outputs.js';
6
5
  import { outputDirectory, readOutputIndex } from '../outputStore.js';
7
6
  import { keepCovering, readKeep } from '../keepStore.js';
8
7
  import path from 'node:path';
9
- import { readFileForExplorer } from '../http/fileRead.js';
8
+ import { openGeminiArtifact } from '../providers/antigravity/artifacts.js';
9
+ import { readExplorerHandle, readGeminiPreview } from './fileRead.js';
10
+ import { sendFileBytes } from './fileBytes.js';
10
11
  import { REFUSED_EXTENSIONS, desktopOpenAvailable, isLoopbackAddress, launchOpener, openerCommand, refusalFor } from './outputOpen.js';
11
- const MIME = { png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif', webp: 'image/webp', wav: 'audio/wav', mp3: 'audio/mpeg', ogg: 'audio/ogg', flac: 'audio/flac', m4a: 'audio/mp4', mp4: 'video/mp4', webm: 'video/webm', mov: 'video/quicktime' };
12
+ const MIME = { png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', gif: 'image/gif', webp: 'image/webp', opus: 'audio/ogg', wav: 'audio/wav', mp3: 'audio/mpeg', ogg: 'audio/ogg', flac: 'audio/flac', m4a: 'audio/mp4', mp4: 'video/mp4', webm: 'video/webm', mov: 'video/quicktime' };
12
13
  function json(res, status, body) { res.writeHead(status, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }); res.end(JSON.stringify(body)); return true; }
13
14
  async function bodyOf(req) {
14
15
  let text = '';
@@ -59,29 +60,21 @@ export async function tryHandleOutputRoutes(req, res) {
59
60
  if (inline)
60
61
  return json(res, 200, { type: 'text', content: inline.content, size: Buffer.byteLength(inline.content) });
61
62
  }
62
- const { entry, file } = await readOutput(ctx, id);
63
- if (url.pathname === '/api/outputs/content')
64
- return json(res, 200, await readFileForExplorer(file));
65
- const handle = await openCheckedFile(file);
63
+ const gemini = id.startsWith('gemini-') ? await openGeminiArtifact(ctx.cwd, ctx.workflowId, { id }) : null;
64
+ const file = gemini?.file ?? (await readOutput(ctx, id)).file;
65
+ const name = path.basename(file);
66
+ const handle = gemini?.handle ?? await openCheckedFile(file);
66
67
  try {
67
- const info = await handle.stat();
68
+ const info = gemini?.info ?? await handle.stat();
68
69
  if (!info.isFile())
69
70
  throw new Error('Output is not a regular file.');
70
- const ext = entry.name.split('.').pop()?.toLowerCase() || '';
71
+ if (url.pathname === '/api/outputs/content')
72
+ return json(res, 200, gemini
73
+ ? await readGeminiPreview(file, handle, info.size, ctx, id) : await readExplorerHandle(file, handle, info.size));
74
+ const ext = name.split('.').pop()?.toLowerCase() || '';
71
75
  // Active formats and unknown binaries are downloads, never executable previews.
72
76
  const preview = url.searchParams.get('download') !== '1' && !!MIME[ext];
73
- const range = /^bytes=(\d+)-(\d*)$/.exec(req.headers.range || '');
74
- const start = range ? Number(range[1]) : 0, end = range?.[2] ? Math.min(Number(range[2]), info.size - 1) : info.size - 1;
75
- if (range && (start > end || start >= info.size)) {
76
- res.writeHead(416, { 'Content-Range': `bytes */${info.size}` });
77
- res.end();
78
- return true;
79
- }
80
- res.writeHead(range ? 206 : 200, { 'Content-Type': preview ? MIME[ext] : 'application/octet-stream', 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff', 'Content-Security-Policy': "sandbox; default-src 'none'", 'Content-Disposition': `${preview ? 'inline' : 'attachment'}; filename*=UTF-8''${encodeURIComponent(entry.name)}`, 'Accept-Ranges': 'bytes', 'Content-Length': range ? end - start + 1 : info.size, ...(range ? { 'Content-Range': `bytes ${start}-${end}/${info.size}` } : {}) });
81
- if (info.size)
82
- await pipeline(handle.createReadStream({ autoClose: false, emitClose: false, start, end }), res);
83
- else
84
- res.end();
77
+ await sendFileBytes(req, res, handle, info.size, name, preview ? MIME[ext] : undefined);
85
78
  return true;
86
79
  }
87
80
  finally {
@@ -1,17 +1,6 @@
1
1
  import { type ReadAccessContext } from '../fileAccessPolicy.js';
2
2
  export declare function readRoots(cwd?: string | null, workflowId?: string | null): Promise<string[]>;
3
3
  export declare function resolveBrowserRead(p: string, cwd?: string | null, workflowId?: string | null, kind?: 'file' | 'directory'): Promise<string>;
4
- export declare function clusterArtifactMatches(cwd: string, workflowId: string, name: string): Promise<{
5
- searched: Array<{
6
- workflowId: string;
7
- name: string;
8
- }>;
9
- matches: Array<{
10
- workflowId: string;
11
- name: string;
12
- path: string;
13
- }>;
14
- } | null>;
15
4
  export declare function listBrowserDirectory(dir: string, directoriesOnly: boolean, access?: ReadAccessContext): Promise<{
16
5
  root: string;
17
6
  entries: {
@@ -8,7 +8,7 @@ import { UPLOADS_DIR } from '../server/constants.js';
8
8
  import { SCRATCH_ROOT } from '../media/scratch.js';
9
9
  import { artifactsDir } from '../workers/limits.js';
10
10
  import { resolveWorktreeFile } from './browserWorktrees.js';
11
- import * as clusterStore from '../clusterStore.js';
11
+ import { geminiSessionKey } from '../providers/antigravity/artifacts.js';
12
12
  export async function readRoots(cwd, workflowId) {
13
13
  const bound = await resolveBoundCwd(cwd, workflowId);
14
14
  if (!bound.ok && bound.reason !== 'none')
@@ -18,6 +18,9 @@ export async function readRoots(cwd, workflowId) {
18
18
  export async function resolveBrowserRead(p, cwd, workflowId, kind = 'file') {
19
19
  if (!p || p.includes('\0'))
20
20
  throw new FileAccessError();
21
+ // Session files are served only by the workflow-bound handle reader.
22
+ if (geminiSessionKey(p) !== undefined)
23
+ throw new FileAccessError();
21
24
  if (workflowId && cwd && kind === 'file') {
22
25
  assertSafePath(path.resolve(cwd, p));
23
26
  const tracked = await import('../outputs.js').then(m => m.resolveTrackedOutput(cwd, workflowId, p)).catch(() => null);
@@ -50,35 +53,6 @@ export async function resolveBrowserRead(p, cwd, workflowId, kind = 'file') {
50
53
  return confinedPath(path.join(artifactsDir(bound.cwd, workflowId), p), [bound.cwd]);
51
54
  }
52
55
  }
53
- // Search only a bound conversation's cluster members after ordinary resolution
54
- // has failed. Every candidate goes through the existing workflow-document guard.
55
- export async function clusterArtifactMatches(cwd, workflowId, name) {
56
- if (!name || path.basename(name) !== name || name.includes('\\') || name.startsWith('.'))
57
- return null;
58
- const bound = await resolveBoundCwd(cwd, workflowId);
59
- const clusterId = clusterStore.getClusterIdForWorkflow(workflowId);
60
- const cluster = clusterId ? await clusterStore.readCluster(clusterId) : null;
61
- if (!bound.ok || !cluster || !cluster.members.includes(workflowId))
62
- return null;
63
- const searched = cluster.members.map((id) => ({ workflowId: id, name: clusterStore.displayNameFor(id) }));
64
- const matches = [];
65
- for (const member of searched) {
66
- try {
67
- const memberBound = await resolveBoundCwd(cluster.cwd, member.workflowId);
68
- const memberCwd = memberBound.ok ? memberBound.cwd : cluster.cwd;
69
- const resolved = await resolveWorkflowDocument(memberCwd, member.workflowId, 'artifacts', name);
70
- const root = artifactsDir(memberCwd, member.workflowId);
71
- // Tracked outputs can resolve outside artifacts; this fallback cannot.
72
- const checked = confinedPath(resolved, [root]);
73
- matches.push({ ...member, path: checked });
74
- }
75
- catch (err) {
76
- if (err.code !== 'ENOENT' && !(err instanceof FileAccessError))
77
- throw err;
78
- }
79
- }
80
- return { searched, matches };
81
- }
82
56
  // The project picker grants directory names only, not file content. Ordinary
83
57
  // absolute locations may be navigated without pre-registering every ancestor
84
58
  // (mounts, network shares, Windows drives); protected roots are never listed.
@@ -44,13 +44,13 @@ import { probeOnce as probePreviewPort } from '../previewAutoDetect.js';
44
44
  import { PreviewGateways } from '../previewProxy.js';
45
45
  import { previewPortRange } from '../previewPortConfiguration.js';
46
46
  import { HOST } from '../server/constants.js';
47
- import { clearTokens as clearClaudeNativeTokens } from '../providers/claude-native/auth.js';
48
47
  import { getClaudeNativeAuthStatus } from '../providers/claude-native/authStatus.js';
49
- import { getCatalog as getClaudeNativeCatalog } from '../providers/claude-native/catalog.js';
48
+ import { getCatalog as getClaudeNativeCatalog, forgetCatalog as forgetClaudeNativeCatalog } from '../providers/claude-native/catalog.js';
50
49
  import { CLAUDE_CLI_USER_AGENT } from '../providers/claude-native/wireFingerprint.js';
51
- import { completeBootstrap as claudeNativeCompleteBootstrap, startBootstrap as claudeNativeStartBootstrap, getBootstrapFlow as claudeNativeGetFlow, cancelBootstrap as claudeNativeCancelFlow, cancelActiveBootstrap as claudeNativeCancelActiveFlow, ensureLiveTokens as ensureClaudeNativeTokens, } from '../providers/claude-native/oauth.js';
50
+ import { completeBootstrap as claudeNativeCompleteBootstrap, startBootstrap as claudeNativeStartBootstrap, getBootstrapFlow as claudeNativeGetFlow, cancelBootstrap as claudeNativeCancelFlow, logout as claudeNativeLogout, ensureLiveTokens as ensureClaudeNativeTokens, } from '../providers/claude-native/oauth.js';
52
51
  import { getCodexCatalog } from '../providers/codex-appserver/catalog.js';
53
- import { resolveProviderAccount, ensureCodexAccountHome } from '../providerAccounts.js';
52
+ import { saveClaudeNativeProfile } from '../settings.js';
53
+ import { requireClaudeNativeAccount, resolveProviderAccount, ensureCodexAccountHome } from '../providerAccounts.js';
54
54
  import { getCursorCatalog } from '../providers/cursor/catalog.js';
55
55
  import { probeLlamacppLive } from '../providers/llamacpp.js';
56
56
  import { llamacppManager } from '../providers/llamacppManager.js';
@@ -68,9 +68,9 @@ import { auditSkillContent } from '../skillAudit.js';
68
68
  import { getUsage } from '../usage.js';
69
69
  import { listAllListeningProcesses } from '../workers/procListeningAll.js';
70
70
  import { flushAll as flushAllWorkflowEvents } from '../workflowStore.js';
71
- import { readFileForExplorer } from './fileRead.js';
71
+ import { tryHandleFileContent } from './fileContentRoute.js';
72
72
  import { explorerRoot } from './explorerRoot.js';
73
- import { clusterArtifactMatches, listBrowserDirectory, resolveBrowserRead } from './readConfinement.js';
73
+ import { listBrowserDirectory } from './readConfinement.js';
74
74
  import { confinedPath, safeDirectory, createReadAccessContext } from '../fileAccessPolicy.js';
75
75
  import { tryHandleClusterRoutes } from './clusterRoutes.js';
76
76
  import { tryHandleClusterSnapshotRoutes } from './clusterSnapshotRoutes.js';
@@ -1562,9 +1562,28 @@ export async function handleHttpRequest(req, res, deps) {
1562
1562
  // logout. The OAuth bootstrap server-side spawns its own local callback
1563
1563
  // listener on port 53692 when possible; on EADDRINUSE we surface a
1564
1564
  // manual-paste flag and accept the redirect URL via /callback.
1565
- if (req.url === '/api/auth/claude-native' && req.method === 'GET') {
1565
+ if (req.url === '/api/auth/claude-native/profiles' && req.method === 'POST') {
1566
1566
  try {
1567
- const status = await getClaudeNativeAuthStatus();
1567
+ let raw = '';
1568
+ for await (const chunk of req)
1569
+ raw += chunk;
1570
+ const body = JSON.parse(raw || '{}');
1571
+ if (typeof body.label !== 'string' || (body.id !== undefined && typeof body.id !== 'string'))
1572
+ throw new Error('Invalid Claude Native profile.');
1573
+ const settings = await saveClaudeNativeProfile(body.label, body.id);
1574
+ res.writeHead(200, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' });
1575
+ res.end(JSON.stringify(settings));
1576
+ }
1577
+ catch (err) {
1578
+ res.writeHead(400, { 'Content-Type': 'application/json' });
1579
+ res.end(JSON.stringify({ error: err instanceof Error ? err.message : 'Could not save Claude Native account.' }));
1580
+ }
1581
+ return;
1582
+ }
1583
+ if (req.url?.split('?')[0] === '/api/auth/claude-native' && req.method === 'GET') {
1584
+ try {
1585
+ const ref = new URL(req.url, 'http://localhost').searchParams.get('account');
1586
+ const status = await getClaudeNativeAuthStatus(await requireClaudeNativeAccount(ref ?? undefined));
1568
1587
  const body = { ...status, loggedIn: status.credentialsPresent };
1569
1588
  res.writeHead(200, { 'Content-Type': 'application/json' });
1570
1589
  res.end(JSON.stringify(body));
@@ -1591,7 +1610,9 @@ export async function handleHttpRequest(req, res, deps) {
1591
1610
  const body = JSON.parse(raw || '{}');
1592
1611
  if (body.workflowId !== undefined && (typeof body.workflowId !== 'string' || body.workflowId.length > 128))
1593
1612
  throw new Error('Invalid originating workflow id.');
1594
- const result = await claudeNativeStartBootstrap(body.binding, body.workflowId);
1613
+ if (body.accountRef !== undefined && typeof body.accountRef !== 'string')
1614
+ throw new Error('Invalid Claude Native account.');
1615
+ const result = await claudeNativeStartBootstrap(body.binding, body.workflowId, body.accountRef);
1595
1616
  res.writeHead(200, { 'Content-Type': 'application/json' });
1596
1617
  res.end(JSON.stringify(result));
1597
1618
  }
@@ -1624,10 +1645,12 @@ export async function handleHttpRequest(req, res, deps) {
1624
1645
  }
1625
1646
  return;
1626
1647
  }
1627
- if (req.url === '/api/auth/claude-native/logout' && req.method === 'POST') {
1648
+ if (req.url?.split('?')[0] === '/api/auth/claude-native/logout' && req.method === 'POST') {
1628
1649
  try {
1629
- await claudeNativeCancelActiveFlow();
1630
- await clearClaudeNativeTokens();
1650
+ const ref = new URL(req.url, 'http://localhost').searchParams.get('account');
1651
+ const account = await requireClaudeNativeAccount(ref ?? undefined);
1652
+ await claudeNativeLogout(account);
1653
+ forgetClaudeNativeCatalog(account);
1631
1654
  res.writeHead(200, { 'Content-Type': 'application/json' });
1632
1655
  res.end(JSON.stringify({ ok: true }));
1633
1656
  }
@@ -1647,7 +1670,7 @@ export async function handleHttpRequest(req, res, deps) {
1647
1670
  try {
1648
1671
  const url = new URL(req.url, `http://localhost:${PORT}`);
1649
1672
  const force = url.searchParams.get('force') === '1';
1650
- const snapshot = await getClaudeNativeCatalog(force);
1673
+ const snapshot = await getClaudeNativeCatalog(force, url.searchParams.get('account') ?? undefined);
1651
1674
  res.writeHead(200, { 'Content-Type': 'application/json' });
1652
1675
  res.end(JSON.stringify(snapshot));
1653
1676
  }
@@ -1718,7 +1741,7 @@ export async function handleHttpRequest(req, res, deps) {
1718
1741
  res.end(JSON.stringify({ error: 'expected { model: string, beta?: string[], maxTokens?: number, prompt?: string }' }));
1719
1742
  return;
1720
1743
  }
1721
- const tokens = await ensureClaudeNativeTokens();
1744
+ const tokens = await ensureClaudeNativeTokens(parsed.accountRef);
1722
1745
  // Match the worker's wire fingerprint exactly so a probe-passing
1723
1746
  // model translates 1:1 to a real-turn-passing model. Caller-supplied
1724
1747
  // beta entries append (don't replace) the standard ones.
@@ -2105,8 +2128,8 @@ export async function handleHttpRequest(req, res, deps) {
2105
2128
  return;
2106
2129
  }
2107
2130
  if (req.url?.startsWith('/api/usage') && req.method === 'GET') {
2108
- const force = new URL(req.url, `http://localhost:${PORT}`).searchParams.get('force') === '1';
2109
- const usage = await getUsage(force);
2131
+ const params = new URL(req.url, `http://localhost:${PORT}`).searchParams;
2132
+ const usage = await getUsage(params.get('force') === '1', params.get('account') ?? undefined);
2110
2133
  res.writeHead(200, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' });
2111
2134
  res.end(JSON.stringify(usage));
2112
2135
  return;
@@ -2133,57 +2156,8 @@ export async function handleHttpRequest(req, res, deps) {
2133
2156
  res.end(JSON.stringify(usage));
2134
2157
  return;
2135
2158
  }
2136
- if (req.url?.startsWith('/api/file-content') && req.method === 'GET') {
2137
- const url = new URL(req.url, `http://localhost:${PORT}`);
2138
- const asked = url.searchParams.get('path') || '';
2139
- const cwd = url.searchParams.get('cwd') || '';
2140
- const workflowId = url.searchParams.get('workflowId') || '';
2141
- const owner = url.searchParams.get('artifactOwner') || '';
2142
- try {
2143
- let target;
2144
- let artifactOwner;
2145
- try {
2146
- target = await resolveBrowserRead(asked, cwd, workflowId);
2147
- if (owner)
2148
- throw Object.assign(new Error('Artifact choice is no longer available.'), { code: 'EACCES' });
2149
- }
2150
- catch (err) {
2151
- if (err.code !== 'ENOENT' || !workflowId || !cwd)
2152
- throw err;
2153
- const found = await clusterArtifactMatches(cwd, workflowId, asked);
2154
- if (!found)
2155
- throw err;
2156
- const choices = found.matches.map(({ workflowId: id, name }) => ({ workflowId: id, name }));
2157
- if (!owner && choices.length > 1) {
2158
- res.writeHead(200, { 'Content-Type': 'application/json' });
2159
- res.end(JSON.stringify({ type: 'choices', choices }));
2160
- return;
2161
- }
2162
- const chosen = owner ? found.matches.find((match) => match.workflowId === owner) : found.matches[0];
2163
- if (!chosen) {
2164
- if (owner)
2165
- throw Object.assign(new Error('Artifact choice is no longer available.'), { code: 'EACCES' });
2166
- res.writeHead(404, { 'Content-Type': 'application/json' });
2167
- res.end(JSON.stringify({ type: 'error', error: `File not found: ${asked}. Searched the project and artifacts of: ${found.searched.map((m) => m.name).join(', ')}.` }));
2168
- return;
2169
- }
2170
- target = chosen.path;
2171
- artifactOwner = chosen.name;
2172
- }
2173
- const payload = await readFileForExplorer(target);
2174
- res.writeHead(200, { 'Content-Type': 'application/json' });
2175
- res.end(JSON.stringify({ ...payload, resolvedPath: target, ...(artifactOwner ? { artifactOwner } : {}) }));
2176
- }
2177
- catch (err) {
2178
- const code = err.code;
2179
- // A missing file is reported by the name that was asked for, never by a
2180
- // path the server or client composed.
2181
- const message = code === 'ENOENT' ? `File not found: ${asked}` : (err instanceof Error ? err.message : String(err));
2182
- res.writeHead(code === 'EACCES' ? 403 : 404, { 'Content-Type': 'application/json' });
2183
- res.end(JSON.stringify({ type: 'error', error: message }));
2184
- }
2159
+ if (await tryHandleFileContent(req, res))
2185
2160
  return;
2186
- }
2187
2161
  if (req.url?.startsWith('/api/files') && req.method === 'GET') {
2188
2162
  try {
2189
2163
  const url = new URL(req.url, `http://localhost:${PORT}`);
@@ -30,7 +30,7 @@ import { handleOperatorQuestionReply, handleOperatorQuestionDismiss } from './ws
30
30
  import { loadWorkspace, onWorkspaceChange, syncWorkspace } from './workspace.js';
31
31
  import './net/forceIpv4.js';
32
32
  import { hydrateProcessPathFromUserEnv } from './runtimeEnv.js';
33
- import { GEMINI_OPERATOR_ONLY_REFUSAL, geminiNudgeText, isGeminiMember, issueGeminiSend } from './geminiMembers.js';
33
+ import { GEMINI_OPERATOR_ONLY_REFUSAL, geminiNudgeText, isGeminiMember, issueGeminiSend, prepareGeminiPickup } from './geminiMembers.js';
34
34
  import { hasGuardrails, isClusterMemberProvider, resolveOutputStyle } from '@arco/shared';
35
35
  import { getEffectivePublicProjectChoice } from './publicProjectChoice.js';
36
36
  import { spawnSync } from 'child_process';
@@ -797,7 +797,7 @@ wss.on('connection', (ws) => {
797
797
  });
798
798
  break;
799
799
  case 'handoff_request':
800
- handleHandoffRequest(ws, session, msg).catch((err) => {
800
+ handleHandoffRequest(ws, session, msg, true).catch((err) => {
801
801
  console.error('[arco] handoff_request handler failed:', err);
802
802
  });
803
803
  break;
@@ -2171,7 +2171,7 @@ setClaudeNativeTaskHandler(async ({ parentWorkflowId, description, prompt, subag
2171
2171
  const policy = resolveNativeSubagents(defaults?.nativeSubagents, capturedPolicy ?? parent.config.nativeSubagents);
2172
2172
  const effectiveModel = policy.model || model || parent.config.primaryModel;
2173
2173
  if (policy.model) {
2174
- const catalog = await getNativeTaskCatalog();
2174
+ const catalog = await getNativeTaskCatalog(false, parent.config.providerAccountRef);
2175
2175
  assertActive();
2176
2176
  const ids = catalog.models.length ? catalog.models.map((m) => m.id) : [...CLAUDE_MODELS];
2177
2177
  if (!ids.includes(policy.model))
@@ -2299,6 +2299,7 @@ setClaudeNativeTaskHandler(async ({ parentWorkflowId, description, prompt, subag
2299
2299
  resumeSessionId: undefined,
2300
2300
  // Task children use the Native transport, including inherited settings.
2301
2301
  claudeTransport: 'native',
2302
+ providerAccountRef: parent.config.providerAccountRef,
2302
2303
  claudeNativeCompact: parent.config.claudeNativeCompact === true,
2303
2304
  claudeNativeForceInterleavedThinkingBeta: parent.config.claudeNativeForceInterleavedThinkingBeta === true,
2304
2305
  claudeNativeThinkingDisplay: parent.config.claudeNativeThinkingDisplay,
@@ -2469,13 +2470,18 @@ function onListening() {
2469
2470
  clusterIds: new Set(),
2470
2471
  clusterObserved: new Map(),
2471
2472
  };
2472
- handleUserMessage(fakeWs, fakeSession, wfid, content, undefined, // no clientMessageId — this is server-originated
2473
- undefined, // no attachments
2474
- false, // not an interjection — auto-turn only fires on idle
2475
- undefined, // kind: default ('follow-up' path is for busy recipients)
2476
- undefined, // no DOCS/GIT primitive
2477
- undefined, // no picked skills
2478
- { automaticKind: 'auto-pickup' }).catch((err) => {
2473
+ const dispatch = async () => {
2474
+ const gemini = isGeminiMember(wfid);
2475
+ const pickup = gemini ? await prepareGeminiPickup(wfid, content, 'rule') : undefined;
2476
+ if (gemini && !pickup)
2477
+ return;
2478
+ return handleUserMessage(fakeWs, fakeSession, wfid, pickup?.content ?? content, undefined, undefined, false, undefined, undefined, undefined, {
2479
+ automaticKind: 'auto-pickup',
2480
+ geminiSend: pickup?.ticket,
2481
+ ...(pickup && { claimGuard: async (claim) => pickup.isCurrent() && claim() }),
2482
+ });
2483
+ };
2484
+ void dispatch().catch((err) => {
2479
2485
  console.error(`[arco] auto-turn handleUserMessage failed for ${wfid.slice(0, 8)}:`, err);
2480
2486
  });
2481
2487
  },
@@ -2542,11 +2548,12 @@ function onListening() {
2542
2548
  const pending = workflows.get(wfid)?.config.incognito ? withoutOperationalLogging(run) : run();
2543
2549
  void pending.then(() => { resolve(false); settled(); }, () => { resolve(false); settled('Computer activity turn failed or was interrupted.'); });
2544
2550
  }));
2545
- const conditionalTurn = (wfid, content, guard, automaticKind) => new Promise((resolve) => {
2551
+ const conditionalTurn = (wfid, content, guard, automaticKind, geminiSend) => new Promise((resolve) => {
2546
2552
  const fakeWs = { readyState: WebSocket.CLOSED, send: () => undefined };
2547
2553
  const fakeSession = { id: 'computer-mail-rule', workflowIds: new Set([wfid]), clusterIds: new Set(), clusterObserved: new Map() };
2548
2554
  void handleUserMessage(fakeWs, fakeSession, wfid, content, undefined, undefined, false, undefined, undefined, undefined, {
2549
2555
  automaticKind,
2556
+ geminiSend,
2550
2557
  claimGuard: async (claim) => {
2551
2558
  const accepted = await guard(claim);
2552
2559
  resolve(accepted);
@@ -2565,7 +2572,14 @@ function onListening() {
2565
2572
  // Smart: Automatic wakes use the same conditional admission; an ask
2566
2573
  // proposal raises one operator notice.
2567
2574
  configureSmartPickupObserver({
2568
- dispatchGuarded: (wfid, content, guard) => conditionalTurn(wfid, content, guard, 'auto-pickup'),
2575
+ dispatchGuarded: async (wfid, content, guard) => {
2576
+ if (!isGeminiMember(wfid))
2577
+ return conditionalTurn(wfid, content, guard, 'auto-pickup');
2578
+ const pickup = await prepareGeminiPickup(wfid, content, 'smart-auto');
2579
+ if (!pickup)
2580
+ return false;
2581
+ return conditionalTurn(wfid, pickup.content, (claim) => guard(() => pickup.isCurrent() && claim()), 'auto-pickup', pickup.ticket);
2582
+ },
2569
2583
  notifyAsk: (d) => emitNotice({
2570
2584
  category: 'cluster-nudge',
2571
2585
  severity: 'warning',
@@ -366,7 +366,7 @@ export async function applyAction(action, actionId) {
366
366
  type: 'handoff_request',
367
367
  workflowId: action.workflowId,
368
368
  mode: 'quick',
369
- }).catch((err) => console.error(`[hub-link] handoff failed for ${action.workflowId.slice(0, 8)}:`, err));
369
+ }, true).catch((err) => console.error(`[hub-link] handoff failed for ${action.workflowId.slice(0, 8)}:`, err));
370
370
  return { ...base, ok: true, applied: 'handoff' };
371
371
  }
372
372
  case 'reply':
@@ -13,6 +13,7 @@ import { workflows } from './server/state.js';
13
13
  import { matchFileEvent } from './recentFilesLedger.js';
14
14
  import { outputDirectory, readOutputIndex, writeOutputIndex, mappedOutputPath } from './outputStore.js';
15
15
  import { readLogLines, sealedThroughSeq } from './eventLog.js';
16
+ import { listGeminiArtifacts } from './providers/antigravity/artifacts.js';
16
17
  import { addOutputGrant, hasOutputGrant, removeOutputGrant } from './outputGrants.js';
17
18
  const LIMIT = 2000;
18
19
  const EXTENSIONS = {
@@ -24,6 +25,7 @@ export function outputCategory(file) {
24
25
  const ext = path.extname(file).slice(1).toLowerCase();
25
26
  return Object.keys(EXTENSIONS).find(kind => EXTENSIONS[kind].includes(ext)) ?? 'other';
26
27
  }
28
+ const GEMINI_ARTIFACT_SOURCE = 'Gemini artifact';
27
29
  const CODE_EXTENSIONS = new Set(['ts', 'tsx', 'js', 'jsx', 'mjs', 'py', 'rs', 'go', 'java', 'css', 'sh', 'sql', 'diff', 'patch']);
28
30
  const EXPORT_SOURCES = new Set(['editor export', 'media export', 'saved copy']);
29
31
  // Whether an output is something made for the operator (shown by default) or a
@@ -376,6 +378,12 @@ export async function listOutputs(ctx) {
376
378
  }
377
379
  if (JSON.stringify(index) !== before)
378
380
  await writeOutputIndex(ctx.cwd, ctx.workflowId, index);
381
+ for (const row of await listGeminiArtifacts(ctx.cwd, ctx.workflowId)) {
382
+ const category = outputCategory(row.name);
383
+ out.push({ ...ctx, id: row.id, name: row.name, title: row.name, path: row.path, category,
384
+ source: GEMINI_ARTIFACT_SOURCE, size: row.size, createdAt: row.mtime, updatedAt: row.mtime,
385
+ primary: !CODE_EXTENSIONS.has(path.extname(row.name).toLowerCase()) && category !== 'other', missing: false });
386
+ }
379
387
  return out.sort((a, b) => b.updatedAt - a.updatedAt);
380
388
  });
381
389
  }
@@ -7,9 +7,11 @@ export interface SummarizerConfig {
7
7
  effort: EffortLevel;
8
8
  providerAccountRef?: string;
9
9
  codexHome?: string;
10
+ claudeTransport?: 'native';
10
11
  goal?: string;
11
12
  }
12
13
  export interface ExportContext {
14
+ allowGeminiHandoffWriter?: boolean;
13
15
  workflowId: string;
14
16
  cwd: string;
15
17
  manager: WorkerManager;
@@ -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();