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.
- package/CONTRIBUTING.md +1 -1
- package/THIRD_PARTY_NOTICES +2 -2
- package/client/dist/assets/{PhosphorBackdrop-BbR3xmfD.js → PhosphorBackdrop-CLILIwOQ.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-UMjbs9ZN.js → ThemedBackgroundShaderImpl-B87chcb5.js} +1 -1
- package/client/dist/assets/{XtermView-n135qz-f.js → XtermView-BP_j7WSN.js} +1 -1
- package/client/dist/assets/{galleryEditor-CFSke4by.js → galleryEditor-B90phoBI.js} +1 -1
- package/client/dist/assets/{index-DeoJbjI3.js → index-BfPp1Oup.js} +270 -270
- package/client/dist/index.html +1 -1
- package/client/dist/manifest-mobile.webmanifest +1 -0
- package/client/src/App.tsx +2 -2
- package/client/src/components/AuthReloginNotice.tsx +7 -6
- package/client/src/components/ChatMessage.tsx +41 -29
- package/client/src/components/ChatPanel.tsx +17 -4
- package/client/src/components/ClaudeNativeAccountPicker.tsx +32 -0
- package/client/src/components/ClaudeNativeAuthRow.tsx +71 -19
- package/client/src/components/ClusterRightPanel/AddWorkerSection.tsx +11 -281
- package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +1 -1
- package/client/src/components/ClusterRightPanel/FreshMemberForm.tsx +315 -0
- package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +17 -7
- package/client/src/components/ClusterRightPanel/index.tsx +1 -1
- package/client/src/components/ClusterRightPanel/useFreshMemberPicker.ts +6 -4
- package/client/src/components/ClusterTab.tsx +2 -2
- package/client/src/components/Connections/Connections.tsx +7 -11
- package/client/src/components/Connections/model.ts +3 -1
- package/client/src/components/FileViewerModal.tsx +54 -17
- package/client/src/components/GitHubPanel/index.tsx +9 -5
- package/client/src/components/HandoffDialog.tsx +5 -3
- package/client/src/components/MobileShell.tsx +1 -33
- package/client/src/components/OperatorQuestionNotice.tsx +5 -4
- package/client/src/components/ProvidersPopover.tsx +6 -2
- package/client/src/components/RightPanel/ActivityTab.tsx +2 -1
- package/client/src/components/RightPanel/ConfigTab.tsx +23 -5
- package/client/src/components/RightPanel/OutputsPanel.tsx +21 -9
- package/client/src/components/RightPanel/outputsReconcile.ts +31 -0
- package/client/src/components/SettingsPanel.tsx +7 -10
- package/client/src/components/SpawnDialog.tsx +14 -3
- package/client/src/components/TabBar.tsx +2 -2
- package/client/src/components/TabContextMenu.tsx +73 -133
- package/client/src/components/TerminalInput.tsx +4 -3
- package/client/src/components/TranscriptWorkerDialog.tsx +14 -4
- package/client/src/components/UsageBar.tsx +37 -18
- package/client/src/components/WorkflowCreator/ClusterMembersSection.tsx +29 -3
- package/client/src/components/WorkflowCreator/index.tsx +29 -15
- package/client/src/components/WorkflowView.tsx +1 -1
- package/client/src/components/providerIndicator.ts +7 -3
- package/client/src/components/research/QuickResearchOverview.tsx +7 -3
- package/client/src/components/research/SavedQuickKeep.tsx +7 -3
- package/client/src/components/settings/GitHubAuthRow.tsx +34 -0
- package/client/src/explorer/ArtifactsLens.tsx +17 -8
- package/client/src/explorer/ExplorerApp.tsx +3 -3
- package/client/src/explorer/types.ts +3 -1
- package/client/src/help/content/cluster.tsx +10 -4
- package/client/src/help/content/composer.tsx +3 -2
- package/client/src/help/content/header.tsx +6 -3
- package/client/src/help/content/misc.tsx +9 -7
- package/client/src/help/content/rightPanel.tsx +11 -6
- package/client/src/help/content/settings.tsx +14 -3
- package/client/src/help/content/tabbar.tsx +1 -1
- package/client/src/help/manualSections/actions.tsx +5 -1
- package/client/src/help/manualSections/clusters.tsx +21 -15
- package/client/src/help/manualSections/configuration.tsx +6 -4
- package/client/src/help/manualSections/gettingStarted.tsx +4 -2
- package/client/src/help/manualSections/maintenance.tsx +24 -0
- package/client/src/help/manualSections/powerFeatures.tsx +4 -2
- package/client/src/help/manualSections/providers.tsx +11 -4
- package/client/src/help/manualSections/workspace.tsx +3 -3
- package/client/src/hooks/useClaudeNativeCatalog.ts +26 -0
- package/client/src/hooks/useClaudeNativeLogin.ts +16 -11
- package/client/src/hooks/useWebSocket.ts +4 -2
- package/client/src/layout/layoutRange.ts +14 -5
- package/client/src/main.tsx +2 -0
- package/client/src/questions/waitingQuestion.ts +2 -0
- package/client/src/stores/appStore.ts +5 -1
- package/client/src/stores/appStore.types.ts +2 -0
- package/client/src/stores/replayContext.ts +20 -0
- package/client/src/utils/chatFileLinks.ts +34 -3
- package/client/src/utils/claudeAuth.ts +9 -1
- package/client/src/ws/handleServerMessage.ts +11 -3
- package/docs/ARCHITECTURE.md +3 -3
- package/docs/BACKUP.md +1 -1
- package/docs/CHECKPOINTS.md +67 -3
- package/docs/CLIENT.md +11 -6
- package/docs/EXTENDING.md +1 -1
- package/docs/FEATURES.md +3 -3
- package/docs/GETTING_STARTED.md +5 -4
- package/docs/GIT_WORKBENCH.md +8 -0
- package/docs/GLOSSARY.md +2 -2
- package/docs/GOTCHAS.md +4 -4
- package/docs/HTTP_API.md +63 -30
- package/docs/OPERATIONS.md +11 -0
- package/docs/OPERATOR_ACTIONS.md +2 -2
- package/docs/OUTPUTS.md +48 -6
- package/docs/PERSISTENCE.md +1 -1
- package/docs/PRIMITIVES.md +4 -2
- package/docs/PROTOCOL_CLUSTER.md +12 -6
- package/docs/PROTOCOL_PRIMITIVES.md +1 -1
- package/docs/PROVIDERS.md +47 -10
- package/docs/RESEARCH.md +3 -3
- package/docs/SETTINGS.md +9 -4
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -3
- package/node_modules/@arco/shared/dist/protocol/clusters.js +1 -1
- package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -1
- package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/settings.d.ts +3 -0
- package/node_modules/@arco/shared/dist/protocol/settings.js +5 -0
- package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/workflows.js +0 -2
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +2 -2
- package/scripts/packaging/services.mjs +20 -1
- package/scripts/packaging/update.mjs +37 -2
- package/server/dist/attention.d.ts +6 -0
- package/server/dist/attention.js +6 -0
- package/server/dist/auth.d.ts +5 -0
- package/server/dist/auth.js +31 -20
- package/server/dist/clusterAutoTurn.d.ts +5 -1
- package/server/dist/clusterAutoTurn.js +31 -9
- package/server/dist/clusterPresets.js +3 -3
- package/server/dist/effortValidation.d.ts +2 -2
- package/server/dist/effortValidation.js +4 -4
- package/server/dist/explorerArtifacts.d.ts +1 -0
- package/server/dist/explorerArtifacts.js +12 -1
- package/server/dist/explorerDocs.d.ts +1 -0
- package/server/dist/explorerDocs.js +4 -4
- package/server/dist/geminiMembers.d.ts +7 -1
- package/server/dist/geminiMembers.js +28 -14
- package/server/dist/gitSnapshots.d.ts +1 -0
- package/server/dist/gitSnapshots.js +547 -83
- package/server/dist/http/clusterRoutes.js +9 -3
- package/server/dist/http/conversationFiles.d.ts +36 -0
- package/server/dist/http/conversationFiles.js +222 -0
- package/server/dist/http/fileBytes.d.ts +3 -0
- package/server/dist/http/fileBytes.js +33 -0
- package/server/dist/http/fileContentRoute.d.ts +2 -0
- package/server/dist/http/fileContentRoute.js +139 -0
- package/server/dist/http/fileRead.d.ts +54 -2
- package/server/dist/http/fileRead.js +31 -24
- package/server/dist/http/outputRoutes.js +14 -21
- package/server/dist/http/readConfinement.d.ts +0 -11
- package/server/dist/http/readConfinement.js +4 -30
- package/server/dist/http/router.js +41 -66
- package/server/dist/index.js +26 -12
- package/server/dist/management/initHubLink.js +1 -1
- package/server/dist/outputs.js +8 -0
- package/server/dist/primitives/exportContext.d.ts +2 -0
- package/server/dist/primitives/exportContext.js +13 -2
- package/server/dist/primitives/runCompare.d.ts +7 -1
- package/server/dist/primitives/runCompare.js +44 -20
- package/server/dist/project/taskLedger.js +46 -34
- package/server/dist/providerAccounts.d.ts +4 -0
- package/server/dist/providerAccounts.js +20 -1
- package/server/dist/providers/antigravity/artifacts.d.ts +23 -0
- package/server/dist/providers/antigravity/artifacts.js +140 -0
- package/server/dist/providers/antigravity/index.js +85 -7
- package/server/dist/providers/antigravity/questions.d.ts +2 -0
- package/server/dist/providers/antigravity/questions.js +58 -0
- package/server/dist/providers/claude-native/auth.d.ts +9 -8
- package/server/dist/providers/claude-native/auth.js +50 -58
- package/server/dist/providers/claude-native/authStatus.d.ts +2 -2
- package/server/dist/providers/claude-native/authStatus.js +9 -7
- package/server/dist/providers/claude-native/catalog.d.ts +6 -5
- package/server/dist/providers/claude-native/catalog.js +50 -39
- package/server/dist/providers/claude-native/oauth.d.ts +10 -9
- package/server/dist/providers/claude-native/oauth.js +120 -96
- package/server/dist/providers/claude-native/worker.d.ts +1 -0
- package/server/dist/providers/claude-native/worker.js +38 -23
- package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -3
- package/server/dist/providers/codex-appserver/operatorQuestions.js +27 -13
- package/server/dist/providers/codexChatBoundary.js +6 -1
- package/server/dist/research/quickPromotion.d.ts +3 -0
- package/server/dist/research/quickPromotion.js +26 -9
- package/server/dist/research/savedQuickPromotion.js +2 -11
- package/server/dist/server/broadcast.js +6 -0
- package/server/dist/settings.d.ts +1 -0
- package/server/dist/settings.js +39 -7
- package/server/dist/skills.js +1 -1
- package/server/dist/smartPickupAdapters.d.ts +1 -0
- package/server/dist/smartPickupAdapters.js +2 -2
- package/server/dist/smartPickupObserver.js +8 -5
- package/server/dist/thirdPartySkills.js +11 -5
- package/server/dist/turnChanges.d.ts +1 -1
- package/server/dist/turnChanges.js +5 -4
- package/server/dist/usage.d.ts +1 -1
- package/server/dist/usage.js +39 -27
- package/server/dist/workers/WorkerManager.d.ts +1 -0
- package/server/dist/workers/WorkerManager.js +1 -0
- package/server/dist/workers/processKill.js +37 -24
- package/server/dist/workflowMeta.js +2 -2
- package/server/dist/ws/clusterHandlers.d.ts +2 -2
- package/server/dist/ws/clusterHandlers.js +127 -113
- package/server/dist/ws/clusterMembers.d.ts +1 -1
- package/server/dist/ws/clusterMembers.js +34 -4
- package/server/dist/ws/compactHandlers.js +30 -14
- package/server/dist/ws/compareHandlers.js +53 -21
- package/server/dist/ws/gateHandlers.js +2 -0
- package/server/dist/ws/genesisHandlers.js +5 -3
- package/server/dist/ws/handoffHandlers.d.ts +1 -1
- package/server/dist/ws/handoffHandlers.js +115 -39
- package/server/dist/ws/transcriptWorkerHandlers.js +7 -2
- package/server/dist/ws/turnEngine.js +37 -19
- package/server/dist/ws/updatePrimaryConfig.d.ts +3 -2
- package/server/dist/ws/updatePrimaryConfig.js +236 -133
- package/server/dist/ws/workflowHandlers.js +21 -4
- package/server/package.json +1 -1
- package/server/src/attention.ts +7 -0
- package/server/src/auth.ts +33 -20
- package/server/src/clusterAutoTurn.ts +31 -11
- package/server/src/clusterPresets.ts +2 -2
- package/server/src/effortValidation.ts +4 -4
- package/server/src/explorerArtifacts.ts +12 -1
- package/server/src/explorerDocs.ts +5 -5
- package/server/src/geminiMembers.ts +26 -15
- package/server/src/gitSnapshots.ts +538 -82
- package/server/src/http/clusterRoutes.ts +10 -3
- package/server/src/http/conversationFiles.ts +231 -0
- package/server/src/http/fileBytes.ts +34 -0
- package/server/src/http/fileContentRoute.ts +123 -0
- package/server/src/http/fileRead.ts +30 -25
- package/server/src/http/outputRoutes.ts +13 -13
- package/server/src/http/readConfinement.ts +3 -30
- package/server/src/http/router.ts +39 -62
- package/server/src/index.ts +27 -18
- package/server/src/management/initHubLink.ts +1 -1
- package/server/src/outputs.ts +8 -0
- package/server/src/primitives/exportContext.ts +14 -2
- package/server/src/primitives/runCompare.ts +73 -46
- package/server/src/project/taskLedger.ts +47 -30
- package/server/src/providerAccounts.ts +20 -1
- package/server/src/providers/antigravity/artifacts.ts +121 -0
- package/server/src/providers/antigravity/index.ts +64 -6
- package/server/src/providers/antigravity/questions.ts +52 -0
- package/server/src/providers/claude-native/auth.ts +45 -60
- package/server/src/providers/claude-native/authStatus.ts +9 -8
- package/server/src/providers/claude-native/catalog.ts +52 -35
- package/server/src/providers/claude-native/oauth.ts +101 -77
- package/server/src/providers/claude-native/worker.ts +38 -22
- package/server/src/providers/codex-appserver/operatorQuestions.ts +26 -12
- package/server/src/providers/codexChatBoundary.ts +6 -1
- package/server/src/research/quickPromotion.ts +24 -6
- package/server/src/research/savedQuickPromotion.ts +2 -8
- package/server/src/server/broadcast.ts +4 -0
- package/server/src/settings.ts +36 -8
- package/server/src/skills.ts +1 -1
- package/server/src/smartPickupAdapters.ts +3 -2
- package/server/src/smartPickupObserver.ts +8 -5
- package/server/src/thirdPartySkills.ts +11 -5
- package/server/src/turnChanges.ts +5 -4
- package/server/src/usage.ts +30 -22
- package/server/src/workers/WorkerManager.ts +2 -0
- package/server/src/workers/processKill.ts +37 -23
- package/server/src/workflowMeta.ts +2 -2
- package/server/src/ws/clusterHandlers.ts +107 -104
- package/server/src/ws/clusterMembers.ts +25 -6
- package/server/src/ws/compactHandlers.ts +29 -15
- package/server/src/ws/compareHandlers.ts +59 -25
- package/server/src/ws/gateHandlers.ts +2 -0
- package/server/src/ws/genesisHandlers.ts +5 -4
- package/server/src/ws/handoffHandlers.ts +105 -37
- package/server/src/ws/transcriptWorkerHandlers.ts +6 -2
- package/server/src/ws/turnEngine.ts +36 -18
- package/server/src/ws/updatePrimaryConfig.ts +230 -132
- package/server/src/ws/workflowHandlers.ts +20 -4
- package/shared/dist/protocol/clusters.d.ts +15 -3
- package/shared/dist/protocol/clusters.js +1 -1
- package/shared/dist/protocol/models.d.ts +6 -1
- package/shared/dist/protocol/operatorQuestions.d.ts +2 -1
- package/shared/dist/protocol/settings.d.ts +3 -0
- package/shared/dist/protocol/settings.js +5 -0
- package/shared/dist/protocol/workflows.d.ts +1 -0
- package/shared/dist/protocol/workflows.js +0 -2
- package/shared/src/protocol/clusters.ts +23 -5
- package/shared/src/protocol/compare.ts +2 -2
- package/shared/src/protocol/models.ts +8 -4
- package/shared/src/protocol/operatorQuestions.ts +2 -1
- package/shared/src/protocol/settings.ts +8 -1
- package/shared/src/protocol/workflows.ts +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AntigravityProvider, registerAntigravityCompact, clearAntigravityCompact } from '../providers/antigravity/index.js';
|
|
2
2
|
import { antigravityChatWorkspace } from '../chatMode.js';
|
|
3
3
|
import type { ProviderEvents } from '../providers/types.js';
|
|
4
|
+
import { promptContextEstimate } from '../contextEstimator.js';
|
|
4
5
|
import { hasConversationHistory } from '../providerConversation.js';
|
|
5
6
|
import { supportsManualCompact } from '../manualCompactCapability.js';
|
|
6
7
|
// `compact_workflow` handler — operator-triggered native compaction. One WS
|
|
@@ -24,7 +25,7 @@ import { supportsManualCompact } from '../manualCompactCapability.js';
|
|
|
24
25
|
import { WebSocket } from 'ws';
|
|
25
26
|
import { publishActivity } from '../voice/activityBus.js';
|
|
26
27
|
import type { CompactWorkflowMessage, FoldWorkflowMessage } from '@arco/shared';
|
|
27
|
-
import { resolveOutputStyle } from '@arco/shared';
|
|
28
|
+
import { isIsolatedAccessMode, resolveOutputStyle } from '@arco/shared';
|
|
28
29
|
import type { Session } from '../workflows/types.js';
|
|
29
30
|
import {
|
|
30
31
|
claimBusy,
|
|
@@ -146,7 +147,7 @@ export async function handleCompactWorkflow(ws: WebSocket, session: Session, msg
|
|
|
146
147
|
: provider === 'antigravity-cli' ? 'Gemini ACP /compact' : 'Claude Native in-place compact',
|
|
147
148
|
});
|
|
148
149
|
|
|
149
|
-
let result: { ok: boolean; error?: string; foldedTurns?: number;
|
|
150
|
+
let result: { ok: boolean; error?: string; foldedTurns?: number; geminiText?: string; geminiContext?: NonNullable<ReturnType<typeof promptContextEstimate>> };
|
|
150
151
|
const beforeContext = wf.lastContextPercent;
|
|
151
152
|
let compactedVia: 'codex-appserver' | 'cursor-acp' | 'claude-native' = 'claude-native';
|
|
152
153
|
try {
|
|
@@ -211,8 +212,11 @@ export async function handleCompactWorkflow(ws: WebSocket, session: Session, msg
|
|
|
211
212
|
}, wf.primarySessionId);
|
|
212
213
|
}
|
|
213
214
|
} else if (provider === 'antigravity-cli') {
|
|
215
|
+
const clusterId = clusterStore.getClusterIdForWorkflow(workflowId);
|
|
216
|
+
const accessMode = clusterId ? clusterStore.getMemberAccessMode(clusterId, workflowId) : undefined;
|
|
214
217
|
if (!expectedSessionId || !cwd) result = { ok: false, error: 'No saved Gemini session; run a turn first.' };
|
|
215
218
|
else if (wf.config.incognito) result = { ok: false, error: 'Gemini compact is unavailable in Incognito.' };
|
|
219
|
+
else if (isIsolatedAccessMode(accessMode) && (accessMode !== 'researcher' || autoDetail)) result = { ok: false, error: 'Gemini compact is unavailable for this isolated worker.' };
|
|
216
220
|
else if (!ownsBusy(wf, busyToken) || wf.primarySessionId !== expectedSessionId || wf.primary.provider !== provider) result = { ok: false, error: 'compaction cancelled before dispatch' };
|
|
217
221
|
else {
|
|
218
222
|
const chat = isChatWorkflow(wf.config);
|
|
@@ -221,20 +225,24 @@ export async function handleCompactWorkflow(ws: WebSocket, session: Session, msg
|
|
|
221
225
|
cwd: chat ? antigravityChatWorkspace(workflowId) : cwd, workflowId,
|
|
222
226
|
skipPermissions: wf.primary.skipPermissions, resumeSessionId: expectedSessionId,
|
|
223
227
|
interactionMode: 'agent', antigravityInteractive: true, antigravityChatWorkspace: chat,
|
|
228
|
+
clusterId, clusterAccessMode: accessMode,
|
|
229
|
+
clusterWebAccess: clusterId ? clusterStore.getMemberWebAccess(clusterId, workflowId) : undefined,
|
|
224
230
|
});
|
|
225
231
|
registerAntigravityCompact(workflowId, process);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
try {
|
|
233
|
+
result = await new Promise((resolve) => {
|
|
234
|
+
const timer = setTimeout(() => process.kill(), 120_000);
|
|
235
|
+
process.once('error', (error: string) => { clearTimeout(timer); resolve({ ok: false, error }); });
|
|
236
|
+
process.once('result', (outcome: Parameters<ProviderEvents['result']>[0]) => {
|
|
237
|
+
clearTimeout(timer);
|
|
238
|
+
const geminiContext = promptContextEstimate(outcome.lastPromptTokens, outcome.modelContextWindow, Date.now()) ?? undefined;
|
|
239
|
+
resolve({ ok: true, geminiContext, geminiText: outcome.text.trim().slice(0, 2000) });
|
|
240
|
+
});
|
|
241
|
+
process.spawn('/compact');
|
|
234
242
|
});
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
243
|
+
} finally {
|
|
244
|
+
clearAntigravityCompact(workflowId, process);
|
|
245
|
+
}
|
|
238
246
|
}
|
|
239
247
|
} else {
|
|
240
248
|
compactedVia = 'claude-native';
|
|
@@ -249,6 +257,7 @@ export async function handleCompactWorkflow(ws: WebSocket, session: Session, msg
|
|
|
249
257
|
additionalDirectories: wf.primary.additionalDirectories,
|
|
250
258
|
fallbackModel: wf.primary.fallbackModel,
|
|
251
259
|
claudeTransport: 'native',
|
|
260
|
+
providerAccountRef: wf.config.providerAccountRef,
|
|
252
261
|
claudeNativeCompact: wf.config.claudeNativeCompact === true,
|
|
253
262
|
claudeNativeForceInterleavedThinkingBeta: wf.config.claudeNativeForceInterleavedThinkingBeta === true,
|
|
254
263
|
claudeNativeThinkingDisplay: wf.config.claudeNativeThinkingDisplay,
|
|
@@ -276,18 +285,22 @@ export async function handleCompactWorkflow(ws: WebSocket, session: Session, msg
|
|
|
276
285
|
if (autoDetail) onSuccess?.();
|
|
277
286
|
else resetAutoCompactionCycle(wf);
|
|
278
287
|
}
|
|
279
|
-
if (result.ok && owned && autoDetail) {
|
|
288
|
+
if (result.ok && owned && autoDetail && provider !== 'antigravity-cli') {
|
|
280
289
|
if (provider === 'codex') resetCodexContextAfterCompact(workflowId, wf);
|
|
281
290
|
else wf.lastContextPercent = 0;
|
|
282
291
|
wf.lastContextBudgetPct = undefined;
|
|
283
292
|
}
|
|
293
|
+
if (result.ok && owned && result.geminiContext) {
|
|
294
|
+
wf.lastContextPercent = result.geminiContext.percentOfWindow;
|
|
295
|
+
broadcastTransient(workflowId, { type: 'context_usage', workflowId, ...result.geminiContext });
|
|
296
|
+
}
|
|
284
297
|
if (result.ok) {
|
|
285
298
|
const foldedNote = typeof result.foldedTurns === 'number' ? ` (${result.foldedTurns} turn(s) folded)` : '';
|
|
286
299
|
broadcastWorkflow(workflowId, {
|
|
287
300
|
type: 'system_notice',
|
|
288
301
|
workflowId,
|
|
289
302
|
content: provider === 'antigravity-cli'
|
|
290
|
-
? `${tag} Compaction sent to Gemini. ${result.
|
|
303
|
+
? `${tag} ${result.geminiText || 'Compaction sent to Gemini.'} ${result.geminiContext === undefined ? 'Gemini did not report a new context size' : `context ${typeof beforeContext === 'number' ? `${beforeContext}% → ` : ''}${result.geminiContext.percentOfWindow}%`}.`
|
|
291
304
|
: provider === 'cursor'
|
|
292
305
|
? `${tag} Conversation compressed — Cursor summarized older context in place. The same ACP session continues with a smaller retained history.`
|
|
293
306
|
: provider === 'codex'
|
|
@@ -402,6 +415,7 @@ export async function handleFoldWorkflow(ws: WebSocket, _session: Session, msg:
|
|
|
402
415
|
additionalDirectories: wf.primary.additionalDirectories,
|
|
403
416
|
fallbackModel: wf.primary.fallbackModel,
|
|
404
417
|
claudeTransport: 'native' as const,
|
|
418
|
+
providerAccountRef: wf.config.providerAccountRef,
|
|
405
419
|
claudeNativeCompact: wf.config.claudeNativeCompact === true,
|
|
406
420
|
claudeNativeForceInterleavedThinkingBeta: wf.config.claudeNativeForceInterleavedThinkingBeta === true,
|
|
407
421
|
claudeNativeThinkingDisplay: wf.config.claudeNativeThinkingDisplay,
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
// server/src/primitives/runCompare.ts (modeled on runReviewer/runResearch).
|
|
7
7
|
|
|
8
8
|
import { WebSocket } from 'ws';
|
|
9
|
-
import { COMPARE_MIN_LEGS, COMPARE_MAX_LEGS, TERMINAL_CODEX_ACCOUNT } from '@arco/shared';
|
|
9
|
+
import { COMPARE_MIN_LEGS, COMPARE_MAX_LEGS, DEFAULT_CLAUDE_NATIVE_ACCOUNT, isClaudeNativeProfileId, TERMINAL_CODEX_ACCOUNT, type CompareLegConfig } from '@arco/shared';
|
|
10
10
|
import { send } from '../server/broadcast.js';
|
|
11
11
|
import { workflows } from '../server/state.js';
|
|
12
|
-
import { resolveProviderAccount } from '../providerAccounts.js';
|
|
13
|
-
import { buildReplyDraftTask, runCompare, type CompareRecord } from '../primitives/runCompare.js';
|
|
12
|
+
import { requireClaudeNativeAccount, resolveProviderAccount } from '../providerAccounts.js';
|
|
13
|
+
import { buildReplyDraftTask, runCompare, spawnCompareLeg, type CompareRecord } from '../primitives/runCompare.js';
|
|
14
|
+
import { resolveClaudeTransport } from '../claudeTransport.js';
|
|
14
15
|
import type { Session } from '../workflows/types.js';
|
|
15
16
|
|
|
16
17
|
// Active races, keyed by compareId. Kept alive after the race settles so the
|
|
@@ -39,6 +40,22 @@ export async function resolveCompareLegs<T extends { provider: string; providerA
|
|
|
39
40
|
return { resolvedLegs: resolutions.map(result => result.leg), codexHomes: resolutions.map(result => result.codexHome) };
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
async function resolveCompareClaudeLeg(
|
|
44
|
+
leg: CompareLegConfig,
|
|
45
|
+
parentClaudeRef?: string,
|
|
46
|
+
parentNativeRef?: string,
|
|
47
|
+
): Promise<CompareLegConfig> {
|
|
48
|
+
if (leg.provider !== 'claude') return leg;
|
|
49
|
+
const ref = leg.providerAccountRef ?? parentNativeRef;
|
|
50
|
+
// An old CLI label or the tab's parked Native choice on CLI is not an
|
|
51
|
+
// account selection for a Native request. An unavailable Native binding
|
|
52
|
+
// must instead be refused, including a legacy label on a Native tab.
|
|
53
|
+
const parked = !parentNativeRef && ref === parentClaudeRef;
|
|
54
|
+
const native = ref !== undefined && !parked
|
|
55
|
+
&& (ref === parentNativeRef || ref === DEFAULT_CLAUDE_NATIVE_ACCOUNT || isClaudeNativeProfileId(ref));
|
|
56
|
+
return { ...leg, providerAccountRef: native ? await requireClaudeNativeAccount(ref) : undefined };
|
|
57
|
+
}
|
|
58
|
+
|
|
42
59
|
// Fan ONE prompt out to N read-only legs. Resolves each leg's config like the
|
|
43
60
|
// reviewer/research paths (Codex legs get their account routed), clamps the leg
|
|
44
61
|
// count, and hands off to runCompare. Returns immediately; per-leg streaming +
|
|
@@ -73,14 +90,33 @@ export async function handleCompareRequest(
|
|
|
73
90
|
return;
|
|
74
91
|
}
|
|
75
92
|
|
|
76
|
-
// Resolve
|
|
77
|
-
//
|
|
78
|
-
let
|
|
93
|
+
// Resolve all bindings before dispatch. Only a matching provider may
|
|
94
|
+
// inherit the parent tab's account.
|
|
95
|
+
let selectedLegs: CompareLegConfig[];
|
|
79
96
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
const parentClaudeRef = wf.primary.provider === 'claude' && legs.some(leg => leg.provider === 'claude')
|
|
98
|
+
? wf.config.providerAccountRef : undefined;
|
|
99
|
+
const parentNativeRef = parentClaudeRef && await resolveClaudeTransport(wf, cwd) === 'native'
|
|
100
|
+
? parentClaudeRef : undefined;
|
|
101
|
+
selectedLegs = await Promise.all(legs.map(leg => resolveCompareClaudeLeg(leg, parentClaudeRef, parentNativeRef)));
|
|
102
|
+
} catch (err) {
|
|
103
|
+
send(ws, { type: 'error', workflowId: msg.workflowId,
|
|
104
|
+
message: err instanceof Error ? err.message : 'The selected Claude Native account is unavailable.' });
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (replyDraft && msg.fileAccess && selectedLegs.some(leg => leg.provider === 'claude' && leg.providerAccountRef)) {
|
|
108
|
+
send(ws, { type: 'error', workflowId: msg.workflowId,
|
|
109
|
+
message: 'Second Opinion with a Claude Native account uses text only. Turn off Let the models read project files and try again.' });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let resolved: Awaited<ReturnType<typeof resolveCompareLegs<CompareLegConfig>>>;
|
|
114
|
+
try {
|
|
115
|
+
const codexFallback = wf.primary.provider === 'codex' ? wf.config.providerAccountRef : undefined;
|
|
116
|
+
resolved = await resolveCompareLegs(selectedLegs, ref => resolveProviderAccount('codex', ref, cwd), codexFallback);
|
|
82
117
|
} catch {
|
|
83
|
-
send(ws, { type: 'error',
|
|
118
|
+
send(ws, { type: 'error', workflowId: msg.workflowId,
|
|
119
|
+
message: 'A selected Codex account is unavailable. Check the account and try again.' });
|
|
84
120
|
return;
|
|
85
121
|
}
|
|
86
122
|
const { resolvedLegs, codexHomes } = resolved;
|
|
@@ -161,7 +197,7 @@ export async function handleCompareSynthesize(
|
|
|
161
197
|
send(ws, { type: 'error', message: 'Synthesize references an out-of-range leg.' });
|
|
162
198
|
return;
|
|
163
199
|
}
|
|
164
|
-
|
|
200
|
+
let synthLeg = rec.legs[idx];
|
|
165
201
|
// Seed the synthesizer with the prompt + every (non-empty) answer, labeled by
|
|
166
202
|
// their position. No cross-leg session — this is a fresh bounded leg whose
|
|
167
203
|
// ENTIRE input is this assembled brief.
|
|
@@ -172,13 +208,16 @@ export async function handleCompareSynthesize(
|
|
|
172
208
|
const synthPrompt = `You are synthesizing the single best ${rec.task ? 'reply (written to the worker, ready to paste)' : 'response'} to a prompt from several independent answers below. Read them all, keep what each got right, drop what's wrong or redundant, and write ONE improved, self-contained answer. Do not mention that you are merging answers — just produce the best response.\n\n--- ORIGINAL PROMPT ---\n\n${rec.task ?? rec.prompt}\n\n--- CANDIDATE ANSWERS ---\n\n${answersBlock}`;
|
|
173
209
|
|
|
174
210
|
let codexHome: string | undefined;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
resolveProviderAccount('codex', ref, cwd)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
211
|
+
if (synthLeg.provider === 'codex') {
|
|
212
|
+
try {
|
|
213
|
+
const resolved = await resolveCompareLegs([synthLeg], ref => resolveProviderAccount('codex', ref, cwd));
|
|
214
|
+
synthLeg = resolved.resolvedLegs[0];
|
|
215
|
+
codexHome = resolved.codexHomes[0];
|
|
216
|
+
} catch {
|
|
217
|
+
send(ws, { type: 'error', workflowId: msg.workflowId,
|
|
218
|
+
message: 'The selected Codex account is unavailable. Check the account and try again.' });
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
182
221
|
}
|
|
183
222
|
|
|
184
223
|
// Spawn directly (not via runCompare) so we can stamp the synthesis pane index
|
|
@@ -192,8 +231,9 @@ export async function handleCompareSynthesize(
|
|
|
192
231
|
type: 'compare_leg_delta', workflowId: msg.workflowId, compareId: msg.compareId,
|
|
193
232
|
legIndex: synthLegIndex, text: '',
|
|
194
233
|
});
|
|
195
|
-
|
|
196
|
-
{
|
|
234
|
+
spawnCompareLeg(
|
|
235
|
+
{ cwd, workflowId: msg.workflowId, manager: wf.manager },
|
|
236
|
+
synthLeg, { id: legId, task: synthPrompt, codexHome },
|
|
197
237
|
(ev) => {
|
|
198
238
|
if (ev.type === 'worker_text') {
|
|
199
239
|
collected += ev.text;
|
|
@@ -202,12 +242,6 @@ export async function handleCompareSynthesize(
|
|
|
202
242
|
send(ws, { type: 'system_notice', workflowId: msg.workflowId, content: ev.notice, authRecovery: ev.authRecovery });
|
|
203
243
|
}
|
|
204
244
|
},
|
|
205
|
-
{
|
|
206
|
-
cwd, workflowId: msg.workflowId,
|
|
207
|
-
skipPermissions: synthLeg.provider === 'ollama',
|
|
208
|
-
sandbox: 'read-only', outputStyle: 'normal',
|
|
209
|
-
...(synthLeg.provider === 'codex' && codexHome ? { providerAccountRef: synthLeg.providerAccountRef, codexHome } : {}),
|
|
210
|
-
},
|
|
211
245
|
).then((r) => {
|
|
212
246
|
send(ws, {
|
|
213
247
|
type: 'compare_leg_complete', workflowId: msg.workflowId, compareId: msg.compareId,
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import type { WebSocket } from 'ws';
|
|
22
22
|
import type { Session } from '../workflows/types.js';
|
|
23
23
|
import { workflows } from '../server/state.js';
|
|
24
|
+
import { acknowledgeSighting } from '../attention.js';
|
|
24
25
|
import { broadcastWorkflow } from '../server/broadcast.js';
|
|
25
26
|
import { handleUserMessage } from './turnEngine.js';
|
|
26
27
|
import { readGateStore, clearPendingGate, removeStandingApproval, type PendingGateRecord } from '../providers/claude-native/gateStore.js';
|
|
@@ -60,6 +61,7 @@ export async function rehydrateGatesOnce(workflowId: string, cwd: string): Promi
|
|
|
60
61
|
await broadcastStanding(workflowId, cwd);
|
|
61
62
|
if (!store || store.pending.length === 0) return;
|
|
62
63
|
for (const g of store.pending) {
|
|
64
|
+
acknowledgeSighting(g.gateId);
|
|
63
65
|
console.log(`[arco] [${workflowId.slice(0, 8)}] re-surfacing pending review gate ${g.gateId.slice(0, 8)} after restart`);
|
|
64
66
|
broadcastWorkflow(workflowId, {
|
|
65
67
|
type: 'gate_required',
|
|
@@ -39,6 +39,7 @@ import { initWorkflowStore, flushWorkflowBuffer, forgetWorkflowBuffer } from '..
|
|
|
39
39
|
import { rememberCwd } from '../crashRecovery.js';
|
|
40
40
|
import { createPlan, recordAttachment } from '../planStore.js';
|
|
41
41
|
import { resolveProviderAccount } from '../providerAccounts.js';
|
|
42
|
+
import { effectiveClaudeTransport } from '../claudeTransport.js';
|
|
42
43
|
import { readSettings } from '../settings.js';
|
|
43
44
|
import { assessGenesisReadiness } from '../genesis/stages.js';
|
|
44
45
|
import { nextFieldPrompt } from '../genesis/prompts.js';
|
|
@@ -409,10 +410,7 @@ export async function handleGenesisAssistRequest(ws: WebSocket, msg: GenesisAssi
|
|
|
409
410
|
? await resolveProviderAccount('codex', wf.config.providerAccountRef, cwd).catch(() => null)
|
|
410
411
|
: null;
|
|
411
412
|
const cascade = await readSettings(cwd).catch(() => null);
|
|
412
|
-
const claudeTransport
|
|
413
|
-
wf.config.claudeTransport === 'native' || wf.config.claudeTransport === 'cli'
|
|
414
|
-
? wf.config.claudeTransport
|
|
415
|
-
: cascade?.claude?.transport === 'native' ? 'native' : 'cli';
|
|
413
|
+
const claudeTransport = effectiveClaudeTransport(wf.config, cascade);
|
|
416
414
|
const codexTransport: 'exec' | 'appserver' =
|
|
417
415
|
wf.config.codexTransport === 'appserver' || wf.config.codexTransport === 'exec'
|
|
418
416
|
? wf.config.codexTransport
|
|
@@ -443,6 +441,9 @@ export async function handleGenesisAssistRequest(ws: WebSocket, msg: GenesisAssi
|
|
|
443
441
|
skipPermissions: wf.primary.provider === 'ollama',
|
|
444
442
|
outputStyle: 'normal',
|
|
445
443
|
...(wf.primary.provider === 'claude' ? { claudeTransport } : {}),
|
|
444
|
+
...(wf.primary.provider === 'claude' && claudeTransport === 'native'
|
|
445
|
+
? { providerAccountRef: wf.config.providerAccountRef }
|
|
446
|
+
: {}),
|
|
446
447
|
...(wf.primary.provider === 'codex' ? { codexTransport, codexContextPolicy: wf.config.codexContextPolicy } : {}),
|
|
447
448
|
...(wf.primary.provider === 'codex' && account
|
|
448
449
|
? { providerAccountRef: account.profile.id, codexHome: account.codexHome }
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { geminiClusterInstructions } from '../geminiMembers.js';
|
|
1
2
|
import { allowedWorkflowEfforts, normalizedWorkflowEffort } from '../effortValidation.js';
|
|
2
3
|
import * as directorContinue from '../directorContinue.js';
|
|
3
4
|
import { runningCodexLateCommands } from '../providers/codex-appserver/index.js';
|
|
@@ -46,7 +47,7 @@ import {
|
|
|
46
47
|
import type { PreviewAutoDetect } from '../previewAutoDetect.js';
|
|
47
48
|
import { runExportContext } from '../primitives/exportContext.js';
|
|
48
49
|
import { runPrimaryTurn } from '../primitives/seedWorker.js';
|
|
49
|
-
import { resolveProviderAccount } from '../providerAccounts.js';
|
|
50
|
+
import { requireClaudeNativeAccount, resolveProviderAccount } from '../providerAccounts.js';
|
|
50
51
|
import { catalogDriftProbe } from './clusterHandlers.js';
|
|
51
52
|
import { checkModelDrift, driftFlag } from '../primitiveDrift.js';
|
|
52
53
|
import { disposeClaudeNativeWorker, getClaudeNativePendingInteractions } from '../providers/claude-native/index.js';
|
|
@@ -81,6 +82,7 @@ import {
|
|
|
81
82
|
} from '../settings.js';
|
|
82
83
|
import {
|
|
83
84
|
appendHistoryEntry,
|
|
85
|
+
clearProviderCliSessions,
|
|
84
86
|
readMeta,
|
|
85
87
|
workflowConfigFromMeta,
|
|
86
88
|
writeMeta,
|
|
@@ -138,13 +140,18 @@ export async function handleHandoffRequest(
|
|
|
138
140
|
ws: WebSocket,
|
|
139
141
|
session: Session,
|
|
140
142
|
msg: import('@arco/shared').HandoffRequestMessage,
|
|
143
|
+
operatorRequested = false,
|
|
141
144
|
): Promise<{ artifactName: string } | void> {
|
|
142
145
|
const wf = workflows.get(msg.workflowId);
|
|
143
146
|
if (!wf) {
|
|
144
147
|
send(ws, { type: 'error', message: `Unknown workflow ${msg.workflowId.slice(0, 8)}` });
|
|
145
148
|
return;
|
|
146
149
|
}
|
|
147
|
-
if (msg.newPrimary &&
|
|
150
|
+
if (msg.newPrimary?.provider === 'claude' && msg.newPrimary.providerAccountRef !== undefined) {
|
|
151
|
+
try { await requireClaudeNativeAccount(msg.newPrimary.providerAccountRef); }
|
|
152
|
+
catch { send(ws, { type: 'error', message: 'Choose an available Claude Native account for the new session.' }); return; }
|
|
153
|
+
}
|
|
154
|
+
if (msg.newPrimary && !allowedWorkflowEfforts(msg.newPrimary.provider, msg.newPrimary.model, msg.newPrimary.providerAccountRef ?? (wf.primary.provider === msg.newPrimary.provider ? wf.config.providerAccountRef : undefined)).includes(msg.newPrimary.effort)) {
|
|
148
155
|
send(ws, { type: 'error', message: 'The selected effort is not supported by this provider and model.' });
|
|
149
156
|
return;
|
|
150
157
|
}
|
|
@@ -154,6 +161,14 @@ export async function handleHandoffRequest(
|
|
|
154
161
|
send(ws, { type: 'error', message: 'Handoff is not available in Chat tabs.' });
|
|
155
162
|
return;
|
|
156
163
|
}
|
|
164
|
+
const involvesGemini = [wf.primary.provider, msg.newPrimary?.provider, msg.summarizer?.provider].includes('antigravity-cli');
|
|
165
|
+
const clusterId = clusterStore.getClusterIdForWorkflow(msg.workflowId);
|
|
166
|
+
const geminiHandoffAllowed = operatorRequested && !isComputer(wf) && (!clusterId ||
|
|
167
|
+
(clusterStore.getMemberAccessMode(clusterId, msg.workflowId) === 'standard' && !clusterStore.getClusterCached(clusterId)?.research));
|
|
168
|
+
if (involvesGemini && !geminiHandoffAllowed) {
|
|
169
|
+
send(ws, { type: 'error', workflowId: msg.workflowId, message: 'Gemini HANDOFF requires an operator request in an Agent tab or a standard member outside Research.' });
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
157
172
|
if (wf.busy) {
|
|
158
173
|
send(ws, { type: 'error', message: 'Primary agent is busy — cancel or wait before rotating.' });
|
|
159
174
|
return;
|
|
@@ -281,7 +296,7 @@ export async function handleHandoffRequest(
|
|
|
281
296
|
if (currentCodexAccount?.profile.id && wf.config.providerAccountRef !== currentCodexAccount.profile.id) {
|
|
282
297
|
wf.config.providerAccountRef = currentCodexAccount.profile.id;
|
|
283
298
|
}
|
|
284
|
-
|
|
299
|
+
let effectiveSummarizer: import('../primitives/exportContext.js').SummarizerConfig = summarizer.provider === 'codex' && currentCodexAccount
|
|
285
300
|
? { ...summarizer, providerAccountRef: currentCodexAccount.profile.id, codexHome: currentCodexAccount.codexHome }
|
|
286
301
|
: summarizer;
|
|
287
302
|
|
|
@@ -309,8 +324,8 @@ export async function handleHandoffRequest(
|
|
|
309
324
|
let claudeTransport: 'cli' | 'native' = 'cli';
|
|
310
325
|
if (wf.primary.provider === 'claude') {
|
|
311
326
|
const tab = wf.config.claudeTransport;
|
|
312
|
-
if (tab === 'native' || tab === 'cli') {
|
|
313
|
-
claudeTransport = tab
|
|
327
|
+
if (wf.config.ultracode || tab === 'native' || tab === 'cli') {
|
|
328
|
+
claudeTransport = wf.config.ultracode ? 'cli' : tab!;
|
|
314
329
|
} else {
|
|
315
330
|
const cascade = await readSettings(cwd).catch(() => null);
|
|
316
331
|
if (!handoffOwned()) return;
|
|
@@ -318,6 +333,10 @@ export async function handleHandoffRequest(
|
|
|
318
333
|
}
|
|
319
334
|
}
|
|
320
335
|
|
|
336
|
+
if (!wf.config.ultracode && wf.primary.provider === 'claude' && claudeTransport === 'native' && effectiveSummarizer.provider === 'claude') {
|
|
337
|
+
effectiveSummarizer = { ...effectiveSummarizer, claudeTransport: 'native', providerAccountRef: wf.config.providerAccountRef };
|
|
338
|
+
}
|
|
339
|
+
|
|
321
340
|
// For 'original-worker' mode the reflection turn runs on the workflow's
|
|
322
341
|
// current primary session via --resume (CLI) or via in-memory messages
|
|
323
342
|
// replay (Native); we pass that context through. For 'fresh-summarizer'
|
|
@@ -329,7 +348,7 @@ export async function handleHandoffRequest(
|
|
|
329
348
|
sessionId: wf.primarySessionId ?? '',
|
|
330
349
|
cwd,
|
|
331
350
|
...(currentCodexAccount ? { providerAccountRef: currentCodexAccount.profile.id, codexHome: currentCodexAccount.codexHome } : {}),
|
|
332
|
-
...(wf.primary.provider === 'claude' ? { transport: claudeTransport } : {}),
|
|
351
|
+
...(wf.primary.provider === 'claude' ? { transport: claudeTransport, providerAccountRef: wf.config.providerAccountRef } : {}),
|
|
333
352
|
}
|
|
334
353
|
: undefined;
|
|
335
354
|
|
|
@@ -340,7 +359,12 @@ export async function handleHandoffRequest(
|
|
|
340
359
|
// operator's "original worker" choice by having the same model reread the
|
|
341
360
|
// transcript through the summarizer path, with the configured summarizer as
|
|
342
361
|
// a fallback when the transcript is too large for that model.
|
|
343
|
-
if (effectiveMode === 'original-worker' &&
|
|
362
|
+
if (effectiveMode === 'original-worker' && wf.primary.provider === 'antigravity-cli') {
|
|
363
|
+
effectiveMode = 'fresh-summarizer';
|
|
364
|
+
translatedSummarizer = { provider: wf.primary.provider, model: wf.primary.model, effort: msg.summarizer?.effort ?? 'medium' };
|
|
365
|
+
send(ws, { type: 'system_notice', workflowId: msg.workflowId,
|
|
366
|
+
content: 'Gemini writes the handoff with the same model in a fresh reply-only session using the saved transcript.' });
|
|
367
|
+
} else if (effectiveMode === 'original-worker' && !resumable) {
|
|
344
368
|
// Overflow heuristic: the summarizer must re-read roughly the whole
|
|
345
369
|
// conversation. If live context is already near full, a same-sized local
|
|
346
370
|
// model can't fit the transcript back into its own window. lastContextPercent
|
|
@@ -398,6 +422,7 @@ export async function handleHandoffRequest(
|
|
|
398
422
|
if (!handoffOwned()) return;
|
|
399
423
|
const handle = runExportContext(
|
|
400
424
|
{
|
|
425
|
+
allowGeminiHandoffWriter: geminiHandoffAllowed,
|
|
401
426
|
workflowId: msg.workflowId,
|
|
402
427
|
cwd,
|
|
403
428
|
manager: wf.manager,
|
|
@@ -512,9 +537,17 @@ export async function handleHandoffRequest(
|
|
|
512
537
|
// Update in-memory state + persist to meta.json BEFORE the pre-warm spawn
|
|
513
538
|
// so the new session is minted against the chosen CLI.
|
|
514
539
|
if (msg.newPrimary) {
|
|
515
|
-
const
|
|
516
|
-
|
|
540
|
+
const previousProvider = wf.primary.provider;
|
|
541
|
+
const nextProviderAccountRef = msg.newPrimary.provider === 'codex' || msg.newPrimary.provider === 'claude'
|
|
542
|
+
? msg.newPrimary.providerAccountRef ?? (previousProvider === msg.newPrimary.provider ? wf.config.providerAccountRef : undefined)
|
|
517
543
|
: undefined;
|
|
544
|
+
if (msg.newPrimary.provider === 'claude' && msg.newPrimary.providerAccountRef !== undefined) {
|
|
545
|
+
claudeTransport = 'native';
|
|
546
|
+
wf.config.claudeTransport = 'native';
|
|
547
|
+
wf.config.ultracode = false;
|
|
548
|
+
} else if (msg.newPrimary.provider === 'claude' && previousProvider !== 'claude') {
|
|
549
|
+
claudeTransport = wf.config.ultracode ? 'cli' : wf.config.claudeTransport ?? summarizerSettings?.claude?.transport ?? 'native';
|
|
550
|
+
}
|
|
518
551
|
wf.primary.provider = msg.newPrimary.provider;
|
|
519
552
|
wf.primary.model = msg.newPrimary.model;
|
|
520
553
|
wf.primary.effort = msg.newPrimary.effort;
|
|
@@ -530,6 +563,10 @@ export async function handleHandoffRequest(
|
|
|
530
563
|
meta.primaryModel = msg.newPrimary.model;
|
|
531
564
|
meta.primaryEffort = msg.newPrimary.effort;
|
|
532
565
|
meta.providerAccountRef = nextProviderAccountRef;
|
|
566
|
+
if (msg.newPrimary.provider === 'claude' && msg.newPrimary.providerAccountRef !== undefined) {
|
|
567
|
+
meta.claudeTransport = 'native';
|
|
568
|
+
meta.ultracode = false;
|
|
569
|
+
}
|
|
533
570
|
meta.lastActiveAt = Date.now();
|
|
534
571
|
if (!handoffOwned()) return;
|
|
535
572
|
await writeMeta(cwd, meta);
|
|
@@ -569,21 +606,14 @@ export async function handleHandoffRequest(
|
|
|
569
606
|
handoffBody = await appendHandoffNotice(cwd, msg.workflowId, handle.artifactName, handoffBody, handoffSourceKey);
|
|
570
607
|
if (!handoffOwned()) return;
|
|
571
608
|
if (wf.primary.provider === 'antigravity-cli') {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
archived: { sessionId: oldSessionId ?? '', turnCount },
|
|
576
|
-
draft: `Read the handoff document at ${handoffPath} and continue.`,
|
|
577
|
-
completedAt: Date.now(),
|
|
578
|
-
});
|
|
579
|
-
resetCompactions(msg.workflowId, wf);
|
|
580
|
-
wf.calibration = undefined;
|
|
581
|
-
wf.lastContextPercent = 0;
|
|
582
|
-
resetAutoCompactionCycle(wf);
|
|
583
|
-
releaseHandoffBusy();
|
|
584
|
-
return { artifactName: handle.artifactName };
|
|
609
|
+
// A failed opening turn must not resume an archived Gemini session after restart.
|
|
610
|
+
await clearProviderCliSessions(cwd, msg.workflowId, wf.primary.provider);
|
|
611
|
+
if (!handoffOwned()) return;
|
|
585
612
|
}
|
|
586
|
-
const
|
|
613
|
+
const geminiRole = wf.primary.provider === 'antigravity-cli' && clusterId
|
|
614
|
+
? await geminiClusterInstructions(clusterId, msg.workflowId) : '';
|
|
615
|
+
if (!handoffOwned()) return;
|
|
616
|
+
const seedPrompt = `[HANDOFF — new session initialized for this tab. Read the document below carefully. Then in 2-3 sentences: (1) state where the project stands right now, and (2) what you believe the most useful next step is. Await the operator's instruction before beginning any work.]\n\n${geminiRole ? geminiRole + '\n\n' : ''}${handoffBody}`;
|
|
587
617
|
send(ws, {
|
|
588
618
|
type: 'user_message_echo',
|
|
589
619
|
workflowId: msg.workflowId,
|
|
@@ -683,12 +713,13 @@ export async function handleHandoffRequest(
|
|
|
683
713
|
{
|
|
684
714
|
primary: wf.primary,
|
|
685
715
|
prompt: seedPrompt,
|
|
716
|
+
...(wf.primary.provider === 'antigravity-cli' ? { interactionMode: 'agent', antigravityInteractive: operatorRequested } as const : {}),
|
|
686
717
|
resumeSessionId: undefined,
|
|
687
718
|
disableRssGuard: wf.disableRssGuard,
|
|
688
719
|
appendSystemPrompt: prewarmAppend,
|
|
689
720
|
systemPrompt: prewarmSystemPrompt,
|
|
690
721
|
...(handoffAccount ? { providerAccountRef: handoffAccount.profile.id, codexHome: handoffAccount.codexHome } : {}),
|
|
691
|
-
...(wf.primary.provider === 'claude' ? { claudeTransport } : {}),
|
|
722
|
+
...(wf.primary.provider === 'claude' ? { claudeTransport, providerAccountRef: wf.config.providerAccountRef } : {}),
|
|
692
723
|
clusterId: prewarmClusterId,
|
|
693
724
|
clusterTaskBoardAttached: prewarmClusterTaskBoardAttached,
|
|
694
725
|
clusterPlan: prewarmClusterPlan,
|
|
@@ -726,13 +757,22 @@ export async function handleHandoffRequest(
|
|
|
726
757
|
});
|
|
727
758
|
});
|
|
728
759
|
|
|
760
|
+
let openingError: string | undefined;
|
|
729
761
|
try {
|
|
730
|
-
await primaryTurn.settled;
|
|
762
|
+
openingError = (await primaryTurn.settled).error;
|
|
731
763
|
} catch (err) {
|
|
764
|
+
openingError = err instanceof Error ? err.message : String(err);
|
|
732
765
|
console.error(`[arco] handoff ${handle.handoffId} pre-warm settle error:`, err);
|
|
733
766
|
}
|
|
734
767
|
|
|
735
768
|
if (!handoffOwned()) return;
|
|
769
|
+
if (openingError && wf.primary.provider === 'antigravity-cli') {
|
|
770
|
+
const error = `Handoff saved as ${handle.artifactName}. Gemini could not finish the opening turn: ${openingError}`;
|
|
771
|
+
send(ws, { type: 'handoff_artifact_ready', workflowId: msg.workflowId, handoffId: handle.handoffId,
|
|
772
|
+
artifactName: handle.artifactName, error, completedAt: Date.now() });
|
|
773
|
+
send(ws, { type: 'system_notice', workflowId: msg.workflowId, content: error });
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
736
776
|
send(ws, {
|
|
737
777
|
type: 'handoff_complete',
|
|
738
778
|
workflowId: msg.workflowId,
|
|
@@ -834,7 +874,7 @@ export async function handleSpawnFromHere(
|
|
|
834
874
|
send(ws, { type: 'error', message: `Unknown parent workflow ${msg.parentWorkflowId.slice(0, 8)}` });
|
|
835
875
|
return;
|
|
836
876
|
}
|
|
837
|
-
if (!allowedWorkflowEfforts(msg.newConfig.primaryProvider, msg.newConfig.primaryModel).includes(msg.newConfig.primaryEffort)) {
|
|
877
|
+
if (!allowedWorkflowEfforts(msg.newConfig.primaryProvider, msg.newConfig.primaryModel, msg.newConfig.providerAccountRef).includes(msg.newConfig.primaryEffort)) {
|
|
838
878
|
send(ws, { type: 'error', message: 'The selected effort is not supported by this provider and model.' });
|
|
839
879
|
return;
|
|
840
880
|
}
|
|
@@ -869,6 +909,16 @@ export async function handleSpawnFromHere(
|
|
|
869
909
|
|
|
870
910
|
const newCwd = msg.newConfig.workingDirectory || parentCwd;
|
|
871
911
|
const newPrimary = derivePrimaryConfig(msg.newConfig);
|
|
912
|
+
if (newPrimary.provider === 'claude' && msg.newConfig.providerAccountRef !== undefined) {
|
|
913
|
+
try {
|
|
914
|
+
await requireClaudeNativeAccount(msg.newConfig.providerAccountRef);
|
|
915
|
+
msg.newConfig.claudeTransport = 'native';
|
|
916
|
+
msg.newConfig.ultracode = false;
|
|
917
|
+
} catch {
|
|
918
|
+
send(ws, { type: 'error', message: 'Choose an available Claude Native account for the new tab.' });
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
872
922
|
const initialSpawnAccount = newPrimary.provider === 'codex'
|
|
873
923
|
? await resolveProviderAccount('codex', msg.newConfig.providerAccountRef, newCwd).catch(() => null)
|
|
874
924
|
: null;
|
|
@@ -1044,8 +1094,8 @@ export async function handleSpawnFromHere(
|
|
|
1044
1094
|
let parentClaudeTransport: 'cli' | 'native' = 'cli';
|
|
1045
1095
|
if (parent.primary.provider === 'claude') {
|
|
1046
1096
|
const tab = parent.config.claudeTransport;
|
|
1047
|
-
if (tab === 'native' || tab === 'cli') {
|
|
1048
|
-
parentClaudeTransport = tab
|
|
1097
|
+
if (parent.config.ultracode || tab === 'native' || tab === 'cli') {
|
|
1098
|
+
parentClaudeTransport = parent.config.ultracode ? 'cli' : tab!;
|
|
1049
1099
|
} else {
|
|
1050
1100
|
const cascade = await readSettings(parentCwd).catch(() => null);
|
|
1051
1101
|
parentClaudeTransport = cascade?.claude?.transport === 'native' ? 'native' : 'cli';
|
|
@@ -1065,7 +1115,7 @@ export async function handleSpawnFromHere(
|
|
|
1065
1115
|
cwd: parentCwd,
|
|
1066
1116
|
sourceWorkflowId: msg.parentWorkflowId,
|
|
1067
1117
|
...(parentCodexAccount ? { providerAccountRef: parentCodexAccount.profile.id, codexHome: parentCodexAccount.codexHome } : {}),
|
|
1068
|
-
...(parent.primary.provider === 'claude' ? { transport: parentClaudeTransport } : {}),
|
|
1118
|
+
...(parent.primary.provider === 'claude' ? { transport: parentClaudeTransport, providerAccountRef: parent.config.providerAccountRef } : {}),
|
|
1069
1119
|
// Native + Spawn: hydrate the child's worker from the parent's
|
|
1070
1120
|
// events.jsonl. Skipped for Handoff (target == parent → existing
|
|
1071
1121
|
// worker carries history) and for CLI (uses --resume instead).
|
|
@@ -1085,7 +1135,9 @@ export async function handleSpawnFromHere(
|
|
|
1085
1135
|
|
|
1086
1136
|
const parentResumable = parent.primary.provider === 'claude' || parent.primary.provider === 'codex';
|
|
1087
1137
|
let effectiveMode = msg.mode;
|
|
1088
|
-
let translatedSummarizer = summarizer
|
|
1138
|
+
let translatedSummarizer: import('../primitives/exportContext.js').SummarizerConfig = parentNativeOriginalEligible && summarizer.provider === 'claude'
|
|
1139
|
+
? { ...summarizer, claudeTransport: 'native', providerAccountRef: parent.config.providerAccountRef }
|
|
1140
|
+
: summarizer;
|
|
1089
1141
|
if (effectiveMode === 'original-worker' && !parentResumable) {
|
|
1090
1142
|
const tooBig = typeof parent.lastContextPercent === 'number'
|
|
1091
1143
|
&& parent.lastContextPercent >= LOCAL_SELF_SUMMARY_LIMIT_PERCENT;
|
|
@@ -1342,7 +1394,7 @@ export async function handleSpawnFromHere(
|
|
|
1342
1394
|
disableRssGuard: parent.disableRssGuard,
|
|
1343
1395
|
appendSystemPrompt: withPreviewNudge(undefined),
|
|
1344
1396
|
...(spawnAccount ? { providerAccountRef: spawnAccount.profile.id, codexHome: spawnAccount.codexHome } : {}),
|
|
1345
|
-
...(newPrimary.provider === 'claude' ? { claudeTransport: newClaudeTransport } : {}),
|
|
1397
|
+
...(newPrimary.provider === 'claude' ? { claudeTransport: newClaudeTransport, providerAccountRef: msg.newConfig.providerAccountRef } : {}),
|
|
1346
1398
|
},
|
|
1347
1399
|
);
|
|
1348
1400
|
|
|
@@ -1443,10 +1495,26 @@ export async function handleRehydrateWorkflows(
|
|
|
1443
1495
|
entries: Array<{ workflowId: string; config: WorkflowConfig; currentSessionId: string; lastSeq?: number; tail?: boolean }>,
|
|
1444
1496
|
): Promise<void> {
|
|
1445
1497
|
for (const entry of entries) {
|
|
1498
|
+
const existing = workflows.get(entry.workflowId);
|
|
1499
|
+
const configCwd = entry.config.workingDirectory;
|
|
1500
|
+
let accountRestored = false;
|
|
1501
|
+
if ((!existing || existing.bootMaterialized) && configCwd && !entry.config.incognito) {
|
|
1502
|
+
try {
|
|
1503
|
+
const saved = await readMeta(configCwd, entry.workflowId);
|
|
1504
|
+
if (saved?.primaryProvider === 'claude') {
|
|
1505
|
+
accountRestored = entry.config.providerAccountRef !== saved.providerAccountRef
|
|
1506
|
+
|| (!!saved.claudeTransport && entry.config.claudeTransport !== saved.claudeTransport);
|
|
1507
|
+
entry.config = { ...entry.config, providerAccountRef: saved.providerAccountRef,
|
|
1508
|
+
...(saved.claudeTransport ? { claudeTransport: saved.claudeTransport } : {}) };
|
|
1509
|
+
}
|
|
1510
|
+
} catch {
|
|
1511
|
+
send(ws, { type: 'error', workflowId: entry.workflowId, message: 'Saved workflow settings could not be read. Reopen the tab before sending.' });
|
|
1512
|
+
continue;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1446
1515
|
const originalEffort = entry.config.primaryEffort;
|
|
1447
|
-
entry.config.primaryEffort = normalizedWorkflowEffort(entry.config.primaryProvider, entry.config.primaryModel, originalEffort);
|
|
1516
|
+
entry.config.primaryEffort = normalizedWorkflowEffort(entry.config.primaryProvider, entry.config.primaryModel, originalEffort, entry.config.providerAccountRef);
|
|
1448
1517
|
const repairedEffort = entry.config.primaryEffort !== originalEffort;
|
|
1449
|
-
const existing = workflows.get(entry.workflowId);
|
|
1450
1518
|
if (!existing && entry.config.incognito) {
|
|
1451
1519
|
// Register before anything below can log the wfid.
|
|
1452
1520
|
registerPrivateLogToken(entry.workflowId);
|
|
@@ -1498,7 +1566,7 @@ export async function handleRehydrateWorkflows(
|
|
|
1498
1566
|
}
|
|
1499
1567
|
session.workflowIds.add(entry.workflowId);
|
|
1500
1568
|
const wf = workflows.get(entry.workflowId)!;
|
|
1501
|
-
if (repairedEffort) send(ws, { type: 'workflow_config_synced', workflowId: entry.workflowId, config: wf.config });
|
|
1569
|
+
if (repairedEffort || accountRestored || wf.config.providerAccountRef !== entry.config.providerAccountRef) send(ws, { type: 'workflow_config_synced', workflowId: entry.workflowId, config: wf.config });
|
|
1502
1570
|
if (!existing && wf.config.incognito && wf.config.voiceOperator) {
|
|
1503
1571
|
// A new server epoch has no private history, even if the reconnecting
|
|
1504
1572
|
// page still has old rows in memory. Do not imply that context survived.
|
|
@@ -1836,7 +1904,7 @@ export async function rehydrateOneWorkflow(
|
|
|
1836
1904
|
if (t !== 'task_started' && t !== 'task_status') continue;
|
|
1837
1905
|
if (((ev as { seq?: number }).seq ?? 0) >= firstTailSeq) break;
|
|
1838
1906
|
if (ws.readyState !== WebSocket.OPEN) break;
|
|
1839
|
-
ws.send(JSON.stringify(ev));
|
|
1907
|
+
ws.send(JSON.stringify({ ...(ev as object), replayed: true }));
|
|
1840
1908
|
}
|
|
1841
1909
|
}
|
|
1842
1910
|
} else if (cwd) {
|
|
@@ -1875,7 +1943,7 @@ export async function rehydrateOneWorkflow(
|
|
|
1875
1943
|
} else {
|
|
1876
1944
|
for (const ev of events) {
|
|
1877
1945
|
if (ws.readyState !== WebSocket.OPEN) break;
|
|
1878
|
-
ws.send(JSON.stringify(ev));
|
|
1946
|
+
ws.send(JSON.stringify({ ...(ev as object), replayed: true }));
|
|
1879
1947
|
}
|
|
1880
1948
|
}
|
|
1881
1949
|
}
|
|
@@ -1897,7 +1965,7 @@ export async function rehydrateOneWorkflow(
|
|
|
1897
1965
|
const t = (ev as { type?: string }).type;
|
|
1898
1966
|
if (t !== 'task_started' && t !== 'task_status') continue;
|
|
1899
1967
|
if (ws.readyState !== WebSocket.OPEN) break;
|
|
1900
|
-
ws.send(JSON.stringify(ev));
|
|
1968
|
+
ws.send(JSON.stringify({ ...(ev as object), replayed: true }));
|
|
1901
1969
|
}
|
|
1902
1970
|
}
|
|
1903
1971
|
}
|