arco-workbench 0.1.5 → 0.1.7
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 +17 -5
- package/client/dist/assets/{PhosphorBackdrop-D6cbmLNY.js → PhosphorBackdrop-DVQdBrTw.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-2dyerOi4.js → ThemedBackgroundShaderImpl-BfSs2tB4.js} +1 -1
- package/client/dist/assets/{XtermView-AIwo7O3D.js → XtermView-DaMjC8Ny.js} +1 -1
- package/client/dist/assets/{galleryEditor-DXAuxS8D.js → galleryEditor-BCQnXj7R.js} +1 -1
- package/client/dist/assets/{index-8j6p-pmQ.js → index-COfbHCYv.js} +245 -243
- package/client/dist/index.html +1 -1
- package/client/src/alerts/desktopAlerts.ts +13 -0
- package/client/src/buildCheck.ts +3 -1
- package/client/src/components/AppUpdateNotice.tsx +2 -1
- package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +46 -11
- package/client/src/components/ClusterRightPanel/MemberRow.tsx +1 -1
- package/client/src/components/ClusterRightPanel/index.tsx +2 -1
- package/client/src/components/ClusterTaskBoardTab.tsx +54 -3
- package/client/src/components/ContextMeter.tsx +7 -0
- package/client/src/components/HeaderVersionBox.tsx +7 -4
- 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/UpdateAction.tsx +18 -4
- package/client/src/components/UpdateResultNotice.tsx +3 -1
- package/client/src/components/clusterNeedsYou.ts +27 -8
- package/client/src/help/content/cluster.tsx +50 -27
- package/client/src/help/content/composer.tsx +8 -1
- package/client/src/help/content/header.tsx +25 -14
- package/client/src/help/content/misc.tsx +8 -0
- package/client/src/help/content/rightPanel.tsx +1 -1
- package/client/src/help/content/settings.tsx +1 -1
- package/client/src/help/content/tabbar.tsx +2 -1
- package/client/src/help/manualSections/clusters.tsx +78 -19
- package/client/src/help/manualSections/configuration.tsx +20 -4
- package/client/src/help/manualSections/gettingStarted.tsx +10 -0
- package/client/src/help/manualSections/maintenance.tsx +50 -8
- package/client/src/help/manualSections/plans.tsx +5 -1
- 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 +20 -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/appUpdateStore.ts +29 -8
- 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/utils/wsSession.ts +2 -1
- 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 +16 -6
- package/docs/GLOSSARY.md +6 -2
- package/docs/GOTCHAS.md +17 -5
- package/docs/OPERATIONS.md +207 -5
- package/docs/PERSISTENCE.md +22 -1
- package/docs/PRIMITIVES.md +1 -1
- package/docs/PROTOCOL.md +1 -1
- package/docs/PROTOCOL_CLUSTER.md +18 -7
- 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/darwin-arm64/manifest.json +1 -1
- 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.d.ts +3 -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/scripts/packaging/native-repair.mjs +46 -8
- package/scripts/packaging/update.mjs +5 -1
- 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/clusterAutoTurn.d.ts +4 -0
- package/server/dist/clusterAutoTurn.js +29 -25
- package/server/dist/clusterBusyReminder.js +1 -1
- package/server/dist/clusterDirector.js +1 -0
- package/server/dist/clusterPeerOps.js +2 -2
- package/server/dist/clusterStore.d.ts +3 -0
- package/server/dist/clusterStore.js +22 -0
- 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/smartPickup.d.ts +2 -1
- package/server/dist/smartPickup.js +28 -1
- package/server/dist/smartPickupAdapters.d.ts +1 -0
- package/server/dist/smartPickupAdapters.js +18 -5
- package/server/dist/smartPickupLedger.js +6 -4
- package/server/dist/smartPickupObserver.d.ts +1 -0
- package/server/dist/smartPickupObserver.js +69 -23
- 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/clusterHandlers.d.ts +1 -0
- package/server/dist/ws/clusterHandlers.js +2 -1
- 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/clusterAutoTurn.ts +26 -21
- package/server/src/clusterBusyReminder.ts +1 -1
- package/server/src/clusterDirector.ts +1 -0
- package/server/src/clusterPeerOps.ts +2 -2
- package/server/src/clusterStore.ts +26 -1
- 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/smartPickup.ts +27 -3
- package/server/src/smartPickupAdapters.ts +19 -5
- package/server/src/smartPickupLedger.ts +6 -4
- package/server/src/smartPickupObserver.ts +51 -17
- 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/clusterHandlers.ts +3 -2
- 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.d.ts +3 -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 +14 -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,3 +1,4 @@
|
|
|
1
|
+
import { ensureWorkflowMetadata, providerConversationState, saveProviderSession } from '../providerConversation.js';
|
|
1
2
|
import { isClaudeNativeTaskActive } from '../providers/claude-native/index.js';
|
|
2
3
|
import { appendHandoffNotice } from '../handoffHistoryTool.js';
|
|
3
4
|
import { unsettledTaskStatuses } from './taskLifecycle.js';
|
|
@@ -35,7 +36,7 @@ import { acquirePlansWatcher, broadcastCluster, broadcastHandoffLockSnapshot, br
|
|
|
35
36
|
import { buildLocalClusterSystemPrompt, LLAMACPP_PRIMARY_SYSTEM_PROMPT, OLLAMA_PRIMARY_SYSTEM_PROMPT, withPreviewNudge, } from '../server/prompts.js';
|
|
36
37
|
import { cwdHandoffChain, workflowCwds, workflows, } from '../server/state.js';
|
|
37
38
|
import { acquireProjectSettingsWatcher, readSettings, } from '../settings.js';
|
|
38
|
-
import { appendHistoryEntry, readMeta, workflowConfigFromMeta,
|
|
39
|
+
import { appendHistoryEntry, readMeta, workflowConfigFromMeta, writeMeta, } from '../workflowMeta.js';
|
|
39
40
|
import { getHeadSeq as getWorkflowHeadSeq, initWorkflowStore, readFirstSeq as readWorkflowFirstSeq, replayEvents as replayWorkflowEvents, replayTailEvents, scanEventsOfTypes, } from '../workflowStore.js';
|
|
40
41
|
import { ptyManager } from '../terminal/ptyManager.js';
|
|
41
42
|
import { sendTaskLedgerSnapshot } from './taskLedgerHandlers.js';
|
|
@@ -416,6 +417,7 @@ export async function handleHandoffRequest(ws, session, msg) {
|
|
|
416
417
|
if (!handoffOwned())
|
|
417
418
|
return;
|
|
418
419
|
wf.primarySessionId = undefined;
|
|
420
|
+
wf.providerConversation = undefined;
|
|
419
421
|
// Retire every cached transport before the new seed, so Codex app-server
|
|
420
422
|
// and Cursor ACP bootstrap their MCP children with the new history grant.
|
|
421
423
|
// Await local teardown too, then recheck ownership before touching the seed.
|
|
@@ -598,7 +600,7 @@ export async function handleHandoffRequest(ws, session, msg) {
|
|
|
598
600
|
// extras filter excludes non-streaming assistants when sessionChat is
|
|
599
601
|
// non-empty from the pre-handoff session). No-op for non-Claude.
|
|
600
602
|
startSessionWatcher(msg.workflowId, wf, cwd, ws);
|
|
601
|
-
|
|
603
|
+
saveProviderSession(cwd, msg.workflowId, wf, 'claude', primaryTurn.initialSessionId).catch((err) => {
|
|
602
604
|
console.error(`[arco] handoff ${handle.handoffId} meta reconcile failed:`, err);
|
|
603
605
|
});
|
|
604
606
|
}
|
|
@@ -612,7 +614,7 @@ export async function handleHandoffRequest(ws, session, msg) {
|
|
|
612
614
|
// practice; startSessionWatcher is a no-op on other providers.
|
|
613
615
|
startSessionWatcher(msg.workflowId, wf, cwd, ws);
|
|
614
616
|
}
|
|
615
|
-
|
|
617
|
+
saveProviderSession(cwd, msg.workflowId, wf, wf.primary.provider, sid, handoffAccount?.profile.id).catch((err) => {
|
|
616
618
|
console.error(`[arco] handoff ${handle.handoffId} meta reconcile (${wf.primary.provider}) failed:`, err);
|
|
617
619
|
});
|
|
618
620
|
});
|
|
@@ -1251,7 +1253,7 @@ export async function handleSpawnFromHere(ws, session, msg) {
|
|
|
1251
1253
|
// the usual watcher-start call never runs. Start it here once the new
|
|
1252
1254
|
// session's id is known — same reasoning as the handoff fix above.
|
|
1253
1255
|
startSessionWatcher(newWorkflowId, spawnedWf, newCwd, ws);
|
|
1254
|
-
|
|
1256
|
+
saveProviderSession(newCwd, newWorkflowId, spawnedWf, 'claude', primaryTurn.initialSessionId).catch((err) => {
|
|
1255
1257
|
console.error(`[arco] spawn meta reconcile failed:`, err);
|
|
1256
1258
|
});
|
|
1257
1259
|
}
|
|
@@ -1263,7 +1265,9 @@ export async function handleSpawnFromHere(ws, session, msg) {
|
|
|
1263
1265
|
wf.primarySessionId = sid;
|
|
1264
1266
|
startSessionWatcher(newWorkflowId, wf, newCwd, ws);
|
|
1265
1267
|
}
|
|
1266
|
-
|
|
1268
|
+
if (!wf)
|
|
1269
|
+
return;
|
|
1270
|
+
saveProviderSession(newCwd, newWorkflowId, wf, newPrimary.provider, sid, spawnAccount?.profile.id).catch((err) => {
|
|
1267
1271
|
console.error(`[arco] spawn meta reconcile (${newPrimary.provider}) failed:`, err);
|
|
1268
1272
|
});
|
|
1269
1273
|
});
|
|
@@ -1411,6 +1415,7 @@ export async function handleRehydrateWorkflows(ws, session, entries) {
|
|
|
1411
1415
|
// Read meta.json to restore primarySessionId so the next user_message
|
|
1412
1416
|
// continues the prior CLI session instead of starting a fresh one.
|
|
1413
1417
|
try {
|
|
1418
|
+
await ensureWorkflowMetadata(cwd, entry.workflowId, wf);
|
|
1414
1419
|
const meta = await readMeta(cwd, entry.workflowId);
|
|
1415
1420
|
if (meta) {
|
|
1416
1421
|
const latestForProvider = [...meta.cliSessions].reverse().find((s) => s.provider === wf.primary.provider);
|
|
@@ -1679,6 +1684,8 @@ const TASK_SCAN_TYPES = [...TASK_LIFECYCLE_TYPES, 'primary_turn_ended'];
|
|
|
1679
1684
|
const REPLAY_BATCH_THRESHOLD = 200;
|
|
1680
1685
|
export async function rehydrateOneWorkflow(ws, workflowId, wf, clientLastSeq, opts = {}) {
|
|
1681
1686
|
const cwd = wf.config.incognito ? '' : wf.config.workingDirectory;
|
|
1687
|
+
if (cwd)
|
|
1688
|
+
await ensureWorkflowMetadata(cwd, workflowId, wf);
|
|
1682
1689
|
let latestNativeLastPromptTokens;
|
|
1683
1690
|
const captureReplayTokens = (events) => {
|
|
1684
1691
|
for (const event of events) {
|
|
@@ -1819,9 +1826,12 @@ export async function rehydrateOneWorkflow(ws, workflowId, wf, clientLastSeq, op
|
|
|
1819
1826
|
: null;
|
|
1820
1827
|
const codexSnapshotWindow = codexSnapshot?.modelContextWindow;
|
|
1821
1828
|
const computerState = isComputer(wf) ? await computerContextState(workflowId, wf) : undefined;
|
|
1829
|
+
const conversationState = cwd ? await providerConversationState(cwd, workflowId, wf) : undefined;
|
|
1830
|
+
wf.providerConversation = conversationState;
|
|
1822
1831
|
const msg = {
|
|
1823
1832
|
type: 'workflow_state_snapshot',
|
|
1824
1833
|
workflowId,
|
|
1834
|
+
...(conversationState ? { providerConversation: conversationState } : {}),
|
|
1825
1835
|
workers: {},
|
|
1826
1836
|
busy: wf.busy,
|
|
1827
1837
|
...(wf.busy && Number.isFinite(wf.turnStartedAt) ? { turnStartedAt: wf.turnStartedAt } : {}),
|
|
@@ -1862,7 +1872,7 @@ export async function rehydrateOneWorkflow(ws, workflowId, wf, clientLastSeq, op
|
|
|
1862
1872
|
startSessionWatcher(workflowId, wf, cwd, ws);
|
|
1863
1873
|
// Phase 2 — emit a context estimate immediately so the client has a fill
|
|
1864
1874
|
// reading as soon as the snapshot arrives (not only after the next turn).
|
|
1865
|
-
if (cwd && wf.primary.provider === 'claude' && typeof latestNativeLastPromptTokens === 'number' && latestNativeLastPromptTokens > 0) {
|
|
1875
|
+
if (cwd && !conversationState && wf.primary.provider === 'claude' && typeof latestNativeLastPromptTokens === 'number' && latestNativeLastPromptTokens > 0) {
|
|
1866
1876
|
const estimate = nativeContextEstimate(wf.primary.model, latestNativeLastPromptTokens);
|
|
1867
1877
|
if (estimate && ws.readyState === WebSocket.OPEN) {
|
|
1868
1878
|
const usage = { type: 'context_usage', workflowId, ...estimate };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WebSocket } from 'ws';
|
|
2
|
-
import type { OperatorQuestionReplyMessage } from '@arco/shared';
|
|
2
|
+
import type { OperatorQuestionReplyMessage, OperatorQuestionDismissMessage } from '@arco/shared';
|
|
3
3
|
import type { Session } from '../workflows/types.js';
|
|
4
4
|
export declare function handleOperatorQuestionReply(ws: WebSocket, session: Session, msg: OperatorQuestionReplyMessage): Promise<void>;
|
|
5
|
+
export declare function handleOperatorQuestionDismiss(ws: WebSocket, session: Session, msg: OperatorQuestionDismissMessage): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebSocket } from 'ws';
|
|
2
2
|
import { workflows } from '../server/state.js';
|
|
3
|
-
import { replyToOperatorQuestion } from '../providers/codex-appserver/operatorQuestions.js';
|
|
3
|
+
import { replyToOperatorQuestion, dismissOperatorQuestion } from '../providers/codex-appserver/operatorQuestions.js';
|
|
4
4
|
import { handleUserMessage } from './turnEngine.js';
|
|
5
5
|
import { broadcastWorkflow } from '../server/broadcast.js';
|
|
6
6
|
export async function handleOperatorQuestionReply(ws, session, msg) {
|
|
@@ -25,4 +25,12 @@ export async function handleOperatorQuestionReply(ws, session, msg) {
|
|
|
25
25
|
if (ws.readyState === WebSocket.OPEN)
|
|
26
26
|
ws.send(JSON.stringify({ type: 'operator_question_reply_result', workflowId: msg.workflowId, requestId: msg.requestId, ...result }));
|
|
27
27
|
}
|
|
28
|
+
export function handleOperatorQuestionDismiss(ws, session, msg) {
|
|
29
|
+
const wf = workflows.get(msg.workflowId);
|
|
30
|
+
const result = !wf || !wf.observers.has(ws) || !session.workflowIds.has(msg.workflowId)
|
|
31
|
+
? { ok: false, error: 'Subscribe to this workflow before dismissing.' }
|
|
32
|
+
: dismissOperatorQuestion(msg.workflowId, msg.requestId);
|
|
33
|
+
if (ws.readyState === WebSocket.OPEN)
|
|
34
|
+
ws.send(JSON.stringify({ type: 'operator_question_dismiss_result', workflowId: msg.workflowId, requestId: msg.requestId, ...result }));
|
|
35
|
+
}
|
|
28
36
|
//# sourceMappingURL=operatorQuestionHandlers.js.map
|
|
@@ -16,7 +16,7 @@ export interface TurnEngineDeps {
|
|
|
16
16
|
handleHandoffRequest: (ws: WebSocket, session: Session, msg: import('@arco/shared').HandoffRequestMessage) => Promise<{
|
|
17
17
|
artifactName: string;
|
|
18
18
|
} | void>;
|
|
19
|
-
handleCompactWorkflow?: (ws: WebSocket, session: Session, msg: import('@arco/shared').CompactWorkflowMessage, guard?: (claim: () => number) => Promise<number | false>, autoDetail?: string) => Promise<void>;
|
|
19
|
+
handleCompactWorkflow?: (ws: WebSocket, session: Session, msg: import('@arco/shared').CompactWorkflowMessage, guard?: (claim: () => number) => Promise<number | false>, autoDetail?: string, onSuccess?: () => void) => Promise<void>;
|
|
20
20
|
}
|
|
21
21
|
export declare function initTurnEngine(d: TurnEngineDeps): void;
|
|
22
22
|
export declare function extractFilePath(tool: string, input: unknown): string | undefined;
|
|
@@ -82,9 +82,7 @@ export declare function projectQueue(items: QueueItem[]): Array<{
|
|
|
82
82
|
export declare function broadcastQueueUpdate(workflowId: string): void;
|
|
83
83
|
export declare function drainSteerForWorker(workflowId: string, ws: WebSocket, deliveryProvider?: WorkflowConfig['primaryProvider']): SteerItem[];
|
|
84
84
|
export declare function requeueSteerForWorker(workflowId: string, ws: WebSocket, items: SteerItem[], bucket: 'steer' | 'follow-up'): void;
|
|
85
|
-
export
|
|
86
|
-
parentWorkflowId?: string;
|
|
87
|
-
}): Promise<void>;
|
|
85
|
+
export { persistInitialMeta } from '../workflowMeta.js';
|
|
88
86
|
export declare function writeCalibrationToMeta(cwd: string, workflowId: string, ratio: number, overhead: number, lastGroundTruth: number): Promise<void>;
|
|
89
87
|
export declare function enqueueBusyReminder(workflowId: string, content: string, allow?: () => boolean): Promise<boolean>;
|
|
90
88
|
export declare function handleUserMessage(ws: WebSocket, session: Session, workflowId: string, content: string, clientMessageId: string | undefined, attachments: string[] | undefined, interjection: boolean, kind: 'steer' | 'follow-up' | 'interrupt' | undefined, primitive: 'docs' | 'git' | 'plan-review' | undefined, pickedSkills?: Array<{
|
|
@@ -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);
|