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
|
@@ -3,7 +3,7 @@ import { sanitizeNativeSubagents } from '@arco/shared';
|
|
|
3
3
|
// `update_primary_config` handler — live per-tab edits to the primary worker's
|
|
4
4
|
// model / effort / account + the per-workflow toggles (transports, efficiency
|
|
5
5
|
// knobs, output style, remote opt-in). Split out of workflowHandlers.ts to keep
|
|
6
|
-
// that file under the size budget
|
|
6
|
+
// that file under the size budget.
|
|
7
7
|
//
|
|
8
8
|
// Source-of-truth rule: each field is mirrored into BOTH the in-memory
|
|
9
9
|
// WorkflowState (wf.config / wf.primary, read by the next turn) AND meta.json
|
|
@@ -15,7 +15,10 @@ import { send, broadcastWorkflow, broadcastTransient } from '../server/broadcast
|
|
|
15
15
|
import { workflows } from '../server/state.js';
|
|
16
16
|
import { capGoal } from '../providers/goalBlock.js';
|
|
17
17
|
import { normalizeGoalRunArm } from '../goalRun.js';
|
|
18
|
-
import { deriveAutoFold, deriveAutoHandoff, startSessionWatcher } from './turnEngine.js';
|
|
18
|
+
import { claimBusy, deriveAutoFold, deriveAutoHandoff, drainQueueIfIdle, releaseBusy, startSessionWatcher } from './turnEngine.js';
|
|
19
|
+
import { requireClaudeNativeAccount } from '../providerAccounts.js';
|
|
20
|
+
import { effectiveClaudeTransport } from '../claudeTransport.js';
|
|
21
|
+
import { readSettings } from '../settings.js';
|
|
19
22
|
import { updateMeta } from '../workflowMeta.js';
|
|
20
23
|
import { withFileLock } from '../atomicFile.js';
|
|
21
24
|
import { disposeProviderResources } from '../providers/index.js';
|
|
@@ -23,103 +26,200 @@ import { refreshHubReporting } from '../management/initHubLink.js';
|
|
|
23
26
|
import { buildPinnedSkillsBlock, resolvePinnedSkills, isValidSlug } from '../skills.js';
|
|
24
27
|
import { withClusterSkillLock } from '../clusterStore.js';
|
|
25
28
|
import { assertWorkflowSkillPins, uniqueSkillRefs } from '../clusterSkills.js';
|
|
26
|
-
import type { Session } from '../workflows/types.js';
|
|
29
|
+
import type { Session, WorkflowState } from '../workflows/types.js';
|
|
30
|
+
|
|
31
|
+
// STOP must not release an in-flight account save and let a new turn race it.
|
|
32
|
+
const updatingNativeAccount = new WeakSet<WorkflowState>();
|
|
33
|
+
|
|
34
|
+
export function isUpdatingNativeAccount(wf: WorkflowState): boolean {
|
|
35
|
+
return updatingNativeAccount.has(wf);
|
|
36
|
+
}
|
|
27
37
|
|
|
28
38
|
export async function handleUpdatePrimaryConfig(
|
|
29
39
|
ws: WebSocket,
|
|
30
|
-
|
|
40
|
+
_session: Session,
|
|
31
41
|
msg: UpdatePrimaryConfigMessage,
|
|
32
42
|
): Promise<void> {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
await withFileLock(`primary-config:${msg.workflowId}`, async () => {
|
|
44
|
+
const wf = workflows.get(msg.workflowId);
|
|
45
|
+
if (!wf) {
|
|
46
|
+
send(ws, { type: 'error', message: `Unknown workflow ${msg.workflowId.slice(0, 8)}` });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const update = (account?: string) => {
|
|
51
|
+
const apply = () => applyPrimaryConfig(ws, wf, msg, account);
|
|
52
|
+
// Keep pin validation and publication under the cluster's pin lock.
|
|
53
|
+
return msg.pinnedSkills !== undefined ? withClusterSkillLock(msg.workflowId, apply) : apply();
|
|
54
|
+
};
|
|
55
|
+
if (msg.providerAccountRef === undefined || wf.primary.provider !== 'claude') {
|
|
56
|
+
await update();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
38
59
|
|
|
39
|
-
|
|
40
|
-
|
|
60
|
+
let token: number | undefined;
|
|
61
|
+
try {
|
|
62
|
+
if (typeof msg.providerAccountRef !== 'string' || !msg.providerAccountRef) throw new Error('Choose a Claude Native account.');
|
|
63
|
+
if (wf.busy) throw new Error('Wait for the current turn to finish before changing its account.');
|
|
64
|
+
token = claimBusy(wf, false);
|
|
65
|
+
updatingNativeAccount.add(wf);
|
|
66
|
+
const account = await requireClaudeNativeAccount(msg.providerAccountRef);
|
|
67
|
+
const settings = await readSettings(wf.config.workingDirectory);
|
|
68
|
+
if (effectiveClaudeTransport({ ...wf.config, claudeTransport: msg.claudeTransport ?? wf.config.claudeTransport, ultracode: msg.ultracode ?? wf.config.ultracode }, settings) !== 'native') {
|
|
69
|
+
throw new Error('Choose Claude Native before changing its account.');
|
|
70
|
+
}
|
|
71
|
+
if (workflows.get(msg.workflowId) !== wf) return;
|
|
72
|
+
await update(account);
|
|
73
|
+
} catch (err) {
|
|
74
|
+
send(ws, { type: 'error', workflowId: msg.workflowId, message: err instanceof Error ? err.message : 'Could not select the Claude Native account.' });
|
|
75
|
+
if (!wf.bootMaterialized) broadcastTransient(msg.workflowId, { type: 'workflow_config_synced', workflowId: msg.workflowId, config: wf.config });
|
|
76
|
+
} finally {
|
|
77
|
+
if (token !== undefined) {
|
|
78
|
+
updatingNativeAccount.delete(wf);
|
|
79
|
+
if (releaseBusy(wf, token, 'finished', false) && workflows.get(msg.workflowId) === wf) {
|
|
80
|
+
void drainQueueIfIdle(msg.workflowId);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function applyPrimaryConfig(
|
|
88
|
+
ws: WebSocket,
|
|
89
|
+
wf: WorkflowState,
|
|
90
|
+
msg: UpdatePrimaryConfigMessage,
|
|
91
|
+
nativeAccount?: string,
|
|
92
|
+
): Promise<void> {
|
|
93
|
+
// A Native account switch publishes the account and all accompanying edits
|
|
94
|
+
// only after validation and the single metadata write have succeeded.
|
|
95
|
+
const config: WorkflowState['config'] = nativeAccount === undefined
|
|
96
|
+
? wf.config
|
|
97
|
+
: { ...wf.config, providerAccountRef: nativeAccount, claudeTransport: 'native' };
|
|
98
|
+
const primary = nativeAccount === undefined ? wf.primary : { ...wf.primary };
|
|
99
|
+
const proposedModel = msg.model ?? primary.model;
|
|
100
|
+
const allowedEfforts = allowedWorkflowEfforts(primary.provider, proposedModel, config.providerAccountRef);
|
|
41
101
|
if (msg.effort !== undefined && !allowedEfforts.includes(msg.effort)) {
|
|
42
|
-
const label =
|
|
43
|
-
|
|
44
|
-
|
|
102
|
+
const label = primary.provider === 'claude' ? 'Claude' : 'Provider';
|
|
103
|
+
const message = `${label} effort must be ${allowedEfforts.join(', ')}; no settings were changed.`;
|
|
104
|
+
if (nativeAccount !== undefined) throw new Error(message);
|
|
105
|
+
send(ws, { type: 'error', workflowId: msg.workflowId, message });
|
|
45
106
|
return;
|
|
46
107
|
}
|
|
47
|
-
if (msg.model !== undefined && msg.effort === undefined) {
|
|
48
|
-
const next = normalizedWorkflowEffort(
|
|
49
|
-
if (next !==
|
|
108
|
+
if ((msg.model !== undefined || nativeAccount !== undefined) && msg.effort === undefined) {
|
|
109
|
+
const next = normalizedWorkflowEffort(primary.provider, proposedModel, primary.effort, config.providerAccountRef);
|
|
110
|
+
if (next !== primary.effort) msg = { ...msg, effort: next };
|
|
50
111
|
}
|
|
51
112
|
|
|
52
|
-
const proposedGoal = msg.goal === undefined ?
|
|
113
|
+
const proposedGoal = msg.goal === undefined ? config.goal : capGoal(msg.goal);
|
|
53
114
|
const proposedGoalRun = msg.goalRun === undefined ? undefined : normalizeGoalRunArm(msg.goalRun, !!proposedGoal?.trim());
|
|
54
115
|
if (typeof proposedGoalRun === 'string') {
|
|
116
|
+
if (nativeAccount !== undefined) throw new Error(proposedGoalRun);
|
|
55
117
|
send(ws, { type: 'error', workflowId: msg.workflowId, message: proposedGoalRun });
|
|
56
118
|
return;
|
|
57
119
|
}
|
|
58
120
|
|
|
59
|
-
|
|
60
121
|
if (msg.autoCompaction !== undefined && msg.autoCompaction !== null && !isAutoCompactionPolicy(msg.autoCompaction)) {
|
|
61
|
-
|
|
62
|
-
if (
|
|
122
|
+
const message = 'Auto-compaction requires a boolean and an integer threshold from 30 to 95.';
|
|
123
|
+
if (nativeAccount !== undefined) throw new Error(message);
|
|
124
|
+
send(ws, { type: 'error', message });
|
|
125
|
+
if (!wf.bootMaterialized) broadcastTransient(msg.workflowId, { type: 'workflow_config_synced', workflowId: msg.workflowId, config });
|
|
63
126
|
return;
|
|
64
127
|
}
|
|
65
|
-
|
|
128
|
+
|
|
129
|
+
const previousCompaction = config.autoCompaction;
|
|
130
|
+
if (msg.autoCompaction !== undefined && nativeAccount !== undefined) {
|
|
131
|
+
config.autoCompaction = msg.autoCompaction === null ? undefined : { ...msg.autoCompaction };
|
|
132
|
+
} else if (msg.autoCompaction !== undefined) {
|
|
66
133
|
const saved = await withFileLock(`auto-compaction:${msg.workflowId}`, async () => {
|
|
67
134
|
const next = msg.autoCompaction === null ? undefined : { ...msg.autoCompaction! };
|
|
68
|
-
const previous =
|
|
135
|
+
const previous = config.autoCompaction;
|
|
69
136
|
const changed = next?.enabled !== previous?.enabled || next?.thresholdPercent !== previous?.thresholdPercent;
|
|
70
137
|
if (!changed) return true;
|
|
71
|
-
if (
|
|
138
|
+
if (config.workingDirectory && !config.incognito) {
|
|
72
139
|
try {
|
|
73
|
-
const updated = await updateMeta(
|
|
140
|
+
const updated = await updateMeta(config.workingDirectory, msg.workflowId, (meta) => { meta.autoCompaction = next; });
|
|
74
141
|
if (!updated) throw new Error('workflow metadata unavailable');
|
|
75
142
|
} catch {
|
|
76
143
|
send(ws, { type: 'error', workflowId: msg.workflowId, message: 'Could not save auto-compaction policy; the previous policy remains active.' });
|
|
77
|
-
if (!wf.bootMaterialized) broadcastTransient(msg.workflowId, { type: 'workflow_config_synced', workflowId: msg.workflowId, config
|
|
144
|
+
if (!wf.bootMaterialized) broadcastTransient(msg.workflowId, { type: 'workflow_config_synced', workflowId: msg.workflowId, config });
|
|
78
145
|
return false;
|
|
79
146
|
}
|
|
80
147
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
content: next ? `[AUTO-COMPACT] Worker policy ${next.enabled ? `enabled at ${next.thresholdPercent}%` : 'disabled'}.` : '[AUTO-COMPACT] Worker policy cleared; cluster or legacy behavior applies.' });
|
|
148
|
+
config.autoCompaction = next;
|
|
149
|
+
announceAutoCompaction(msg.workflowId, next);
|
|
84
150
|
return true;
|
|
85
151
|
});
|
|
86
152
|
if (!saved) return;
|
|
87
153
|
}
|
|
88
154
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
155
|
+
// Standing skill pins are a whole-set replacement. Resolve before persisting
|
|
156
|
+
// so malformed / missing references never become durable config, and report
|
|
157
|
+
// current prompt bytes for cost visibility. Bodies remain on disk and are
|
|
158
|
+
// re-read at every turn; this snapshot is only the pin acknowledgement.
|
|
159
|
+
let pinnedSkillsBroadcast: {
|
|
160
|
+
skills: Array<{ scope: 'project' | 'global'; slug: string; name: string }>;
|
|
161
|
+
bytes: number;
|
|
162
|
+
missing: string[];
|
|
163
|
+
} | undefined;
|
|
164
|
+
if (msg.pinnedSkills !== undefined) {
|
|
165
|
+
const requested = uniqueSkillRefs((Array.isArray(msg.pinnedSkills) ? msg.pinnedSkills : []).filter(ref => ref && (ref.scope === 'project' || ref.scope === 'global') && isValidSlug(ref.slug)));
|
|
166
|
+
let resolved;
|
|
167
|
+
try {
|
|
168
|
+
await assertWorkflowSkillPins(msg.workflowId, config.workingDirectory, requested);
|
|
169
|
+
resolved = await resolvePinnedSkills(requested, config.workingDirectory);
|
|
170
|
+
const refs = resolved.skills.map(s => ({ scope: s.scope, slug: s.slug }));
|
|
171
|
+
if (refs.length) config.pinnedSkills = refs;
|
|
172
|
+
else delete config.pinnedSkills;
|
|
173
|
+
} catch (err) {
|
|
174
|
+
if (nativeAccount !== undefined) throw err;
|
|
175
|
+
send(ws, { type: 'error', workflowId: msg.workflowId, message: err instanceof Error ? err.message : String(err) });
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const block = buildPinnedSkillsBlock(resolved.skills);
|
|
179
|
+
pinnedSkillsBroadcast = {
|
|
180
|
+
skills: resolved.skills.map((s) => ({ scope: s.scope, slug: s.slug, name: s.name })),
|
|
181
|
+
bytes: block.bytes,
|
|
182
|
+
missing: [...resolved.missing, ...resolved.truncated],
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (msg.model !== undefined) primary.model = msg.model;
|
|
187
|
+
if (msg.effort !== undefined) primary.effort = msg.effort;
|
|
188
|
+
if (msg.providerAccountRef !== undefined && nativeAccount === undefined) {
|
|
92
189
|
if (wf.busy) {
|
|
93
190
|
send(ws, { type: 'error', message: 'Cannot change account profile while a turn is running.' });
|
|
94
191
|
return;
|
|
95
192
|
}
|
|
96
|
-
|
|
193
|
+
config.providerAccountRef = msg.providerAccountRef || undefined;
|
|
97
194
|
disposeProviderResources(msg.workflowId);
|
|
98
195
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] provider.account updated → ${msg.providerAccountRef || 'default'}`);
|
|
99
196
|
}
|
|
100
197
|
|
|
101
|
-
// Update the auto-handoff config. Mirrors into
|
|
198
|
+
// Update the auto-handoff config. Mirrors into config so the client
|
|
102
199
|
// receives the updated config on next rehydrate. The compaction count of
|
|
103
200
|
// the current conversation is kept: lowering N to or below it hands off at
|
|
104
201
|
// the next turn boundary. A malformed value is ignored. The 0.1.4
|
|
105
202
|
// percentages the tab already has are kept when the update leaves them out.
|
|
106
|
-
const previous =
|
|
203
|
+
const previous = config.autoHandoff;
|
|
107
204
|
const raw: unknown = msg.autoHandoff;
|
|
108
205
|
const autoHandoff = raw === undefined ? undefined
|
|
109
206
|
: normalizeAutoHandoff(raw && typeof raw === 'object' ? { warnAt: previous?.warnAt, autoAt: previous?.autoAt, ...raw } : raw);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const live = deriveAutoHandoff(wf.config);
|
|
207
|
+
const applyAutoHandoff = () => {
|
|
208
|
+
const live = deriveAutoHandoff(config);
|
|
113
209
|
wf.autoHandoff = { ...live, compactions: wf.autoHandoff?.compactions ?? 0, session: wf.autoHandoff?.session, fired: wf.autoHandoff?.fired ?? false };
|
|
114
|
-
|
|
210
|
+
};
|
|
211
|
+
if (autoHandoff) {
|
|
212
|
+
config.autoHandoff = autoHandoff;
|
|
213
|
+
if (nativeAccount === undefined) applyAutoHandoff();
|
|
214
|
+
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] auto-handoff updated → enabled=${autoHandoff.enabled} after=${autoHandoff.afterCompactions} compactions`);
|
|
115
215
|
}
|
|
116
216
|
|
|
117
217
|
// §2.1 — auto-fold config. Mirror into the live state (deriveAutoFold carries
|
|
118
218
|
// the runtime fired/anti-thrash counters) so the next post-turn check honors
|
|
119
219
|
// it without a reload.
|
|
120
220
|
if (msg.autoFold !== undefined) {
|
|
121
|
-
|
|
122
|
-
wf.autoFold = deriveAutoFold(
|
|
221
|
+
config.autoFold = { ...msg.autoFold };
|
|
222
|
+
if (nativeAccount === undefined) wf.autoFold = deriveAutoFold(config);
|
|
123
223
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] auto-fold updated → enabled=${msg.autoFold.enabled} foldAt=${msg.autoFold.foldAt}%`);
|
|
124
224
|
}
|
|
125
225
|
|
|
@@ -131,9 +231,9 @@ export async function handleUpdatePrimaryConfig(
|
|
|
131
231
|
if (msg.goalRun !== undefined) {
|
|
132
232
|
const next = proposedGoalRun!;
|
|
133
233
|
if (next.enabled) {
|
|
134
|
-
|
|
234
|
+
config.goalRun = next;
|
|
135
235
|
} else {
|
|
136
|
-
delete
|
|
236
|
+
delete config.goalRun;
|
|
137
237
|
}
|
|
138
238
|
goalRunBroadcast = next;
|
|
139
239
|
console.log(
|
|
@@ -145,7 +245,7 @@ export async function handleUpdatePrimaryConfig(
|
|
|
145
245
|
// read it) so the toggle survives a provider swap on the same tab. Takes
|
|
146
246
|
// effect on the next message — each turn recomputes chatWebArmed().
|
|
147
247
|
if (msg.chatWebAccess !== undefined) {
|
|
148
|
-
|
|
248
|
+
config.chatWebAccess = msg.chatWebAccess;
|
|
149
249
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] chat.web updated → ${msg.chatWebAccess ? 'armed' : 'off'}`);
|
|
150
250
|
}
|
|
151
251
|
|
|
@@ -155,41 +255,27 @@ export async function handleUpdatePrimaryConfig(
|
|
|
155
255
|
// provider so a Handoff that swaps from claude→codex on the same tab still
|
|
156
256
|
// sees the operator's pinned choice.
|
|
157
257
|
if (msg.codexTransport !== undefined) {
|
|
158
|
-
|
|
258
|
+
config.codexTransport = msg.codexTransport;
|
|
159
259
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] codex.transport updated → ${msg.codexTransport}`);
|
|
160
260
|
}
|
|
161
261
|
if (msg.codexContextPolicy !== undefined) {
|
|
162
|
-
|
|
262
|
+
config.codexContextPolicy = msg.codexContextPolicy;
|
|
163
263
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] codex.context updated → ${msg.codexContextPolicy}`);
|
|
164
264
|
}
|
|
165
265
|
// Phase 7a — same shape for Claude. Honored only on Claude tabs but written
|
|
166
266
|
// unconditionally so a Handoff that swaps from codex→claude on the same
|
|
167
267
|
// tab still sees the operator's pinned choice.
|
|
168
|
-
if (msg.claudeTransport !== undefined) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// transcript truth is events.jsonl; watching a stale CLI file painted
|
|
172
|
-
// calibration-probe entries over real answers). A live
|
|
173
|
-
// swap must move the watcher NOW, not at the next restart: stop it on the
|
|
174
|
-
// native direction, (re)start it on the cli direction — nothing on the
|
|
175
|
-
// normal turn path starts it (only create/rehydrate and handoff rotation
|
|
176
|
-
// do), so without this a cli→native→cli round trip leaves it dead.
|
|
177
|
-
if (msg.claudeTransport === 'native') {
|
|
178
|
-
if (wf.sessionWatcher) {
|
|
179
|
-
try { wf.sessionWatcher(); } catch { /* already disposed */ }
|
|
180
|
-
wf.sessionWatcher = null;
|
|
181
|
-
}
|
|
182
|
-
} else if (wf.config.workingDirectory) {
|
|
183
|
-
startSessionWatcher(msg.workflowId, wf, wf.config.workingDirectory, ws);
|
|
184
|
-
}
|
|
268
|
+
if (msg.claudeTransport !== undefined && nativeAccount === undefined) {
|
|
269
|
+
config.claudeTransport = msg.claudeTransport;
|
|
270
|
+
applyClaudeTransportWatcher(ws, msg.workflowId, wf);
|
|
185
271
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] claude.transport updated → ${msg.claudeTransport}`);
|
|
186
272
|
}
|
|
187
273
|
// docs/PROVIDERS.md - sticky ultracode toggle. We deliberately do NOT mutate
|
|
188
|
-
//
|
|
274
|
+
// config.claudeTransport here: turnEngine forces 'cli' at turn time while
|
|
189
275
|
// this is on, so the stored base transport stays intact and restores itself
|
|
190
276
|
// when ultracode flips off. Takes effect on the next turn; reversible.
|
|
191
277
|
if (msg.ultracode !== undefined) {
|
|
192
|
-
|
|
278
|
+
config.ultracode = msg.ultracode;
|
|
193
279
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] ultracode → ${msg.ultracode ? 'ON (CLI + Workflow + xhigh forced next turn)' : 'OFF'}`);
|
|
194
280
|
}
|
|
195
281
|
// Per-tab Claude Native web budget (server-tool max_uses). Clamp to a sane
|
|
@@ -197,7 +283,7 @@ export async function handleUpdatePrimaryConfig(
|
|
|
197
283
|
// posture picker is for — keep at least 1. Takes effect next turn.
|
|
198
284
|
if (msg.webSearchMaxUses !== undefined) {
|
|
199
285
|
const clamped = Math.max(1, Math.min(50, Math.round(msg.webSearchMaxUses)));
|
|
200
|
-
|
|
286
|
+
config.webSearchMaxUses = clamped;
|
|
201
287
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] web search budget → ${clamped}/turn`);
|
|
202
288
|
}
|
|
203
289
|
|
|
@@ -205,65 +291,65 @@ export async function handleUpdatePrimaryConfig(
|
|
|
205
291
|
// Native tabs only, but stored unconditionally so a transport flip
|
|
206
292
|
// back to Native picks up the operator's last pinned value.
|
|
207
293
|
if (msg.claudeNativeCompact !== undefined) {
|
|
208
|
-
|
|
294
|
+
config.claudeNativeCompact = msg.claudeNativeCompact;
|
|
209
295
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] claude.native.compact updated → ${msg.claudeNativeCompact}`);
|
|
210
296
|
}
|
|
211
297
|
if (msg.claudeNativeForceInterleavedThinkingBeta !== undefined) {
|
|
212
|
-
|
|
298
|
+
config.claudeNativeForceInterleavedThinkingBeta = msg.claudeNativeForceInterleavedThinkingBeta;
|
|
213
299
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] claude.native.force-interleaved-beta updated → ${msg.claudeNativeForceInterleavedThinkingBeta}`);
|
|
214
300
|
}
|
|
215
301
|
// Native Task defaults are captured at the next parent turn.
|
|
216
302
|
if (msg.nativeSubagents !== undefined) {
|
|
217
|
-
if (msg.nativeSubagents === null) delete
|
|
218
|
-
else
|
|
303
|
+
if (msg.nativeSubagents === null) delete config.nativeSubagents;
|
|
304
|
+
else config.nativeSubagents = sanitizeNativeSubagents(msg.nativeSubagents);
|
|
219
305
|
}
|
|
220
306
|
// Adaptive-thinking display. Stored unconditionally so a CLI→Native
|
|
221
307
|
// transport flip picks up the operator's last pinned value; only the
|
|
222
308
|
// Native worker's buildThinkingParams reads it. Takes effect next turn.
|
|
223
309
|
if (msg.claudeNativeThinkingDisplay !== undefined) {
|
|
224
|
-
|
|
310
|
+
config.claudeNativeThinkingDisplay = msg.claudeNativeThinkingDisplay;
|
|
225
311
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] claude.native.thinking-display updated → ${msg.claudeNativeThinkingDisplay}`);
|
|
226
312
|
}
|
|
227
313
|
// NATIVE_COMPACTION_PLAN Phase 3 — opt-in auto-continue after compaction.
|
|
228
314
|
// Stored unconditionally so a transport flip back to Native picks up the
|
|
229
315
|
// operator's last pinned value; only the Native compaction paths read it.
|
|
230
316
|
if (msg.nativeCompactAutoContinue !== undefined) {
|
|
231
|
-
|
|
317
|
+
config.nativeCompactAutoContinue = msg.nativeCompactAutoContinue;
|
|
232
318
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] native.compact.auto-continue updated → ${msg.nativeCompactAutoContinue}`);
|
|
233
319
|
}
|
|
234
320
|
// docs/PROVIDERS.md - Native tool-result filter mode. Stored
|
|
235
321
|
// unconditionally so a CLI→Native transport flip picks up the operator's
|
|
236
322
|
// last pinned value; only honored on Native turns at handleUserMessage.
|
|
237
323
|
if (msg.efficiencyToolFilter !== undefined) {
|
|
238
|
-
|
|
324
|
+
config.efficiencyToolFilter = msg.efficiencyToolFilter;
|
|
239
325
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] efficiency.tool-filter updated → ${msg.efficiencyToolFilter}`);
|
|
240
326
|
}
|
|
241
327
|
// docs/PROVIDERS.md - fact-force first-edit gate. Stored
|
|
242
328
|
// unconditionally so a CLI→Native transport flip picks up the operator's
|
|
243
329
|
// last pinned value; only honored on Native turns at handleUserMessage.
|
|
244
330
|
if (msg.efficiencyFactForce !== undefined) {
|
|
245
|
-
|
|
331
|
+
config.efficiencyFactForce = msg.efficiencyFactForce;
|
|
246
332
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] efficiency.fact-force updated → ${msg.efficiencyFactForce}`);
|
|
247
333
|
}
|
|
248
334
|
// Config-protection write-gate. Stored unconditionally so a CLI→Native
|
|
249
335
|
// transport flip picks up the operator's last pinned value; only honored
|
|
250
336
|
// on Native turns (the gate lives in the Native worker's dispatchTool).
|
|
251
337
|
if (msg.efficiencyConfigProtection !== undefined) {
|
|
252
|
-
|
|
338
|
+
config.efficiencyConfigProtection = msg.efficiencyConfigProtection;
|
|
253
339
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] efficiency.config-protection updated → ${msg.efficiencyConfigProtection}`);
|
|
254
340
|
}
|
|
255
341
|
// docs/PROVIDERS.md - opt-in sandbox tools. Stored
|
|
256
342
|
// unconditionally so a CLI→Native flip picks up the last pinned
|
|
257
343
|
// value; honored only on Native turns at handleUserMessage.
|
|
258
344
|
if (msg.efficiencySandbox !== undefined) {
|
|
259
|
-
|
|
345
|
+
config.efficiencySandbox = msg.efficiencySandbox;
|
|
260
346
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] efficiency.sandbox updated → ${msg.efficiencySandbox}`);
|
|
261
347
|
}
|
|
262
348
|
// docs/PROVIDERS.md - operator-armed durable review gate. Stored unconditionally
|
|
263
349
|
// so a transport flip picks up the last pinned value; honored only on Native
|
|
264
350
|
// turns (the gate lives in the Native worker's dispatchTool).
|
|
265
351
|
if (msg.reviewSafeMode !== undefined) {
|
|
266
|
-
|
|
352
|
+
config.reviewSafeMode = msg.reviewSafeMode;
|
|
267
353
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] review-safe-mode updated → ${msg.reviewSafeMode}`);
|
|
268
354
|
}
|
|
269
355
|
// docs/PROVIDERS.md - operator-armed terseness picker. Stored
|
|
@@ -273,12 +359,12 @@ export async function handleUpdatePrimaryConfig(
|
|
|
273
359
|
// so 0.1.4 never reads a value it does not know.
|
|
274
360
|
const outputStyle = msg.outputStyle !== undefined ? normalizeOutputStyle(msg.outputStyle) : undefined;
|
|
275
361
|
if (outputStyle) {
|
|
276
|
-
|
|
362
|
+
config.outputStyle = outputStyle;
|
|
277
363
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] output-style updated → ${outputStyle}`);
|
|
278
364
|
}
|
|
279
365
|
// docs/GOTCHAS.md - operator-set persistent north-star. Trim + byte-cap;
|
|
280
366
|
// empty / whitespace-only ⇒ clear (delete the field so pre-feature meta.json
|
|
281
|
-
// stays byte-clean). We mutate
|
|
367
|
+
// stays byte-clean). We mutate config now (the next turn reads it) but DEFER
|
|
282
368
|
// the goal_set broadcast until AFTER the meta.json write below — persist-then-
|
|
283
369
|
// announce, so "goal_set observed ⇒ value already durable" holds and a client
|
|
284
370
|
// (or the smoke) that reads meta.json on the event never races the disk write.
|
|
@@ -287,56 +373,24 @@ export async function handleUpdatePrimaryConfig(
|
|
|
287
373
|
let goalBroadcast: { goal: string | null; byteLen: number } | undefined;
|
|
288
374
|
if (msg.goal !== undefined) {
|
|
289
375
|
const capped = capGoal(msg.goal);
|
|
290
|
-
if (capped)
|
|
291
|
-
else delete
|
|
376
|
+
if (capped) config.goal = capped;
|
|
377
|
+
else delete config.goal;
|
|
292
378
|
goalBroadcast = { goal: capped || null, byteLen: capped ? Buffer.byteLength(capped, 'utf8') : 0 };
|
|
293
379
|
}
|
|
294
|
-
// Standing skill pins are a whole-set replacement. Resolve before persisting
|
|
295
|
-
// so malformed / missing references never become durable config, and report
|
|
296
|
-
// current prompt bytes for cost visibility. Bodies remain on disk and are
|
|
297
|
-
// re-read at every turn; this snapshot is only the pin acknowledgement.
|
|
298
|
-
let pinnedSkillsBroadcast: {
|
|
299
|
-
skills: Array<{ scope: 'project' | 'global'; slug: string; name: string }>;
|
|
300
|
-
bytes: number;
|
|
301
|
-
missing: string[];
|
|
302
|
-
} | undefined;
|
|
303
|
-
if (msg.pinnedSkills !== undefined) {
|
|
304
|
-
const requested = uniqueSkillRefs((Array.isArray(msg.pinnedSkills) ? msg.pinnedSkills : []).filter(ref => ref && (ref.scope === 'project' || ref.scope === 'global') && isValidSlug(ref.slug)));
|
|
305
|
-
let resolved;
|
|
306
|
-
try {
|
|
307
|
-
resolved = await withClusterSkillLock(msg.workflowId, async () => {
|
|
308
|
-
await assertWorkflowSkillPins(msg.workflowId, wf.config.workingDirectory, requested);
|
|
309
|
-
const result = await resolvePinnedSkills(requested, wf.config.workingDirectory);
|
|
310
|
-
const refs = result.skills.map(s => ({ scope: s.scope, slug: s.slug }));
|
|
311
|
-
if (refs.length) wf.config.pinnedSkills = refs;
|
|
312
|
-
else delete wf.config.pinnedSkills;
|
|
313
|
-
return result;
|
|
314
|
-
});
|
|
315
|
-
} catch (err) {
|
|
316
|
-
send(ws, { type: 'error', workflowId: msg.workflowId, message: err instanceof Error ? err.message : String(err) });
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
const block = buildPinnedSkillsBlock(resolved.skills);
|
|
320
|
-
pinnedSkillsBroadcast = {
|
|
321
|
-
skills: resolved.skills.map((s) => ({ scope: s.scope, slug: s.slug, name: s.name })),
|
|
322
|
-
bytes: block.bytes,
|
|
323
|
-
missing: [...resolved.missing, ...resolved.truncated],
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
380
|
// REMOTE_MANAGEMENT.md §1.4 — per-workflow hub opt-in (`REMOTE CONTINUATION`).
|
|
327
381
|
// Default OFF. Flipping it re-pushes the hub snapshot + re-broadcasts
|
|
328
382
|
// hub_link_status below so the VPS console and the header monitored-count
|
|
329
383
|
// update immediately.
|
|
330
384
|
let remoteEnabledChanged = false;
|
|
331
|
-
if (msg.remoteEnabled !== undefined && msg.remoteEnabled !==
|
|
332
|
-
|
|
385
|
+
if (msg.remoteEnabled !== undefined && msg.remoteEnabled !== config.remoteEnabled) {
|
|
386
|
+
config.remoteEnabled = msg.remoteEnabled;
|
|
333
387
|
remoteEnabledChanged = true;
|
|
334
388
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] remote-enabled updated → ${msg.remoteEnabled}`);
|
|
335
389
|
}
|
|
336
390
|
// R1 §9.2 — remote-gates arming shares remoteEnabled's re-push semantics so
|
|
337
391
|
// the console's gate buttons track the flip without waiting for the 4s tick.
|
|
338
|
-
if (msg.remoteGatesEnabled !== undefined && msg.remoteGatesEnabled !==
|
|
339
|
-
|
|
392
|
+
if (msg.remoteGatesEnabled !== undefined && msg.remoteGatesEnabled !== config.remoteGatesEnabled) {
|
|
393
|
+
config.remoteGatesEnabled = msg.remoteGatesEnabled;
|
|
340
394
|
remoteEnabledChanged = true;
|
|
341
395
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] remote-gates updated → ${msg.remoteGatesEnabled}`);
|
|
342
396
|
}
|
|
@@ -353,7 +407,7 @@ export async function handleUpdatePrimaryConfig(
|
|
|
353
407
|
// way the effort switch is logged. The next Ollama turn re-prefills its
|
|
354
408
|
// prompt (one-time cost the operator opted into).
|
|
355
409
|
if (msg.ollamaParams !== undefined) {
|
|
356
|
-
|
|
410
|
+
config.ollamaParams = msg.ollamaParams;
|
|
357
411
|
const keys = Object.keys(msg.ollamaParams).join(', ') || '(cleared)';
|
|
358
412
|
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] ollama.params updated → ${keys} (prefix cache invalidates next turn)`);
|
|
359
413
|
}
|
|
@@ -361,24 +415,26 @@ export async function handleUpdatePrimaryConfig(
|
|
|
361
415
|
// Mirror into the wire-facing config too so rehydrate / snapshot reflects the
|
|
362
416
|
// change; fields on WorkflowConfig and PrimaryConfig are the source of
|
|
363
417
|
// truth together (derivePrimaryConfig reads from config).
|
|
364
|
-
if (msg.model !== undefined)
|
|
365
|
-
if (msg.effort !== undefined)
|
|
418
|
+
if (msg.model !== undefined) config.primaryModel = msg.model;
|
|
419
|
+
if (msg.effort !== undefined) config.primaryEffort = msg.effort;
|
|
366
420
|
|
|
367
|
-
const cwd =
|
|
421
|
+
const cwd = config.workingDirectory;
|
|
368
422
|
const hasOtherConfig = Object.keys(msg).some((key) => key !== 'type' && key !== 'workflowId' && key !== 'autoCompaction');
|
|
369
|
-
if (
|
|
423
|
+
if (nativeAccount !== undefined && workflows.get(msg.workflowId) !== wf) return;
|
|
424
|
+
if (cwd && hasOtherConfig && !config.incognito) {
|
|
370
425
|
try {
|
|
371
426
|
const saved = await updateMeta(cwd, msg.workflowId, (meta) => {
|
|
372
427
|
if (msg.model !== undefined) meta.primaryModel = msg.model;
|
|
373
428
|
if (msg.effort !== undefined) meta.primaryEffort = msg.effort;
|
|
374
|
-
if (msg.providerAccountRef !== undefined) meta.providerAccountRef =
|
|
429
|
+
if (msg.providerAccountRef !== undefined) meta.providerAccountRef = config.providerAccountRef;
|
|
375
430
|
if (autoHandoff) meta.autoHandoff = { ...autoHandoff };
|
|
376
431
|
if (msg.autoFold !== undefined) meta.autoFold = { ...msg.autoFold };
|
|
377
432
|
if (msg.codexTransport !== undefined) meta.codexTransport = msg.codexTransport;
|
|
378
433
|
if (msg.codexContextPolicy !== undefined) meta.codexContextPolicy = msg.codexContextPolicy;
|
|
379
|
-
if (msg.claudeTransport !== undefined) meta.claudeTransport =
|
|
434
|
+
if (nativeAccount !== undefined || msg.claudeTransport !== undefined) meta.claudeTransport = config.claudeTransport;
|
|
435
|
+
if (nativeAccount !== undefined && msg.autoCompaction !== undefined) meta.autoCompaction = config.autoCompaction;
|
|
380
436
|
if (msg.ultracode !== undefined) meta.ultracode = msg.ultracode;
|
|
381
|
-
if (msg.webSearchMaxUses !== undefined) meta.webSearchMaxUses =
|
|
437
|
+
if (msg.webSearchMaxUses !== undefined) meta.webSearchMaxUses = config.webSearchMaxUses;
|
|
382
438
|
if (msg.chatWebAccess !== undefined) meta.chatWebAccess = msg.chatWebAccess;
|
|
383
439
|
|
|
384
440
|
if (msg.claudeNativeCompact !== undefined) {
|
|
@@ -392,7 +448,7 @@ export async function handleUpdatePrimaryConfig(
|
|
|
392
448
|
if (msg.claudeNativeForceInterleavedThinkingBeta !== undefined) meta.claudeNativeForceInterleavedThinkingBeta = msg.claudeNativeForceInterleavedThinkingBeta;
|
|
393
449
|
if (msg.nativeSubagents !== undefined) {
|
|
394
450
|
if (msg.nativeSubagents === null) delete meta.nativeSubagents;
|
|
395
|
-
else meta.nativeSubagents =
|
|
451
|
+
else meta.nativeSubagents = config.nativeSubagents;
|
|
396
452
|
}
|
|
397
453
|
if (msg.claudeNativeThinkingDisplay !== undefined) meta.claudeNativeThinkingDisplay = msg.claudeNativeThinkingDisplay;
|
|
398
454
|
if (msg.nativeCompactAutoContinue !== undefined) meta.nativeCompactAutoContinue = msg.nativeCompactAutoContinue;
|
|
@@ -403,14 +459,14 @@ export async function handleUpdatePrimaryConfig(
|
|
|
403
459
|
if (msg.reviewSafeMode !== undefined) meta.reviewSafeMode = msg.reviewSafeMode;
|
|
404
460
|
if (outputStyle) meta.outputStyle = storedOutputStyle(outputStyle);
|
|
405
461
|
if (msg.goal !== undefined) {
|
|
406
|
-
// Mirror the
|
|
462
|
+
// Mirror the config decision above: capped text persists, blank clears.
|
|
407
463
|
const capped = capGoal(msg.goal);
|
|
408
464
|
if (capped) meta.goal = capped;
|
|
409
465
|
else delete meta.goal;
|
|
410
466
|
}
|
|
411
467
|
if (msg.pinnedSkills !== undefined) {
|
|
412
|
-
if (
|
|
413
|
-
meta.pinnedSkills =
|
|
468
|
+
if (config.pinnedSkills?.length) {
|
|
469
|
+
meta.pinnedSkills = config.pinnedSkills.map((s) => ({ ...s }));
|
|
414
470
|
} else {
|
|
415
471
|
delete meta.pinnedSkills;
|
|
416
472
|
}
|
|
@@ -423,15 +479,34 @@ export async function handleUpdatePrimaryConfig(
|
|
|
423
479
|
if (!saved) throw new Error('workflow metadata unavailable');
|
|
424
480
|
} catch (err) {
|
|
425
481
|
console.error(`[arco] [${msg.workflowId.slice(0, 8)}] update_primary_config meta write failed:`, err);
|
|
482
|
+
if (nativeAccount !== undefined) {
|
|
483
|
+
throw new Error('Workflow settings could not be saved. The previous account and settings are still active.');
|
|
484
|
+
}
|
|
426
485
|
const message = 'Workflow settings could not be saved. Changes are temporary for this running tab and may be lost after restart. Retry the save when storage is available.';
|
|
427
486
|
send(ws, { type: 'error', workflowId: msg.workflowId, message });
|
|
428
487
|
broadcastWorkflow(msg.workflowId, { type: 'system_notice', workflowId: msg.workflowId, content: message });
|
|
429
|
-
if (!wf.bootMaterialized) broadcastTransient(msg.workflowId, { type: 'workflow_config_synced', workflowId: msg.workflowId, config
|
|
488
|
+
if (!wf.bootMaterialized) broadcastTransient(msg.workflowId, { type: 'workflow_config_synced', workflowId: msg.workflowId, config });
|
|
430
489
|
if (remoteEnabledChanged) refreshHubReporting();
|
|
431
490
|
return;
|
|
432
491
|
}
|
|
433
492
|
}
|
|
434
493
|
|
|
494
|
+
if (nativeAccount !== undefined) {
|
|
495
|
+
if (workflows.get(msg.workflowId) !== wf) return;
|
|
496
|
+
wf.config = config;
|
|
497
|
+
wf.primary = primary;
|
|
498
|
+
if (autoHandoff) applyAutoHandoff();
|
|
499
|
+
if (msg.autoFold !== undefined) wf.autoFold = deriveAutoFold(config);
|
|
500
|
+
applyClaudeTransportWatcher(ws, msg.workflowId, wf);
|
|
501
|
+
await disposeProviderResources(msg.workflowId).catch((err) => {
|
|
502
|
+
console.error('Could not dispose previous provider resources:', err);
|
|
503
|
+
});
|
|
504
|
+
if (msg.autoCompaction !== undefined && (config.autoCompaction?.enabled !== previousCompaction?.enabled
|
|
505
|
+
|| config.autoCompaction?.thresholdPercent !== previousCompaction?.thresholdPercent)) {
|
|
506
|
+
announceAutoCompaction(msg.workflowId, config.autoCompaction);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
435
510
|
// Persist-then-announce (see the north-star note above): the meta.json write
|
|
436
511
|
// is durable now, so emit the goal_set event. Storage failures return above with an explicit temporary-setting notice.
|
|
437
512
|
if (goalBroadcast) {
|
|
@@ -483,8 +558,31 @@ export async function handleUpdatePrimaryConfig(
|
|
|
483
558
|
// config replayed after later non-config edits would regress the job; a
|
|
484
559
|
// reconnecting browser takes the live config from workspace_snapshot instead.
|
|
485
560
|
if (!wf.bootMaterialized) {
|
|
486
|
-
broadcastTransient(msg.workflowId, { type: 'workflow_config_synced', workflowId: msg.workflowId, config
|
|
561
|
+
broadcastTransient(msg.workflowId, { type: 'workflow_config_synced', workflowId: msg.workflowId, config });
|
|
487
562
|
}
|
|
488
563
|
|
|
489
|
-
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] primary updated → ${
|
|
564
|
+
console.log(`[arco] [${msg.workflowId.slice(0, 8)}] primary updated → ${primary.provider}:${primary.model}@${primary.effort}`);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function announceAutoCompaction(workflowId: string, next: WorkflowState['config']['autoCompaction']): void {
|
|
568
|
+
broadcastWorkflow(workflowId, { type: 'system_notice', workflowId,
|
|
569
|
+
content: next ? `[AUTO-COMPACT] Worker policy ${next.enabled ? `enabled at ${next.thresholdPercent}%` : 'disabled'}.` : '[AUTO-COMPACT] Worker policy cleared; cluster or legacy behavior applies.' });
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
function applyClaudeTransportWatcher(ws: WebSocket, workflowId: string, wf: WorkflowState): void {
|
|
573
|
+
// The CLI-session JSONL watcher is CLI-transport-only (a Native tab's
|
|
574
|
+
// transcript truth is events.jsonl; watching a stale CLI file painted
|
|
575
|
+
// calibration-probe entries over real answers). A live
|
|
576
|
+
// swap must move the watcher NOW, not at the next restart: stop it on the
|
|
577
|
+
// native direction, (re)start it on the cli direction — nothing on the
|
|
578
|
+
// normal turn path starts it (only create/rehydrate and handoff rotation
|
|
579
|
+
// do), so without this a cli→native→cli round trip leaves it dead.
|
|
580
|
+
if (wf.config.claudeTransport === 'native') {
|
|
581
|
+
if (wf.sessionWatcher) {
|
|
582
|
+
try { wf.sessionWatcher(); } catch { /* already disposed */ }
|
|
583
|
+
wf.sessionWatcher = null;
|
|
584
|
+
}
|
|
585
|
+
} else if (wf.config.workingDirectory) {
|
|
586
|
+
startSessionWatcher(workflowId, wf, wf.config.workingDirectory, ws);
|
|
587
|
+
}
|
|
490
588
|
}
|