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
|
@@ -2,7 +2,8 @@ import { nativeOAuthBaseUrl } from './providers/claude-native/apiEndpoint.js';
|
|
|
2
2
|
// Smart AUTO-PICKUP evaluator adapters. Each makes one bounded request with
|
|
3
3
|
// no tools and nothing Arco keeps or resumes afterwards: a time limit, an
|
|
4
4
|
// abort signal and an output cap. Any error, tool attempt or oversized answer
|
|
5
|
-
// rejects
|
|
5
|
+
// rejects. Smart: Automatic may then attempt ordinary pickup through its
|
|
6
|
+
// deterministic wake gate; Observe-only records the failure without waking.
|
|
6
7
|
//
|
|
7
8
|
// Capability per provider:
|
|
8
9
|
// ollama - /api/chat, stream off, JSON-schema format, no tools field.
|
|
@@ -48,8 +49,16 @@ import { localModelsUnloading } from './providers/localModelControl.js';
|
|
|
48
49
|
// initialize about 0.25 s, session/new about 2 s); the allowance covers a cold
|
|
49
50
|
// agent start (update, sign-in refresh) without touching the answer limit.
|
|
50
51
|
export const EVALUATOR_STARTUP_TIMEOUT_MS = 30_000;
|
|
52
|
+
// Match the existing short Claude request's bounded reasoning allowance.
|
|
53
|
+
// The selected answer limit still caps visible text; this is total generation
|
|
54
|
+
// headroom for evaluator requests, not a larger permitted evaluator answer.
|
|
55
|
+
export const EVALUATOR_REASONING_HEADROOM = 8192;
|
|
56
|
+
function totalOutputLimit(req) {
|
|
57
|
+
return req.maxOutputTokens + (req.freeText ? 0 : EVALUATOR_REASONING_HEADROOM);
|
|
58
|
+
}
|
|
51
59
|
// A failure before the agent session was ready (reason prefix startup_). The
|
|
52
|
-
// observer
|
|
60
|
+
// observer preserves one retry of such a failure for the same mail, with a
|
|
61
|
+
// fresh reservation. A second startup failure can use guarded fallback.
|
|
53
62
|
export function isStartupFailure(reason) {
|
|
54
63
|
return reason.startsWith('startup_');
|
|
55
64
|
}
|
|
@@ -100,7 +109,8 @@ export function ollamaAdapter(opts = {}) {
|
|
|
100
109
|
model: req.model,
|
|
101
110
|
stream: false,
|
|
102
111
|
...(req.freeText ? {} : { format: ANSWER_SCHEMA }),
|
|
103
|
-
|
|
112
|
+
...(req.freeText ? {} : { think: false }),
|
|
113
|
+
options: { num_predict: totalOutputLimit(req), temperature: 0 },
|
|
104
114
|
messages: [{ role: 'system', content: req.instructions }, { role: 'user', content: req.prompt }],
|
|
105
115
|
}),
|
|
106
116
|
});
|
|
@@ -154,6 +164,7 @@ export function claudeAdapter(opts = {}) {
|
|
|
154
164
|
const resp = await client.messages.create({
|
|
155
165
|
model,
|
|
156
166
|
...shortTextRequestParams(model, req.maxOutputTokens),
|
|
167
|
+
...(req.freeText ? {} : { max_tokens: totalOutputLimit(req) }),
|
|
157
168
|
system: [{ type: 'text', text: CLAUDE_IDENTITY }, { type: 'text', text: req.instructions }],
|
|
158
169
|
messages: [{ role: 'user', content: req.prompt }],
|
|
159
170
|
}, { signal });
|
|
@@ -168,6 +179,8 @@ export function claudeAdapter(opts = {}) {
|
|
|
168
179
|
};
|
|
169
180
|
if (!Array.isArray(blocks))
|
|
170
181
|
return refuse('unreadable_answer');
|
|
182
|
+
if (resp.stop_reason === 'refusal')
|
|
183
|
+
return refuse('provider_refused');
|
|
171
184
|
if (resp.stop_reason === 'tool_use' || types.includes('tool_use') || types.includes('other'))
|
|
172
185
|
return refuse('non_text_answer');
|
|
173
186
|
if (blocks.some((b) => b && typeof b === 'object' && 'type' in b && b.type === 'text' && (!('text' in b) || typeof b.text !== 'string')))
|
|
@@ -555,12 +568,12 @@ export function openAiCompatibleAdapter(provider, opts) {
|
|
|
555
568
|
signal.throwIfAborted();
|
|
556
569
|
const response = await fetchImpl(`${base}/chat/completions`, {
|
|
557
570
|
method: 'POST', headers: { 'Content-Type': 'application/json' }, signal,
|
|
558
|
-
body: JSON.stringify({ model: req.model, stream: false, max_tokens: req
|
|
571
|
+
body: JSON.stringify({ model: req.model, stream: false, max_tokens: totalOutputLimit(req), temperature: 0,
|
|
559
572
|
messages: [{ role: 'system', content: req.instructions }, { role: 'user', content: req.prompt }] }),
|
|
560
573
|
});
|
|
561
574
|
if (!response.ok)
|
|
562
575
|
throw new EvaluatorRefused(response.status === 401 || response.status === 403 ? 'not_signed_in' : `provider_http_${response.status}`);
|
|
563
|
-
const result = await boundedLocalResponse(response, outputCharCap(req
|
|
576
|
+
const result = await boundedLocalResponse(response, outputCharCap(totalOutputLimit(req)) * 4 + 16_384);
|
|
564
577
|
const choice = result && Array.isArray(result.choices) ? result.choices[0] : undefined;
|
|
565
578
|
if ((choice?.message?.tool_calls != null && (!Array.isArray(choice.message.tool_calls) || choice.message.tool_calls.length > 0)) || choice?.message?.function_call || (choice?.finish_reason === 'tool_calls' || choice?.finish_reason === 'function_call'))
|
|
566
579
|
throw new EvaluatorRefused('tool_attempted');
|
|
@@ -10,10 +10,11 @@ import { promises as fs } from 'node:fs';
|
|
|
10
10
|
import { join } from 'node:path';
|
|
11
11
|
import { randomUUID } from 'node:crypto';
|
|
12
12
|
import { atomicWriteFile } from './atomicFile.js';
|
|
13
|
-
import { clusterDir } from './clusterStore.js';
|
|
13
|
+
import { clusterDir, getClusterCached } from './clusterStore.js';
|
|
14
14
|
const HOUR_MS = 60 * 60 * 1000;
|
|
15
|
-
//
|
|
16
|
-
// of at most 8 hours), so they are dropped on the next write.
|
|
15
|
+
// Older entries normally cannot affect a limit (hour windows and sessions
|
|
16
|
+
// of at most 8 hours), so they are dropped on the next write. Pauses can
|
|
17
|
+
// extend a session's wall-clock life: retain its entries until it ends.
|
|
17
18
|
const RETAIN_MS = 9 * HOUR_MS;
|
|
18
19
|
const DECISIONS_KEPT = 50;
|
|
19
20
|
export class SmartPickupLedgerUnreadable extends Error {
|
|
@@ -50,7 +51,8 @@ async function read(clusterId) {
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
async function write(clusterId, ledger, now) {
|
|
53
|
-
|
|
54
|
+
const activeSession = getClusterCached(clusterId)?.smartPickup?.session?.id;
|
|
55
|
+
ledger.entries = ledger.entries.filter((e) => e.status === 'reserved' || e.sessionId === activeSession || now - e.at < RETAIN_MS);
|
|
54
56
|
ledger.decisions = ledger.decisions.slice(-DECISIONS_KEPT);
|
|
55
57
|
await fs.mkdir(clusterDir(clusterId), { recursive: true });
|
|
56
58
|
await atomicWriteFile(ledgerPath(clusterId), JSON.stringify(ledger, null, 2));
|
|
@@ -26,5 +26,6 @@ export declare function onSmartPickupMail(clusterId: string, workflowId: string,
|
|
|
26
26
|
export declare function evaluateOnce(clusterId: string, workflowId: string): Promise<ObservedDecision | null>;
|
|
27
27
|
export declare function noteSmartPickupStop(workflowId: string): Promise<void>;
|
|
28
28
|
export declare function sweepSmartPickupMail(): Promise<void>;
|
|
29
|
+
export declare function pickupSmartWaitingMail(clusterId: string): Promise<void>;
|
|
29
30
|
export declare function startSmartPickupObserver(next: Partial<Deps>): void;
|
|
30
31
|
export {};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// decision per unchanged mail fingerprint per session; an evaluator slot is
|
|
10
10
|
// reserved before any request and always counts. A result is discarded when
|
|
11
11
|
// the session or mode changed while it was running.
|
|
12
|
-
import { isSmartPickupMode, presetForText, sanitizeSmartPickupLimits, } from '@arco/shared';
|
|
12
|
+
import { isSmartPickupMode, isAutoPickupAcknowledgement, presetForText, sanitizeSmartPickupLimits, } from '@arco/shared';
|
|
13
13
|
import * as clusterStore from './clusterStore.js';
|
|
14
14
|
import * as clusterMailbox from './clusterMailbox.js';
|
|
15
15
|
import * as taskLedger from './project/taskLedger.js';
|
|
@@ -91,7 +91,7 @@ function armed(clusterId) {
|
|
|
91
91
|
return null;
|
|
92
92
|
const mode = clusterStore.autoPickupModeOf(state);
|
|
93
93
|
const session = state.smartPickup?.session;
|
|
94
|
-
if (!isSmartPickupMode(mode) || !session || !state.smartPickup?.evaluator)
|
|
94
|
+
if (state.autoPickupPausedAt !== undefined || !isSmartPickupMode(mode) || !session || !state.smartPickup?.evaluator)
|
|
95
95
|
return null;
|
|
96
96
|
if (deps.now() >= session.expiresAt)
|
|
97
97
|
return null;
|
|
@@ -101,11 +101,11 @@ function armed(clusterId) {
|
|
|
101
101
|
// evaluation per recipient at a time; a trigger during a run schedules one
|
|
102
102
|
// more pass afterwards.
|
|
103
103
|
export function onSmartPickupMail(clusterId, workflowId, chainDepth = 0) {
|
|
104
|
-
if (!armed(clusterId))
|
|
105
|
-
return Promise.resolve();
|
|
106
104
|
const k = key(clusterId, workflowId);
|
|
107
105
|
if (chainDepth > (depthSeen.get(k) ?? 0))
|
|
108
106
|
depthSeen.set(k, chainDepth);
|
|
107
|
+
if (!armed(clusterId))
|
|
108
|
+
return Promise.resolve();
|
|
109
109
|
const current = running.get(k);
|
|
110
110
|
if (current) {
|
|
111
111
|
rerun.add(k);
|
|
@@ -153,8 +153,10 @@ export async function evaluateOnce(clusterId, workflowId) {
|
|
|
153
153
|
if (prior && prior.sessionId === arm.sessionId && prior.fingerprint === snapshot.fingerprint) {
|
|
154
154
|
// An admitted-in-principle wake that was blocked by a passing condition
|
|
155
155
|
// (busy, cooldown) is retried without asking the evaluator again.
|
|
156
|
-
if (prior.wakeOwed && arm.mode === 'smart-auto')
|
|
157
|
-
|
|
156
|
+
if (prior.wakeOwed && arm.mode === 'smart-auto') {
|
|
157
|
+
const fallback = prior.action === null;
|
|
158
|
+
return gateAndRecord({ ...base, action: fallback ? null : 'wake', reason: fallback ? prior.reason : 'retry', outcome: 'pending' }, arm);
|
|
159
|
+
}
|
|
158
160
|
// A defer lapses after deferMs so unchanged mail is looked at again; an
|
|
159
161
|
// evaluation refused by a passing limit is attempted again.
|
|
160
162
|
const deferLapsed = prior.action === 'defer' && prior.deferUntil !== undefined && deps.now() >= prior.deferUntil;
|
|
@@ -175,6 +177,8 @@ export async function evaluateOnce(clusterId, workflowId) {
|
|
|
175
177
|
return d;
|
|
176
178
|
}
|
|
177
179
|
const evaluator = state.smartPickup.evaluator;
|
|
180
|
+
if (armed(clusterId)?.sessionId !== arm.sessionId)
|
|
181
|
+
return null;
|
|
178
182
|
const slot = await reserveSmartPickup(clusterId, { kind: 'evaluator', memberId: workflowId, sessionId: arm.sessionId, limits, now: deps.now() }).catch(() => ({ ok: false, reason: 'ledger_unreadable' }));
|
|
179
183
|
if (!slot.ok) {
|
|
180
184
|
const d = { ...base, action: null, reason: slot.reason, outcome: 'skipped' };
|
|
@@ -189,6 +193,10 @@ export async function evaluateOnce(clusterId, workflowId) {
|
|
|
189
193
|
}
|
|
190
194
|
let raw = null;
|
|
191
195
|
let failure = null;
|
|
196
|
+
if (armed(clusterId)?.sessionId !== arm.sessionId) {
|
|
197
|
+
await settleSmartPickup(clusterId, slot.id, 'session_changed', deps.now()).catch(() => undefined);
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
192
200
|
try {
|
|
193
201
|
raw = await evaluatorAdapter(evaluator.provider).evaluate({
|
|
194
202
|
model: evaluator.model,
|
|
@@ -211,21 +219,32 @@ export async function evaluateOnce(clusterId, workflowId) {
|
|
|
211
219
|
}
|
|
212
220
|
if (failure !== null) {
|
|
213
221
|
const d = { ...base, action: null, reason: `evaluator_error:${failure}`.slice(0, 64), outcome: 'none' };
|
|
214
|
-
//
|
|
215
|
-
//
|
|
216
|
-
//
|
|
217
|
-
//
|
|
222
|
+
// Preserve the established one retry for a failure before the evaluator
|
|
223
|
+
// session was ready: the model has not seen this mail yet. The retry
|
|
224
|
+
// spends its own reservation. A second startup failure or any other
|
|
225
|
+
// failure then takes the guarded fallback path without another request.
|
|
218
226
|
const sameMail = prior?.fingerprint === snapshot.fingerprint && prior.sessionId === arm.sessionId;
|
|
219
227
|
if (isStartupFailure(failure) && !(sameMail && prior?.startupRetried)) {
|
|
220
228
|
await record(d, { retryEvaluation: true, startupRetried: true });
|
|
221
229
|
return d;
|
|
222
230
|
}
|
|
231
|
+
if (failure === 'cancelled') {
|
|
232
|
+
d.outcome = 'discarded';
|
|
233
|
+
await record(d);
|
|
234
|
+
return d;
|
|
235
|
+
}
|
|
236
|
+
if (still.mode === 'smart-auto')
|
|
237
|
+
return gateAndRecord(d, still);
|
|
238
|
+
d.outcome = 'fallback_observed';
|
|
223
239
|
await record(d);
|
|
224
240
|
return d;
|
|
225
241
|
}
|
|
226
242
|
const parsed = parseEvaluatorAnswer(raw);
|
|
227
243
|
if (!parsed.ok) {
|
|
228
244
|
const d = { ...base, action: null, reason: `invalid_answer:${parsed.problem}`, outcome: 'none' };
|
|
245
|
+
if (still.mode === 'smart-auto')
|
|
246
|
+
return gateAndRecord(d, still);
|
|
247
|
+
d.outcome = 'fallback_observed';
|
|
229
248
|
await record(d);
|
|
230
249
|
return d;
|
|
231
250
|
}
|
|
@@ -245,7 +264,10 @@ export async function evaluateOnce(clusterId, workflowId) {
|
|
|
245
264
|
const TRANSIENT = new Set(['busy', 'cooldown', 'rate_capped', 'limit_wakes_member_hour']);
|
|
246
265
|
async function gateAndRecord(proposal, arm) {
|
|
247
266
|
const result = await gateWake(proposal, arm);
|
|
248
|
-
const
|
|
267
|
+
const fallback = proposal.action === null;
|
|
268
|
+
const d = fallback
|
|
269
|
+
? { ...proposal, outcome: `fallback_${result.outcome}${result.reason ? `:${result.reason}` : ''}` }
|
|
270
|
+
: { ...proposal, outcome: result.outcome, ...(result.reason ? { reason: proposal.reason === 'retry' ? result.reason : `${proposal.reason}:${result.reason}` } : {}) };
|
|
249
271
|
const owed = result.outcome !== 'woke' && result.reason !== undefined && TRANSIENT.has(result.reason);
|
|
250
272
|
await record(d, owed ? { wakeOwed: true } : {});
|
|
251
273
|
return d;
|
|
@@ -297,6 +319,27 @@ async function gateWake(p, arm) {
|
|
|
297
319
|
refusal = 'mail_changed';
|
|
298
320
|
return false;
|
|
299
321
|
}
|
|
322
|
+
if (p.action === null) {
|
|
323
|
+
// Ordinary pickup ignores bare acknowledgements. Re-read the same
|
|
324
|
+
// exact mailbox under its lock; unreadable or empty mail cannot
|
|
325
|
+
// authorise fallback, and attachments retain their normal exception.
|
|
326
|
+
let pending;
|
|
327
|
+
try {
|
|
328
|
+
pending = await clusterMailbox.peek(wfid);
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
refusal = 'unverifiable';
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
if (ids.length === 0 || pending.length !== ids.length || pending.some((m) => !ids.includes(m.msgId))) {
|
|
335
|
+
refusal = 'unverifiable';
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
if (pending.every((m) => !m.artifacts?.length && isAutoPickupAcknowledgement(m.content))) {
|
|
339
|
+
refusal = 'ack_only';
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
300
343
|
if (await smartPickupHoldActive(clusterId, wfid, ids, deps.now()).catch(() => true)) {
|
|
301
344
|
refusal = 'stop_hold';
|
|
302
345
|
return false;
|
|
@@ -342,24 +385,27 @@ export async function sweepSmartPickupMail() {
|
|
|
342
385
|
sweeping = true;
|
|
343
386
|
try {
|
|
344
387
|
for (const clusterId of clusterStore.listKnownClusterIds().sort()) {
|
|
345
|
-
|
|
346
|
-
continue;
|
|
347
|
-
const members = [...(clusterStore.getClusterCached(clusterId)?.members ?? [])].sort();
|
|
348
|
-
// One member at a time per cluster, in a stable order, so the
|
|
349
|
-
// in-flight limit is respected and no mailbox starves another.
|
|
350
|
-
for (const wfid of members) {
|
|
351
|
-
if (deps.isBusy(wfid))
|
|
352
|
-
continue;
|
|
353
|
-
const depth = await clusterMailbox.depthFor(wfid).catch(() => 0);
|
|
354
|
-
if (depth > 0)
|
|
355
|
-
await onSmartPickupMail(clusterId, wfid).catch(() => undefined);
|
|
356
|
-
}
|
|
388
|
+
await pickupSmartWaitingMail(clusterId);
|
|
357
389
|
}
|
|
358
390
|
}
|
|
359
391
|
finally {
|
|
360
392
|
sweeping = false;
|
|
361
393
|
}
|
|
362
394
|
}
|
|
395
|
+
export async function pickupSmartWaitingMail(clusterId) {
|
|
396
|
+
if (!armed(clusterId))
|
|
397
|
+
return;
|
|
398
|
+
const members = [...(clusterStore.getClusterCached(clusterId)?.members ?? [])].sort();
|
|
399
|
+
// One member at a time per cluster, in a stable order, so the
|
|
400
|
+
// in-flight limit is respected and no mailbox starves another.
|
|
401
|
+
for (const wfid of members) {
|
|
402
|
+
if (deps.isBusy(wfid))
|
|
403
|
+
continue;
|
|
404
|
+
const depth = await clusterMailbox.depthFor(wfid).catch(() => 0);
|
|
405
|
+
if (depth > 0)
|
|
406
|
+
await onSmartPickupMail(clusterId, wfid).catch(() => undefined);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
363
409
|
let mailTimer = null;
|
|
364
410
|
const MAIL_SWEEP_MS = (() => {
|
|
365
411
|
const raw = Number(process.env.ARCO_SMART_PICKUP_MAIL_SWEEP_MS);
|
|
@@ -53,6 +53,7 @@ export declare class WorkerManager {
|
|
|
53
53
|
sessionId?: string;
|
|
54
54
|
}) => void;
|
|
55
55
|
drainSteer?: WorkerConfig['drainSteer'];
|
|
56
|
+
peekSteer?: WorkerConfig['peekSteer'];
|
|
56
57
|
requeueSteer?: WorkerConfig['requeueSteer'];
|
|
57
58
|
onSteerDelivered?: WorkerConfig['onSteerDelivered'];
|
|
58
59
|
codexTransport?: WorkerConfig['codexTransport'];
|
|
@@ -64,6 +64,7 @@ export class WorkerManager {
|
|
|
64
64
|
voiceOperator: options?.voiceOperator,
|
|
65
65
|
incognito: options?.incognito,
|
|
66
66
|
drainSteer: options?.drainSteer,
|
|
67
|
+
peekSteer: options?.peekSteer,
|
|
67
68
|
requeueSteer: options?.requeueSteer,
|
|
68
69
|
onSteerDelivered: options?.onSteerDelivered,
|
|
69
70
|
// Phase 6 — workflowId is required for per-workflow-lifetime providers
|
|
@@ -19,7 +19,7 @@ function formatCapMb(bytes) {
|
|
|
19
19
|
}
|
|
20
20
|
export const OUTPUT_TRUNCATION_NOTICE = `\n\n[OUTPUT TRUNCATED — Arco enforced ${formatCapMb(MAX_WORKER_OUTPUT_BYTES)} worker-output cap. ` +
|
|
21
21
|
'For reports larger than this, instruct the worker to write the full ' +
|
|
22
|
-
'output to a markdown file in the workflow artifacts directory and return only a brief summary + path.]';
|
|
22
|
+
'output to a markdown file in the workflow artifacts directory and return only a brief summary + path, unless the operator wants it kept in the project.]';
|
|
23
23
|
function parseRssEnv() {
|
|
24
24
|
const raw = process.env.ARCO_RSS_KILL_BYTES;
|
|
25
25
|
if (!raw)
|
|
@@ -61,6 +61,10 @@ export function buildWorkerSafetyFooter(cwd, wfid) {
|
|
|
61
61
|
const bigOutputLine = dir
|
|
62
62
|
? `- For report-shaped outputs (deep dives, inventories, audits, multi-section findings), write a markdown file into \`${dir}/\` (this directory already exists) and return a brief summary that names the file in backticks (for example \`audit-spawns.md\`) so it is clickable in chat. Do NOT write report files at the project root — Arco tracks artifacts per-workflow and surfaces them inline in chat. For ordinary prose responses — even detailed ones — return the full text inline; the operator reads it in chat.`
|
|
63
63
|
: `- For report-shaped outputs (deep dives, inventories, audits, multi-section findings), write a markdown file in the cwd and return a brief summary + absolute path. For ordinary prose responses — even detailed ones — return the full text inline; the operator reads it in chat.`;
|
|
64
|
+
const projectStateLine = `Never commit, force-add or add an ignore exception for \`.arco/\`, which is local state, except a skill shared through SHARE WITH REPOSITORY.`;
|
|
65
|
+
const projectFilesLine = dir
|
|
66
|
+
? `\n- Put files the operator wants kept in the project (documentation, a README or notes to commit) in the project tree, for example \`docs/\`, not in artifacts. ${projectStateLine}`
|
|
67
|
+
: `\n- ${projectStateLine}`;
|
|
64
68
|
const scratchLine = dir
|
|
65
69
|
? `\n- Put large intermediate files (builds, disk images, downloads, datasets) in \`${path.join(path.dirname(dir), 'scratch')}/\` (create it if missing), not in artifacts. Keep only finished deliverables in artifacts. The operator empties scratch with EMPTY SCRATCH; nothing there is deleted automatically.`
|
|
66
70
|
: '';
|
|
@@ -72,7 +76,7 @@ export function buildWorkerSafetyFooter(cwd, wfid) {
|
|
|
72
76
|
- No \`find /\` / \`du -sh /\` without \`-maxdepth\` and exclusions for \`/proc /sys /dev /run\`. Skip \`~/.cache\`, \`node_modules\`, \`.git/objects\`, \`/var/cache\`, \`/snap\`.
|
|
73
77
|
- No reads of \`/proc/kcore\`, \`/proc/*/mem\`, \`/dev/{kmem,mem,zero,urandom}\` past first KB. No unbounded \`journalctl\` or \`while true\` loops.
|
|
74
78
|
- No \`cat\` of files >10MB; use \`head -c 100K\` instead. \`xargs\` always with explicit limits.
|
|
75
|
-
${bigOutputLine}${scratchLine}
|
|
79
|
+
${bigOutputLine}${projectFilesLine}${scratchLine}
|
|
76
80
|
- Arco will hard-kill your process tree at 32GB RSS or ${formatCapMb(MAX_WORKER_OUTPUT_BYTES)} returned output. These are the floor, not the budget.
|
|
77
81
|
`;
|
|
78
82
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PrimaryConfig } from './primitives/seedWorker.js';
|
|
1
2
|
import type { ProviderName, ModelName, EffortLevel, WorkflowMetaSummary, SessionHistoryEntry, PreviewHistoryEntry, SessionInfo, McpWorkflowAllow, GenesisSeed, WorkflowConfig, ArcoSkillRef, AutoHandoffConfig } from '@arco/shared';
|
|
2
3
|
declare const WFID_PATTERN: RegExp;
|
|
3
4
|
export declare function workflowDir(cwd: string, wfid: string): string;
|
|
@@ -23,6 +24,7 @@ export interface WorkflowMeta {
|
|
|
23
24
|
providerAccountRef?: string;
|
|
24
25
|
schemaVersion?: number;
|
|
25
26
|
cliSessions: WorkflowCliSession[];
|
|
27
|
+
providerConversationPendingReading?: boolean;
|
|
26
28
|
history?: SessionHistoryEntry[];
|
|
27
29
|
handoffHistory?: import('./handoffHistory.js').HandoffHistorySource[];
|
|
28
30
|
operator: string;
|
|
@@ -119,7 +121,7 @@ export declare function ensureMeta(cwd: string, seed: WorkflowMeta): Promise<Wor
|
|
|
119
121
|
export declare function setResolvedModelId(cwd: string, wfid: string, resolvedModelId: string): Promise<void>;
|
|
120
122
|
export declare function touchLastActive(cwd: string, wfid: string): Promise<void>;
|
|
121
123
|
export declare function appendCliSession(cwd: string, wfid: string, session: WorkflowCliSession): Promise<void>;
|
|
122
|
-
export declare function reconcileLatestCliSession(cwd: string, wfid: string, provider: ProviderName, liveSessionId: string, providerAccountRef?: string): Promise<void>;
|
|
124
|
+
export declare function reconcileLatestCliSession(cwd: string, wfid: string, provider: ProviderName, liveSessionId: string, providerAccountRef?: string, seed?: WorkflowMeta): Promise<void>;
|
|
123
125
|
export declare function latestCliSessionFor(meta: WorkflowMeta, provider: ProviderName): WorkflowCliSession | null;
|
|
124
126
|
export declare function arcoInternalSessionInfoForMeta(meta: WorkflowMeta): SessionInfo | null;
|
|
125
127
|
export declare function appendHistoryEntry(cwd: string, wfid: string, entry: SessionHistoryEntry): Promise<void>;
|
|
@@ -127,3 +129,11 @@ export declare function clearProviderCliSessions(cwd: string, wfid: string, prov
|
|
|
127
129
|
export declare function setMcpAllow(cwd: string, wfid: string, entry: McpWorkflowAllow): Promise<McpWorkflowAllow[] | null>;
|
|
128
130
|
export declare function setMcpProbedTools(cwd: string, wfid: string, serverId: string, tools: McpWorkflowAllow['tools']): Promise<void>;
|
|
129
131
|
export declare function listWorkflowMetas(cwd: string): Promise<WorkflowMetaSummary[]>;
|
|
132
|
+
export declare function workflowMetaSeed(cwd: string, workflowId: string, config: WorkflowConfig, primary: Pick<PrimaryConfig, 'provider' | 'model' | 'effort'>, opts?: {
|
|
133
|
+
parentWorkflowId?: string;
|
|
134
|
+
}): WorkflowMeta;
|
|
135
|
+
export declare function persistInitialMeta(cwd: string, workflowId: string, config: WorkflowConfig, primary: Pick<PrimaryConfig, 'provider' | 'model' | 'effort'>, opts?: {
|
|
136
|
+
parentWorkflowId?: string;
|
|
137
|
+
sessionId?: string;
|
|
138
|
+
pendingReading?: boolean;
|
|
139
|
+
}): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { beginConversationWrite } from './conversationActivity.js';
|
|
2
2
|
import { ensureProjectStateIgnore } from './projectStateIgnore.js';
|
|
3
|
-
import { normalizeAutoHandoff, normalizeOutputStyle, retiredProviderReason, resolveAutoCompactionPolicy } from '@arco/shared';
|
|
3
|
+
import { isAutoCompactionPolicy, storedOutputStyle, normalizeAutoHandoff, normalizeOutputStyle, retiredProviderReason, resolveAutoCompactionPolicy } from '@arco/shared';
|
|
4
4
|
// Slot 9 — per-workflow identity + session ledger (meta.json).
|
|
5
5
|
//
|
|
6
6
|
// Lives at <cwd>/.arco/workflows/<wfid>/meta.json alongside Slot 5's
|
|
@@ -226,8 +226,8 @@ export async function updateMeta(cwd, wfid, mutate) {
|
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
228
|
// Ensure a meta.json exists — write one from `seed` if missing. Used by the
|
|
229
|
-
//
|
|
230
|
-
//
|
|
229
|
+
// creation, reconnect and turn paths. Existing metadata is preserved, including
|
|
230
|
+
// updates that land while the caller is constructing its authoritative seed.
|
|
231
231
|
export async function ensureMeta(cwd, seed) {
|
|
232
232
|
if (!cwd)
|
|
233
233
|
return seed;
|
|
@@ -270,11 +270,16 @@ export async function appendCliSession(cwd, wfid, session) {
|
|
|
270
270
|
// with Arco's placeholder id. Update that provider's latest entry in place
|
|
271
271
|
// rather than appending a second row; when the ids already match, only refresh
|
|
272
272
|
// lastActiveAt. This keeps resume lookup aligned with the live CLI session
|
|
273
|
-
// after initial binding or session rotation.
|
|
274
|
-
|
|
273
|
+
// after initial binding or session rotation. An authoritative seed repairs a
|
|
274
|
+
// missing file inside the same lock; generic updateMeta remains update-only.
|
|
275
|
+
export async function reconcileLatestCliSession(cwd, wfid, provider, liveSessionId, providerAccountRef, seed) {
|
|
275
276
|
if (!cwd || !liveSessionId)
|
|
276
277
|
return;
|
|
277
|
-
|
|
278
|
+
validateWfid(wfid);
|
|
279
|
+
await withFileLock(metaPath(cwd, wfid), async () => {
|
|
280
|
+
const meta = await readMeta(cwd, wfid) ?? seed;
|
|
281
|
+
if (!meta)
|
|
282
|
+
throw new Error('Workflow metadata is missing; the provider conversation was not saved.');
|
|
278
283
|
// Find the latest entry for this provider (not strictly the last overall —
|
|
279
284
|
// a cross-provider workflow might have interleaved entries).
|
|
280
285
|
let latestIdx = -1;
|
|
@@ -295,6 +300,13 @@ export async function reconcileLatestCliSession(cwd, wfid, provider, liveSession
|
|
|
295
300
|
meta.cliSessions[latestIdx].providerAccountRef = providerAccountRef;
|
|
296
301
|
}
|
|
297
302
|
meta.lastActiveAt = now;
|
|
303
|
+
if (seed) {
|
|
304
|
+
if (seed.providerConversationPendingReading)
|
|
305
|
+
meta.providerConversationPendingReading = true;
|
|
306
|
+
else
|
|
307
|
+
delete meta.providerConversationPendingReading;
|
|
308
|
+
}
|
|
309
|
+
await writeMeta(cwd, meta);
|
|
298
310
|
});
|
|
299
311
|
}
|
|
300
312
|
// Most recent CLI session for the given provider, or null if the workflow
|
|
@@ -421,4 +433,118 @@ export async function listWorkflowMetas(cwd) {
|
|
|
421
433
|
out.sort((a, b) => b.lastActiveAt - a.lastActiveAt);
|
|
422
434
|
return out;
|
|
423
435
|
}
|
|
436
|
+
export function workflowMetaSeed(cwd, workflowId, config, primary, opts) {
|
|
437
|
+
const now = Date.now();
|
|
438
|
+
return {
|
|
439
|
+
workflowId,
|
|
440
|
+
name: config.name,
|
|
441
|
+
cwd,
|
|
442
|
+
...(config.kind === 'chat' ? { kind: 'chat' } : {}),
|
|
443
|
+
...(config.kind === 'chat' && config.voiceOperator === true ? { voiceOperator: true } : {}),
|
|
444
|
+
createdAt: now,
|
|
445
|
+
lastActiveAt: now,
|
|
446
|
+
primaryProvider: primary.provider,
|
|
447
|
+
primaryModel: primary.model,
|
|
448
|
+
primaryEffort: primary.effort,
|
|
449
|
+
...(config.providerAccountRef ? { providerAccountRef: config.providerAccountRef } : {}),
|
|
450
|
+
cliSessions: [],
|
|
451
|
+
operator: 'local',
|
|
452
|
+
lastEventSeq: null,
|
|
453
|
+
lastTranscriptSeq: null,
|
|
454
|
+
compactedAt: null,
|
|
455
|
+
...(config.pinnedSkills?.length
|
|
456
|
+
? { pinnedSkills: config.pinnedSkills.map((s) => ({ scope: s.scope, slug: s.slug })) }
|
|
457
|
+
: {}),
|
|
458
|
+
...(opts?.parentWorkflowId ? { parentWorkflowId: opts.parentWorkflowId } : {}),
|
|
459
|
+
// docs/PROVIDERS.md / docs/PROVIDERS.md - when the New-tab
|
|
460
|
+
// picker (or Spawn-from-here parent inheritance) provided a non-default
|
|
461
|
+
// value, persist it to disk on the very first meta write so a server
|
|
462
|
+
// restart before the operator's first turn doesn't lose the pick.
|
|
463
|
+
// Sanitized one more time at write-site against unknown values reaching
|
|
464
|
+
// disk via a hand-edited cascade default.
|
|
465
|
+
...(config.efficiencyToolFilter === 'off' || config.efficiencyToolFilter === 'conservative' || config.efficiencyToolFilter === 'aggressive'
|
|
466
|
+
? { efficiencyToolFilter: config.efficiencyToolFilter }
|
|
467
|
+
: {}),
|
|
468
|
+
// docs/PROVIDERS.md - persist the stamped new-tab default or
|
|
469
|
+
// an explicit operator choice on the first meta write.
|
|
470
|
+
...(config.efficiencyFactForce === 'on' || config.efficiencyFactForce === 'off'
|
|
471
|
+
? { efficiencyFactForce: config.efficiencyFactForce }
|
|
472
|
+
: {}),
|
|
473
|
+
// Persist an explicit config-protection choice to disk on first meta-write
|
|
474
|
+
// so an operator opt-out survives a restart. Absent ⇒ gate ON by default.
|
|
475
|
+
...(config.efficiencyConfigProtection === 'on' || config.efficiencyConfigProtection === 'off'
|
|
476
|
+
? { efficiencyConfigProtection: config.efficiencyConfigProtection }
|
|
477
|
+
: {}),
|
|
478
|
+
...(typeof config.claudeNativeCompact === 'boolean'
|
|
479
|
+
? {
|
|
480
|
+
claudeNativeCompact: config.claudeNativeCompact,
|
|
481
|
+
...(config.claudeNativeCompact === true ? { claudeNativeCompactUserSetAt: now } : {}),
|
|
482
|
+
}
|
|
483
|
+
: {}),
|
|
484
|
+
...(typeof config.claudeNativeForceInterleavedThinkingBeta === 'boolean'
|
|
485
|
+
? { claudeNativeForceInterleavedThinkingBeta: config.claudeNativeForceInterleavedThinkingBeta }
|
|
486
|
+
: {}),
|
|
487
|
+
nativeSubagents: config.nativeSubagents,
|
|
488
|
+
claudeNativeTaskDisabled: config.claudeNativeTaskDisabled,
|
|
489
|
+
...(config.claudeNativeThinkingDisplay === 'omitted' || config.claudeNativeThinkingDisplay === 'summarized' || config.claudeNativeThinkingDisplay === 'updates'
|
|
490
|
+
? { claudeNativeThinkingDisplay: config.claudeNativeThinkingDisplay }
|
|
491
|
+
: {}),
|
|
492
|
+
...(config.codexTransport === 'exec' || config.codexTransport === 'appserver'
|
|
493
|
+
? { codexTransport: config.codexTransport }
|
|
494
|
+
: {}),
|
|
495
|
+
...(config.codexContextPolicy === 'max' || config.codexContextPolicy === 'standard'
|
|
496
|
+
? { codexContextPolicy: config.codexContextPolicy }
|
|
497
|
+
: {}),
|
|
498
|
+
...(config.claudeTransport === 'cli' || config.claudeTransport === 'native'
|
|
499
|
+
? { claudeTransport: config.claudeTransport }
|
|
500
|
+
: {}),
|
|
501
|
+
// Persist the seeded auto-handoff default on the first meta-write so a
|
|
502
|
+
// server restart before the operator's first turn keeps the global
|
|
503
|
+
// default (handleCreateWorkflow bakes it into config for new tabs). The
|
|
504
|
+
// savedMeta restore in handleCreateWorkflow reads this back.
|
|
505
|
+
...(isAutoCompactionPolicy(config.autoCompaction) ? { autoCompaction: { ...config.autoCompaction } } : {}),
|
|
506
|
+
...(config.autoHandoff ? { autoHandoff: { ...config.autoHandoff } } : {}),
|
|
507
|
+
// docs/PROVIDERS.md - persist the sandbox toggle on the
|
|
508
|
+
// first meta-write when the cascade default supplied a non-undefined
|
|
509
|
+
// value. Default is 'off'; only the explicit on/off pair lands here so
|
|
510
|
+
// a stale cascade doesn't accidentally turn the sandbox on for tabs
|
|
511
|
+
// that were never asked.
|
|
512
|
+
...(config.efficiencySandbox === 'on' || config.efficiencySandbox === 'off'
|
|
513
|
+
? { efficiencySandbox: config.efficiencySandbox }
|
|
514
|
+
: {}),
|
|
515
|
+
// docs/PROVIDERS.md - persist the review-gate toggle on the first meta-write
|
|
516
|
+
// when the cascade default supplied an explicit value, so an operator opt-in
|
|
517
|
+
// survives a restart before the first turn. Default 'off'.
|
|
518
|
+
...(config.reviewSafeMode === 'on' || config.reviewSafeMode === 'off'
|
|
519
|
+
? { reviewSafeMode: config.reviewSafeMode }
|
|
520
|
+
: {}),
|
|
521
|
+
// Only a style other than the default is written; unset means
|
|
522
|
+
// DEFAULT_OUTPUT_STYLE. Legacy `lite` / `caveman` from a stale client are
|
|
523
|
+
// written as `plain` / `terse` (plain being the default, it stays unset).
|
|
524
|
+
...(storedOutputStyle(config.outputStyle) ? { outputStyle: storedOutputStyle(config.outputStyle) } : {}),
|
|
525
|
+
// docs/GOTCHAS.md - persist a north-star seeded before the first turn
|
|
526
|
+
// (e.g. a Spawn-from-here that inherited the parent's) so it survives a
|
|
527
|
+
// restart even if the operator never re-sets it. Blank ⇒ omitted.
|
|
528
|
+
...(config.goal && config.goal.trim() ? { goal: config.goal } : {}),
|
|
529
|
+
// docs/PROVIDERS.md - persist sticky ultracode on the first meta-write so a
|
|
530
|
+
// tab left in ultracode survives a restart (the rehydrate read in
|
|
531
|
+
// workflowHandlers.ts expects saved.ultracode). Without this the flag lives
|
|
532
|
+
// only in-memory and the tab silently drops out of ultracode on restart.
|
|
533
|
+
...(config.ultracode === true ? { ultracode: true } : {}),
|
|
534
|
+
...(typeof config.webSearchMaxUses === 'number' ? { webSearchMaxUses: config.webSearchMaxUses } : {}),
|
|
535
|
+
...(config.managedWorktreeSourceCwd
|
|
536
|
+
? { managedWorktreeSourceCwd: config.managedWorktreeSourceCwd }
|
|
537
|
+
: {}),
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
export async function persistInitialMeta(cwd, workflowId, config, primary, opts) {
|
|
541
|
+
if (config.incognito)
|
|
542
|
+
return;
|
|
543
|
+
const seed = workflowMetaSeed(cwd, workflowId, config, primary, opts);
|
|
544
|
+
if (opts?.pendingReading)
|
|
545
|
+
seed.providerConversationPendingReading = true;
|
|
546
|
+
if (opts?.sessionId)
|
|
547
|
+
seed.cliSessions.push({ provider: primary.provider, sessionId: opts.sessionId, createdAt: Date.now(), providerAccountRef: config.providerAccountRef });
|
|
548
|
+
await ensureMeta(cwd, seed);
|
|
549
|
+
}
|
|
424
550
|
//# sourceMappingURL=workflowMeta.js.map
|
|
@@ -68,6 +68,7 @@ export declare function handleClusterAutoTurnToggle(ws: WebSocket, clusterId: st
|
|
|
68
68
|
export declare function handleClusterAutoPickupSet(ws: WebSocket, msg: {
|
|
69
69
|
clusterId: string;
|
|
70
70
|
mode: unknown;
|
|
71
|
+
paused?: unknown;
|
|
71
72
|
evaluator?: unknown;
|
|
72
73
|
limits?: unknown;
|
|
73
74
|
ruleLimits?: unknown;
|
|
@@ -2389,9 +2389,10 @@ export async function handleClusterAutoTurnToggle(ws, clusterId, enabled) {
|
|
|
2389
2389
|
// Operator chose an AUTO-PICKUP mode in the cluster dialog. Smart modes need
|
|
2390
2390
|
// an evaluator from an enabled provider and start a new session; Off and
|
|
2391
2391
|
// Rule-based end any Smart session. Pushes cluster_state on success.
|
|
2392
|
+
// A pause-only request keeps the current mode, session and budgets.
|
|
2392
2393
|
export async function handleClusterAutoPickupSet(ws, msg) {
|
|
2393
2394
|
const settings = await readSettings().catch(() => null);
|
|
2394
|
-
const result = await applyAutoPickup(msg.clusterId, { mode: msg.mode, evaluator: msg.evaluator, limits: msg.limits, ruleLimits: msg.ruleLimits, resumeRule: msg.resumeRule }, (provider) => settings?.enabledProviders?.[provider] !== false);
|
|
2395
|
+
const result = await applyAutoPickup(msg.clusterId, { mode: msg.mode, paused: msg.paused, evaluator: msg.evaluator, limits: msg.limits, ruleLimits: msg.ruleLimits, resumeRule: msg.resumeRule }, (provider) => settings?.enabledProviders?.[provider] !== false);
|
|
2395
2396
|
if (!result.ok) {
|
|
2396
2397
|
send(ws, { type: 'error', message: `cluster_auto_pickup_set rejected: ${result.problem}` });
|
|
2397
2398
|
return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocket } from 'ws';
|
|
2
2
|
import type { CompactWorkflowMessage, FoldWorkflowMessage } from '@arco/shared';
|
|
3
3
|
import type { Session } from '../workflows/types.js';
|
|
4
|
-
export declare function handleCompactWorkflow(ws: WebSocket, session: Session, msg: CompactWorkflowMessage, claimGuard?: (claim: () => number) => Promise<number | false>, autoDetail?: string): Promise<void>;
|
|
4
|
+
export declare function handleCompactWorkflow(ws: WebSocket, session: Session, msg: CompactWorkflowMessage, claimGuard?: (claim: () => number) => Promise<number | false>, autoDetail?: string, onSuccess?: () => void): Promise<void>;
|
|
5
5
|
export declare function handleFoldWorkflow(ws: WebSocket, _session: Session, msg: FoldWorkflowMessage): Promise<void>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { hasConversationHistory } from '../providerConversation.js';
|
|
1
2
|
import { supportsManualCompact } from '../manualCompactCapability.js';
|
|
2
3
|
import { publishActivity } from '../voice/activityBus.js';
|
|
3
4
|
import { resolveOutputStyle } from '@arco/shared';
|
|
4
|
-
import { claimBusy, ownsBusy, drainQueueIfIdle, maybeAutoContinueAfterCompact, releaseBusy, resetCodexContextAfterCompact, } from './turnEngine.js';
|
|
5
|
+
import { claimBusy, ownsBusy, drainQueueIfIdle, maybeAutoContinueAfterCompact, releaseBusy, resetCodexContextAfterCompact, resetAutoCompactionCycle, } from './turnEngine.js';
|
|
5
6
|
import { send, broadcastWorkflow, broadcastTransient, notifyClusterStateForWorkflow } from '../server/broadcast.js';
|
|
6
7
|
import { workflows, workflowCwds } from '../server/state.js';
|
|
7
8
|
import { compactCodexAppServerThread } from '../providers/codex-appserver/index.js';
|
|
@@ -12,7 +13,7 @@ import { armOllamaForceCompact } from '../providers/ollamaForceCompact.js';
|
|
|
12
13
|
import { resolveProviderAccount } from '../providerAccounts.js';
|
|
13
14
|
import { readSettings } from '../settings.js';
|
|
14
15
|
import * as clusterStore from '../clusterStore.js';
|
|
15
|
-
export async function handleCompactWorkflow(ws, session, msg, claimGuard, autoDetail) {
|
|
16
|
+
export async function handleCompactWorkflow(ws, session, msg, claimGuard, autoDetail, onSuccess) {
|
|
16
17
|
const workflowId = msg.workflowId;
|
|
17
18
|
const wf = workflows.get(workflowId);
|
|
18
19
|
if (!wf) {
|
|
@@ -121,7 +122,7 @@ export async function handleCompactWorkflow(ws, session, msg, claimGuard, autoDe
|
|
|
121
122
|
result = { ok: false, error: 'Compact needs the Codex app-server transport (CONFIG → TRANSPORT). On Codex exec, use Handoff.' };
|
|
122
123
|
}
|
|
123
124
|
else if (!wf.primarySessionId) {
|
|
124
|
-
result = { ok: false, error: 'no saved Codex thread for this workflow — run a turn first' };
|
|
125
|
+
result = { ok: false, error: await hasConversationHistory(cwd, workflowId) ? 'The previous Codex conversation cannot be resumed because its saved thread id is unavailable. The next message starts a new conversation; earlier messages remain in this tab.' : 'no saved Codex thread for this workflow — run a turn first' };
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
127
128
|
const account = await resolveProviderAccount('codex', wf.config.providerAccountRef, cwd).catch(() => null);
|
|
@@ -155,7 +156,7 @@ export async function handleCompactWorkflow(ws, session, msg, claimGuard, autoDe
|
|
|
155
156
|
else if (provider === 'cursor') {
|
|
156
157
|
compactedVia = 'cursor-acp';
|
|
157
158
|
if (!wf.primarySessionId) {
|
|
158
|
-
result = { ok: false, error: 'no saved Cursor session for this workflow — run a turn first' };
|
|
159
|
+
result = { ok: false, error: await hasConversationHistory(cwd, workflowId) ? 'The previous Cursor conversation cannot be resumed because its saved session id is unavailable. The next message starts a new conversation; earlier messages remain in this tab.' : 'no saved Cursor session for this workflow — run a turn first' };
|
|
159
160
|
}
|
|
160
161
|
else {
|
|
161
162
|
const turnClusterId = clusterStore.getClusterIdForWorkflow(workflowId);
|
|
@@ -213,6 +214,12 @@ export async function handleCompactWorkflow(ws, session, msg, claimGuard, autoDe
|
|
|
213
214
|
// False when STOP revoked the claim mid-compact (and a newer turn may hold
|
|
214
215
|
// busy now) — report the outcome but leave busy + the queue alone.
|
|
215
216
|
const owned = releaseBusy(wf, busyToken, 'interrupted', false);
|
|
217
|
+
if (result.ok && owned) {
|
|
218
|
+
if (autoDetail)
|
|
219
|
+
onSuccess?.();
|
|
220
|
+
else
|
|
221
|
+
resetAutoCompactionCycle(wf);
|
|
222
|
+
}
|
|
216
223
|
if (result.ok && owned && autoDetail) {
|
|
217
224
|
if (provider === 'codex')
|
|
218
225
|
resetCodexContextAfterCompact(workflowId, wf);
|