arco-workbench 0.1.5 → 0.1.6
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 +9 -0
- package/README.md +11 -4
- package/client/dist/assets/{PhosphorBackdrop-D6cbmLNY.js → PhosphorBackdrop-BR-TgB5x.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-2dyerOi4.js → ThemedBackgroundShaderImpl-DgcFj6JN.js} +1 -1
- package/client/dist/assets/{XtermView-AIwo7O3D.js → XtermView-CflVBQgC.js} +1 -1
- package/client/dist/assets/{galleryEditor-DXAuxS8D.js → galleryEditor-BB-emfmi.js} +1 -1
- package/client/dist/assets/{index-8j6p-pmQ.js → index-B_EqHDz3.js} +242 -240
- package/client/dist/index.html +1 -1
- package/client/src/alerts/desktopAlerts.ts +13 -0
- package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +28 -5
- package/client/src/components/ClusterRightPanel/MemberRow.tsx +1 -1
- package/client/src/components/ClusterTaskBoardTab.tsx +54 -3
- package/client/src/components/ContextMeter.tsx +7 -0
- package/client/src/components/Home/HomeView.tsx +1 -1
- package/client/src/components/NeedsYouBadge.tsx +31 -16
- package/client/src/components/OperatorQuestionNotice.tsx +10 -1
- package/client/src/components/ProvidersPopover.tsx +23 -12
- package/client/src/components/TabBar.tsx +11 -8
- package/client/src/components/TabStatusChip.tsx +8 -7
- package/client/src/components/clusterNeedsYou.ts +27 -8
- package/client/src/help/content/cluster.tsx +34 -22
- package/client/src/help/content/composer.tsx +8 -1
- package/client/src/help/content/header.tsx +22 -13
- package/client/src/help/content/misc.tsx +8 -0
- package/client/src/help/content/tabbar.tsx +2 -1
- package/client/src/help/manualSections/clusters.tsx +61 -18
- package/client/src/help/manualSections/gettingStarted.tsx +10 -0
- package/client/src/help/manualSections/maintenance.tsx +38 -8
- package/client/src/help/manualSections/providers.tsx +10 -3
- package/client/src/help/manualSections/reference.tsx +1 -1
- package/client/src/help/manualSections/workflows.tsx +13 -0
- package/client/src/help/manualSections/workspace.tsx +7 -1
- package/client/src/questions/waitingQuestion.ts +3 -2
- package/client/src/stores/appStore.ts +1 -1
- package/client/src/stores/appStore.types.ts +1 -0
- package/client/src/stores/notificationStore.ts +2 -0
- package/client/src/utils/activityPresentation.ts +1 -1
- package/client/src/utils/tabStatus.ts +8 -0
- package/client/src/voice/commands.ts +4 -3
- package/client/src/voice/executor.ts +3 -3
- package/client/src/ws/handleServerMessage.ts +22 -2
- package/client/src/ws/operatorQuestions.ts +2 -0
- package/docs/CLIENT.md +3 -3
- package/docs/FEATURES.md +1 -1
- package/docs/GETTING_STARTED.md +11 -5
- package/docs/GLOSSARY.md +6 -2
- package/docs/GOTCHAS.md +17 -5
- package/docs/OPERATIONS.md +184 -5
- package/docs/PERSISTENCE.md +4 -0
- package/docs/PRIMITIVES.md +1 -1
- package/docs/PROTOCOL.md +1 -1
- package/docs/PROTOCOL_CLUSTER.md +9 -5
- package/docs/PROVIDERS.md +10 -5
- package/docs/SETTINGS.md +4 -2
- package/docs/TASK_LEDGER.md +6 -0
- package/docs/VOICE.md +2 -0
- package/native/win32-arm64/manifest.json +1 -1
- package/node_modules/@arco/shared/dist/clusterRolePresets.d.ts +1 -1
- package/node_modules/@arco/shared/dist/clusterRolePresets.js +10 -0
- package/node_modules/@arco/shared/dist/protocol/autoPickup.js +9 -1
- package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +2 -2
- package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -0
- package/node_modules/@arco/shared/dist/protocol/notifications.d.ts +4 -0
- package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +12 -0
- package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +9 -3
- package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +2 -2
- package/scripts/packaging/arco.mjs +1 -0
- package/server/dist/attention.d.ts +1 -1
- package/server/dist/attention.js +6 -4
- package/server/dist/capabilities.d.ts +9 -8
- package/server/dist/capabilities.js +71 -102
- package/server/dist/cliUpdateDecision.d.ts +34 -0
- package/server/dist/cliUpdateDecision.js +152 -0
- package/server/dist/clusterDirector.js +1 -0
- package/server/dist/clusterPeerOps.js +2 -2
- package/server/dist/defaults/models.md +1 -1
- package/server/dist/fileAccessPolicy.js +7 -5
- package/server/dist/http/workflowDataRoutes.js +1 -1
- package/server/dist/index.js +5 -1
- package/server/dist/primitives/seedWorker.d.ts +1 -0
- package/server/dist/primitives/seedWorker.js +2 -1
- package/server/dist/providerConversation.d.ts +9 -0
- package/server/dist/providerConversation.js +80 -0
- package/server/dist/providers/claude-native/retainedContext.d.ts +4 -0
- package/server/dist/providers/claude-native/retainedContext.js +20 -0
- package/server/dist/providers/claude-native/worker.d.ts +1 -0
- package/server/dist/providers/claude-native/worker.js +34 -6
- package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -0
- package/server/dist/providers/codex-appserver/operatorQuestions.js +30 -0
- package/server/dist/providers/codex-appserver/worker.js +9 -4
- package/server/dist/providers/ollama.js +2 -3
- package/server/dist/server/broadcast.d.ts +1 -1
- package/server/dist/smartPickupAdapters.d.ts +1 -0
- package/server/dist/smartPickupAdapters.js +18 -5
- package/server/dist/smartPickupObserver.js +45 -8
- package/server/dist/workers/WorkerManager.d.ts +1 -0
- package/server/dist/workers/WorkerManager.js +1 -0
- package/server/dist/workers/limits.js +6 -2
- package/server/dist/workflowMeta.d.ts +11 -1
- package/server/dist/workflowMeta.js +132 -6
- package/server/dist/workflows/types.d.ts +1 -0
- package/server/dist/ws/compactHandlers.d.ts +1 -1
- package/server/dist/ws/compactHandlers.js +11 -4
- package/server/dist/ws/handoffHandlers.js +16 -6
- package/server/dist/ws/operatorQuestionHandlers.d.ts +2 -1
- package/server/dist/ws/operatorQuestionHandlers.js +9 -1
- package/server/dist/ws/turnEngine.d.ts +2 -4
- package/server/dist/ws/turnEngine.js +88 -129
- package/server/package.json +1 -1
- package/server/src/attention.ts +5 -4
- package/server/src/capabilities.ts +70 -111
- package/server/src/cliUpdateDecision.ts +159 -0
- package/server/src/clusterDirector.ts +1 -0
- package/server/src/clusterPeerOps.ts +2 -2
- package/server/src/defaults/models.md +1 -1
- package/server/src/fileAccessPolicy.ts +7 -5
- package/server/src/http/workflowDataRoutes.ts +1 -1
- package/server/src/index.ts +5 -1
- package/server/src/primitives/seedWorker.ts +3 -1
- package/server/src/providerConversation.ts +71 -0
- package/server/src/providers/claude-native/retainedContext.ts +22 -0
- package/server/src/providers/claude-native/worker.ts +33 -5
- package/server/src/providers/codex-appserver/operatorQuestions.ts +24 -0
- package/server/src/providers/codex-appserver/worker.ts +8 -4
- package/server/src/providers/ollama.ts +2 -3
- package/server/src/smartPickupAdapters.ts +19 -5
- package/server/src/smartPickupObserver.ts +31 -6
- package/server/src/workers/WorkerManager.ts +2 -0
- package/server/src/workers/limits.ts +7 -2
- package/server/src/workflowMeta.ts +139 -5
- package/server/src/workflows/types.ts +1 -0
- package/server/src/ws/compactHandlers.ts +9 -3
- package/server/src/ws/handoffHandlers.ts +13 -6
- package/server/src/ws/operatorQuestionHandlers.ts +10 -2
- package/server/src/ws/turnEngine.ts +80 -135
- package/shared/dist/clusterRolePresets.d.ts +1 -1
- package/shared/dist/clusterRolePresets.js +10 -0
- package/shared/dist/protocol/autoPickup.js +9 -1
- package/shared/dist/protocol/clientMessages.d.ts +2 -2
- package/shared/dist/protocol/models.d.ts +6 -0
- package/shared/dist/protocol/notifications.d.ts +4 -0
- package/shared/dist/protocol/operatorQuestions.d.ts +12 -0
- package/shared/dist/protocol/serverMessages.d.ts +9 -3
- package/shared/dist/protocol/workflows.d.ts +1 -0
- package/shared/src/clusterRolePresets.ts +11 -1
- package/shared/src/protocol/autoPickup.ts +9 -1
- package/shared/src/protocol/clientMessages.ts +2 -1
- package/shared/src/protocol/models.ts +5 -2
- package/shared/src/protocol/notifications.ts +5 -0
- package/shared/src/protocol/operatorQuestions.ts +13 -0
- package/shared/src/protocol/serverMessages.ts +12 -2
- package/shared/src/protocol/workflows.ts +4 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { ensureWorkflowMetadata, providerConversationState, saveProviderSession, announceReplacementConversation, markConversationReading } from '../providerConversation.js';
|
|
1
2
|
import { mintHandoffHistoryCapability } from '../http/handoffHistoryRoutes.js';
|
|
2
3
|
import { deliverAfterTurnRevoked } from './taskLifecycle.js';
|
|
3
4
|
import { resolveClaudeTransport } from '../claudeTransport.js';
|
|
4
5
|
import { projectLocalFileReferences } from '../primitives/localFileContext.js';
|
|
5
6
|
import { getEffectivePublicProjectChoice } from '../publicProjectChoice.js';
|
|
6
|
-
import { buildMessageGuardPolicy
|
|
7
|
+
import { buildMessageGuardPolicy } from '@arco/shared';
|
|
7
8
|
import * as attention from '../attention.js';
|
|
8
9
|
import { acquireCheckoutWriter, assertCheckoutAvailable, workflowWritePaths, observeCheckoutWriters } from '../checkoutOwnership.js';
|
|
9
10
|
import { randomUUID } from 'node:crypto';
|
|
@@ -15,7 +16,7 @@ import { watchClaimed, watchSettled } from '../voice/watches.js';
|
|
|
15
16
|
import { renderComputerHistory } from '../voice/history.js';
|
|
16
17
|
import { computerReplayEvents, announceComputerSettled } from '../voice/computerContext.js';
|
|
17
18
|
import { COMPUTER_TIMEOUT } from '../voice/turnWatchdog.js';
|
|
18
|
-
import { AUTO_HANDOFF_DEFAULT_COMPACTIONS, autoHandoffAvailability, clampAutoHandoffCompactions,
|
|
19
|
+
import { AUTO_HANDOFF_DEFAULT_COMPACTIONS, autoHandoffAvailability, clampAutoHandoffCompactions, normalizeAutoHandoff, resolveProviderAutoCompaction } from '@arco/shared';
|
|
19
20
|
import { compactionsThisConversation } from '../compactionCounter.js';
|
|
20
21
|
import { WebSocket } from 'ws';
|
|
21
22
|
import { discoverClaudeMdFiles } from '../claudeMdDiscovery.js';
|
|
@@ -67,7 +68,7 @@ import { readSettings } from '../settings.js';
|
|
|
67
68
|
import { buildPickedSkillsBlock, buildPinnedSkillsBlock, resolvePinnedSkills, buildSkillsManifest, listSkills, readSkillBody, readBuiltinSkill, } from '../skills.js';
|
|
68
69
|
import { ARCHITECTURE_REVIEW_SLUG, architectureReviewFacts } from '../architectureReview.js';
|
|
69
70
|
import { artifactsDir } from '../workers/limits.js';
|
|
70
|
-
import {
|
|
71
|
+
import { readMeta, updateMeta, workflowDir } from '../workflowMeta.js';
|
|
71
72
|
import { currentSeq as currentWorkflowSeq, replayEvents as replayWorkflowEvents } from '../workflowStore.js';
|
|
72
73
|
import { latestCodexTokenSnapshot } from '../workflows/transcripts.js';
|
|
73
74
|
import { foldClaudeNativeWorker } from '../providers/claude-native/index.js';
|
|
@@ -450,6 +451,33 @@ const storageMigrations = new WeakSet();
|
|
|
450
451
|
const incomingMessages = new WeakMap();
|
|
451
452
|
const lastBusyClaim = new WeakMap();
|
|
452
453
|
const busyRevocations = new WeakMap();
|
|
454
|
+
const requeuedSteerDrains = new WeakMap();
|
|
455
|
+
function hasRequeuedSteerDrain(wf) {
|
|
456
|
+
return requeuedSteerDrains.get(wf)?.epoch === (busyRevocations.get(wf) ?? 0);
|
|
457
|
+
}
|
|
458
|
+
function resumeRequeuedSteer(workflowId, wf) {
|
|
459
|
+
const pending = requeuedSteerDrains.get(wf);
|
|
460
|
+
if (!pending)
|
|
461
|
+
return;
|
|
462
|
+
if (workflows.get(workflowId) !== wf || pending.epoch !== (busyRevocations.get(wf) ?? 0)
|
|
463
|
+
|| (wf.queue.steering.length === 0 && wf.queue.followUp.length === 0)) {
|
|
464
|
+
requeuedSteerDrains.delete(wf);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
// Existing or incoming turns own the next admission. Their finalizer will
|
|
468
|
+
// try again; a later operator send stays queued during this preparation.
|
|
469
|
+
if (pending.active || wf.busy || wf.primaryTurn || wf.computerResetting || incomingMessages.get(wf))
|
|
470
|
+
return;
|
|
471
|
+
pending.active = true;
|
|
472
|
+
void drainQueueIfIdle(workflowId).catch((err) => {
|
|
473
|
+
console.error(`[arco] [${workflowId.slice(0, 8)}] re-queued steer drain failed:`, err);
|
|
474
|
+
}).finally(() => {
|
|
475
|
+
pending.active = false;
|
|
476
|
+
if (requeuedSteerDrains.get(wf) === pending && (pending.epoch !== (busyRevocations.get(wf) ?? 0)
|
|
477
|
+
|| (wf.queue.steering.length === 0 && wf.queue.followUp.length === 0)))
|
|
478
|
+
requeuedSteerDrains.delete(wf);
|
|
479
|
+
});
|
|
480
|
+
}
|
|
453
481
|
export function publishWorkerActivity(wf, kind) {
|
|
454
482
|
if (wf.config?.incognito || wf.config?.kind === 'chat' || wf.config?.voiceOperator)
|
|
455
483
|
return;
|
|
@@ -813,15 +841,27 @@ export async function maybeAutoCompactPolicy(workflowId, wf, cwd, policy, readin
|
|
|
813
841
|
return false;
|
|
814
842
|
let state = policyAttempts.get(wf);
|
|
815
843
|
if (!state || state.sessionId !== reading.sessionId || state.provider !== reading.provider) {
|
|
816
|
-
state = { sessionId: reading.sessionId, provider: reading.provider, fired: false };
|
|
844
|
+
state = { sessionId: reading.sessionId, provider: reading.provider, fired: false, awaitingReading: false, highAfterSuccess: 0 };
|
|
817
845
|
policyAttempts.set(wf, state);
|
|
818
846
|
}
|
|
819
|
-
if (reading.percent < policy.thresholdPercent
|
|
820
|
-
state.
|
|
821
|
-
|
|
847
|
+
if (reading.percent < policy.thresholdPercent) {
|
|
848
|
+
state.awaitingReading = false;
|
|
849
|
+
if (reading.percent < policy.thresholdPercent - 5)
|
|
850
|
+
state.fired = false;
|
|
851
|
+
state.highAfterSuccess = 0;
|
|
822
852
|
return false;
|
|
823
|
-
|
|
824
|
-
|
|
853
|
+
}
|
|
854
|
+
if (state.awaitingReading) {
|
|
855
|
+
state.awaitingReading = false;
|
|
856
|
+
state.highAfterSuccess++;
|
|
857
|
+
if (state.highAfterSuccess === 3) {
|
|
858
|
+
broadcastWorkflow(workflowId, { type: 'system_notice', workflowId, content: `Automatic compaction has run after each of the last 3 turns and the context is still at or above the ${policy.thresholdPercent}% threshold at turn end. It keeps running. If the turns are simply large this is expected; otherwise raise the threshold or use HANDOFF.` });
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
if (state.fired)
|
|
862
|
+
return false;
|
|
863
|
+
// Prevent retries of an unsuccessful compact until a later valid reading
|
|
864
|
+
// confirms a drop. Mark before awaiting any external work.
|
|
825
865
|
state.fired = true;
|
|
826
866
|
const observedClaim = expectedClaim;
|
|
827
867
|
const obs = ws ?? anyObserver(workflowId);
|
|
@@ -836,7 +876,12 @@ export async function maybeAutoCompactPolicy(workflowId, wf, cwd, policy, readin
|
|
|
836
876
|
if (wf.busy || lastBusyClaim.get(wf) !== observedClaim || wf.primarySessionId !== reading.sessionId || wf.primary.provider !== reading.provider || !current?.enabled || current.thresholdPercent !== policy.thresholdPercent)
|
|
837
877
|
return false;
|
|
838
878
|
return claim();
|
|
839
|
-
}, `context ${reading.percent}% >= ${policy.thresholdPercent}
|
|
879
|
+
}, `context ${reading.percent}% >= ${policy.thresholdPercent}%`, () => {
|
|
880
|
+
if (policyAttempts.get(wf) === state) {
|
|
881
|
+
state.fired = false;
|
|
882
|
+
state.awaitingReading = true;
|
|
883
|
+
}
|
|
884
|
+
});
|
|
840
885
|
return true;
|
|
841
886
|
}
|
|
842
887
|
export async function runExplicitContextActions(workflowId, wf, cwd, policy, reading, busyToken, ws, session) {
|
|
@@ -1214,122 +1259,18 @@ export function requeueSteerForWorker(workflowId, ws, items, bucket) {
|
|
|
1214
1259
|
// is preferable to flicker-restoring it; the queue strip is the source of
|
|
1215
1260
|
// truth for "items waiting" and the re-broadcast above repopulates it.
|
|
1216
1261
|
console.log(`[arco] [${workflowId.slice(0, 8)}] mid-turn steer re-queued (bucket=${bucket}, items=${items.length})`);
|
|
1262
|
+
if (!wf.busy) {
|
|
1263
|
+
const epoch = busyRevocations.get(wf) ?? 0;
|
|
1264
|
+
if (!hasRequeuedSteerDrain(wf))
|
|
1265
|
+
requeuedSteerDrains.set(wf, { epoch, active: false });
|
|
1266
|
+
resumeRequeuedSteer(workflowId, wf);
|
|
1267
|
+
}
|
|
1217
1268
|
// ws is unused today (no per-originator notification); keep the parameter
|
|
1218
1269
|
// for parity with drainSteerForWorker so future per-tab signaling can wire
|
|
1219
1270
|
// through here without re-threading the call sites.
|
|
1220
1271
|
void ws;
|
|
1221
1272
|
}
|
|
1222
|
-
export
|
|
1223
|
-
// Cheap unlocked probe first (the common resume case); the actual seed goes
|
|
1224
|
-
// through ensureMeta so a check-then-write can't clobber a concurrent
|
|
1225
|
-
// updateMeta landing between the two.
|
|
1226
|
-
const existing = await readMeta(cwd, workflowId);
|
|
1227
|
-
if (existing)
|
|
1228
|
-
return;
|
|
1229
|
-
const now = Date.now();
|
|
1230
|
-
const meta = {
|
|
1231
|
-
workflowId,
|
|
1232
|
-
name: config.name,
|
|
1233
|
-
cwd,
|
|
1234
|
-
...(config.kind === 'chat' ? { kind: 'chat' } : {}),
|
|
1235
|
-
...(config.kind === 'chat' && config.voiceOperator === true ? { voiceOperator: true } : {}),
|
|
1236
|
-
createdAt: now,
|
|
1237
|
-
lastActiveAt: now,
|
|
1238
|
-
primaryProvider: primary.provider,
|
|
1239
|
-
primaryModel: primary.model,
|
|
1240
|
-
primaryEffort: primary.effort,
|
|
1241
|
-
...(config.providerAccountRef ? { providerAccountRef: config.providerAccountRef } : {}),
|
|
1242
|
-
cliSessions: [],
|
|
1243
|
-
operator: 'local',
|
|
1244
|
-
lastEventSeq: null,
|
|
1245
|
-
lastTranscriptSeq: null,
|
|
1246
|
-
compactedAt: null,
|
|
1247
|
-
...(config.pinnedSkills?.length
|
|
1248
|
-
? { pinnedSkills: config.pinnedSkills.map((s) => ({ scope: s.scope, slug: s.slug })) }
|
|
1249
|
-
: {}),
|
|
1250
|
-
...(opts?.parentWorkflowId ? { parentWorkflowId: opts.parentWorkflowId } : {}),
|
|
1251
|
-
// docs/PROVIDERS.md / docs/PROVIDERS.md - when the New-tab
|
|
1252
|
-
// picker (or Spawn-from-here parent inheritance) provided a non-default
|
|
1253
|
-
// value, persist it to disk on the very first meta write so a server
|
|
1254
|
-
// restart before the operator's first turn doesn't lose the pick.
|
|
1255
|
-
// Sanitized one more time at write-site against unknown values reaching
|
|
1256
|
-
// disk via a hand-edited cascade default.
|
|
1257
|
-
...(config.efficiencyToolFilter === 'off' || config.efficiencyToolFilter === 'conservative' || config.efficiencyToolFilter === 'aggressive'
|
|
1258
|
-
? { efficiencyToolFilter: config.efficiencyToolFilter }
|
|
1259
|
-
: {}),
|
|
1260
|
-
// docs/PROVIDERS.md - persist the stamped new-tab default or
|
|
1261
|
-
// an explicit operator choice on the first meta write.
|
|
1262
|
-
...(config.efficiencyFactForce === 'on' || config.efficiencyFactForce === 'off'
|
|
1263
|
-
? { efficiencyFactForce: config.efficiencyFactForce }
|
|
1264
|
-
: {}),
|
|
1265
|
-
// Persist an explicit config-protection choice to disk on first meta-write
|
|
1266
|
-
// so an operator opt-out survives a restart. Absent ⇒ gate ON by default.
|
|
1267
|
-
...(config.efficiencyConfigProtection === 'on' || config.efficiencyConfigProtection === 'off'
|
|
1268
|
-
? { efficiencyConfigProtection: config.efficiencyConfigProtection }
|
|
1269
|
-
: {}),
|
|
1270
|
-
...(typeof config.claudeNativeCompact === 'boolean'
|
|
1271
|
-
? {
|
|
1272
|
-
claudeNativeCompact: config.claudeNativeCompact,
|
|
1273
|
-
...(config.claudeNativeCompact === true ? { claudeNativeCompactUserSetAt: now } : {}),
|
|
1274
|
-
}
|
|
1275
|
-
: {}),
|
|
1276
|
-
...(typeof config.claudeNativeForceInterleavedThinkingBeta === 'boolean'
|
|
1277
|
-
? { claudeNativeForceInterleavedThinkingBeta: config.claudeNativeForceInterleavedThinkingBeta }
|
|
1278
|
-
: {}),
|
|
1279
|
-
nativeSubagents: config.nativeSubagents,
|
|
1280
|
-
claudeNativeTaskDisabled: config.claudeNativeTaskDisabled,
|
|
1281
|
-
...(config.claudeNativeThinkingDisplay === 'omitted' || config.claudeNativeThinkingDisplay === 'summarized' || config.claudeNativeThinkingDisplay === 'updates'
|
|
1282
|
-
? { claudeNativeThinkingDisplay: config.claudeNativeThinkingDisplay }
|
|
1283
|
-
: {}),
|
|
1284
|
-
...(config.codexTransport === 'exec' || config.codexTransport === 'appserver'
|
|
1285
|
-
? { codexTransport: config.codexTransport }
|
|
1286
|
-
: {}),
|
|
1287
|
-
...(config.codexContextPolicy === 'max' || config.codexContextPolicy === 'standard'
|
|
1288
|
-
? { codexContextPolicy: config.codexContextPolicy }
|
|
1289
|
-
: {}),
|
|
1290
|
-
...(config.claudeTransport === 'cli' || config.claudeTransport === 'native'
|
|
1291
|
-
? { claudeTransport: config.claudeTransport }
|
|
1292
|
-
: {}),
|
|
1293
|
-
// Persist the seeded auto-handoff default on the first meta-write so a
|
|
1294
|
-
// server restart before the operator's first turn keeps the global
|
|
1295
|
-
// default (handleCreateWorkflow bakes it into config for new tabs). The
|
|
1296
|
-
// savedMeta restore in handleCreateWorkflow reads this back.
|
|
1297
|
-
...(isAutoCompactionPolicy(config.autoCompaction) ? { autoCompaction: { ...config.autoCompaction } } : {}),
|
|
1298
|
-
...(config.autoHandoff ? { autoHandoff: { ...config.autoHandoff } } : {}),
|
|
1299
|
-
// docs/PROVIDERS.md - persist the sandbox toggle on the
|
|
1300
|
-
// first meta-write when the cascade default supplied a non-undefined
|
|
1301
|
-
// value. Default is 'off'; only the explicit on/off pair lands here so
|
|
1302
|
-
// a stale cascade doesn't accidentally turn the sandbox on for tabs
|
|
1303
|
-
// that were never asked.
|
|
1304
|
-
...(config.efficiencySandbox === 'on' || config.efficiencySandbox === 'off'
|
|
1305
|
-
? { efficiencySandbox: config.efficiencySandbox }
|
|
1306
|
-
: {}),
|
|
1307
|
-
// docs/PROVIDERS.md - persist the review-gate toggle on the first meta-write
|
|
1308
|
-
// when the cascade default supplied an explicit value, so an operator opt-in
|
|
1309
|
-
// survives a restart before the first turn. Default 'off'.
|
|
1310
|
-
...(config.reviewSafeMode === 'on' || config.reviewSafeMode === 'off'
|
|
1311
|
-
? { reviewSafeMode: config.reviewSafeMode }
|
|
1312
|
-
: {}),
|
|
1313
|
-
// Only a style other than the default is written; unset means
|
|
1314
|
-
// DEFAULT_OUTPUT_STYLE. Legacy `lite` / `caveman` from a stale client are
|
|
1315
|
-
// written as `plain` / `terse` (plain being the default, it stays unset).
|
|
1316
|
-
...(storedOutputStyle(config.outputStyle) ? { outputStyle: storedOutputStyle(config.outputStyle) } : {}),
|
|
1317
|
-
// docs/GOTCHAS.md - persist a north-star seeded before the first turn
|
|
1318
|
-
// (e.g. a Spawn-from-here that inherited the parent's) so it survives a
|
|
1319
|
-
// restart even if the operator never re-sets it. Blank ⇒ omitted.
|
|
1320
|
-
...(config.goal && config.goal.trim() ? { goal: config.goal } : {}),
|
|
1321
|
-
// docs/PROVIDERS.md - persist sticky ultracode on the first meta-write so a
|
|
1322
|
-
// tab left in ultracode survives a restart (the rehydrate read in
|
|
1323
|
-
// workflowHandlers.ts expects saved.ultracode). Without this the flag lives
|
|
1324
|
-
// only in-memory and the tab silently drops out of ultracode on restart.
|
|
1325
|
-
...(config.ultracode === true ? { ultracode: true } : {}),
|
|
1326
|
-
...(typeof config.webSearchMaxUses === 'number' ? { webSearchMaxUses: config.webSearchMaxUses } : {}),
|
|
1327
|
-
...(config.managedWorktreeSourceCwd
|
|
1328
|
-
? { managedWorktreeSourceCwd: config.managedWorktreeSourceCwd }
|
|
1329
|
-
: {}),
|
|
1330
|
-
};
|
|
1331
|
-
await ensureMeta(cwd, meta);
|
|
1332
|
-
}
|
|
1273
|
+
export { persistInitialMeta } from '../workflowMeta.js';
|
|
1333
1274
|
export async function writeCalibrationToMeta(cwd, workflowId, ratio, overhead, lastGroundTruth) {
|
|
1334
1275
|
// Locked RMW — calibration lands post-turn, concurrently with plan-prefix /
|
|
1335
1276
|
// chat-preview / handler meta writes; an unlocked read→write drops theirs.
|
|
@@ -1515,9 +1456,9 @@ opts) {
|
|
|
1515
1456
|
// per provider.
|
|
1516
1457
|
if (opts?.busyOnly && (!wf.busy || wf.computerResetting || lastBusyClaim.get(wf) !== busyOnlyClaim || (opts.busyOnlyGuard && !opts.busyOnlyGuard())))
|
|
1517
1458
|
return;
|
|
1518
|
-
if (opts?.claimGuard && (wf.busy || wf.computerResetting))
|
|
1459
|
+
if (opts?.claimGuard && (wf.busy || wf.computerResetting || hasRequeuedSteerDrain(wf)))
|
|
1519
1460
|
return;
|
|
1520
|
-
if (wf.busy || wf.computerResetting) {
|
|
1461
|
+
if (wf.busy || wf.computerResetting || (!fromQueue && hasRequeuedSteerDrain(wf))) {
|
|
1521
1462
|
if (primitive === 'plan-review') {
|
|
1522
1463
|
send(ws, { type: 'system_notice', workflowId, content: '[PLAN DRAFT NOT STARTED] Wait for the current turn to finish, then try again.' });
|
|
1523
1464
|
return;
|
|
@@ -1867,10 +1808,19 @@ opts) {
|
|
|
1867
1808
|
if (providerAccount?.profile.id && wf.config.providerAccountRef !== providerAccount.profile.id) {
|
|
1868
1809
|
wf.config.providerAccountRef = providerAccount.profile.id;
|
|
1869
1810
|
}
|
|
1811
|
+
if (!incognito) {
|
|
1812
|
+
await ensureWorkflowMetadata(cwd, workflowId, wf);
|
|
1813
|
+
wf.providerConversation = await providerConversationState(cwd, workflowId, wf);
|
|
1814
|
+
if (wf.providerConversation)
|
|
1815
|
+
broadcastTransient(workflowId, { type: 'provider_conversation_state', workflowId, state: wf.providerConversation });
|
|
1816
|
+
}
|
|
1817
|
+
let sessionSave = Promise.resolve();
|
|
1818
|
+
let hasFreshContextReading = false;
|
|
1870
1819
|
let activeTurnObservation;
|
|
1871
1820
|
try {
|
|
1872
1821
|
while (true) {
|
|
1873
1822
|
primaryTurn.clusterDispatch = undefined;
|
|
1823
|
+
hasFreshContextReading = false;
|
|
1874
1824
|
const pickedSkillsBlock = await resolvePickedSkillsBlock(promptPickedSkills);
|
|
1875
1825
|
console.log(`[arco] [${workflowId.slice(0, 8)}] user_message received; starting primary turn (${wf.primary.provider}:${wf.primary.model}, resume=${wf.primarySessionId?.slice(0, 8) || 'none'})`);
|
|
1876
1826
|
// Peer mailbox: don't auto-drain pre-turn. Just count what's pending and
|
|
@@ -2540,6 +2490,9 @@ opts) {
|
|
|
2540
2490
|
// A Task child's final status still belongs to the card after STOP.
|
|
2541
2491
|
if (!dispatchCurrent() && !deliverAfterTurnRevoked(msg))
|
|
2542
2492
|
return;
|
|
2493
|
+
if (msg.type === 'primary_complete' && msg.tokens
|
|
2494
|
+
&& msg.tokens.input + (msg.tokens.cacheRead ?? 0) + (msg.tokens.cacheCreate ?? 0) > 0)
|
|
2495
|
+
hasFreshContextReading = true;
|
|
2543
2496
|
const delivery = msg.type === 'primary_turn_started' && executionInputClientIds.length
|
|
2544
2497
|
? { ...msg, inputClientMessageIds: executionInputClientIds } : msg;
|
|
2545
2498
|
send(ws, ollamaExecutionId ? stampOllamaExecution(delivery, ollamaExecutionId, executionInputSeqs) : delivery);
|
|
@@ -2567,6 +2520,11 @@ opts) {
|
|
|
2567
2520
|
return [];
|
|
2568
2521
|
return drainSteerForWorker(workflowId, ws, policyTurnProvider);
|
|
2569
2522
|
},
|
|
2523
|
+
peekSteer: () => {
|
|
2524
|
+
if (!dispatchCurrent() || wf.primaryTurn?.holdSteer || wf.queue.steering.some((item) => item.interrupt))
|
|
2525
|
+
return [];
|
|
2526
|
+
return wf.queue.steering;
|
|
2527
|
+
},
|
|
2570
2528
|
requeueSteer: (items, bucket) => {
|
|
2571
2529
|
if (workflows.get(workflowId) === wf && (busyRevocations.get(wf) ?? 0) === interruptEpoch)
|
|
2572
2530
|
requeueSteerForWorker(workflowId, ws, items, bucket);
|
|
@@ -2644,9 +2602,7 @@ opts) {
|
|
|
2644
2602
|
if (!incognito && firstIteration && !wf.primarySessionId && turn.initialSessionId
|
|
2645
2603
|
&& wf.primary.provider === 'claude' && claudeTransport !== 'native') {
|
|
2646
2604
|
wf.primarySessionId = turn.initialSessionId;
|
|
2647
|
-
|
|
2648
|
-
console.error(`[arco] [${workflowId.slice(0, 8)}] meta reconcile (claude mint) failed:`, err);
|
|
2649
|
-
});
|
|
2605
|
+
sessionSave = saveProviderSession(cwd, workflowId, wf, 'claude', turn.initialSessionId);
|
|
2650
2606
|
}
|
|
2651
2607
|
// Codex emits thread_id at init. Capture on first fire, persist to meta.
|
|
2652
2608
|
turn.onSessionDiscovered((sid) => {
|
|
@@ -2654,9 +2610,8 @@ opts) {
|
|
|
2654
2610
|
return;
|
|
2655
2611
|
if (!wf.primarySessionId)
|
|
2656
2612
|
wf.primarySessionId = sid;
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
});
|
|
2613
|
+
announceReplacementConversation(workflowId, wf);
|
|
2614
|
+
sessionSave = sessionSave.then(() => saveProviderSession(cwd, workflowId, wf, policyTurnProvider, sid, providerAccount?.profile.id));
|
|
2660
2615
|
});
|
|
2661
2616
|
// docs/PROVIDERS.md - surface the background fleet. Under ultracode the
|
|
2662
2617
|
// CLI's WorkflowTool runs subagents whose transcripts never touch the
|
|
@@ -2678,6 +2633,9 @@ opts) {
|
|
|
2678
2633
|
let carryInterruptedPrompt = false;
|
|
2679
2634
|
try {
|
|
2680
2635
|
outcome = await turn.settled;
|
|
2636
|
+
await sessionSave;
|
|
2637
|
+
if (hasFreshContextReading && dispatchCurrent())
|
|
2638
|
+
await markConversationReading(cwd, workflowId, wf);
|
|
2681
2639
|
// A second correction may cancel Native during auth/hooks, before
|
|
2682
2640
|
// its first correction entered history. Carry that unsent input.
|
|
2683
2641
|
carryInterruptedPrompt = await primaryTurn.interruption === false && primaryTurn.holdSteer;
|
|
@@ -2967,6 +2925,7 @@ opts) {
|
|
|
2967
2925
|
incomingMessages.set(wf, remaining);
|
|
2968
2926
|
else
|
|
2969
2927
|
incomingMessages.delete(wf);
|
|
2928
|
+
resumeRequeuedSteer(workflowId, wf);
|
|
2970
2929
|
}
|
|
2971
2930
|
}
|
|
2972
2931
|
// docs/GOTCHAS.md - one tick of an armed goal run. Every branch either
|
package/server/package.json
CHANGED
package/server/src/attention.ts
CHANGED
|
@@ -126,7 +126,7 @@ function shouldRaise(kind: AttentionKind, workflowId: string): boolean {
|
|
|
126
126
|
return isClusterDirector(clusterStore.getMemberRole(clusterId, workflowId));
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
export function raise(kind: AttentionKind, workflowId: string, info: WorkflowInfo, text?: string, longEnough = true): void {
|
|
129
|
+
export function raise(kind: AttentionKind, workflowId: string, info: WorkflowInfo, text?: string, longEnough = true, requestId?: string): void {
|
|
130
130
|
if (info.incognito) return;
|
|
131
131
|
const externalEligible = longEnough && shouldRaise(kind, workflowId);
|
|
132
132
|
const wantDesktop = channels.desktop[kind] && externalEligible;
|
|
@@ -134,11 +134,11 @@ export function raise(kind: AttentionKind, workflowId: string, info: WorkflowInf
|
|
|
134
134
|
// One alert per workflow and kind per few seconds, whatever produced it.
|
|
135
135
|
const key = `${workflowId}:${kind}`;
|
|
136
136
|
const now = Date.now();
|
|
137
|
-
if (now - (lastAlertAt.get(key) ?? 0) < 3000) return;
|
|
137
|
+
if (!requestId && now - (lastAlertAt.get(key) ?? 0) < 3000) return;
|
|
138
138
|
lastAlertAt.set(key, now);
|
|
139
139
|
const name = noticeSourceFor(workflowId, info.name);
|
|
140
140
|
{
|
|
141
|
-
broadcastToClients({ type: 'attention_event', id: `at_${now.toString(36)}_${(idCounter++).toString(36)}`, kind, workflowId, workflowName: name, desktopEligible: wantDesktop });
|
|
141
|
+
broadcastToClients({ type: 'attention_event', id: requestId ? `question-${requestId}` : `at_${now.toString(36)}_${(idCounter++).toString(36)}`, kind, workflowId, workflowName: name, desktopEligible: wantDesktop });
|
|
142
142
|
}
|
|
143
143
|
if (target) {
|
|
144
144
|
const body = channels.phoneText && text ? ascii(text, TEXT_MAX) : `Open Arco to see it.`;
|
|
@@ -167,7 +167,8 @@ export function observeAttention(workflowId: string, message: ServerMessage, inf
|
|
|
167
167
|
break;
|
|
168
168
|
}
|
|
169
169
|
case 'operator_question':
|
|
170
|
-
if (message.question.status === 'pending' && firstSighting(message.question.requestId)) raise('waiting', workflowId, info, message.question.questions.map((q) => q.question).join(' '));
|
|
170
|
+
if (message.question.status === 'pending' && firstSighting(message.question.requestId)) raise('waiting', workflowId, info, message.question.questions.map((q) => q.question).join(' '), true, message.question.requestId);
|
|
171
|
+
else if (message.question.status !== 'pending' && !info.incognito) broadcastToClients({ type: 'attention_question_closed', requestId: message.question.requestId });
|
|
171
172
|
break;
|
|
172
173
|
case 'gate_required':
|
|
173
174
|
if (firstSighting(message.gateId)) raise('waiting', workflowId, info, message.reason);
|
|
@@ -5,12 +5,13 @@ import { join } from 'path';
|
|
|
5
5
|
import { homedir } from 'os';
|
|
6
6
|
import { createHash } from 'crypto';
|
|
7
7
|
import { CLAUDE_MODELS } from '@arco/shared';
|
|
8
|
-
import type { Capabilities, EffortLevel, ModelName } from '@arco/shared';
|
|
8
|
+
import type { Capabilities, CliUpdateOutcome, EffortLevel, ModelName } from '@arco/shared';
|
|
9
9
|
import { getStrataBase } from './providers/strata.js';
|
|
10
10
|
import { getDeepSeekBase } from './providers/deepseek.js';
|
|
11
11
|
import { probeStrataVersion, installedXolotlRevision, strataEngineReleaseVersion } from './providers/runtimeVersions.js';
|
|
12
12
|
import { atomicWriteFile } from './atomicFile.js';
|
|
13
|
-
import {
|
|
13
|
+
import { probeCodexUpdate, describeCliUpdate, type CliUpdateDecision, type UpdateCommandResult } from './cliUpdateDecision.js';
|
|
14
|
+
import { compareVersions } from './updateCheck.js';
|
|
14
15
|
import { arcoHome } from './arcoHome.js';
|
|
15
16
|
import { commandArgs } from './windowsCommand.js';
|
|
16
17
|
|
|
@@ -76,23 +77,26 @@ export async function probeCapabilities(): Promise<Capabilities> {
|
|
|
76
77
|
// Keep fallback
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
const
|
|
80
|
+
const codexDecision = npmLatest('@openai/codex').then(probeCodexUpdate);
|
|
81
|
+
const [cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions, codexUpdate] = await Promise.all([
|
|
80
82
|
probeVersion('claude'),
|
|
81
83
|
probeVersion('codex'),
|
|
82
84
|
probeVersion('cursor-agent'),
|
|
83
85
|
probeStrataVersion(await getStrataBase()),
|
|
84
86
|
installedXolotlRevision(await getDeepSeekBase()),
|
|
85
|
-
probeLatestVersions(),
|
|
87
|
+
probeLatestVersions(codexDecision),
|
|
88
|
+
codexDecision,
|
|
86
89
|
]);
|
|
87
90
|
|
|
88
|
-
return { efforts, models: MODELS, cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions
|
|
91
|
+
return { efforts, models: MODELS, cliVersion, codexVersion, cursorVersion, strataVersion, xolotlRevision, latestVersions,
|
|
92
|
+
codexUpdate: { kind: codexUpdate.kind, updateAvailable: !!codexUpdate.targetVersion && (compareVersions(codexVersion, codexUpdate.targetVersion) ?? 0) < 0, instruction: codexUpdate.message ?? codexUpdate.notice } };
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
// ── Upstream latest-version probes ──
|
|
92
96
|
//
|
|
93
|
-
// Source of truth for "is the operator running the latest CLI?"
|
|
94
|
-
// npm
|
|
95
|
-
// Releases since it's not npm-installed. All
|
|
97
|
+
// Source of truth for "is the operator running the latest CLI?" Claude reads
|
|
98
|
+
// npm; Codex uses its installation decision and npm publication metadata;
|
|
99
|
+
// Ollama queries GitHub Releases since it's not npm-installed. All are best-effort: any
|
|
96
100
|
// failure (offline, rate-limited, schema drift) leaves that key undefined
|
|
97
101
|
// and the UI falls back to displaying the installed version with no
|
|
98
102
|
// outdated indicator. Caller decides cadence — boot + the existing 4h
|
|
@@ -144,10 +148,10 @@ async function strataLatestRelease(): Promise<string | undefined> {
|
|
|
144
148
|
return strataEngineReleaseVersion(feed, release);
|
|
145
149
|
}
|
|
146
150
|
|
|
147
|
-
export async function probeLatestVersions(): Promise<Capabilities['latestVersions']> {
|
|
151
|
+
export async function probeLatestVersions(codexDecision = npmLatest('@openai/codex').then(probeCodexUpdate)): Promise<Capabilities['latestVersions']> {
|
|
148
152
|
const [claude, codex, ollama, strata, xolotl] = await Promise.all([
|
|
149
153
|
npmLatest('@anthropic-ai/claude-code'),
|
|
150
|
-
|
|
154
|
+
codexDecision.then((decision) => decision.targetVersion),
|
|
151
155
|
ollamaLatestRelease(),
|
|
152
156
|
strataLatestRelease(),
|
|
153
157
|
fetchJson('https://api.github.com/repos/Indras-Mirror/Xolotl/commits/HEAD').then((data) => {
|
|
@@ -165,6 +169,8 @@ export interface UpdateResult {
|
|
|
165
169
|
currentVersion: string;
|
|
166
170
|
capabilities: Capabilities;
|
|
167
171
|
output: string;
|
|
172
|
+
outcome: CliUpdateOutcome;
|
|
173
|
+
message: string;
|
|
168
174
|
// Set when preflight refuses the install or the command leaves no working binary.
|
|
169
175
|
// The client renders this instead of a bogus version transition.
|
|
170
176
|
error?: string;
|
|
@@ -174,136 +180,89 @@ export interface UpdateResult {
|
|
|
174
180
|
notice?: string;
|
|
175
181
|
}
|
|
176
182
|
|
|
177
|
-
const UPDATE_COMMAND: Record<CliProvider, { cmd: string; args: string[] }> = {
|
|
178
|
-
claude: { cmd: 'claude', args: ['update'] },
|
|
179
|
-
|
|
180
|
-
codex: { cmd: 'npm', args: ['install', '-g', '@openai/codex@latest'] },
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
// npm package behind each CLI, for the pre-flight platform-build check. Claude
|
|
184
|
-
// is absent on purpose: it self-updates via `claude update`, so there is no
|
|
185
|
-
// `npm install` for us to aim at a specific version.
|
|
186
|
-
const NPM_PACKAGE: Partial<Record<CliProvider, string>> = {
|
|
187
|
-
|
|
188
|
-
codex: '@openai/codex',
|
|
189
|
-
};
|
|
190
|
-
|
|
191
183
|
function versionForProvider(caps: Capabilities, provider: CliProvider): string {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return caps.codexVersion ?? 'unknown';
|
|
184
|
+
return provider === 'claude' ? caps.cliVersion : caps.codexVersion ?? 'unknown';
|
|
195
185
|
}
|
|
196
186
|
|
|
197
187
|
/**
|
|
198
|
-
* Run the
|
|
199
|
-
*
|
|
200
|
-
*
|
|
188
|
+
* Run the updater for the installation Arco actually launches. Claude uses its
|
|
189
|
+
* built-in updater; Codex shares one installation decision with its version flag.
|
|
190
|
+
* Re-probe afterwards: a successful command alone does not prove a working CLI.
|
|
201
191
|
*/
|
|
202
|
-
export async function runCliUpdate(previous: Capabilities, provider: CliProvider = 'claude', runCommand = runUpdateCommand): Promise<UpdateResult> {
|
|
203
|
-
const previousVersion = versionForProvider(previous, provider);
|
|
204
|
-
|
|
192
|
+
export async function runCliUpdate(previous: Capabilities, provider: CliProvider = 'claude', runCommand: (cmd: string, args: string[]) => Promise<UpdateCommandResult> = (cmd, args) => runUpdateCommand(cmd, args, provider)): Promise<UpdateResult> {
|
|
193
|
+
const previousVersion = provider === 'codex' ? await probeVersion('codex') : versionForProvider(previous, provider);
|
|
205
194
|
// Pre-flight: for npm-installed CLIs, work out which version can actually run
|
|
206
195
|
// on this machine before installing anything. `@latest` is not automatically
|
|
207
196
|
// installable — a package whose binary ships as a platform-specific
|
|
208
197
|
// optionalDependency is broken-on-arrival during the window between the
|
|
209
198
|
// wrapper being tagged `latest` and that platform's tarball being published,
|
|
210
199
|
// and npm reports that as success. See npmPlatformResolve.ts.
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return {
|
|
223
|
-
provider,
|
|
224
|
-
updated: false,
|
|
225
|
-
previousVersion,
|
|
226
|
-
currentVersion: previousVersion,
|
|
227
|
-
capabilities: previous,
|
|
228
|
-
output: notice ?? 'Update deferred; the current CLI was not changed.',
|
|
229
|
-
error: notice ?? 'Update deferred: no installable platform build was found.',
|
|
230
|
-
...(notice ? { notice } : {}),
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
args = ['install', '-g', `${pkg}@${resolved.version}`];
|
|
234
|
-
// Already on the version we would install, and it runs — skip the install
|
|
235
|
-
// entirely so a no-op click can't churn a working CLI into a broken one.
|
|
236
|
-
if (resolved.version === previousVersion && previousVersion !== 'broken' && previousVersion !== 'unknown') {
|
|
237
|
-
return {
|
|
238
|
-
provider,
|
|
239
|
-
updated: false,
|
|
240
|
-
previousVersion,
|
|
241
|
-
currentVersion: previousVersion,
|
|
242
|
-
capabilities: previous,
|
|
243
|
-
output: `${pkg}@${previousVersion} is already installed`,
|
|
244
|
-
...(notice ? { notice } : {}),
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
}
|
|
200
|
+
const decision: CliUpdateDecision = provider === 'codex'
|
|
201
|
+
? await probeCodexUpdate(await npmLatest('@openai/codex'))
|
|
202
|
+
: { kind: 'unknown' as const, command: { cmd: 'claude', args: ['update'] }, targetVersion: previous.latestVersions?.claude };
|
|
203
|
+
const notice = decision.notice;
|
|
204
|
+
const capabilities = provider === 'codex'
|
|
205
|
+
? { ...previous, codexVersion: previousVersion, latestVersions: { ...previous.latestVersions, codex: decision.targetVersion }, codexUpdate: { kind: decision.kind, updateAvailable: !!decision.targetVersion && (compareVersions(previousVersion, decision.targetVersion) ?? 0) < 0, instruction: decision.message ?? decision.notice } }
|
|
206
|
+
: previous;
|
|
207
|
+
if (!decision.command) {
|
|
208
|
+
const message = decision.message ?? 'Update deferred; the current CLI was not changed.';
|
|
209
|
+
return { provider, previousVersion, currentVersion: previousVersion, capabilities, updated: false,
|
|
210
|
+
outcome: decision.outcome ?? 'deferred', message, output: message, notice: message };
|
|
248
211
|
}
|
|
249
|
-
|
|
250
|
-
|
|
212
|
+
// Already on the version we would install, and it runs — skip the install
|
|
213
|
+
// entirely so a no-op click can't churn a working CLI into a broken one.
|
|
214
|
+
if (provider === 'codex' && decision.targetVersion && (compareVersions(previousVersion, decision.targetVersion) ?? -1) >= 0) {
|
|
215
|
+
return { provider, previousVersion, currentVersion: previousVersion, capabilities, output: '',
|
|
216
|
+
...describeCliUpdate(provider, previousVersion, previousVersion, decision.targetVersion, { exitCode: 0, output: '' }, notice),
|
|
217
|
+
...(notice ? { notice } : {}) };
|
|
218
|
+
}
|
|
219
|
+
const { cmd, args } = decision.command;
|
|
220
|
+
let commandResult = await runCommand(cmd, args);
|
|
251
221
|
let next = await probeCapabilities();
|
|
252
222
|
let currentVersion = versionForProvider(next, provider);
|
|
253
223
|
|
|
254
224
|
// Post-flight repair. The pre-flight check closes the common case, but npm can
|
|
255
225
|
// still skip an optional dep that does exist (a mid-install network failure,
|
|
256
226
|
// a poisoned cache), and that also exits 0. One retry with a clean cache is
|
|
257
|
-
// cheap next to leaving the operator's CLI dead.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
227
|
+
// cheap next to leaving the operator's CLI dead. Only a proven npm install
|
|
228
|
+
// with a successful updater exit can reach this npm repair path.
|
|
229
|
+
if (commandResult.exitCode === 0 && (currentVersion === 'broken' || currentVersion === 'unknown') && decision.repairArgs) {
|
|
230
|
+
const repairArgs = [...decision.repairArgs, '--force'];
|
|
231
|
+
const repaired = await runCommand('npm', repairArgs);
|
|
232
|
+
commandResult = { exitCode: repaired.exitCode, output: `${commandResult.output}\n\n[arco] ${provider} did not run after the update — retrying: npm ${repairArgs.join(' ')}\n${repaired.output}` };
|
|
262
233
|
next = await probeCapabilities();
|
|
263
234
|
currentVersion = versionForProvider(next, provider);
|
|
264
235
|
}
|
|
265
236
|
|
|
266
237
|
// A post-update probe that can't report a version means the command left the
|
|
267
238
|
// CLI unusable, however cleanly it exited. Deciding `updated` purely on the
|
|
268
|
-
// version string differing is how a silently-failed
|
|
269
|
-
//
|
|
270
|
-
// the
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
previousVersion,
|
|
276
|
-
currentVersion,
|
|
277
|
-
capabilities: next,
|
|
278
|
-
output,
|
|
279
|
-
error: (await probeFailureReason(provider)) ?? `${provider} did not run after the update`,
|
|
280
|
-
...(notice ? { notice } : {}),
|
|
281
|
-
};
|
|
239
|
+
// version string differing is how a silently-failed npm install surfaced
|
|
240
|
+
// as a cheerful "→ vunknown". Nonzero exits are also failures, even when
|
|
241
|
+
// the previous executable still runs and reports the same version.
|
|
242
|
+
const report = describeCliUpdate(provider, previousVersion, currentVersion, next.latestVersions?.[provider], commandResult, notice);
|
|
243
|
+
if (report.outcome === 'failed' && commandResult.exitCode === 0) {
|
|
244
|
+
const reason = await probeFailureReason(provider);
|
|
245
|
+
if (reason) { report.error = reason; report.message = reason; }
|
|
282
246
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
provider,
|
|
286
|
-
updated: currentVersion !== previousVersion,
|
|
287
|
-
previousVersion,
|
|
288
|
-
currentVersion,
|
|
289
|
-
capabilities: next,
|
|
290
|
-
output,
|
|
291
|
-
...(notice ? { notice } : {}),
|
|
292
|
-
};
|
|
247
|
+
return { provider, previousVersion, currentVersion, capabilities: next, output: commandResult.output,
|
|
248
|
+
...report, ...(notice ? { notice } : {}) };
|
|
293
249
|
}
|
|
294
250
|
|
|
295
|
-
//
|
|
296
|
-
//
|
|
297
|
-
|
|
298
|
-
|
|
251
|
+
// Keep the command status as well as its captured output. npm can exit zero
|
|
252
|
+
// after skipping an optional dep, but a nonzero updater exit is always failure.
|
|
253
|
+
async function runUpdateCommand(cmd: string, args: string[], provider: CliProvider): Promise<UpdateCommandResult> {
|
|
254
|
+
const env = { ...process.env };
|
|
255
|
+
if (provider === 'codex') {
|
|
256
|
+
// Native Codex must detect its own install; an enclosing agent's package
|
|
257
|
+
// manager provenance must not turn a standalone update into an npm install.
|
|
258
|
+
for (const name of ['CODEX_MANAGED_BY_NPM', 'CODEX_MANAGED_BY_BUN', 'CODEX_MANAGED_BY_PNPM', 'CODEX_MANAGED_BY_VITE_PLUS', 'CODEX_MANAGED_PACKAGE_ROOT', 'npm_config_user_agent', 'npm_execpath']) delete env[name];
|
|
259
|
+
}
|
|
299
260
|
try {
|
|
300
|
-
const { stdout, stderr } = await execFileAsync(...commandArgs(cmd, args), {
|
|
301
|
-
|
|
302
|
-
timeout: 180_000,
|
|
303
|
-
});
|
|
304
|
-
return (stdout + stderr).trim();
|
|
261
|
+
const { stdout, stderr } = await execFileAsync(...commandArgs(cmd, args), { env, maxBuffer: 4 * 1024 * 1024, timeout: 180_000 });
|
|
262
|
+
return { output: (stdout + stderr).trim(), exitCode: 0 };
|
|
305
263
|
} catch (err) {
|
|
306
|
-
|
|
264
|
+
const error = err as { code?: number | string; stdout?: string; stderr?: string; message?: string };
|
|
265
|
+
return { output: (error.stderr || error.stdout || error.message || String(err)).trim(), exitCode: typeof error.code === 'number' ? error.code : 1 };
|
|
307
266
|
}
|
|
308
267
|
}
|
|
309
268
|
|