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
|
@@ -35,6 +35,7 @@ import Anthropic from '@anthropic-ai/sdk';
|
|
|
35
35
|
import type { WorkerConfig, ServerMessage, SteerItem } from '@arco/shared';
|
|
36
36
|
import { supportsClaudeAdaptiveThinking, isClaudeModelAlias, enforcesPreservedThinking, supportsMidConversationSystemMessages, supportsMidConversationToolChanges } from '@arco/shared';
|
|
37
37
|
import { loadTokens, nativeCredentialBinding } from './auth.js';
|
|
38
|
+
import { ClaudeNativeAccountUnavailableError } from '../../providerAccounts.js';
|
|
38
39
|
import type { AuthRecoveryContext } from '@arco/shared';
|
|
39
40
|
import { ensureLiveTokens, forceRefreshTokens, markClaudeAuthProblem, ClaudeNativeNoAuthError } from './oauth.js';
|
|
40
41
|
import { resolveTrustStatus } from '../../projectTrust.js';
|
|
@@ -45,7 +46,7 @@ import { checkPartialReadFullWrite } from './pretoolGuards.js';
|
|
|
45
46
|
import { firstBlockingGuard, postToolSteps, runPostToolSteps } from './toolChecks.js';
|
|
46
47
|
import { evaluateGate, gateOutcome, gateSignature, type GateProposal } from './gateReview.js';
|
|
47
48
|
import { recordPendingGate, clearPendingGate, readGateStore, hasStandingApproval, addStandingApproval } from './gateStore.js';
|
|
48
|
-
import { getCachedModelCapabilities, getCatalog,
|
|
49
|
+
import { getCachedModelCapabilities, getCatalog, resolveClaudeAliasFromCatalog } from './catalog.js';
|
|
49
50
|
import { filterToolResult } from './filterToolResult.js';
|
|
50
51
|
import { planTurnSpill, toolEvictEnabled, turnToolTokenBudget, type EvictableResult } from './toolResultEviction.js';
|
|
51
52
|
import { outputHash } from '../outputSignature.js';
|
|
@@ -387,6 +388,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
387
388
|
// against on-disk tokens and rebuild the client transparently.
|
|
388
389
|
private authRecovery: AuthRecoveryContext = { transport: 'native', binding: nativeCredentialBinding() };
|
|
389
390
|
private clientTokenObtainedAt: number | null = null;
|
|
391
|
+
private clientBinding: AuthRecoveryContext['binding'];
|
|
390
392
|
private messages: MessageParam[] = [];
|
|
391
393
|
private heldSteerNotices = new WeakSet<object>();
|
|
392
394
|
private hooks: HookConfig = { byEvent: {} };
|
|
@@ -844,6 +846,10 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
844
846
|
// shouldn't change without a worker tear-down, but
|
|
845
847
|
// appendSystemPrompt rotates per turn (skills manifest, transcript)
|
|
846
848
|
// and effort/model can be live-edited.
|
|
849
|
+
if (this.config.providerAccountRef !== next.providerAccountRef) {
|
|
850
|
+
this.catalogWarmAttempted = false;
|
|
851
|
+
this.authFailureCount = 0;
|
|
852
|
+
}
|
|
847
853
|
this.config = next;
|
|
848
854
|
this.taskDisabled = this.taskDisabled || next.claudeNativeTaskDisabled === true;
|
|
849
855
|
}
|
|
@@ -1545,20 +1551,22 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
1545
1551
|
// worker built its client, ensureLiveTokens() returns the fresh set
|
|
1546
1552
|
// and the obtainedAt mismatch below forces a client rebuild. Cheap:
|
|
1547
1553
|
// ensureLiveTokens is a single disk read on the happy path.
|
|
1548
|
-
const
|
|
1549
|
-
|
|
1554
|
+
const accountRef = this.config.providerAccountRef;
|
|
1555
|
+
const tokens = await ensureLiveTokens(accountRef);
|
|
1556
|
+
const binding = nativeCredentialBinding(tokens, accountRef);
|
|
1557
|
+
this.authRecovery = { transport: 'native', binding, ...(accountRef ? { accountRef } : {}) };
|
|
1550
1558
|
// An alias tab can't be dispatched until the alias resolves to a concrete
|
|
1551
1559
|
// id. Warm the catalog once per worker so the resolution is catalog-backed
|
|
1552
1560
|
// (newest family member) rather than the static CLAUDE_ALIAS_FALLBACK.
|
|
1553
1561
|
// Failure is non-fatal — the fallback still yields a real, dispatchable id.
|
|
1554
|
-
if (!this.catalogWarmAttempted && isClaudeModelAlias(this.config.model)
|
|
1562
|
+
if ((!this.catalogWarmAttempted || this.clientBinding?.revision !== binding.revision) && isClaudeModelAlias(this.config.model)) {
|
|
1555
1563
|
this.catalogWarmAttempted = true;
|
|
1556
|
-
await getCatalog(false).catch((err) => {
|
|
1564
|
+
await getCatalog(false, this.config.providerAccountRef).catch((err) => {
|
|
1557
1565
|
console.warn(`[claude-native:${this.workflowId.slice(0, 8)}] catalog warm for alias '${this.config.model}' failed; using static fallback:`, err instanceof Error ? err.message : err);
|
|
1558
1566
|
});
|
|
1559
1567
|
}
|
|
1560
1568
|
const baseURL = await nativeOAuthBaseUrl();
|
|
1561
|
-
if (this.client && this.
|
|
1569
|
+
if (this.client && this.clientBinding?.storeId === binding.storeId && this.clientBinding.revision === binding.revision && this.client.baseURL === baseURL) return;
|
|
1562
1570
|
const isRebuild = this.client !== null;
|
|
1563
1571
|
if (isRebuild) {
|
|
1564
1572
|
console.log(`[claude-native:${this.workflowId.slice(0, 8)}] credentials or endpoint changed - rebuilding Anthropic client`);
|
|
@@ -1576,6 +1584,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
1576
1584
|
maxRetries: 0,
|
|
1577
1585
|
} as ConstructorParameters<typeof Anthropic>[0]);
|
|
1578
1586
|
this.clientTokenObtainedAt = tokens.obtainedAt;
|
|
1587
|
+
this.clientBinding = binding;
|
|
1579
1588
|
// Token-rotation rebuilds reuse the existing hooks + replayed state
|
|
1580
1589
|
// and skip the worker-init emit. Hooks come from CLAUDE.md files,
|
|
1581
1590
|
// unrelated to auth; replay only ever runs once per worker; 'init'
|
|
@@ -1615,7 +1624,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
1615
1624
|
// `not_found_error: model: opus`. Resolved per call, not cached: the operator
|
|
1616
1625
|
// can live-swap the model through updateConfig mid-session.
|
|
1617
1626
|
private requestModel(): string {
|
|
1618
|
-
return resolveClaudeAliasFromCatalog(this.config.model);
|
|
1627
|
+
return resolveClaudeAliasFromCatalog(this.config.model, this.config.providerAccountRef);
|
|
1619
1628
|
}
|
|
1620
1629
|
|
|
1621
1630
|
// Opus-5 plan Phase 2 — the model id capability decisions key on. For a
|
|
@@ -1662,7 +1671,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
1662
1671
|
private buildBetaHeader(): string {
|
|
1663
1672
|
const parts: string[] = ['claude-code-20250219', 'oauth-2025-04-20'];
|
|
1664
1673
|
if (shouldSendInterleavedThinkingBeta(this.capModel(), this.config.claudeNativeForceInterleavedThinkingBeta === true)) parts.push('interleaved-thinking-2025-05-14');
|
|
1665
|
-
const caps = getCachedModelCapabilities(this.capModel());
|
|
1674
|
+
const caps = getCachedModelCapabilities(this.capModel(), this.config.providerAccountRef);
|
|
1666
1675
|
// compact is OFF by default for Native (NATIVE_COMPACTION_PLAN §1); the
|
|
1667
1676
|
// beta is only attached when WorkflowConfig.claudeNativeCompact is the
|
|
1668
1677
|
// explicit per-tab/global opt-in true. Once a server compaction block is
|
|
@@ -1826,7 +1835,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
1826
1835
|
// an empty object when no context-management feature is active so the
|
|
1827
1836
|
// call site can spread it unconditionally.
|
|
1828
1837
|
private buildContextManagementBody(): Record<string, unknown> {
|
|
1829
|
-
const caps = getCachedModelCapabilities(this.capModel());
|
|
1838
|
+
const caps = getCachedModelCapabilities(this.capModel(), this.config.providerAccountRef);
|
|
1830
1839
|
const edits = buildContextManagementEditsForRequest(caps, this.config.claudeNativeCompact === true && !hasLeadingServerFoldBlock(this.messages));
|
|
1831
1840
|
// Anthropic's server-managed compaction is an edit strategy, not a sibling
|
|
1832
1841
|
// `context_management.compact` object. Let the model+server pick the
|
|
@@ -1837,14 +1846,14 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
1837
1846
|
|
|
1838
1847
|
private async hydrateContextManagementCapabilities(): Promise<void> {
|
|
1839
1848
|
const model = this.capModel();
|
|
1840
|
-
if (getCachedModelCapabilities(model)) return;
|
|
1841
|
-
await getCatalog(false).catch((err) => {
|
|
1849
|
+
if (getCachedModelCapabilities(model, this.config.providerAccountRef)) return;
|
|
1850
|
+
await getCatalog(false, this.config.providerAccountRef).catch((err) => {
|
|
1842
1851
|
console.warn(`[claude-native:${this.workflowId.slice(0, 8)}] catalog warm-up failed:`, err instanceof Error ? err.message : err);
|
|
1843
1852
|
});
|
|
1844
|
-
if (getCachedModelCapabilities(model)) return;
|
|
1853
|
+
if (getCachedModelCapabilities(model, this.config.providerAccountRef)) return;
|
|
1845
1854
|
if (this.forcedCatalogRefreshModels.has(model)) return;
|
|
1846
1855
|
this.forcedCatalogRefreshModels.add(model);
|
|
1847
|
-
await getCatalog(true).catch((err) => {
|
|
1856
|
+
await getCatalog(true, this.config.providerAccountRef).catch((err) => {
|
|
1848
1857
|
console.warn(`[claude-native:${this.workflowId.slice(0, 8)}] catalog force-refresh failed for ${model}:`, err instanceof Error ? err.message : err);
|
|
1849
1858
|
});
|
|
1850
1859
|
}
|
|
@@ -2778,17 +2787,24 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
2778
2787
|
this.taskPolicy = resolveNativeSubagents(taskDefaults?.nativeSubagents, this.config.nativeSubagents);
|
|
2779
2788
|
await this.ensureStarted();
|
|
2780
2789
|
} catch (err) {
|
|
2781
|
-
|
|
2790
|
+
const accountRef = this.config.providerAccountRef;
|
|
2791
|
+
if (err instanceof ClaudeNativeAccountUnavailableError) {
|
|
2792
|
+
this.emit('system_notice', `[AUTH:claude] ${err.message}`, { transport: 'native', accountRef, accountUnavailable: true });
|
|
2793
|
+
this.emit('error', 'claude account unavailable');
|
|
2794
|
+
return;
|
|
2795
|
+
}
|
|
2796
|
+
try { this.authRecovery = { transport: 'native', ...(accountRef ? { accountRef } : {}), binding: nativeCredentialBinding(await loadTokens(accountRef), accountRef) }; }
|
|
2797
|
+
catch { this.authRecovery = { transport: 'native', ...(accountRef ? { accountRef } : {}) }; }
|
|
2782
2798
|
// Pre-flight auth surface: emit the [AUTH:claude] sentinel so the
|
|
2783
2799
|
// chat renderer offers RE-LOGIN instead of a raw error string.
|
|
2784
2800
|
if (err instanceof ClaudeNativeNoAuthError) {
|
|
2785
|
-
markClaudeAuthProblem('not authenticated'); // A2 — phone banner + notice
|
|
2801
|
+
markClaudeAuthProblem('not authenticated', accountRef); // A2 — phone banner + notice
|
|
2786
2802
|
this.emit('system_notice', '[AUTH:claude] Claude Native is not authenticated. Re-login to continue.', this.authRecovery);
|
|
2787
2803
|
this.emit('error', 'claude auth required');
|
|
2788
2804
|
return;
|
|
2789
2805
|
}
|
|
2790
2806
|
const detail = err instanceof Error ? err.message : String(err);
|
|
2791
|
-
markClaudeAuthProblem(detail); // A2 — pre-flight refresh failure
|
|
2807
|
+
markClaudeAuthProblem(detail, accountRef); // A2 — pre-flight refresh failure
|
|
2792
2808
|
this.emit('system_notice', `[AUTH:claude] Claude Native auth failed: ${detail}. Re-login to continue.`, this.authRecovery);
|
|
2793
2809
|
this.emit('error', 'claude auth failed');
|
|
2794
2810
|
return;
|
|
@@ -4272,7 +4288,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
4272
4288
|
return !this.config.incognito && cwd && WFID_PATTERN.test(this.workflowId) ? join(workflowDir(cwd, this.workflowId), 'pending-subagent-approval.json') : null;
|
|
4273
4289
|
}
|
|
4274
4290
|
|
|
4275
|
-
private async batchCatalog(force: boolean) { return await getCatalog(force); }
|
|
4291
|
+
private async batchCatalog(force: boolean) { return await getCatalog(force, this.config.providerAccountRef); }
|
|
4276
4292
|
|
|
4277
4293
|
private async approveTaskBatch(blocks: ToolUseBlock[]): Promise<boolean> {
|
|
4278
4294
|
if (!blocks.length) return true;
|
|
@@ -4328,7 +4344,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
4328
4344
|
}
|
|
4329
4345
|
const available = current.models.map((m) => m.id);
|
|
4330
4346
|
const proposed = selected ? [selected] : entries.map((e) => e.effective);
|
|
4331
|
-
if (proposed.some((model) => !available.includes(model) && !available.includes(resolveClaudeAliasFromCatalog(model)))) {
|
|
4347
|
+
if (proposed.some((model) => !available.includes(model) && !available.includes(resolveClaudeAliasFromCatalog(model, this.config.providerAccountRef)))) {
|
|
4332
4348
|
this.taskBatchRefusal = 'Task not started: a selected model is no longer available.';
|
|
4333
4349
|
this.emit('system_notice', 'Sub-agent batch not started: a selected model is no longer available.');
|
|
4334
4350
|
return false;
|
|
@@ -4453,7 +4469,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
4453
4469
|
summary: finalText.slice(0, 200),
|
|
4454
4470
|
});
|
|
4455
4471
|
const overridden = spawnPolicy.model && args.model
|
|
4456
|
-
&& resolveClaudeAliasFromCatalog(spawnPolicy.model) !== resolveClaudeAliasFromCatalog(args.model);
|
|
4472
|
+
&& resolveClaudeAliasFromCatalog(spawnPolicy.model, this.config.providerAccountRef) !== resolveClaudeAliasFromCatalog(args.model, this.config.providerAccountRef);
|
|
4457
4473
|
return overridden
|
|
4458
4474
|
? `${finalText}\n\nSub-agent used ${chosenModel ?? handle.model ?? spawnPolicy.model}: the operator's model selection overrides the requested ${args.model}.`
|
|
4459
4475
|
: finalText;
|
|
@@ -4524,7 +4540,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
4524
4540
|
if (!this.forcedAuthRefreshThisTurn && attempt < MAX_RETRY_ATTEMPTS - 1) {
|
|
4525
4541
|
this.forcedAuthRefreshThisTurn = true;
|
|
4526
4542
|
try {
|
|
4527
|
-
await forceRefreshTokens(this.clientTokenObtainedAt ?? 0);
|
|
4543
|
+
await forceRefreshTokens(this.clientTokenObtainedAt ?? 0, this.config.providerAccountRef);
|
|
4528
4544
|
// On-disk tokens rotated → obtainedAt mismatch → client rebuild.
|
|
4529
4545
|
await this.ensureStarted();
|
|
4530
4546
|
console.log(`[claude-native:${this.workflowId.slice(0, 8)}] 401 on unexpired token — forced refresh ok, retrying`);
|
|
@@ -4538,10 +4554,10 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
4538
4554
|
}
|
|
4539
4555
|
}
|
|
4540
4556
|
this.authFailureCount += 1;
|
|
4541
|
-
const detail =
|
|
4557
|
+
const detail = 'The provider rejected this account credentials';
|
|
4542
4558
|
// A2 — flip the live auth-problem flag (phone console banner + one
|
|
4543
4559
|
// auth-expired notice). Cleared by a successful refresh/bootstrap.
|
|
4544
|
-
markClaudeAuthProblem(detail);
|
|
4560
|
+
markClaudeAuthProblem(detail, this.config.providerAccountRef);
|
|
4545
4561
|
const loud = this.authFailureCount >= AUTH_FAILURE_LOUD_THRESHOLD;
|
|
4546
4562
|
const prefix = loud
|
|
4547
4563
|
? `[AUTH:claude] Repeated Claude auth failures (${this.authFailureCount}). Re-login required to continue.`
|
|
@@ -8,9 +8,9 @@ interface Pending {
|
|
|
8
8
|
workflowId: string;
|
|
9
9
|
state: OperatorQuestionState;
|
|
10
10
|
rpcId?: JsonRpcId;
|
|
11
|
-
respond?: (
|
|
11
|
+
respond?: (answers: Answers | null) => boolean | void;
|
|
12
12
|
publish: (state: OperatorQuestionState) => void;
|
|
13
|
-
|
|
13
|
+
finish: (state: OperatorQuestionState) => void;
|
|
14
14
|
sending: boolean;
|
|
15
15
|
}
|
|
16
16
|
// Process-local handles only. Disk/replay stores the public state, never callbacks.
|
|
@@ -39,14 +39,28 @@ export function pendingOperatorQuestions(workflowId: string): OperatorQuestionSt
|
|
|
39
39
|
return [...pending.values()].filter((p) => p.workflowId === workflowId).map((p) => p.state);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
export function openGeminiOperatorQuestion(workflowId: string, sessionId: string, questions: OperatorQuestion[], respond: NonNullable<Pending['respond']>): () => void {
|
|
43
|
+
const requestId = randomUUID();
|
|
44
|
+
const state: OperatorQuestionState = { requestId, provider: 'antigravity-cli', threadId: sessionId, turnId: requestId,
|
|
45
|
+
itemId: requestId, mode: 'blocking', questions, status: 'pending', createdAt: Date.now() };
|
|
46
|
+
const publish = (next: OperatorQuestionState) => publisher?.(workflowId, next);
|
|
47
|
+
const finish = (next: OperatorQuestionState) => { pending.delete(requestId); publish(next); };
|
|
48
|
+
pending.set(requestId, { workflowId, state, respond, publish, finish, sending: false });
|
|
49
|
+
publish(state);
|
|
50
|
+
return () => {
|
|
51
|
+
if (pending.has(requestId)) finish({ ...state, status: 'cancelled', reason: 'Gemini closed this question.' });
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
export async function replyToOperatorQuestion(workflowId: string, requestId: string, value: unknown, sendInput?: SendInput): Promise<{ ok: boolean; error?: string }> {
|
|
43
56
|
const entry = pending.get(requestId);
|
|
44
57
|
if (!entry || entry.workflowId !== workflowId) return { ok: false, error: 'This question is no longer pending.' };
|
|
45
58
|
if (entry.sending) return { ok: false, error: 'An answer is already being delivered.' };
|
|
46
|
-
if (!record(value) || Object.keys(value).
|
|
59
|
+
if (!record(value) || Object.keys(value).some(id => !entry.state.questions.some(q => q.id === id))) return { ok: false, error: 'Answer every required question.' };
|
|
47
60
|
const answers: Answers = Object.create(null);
|
|
48
61
|
for (const q of entry.state.questions) {
|
|
49
62
|
const a = Object.hasOwn(value, q.id) ? value[q.id] : undefined;
|
|
63
|
+
if (a === undefined && q.optional) continue;
|
|
50
64
|
if (!Array.isArray(a) || a.length !== 1 || !text(a[0], 16384) || !a[0].trim()) return { ok: false, error: 'Each question needs an answer.' };
|
|
51
65
|
if (q.options?.length && !q.allowOther && !q.options.some((o) => o.label === a[0])) return { ok: false, error: 'Choose one of the offered options.' };
|
|
52
66
|
answers[q.id] = [a[0]];
|
|
@@ -54,8 +68,7 @@ export async function replyToOperatorQuestion(workflowId: string, requestId: str
|
|
|
54
68
|
entry.sending = true;
|
|
55
69
|
try {
|
|
56
70
|
if (entry.respond) {
|
|
57
|
-
|
|
58
|
-
if (delivered === false) throw new Error('Codex connection closed.');
|
|
71
|
+
if (entry.respond(answers) === false) throw new Error('Agent connection closed.');
|
|
59
72
|
} else {
|
|
60
73
|
if (!sendInput) throw new Error('The question reply channel is unavailable.');
|
|
61
74
|
// Async agent-message questions have no pending RPC. Send an ordinary
|
|
@@ -63,8 +76,8 @@ export async function replyToOperatorQuestion(workflowId: string, requestId: str
|
|
|
63
76
|
await sendInput('Answers to your questions:\n' + entry.state.questions.map((q) => `${q.question}\nAnswer: ${answers[q.id][0]}`).join('\n\n'), entry.state);
|
|
64
77
|
}
|
|
65
78
|
if (pending.get(requestId) === entry) {
|
|
66
|
-
const publicAnswers = Object.fromEntries(entry.state.questions.
|
|
67
|
-
entry.
|
|
79
|
+
const publicAnswers = Object.fromEntries(entry.state.questions.filter(q => Object.hasOwn(answers, q.id)).map(q => [q.id, q.secret ? ['[redacted]'] : answers[q.id]]));
|
|
80
|
+
entry.finish({ ...entry.state, status: 'answered', answers: publicAnswers });
|
|
68
81
|
}
|
|
69
82
|
return { ok: true };
|
|
70
83
|
} catch {
|
|
@@ -78,9 +91,9 @@ export function dismissOperatorQuestion(workflowId: string, requestId: string):
|
|
|
78
91
|
if (entry.sending) return { ok: false, error: 'An answer is already being delivered.' };
|
|
79
92
|
entry.sending = true;
|
|
80
93
|
try {
|
|
81
|
-
if (entry.respond
|
|
94
|
+
if (entry.respond?.(null) === false) throw new Error('Agent connection closed.');
|
|
82
95
|
if (pending.get(requestId) !== entry) return { ok: false, error: 'This question is no longer pending.' };
|
|
83
|
-
entry.
|
|
96
|
+
entry.finish({ ...entry.state, status: 'cancelled', reason: 'Dismissed by the operator.' });
|
|
84
97
|
return { ok: true };
|
|
85
98
|
} catch {
|
|
86
99
|
return { ok: false, error: 'The dismissal could not be delivered. The question is still pending.' };
|
|
@@ -98,7 +111,8 @@ export class CodexOperatorQuestions {
|
|
|
98
111
|
if (p.isBlocking !== undefined && typeof p.isBlocking !== 'boolean') throw new Error('Invalid blocking flag.');
|
|
99
112
|
if ([...this.ids].some((id) => pending.get(id)?.rpcId === req.id)) throw new Error('Duplicate question request.');
|
|
100
113
|
const questions = parseQuestions(p.questions);
|
|
101
|
-
this.add({ threadId: p.threadId, turnId: p.turnId, itemId: p.itemId, mode: p.isBlocking === false ? 'async' : 'blocking', questions },
|
|
114
|
+
this.add({ threadId: p.threadId, turnId: p.turnId, itemId: p.itemId, mode: p.isBlocking === false ? 'async' : 'blocking', questions },
|
|
115
|
+
(answers) => respond({ answers: Object.fromEntries(Object.entries(answers ?? {}).map(([id, a]) => [id, { answers: a }])) }), req.id);
|
|
102
116
|
}
|
|
103
117
|
|
|
104
118
|
acceptAsync(threadId: string, turnId: string, item: { id: string; questions?: unknown }): void {
|
|
@@ -119,7 +133,7 @@ export class CodexOperatorQuestions {
|
|
|
119
133
|
private add(data: Pick<OperatorQuestionState, 'threadId' | 'turnId' | 'itemId' | 'mode' | 'questions'>, respond?: Pending['respond'], rpcId?: JsonRpcId): void {
|
|
120
134
|
if (this.ids.size >= 16) throw new Error('Too many pending questions.');
|
|
121
135
|
const state: OperatorQuestionState = { ...data, requestId: randomUUID(), provider: this.provider, status: 'pending', createdAt: Date.now() };
|
|
122
|
-
const entry: Pending = { workflowId: this.workflowId, state, respond, rpcId, publish: this.publish,
|
|
136
|
+
const entry: Pending = { workflowId: this.workflowId, state, respond, rpcId, publish: this.publish, finish: (next) => this.finish(entry, next), sending: false };
|
|
123
137
|
this.ids.add(state.requestId); pending.set(state.requestId, entry); this.publish(state);
|
|
124
138
|
}
|
|
125
139
|
|
|
@@ -148,7 +162,7 @@ export class CodexOperatorQuestions {
|
|
|
148
162
|
const p = pending.get(id);
|
|
149
163
|
if (!p || (rpcOnly && p.rpcId === undefined)) continue;
|
|
150
164
|
this.finish(p, { ...p.state, status: 'cancelled', reason });
|
|
151
|
-
p.respond?.(
|
|
165
|
+
p.respond?.(null);
|
|
152
166
|
}
|
|
153
167
|
}
|
|
154
168
|
}
|
|
@@ -444,6 +444,10 @@ function observeTurnBoundary(workflowId: string, wf: WorkflowState, message: Ser
|
|
|
444
444
|
// attention.ts sees every message (questions, gates and errors too) and
|
|
445
445
|
// ignores a repeated start or end itself.
|
|
446
446
|
attention.observeAttention(workflowId, message, { name: wf.config.name ?? '', incognito: !!wf.config.incognito });
|
|
447
|
+
// A finished handoff or fold leaves a smaller conversation in the same member: automatic pickup may resume.
|
|
448
|
+
if (message.type === 'handoff_complete' || message.type === 'context_folded') clusterAutoTurn.noteTurnOutcome(workflowId, null);
|
|
449
|
+
// A terminal request_too_large stops automatic pickup for this member before its turn-end sweep.
|
|
450
|
+
if (message.type === 'error' && typeof message.message === 'string' && clusterAutoTurn.isOversizeError(message.message)) clusterAutoTurn.noteTurnOutcome(workflowId, message.message);
|
|
447
451
|
if (message.type === 'primary_turn_started') {
|
|
448
452
|
if (turnBoundaryState.get(workflowId) === 'open') return;
|
|
449
453
|
turnBoundaryState.set(workflowId, 'open');
|
package/server/src/settings.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
1
2
|
import { sanitizeNativeSubagents } from '@arco/shared';
|
|
2
3
|
import { scanBeforeDeadline } from './scanDeadline.js';
|
|
3
4
|
import { parsePreviewPorts } from './previewProxy.js';
|
|
@@ -24,7 +25,7 @@ import { mkdirSync, realpathSync, watch as fsWatch, type FSWatcher } from 'fs';
|
|
|
24
25
|
import path from 'path';
|
|
25
26
|
import { homedir } from 'os';
|
|
26
27
|
import type { ArcoSettings, ProviderName, ModelName, WorkflowDefaults, EffortLevel, ProviderAccountsConfig, ProviderAccountProfile, FallbackChainsConfig, FallbackLegConfig, PinnedService, OllamaBackendConfig, OllamaUtilityConfig, OllamaCompactionConfig } from '@arco/shared';
|
|
27
|
-
import { VALID_THEME_IDS, VALID_FONT_PACK_IDS, normalizeLegacyThemeId, DEFAULT_UI_SCALE, normalizeUiScale } from '@arco/shared';
|
|
28
|
+
import { isClaudeNativeProfileId, VALID_THEME_IDS, VALID_FONT_PACK_IDS, normalizeLegacyThemeId, DEFAULT_UI_SCALE, normalizeUiScale } from '@arco/shared';
|
|
28
29
|
import { describeConfigValue } from './configValue.js';
|
|
29
30
|
import { atomicWriteFile, withFileLock } from './atomicFile.js';
|
|
30
31
|
import { arcoHome } from './arcoHome.js';
|
|
@@ -283,11 +284,11 @@ function sanitizeAccountBrowser(raw: unknown): ProviderAccountProfile['authBrows
|
|
|
283
284
|
return args && args.length > 0 ? { command, args } : { command };
|
|
284
285
|
}
|
|
285
286
|
|
|
286
|
-
function sanitizeAccountProfile(raw: unknown, provider:
|
|
287
|
+
function sanitizeAccountProfile(raw: unknown, provider: keyof ProviderAccountsConfig): ProviderAccountProfile | null {
|
|
287
288
|
if (!raw || typeof raw !== 'object') return null;
|
|
288
289
|
const r = raw as Record<string, unknown>;
|
|
289
290
|
const id = typeof r.id === 'string' ? r.id.trim() : '';
|
|
290
|
-
if (!ACCOUNT_ID_PATTERN.test(id)) return null;
|
|
291
|
+
if (provider === 'claudeNative' ? !isClaudeNativeProfileId(id) : !ACCOUNT_ID_PATTERN.test(id)) return null;
|
|
291
292
|
const labelRaw = typeof r.label === 'string' ? r.label.trim().replace(/[\r\n\t]+/g, ' ') : id;
|
|
292
293
|
const label = (labelRaw || id).slice(0, 32);
|
|
293
294
|
const shortRaw = typeof r.shortLabel === 'string' ? r.shortLabel.trim().replace(/[\r\n\t]+/g, ' ') : '';
|
|
@@ -300,7 +301,7 @@ function sanitizeAccountProfile(raw: unknown, provider: 'codex' | 'claude'): Pro
|
|
|
300
301
|
const codexHome = r.codexHome.trim();
|
|
301
302
|
if (codexHome && codexHome.length <= 512 && !/[\r\n]/.test(codexHome)) out.codexHome = codexHome;
|
|
302
303
|
}
|
|
303
|
-
const authBrowser = sanitizeAccountBrowser(r.authBrowser);
|
|
304
|
+
const authBrowser = provider === 'claudeNative' ? undefined : sanitizeAccountBrowser(r.authBrowser);
|
|
304
305
|
if (authBrowser) out.authBrowser = authBrowser;
|
|
305
306
|
return out;
|
|
306
307
|
}
|
|
@@ -309,7 +310,7 @@ function sanitizeProviderAccounts(raw: unknown): ProviderAccountsConfig | undefi
|
|
|
309
310
|
if (!raw || typeof raw !== 'object') return undefined;
|
|
310
311
|
const r = raw as Record<string, unknown>;
|
|
311
312
|
const out: ProviderAccountsConfig = {};
|
|
312
|
-
for (const provider of ['codex', 'claude'] as const) {
|
|
313
|
+
for (const provider of ['codex', 'claude', 'claudeNative'] as const) {
|
|
313
314
|
const arr = r[provider];
|
|
314
315
|
if (!Array.isArray(arr)) continue;
|
|
315
316
|
const seen = new Set<string>();
|
|
@@ -802,8 +803,19 @@ export async function readSettings(
|
|
|
802
803
|
// global scope only, so this never recurses.
|
|
803
804
|
if (opts?.includeProject === false) return mergeWithDefaults(global);
|
|
804
805
|
const project = await readJsonFile(projectSettingsPath(cwd), 'project');
|
|
805
|
-
const merged = deepMerge(global, project);
|
|
806
|
-
|
|
806
|
+
const merged = mergeWithDefaults(deepMerge(global, project));
|
|
807
|
+
// A project can tune its transport. The Native profile names and IDs are
|
|
808
|
+
// global operator settings because the same IDs select paid credentials.
|
|
809
|
+
const operatorAccounts = sanitizeProviderAccounts(global.providerAccounts);
|
|
810
|
+
if (merged.providerAccounts || operatorAccounts) {
|
|
811
|
+
const accounts = { ...merged.providerAccounts };
|
|
812
|
+
delete accounts.claude;
|
|
813
|
+
delete accounts.claudeNative;
|
|
814
|
+
if (operatorAccounts?.claude) accounts.claude = operatorAccounts.claude;
|
|
815
|
+
if (operatorAccounts?.claudeNative) accounts.claudeNative = operatorAccounts.claudeNative;
|
|
816
|
+
merged.providerAccounts = Object.keys(accounts).length ? accounts : undefined;
|
|
817
|
+
}
|
|
818
|
+
return merged;
|
|
807
819
|
}
|
|
808
820
|
|
|
809
821
|
export async function writeSettings(next: ArcoSettings): Promise<void> {
|
|
@@ -854,7 +866,7 @@ async function patchSettingsUnlocked(patch: Partial<ArcoSettings>): Promise<Arco
|
|
|
854
866
|
merged.localClusterCapacity = current.localClusterCapacity;
|
|
855
867
|
}
|
|
856
868
|
if ('providerAccounts' in patch) {
|
|
857
|
-
const sanitized = sanitizeProviderAccounts(patch.providerAccounts);
|
|
869
|
+
const sanitized = sanitizeProviderAccounts(patch.providerAccounts ? { ...current.providerAccounts, ...patch.providerAccounts } : patch.providerAccounts);
|
|
858
870
|
if (sanitized) merged.providerAccounts = sanitized;
|
|
859
871
|
} else if (current.providerAccounts) {
|
|
860
872
|
merged.providerAccounts = current.providerAccounts;
|
|
@@ -1175,6 +1187,22 @@ export async function patchSettings(patch: Partial<ArcoSettings>): Promise<ArcoS
|
|
|
1175
1187
|
return withFileLock(GLOBAL_SETTINGS_PATH, () => patchSettingsUnlocked(patch));
|
|
1176
1188
|
}
|
|
1177
1189
|
|
|
1190
|
+
export async function saveClaudeNativeProfile(label: string, id?: string): Promise<ArcoSettings> {
|
|
1191
|
+
const cleanLabel = label.trim();
|
|
1192
|
+
if (!cleanLabel || cleanLabel.length > 32 || /[\r\n\t]/.test(cleanLabel)) throw new Error('Enter an account name of 1 to 32 characters.');
|
|
1193
|
+
return withFileLock(GLOBAL_SETTINGS_PATH, async () => {
|
|
1194
|
+
const current = await readSettings();
|
|
1195
|
+
const accounts = current.providerAccounts ?? {};
|
|
1196
|
+
const profiles = accounts.claudeNative ?? [];
|
|
1197
|
+
if (id && !profiles.some(profile => profile.id === id)) throw new Error('Claude Native account unavailable.');
|
|
1198
|
+
if (!id && profiles.length >= 8) throw new Error('Up to 8 additional Claude Native accounts are supported.');
|
|
1199
|
+
const next = id
|
|
1200
|
+
? profiles.map(profile => profile.id === id ? { ...profile, label: cleanLabel } : profile)
|
|
1201
|
+
: [...profiles, { id: `native-${randomBytes(12).toString('hex')}`, label: cleanLabel }];
|
|
1202
|
+
return patchSettingsUnlocked({ providerAccounts: { ...accounts, claudeNative: next } });
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1178
1206
|
// ── Watchers (HMR) ───────────────────────────────────────────────────────
|
|
1179
1207
|
//
|
|
1180
1208
|
// One global watcher and one per-cwd project watcher. Both watch the parent
|
package/server/src/skills.ts
CHANGED
|
@@ -41,7 +41,7 @@ export interface SkillRef { scope: SkillScope; slug: string }
|
|
|
41
41
|
// from the SKILLS menu; model-invoked entries also appear in the manifest.
|
|
42
42
|
export type PickedSkillScope = SkillScope | 'builtin';
|
|
43
43
|
export interface BuiltinSkillSummary { slug: string; name: string; description: string; scope: 'builtin'; operatorOnly: boolean; off?: boolean; replaced?: boolean; path?: string }
|
|
44
|
-
const OPERATOR_BUILTINS = new Set(['grill-me', 'grill-with-docs', 'wait-what', 'retro']);
|
|
44
|
+
const OPERATOR_BUILTINS = new Set(['grill-me', 'grill-with-docs', 'wait-what', 'retro', 'code-review']);
|
|
45
45
|
export function listBuiltinSkills(): BuiltinSkillSummary[] {
|
|
46
46
|
return [...ARCO_BUILTIN_SKILLS.map(s => ({ slug: s.slug, name: s.name, description: s.description, scope: 'builtin' as const, operatorOnly: s.operatorOnly })), ...THIRD_PARTY_SKILL_FILES.map(({ slug, files }) => {
|
|
47
47
|
const parsed = parseSkillFile(files['SKILL.md']);
|
|
@@ -50,6 +50,7 @@ import { cursorAgentEnv } from './providers/cursor/agentEnv.js';
|
|
|
50
50
|
|
|
51
51
|
export interface EvaluatorRequest {
|
|
52
52
|
model: string;
|
|
53
|
+
providerAccountRef?: string;
|
|
53
54
|
instructions: string;
|
|
54
55
|
prompt: string;
|
|
55
56
|
timeoutMs: number;
|
|
@@ -179,7 +180,7 @@ export function claudeAdapter(opts: { fetchImpl?: typeof fetch; tokens?: () => P
|
|
|
179
180
|
async evaluate(req) {
|
|
180
181
|
const { signal, done } = deadline(req);
|
|
181
182
|
try {
|
|
182
|
-
const { accessToken } = await tokens().catch(() => { throw new EvaluatorRefused('not_signed_in'); });
|
|
183
|
+
const { accessToken } = await tokens(req.providerAccountRef).catch(() => { throw new EvaluatorRefused('not_signed_in'); });
|
|
183
184
|
const client = new Anthropic({
|
|
184
185
|
authToken: accessToken,
|
|
185
186
|
apiKey: null,
|
|
@@ -188,7 +189,7 @@ export function claudeAdapter(opts: { fetchImpl?: typeof fetch; tokens?: () => P
|
|
|
188
189
|
defaultHeaders: { 'anthropic-beta': 'claude-code-20250219,oauth-2025-04-20', 'anthropic-dangerous-direct-browser-access': 'true', 'user-agent': CLAUDE_CLI_USER_AGENT, 'x-app': 'cli' },
|
|
189
190
|
...(opts.fetchImpl ? { fetch: opts.fetchImpl } : {}),
|
|
190
191
|
} as ConstructorParameters<typeof Anthropic>[0]);
|
|
191
|
-
const model = resolveClaudeAliasFromCatalog(req.model);
|
|
192
|
+
const model = resolveClaudeAliasFromCatalog(req.model, req.providerAccountRef);
|
|
192
193
|
const resp = await client.messages.create({
|
|
193
194
|
model,
|
|
194
195
|
...shortTextRequestParams(model, req.maxOutputTokens),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { workflows } from './server/state.js';
|
|
1
2
|
// Smart AUTO-PICKUP observer: decides, for one idle member at a time, what
|
|
2
3
|
// the chosen evaluator proposes for its waiting mail, and records it. In
|
|
3
4
|
// Observe-only mode that record is the whole effect. In Automatic mode a wake
|
|
@@ -25,7 +26,7 @@ import { withFileLock } from './atomicFile.js';
|
|
|
25
26
|
import { buildClusterAutoPickup } from '@arco/shared';
|
|
26
27
|
import { evaluatorAdapter, isStartupFailure } from './smartPickupAdapters.js';
|
|
27
28
|
import { recentSentTo } from './smartPickupThread.js';
|
|
28
|
-
import { isGeminiMember } from './geminiMembers.js';
|
|
29
|
+
import { geminiPickupAllowed, isGeminiMember } from './geminiMembers.js';
|
|
29
30
|
|
|
30
31
|
export interface ObservedDecision {
|
|
31
32
|
clusterId: string;
|
|
@@ -203,9 +204,7 @@ export async function evaluateOnce(clusterId: string, workflowId: string): Promi
|
|
|
203
204
|
const deferLapsed = prior.action === 'defer' && prior.deferUntil !== undefined && deps.now() >= prior.deferUntil;
|
|
204
205
|
if (!deferLapsed && !prior.retryEvaluation) return null;
|
|
205
206
|
}
|
|
206
|
-
|
|
207
|
-
// NUDGE; Smart pickup neither evaluates nor wakes it.
|
|
208
|
-
if (isGeminiMember(workflowId)) {
|
|
207
|
+
if (isGeminiMember(workflowId) && !geminiPickupAllowed(workflowId)) {
|
|
209
208
|
const d = { ...base, action: null, reason: 'operator_send_only', outcome: 'skipped' };
|
|
210
209
|
await record(d);
|
|
211
210
|
return d;
|
|
@@ -244,7 +243,11 @@ export async function evaluateOnce(clusterId: string, workflowId: string): Promi
|
|
|
244
243
|
return null;
|
|
245
244
|
}
|
|
246
245
|
try {
|
|
246
|
+
const recipient = workflows.get(workflowId);
|
|
247
|
+
const providerAccountRef = evaluator.provider === 'claude' && recipient?.primary.provider === 'claude'
|
|
248
|
+
&& recipient.config.claudeTransport !== 'cli' && !recipient.config.ultracode ? recipient.config.providerAccountRef : undefined;
|
|
247
249
|
raw = await evaluatorAdapter(evaluator.provider).evaluate({
|
|
250
|
+
providerAccountRef,
|
|
248
251
|
model: evaluator.model,
|
|
249
252
|
instructions: EVALUATOR_INSTRUCTIONS,
|
|
250
253
|
prompt: evaluatorUserPrompt(snapshot.payload!),
|
|
@@ -301,7 +304,7 @@ export async function evaluateOnce(clusterId: string, workflowId: string): Promi
|
|
|
301
304
|
}
|
|
302
305
|
|
|
303
306
|
// Conditions that pass with time; a wake blocked by one stays owed.
|
|
304
|
-
const TRANSIENT = new Set(['busy', 'cooldown', 'rate_capped', 'limit_wakes_member_hour']);
|
|
307
|
+
const TRANSIENT = new Set(['busy', 'cooldown', 'rate_capped', 'limit_wakes_member_hour', 'member_blocked']);
|
|
305
308
|
|
|
306
309
|
async function gateAndRecord(proposal: ObservedDecision, arm: { sessionId: string; mode: 'smart-observe' | 'smart-auto' }): Promise<ObservedDecision> {
|
|
307
310
|
const result = await gateWake(proposal, arm);
|