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,27 +1,31 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
3
|
import * as lockfile from 'proper-lockfile';
|
|
4
4
|
import { atomicWriteFile } from '../../atomicFile.js';
|
|
5
|
-
import { arcoHome } from '../../arcoHome.js';
|
|
5
|
+
import { arcoHome, assertTestHomeSafe } from '../../arcoHome.js';
|
|
6
6
|
import { createHash } from 'node:crypto';
|
|
7
|
+
import { DEFAULT_CLAUDE_NATIVE_ACCOUNT, isClaudeNativeProfileId } from '@arco/shared';
|
|
7
8
|
// The stamp changes with the actual credential material, including rotations.
|
|
8
9
|
// It exposes no token bytes and is not proof of account identity or execution.
|
|
9
|
-
export function nativeCredentialBinding(tokens) {
|
|
10
|
+
export function nativeCredentialBinding(tokens, accountRef = DEFAULT_CLAUDE_NATIVE_ACCOUNT) {
|
|
10
11
|
return {
|
|
11
|
-
source: 'claude-native', storeId: 'claude.native'
|
|
12
|
+
source: 'claude-native', storeId: accountRef === DEFAULT_CLAUDE_NATIVE_ACCOUNT ? 'claude.native' : `claude.native:${accountRef}`,
|
|
12
13
|
...(tokens ? { revision: createHash('sha256').update(JSON.stringify([
|
|
13
14
|
tokens.accessToken, tokens.refreshToken, tokens.expiresAt, tokens.obtainedAt, tokens.tokenType, tokens.scope,
|
|
14
15
|
])).digest('hex') } : {}),
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
const ARCO_DIR = arcoHome();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
function authPath(accountRef = DEFAULT_CLAUDE_NATIVE_ACCOUNT) {
|
|
20
|
+
if (accountRef === DEFAULT_CLAUDE_NATIVE_ACCOUNT)
|
|
21
|
+
return join(ARCO_DIR, 'auth.json');
|
|
22
|
+
if (!isClaudeNativeProfileId(accountRef))
|
|
23
|
+
throw new Error('Invalid Claude Native account ID.');
|
|
24
|
+
return join(ARCO_DIR, 'provider-accounts', `claude-${accountRef}`, 'auth.json');
|
|
21
25
|
}
|
|
22
|
-
async function readRaw() {
|
|
26
|
+
async function readRaw(path) {
|
|
23
27
|
try {
|
|
24
|
-
const buf = await fs.readFile(
|
|
28
|
+
const buf = await fs.readFile(path, 'utf8');
|
|
25
29
|
const parsed = JSON.parse(buf);
|
|
26
30
|
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
27
31
|
}
|
|
@@ -31,24 +35,26 @@ async function readRaw() {
|
|
|
31
35
|
throw err;
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
|
-
async function writeRaw(data) {
|
|
35
|
-
await
|
|
36
|
-
await atomicWriteFile(AUTH_PATH, JSON.stringify(data, null, 2), { mode: 0o600 });
|
|
38
|
+
async function writeRaw(path, data) {
|
|
39
|
+
await atomicWriteFile(path, JSON.stringify(data, null, 2), { mode: 0o600 });
|
|
37
40
|
}
|
|
38
|
-
// proper-lockfile requires
|
|
39
|
-
//
|
|
40
|
-
async function ensureFile() {
|
|
41
|
+
// proper-lockfile requires an existing target. Exclusive creation prevents a
|
|
42
|
+
// concurrent first login from being overwritten by the initial empty file.
|
|
43
|
+
async function ensureFile(path) {
|
|
44
|
+
assertTestHomeSafe(path);
|
|
45
|
+
await fs.mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
41
46
|
try {
|
|
42
|
-
await fs.
|
|
47
|
+
await fs.writeFile(path, '{}\n', { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
43
48
|
}
|
|
44
|
-
catch {
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
catch (err) {
|
|
50
|
+
if (err.code !== 'EEXIST')
|
|
51
|
+
throw err;
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
async function
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
export async function withAuthLock(fn, accountRef) {
|
|
55
|
+
const path = authPath(accountRef);
|
|
56
|
+
await ensureFile(path);
|
|
57
|
+
const release = await lockfile.lock(path, {
|
|
52
58
|
retries: { retries: 10, minTimeout: 50, maxTimeout: 500 },
|
|
53
59
|
stale: 30_000,
|
|
54
60
|
});
|
|
@@ -59,46 +65,32 @@ async function withLock(fn) {
|
|
|
59
65
|
await release();
|
|
60
66
|
}
|
|
61
67
|
}
|
|
62
|
-
export async function loadTokens() {
|
|
63
|
-
const data = await readRaw();
|
|
68
|
+
export async function loadTokens(accountRef) {
|
|
69
|
+
const data = await readRaw(authPath(accountRef));
|
|
64
70
|
return data.claude?.native ?? null;
|
|
65
71
|
}
|
|
66
|
-
export async function saveTokens(next) {
|
|
67
|
-
await
|
|
68
|
-
const data = await readRaw();
|
|
69
|
-
const merged = {
|
|
70
|
-
...data,
|
|
71
|
-
claude: { ...(data.claude ?? {}), native: next },
|
|
72
|
-
};
|
|
73
|
-
await writeRaw(merged);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
export async function clearTokens() {
|
|
77
|
-
await withLock(async () => {
|
|
78
|
-
const data = await readRaw();
|
|
79
|
-
if (data.claude?.native) {
|
|
80
|
-
delete data.claude.native;
|
|
81
|
-
if (Object.keys(data.claude).length === 0)
|
|
82
|
-
delete data.claude;
|
|
83
|
-
}
|
|
84
|
-
await writeRaw(data);
|
|
85
|
-
});
|
|
72
|
+
export async function saveTokens(next, accountRef) {
|
|
73
|
+
await withAuthLock(() => writeTokensUnlocked(next, accountRef), accountRef);
|
|
86
74
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
export async function withAuthLock(fn) {
|
|
90
|
-
return withLock(fn);
|
|
75
|
+
export async function clearTokens(accountRef) {
|
|
76
|
+
await withAuthLock(() => clearTokensUnlocked(accountRef), accountRef);
|
|
91
77
|
}
|
|
92
|
-
export async function
|
|
93
|
-
const
|
|
94
|
-
|
|
78
|
+
export async function clearTokensUnlocked(accountRef) {
|
|
79
|
+
const path = authPath(accountRef);
|
|
80
|
+
const data = await readRaw(path);
|
|
81
|
+
if (!data.claude?.native)
|
|
82
|
+
return;
|
|
83
|
+
delete data.claude.native;
|
|
84
|
+
if (Object.keys(data.claude).length === 0)
|
|
85
|
+
delete data.claude;
|
|
86
|
+
await writeRaw(path, data);
|
|
95
87
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
await writeRaw(
|
|
88
|
+
// OAuth holds the profile lock while reading a refresh grant and writing its
|
|
89
|
+
// replacement. Reads outside the lock observe one complete file version.
|
|
90
|
+
export const readTokensUnlocked = loadTokens;
|
|
91
|
+
export async function writeTokensUnlocked(next, accountRef) {
|
|
92
|
+
const path = authPath(accountRef);
|
|
93
|
+
const data = await readRaw(path);
|
|
94
|
+
await writeRaw(path, { ...data, claude: { ...(data.claude ?? {}), native: next } });
|
|
103
95
|
}
|
|
104
96
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare function getClaudeNativeAuthStatus(): Promise<ClaudeNativeAuthStatus>;
|
|
1
|
+
import { type ClaudeNativeAuthStatus } from '@arco/shared';
|
|
2
|
+
export declare function getClaudeNativeAuthStatus(accountRef?: string): Promise<ClaudeNativeAuthStatus>;
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
+
import { DEFAULT_CLAUDE_NATIVE_ACCOUNT } from '@arco/shared';
|
|
1
2
|
import { loadTokens, nativeCredentialBinding } from './auth.js';
|
|
2
3
|
import { getClaudeAuthProblem, REFRESH_LEAD_MS_EXPORT } from './oauth.js';
|
|
3
|
-
|
|
4
|
+
const statuses = new Map();
|
|
4
5
|
// Metadata only: never refresh, start OAuth, query allowance or send inference.
|
|
5
|
-
export async function getClaudeNativeAuthStatus() {
|
|
6
|
+
export async function getClaudeNativeAuthStatus(accountRef = DEFAULT_CLAUDE_NATIVE_ACCOUNT) {
|
|
7
|
+
const lastStatus = statuses.get(accountRef);
|
|
6
8
|
try {
|
|
7
|
-
const tokens = await loadTokens();
|
|
9
|
+
const tokens = await loadTokens(accountRef);
|
|
8
10
|
if (tokens && (typeof tokens.accessToken !== 'string' || !tokens.accessToken
|
|
9
11
|
|| typeof tokens.refreshToken !== 'string' || !tokens.refreshToken
|
|
10
12
|
|| !Number.isFinite(tokens.expiresAt)))
|
|
11
13
|
throw new Error('Invalid Native credential metadata');
|
|
12
|
-
const problem = getClaudeAuthProblem();
|
|
14
|
+
const problem = getClaudeAuthProblem(accountRef);
|
|
13
15
|
const status = {
|
|
14
16
|
state: !tokens ? 'missing' : problem ? 'needs-attention' : tokens.expiresAt <= Date.now() + REFRESH_LEAD_MS_EXPORT ? 'refresh-needed' : 'present',
|
|
15
17
|
credentialsPresent: !!tokens,
|
|
16
18
|
execution: 'unverified',
|
|
17
|
-
binding: nativeCredentialBinding(tokens),
|
|
19
|
+
binding: nativeCredentialBinding(tokens, accountRef),
|
|
18
20
|
checkedAt: Date.now(),
|
|
19
21
|
...(tokens ? { expiresAt: tokens.expiresAt, scopes: typeof tokens.scope === 'string' ? tokens.scope.split(/\s+/).filter(Boolean) : [] } : {}),
|
|
20
22
|
...(tokens && problem ? { problemSince: problem.since, error: 'Native authentication reported a problem. Open Native settings to recover.' } : {}),
|
|
21
23
|
};
|
|
22
|
-
|
|
24
|
+
statuses.set(accountRef, status);
|
|
23
25
|
return status;
|
|
24
26
|
}
|
|
25
27
|
catch {
|
|
26
28
|
return {
|
|
27
|
-
...(lastStatus ?? { credentialsPresent: false, execution: 'unverified', binding: nativeCredentialBinding(), checkedAt: Date.now() }),
|
|
29
|
+
...(lastStatus ?? { credentialsPresent: false, execution: 'unverified', binding: nativeCredentialBinding(null, accountRef), checkedAt: Date.now() }),
|
|
28
30
|
state: 'unknown', probeFailed: true, stale: !!lastStatus,
|
|
29
31
|
error: 'Native credential status could not be read. The previous result may be out of date.',
|
|
30
32
|
};
|
|
@@ -56,12 +56,13 @@ export interface AnthropicModel {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
export declare function
|
|
59
|
+
export declare function forgetCatalog(accountRef: string): void;
|
|
60
|
+
export declare function getCachedModelCapabilities(modelId: string, accountRef?: string): {
|
|
60
61
|
supportsClearThinking: boolean;
|
|
61
62
|
supportsClearToolUses: boolean;
|
|
62
63
|
supportsCompact: boolean;
|
|
63
64
|
} | null;
|
|
64
|
-
export declare function getCachedClaudeModelEfforts(modelId: string): ClaudeCatalogModel['supportedEfforts'] | undefined;
|
|
65
|
-
export declare function hasCatalogCache(): boolean;
|
|
66
|
-
export declare function resolveClaudeAliasFromCatalog(modelId: string): string;
|
|
67
|
-
export declare function getCatalog(force?: boolean): Promise<ClaudeCatalogSnapshot>;
|
|
65
|
+
export declare function getCachedClaudeModelEfforts(modelId: string, accountRef?: string): ClaudeCatalogModel['supportedEfforts'] | undefined;
|
|
66
|
+
export declare function hasCatalogCache(accountRef?: string): boolean;
|
|
67
|
+
export declare function resolveClaudeAliasFromCatalog(modelId: string, accountRef?: string): string;
|
|
68
|
+
export declare function getCatalog(force?: boolean, requestedAccount?: string): Promise<ClaudeCatalogSnapshot>;
|
|
@@ -11,13 +11,18 @@
|
|
|
11
11
|
//
|
|
12
12
|
// Refresh cadence: 1 hour. New models surface within that window
|
|
13
13
|
// without an Arco restart.
|
|
14
|
+
import { loadTokens, nativeCredentialBinding } from './auth.js';
|
|
15
|
+
import { requireClaudeNativeAccount } from '../../providerAccounts.js';
|
|
14
16
|
import { ensureLiveTokens } from './oauth.js';
|
|
15
17
|
import { CLAUDE_CLI_USER_AGENT } from './wireFingerprint.js';
|
|
16
|
-
import { claudeAliasFamily, CLAUDE_ALIAS_FALLBACK, distillCatalogModel, } from '@arco/shared';
|
|
18
|
+
import { DEFAULT_CLAUDE_NATIVE_ACCOUNT, claudeAliasFamily, CLAUDE_ALIAS_FALLBACK, distillCatalogModel, } from '@arco/shared';
|
|
17
19
|
const REFRESH_INTERVAL_MS = 60 * 60 * 1000;
|
|
18
20
|
const REQUEST_TIMEOUT_MS = 15_000;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const catalogs = new Map();
|
|
22
|
+
const cached = (accountRef = DEFAULT_CLAUDE_NATIVE_ACCOUNT) => catalogs.get(accountRef)?.snapshot;
|
|
23
|
+
export function forgetCatalog(accountRef) {
|
|
24
|
+
catalogs.delete(accountRef);
|
|
25
|
+
}
|
|
21
26
|
// Phase 7c-followup — synchronous catalog-capability lookup for the Native
|
|
22
27
|
// worker's per-request beta-header construction. Returns `null` when the
|
|
23
28
|
// model isn't in the cached catalog (cold-start, fetch failure, or a
|
|
@@ -25,10 +30,8 @@ let inFlight = null;
|
|
|
25
30
|
// Worker treats `null` conservatively: skip context-management betas
|
|
26
31
|
// rather than risk a 400. The catalog refresh is async and hourly; the
|
|
27
32
|
// worker reads the in-memory cache only.
|
|
28
|
-
export function getCachedModelCapabilities(modelId) {
|
|
29
|
-
|
|
30
|
-
return null;
|
|
31
|
-
const m = cache.models.find((x) => x.id === modelId);
|
|
33
|
+
export function getCachedModelCapabilities(modelId, accountRef) {
|
|
34
|
+
const m = cached(accountRef)?.models.find((x) => x.id === modelId);
|
|
32
35
|
if (!m)
|
|
33
36
|
return null;
|
|
34
37
|
return {
|
|
@@ -38,13 +41,13 @@ export function getCachedModelCapabilities(modelId) {
|
|
|
38
41
|
};
|
|
39
42
|
}
|
|
40
43
|
// The picker uses the same cached model efforts when a catalog is available.
|
|
41
|
-
export function getCachedClaudeModelEfforts(modelId) {
|
|
42
|
-
return
|
|
44
|
+
export function getCachedClaudeModelEfforts(modelId, accountRef) {
|
|
45
|
+
return cached(accountRef)?.models.find((model) => model.id === modelId)?.supportedEfforts;
|
|
43
46
|
}
|
|
44
47
|
// True once a non-empty catalog has been fetched in this process. Callers use
|
|
45
48
|
// it to decide whether an alias resolution is catalog-backed or a static guess.
|
|
46
|
-
export function hasCatalogCache() {
|
|
47
|
-
return
|
|
49
|
+
export function hasCatalogCache(accountRef) {
|
|
50
|
+
return (cached(accountRef)?.models.length ?? 0) > 0;
|
|
48
51
|
}
|
|
49
52
|
// resolve a family alias ('opus' / 'opus[1m]' / 'sonnet' /
|
|
50
53
|
// 'haiku') to the newest concrete id in that family. The Messages API has no
|
|
@@ -54,11 +57,11 @@ export function hasCatalogCache() {
|
|
|
54
57
|
//
|
|
55
58
|
// Concrete ids pass through untouched. Falls back to CLAUDE_ALIAS_FALLBACK
|
|
56
59
|
// when the catalog is cold — a stale-but-real id beats a guaranteed 404.
|
|
57
|
-
export function resolveClaudeAliasFromCatalog(modelId) {
|
|
60
|
+
export function resolveClaudeAliasFromCatalog(modelId, accountRef) {
|
|
58
61
|
const family = claudeAliasFamily(modelId);
|
|
59
62
|
if (!family)
|
|
60
63
|
return modelId;
|
|
61
|
-
const inFamily = (
|
|
64
|
+
const inFamily = (cached(accountRef)?.models ?? []).filter((m) => m.id.includes(family));
|
|
62
65
|
if (inFamily.length === 0)
|
|
63
66
|
return CLAUDE_ALIAS_FALLBACK[family];
|
|
64
67
|
// Newest by created_at, not catalog order — /v1/models happens to sort
|
|
@@ -69,33 +72,43 @@ export function resolveClaudeAliasFromCatalog(modelId) {
|
|
|
69
72
|
// Public accessor. Returns the cached snapshot; refreshes if older than
|
|
70
73
|
// REFRESH_INTERVAL_MS, in-flight request, or never fetched. Failures
|
|
71
74
|
// degrade to the last good cache rather than throwing.
|
|
72
|
-
export async function getCatalog(force = false) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
export async function getCatalog(force = false, requestedAccount) {
|
|
76
|
+
const accountRef = await requireClaudeNativeAccount(requestedAccount);
|
|
77
|
+
const empty = { fetchedAt: Date.now(), models: [], fresh: false };
|
|
78
|
+
const tokens = await loadTokens(accountRef);
|
|
79
|
+
if (!tokens) {
|
|
80
|
+
forgetCatalog(accountRef);
|
|
81
|
+
return empty;
|
|
82
|
+
}
|
|
83
|
+
const revision = nativeCredentialBinding(tokens, accountRef).revision;
|
|
84
|
+
let entry = catalogs.get(accountRef);
|
|
85
|
+
if (!entry || entry.revision !== revision) {
|
|
86
|
+
entry = { revision };
|
|
87
|
+
catalogs.set(accountRef, entry);
|
|
88
|
+
}
|
|
89
|
+
if (!force && entry.snapshot && Date.now() - entry.snapshot.fetchedAt < REFRESH_INTERVAL_MS)
|
|
90
|
+
return entry.snapshot;
|
|
91
|
+
if (entry.inFlight)
|
|
92
|
+
return entry.inFlight;
|
|
93
|
+
const current = entry;
|
|
94
|
+
current.inFlight = (async () => {
|
|
79
95
|
try {
|
|
80
|
-
const
|
|
81
|
-
|
|
96
|
+
const live = await ensureLiveTokens(accountRef);
|
|
97
|
+
const fresh = await fetchCatalog(live);
|
|
98
|
+
const after = await loadTokens(accountRef);
|
|
99
|
+
if (catalogs.get(accountRef) !== current || nativeCredentialBinding(live, accountRef).revision !== nativeCredentialBinding(after, accountRef).revision)
|
|
100
|
+
return empty;
|
|
101
|
+
current.revision = nativeCredentialBinding(live, accountRef).revision;
|
|
102
|
+
current.snapshot = fresh;
|
|
82
103
|
return fresh;
|
|
83
104
|
}
|
|
84
|
-
catch
|
|
85
|
-
|
|
86
|
-
console.warn('[claude-native:catalog] refresh failed; serving stale cache:', err instanceof Error ? err.message : err);
|
|
87
|
-
return { ...cache, fresh: false };
|
|
88
|
-
}
|
|
89
|
-
// No cache to fall back on. Return an empty snapshot; the UI uses
|
|
90
|
-
// the compile-time CLAUDE_MODELS list as a baseline.
|
|
91
|
-
console.warn('[claude-native:catalog] no auth and no cache:', err instanceof Error ? err.message : err);
|
|
92
|
-
return { fetchedAt: now, models: [], fresh: false };
|
|
105
|
+
catch {
|
|
106
|
+
return catalogs.get(accountRef) === current && current.snapshot ? { ...current.snapshot, fresh: false } : empty;
|
|
93
107
|
}
|
|
94
|
-
})().finally(() => { inFlight =
|
|
95
|
-
return inFlight;
|
|
108
|
+
})().finally(() => { current.inFlight = undefined; });
|
|
109
|
+
return current.inFlight;
|
|
96
110
|
}
|
|
97
|
-
async function fetchCatalog() {
|
|
98
|
-
const tokens = await ensureLiveTokens();
|
|
111
|
+
async function fetchCatalog(tokens) {
|
|
99
112
|
const controller = new AbortController();
|
|
100
113
|
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
101
114
|
try {
|
|
@@ -111,10 +124,8 @@ async function fetchCatalog() {
|
|
|
111
124
|
},
|
|
112
125
|
signal: controller.signal,
|
|
113
126
|
});
|
|
114
|
-
if (!resp.ok)
|
|
115
|
-
|
|
116
|
-
throw new Error(`/v1/models ${resp.status}: ${text.slice(0, 200)}`);
|
|
117
|
-
}
|
|
127
|
+
if (!resp.ok)
|
|
128
|
+
throw new Error(`/v1/models ${resp.status}`);
|
|
118
129
|
const body = await resp.json();
|
|
119
130
|
const raw = Array.isArray(body.data) ? body.data : [];
|
|
120
131
|
// Distil into the picker shape (camelCase displayName, supportedEfforts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ClaudeCredentialBinding, type ClaudeNativeAuthFlow } from '@arco/shared';
|
|
2
2
|
import { type ClaudeNativeTokens } from './auth.js';
|
|
3
3
|
export interface BootstrapStartResult {
|
|
4
4
|
authorizationUrl: string;
|
|
@@ -7,20 +7,21 @@ export interface BootstrapStartResult {
|
|
|
7
7
|
manualReason?: string;
|
|
8
8
|
flow: ClaudeNativeAuthFlow;
|
|
9
9
|
}
|
|
10
|
-
export declare function startBootstrap(expectedBinding?: ClaudeCredentialBinding, workflowId?: string): Promise<BootstrapStartResult>;
|
|
10
|
+
export declare function startBootstrap(expectedBinding?: ClaudeCredentialBinding, workflowId?: string, requestedAccount?: string): Promise<BootstrapStartResult>;
|
|
11
11
|
export declare function getBootstrapFlow(id: string): Promise<ClaudeNativeAuthFlow | null>;
|
|
12
12
|
export declare function cancelBootstrap(id: string, reason?: 'cancelled' | 'expired'): Promise<ClaudeNativeAuthFlow | null>;
|
|
13
|
-
export declare function cancelActiveBootstrap(): Promise<void>;
|
|
13
|
+
export declare function cancelActiveBootstrap(accountRef?: string): Promise<void>;
|
|
14
|
+
export declare function logout(accountRef?: string): Promise<void>;
|
|
14
15
|
export declare function completeBootstrap(rawUrl: string, flowId?: string): Promise<{
|
|
15
16
|
ok: true;
|
|
16
17
|
flow: ClaudeNativeAuthFlow;
|
|
17
18
|
}>;
|
|
18
|
-
export declare function refreshTokens(
|
|
19
|
-
export declare function forceRefreshTokens(staleObtainedAt: number): Promise<ClaudeNativeTokens>;
|
|
19
|
+
export declare function refreshTokens(_current: ClaudeNativeTokens, accountRef?: string): Promise<ClaudeNativeTokens>;
|
|
20
|
+
export declare function forceRefreshTokens(staleObtainedAt: number, accountRef?: string): Promise<ClaudeNativeTokens>;
|
|
20
21
|
export declare function setClaudeAuthProblemNotifier(fn: (detail: string) => void): void;
|
|
21
|
-
export declare function markClaudeAuthProblem(detail: string): void;
|
|
22
|
-
export declare function clearClaudeAuthProblem(): void;
|
|
23
|
-
export declare function getClaudeAuthProblem(): {
|
|
22
|
+
export declare function markClaudeAuthProblem(detail: string, accountRef?: string): void;
|
|
23
|
+
export declare function clearClaudeAuthProblem(accountRef?: string): void;
|
|
24
|
+
export declare function getClaudeAuthProblem(accountRef?: string): {
|
|
24
25
|
since: number;
|
|
25
26
|
detail: string;
|
|
26
27
|
} | null;
|
|
@@ -28,5 +29,5 @@ export declare class ClaudeNativeNoAuthError extends Error {
|
|
|
28
29
|
readonly code: "NO_AUTH";
|
|
29
30
|
constructor();
|
|
30
31
|
}
|
|
31
|
-
export declare function ensureLiveTokens(): Promise<ClaudeNativeTokens>;
|
|
32
|
+
export declare function ensureLiveTokens(requestedAccount?: string): Promise<ClaudeNativeTokens>;
|
|
32
33
|
export declare const REFRESH_LEAD_MS_EXPORT = 30000;
|