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.
- package/CONTRIBUTING.md +1 -1
- package/THIRD_PARTY_NOTICES +2 -2
- package/client/dist/assets/{PhosphorBackdrop-CHXVFLGT.js → PhosphorBackdrop-CLILIwOQ.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-Bhs4I9jA.js → ThemedBackgroundShaderImpl-B87chcb5.js} +1 -1
- package/client/dist/assets/{XtermView-CdfurwFx.js → XtermView-BP_j7WSN.js} +1 -1
- package/client/dist/assets/{galleryEditor-DYjZZ4cf.js → galleryEditor-B90phoBI.js} +1 -1
- package/client/dist/assets/{index-BjDmFvqG.js → index-BfPp1Oup.js} +269 -269
- package/client/dist/index.html +1 -1
- 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 +5 -9
- 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/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 +7 -5
- package/client/src/help/content/rightPanel.tsx +8 -4
- 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 +20 -14
- 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 +1 -0
- 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 +4 -5
- 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/CLIENT.md +10 -5
- 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 +54 -23
- 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 +46 -9
- package/docs/RESEARCH.md +1 -1
- 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/geminiMembers.d.ts +7 -1
- package/server/dist/geminiMembers.js +28 -14
- 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 +40 -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/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/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 +33 -18
- 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/geminiMembers.ts +26 -15
- 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 +38 -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/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/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 +32 -17
- 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
|
@@ -71,20 +71,20 @@ import { probeOnce as probePreviewPort } from '../previewAutoDetect.js';
|
|
|
71
71
|
import { PreviewGateways } from '../previewProxy.js';
|
|
72
72
|
import { previewPortRange } from '../previewPortConfiguration.js';
|
|
73
73
|
import { HOST } from '../server/constants.js';
|
|
74
|
-
import { clearTokens as clearClaudeNativeTokens } from '../providers/claude-native/auth.js';
|
|
75
74
|
import { getClaudeNativeAuthStatus } from '../providers/claude-native/authStatus.js';
|
|
76
|
-
import { getCatalog as getClaudeNativeCatalog } from '../providers/claude-native/catalog.js';
|
|
75
|
+
import { getCatalog as getClaudeNativeCatalog, forgetCatalog as forgetClaudeNativeCatalog } from '../providers/claude-native/catalog.js';
|
|
77
76
|
import { CLAUDE_CLI_USER_AGENT } from '../providers/claude-native/wireFingerprint.js';
|
|
78
77
|
import {
|
|
79
78
|
completeBootstrap as claudeNativeCompleteBootstrap,
|
|
80
79
|
startBootstrap as claudeNativeStartBootstrap,
|
|
81
80
|
getBootstrapFlow as claudeNativeGetFlow,
|
|
82
81
|
cancelBootstrap as claudeNativeCancelFlow,
|
|
83
|
-
|
|
82
|
+
logout as claudeNativeLogout,
|
|
84
83
|
ensureLiveTokens as ensureClaudeNativeTokens,
|
|
85
84
|
} from '../providers/claude-native/oauth.js';
|
|
86
85
|
import { getCodexCatalog } from '../providers/codex-appserver/catalog.js';
|
|
87
|
-
import {
|
|
86
|
+
import { saveClaudeNativeProfile } from '../settings.js';
|
|
87
|
+
import { requireClaudeNativeAccount, resolveProviderAccount, ensureCodexAccountHome } from '../providerAccounts.js';
|
|
88
88
|
import { getCursorCatalog } from '../providers/cursor/catalog.js';
|
|
89
89
|
import { probeLlamacppLive } from '../providers/llamacpp.js';
|
|
90
90
|
import { llamacppManager } from '../providers/llamacppManager.js';
|
|
@@ -133,9 +133,9 @@ import { listAllListeningProcesses } from '../workers/procListeningAll.js';
|
|
|
133
133
|
import {
|
|
134
134
|
flushAll as flushAllWorkflowEvents
|
|
135
135
|
} from '../workflowStore.js';
|
|
136
|
-
import {
|
|
136
|
+
import { tryHandleFileContent } from './fileContentRoute.js';
|
|
137
137
|
import { explorerRoot } from './explorerRoot.js';
|
|
138
|
-
import {
|
|
138
|
+
import { listBrowserDirectory } from './readConfinement.js';
|
|
139
139
|
import { confinedPath, safeDirectory, createReadAccessContext } from '../fileAccessPolicy.js';
|
|
140
140
|
import { tryHandleClusterRoutes } from './clusterRoutes.js';
|
|
141
141
|
import { tryHandleClusterSnapshotRoutes } from './clusterSnapshotRoutes.js';
|
|
@@ -1601,9 +1601,25 @@ export async function handleHttpRequest(
|
|
|
1601
1601
|
// logout. The OAuth bootstrap server-side spawns its own local callback
|
|
1602
1602
|
// listener on port 53692 when possible; on EADDRINUSE we surface a
|
|
1603
1603
|
// manual-paste flag and accept the redirect URL via /callback.
|
|
1604
|
-
if (req.url === '/api/auth/claude-native' && req.method === '
|
|
1604
|
+
if (req.url === '/api/auth/claude-native/profiles' && req.method === 'POST') {
|
|
1605
1605
|
try {
|
|
1606
|
-
|
|
1606
|
+
let raw = '';
|
|
1607
|
+
for await (const chunk of req) raw += chunk;
|
|
1608
|
+
const body = JSON.parse(raw || '{}') as { label?: unknown; id?: unknown };
|
|
1609
|
+
if (typeof body.label !== 'string' || (body.id !== undefined && typeof body.id !== 'string')) throw new Error('Invalid Claude Native profile.');
|
|
1610
|
+
const settings = await saveClaudeNativeProfile(body.label, body.id);
|
|
1611
|
+
res.writeHead(200, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' });
|
|
1612
|
+
res.end(JSON.stringify(settings));
|
|
1613
|
+
} catch (err) {
|
|
1614
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1615
|
+
res.end(JSON.stringify({ error: err instanceof Error ? err.message : 'Could not save Claude Native account.' }));
|
|
1616
|
+
}
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
if (req.url?.split('?')[0] === '/api/auth/claude-native' && req.method === 'GET') {
|
|
1620
|
+
try {
|
|
1621
|
+
const ref = new URL(req.url, 'http://localhost').searchParams.get('account');
|
|
1622
|
+
const status = await getClaudeNativeAuthStatus(await requireClaudeNativeAccount(ref ?? undefined));
|
|
1607
1623
|
const body = { ...status, loggedIn: status.credentialsPresent };
|
|
1608
1624
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1609
1625
|
res.end(JSON.stringify(body));
|
|
@@ -1625,9 +1641,10 @@ export async function handleHttpRequest(
|
|
|
1625
1641
|
try {
|
|
1626
1642
|
let raw = '';
|
|
1627
1643
|
for await (const chunk of req) raw += chunk;
|
|
1628
|
-
const body = JSON.parse(raw || '{}') as { binding?: import('@arco/shared').ClaudeCredentialBinding; workflowId?: string };
|
|
1644
|
+
const body = JSON.parse(raw || '{}') as { binding?: import('@arco/shared').ClaudeCredentialBinding; workflowId?: string; accountRef?: string };
|
|
1629
1645
|
if (body.workflowId !== undefined && (typeof body.workflowId !== 'string' || body.workflowId.length > 128)) throw new Error('Invalid originating workflow id.');
|
|
1630
|
-
|
|
1646
|
+
if (body.accountRef !== undefined && typeof body.accountRef !== 'string') throw new Error('Invalid Claude Native account.');
|
|
1647
|
+
const result = await claudeNativeStartBootstrap(body.binding, body.workflowId, body.accountRef);
|
|
1631
1648
|
|
|
1632
1649
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1633
1650
|
res.end(JSON.stringify(result));
|
|
@@ -1658,10 +1675,12 @@ export async function handleHttpRequest(
|
|
|
1658
1675
|
}
|
|
1659
1676
|
return;
|
|
1660
1677
|
}
|
|
1661
|
-
if (req.url === '/api/auth/claude-native/logout' && req.method === 'POST') {
|
|
1678
|
+
if (req.url?.split('?')[0] === '/api/auth/claude-native/logout' && req.method === 'POST') {
|
|
1662
1679
|
try {
|
|
1663
|
-
|
|
1664
|
-
await
|
|
1680
|
+
const ref = new URL(req.url, 'http://localhost').searchParams.get('account');
|
|
1681
|
+
const account = await requireClaudeNativeAccount(ref ?? undefined);
|
|
1682
|
+
await claudeNativeLogout(account);
|
|
1683
|
+
forgetClaudeNativeCatalog(account);
|
|
1665
1684
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1666
1685
|
res.end(JSON.stringify({ ok: true }));
|
|
1667
1686
|
} catch (err) {
|
|
@@ -1681,7 +1700,7 @@ export async function handleHttpRequest(
|
|
|
1681
1700
|
try {
|
|
1682
1701
|
const url = new URL(req.url, `http://localhost:${PORT}`);
|
|
1683
1702
|
const force = url.searchParams.get('force') === '1';
|
|
1684
|
-
const snapshot = await getClaudeNativeCatalog(force);
|
|
1703
|
+
const snapshot = await getClaudeNativeCatalog(force, url.searchParams.get('account') ?? undefined);
|
|
1685
1704
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1686
1705
|
res.end(JSON.stringify(snapshot));
|
|
1687
1706
|
} catch (err) {
|
|
@@ -1749,13 +1768,14 @@ export async function handleHttpRequest(
|
|
|
1749
1768
|
beta?: string[];
|
|
1750
1769
|
maxTokens?: number;
|
|
1751
1770
|
prompt?: string;
|
|
1771
|
+
accountRef?: string;
|
|
1752
1772
|
};
|
|
1753
1773
|
if (typeof parsed.model !== 'string' || !parsed.model) {
|
|
1754
1774
|
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1755
1775
|
res.end(JSON.stringify({ error: 'expected { model: string, beta?: string[], maxTokens?: number, prompt?: string }' }));
|
|
1756
1776
|
return;
|
|
1757
1777
|
}
|
|
1758
|
-
const tokens = await ensureClaudeNativeTokens();
|
|
1778
|
+
const tokens = await ensureClaudeNativeTokens(parsed.accountRef);
|
|
1759
1779
|
// Match the worker's wire fingerprint exactly so a probe-passing
|
|
1760
1780
|
// model translates 1:1 to a real-turn-passing model. Caller-supplied
|
|
1761
1781
|
// beta entries append (don't replace) the standard ones.
|
|
@@ -2101,8 +2121,8 @@ export async function handleHttpRequest(
|
|
|
2101
2121
|
}
|
|
2102
2122
|
|
|
2103
2123
|
if (req.url?.startsWith('/api/usage') && req.method === 'GET') {
|
|
2104
|
-
const
|
|
2105
|
-
const usage = await getUsage(force);
|
|
2124
|
+
const params = new URL(req.url, `http://localhost:${PORT}`).searchParams;
|
|
2125
|
+
const usage = await getUsage(params.get('force') === '1', params.get('account') ?? undefined);
|
|
2106
2126
|
res.writeHead(200, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' });
|
|
2107
2127
|
res.end(JSON.stringify(usage));
|
|
2108
2128
|
return;
|
|
@@ -2135,51 +2155,7 @@ export async function handleHttpRequest(
|
|
|
2135
2155
|
|
|
2136
2156
|
|
|
2137
2157
|
|
|
2138
|
-
if (
|
|
2139
|
-
const url = new URL(req.url, `http://localhost:${PORT}`);
|
|
2140
|
-
const asked = url.searchParams.get('path') || '';
|
|
2141
|
-
const cwd = url.searchParams.get('cwd') || '';
|
|
2142
|
-
const workflowId = url.searchParams.get('workflowId') || '';
|
|
2143
|
-
const owner = url.searchParams.get('artifactOwner') || '';
|
|
2144
|
-
try {
|
|
2145
|
-
let target: string;
|
|
2146
|
-
let artifactOwner: string | undefined;
|
|
2147
|
-
try {
|
|
2148
|
-
target = await resolveBrowserRead(asked, cwd, workflowId);
|
|
2149
|
-
if (owner) throw Object.assign(new Error('Artifact choice is no longer available.'), { code: 'EACCES' });
|
|
2150
|
-
} catch (err) {
|
|
2151
|
-
if ((err as NodeJS.ErrnoException).code !== 'ENOENT' || !workflowId || !cwd) throw err;
|
|
2152
|
-
const found = await clusterArtifactMatches(cwd, workflowId, asked);
|
|
2153
|
-
if (!found) throw err;
|
|
2154
|
-
const choices = found.matches.map(({ workflowId: id, name }) => ({ workflowId: id, name }));
|
|
2155
|
-
if (!owner && choices.length > 1) {
|
|
2156
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
2157
|
-
res.end(JSON.stringify({ type: 'choices', choices }));
|
|
2158
|
-
return;
|
|
2159
|
-
}
|
|
2160
|
-
const chosen = owner ? found.matches.find((match) => match.workflowId === owner) : found.matches[0];
|
|
2161
|
-
if (!chosen) {
|
|
2162
|
-
if (owner) throw Object.assign(new Error('Artifact choice is no longer available.'), { code: 'EACCES' });
|
|
2163
|
-
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
2164
|
-
res.end(JSON.stringify({ type: 'error', error: `File not found: ${asked}. Searched the project and artifacts of: ${found.searched.map((m) => m.name).join(', ')}.` }));
|
|
2165
|
-
return;
|
|
2166
|
-
}
|
|
2167
|
-
target = chosen.path;
|
|
2168
|
-
artifactOwner = chosen.name;
|
|
2169
|
-
}
|
|
2170
|
-
const payload = await readFileForExplorer(target);
|
|
2171
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
2172
|
-
res.end(JSON.stringify({ ...payload, resolvedPath: target, ...(artifactOwner ? { artifactOwner } : {}) }));
|
|
2173
|
-
} catch (err) {
|
|
2174
|
-
const code = (err as NodeJS.ErrnoException).code;
|
|
2175
|
-
// A missing file is reported by the name that was asked for, never by a
|
|
2176
|
-
// path the server or client composed.
|
|
2177
|
-
const message = code === 'ENOENT' ? `File not found: ${asked}` : (err instanceof Error ? err.message : String(err));
|
|
2178
|
-
res.writeHead(code === 'EACCES' ? 403 : 404, { 'Content-Type': 'application/json' });
|
|
2179
|
-
res.end(JSON.stringify({ type: 'error', error: message }));
|
|
2180
|
-
}
|
|
2181
|
-
return;
|
|
2182
|
-
}
|
|
2158
|
+
if (await tryHandleFileContent(req, res)) return;
|
|
2183
2159
|
|
|
2184
2160
|
if (req.url?.startsWith('/api/files') && req.method === 'GET') {
|
|
2185
2161
|
try {
|
package/server/src/index.ts
CHANGED
|
@@ -36,7 +36,7 @@ ClientMessage,
|
|
|
36
36
|
ServerMessage,
|
|
37
37
|
WorkflowConfig
|
|
38
38
|
} from '@arco/shared';
|
|
39
|
-
import { GEMINI_OPERATOR_ONLY_REFUSAL, geminiNudgeText, isGeminiMember, issueGeminiSend } from './geminiMembers.js';
|
|
39
|
+
import { GEMINI_OPERATOR_ONLY_REFUSAL, geminiNudgeText, isGeminiMember, issueGeminiSend, prepareGeminiPickup } from './geminiMembers.js';
|
|
40
40
|
import { hasGuardrails, isClusterMemberProvider, resolveOutputStyle } from '@arco/shared';
|
|
41
41
|
import { getEffectivePublicProjectChoice } from './publicProjectChoice.js';
|
|
42
42
|
import { spawnSync } from 'child_process';
|
|
@@ -997,7 +997,7 @@ wss.on('connection', (ws: WebSocket) => {
|
|
|
997
997
|
});
|
|
998
998
|
break;
|
|
999
999
|
case 'handoff_request':
|
|
1000
|
-
handleHandoffRequest(ws, session, msg).catch((err) => {
|
|
1000
|
+
handleHandoffRequest(ws, session, msg, true).catch((err) => {
|
|
1001
1001
|
console.error('[arco] handoff_request handler failed:', err);
|
|
1002
1002
|
});
|
|
1003
1003
|
break;
|
|
@@ -2339,7 +2339,7 @@ setClaudeNativeTaskHandler(async ({ parentWorkflowId, description, prompt, subag
|
|
|
2339
2339
|
const policy = resolveNativeSubagents(defaults?.nativeSubagents, capturedPolicy ?? parent.config.nativeSubagents);
|
|
2340
2340
|
const effectiveModel = policy.model || model || parent.config.primaryModel;
|
|
2341
2341
|
if (policy.model) {
|
|
2342
|
-
const catalog = await getNativeTaskCatalog();
|
|
2342
|
+
const catalog = await getNativeTaskCatalog(false, parent.config.providerAccountRef);
|
|
2343
2343
|
assertActive();
|
|
2344
2344
|
const ids = catalog.models.length ? catalog.models.map((m) => m.id) : [...CLAUDE_MODELS];
|
|
2345
2345
|
if (!ids.includes(policy.model)) throw new Error(`Task not started: selected sub-agent model ${policy.model} is unavailable. Select a model in Settings or tab configuration.`);
|
|
@@ -2462,6 +2462,7 @@ setClaudeNativeTaskHandler(async ({ parentWorkflowId, description, prompt, subag
|
|
|
2462
2462
|
resumeSessionId: undefined,
|
|
2463
2463
|
// Task children use the Native transport, including inherited settings.
|
|
2464
2464
|
claudeTransport: 'native',
|
|
2465
|
+
providerAccountRef: parent.config.providerAccountRef,
|
|
2465
2466
|
claudeNativeCompact: parent.config.claudeNativeCompact === true,
|
|
2466
2467
|
claudeNativeForceInterleavedThinkingBeta: parent.config.claudeNativeForceInterleavedThinkingBeta === true,
|
|
2467
2468
|
claudeNativeThinkingDisplay: parent.config.claudeNativeThinkingDisplay,
|
|
@@ -2616,19 +2617,21 @@ function onListening() {
|
|
|
2616
2617
|
clusterIds: new Set(),
|
|
2617
2618
|
clusterObserved: new Map(),
|
|
2618
2619
|
};
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2620
|
+
const dispatch = async () => {
|
|
2621
|
+
const gemini = isGeminiMember(wfid);
|
|
2622
|
+
const pickup = gemini ? await prepareGeminiPickup(wfid, content, 'rule') : undefined;
|
|
2623
|
+
if (gemini && !pickup) return;
|
|
2624
|
+
return handleUserMessage(
|
|
2625
|
+
fakeWs, fakeSession, wfid, pickup?.content ?? content,
|
|
2626
|
+
undefined, undefined, false, undefined, undefined, undefined,
|
|
2627
|
+
{
|
|
2628
|
+
automaticKind: 'auto-pickup',
|
|
2629
|
+
geminiSend: pickup?.ticket,
|
|
2630
|
+
...(pickup && { claimGuard: async (claim) => pickup.isCurrent() && claim() }),
|
|
2631
|
+
},
|
|
2632
|
+
);
|
|
2633
|
+
};
|
|
2634
|
+
void dispatch().catch((err) => {
|
|
2632
2635
|
console.error(`[arco] auto-turn handleUserMessage failed for ${wfid.slice(0, 8)}:`, err);
|
|
2633
2636
|
});
|
|
2634
2637
|
},
|
|
@@ -2692,11 +2695,12 @@ function onListening() {
|
|
|
2692
2695
|
void pending.then(()=>{resolve(false);settled();},()=>{resolve(false);settled('Computer activity turn failed or was interrupted.');});
|
|
2693
2696
|
}));
|
|
2694
2697
|
|
|
2695
|
-
const conditionalTurn = (wfid: string, content: string, guard: (claim: () => boolean) => Promise<boolean>, automaticKind?: 'auto-pickup') => new Promise<boolean>((resolve) => {
|
|
2698
|
+
const conditionalTurn = (wfid: string, content: string, guard: (claim: () => boolean) => Promise<boolean>, automaticKind?: 'auto-pickup', geminiSend?: string) => new Promise<boolean>((resolve) => {
|
|
2696
2699
|
const fakeWs = { readyState: WebSocket.CLOSED, send: () => undefined } as unknown as WebSocket;
|
|
2697
2700
|
const fakeSession: Session = { id: 'computer-mail-rule', workflowIds: new Set([wfid]), clusterIds: new Set(), clusterObserved: new Map() };
|
|
2698
2701
|
void handleUserMessage(fakeWs, fakeSession, wfid, content, undefined, undefined, false, undefined, undefined, undefined, {
|
|
2699
2702
|
automaticKind,
|
|
2703
|
+
geminiSend,
|
|
2700
2704
|
claimGuard: async (claim) => {
|
|
2701
2705
|
const accepted = await guard(claim); resolve(accepted); return accepted;
|
|
2702
2706
|
},
|
|
@@ -2713,7 +2717,12 @@ function onListening() {
|
|
|
2713
2717
|
// Smart: Automatic wakes use the same conditional admission; an ask
|
|
2714
2718
|
// proposal raises one operator notice.
|
|
2715
2719
|
configureSmartPickupObserver({
|
|
2716
|
-
dispatchGuarded: (wfid, content, guard) =>
|
|
2720
|
+
dispatchGuarded: async (wfid, content, guard) => {
|
|
2721
|
+
if (!isGeminiMember(wfid)) return conditionalTurn(wfid, content, guard, 'auto-pickup');
|
|
2722
|
+
const pickup = await prepareGeminiPickup(wfid, content, 'smart-auto');
|
|
2723
|
+
if (!pickup) return false;
|
|
2724
|
+
return conditionalTurn(wfid, pickup.content, (claim) => guard(() => pickup.isCurrent() && claim()), 'auto-pickup', pickup.ticket);
|
|
2725
|
+
},
|
|
2717
2726
|
notifyAsk: (d) => emitNotice({
|
|
2718
2727
|
category: 'cluster-nudge',
|
|
2719
2728
|
severity: 'warning',
|
|
@@ -415,7 +415,7 @@ export async function applyAction(
|
|
|
415
415
|
type: 'handoff_request',
|
|
416
416
|
workflowId: action.workflowId,
|
|
417
417
|
mode: 'quick',
|
|
418
|
-
}).catch((err) =>
|
|
418
|
+
}, true).catch((err) =>
|
|
419
419
|
console.error(`[hub-link] handoff failed for ${action.workflowId.slice(0, 8)}:`, err),
|
|
420
420
|
);
|
|
421
421
|
return { ...base, ok: true, applied: 'handoff' };
|
package/server/src/outputs.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { workflows } from './server/state.js';
|
|
|
14
14
|
import { matchFileEvent } from './recentFilesLedger.js';
|
|
15
15
|
import { outputDirectory, readOutputIndex, writeOutputIndex, mappedOutputPath, type StoredOutput, type OutputIndex } from './outputStore.js';
|
|
16
16
|
import { readLogLines, sealedThroughSeq } from './eventLog.js';
|
|
17
|
+
import { listGeminiArtifacts } from './providers/antigravity/artifacts.js';
|
|
17
18
|
import { addOutputGrant, hasOutputGrant, removeOutputGrant } from './outputGrants.js';
|
|
18
19
|
|
|
19
20
|
export interface OutputContext { cwd: string; workflowId: string; producer: string; }
|
|
@@ -27,6 +28,7 @@ export function outputCategory(file: string): OutputCategory {
|
|
|
27
28
|
const ext = path.extname(file).slice(1).toLowerCase();
|
|
28
29
|
return (Object.keys(EXTENSIONS) as OutputCategory[]).find(kind => EXTENSIONS[kind].includes(ext)) ?? 'other';
|
|
29
30
|
}
|
|
31
|
+
const GEMINI_ARTIFACT_SOURCE = 'Gemini artifact';
|
|
30
32
|
const CODE_EXTENSIONS = new Set(['ts', 'tsx', 'js', 'jsx', 'mjs', 'py', 'rs', 'go', 'java', 'css', 'sh', 'sql', 'diff', 'patch']);
|
|
31
33
|
const EXPORT_SOURCES = new Set(['editor export', 'media export', 'saved copy']);
|
|
32
34
|
|
|
@@ -264,6 +266,12 @@ export async function listOutputs(ctx: OutputContext): Promise<WorkflowOutput[]>
|
|
|
264
266
|
}
|
|
265
267
|
}
|
|
266
268
|
if (JSON.stringify(index) !== before) await writeOutputIndex(ctx.cwd, ctx.workflowId, index);
|
|
269
|
+
for (const row of await listGeminiArtifacts(ctx.cwd, ctx.workflowId)) {
|
|
270
|
+
const category = outputCategory(row.name);
|
|
271
|
+
out.push({ ...ctx, id: row.id, name: row.name, title: row.name, path: row.path, category,
|
|
272
|
+
source: GEMINI_ARTIFACT_SOURCE, size: row.size, createdAt: row.mtime, updatedAt: row.mtime,
|
|
273
|
+
primary: !CODE_EXTENSIONS.has(path.extname(row.name).toLowerCase()) && category !== 'other', missing: false });
|
|
274
|
+
}
|
|
267
275
|
return out.sort((a, b) => b.updatedAt - a.updatedAt);
|
|
268
276
|
});
|
|
269
277
|
}
|
|
@@ -33,7 +33,7 @@ import { WorkerManager } from '../workers/WorkerManager.js';
|
|
|
33
33
|
import { runPrimaryTurn, type PrimaryConfig } from './seedWorker.js';
|
|
34
34
|
import { loadEffectivePrompt, renderPrompt } from '../handoffPrompts.js';
|
|
35
35
|
import { probeProjectFacts } from '../providers/claude-native/workspaceFacts.js';
|
|
36
|
-
import { seedClaudeNativeWorkerFromForeignEvents } from '../providers/claude-native/index.js';
|
|
36
|
+
import { disposeClaudeNativeWorker, seedClaudeNativeWorkerFromForeignEvents } from '../providers/claude-native/index.js';
|
|
37
37
|
import { releaseCodexAppServerWorker } from '../providers/codex-appserver/index.js';
|
|
38
38
|
import { buildQuickHandoff } from './quickHandoff.js';
|
|
39
39
|
import { isShellToolName } from '@arco/shared';
|
|
@@ -52,6 +52,7 @@ export interface SummarizerConfig {
|
|
|
52
52
|
effort: EffortLevel;
|
|
53
53
|
providerAccountRef?: string;
|
|
54
54
|
codexHome?: string;
|
|
55
|
+
claudeTransport?: 'native';
|
|
55
56
|
// docs/GOTCHAS.md - the source tab's north-star, inherited so the
|
|
56
57
|
// fresh summarizer preserves the session's standing objective in the handoff
|
|
57
58
|
// artifact (the continuation reads it). Absent / blank ⇒ no block.
|
|
@@ -59,6 +60,7 @@ export interface SummarizerConfig {
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
export interface ExportContext {
|
|
63
|
+
allowGeminiHandoffWriter?: boolean;
|
|
62
64
|
// workflowId = where events stamp + artifact lives. For Handoff this is
|
|
63
65
|
// the workflow being rotated; for Spawn this is the newly-created workflow.
|
|
64
66
|
workflowId: string;
|
|
@@ -367,6 +369,7 @@ async function runOriginalWorkerNative(
|
|
|
367
369
|
cwd: ctx.cwd,
|
|
368
370
|
workflowId: ctx.workflowId,
|
|
369
371
|
claudeTransport: 'native',
|
|
372
|
+
providerAccountRef: original.providerAccountRef,
|
|
370
373
|
};
|
|
371
374
|
await seedClaudeNativeWorkerFromForeignEvents(ctx.workflowId, baseConfig, original.nativeReplaySource, original.nativeReplaySource.maxSeq);
|
|
372
375
|
}
|
|
@@ -400,6 +403,7 @@ async function runOriginalWorkerNative(
|
|
|
400
403
|
// messages[] (seeded above for Spawn; in-memory for Handoff).
|
|
401
404
|
resumeSessionId: undefined,
|
|
402
405
|
claudeTransport: 'native',
|
|
406
|
+
providerAccountRef: original.providerAccountRef,
|
|
403
407
|
interactionMode: 'chat',
|
|
404
408
|
disableProviderHooks: true,
|
|
405
409
|
// docs/PROVIDERS.md - handoff seed output feeds the next
|
|
@@ -538,6 +542,13 @@ function runFreshSummarizer(
|
|
|
538
542
|
{
|
|
539
543
|
cwd: ctx.cwd,
|
|
540
544
|
workflowId: ctx.workflowId,
|
|
545
|
+
...(args.summarizer.provider === 'claude' && args.summarizer.claudeTransport === 'native' ? {
|
|
546
|
+
providerAccountRef: args.summarizer.providerAccountRef,
|
|
547
|
+
claudeTransport: 'native',
|
|
548
|
+
sessionScopeId: handoffId,
|
|
549
|
+
interactionMode: 'chat',
|
|
550
|
+
disableProviderHooks: true,
|
|
551
|
+
} as const : {}),
|
|
541
552
|
skipPermissions: false,
|
|
542
553
|
// The summarizer only reads a transcript and returns prose — the artifact
|
|
543
554
|
// is written by the handoff machinery, not the worker. Marking it
|
|
@@ -549,6 +560,7 @@ function runFreshSummarizer(
|
|
|
549
560
|
// workflowId — would otherwise run the summary INSIDE the operator's live
|
|
550
561
|
// Cursor session. See providers/index.ts (Phase 5 routing).
|
|
551
562
|
sandbox: 'read-only',
|
|
563
|
+
antigravityHandoffWriter: args.summarizer.provider === 'antigravity-cli' && ctx.allowGeminiHandoffWriter === true,
|
|
552
564
|
// docs/PROVIDERS.md - fresh-summarizer output becomes the
|
|
553
565
|
// *input* to the next worker; forced normal regardless of source
|
|
554
566
|
// tab's outputStyle.
|
|
@@ -560,7 +572,7 @@ function runFreshSummarizer(
|
|
|
560
572
|
? { providerAccountRef: args.summarizer.providerAccountRef, codexHome: args.summarizer.codexHome }
|
|
561
573
|
: {}),
|
|
562
574
|
},
|
|
563
|
-
);
|
|
575
|
+
).finally(() => { if (args.summarizer.claudeTransport === 'native') disposeClaudeNativeWorker(handoffId); });
|
|
564
576
|
}).then(async (r) => {
|
|
565
577
|
if (ab.killed) return { error: 'cancelled' };
|
|
566
578
|
const completedAt = Date.now();
|
|
@@ -16,8 +16,9 @@
|
|
|
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
18
|
|
|
19
|
-
import {
|
|
20
|
-
import type { WorkerResult } from '../workers/WorkerManager.js';
|
|
19
|
+
import { randomUUID } from 'node:crypto';
|
|
20
|
+
import type { WorkerManager, WorkerManagerEvent, WorkerResult } from '../workers/WorkerManager.js';
|
|
21
|
+
import { disposeClaudeNativeWorker } from '../providers/claude-native/index.js';
|
|
21
22
|
import type {
|
|
22
23
|
ServerMessage,
|
|
23
24
|
CompareLegConfig,
|
|
@@ -84,6 +85,52 @@ export function buildReplyDraftTask(question: string, context: string, fileAcces
|
|
|
84
85
|
return lines.join('\n');
|
|
85
86
|
}
|
|
86
87
|
|
|
88
|
+
// A resolved Claude account is a Native leg. Use the existing tool-free
|
|
89
|
+
// Chat surface and a fresh session, including when the leg synthesizes.
|
|
90
|
+
export async function spawnCompareLeg(
|
|
91
|
+
ctx: Pick<CompareContext, 'workflowId' | 'cwd' | 'manager'>,
|
|
92
|
+
leg: CompareLegConfig,
|
|
93
|
+
request: { id: string; task: string; fileAccess?: boolean; codexHome?: string },
|
|
94
|
+
onEvent: (event: WorkerManagerEvent) => void,
|
|
95
|
+
): Promise<WorkerResult> {
|
|
96
|
+
const sessionScopeId = leg.provider === 'claude' && leg.providerAccountRef ? randomUUID() : undefined;
|
|
97
|
+
try {
|
|
98
|
+
return await ctx.manager.spawn(
|
|
99
|
+
{
|
|
100
|
+
id: request.id,
|
|
101
|
+
task: request.task,
|
|
102
|
+
model: leg.model,
|
|
103
|
+
effort: leg.effort,
|
|
104
|
+
provider: leg.provider,
|
|
105
|
+
tools: request.fileAccess ? readOnlyFileTools(leg.provider) : NO_TOOLS,
|
|
106
|
+
},
|
|
107
|
+
onEvent,
|
|
108
|
+
{
|
|
109
|
+
cwd: ctx.cwd,
|
|
110
|
+
workflowId: ctx.workflowId,
|
|
111
|
+
// Read-only, no-tools. Claude gates via the empty `tools` allowlist;
|
|
112
|
+
// Codex gates via `-s read-only`; Ollama gates via the empty allowlist
|
|
113
|
+
// (its SAFE mode also refuses tools). skipPermissions=true for Ollama so
|
|
114
|
+
// SAFE mode doesn't emit denial strings for a prompt that needs none.
|
|
115
|
+
skipPermissions: leg.provider === 'ollama',
|
|
116
|
+
sandbox: 'read-only',
|
|
117
|
+
// docs/PROVIDERS.md - compared answers are read carefully by the
|
|
118
|
+
// operator; never plain/terse. Forced regardless of source-tab style.
|
|
119
|
+
outputStyle: 'normal',
|
|
120
|
+
...(leg.provider === 'codex' && request.codexHome
|
|
121
|
+
? { providerAccountRef: leg.providerAccountRef, codexHome: request.codexHome }
|
|
122
|
+
: {}),
|
|
123
|
+
...(sessionScopeId ? {
|
|
124
|
+
sessionScopeId, claudeTransport: 'native', providerAccountRef: leg.providerAccountRef,
|
|
125
|
+
interactionMode: 'chat', chatWebAccess: false, incognito: true,
|
|
126
|
+
} : {}),
|
|
127
|
+
},
|
|
128
|
+
);
|
|
129
|
+
} finally {
|
|
130
|
+
if (sessionScopeId) disposeClaudeNativeWorker(sessionScopeId);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
87
134
|
// Per-compare synthesizer framing builder lives in the WS handler (it needs the
|
|
88
135
|
// collected answers); runCompare itself just spawns whatever task it's handed.
|
|
89
136
|
|
|
@@ -130,50 +177,30 @@ export function runCompare(
|
|
|
130
177
|
let collected = '';
|
|
131
178
|
const legStartedAt = Date.now();
|
|
132
179
|
|
|
133
|
-
const spawnP
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
cwd: ctx.cwd,
|
|
162
|
-
workflowId: ctx.workflowId,
|
|
163
|
-
// Read-only, no-tools. Claude gates via the empty `tools` allowlist;
|
|
164
|
-
// Codex gates via `-s read-only`; Ollama gates via the empty allowlist
|
|
165
|
-
// (its SAFE mode also refuses tools). skipPermissions=true for Ollama so
|
|
166
|
-
// SAFE mode doesn't emit denial strings for a prompt that needs none.
|
|
167
|
-
skipPermissions: leg.provider === 'ollama',
|
|
168
|
-
sandbox: 'read-only',
|
|
169
|
-
// docs/PROVIDERS.md - compared answers are read carefully by the
|
|
170
|
-
// operator; never plain/terse. Forced regardless of source-tab style.
|
|
171
|
-
outputStyle: 'normal',
|
|
172
|
-
...(leg.provider === 'codex' && args.codexHomes?.[legIndex]
|
|
173
|
-
? { providerAccountRef: leg.providerAccountRef, codexHome: args.codexHomes[legIndex] }
|
|
174
|
-
: {}),
|
|
175
|
-
},
|
|
176
|
-
);
|
|
180
|
+
const spawnP = spawnCompareLeg(ctx, leg, {
|
|
181
|
+
id: legId,
|
|
182
|
+
task: args.task ?? args.prompt,
|
|
183
|
+
fileAccess: args.fileAccess,
|
|
184
|
+
codexHome: args.codexHomes?.[legIndex],
|
|
185
|
+
}, (ev) => {
|
|
186
|
+
if (ev.type === 'worker_text') {
|
|
187
|
+
collected += ev.text;
|
|
188
|
+
ctx.broadcast({
|
|
189
|
+
type: 'compare_leg_delta',
|
|
190
|
+
workflowId: ctx.workflowId,
|
|
191
|
+
compareId,
|
|
192
|
+
legIndex,
|
|
193
|
+
text: ev.text,
|
|
194
|
+
});
|
|
195
|
+
} else if (ev.type === 'worker_system_notice') {
|
|
196
|
+
ctx.broadcast({
|
|
197
|
+
type: 'system_notice',
|
|
198
|
+
workflowId: ctx.workflowId,
|
|
199
|
+
content: ev.notice,
|
|
200
|
+
authRecovery: ev.authRecovery,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
});
|
|
177
204
|
|
|
178
205
|
return spawnP.then((r) => {
|
|
179
206
|
const completedAt = Date.now();
|
|
@@ -369,16 +369,35 @@ export async function loadKernel(cwd: string, boardKey?: TaskBoardKey): Promise<
|
|
|
369
369
|
if (!cwd) return { tasks: [], comments: [], runs: [] };
|
|
370
370
|
const snapshot = await readKernelSnapshot(cwd, boardKey);
|
|
371
371
|
if (snapshot !== null) return snapshot;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
372
|
+
return rebuildKernelOnce(cwd, boardKey);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Without a snapshot the board is folded from every conversation's log in the
|
|
376
|
+
// project. Reconnecting tabs of one project each ask for the board at once, so
|
|
377
|
+
// concurrent requests share one rebuild: N tabs used to start N rebuilds, each
|
|
378
|
+
// reading all N logs again, and the server answered none of them for many
|
|
379
|
+
// seconds on a project with long histories.
|
|
380
|
+
const kernelRebuilds = new Map<string, Promise<TaskKernelState>>();
|
|
381
|
+
function rebuildKernelOnce(cwd: string, boardKey?: TaskBoardKey): Promise<TaskKernelState> {
|
|
382
|
+
const key = `${cwd}\0${sanitizeBoardKey(boardKey) ?? ''}`;
|
|
383
|
+
const running = kernelRebuilds.get(key);
|
|
384
|
+
if (running) return running;
|
|
385
|
+
const started = (async () => {
|
|
386
|
+
// One pass over the logs gives the tasks, comments, runs and receipts.
|
|
387
|
+
const events = await taskLedgerEvents(cwd, boardKey);
|
|
388
|
+
const tasks = foldTasks(events);
|
|
389
|
+
const comments = foldComments(events);
|
|
390
|
+
const runs = foldRuns(events);
|
|
391
|
+
const proposalReceipts: Record<string, string> = {};
|
|
392
|
+
for (const event of events) {
|
|
393
|
+
const receipt = event.payload?.proposalReceipt as { key?: unknown; taskId?: unknown } | undefined;
|
|
394
|
+
if (typeof receipt?.key === 'string' && typeof receipt.taskId === 'string') proposalReceipts[receipt.key] = receipt.taskId;
|
|
395
|
+
}
|
|
396
|
+
await saveKernel(cwd, { tasks, comments, runs, proposalReceipts }, boardKey).catch(() => { /* best-effort cache write */ });
|
|
397
|
+
return { tasks, comments, runs, proposalReceipts };
|
|
398
|
+
})().finally(() => { kernelRebuilds.delete(key); });
|
|
399
|
+
kernelRebuilds.set(key, started);
|
|
400
|
+
return started;
|
|
382
401
|
}
|
|
383
402
|
|
|
384
403
|
export async function saveKernel(cwd: string, state: TaskKernelState, boardKey?: TaskBoardKey): Promise<void> {
|
|
@@ -506,22 +525,7 @@ function eventBelongsToBoard(ev: TaskLedgerEventMessage, boardKey?: TaskBoardKey
|
|
|
506
525
|
return sanitizeBoardKey(ev.boardKey) === sanitizeBoardKey(boardKey);
|
|
507
526
|
}
|
|
508
527
|
|
|
509
|
-
|
|
510
|
-
if (!cwd) return [];
|
|
511
|
-
const metas = await listWorkflowMetas(cwd).catch(() => []);
|
|
512
|
-
const events: Array<TaskLedgerEventMessage & { seq: number }> = [];
|
|
513
|
-
for (const meta of metas) {
|
|
514
|
-
const msgs = await replayEvents(cwd, meta.workflowId, 0).catch(() => []);
|
|
515
|
-
for (const m of msgs) {
|
|
516
|
-
if (m.type !== 'task_ledger_event') continue;
|
|
517
|
-
const ev = m as unknown as TaskLedgerEventMessage & { seq?: number };
|
|
518
|
-
// Only fold events for THIS cwd (a workflow's log is cwd-local, but the
|
|
519
|
-
// event carries cwd explicitly — guard against a moved log).
|
|
520
|
-
if (ev.cwd !== cwd || !eventBelongsToBoard(ev, boardKey)) continue;
|
|
521
|
-
events.push({ ...ev, seq: ev.seq ?? 0 });
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
events.sort((a, b) => (a.at - b.at) || (a.seq - b.seq));
|
|
528
|
+
function foldTasks(events: Array<TaskLedgerEventMessage & { seq: number }>): LedgerTask[] {
|
|
525
529
|
const byId = new Map<string, LedgerTask>();
|
|
526
530
|
for (const ev of events) {
|
|
527
531
|
if (ev.op === 'delete') {
|
|
@@ -534,6 +538,11 @@ export async function rebuildFromEvents(cwd: string, boardKey?: TaskBoardKey): P
|
|
|
534
538
|
return [...byId.values()].sort((a, b) => a.createdAt - b.createdAt);
|
|
535
539
|
}
|
|
536
540
|
|
|
541
|
+
export async function rebuildFromEvents(cwd: string, boardKey?: TaskBoardKey): Promise<LedgerTask[]> {
|
|
542
|
+
if (!cwd) return [];
|
|
543
|
+
return foldTasks(await taskLedgerEvents(cwd, boardKey));
|
|
544
|
+
}
|
|
545
|
+
|
|
537
546
|
async function taskLedgerEvents(cwd: string, boardKey?: TaskBoardKey): Promise<Array<TaskLedgerEventMessage & { seq: number }>> {
|
|
538
547
|
if (!cwd) return [];
|
|
539
548
|
const metas = await listWorkflowMetas(cwd).catch(() => []);
|
|
@@ -551,9 +560,9 @@ async function taskLedgerEvents(cwd: string, boardKey?: TaskBoardKey): Promise<A
|
|
|
551
560
|
return events;
|
|
552
561
|
}
|
|
553
562
|
|
|
554
|
-
|
|
563
|
+
function foldComments(events: Array<TaskLedgerEventMessage & { seq: number }>): TaskComment[] {
|
|
555
564
|
const comments: TaskComment[] = [];
|
|
556
|
-
for (const ev of
|
|
565
|
+
for (const ev of events) {
|
|
557
566
|
const comment = ev.payload?.comment;
|
|
558
567
|
if (isTaskComment(comment)) {
|
|
559
568
|
comments.push(normalizeComment(comment));
|
|
@@ -563,9 +572,13 @@ export async function rebuildCommentsFromEvents(cwd: string, boardKey?: TaskBoar
|
|
|
563
572
|
return comments;
|
|
564
573
|
}
|
|
565
574
|
|
|
566
|
-
export async function
|
|
575
|
+
export async function rebuildCommentsFromEvents(cwd: string, boardKey?: TaskBoardKey): Promise<TaskComment[]> {
|
|
576
|
+
return foldComments(await taskLedgerEvents(cwd, boardKey));
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function foldRuns(events: Array<TaskLedgerEventMessage & { seq: number }>): TaskRun[] {
|
|
567
580
|
const byId = new Map<string, TaskRun>();
|
|
568
|
-
for (const ev of
|
|
581
|
+
for (const ev of events) {
|
|
569
582
|
const run = ev.payload?.run;
|
|
570
583
|
if (
|
|
571
584
|
(ev.op === 'run_started'
|
|
@@ -583,6 +596,10 @@ export async function rebuildRunsFromEvents(cwd: string, boardKey?: TaskBoardKey
|
|
|
583
596
|
return [...byId.values()].sort((a, b) => a.startedAt - b.startedAt);
|
|
584
597
|
}
|
|
585
598
|
|
|
599
|
+
export async function rebuildRunsFromEvents(cwd: string, boardKey?: TaskBoardKey): Promise<TaskRun[]> {
|
|
600
|
+
return foldRuns(await taskLedgerEvents(cwd, boardKey));
|
|
601
|
+
}
|
|
602
|
+
|
|
586
603
|
// ── mutation helpers (pure — caller persists + emits the event) ──────────────
|
|
587
604
|
|
|
588
605
|
export function newTask(input: {
|