arco-workbench 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +9 -0
- package/README.md +11 -4
- package/client/dist/assets/{PhosphorBackdrop-D6cbmLNY.js → PhosphorBackdrop-BR-TgB5x.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-2dyerOi4.js → ThemedBackgroundShaderImpl-DgcFj6JN.js} +1 -1
- package/client/dist/assets/{XtermView-AIwo7O3D.js → XtermView-CflVBQgC.js} +1 -1
- package/client/dist/assets/{galleryEditor-DXAuxS8D.js → galleryEditor-BB-emfmi.js} +1 -1
- package/client/dist/assets/{index-8j6p-pmQ.js → index-B_EqHDz3.js} +242 -240
- package/client/dist/index.html +1 -1
- package/client/src/alerts/desktopAlerts.ts +13 -0
- package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +28 -5
- package/client/src/components/ClusterRightPanel/MemberRow.tsx +1 -1
- package/client/src/components/ClusterTaskBoardTab.tsx +54 -3
- package/client/src/components/ContextMeter.tsx +7 -0
- package/client/src/components/Home/HomeView.tsx +1 -1
- package/client/src/components/NeedsYouBadge.tsx +31 -16
- package/client/src/components/OperatorQuestionNotice.tsx +10 -1
- package/client/src/components/ProvidersPopover.tsx +23 -12
- package/client/src/components/TabBar.tsx +11 -8
- package/client/src/components/TabStatusChip.tsx +8 -7
- package/client/src/components/clusterNeedsYou.ts +27 -8
- package/client/src/help/content/cluster.tsx +34 -22
- package/client/src/help/content/composer.tsx +8 -1
- package/client/src/help/content/header.tsx +22 -13
- package/client/src/help/content/misc.tsx +8 -0
- package/client/src/help/content/tabbar.tsx +2 -1
- package/client/src/help/manualSections/clusters.tsx +61 -18
- package/client/src/help/manualSections/gettingStarted.tsx +10 -0
- package/client/src/help/manualSections/maintenance.tsx +38 -8
- package/client/src/help/manualSections/providers.tsx +10 -3
- package/client/src/help/manualSections/reference.tsx +1 -1
- package/client/src/help/manualSections/workflows.tsx +13 -0
- package/client/src/help/manualSections/workspace.tsx +7 -1
- package/client/src/questions/waitingQuestion.ts +3 -2
- package/client/src/stores/appStore.ts +1 -1
- package/client/src/stores/appStore.types.ts +1 -0
- package/client/src/stores/notificationStore.ts +2 -0
- package/client/src/utils/activityPresentation.ts +1 -1
- package/client/src/utils/tabStatus.ts +8 -0
- package/client/src/voice/commands.ts +4 -3
- package/client/src/voice/executor.ts +3 -3
- package/client/src/ws/handleServerMessage.ts +22 -2
- package/client/src/ws/operatorQuestions.ts +2 -0
- package/docs/CLIENT.md +3 -3
- package/docs/FEATURES.md +1 -1
- package/docs/GETTING_STARTED.md +11 -5
- package/docs/GLOSSARY.md +6 -2
- package/docs/GOTCHAS.md +17 -5
- package/docs/OPERATIONS.md +184 -5
- package/docs/PERSISTENCE.md +4 -0
- package/docs/PRIMITIVES.md +1 -1
- package/docs/PROTOCOL.md +1 -1
- package/docs/PROTOCOL_CLUSTER.md +9 -5
- package/docs/PROVIDERS.md +10 -5
- package/docs/SETTINGS.md +4 -2
- package/docs/TASK_LEDGER.md +6 -0
- package/docs/VOICE.md +2 -0
- package/native/win32-arm64/manifest.json +1 -1
- package/node_modules/@arco/shared/dist/clusterRolePresets.d.ts +1 -1
- package/node_modules/@arco/shared/dist/clusterRolePresets.js +10 -0
- package/node_modules/@arco/shared/dist/protocol/autoPickup.js +9 -1
- package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +2 -2
- package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -0
- package/node_modules/@arco/shared/dist/protocol/notifications.d.ts +4 -0
- package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +12 -0
- package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +9 -3
- package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +2 -2
- package/scripts/packaging/arco.mjs +1 -0
- package/server/dist/attention.d.ts +1 -1
- package/server/dist/attention.js +6 -4
- package/server/dist/capabilities.d.ts +9 -8
- package/server/dist/capabilities.js +71 -102
- package/server/dist/cliUpdateDecision.d.ts +34 -0
- package/server/dist/cliUpdateDecision.js +152 -0
- package/server/dist/clusterDirector.js +1 -0
- package/server/dist/clusterPeerOps.js +2 -2
- package/server/dist/defaults/models.md +1 -1
- package/server/dist/fileAccessPolicy.js +7 -5
- package/server/dist/http/workflowDataRoutes.js +1 -1
- package/server/dist/index.js +5 -1
- package/server/dist/primitives/seedWorker.d.ts +1 -0
- package/server/dist/primitives/seedWorker.js +2 -1
- package/server/dist/providerConversation.d.ts +9 -0
- package/server/dist/providerConversation.js +80 -0
- package/server/dist/providers/claude-native/retainedContext.d.ts +4 -0
- package/server/dist/providers/claude-native/retainedContext.js +20 -0
- package/server/dist/providers/claude-native/worker.d.ts +1 -0
- package/server/dist/providers/claude-native/worker.js +34 -6
- package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -0
- package/server/dist/providers/codex-appserver/operatorQuestions.js +30 -0
- package/server/dist/providers/codex-appserver/worker.js +9 -4
- package/server/dist/providers/ollama.js +2 -3
- package/server/dist/server/broadcast.d.ts +1 -1
- package/server/dist/smartPickupAdapters.d.ts +1 -0
- package/server/dist/smartPickupAdapters.js +18 -5
- package/server/dist/smartPickupObserver.js +45 -8
- package/server/dist/workers/WorkerManager.d.ts +1 -0
- package/server/dist/workers/WorkerManager.js +1 -0
- package/server/dist/workers/limits.js +6 -2
- package/server/dist/workflowMeta.d.ts +11 -1
- package/server/dist/workflowMeta.js +132 -6
- package/server/dist/workflows/types.d.ts +1 -0
- package/server/dist/ws/compactHandlers.d.ts +1 -1
- package/server/dist/ws/compactHandlers.js +11 -4
- package/server/dist/ws/handoffHandlers.js +16 -6
- package/server/dist/ws/operatorQuestionHandlers.d.ts +2 -1
- package/server/dist/ws/operatorQuestionHandlers.js +9 -1
- package/server/dist/ws/turnEngine.d.ts +2 -4
- package/server/dist/ws/turnEngine.js +88 -129
- package/server/package.json +1 -1
- package/server/src/attention.ts +5 -4
- package/server/src/capabilities.ts +70 -111
- package/server/src/cliUpdateDecision.ts +159 -0
- package/server/src/clusterDirector.ts +1 -0
- package/server/src/clusterPeerOps.ts +2 -2
- package/server/src/defaults/models.md +1 -1
- package/server/src/fileAccessPolicy.ts +7 -5
- package/server/src/http/workflowDataRoutes.ts +1 -1
- package/server/src/index.ts +5 -1
- package/server/src/primitives/seedWorker.ts +3 -1
- package/server/src/providerConversation.ts +71 -0
- package/server/src/providers/claude-native/retainedContext.ts +22 -0
- package/server/src/providers/claude-native/worker.ts +33 -5
- package/server/src/providers/codex-appserver/operatorQuestions.ts +24 -0
- package/server/src/providers/codex-appserver/worker.ts +8 -4
- package/server/src/providers/ollama.ts +2 -3
- package/server/src/smartPickupAdapters.ts +19 -5
- package/server/src/smartPickupObserver.ts +31 -6
- package/server/src/workers/WorkerManager.ts +2 -0
- package/server/src/workers/limits.ts +7 -2
- package/server/src/workflowMeta.ts +139 -5
- package/server/src/workflows/types.ts +1 -0
- package/server/src/ws/compactHandlers.ts +9 -3
- package/server/src/ws/handoffHandlers.ts +13 -6
- package/server/src/ws/operatorQuestionHandlers.ts +10 -2
- package/server/src/ws/turnEngine.ts +80 -135
- package/shared/dist/clusterRolePresets.d.ts +1 -1
- package/shared/dist/clusterRolePresets.js +10 -0
- package/shared/dist/protocol/autoPickup.js +9 -1
- package/shared/dist/protocol/clientMessages.d.ts +2 -2
- package/shared/dist/protocol/models.d.ts +6 -0
- package/shared/dist/protocol/notifications.d.ts +4 -0
- package/shared/dist/protocol/operatorQuestions.d.ts +12 -0
- package/shared/dist/protocol/serverMessages.d.ts +9 -3
- package/shared/dist/protocol/workflows.d.ts +1 -0
- package/shared/src/clusterRolePresets.ts +11 -1
- package/shared/src/protocol/autoPickup.ts +9 -1
- package/shared/src/protocol/clientMessages.ts +2 -1
- package/shared/src/protocol/models.ts +5 -2
- package/shared/src/protocol/notifications.ts +5 -0
- package/shared/src/protocol/operatorQuestions.ts +13 -0
- package/shared/src/protocol/serverMessages.ts +12 -2
- package/shared/src/protocol/workflows.ts +4 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promises as fs, constants, statSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import type { CliUpdateOutcome } from '@arco/shared';
|
|
7
|
+
import { commandArgs, findWindowsCommand, npmShimTarget } from './windowsCommand.js';
|
|
8
|
+
import { resolveInstallableVersion, type ResolvedInstall } from './npmPlatformResolve.js';
|
|
9
|
+
import { compareVersions } from './updateCheck.js';
|
|
10
|
+
|
|
11
|
+
const exec = promisify(execFile);
|
|
12
|
+
const options = { timeout: 5_000, maxBuffer: 256 * 1024, killSignal: 'SIGKILL' as const };
|
|
13
|
+
|
|
14
|
+
export interface CodexInstallation {
|
|
15
|
+
kind: 'standalone' | 'npm' | 'unknown';
|
|
16
|
+
launcher?: string;
|
|
17
|
+
supportsUpdate: boolean;
|
|
18
|
+
npmRootMatches?: boolean;
|
|
19
|
+
instruction?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CliUpdateDecision {
|
|
23
|
+
kind: CodexInstallation['kind'];
|
|
24
|
+
targetVersion?: string;
|
|
25
|
+
command?: { cmd: string; args: string[] };
|
|
26
|
+
repairArgs?: string[];
|
|
27
|
+
outcome?: 'manual' | 'deferred';
|
|
28
|
+
message?: string;
|
|
29
|
+
notice?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function inside(root: string, file: string): boolean {
|
|
33
|
+
const relative = path.relative(root, file);
|
|
34
|
+
return relative !== '' && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function canonical(file: string): Promise<string | undefined> {
|
|
38
|
+
try { return await fs.realpath(file); } catch { return undefined; }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function launcherOnPath(): Promise<string | undefined> {
|
|
42
|
+
if (process.platform === 'win32') {
|
|
43
|
+
return findWindowsCommand('codex', process.env, (file) => {
|
|
44
|
+
try { return requireFile(file); } catch { return false; }
|
|
45
|
+
}) ?? undefined;
|
|
46
|
+
}
|
|
47
|
+
for (const dir of (process.env.PATH ?? '').split(path.delimiter).filter(Boolean)) {
|
|
48
|
+
const file = path.resolve(dir, 'codex');
|
|
49
|
+
try { await fs.access(file, constants.X_OK); if ((await fs.stat(file)).isFile()) return file; } catch { /* try the next PATH entry */ }
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Windows command lookup is synchronous so it can use the same PATH/PATHEXT
|
|
55
|
+
// selection as the provider launcher, including npm's .cmd wrapper.
|
|
56
|
+
function requireFile(file: string): boolean { return statSync(file).isFile(); }
|
|
57
|
+
|
|
58
|
+
export async function inspectCodexInstallation(): Promise<CodexInstallation> {
|
|
59
|
+
const launcher = await launcherOnPath();
|
|
60
|
+
if (!launcher) return { kind: 'unknown', supportsUpdate: false };
|
|
61
|
+
let entry = launcher;
|
|
62
|
+
if (process.platform === 'win32' && /\.(?:cmd|bat)$/i.test(launcher)) {
|
|
63
|
+
try { entry = npmShimTarget(launcher, await fs.readFile(launcher, 'utf8')) ?? launcher; } catch { /* leave an unreadable wrapper unknown */ }
|
|
64
|
+
}
|
|
65
|
+
const real = await canonical(entry);
|
|
66
|
+
if (!real) return { kind: 'unknown', launcher, supportsUpdate: false };
|
|
67
|
+
let supportsUpdate = false;
|
|
68
|
+
try {
|
|
69
|
+
const { stdout } = await exec(...commandArgs(launcher, ['--help']), options);
|
|
70
|
+
supportsUpdate = /^\s+update\s+/m.test(stdout);
|
|
71
|
+
} catch { /* an older or broken CLI can still have a proven npm repair path */ }
|
|
72
|
+
|
|
73
|
+
if (path.basename(real) === 'codex.js') {
|
|
74
|
+
const packageRoot = path.dirname(path.dirname(real));
|
|
75
|
+
try {
|
|
76
|
+
const manifest = JSON.parse(await fs.readFile(path.join(packageRoot, 'package.json'), 'utf8'));
|
|
77
|
+
if (manifest.name === '@openai/codex') {
|
|
78
|
+
const { stdout } = await exec(...commandArgs('npm', ['root', '-g']), options);
|
|
79
|
+
const target = await canonical(path.join(stdout.trim(), '@openai', 'codex'));
|
|
80
|
+
return { kind: 'npm', launcher, supportsUpdate, npmRootMatches: !!target && path.relative(target, packageRoot) === '' };
|
|
81
|
+
}
|
|
82
|
+
} catch { /* ownership could not be proved; never guess a global npm target */ }
|
|
83
|
+
return { kind: 'unknown', launcher, supportsUpdate, instruction: 'Arco could not confirm the npm update target. No update was run. Use the package manager that installed this Codex.' };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const home = process.env.CODEX_HOME || path.join(homedir(), '.codex');
|
|
87
|
+
const releases = await canonical(path.join(home, 'packages', 'standalone', 'releases'));
|
|
88
|
+
if (releases && inside(releases, real)) {
|
|
89
|
+
const defaultBin = process.platform === 'win32'
|
|
90
|
+
? process.env.LOCALAPPDATA && path.join(process.env.LOCALAPPDATA, 'Programs', 'OpenAI', 'Codex', 'bin')
|
|
91
|
+
: path.join(homedir(), '.local', 'bin');
|
|
92
|
+
const installBin = process.env.CODEX_INSTALL_DIR || defaultBin;
|
|
93
|
+
// The updater reruns the installer. Its destination must still be the
|
|
94
|
+
// active command directory, including a retained custom install directory.
|
|
95
|
+
if (!installBin || path.relative(path.resolve(path.dirname(launcher)), path.resolve(installBin)) !== '') {
|
|
96
|
+
return { kind: 'unknown', launcher, supportsUpdate, instruction: 'This Codex was not installed through npm. No update was run because its installer destination could not be confirmed. Open codex in a terminal and use its update prompt with the original install directory.' };
|
|
97
|
+
}
|
|
98
|
+
return { kind: 'standalone', launcher, supportsUpdate };
|
|
99
|
+
}
|
|
100
|
+
return { kind: 'unknown', launcher, supportsUpdate };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function decideCodexUpdate(installation: CodexInstallation, published?: string, resolved?: ResolvedInstall | null): CliUpdateDecision {
|
|
104
|
+
const base = { kind: installation.kind };
|
|
105
|
+
if (installation.kind === 'unknown' || !installation.launcher) {
|
|
106
|
+
return { ...base, outcome: 'manual', message: installation.instruction ?? 'Arco could not identify how this Codex was installed. No update was run. Open codex in a terminal and use its update prompt or the package manager that installed it.' };
|
|
107
|
+
}
|
|
108
|
+
if (installation.kind === 'standalone') {
|
|
109
|
+
return installation.supportsUpdate
|
|
110
|
+
? { ...base, targetVersion: published, command: { cmd: installation.launcher, args: ['update'] } }
|
|
111
|
+
: { ...base, targetVersion: published, outcome: 'manual', message: 'This Codex was not installed through npm and does not support codex update. No update was run. Open codex in a terminal and use its update prompt.' };
|
|
112
|
+
}
|
|
113
|
+
if (!installation.npmRootMatches) {
|
|
114
|
+
return { ...base, outcome: 'manual', message: 'The npm update would target a different Codex installation. No update was run. Use the package manager that installed this Codex.' };
|
|
115
|
+
}
|
|
116
|
+
if (!resolved) {
|
|
117
|
+
return { ...base, outcome: 'deferred', message: 'Arco could not confirm an installable Codex npm build. The current installation was not changed.' };
|
|
118
|
+
}
|
|
119
|
+
if (resolved.blocked || (installation.supportsUpdate && resolved.degraded)) {
|
|
120
|
+
return { ...base, outcome: 'deferred', message: `Codex v${resolved.latest} has no ${process.platform}-${process.arch} build available yet. The current installation was not changed.` };
|
|
121
|
+
}
|
|
122
|
+
const args = ['install', '-g', `@openai/codex@${resolved.version}`];
|
|
123
|
+
return {
|
|
124
|
+
...base, targetVersion: resolved.version,
|
|
125
|
+
command: installation.supportsUpdate ? { cmd: installation.launcher, args: ['update'] } : { cmd: 'npm', args },
|
|
126
|
+
repairArgs: args,
|
|
127
|
+
...(resolved.degraded ? { notice: `Codex v${resolved.latest} has no ${process.platform}-${process.arch} build available yet. The newest installable npm version is v${resolved.version}.` } : {}),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function probeCodexUpdate(published?: string): Promise<CliUpdateDecision> {
|
|
132
|
+
const installation = await inspectCodexInstallation();
|
|
133
|
+
const resolved = installation.kind === 'npm' && installation.npmRootMatches
|
|
134
|
+
? await resolveInstallableVersion('@openai/codex') : undefined;
|
|
135
|
+
return decideCodexUpdate(installation, published, resolved);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface UpdateCommandResult { output: string; exitCode: number; }
|
|
139
|
+
|
|
140
|
+
export function describeCliUpdate(provider: string, previous: string, current: string, target: string | undefined, command: UpdateCommandResult, notice?: string): { outcome: CliUpdateOutcome; message: string; updated: boolean; error?: string } {
|
|
141
|
+
const name = provider === 'codex' ? 'Codex' : 'Claude CLI';
|
|
142
|
+
if (command.exitCode !== 0) {
|
|
143
|
+
const error = `${name} update failed: ${command.output.trim().slice(0, 2000) || `exit code ${command.exitCode}`}`;
|
|
144
|
+
return { outcome: 'failed', message: error, updated: false, error };
|
|
145
|
+
}
|
|
146
|
+
if (current === 'unknown' || current === 'broken') {
|
|
147
|
+
const error = `${name} did not run after the update.`;
|
|
148
|
+
return { outcome: 'failed', message: error, updated: false, error };
|
|
149
|
+
}
|
|
150
|
+
if (previous !== current && (compareVersions(current, previous) ?? 1) > 0) {
|
|
151
|
+
return { outcome: 'updated', message: `Updated ${name} from v${previous} to v${current}.${notice ? ` ${notice}` : ''}`, updated: true };
|
|
152
|
+
}
|
|
153
|
+
if (notice) return { outcome: 'deferred', message: notice, updated: false };
|
|
154
|
+
const comparison = target ? compareVersions(current, target) : null;
|
|
155
|
+
if (comparison !== null && comparison >= 0) return { outcome: 'current', message: `${name} v${current} is up to date for this installation.`, updated: false };
|
|
156
|
+
return { outcome: 'unchanged', updated: false, message: comparison !== null
|
|
157
|
+
? `${name} did not change; v${target} is still available.`
|
|
158
|
+
: `The ${name} version did not change. Arco could not check whether it is up to date.` };
|
|
159
|
+
}
|
|
@@ -14,6 +14,7 @@ export function buildClusterDirectorDoctrine(role: string | undefined): string |
|
|
|
14
14
|
'You are the operator-assigned Director of THIS Arco cluster: you coordinate, read the diff, and land. Peers implement, build, and test.',
|
|
15
15
|
'At the start of each turn, inspect pending peer mail. If the injected shared plan is marked OUTLINE, call cluster_plan_read before deciding what to do.',
|
|
16
16
|
'Reconcile relevant tasks, new peer evidence, repository state and applicable project instructions before reporting status. Read the broader plan or history when relevant or stale. Check an operator problem against the affected priorities and open items before asking them anything.',
|
|
17
|
+
'When this cluster has an Advisor, consult it before a design decision or when the evidence is thin; the decision remains yours.',
|
|
17
18
|
'Delegate implementation, builds, and test runs only through peer_send and track them on the board. Do not write or edit product code or tests yourself.',
|
|
18
19
|
'Stay available to the operator. Hand long-running work to peers: the project\'s checks to the tester (or a builder when there is no tester), CI watching to the change\'s author. Use their reports of what was done, run and not covered; do not run builds, test suites or CI waits yourself.',
|
|
19
20
|
'Never wait inside a turn: no sleep or polling longer than 60 seconds at a time. When the next step depends on a peer or on CI, say what is pending and end the turn; reports arrive as mail.',
|
|
@@ -44,7 +44,7 @@ import * as clusterPlanStore from './clusterPlanStore.js';
|
|
|
44
44
|
import * as clusterPlanBridge from './clusterPlanBridge.js';
|
|
45
45
|
import * as taskLedger from './project/taskLedger.js';
|
|
46
46
|
import { appendLedgerComment, persistLedgerKernelMutation, persistLedgerMutation } from './ws/taskLedgerHandlers.js';
|
|
47
|
-
import { isClusterDirector } from '@arco/shared';
|
|
47
|
+
import { isClusterDirector, presetForText } from '@arco/shared';
|
|
48
48
|
import type { ServerMessage, MemberTier, LedgerTask, LedgerTaskStatus, TaskComment, TaskDetails, TaskLink, TaskRun, TaskSignoff, TaskSignoffState } from '@arco/shared';
|
|
49
49
|
|
|
50
50
|
// peer_send dedupe — guards against the orphan-tool-use retry pattern:
|
|
@@ -210,7 +210,7 @@ export async function peerSend(
|
|
|
210
210
|
if (rolePrefix.length === 1) {
|
|
211
211
|
resolved = rolePrefix[0].wfid;
|
|
212
212
|
} else if (rolePrefix.length === 0) {
|
|
213
|
-
const roleWord = withRole.filter((r) => r.roleLc.split(/[^a-z0-9]+/).some((part) => part === ref));
|
|
213
|
+
const roleWord = withRole.filter((r) => (presetForText(r.role!)?.label.toLowerCase() ?? r.roleLc).split(/[^a-z0-9]+/).some((part) => part === ref));
|
|
214
214
|
if (roleWord.length === 1) resolved = roleWord[0].wfid;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -36,7 +36,7 @@ The operator can set a per-workflow Claude effort floor via `minClaudeWorkerEffo
|
|
|
36
36
|
|
|
37
37
|
## Artifact references
|
|
38
38
|
|
|
39
|
-
When a worker writes a report
|
|
39
|
+
When a worker writes a conversation report in the workflow artifacts directory, reference the file in chat as `[artifact:<name>]` - e.g. `[artifact:audit-spawns.md]`. Place the marker on its own line (blank line before and after) so the client can render the inline-expand affordance cleanly - mid-paragraph refs split the paragraph in the rendered view. Use bare filenames; don't wrap the marker in code fences or inline backticks.
|
|
40
40
|
|
|
41
41
|
**Open-ended asks are not opus signals.** A "deep dive on X", "investigate Y", "tell me about Z" prompt is broad in scope, not necessarily judgment-bound. Sonnet at `max` or GPT-5.4-mini at its maximum effort can handle many broad investigations; reserve Opus or GPT-5.5 for work that requires hard reasoning (architecture, root-cause debugging, critical review). Prompt breadth does not imply judgment depth.
|
|
42
42
|
|
|
@@ -70,12 +70,14 @@ export function assertSpellingSafe(target: string, pathApi = path): void {
|
|
|
70
70
|
// transcripts, settings, account homes, cluster vaults or logs browseable.
|
|
71
71
|
for (let i = 0; i < parts.length; i++) {
|
|
72
72
|
if (parts[i] !== '.arco') continue;
|
|
73
|
-
|
|
73
|
+
const runtimeUploads = isPathWithin(pathApi.join(homedir(), '.arco'), target, pathApi) || isPathWithin(runtimeHome(), target, pathApi);
|
|
74
|
+
if (!runtimePathAllowed(parts.slice(i + 1), runtimeUploads)) throw new FileAccessError();
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
function runtimePathAllowed(parts: string[]): boolean {
|
|
78
|
-
return parts[0] === '
|
|
78
|
+
function runtimePathAllowed(parts: string[], allowUploads = false): boolean {
|
|
79
|
+
return (allowUploads && parts[0] === 'uploads' && parts.length <= 2)
|
|
80
|
+
|| parts[0] === 'plans' || parts[0] === 'media-scratch'
|
|
79
81
|
|| (parts[0] === 'workflows' && /^[a-z0-9_-]+$/.test(parts[1] || '') && ['artifacts', 'handoffs'].includes(parts[2]))
|
|
80
82
|
|| (['chats', 'genesis'].includes(parts[0]) && /^[a-z0-9_-]+$/.test(parts[1] || ''));
|
|
81
83
|
}
|
|
@@ -90,7 +92,7 @@ export function assertSafePath(target: string): void {
|
|
|
90
92
|
try { runtimeRoots.push(realpathSync(runtime)); } catch { /* not created */ }
|
|
91
93
|
}
|
|
92
94
|
for (const root of runtimeRoots) {
|
|
93
|
-
if (isPathWithin(root, target) && !runtimePathAllowed(path.relative(root, target).split(path.sep).map((p) => p.toLowerCase()))) throw new FileAccessError();
|
|
95
|
+
if (isPathWithin(root, target) && !runtimePathAllowed(path.relative(root, target).split(path.sep).map((p) => p.toLowerCase()), true)) throw new FileAccessError();
|
|
94
96
|
}
|
|
95
97
|
for (const { root, temporaryRoot } of protectedRoots()) {
|
|
96
98
|
// Default AppData and LOCALAPPDATA exempt only local temporary storage.
|
|
@@ -170,7 +172,7 @@ export async function createReadAccessContext(): Promise<ReadAccessContext> {
|
|
|
170
172
|
const assert = (target: string) => {
|
|
171
173
|
assertSpellingSafe(target);
|
|
172
174
|
for (const root of runtimeRoots) {
|
|
173
|
-
if (isPathWithin(root, target) && !runtimePathAllowed(path.relative(root, target).split(path.sep).map(p => p.toLowerCase()))) throw new FileAccessError();
|
|
175
|
+
if (isPathWithin(root, target) && !runtimePathAllowed(path.relative(root, target).split(path.sep).map(p => p.toLowerCase()), true)) throw new FileAccessError();
|
|
174
176
|
}
|
|
175
177
|
protectedPaths.forEach(({ root, temporaryRoot }, index) => {
|
|
176
178
|
if (isProtectedRoot(root, target, temporaryRoot)) throw new FileAccessError();
|
|
@@ -529,7 +529,7 @@ export async function tryHandleWorkflowDataRoutes(
|
|
|
529
529
|
return true;
|
|
530
530
|
}
|
|
531
531
|
|
|
532
|
-
// Per-workflow artifact reader. Workers write
|
|
532
|
+
// Per-workflow artifact reader. Workers write conversation reports into
|
|
533
533
|
// `<cwd>/.arco/workflows/<wfid>/artifacts/`; the client fetches them on
|
|
534
534
|
// demand when chat contains `[artifact:<name>]`. Name is strictly sanitized.
|
|
535
535
|
if (req.url?.startsWith('/api/workflows/artifact') && req.method === 'GET') {
|
package/server/src/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { setDeepSeekActivityCheck } from './providers/deepseekProfiles.js';
|
|
|
19
19
|
import { setStrataSwitchActivityCheck } from './providers/strataProfiles.js';
|
|
20
20
|
import { setOperatorQuestionPublisher } from './providers/codex-appserver/operatorQuestions.js';
|
|
21
21
|
import { resolveVoiceTool, setVoiceToolPublisher } from './voice/operatorTools.js';
|
|
22
|
-
import { handleOperatorQuestionReply } from './ws/operatorQuestionHandlers.js';
|
|
22
|
+
import { handleOperatorQuestionReply, handleOperatorQuestionDismiss } from './ws/operatorQuestionHandlers.js';
|
|
23
23
|
// Side-effect import, kept FIRST: forces this process onto IPv4 before any
|
|
24
24
|
// module can open a socket. See server/src/net/forceIpv4.ts.
|
|
25
25
|
import { loadWorkspace, onWorkspaceChange, syncWorkspace } from './workspace.js';
|
|
@@ -975,6 +975,10 @@ wss.on('connection', (ws: WebSocket) => {
|
|
|
975
975
|
if (wf && wf.observers.has(ws)) resolveVoiceTool(msg);
|
|
976
976
|
break;
|
|
977
977
|
}
|
|
978
|
+
case 'operator_question_dismiss': {
|
|
979
|
+
handleOperatorQuestionDismiss(ws, session, msg);
|
|
980
|
+
break;
|
|
981
|
+
}
|
|
978
982
|
case 'operator_question_reply': {
|
|
979
983
|
void handleOperatorQuestionReply(ws, session, msg).catch(() => {
|
|
980
984
|
if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ type: 'operator_question_reply_result', workflowId: msg.workflowId, requestId: msg.requestId, ok: false, error: 'The answer could not be delivered.' }));
|
|
@@ -224,6 +224,7 @@ export function runPrimaryTurn(
|
|
|
224
224
|
// tool-result append and the next API round-trip. Other providers
|
|
225
225
|
// ignore it; the post-turn drain still picks up anything not consumed.
|
|
226
226
|
drainSteer?: () => SteerItem[];
|
|
227
|
+
peekSteer?: () => readonly SteerItem[];
|
|
227
228
|
// Phase 6b — paired with drainSteer for the Codex app-server worker.
|
|
228
229
|
// Symmetrical contract — same scoping (primary-turn only), same
|
|
229
230
|
// in-process callback shape. Called when a `turn/steer` round-trip
|
|
@@ -358,7 +359,7 @@ export function runPrimaryTurn(
|
|
|
358
359
|
webSearchMaxUses?: number;
|
|
359
360
|
},
|
|
360
361
|
): TurnHandle {
|
|
361
|
-
const { primary, prompt, resumeSessionId, attachments, disableRssGuard, appendSystemPrompt, systemPrompt, interactionMode, disableProviderHooks, chatWebAccess, voiceOperator, incognito, drainSteer, requeueSteer, onSteerDelivered, codexTransport, codexContextPolicy, providerAccountRef, codexHome, claudeTransport, ultracode, claudeNativeTaskDisabled, claudeNativeSubagent, claudeNativeCompact, claudeNativeInTurnCompactPercent, claudeNativeForceInterleavedThinkingBeta, claudeNativeThinkingDisplay, nativeSubagents, claudeNativePlanModeArmed, turnNotice, efficiencyToolFilter, efficiencyFactForce, efficiencyConfigProtection, efficiencySandbox, reviewSafeMode, outputStyle, goal, toolPosture, clusterId, clusterAccessMode, executionCwd, persistenceCwd, clusterTaskBoardAttached, clusterPlan, clusterRole, clusterEfficiencyDoctrine, clusterProgressDoctrine, clusterMcpConfigPath, codebaseMemoryAttached, codebaseMemoryIndexPath, mcpRegistryServers, mcpDisallowedTools, ollamaParams, webSearchMaxUses } = args;
|
|
362
|
+
const { primary, prompt, resumeSessionId, attachments, disableRssGuard, appendSystemPrompt, systemPrompt, interactionMode, disableProviderHooks, chatWebAccess, voiceOperator, incognito, drainSteer, peekSteer, requeueSteer, onSteerDelivered, codexTransport, codexContextPolicy, providerAccountRef, codexHome, claudeTransport, ultracode, claudeNativeTaskDisabled, claudeNativeSubagent, claudeNativeCompact, claudeNativeInTurnCompactPercent, claudeNativeForceInterleavedThinkingBeta, claudeNativeThinkingDisplay, nativeSubagents, claudeNativePlanModeArmed, turnNotice, efficiencyToolFilter, efficiencyFactForce, efficiencyConfigProtection, efficiencySandbox, reviewSafeMode, outputStyle, goal, toolPosture, clusterId, clusterAccessMode, executionCwd, persistenceCwd, clusterTaskBoardAttached, clusterPlan, clusterRole, clusterEfficiencyDoctrine, clusterProgressDoctrine, clusterMcpConfigPath, codebaseMemoryAttached, codebaseMemoryIndexPath, mcpRegistryServers, mcpDisallowedTools, ollamaParams, webSearchMaxUses } = args;
|
|
362
363
|
|
|
363
364
|
const workerId = `primary-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
|
|
364
365
|
|
|
@@ -401,6 +402,7 @@ export function runPrimaryTurn(
|
|
|
401
402
|
...(interactionMode === 'chat' ? { sandbox: 'read-only' as const } : {}),
|
|
402
403
|
disableRssGuard,
|
|
403
404
|
drainSteer,
|
|
405
|
+
peekSteer,
|
|
404
406
|
requeueSteer,
|
|
405
407
|
onSteerDelivered,
|
|
406
408
|
codexTransport,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ProviderName } from '@arco/shared';
|
|
2
|
+
import type { WorkflowState } from './workflows/types.js';
|
|
3
|
+
import { resolveClaudeTransport } from './claudeTransport.js';
|
|
4
|
+
import { readMeta, persistInitialMeta, reconcileLatestCliSession, workflowMetaSeed, updateMeta } from './workflowMeta.js';
|
|
5
|
+
import { scanEventsOfTypes } from './workflowStore.js';
|
|
6
|
+
import { broadcastWorkflow, broadcastTransient } from './server/broadcast.js';
|
|
7
|
+
|
|
8
|
+
export async function hasConversationHistory(cwd: string, workflowId: string, afterSeq = 0): Promise<boolean> {
|
|
9
|
+
let found = false;
|
|
10
|
+
await scanEventsOfTypes(cwd, workflowId, ['primary_complete', 'primary_text'], event => { if ((('seq' in event && typeof event.seq === 'number') ? event.seq : 0) > afterSeq) found = true; });
|
|
11
|
+
return found;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function reportConversationSaveFailure(workflowId: string, err: unknown): void {
|
|
15
|
+
console.error(`[arco] [${workflowId.slice(0, 8)}] conversation metadata save failed:`, err);
|
|
16
|
+
broadcastWorkflow(workflowId, { type: 'system_notice', workflowId,
|
|
17
|
+
content: 'Could not save the provider conversation metadata. A restart may lose its resume id. Check that the project folder is writable.' });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function ensureWorkflowMetadata(cwd: string, workflowId: string, wf: WorkflowState): Promise<void> {
|
|
21
|
+
if (wf.config.incognito) return;
|
|
22
|
+
try {
|
|
23
|
+
await persistInitialMeta(cwd, workflowId, wf.config, wf.primary, { sessionId: wf.primarySessionId, pendingReading: wf.providerConversation === 'awaiting-reading' });
|
|
24
|
+
const meta = await readMeta(cwd, workflowId);
|
|
25
|
+
if (meta?.providerConversationPendingReading) wf.providerConversation = 'awaiting-reading';
|
|
26
|
+
} catch (err) { reportConversationSaveFailure(workflowId, err); }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function providerConversationState(cwd: string, workflowId: string, wf: WorkflowState): Promise<WorkflowState['providerConversation']> {
|
|
30
|
+
if (wf.config.incognito) return undefined;
|
|
31
|
+
const provider = wf.primary.provider;
|
|
32
|
+
const external = provider === 'codex' || provider === 'cursor'
|
|
33
|
+
|| (provider === 'claude' && await resolveClaudeTransport(wf, cwd) === 'cli');
|
|
34
|
+
if (!external) return undefined;
|
|
35
|
+
if (!wf.primarySessionId) {
|
|
36
|
+
const boundary = wf.config.voiceOperator ? wf.config.computerContext?.lastResetSeq ?? 0 : 0;
|
|
37
|
+
return await hasConversationHistory(cwd, workflowId, boundary) ? 'unavailable' : undefined;
|
|
38
|
+
}
|
|
39
|
+
return wf.providerConversation === 'awaiting-reading' ? wf.providerConversation : undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function saveProviderSession(cwd: string, workflowId: string, wf: WorkflowState, provider: ProviderName, sessionId: string, providerAccountRef?: string): Promise<void> {
|
|
43
|
+
if (wf.config.incognito) return;
|
|
44
|
+
const seed = workflowMetaSeed(cwd, workflowId, wf.config, wf.primary);
|
|
45
|
+
seed.providerConversationPendingReading = wf.providerConversation === 'awaiting-reading';
|
|
46
|
+
try {
|
|
47
|
+
await reconcileLatestCliSession(cwd, workflowId, provider, sessionId, providerAccountRef, seed);
|
|
48
|
+
} catch (err) { reportConversationSaveFailure(workflowId, err); }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Only session discovery proves that the provider actually started the new
|
|
52
|
+
// conversation. Reconnecting or a failed pre-dispatch attempt is not a start.
|
|
53
|
+
export function announceReplacementConversation(workflowId: string, wf: WorkflowState): void {
|
|
54
|
+
if (wf.providerConversation !== 'unavailable') return;
|
|
55
|
+
const provider = wf.primary.provider === 'codex' ? 'Codex' : wf.primary.provider === 'cursor' ? 'Cursor' : 'Claude CLI';
|
|
56
|
+
wf.providerConversation = 'awaiting-reading';
|
|
57
|
+
broadcastWorkflow(workflowId, { type: 'provider_conversation_state', workflowId, state: 'awaiting-reading' });
|
|
58
|
+
broadcastWorkflow(workflowId, { type: 'system_notice', workflowId,
|
|
59
|
+
content: `A new ${provider} conversation started because no saved thread id is available. Earlier messages remain in this tab.` });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function markConversationReading(cwd: string, workflowId: string, wf: WorkflowState): Promise<void> {
|
|
63
|
+
if (wf.providerConversation !== 'awaiting-reading') return;
|
|
64
|
+
wf.providerConversation = undefined;
|
|
65
|
+
broadcastTransient(workflowId, { type: 'provider_conversation_state', workflowId, state: 'ready' });
|
|
66
|
+
try {
|
|
67
|
+
const saved = await updateMeta(cwd, workflowId, meta => { delete meta.providerConversationPendingReading; });
|
|
68
|
+
if (!saved) throw new Error('Workflow metadata disappeared before the context reading was saved.');
|
|
69
|
+
}
|
|
70
|
+
catch (err) { reportConversationSaveFailure(workflowId, err); }
|
|
71
|
+
}
|
|
@@ -21,6 +21,28 @@ export function isServerToolResultType(type: string): type is ServerToolResultTy
|
|
|
21
21
|
return SERVER_TOOL_RESULT_TYPES.has(type);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// A mixed client/server response can defer its server results to a later
|
|
25
|
+
// assistant message. Until those IDs are answered, the continuation must
|
|
26
|
+
// contain only client tool_result blocks, without a steer or history splice.
|
|
27
|
+
export function pendingServerTools(
|
|
28
|
+
messages: readonly { role?: string; content?: unknown }[],
|
|
29
|
+
startMessageIndex: number,
|
|
30
|
+
): string[] {
|
|
31
|
+
const pending = new Map<string, string>();
|
|
32
|
+
for (let i = Math.max(0, startMessageIndex); i < messages.length; i++) {
|
|
33
|
+
const message = messages[i];
|
|
34
|
+
if (message.role !== 'assistant' || !Array.isArray(message.content)) continue;
|
|
35
|
+
for (const block of message.content as Array<Record<string, unknown>>) {
|
|
36
|
+
if (block.type === 'server_tool_use' && typeof block.id === 'string') {
|
|
37
|
+
pending.set(block.id, typeof block.name === 'string' ? block.name : 'server tool');
|
|
38
|
+
} else if (typeof block.type === 'string' && isServerToolResultType(block.type) && typeof block.tool_use_id === 'string') {
|
|
39
|
+
pending.delete(block.tool_use_id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return [...new Set(pending.values())];
|
|
44
|
+
}
|
|
45
|
+
|
|
24
46
|
export function isClaudeServerToolDef(tool: unknown): boolean {
|
|
25
47
|
const type = (tool as { type?: unknown }).type;
|
|
26
48
|
return typeof type === 'string' && (
|
|
@@ -61,7 +61,7 @@ import { getSandboxToolDefinitions, isSandboxTool, executeSandboxTool } from './
|
|
|
61
61
|
import { buildMessagesFromReplayEvents, replayMessagesWithResumePolicy, compactSummarySeed, type ClaudeResumeMessage } from './resumeSummary.js';
|
|
62
62
|
import { readMeta, setResolvedModelId } from '../../workflowMeta.js';
|
|
63
63
|
import { lspManager } from '../../lsp/client.js';
|
|
64
|
-
import { isClaudeServerToolDef, isServerToolResultType, pruneServerToolEvidenceAfterTurn, stripDanglingServerToolResults } from './retainedContext.js';
|
|
64
|
+
import { isClaudeServerToolDef, isServerToolResultType, pendingServerTools, pruneServerToolEvidenceAfterTurn, stripDanglingServerToolResults } from './retainedContext.js';
|
|
65
65
|
import { gzipSync } from 'node:zlib';
|
|
66
66
|
import {
|
|
67
67
|
executeNativeToolResult,
|
|
@@ -378,6 +378,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
378
378
|
private authRecovery: AuthRecoveryContext = { transport: 'native', binding: nativeCredentialBinding() };
|
|
379
379
|
private clientTokenObtainedAt: number | null = null;
|
|
380
380
|
private messages: MessageParam[] = [];
|
|
381
|
+
private heldSteerNotices = new WeakSet<object>();
|
|
381
382
|
private hooks: HookConfig = { byEvent: {} };
|
|
382
383
|
// Set once discoverTrustedHooks has run (ensureStarted, or a FOLD before any turn).
|
|
383
384
|
private hooksLoaded = false;
|
|
@@ -3005,6 +3006,21 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
3005
3006
|
return;
|
|
3006
3007
|
}
|
|
3007
3008
|
|
|
3009
|
+
// Client results alone do not close a mixed server/client turn. Match
|
|
3010
|
+
// server results across assistant messages before adding ordinary user
|
|
3011
|
+
// input or replacing history; either would end an unresolved turn.
|
|
3012
|
+
const pendingServer = pendingServerTools(this.messages, turnMessageStart);
|
|
3013
|
+
if (pendingServer.length > 0) {
|
|
3014
|
+
const work = pendingServer.every((name) => name === 'web_search') ? 'web search finishes'
|
|
3015
|
+
: pendingServer.every((name) => name === 'web_fetch') ? 'web fetch finishes' : 'server tools finish';
|
|
3016
|
+
for (const item of this.config.peekSteer?.() ?? []) {
|
|
3017
|
+
if (this.heldSteerNotices.has(item)) continue;
|
|
3018
|
+
this.heldSteerNotices.add(item);
|
|
3019
|
+
this.emit('system_notice', `Message held until ${work}.`);
|
|
3020
|
+
}
|
|
3021
|
+
continue;
|
|
3022
|
+
}
|
|
3023
|
+
|
|
3008
3024
|
// In-turn auto-compaction at a clean boundary: every tool_use of this
|
|
3009
3025
|
// round has its result and the next request has not been sent. Runs
|
|
3010
3026
|
// before the steer drain so a steer lands after the compacted history.
|
|
@@ -4263,7 +4279,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
4263
4279
|
// SDK's own `.type` property), NOT on `e.error.type` (which is the outer
|
|
4264
4280
|
// body wrapper field "error"). Read `e.type` first so overloaded/rate-limit
|
|
4265
4281
|
// mid-stream errors are correctly classified for retry.
|
|
4266
|
-
const e = err as { status?: number; message?: string; error?: { type?: string; message?: string; error?: { type?: string; message?: string } }; type?: string; name?: string };
|
|
4282
|
+
const e = err as { status?: number; message?: string; error?: { type?: string; message?: string; error?: { type?: string; message?: string } }; type?: string; name?: string; code?: string; cause?: { code?: string } };
|
|
4267
4283
|
const name = e.name ?? '';
|
|
4268
4284
|
// Inner message is at e.error.error.message (full body → error → message)
|
|
4269
4285
|
// for streaming errors; fall back through outer body message and SDK message.
|
|
@@ -4317,7 +4333,15 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
4317
4333
|
this.emit('error', 'request_too_large');
|
|
4318
4334
|
return 'fatal';
|
|
4319
4335
|
}
|
|
4320
|
-
|
|
4336
|
+
const gatewayError = status === 502 || status === 503 || status === 504 || (status >= 520 && status <= 524);
|
|
4337
|
+
// The SDK wraps failures before headers in APIConnectionError (including
|
|
4338
|
+
// APIConnectionTimeoutError). A dropped response body can instead expose
|
|
4339
|
+
// the fetch socket error directly; do not retry arbitrary statusless errors.
|
|
4340
|
+
const connectionCode = e.cause?.code ?? e.code ?? '';
|
|
4341
|
+
const connectionError = status === 0 && (err instanceof Anthropic.APIConnectionError
|
|
4342
|
+
|| /^(?:ECONNRESET|ECONNREFUSED|ETIMEDOUT|EPIPE|UND_ERR_(?:SOCKET|CONNECT_TIMEOUT|HEADERS_TIMEOUT|BODY_TIMEOUT))$/.test(connectionCode));
|
|
4343
|
+
const transportError = gatewayError || connectionError;
|
|
4344
|
+
if (transportError || status === 429 || status === 529 || errType === 'rate_limit_error' || errType === 'overloaded_error' || status === 500 || errType === 'api_error') {
|
|
4321
4345
|
// H10 — honor Anthropic's own retry timing when it sends one. `retry-after`
|
|
4322
4346
|
// (seconds or HTTP-date) wins; else the soonest `anthropic-ratelimit-*-reset`.
|
|
4323
4347
|
// Falls back to the fixed 15/30/60s ladder when no usable header is present
|
|
@@ -4330,7 +4354,9 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
4330
4354
|
const via = timing.source
|
|
4331
4355
|
? ` (per ${timing.source}${timing.capped ? ', capped' : ''})`
|
|
4332
4356
|
: '';
|
|
4333
|
-
const label =
|
|
4357
|
+
const label = gatewayError ? `gateway error (HTTP ${status})`
|
|
4358
|
+
: connectionError ? (err instanceof Anthropic.APIConnectionTimeoutError ? 'connection timeout' : 'connection error')
|
|
4359
|
+
: kind === 'genuine'
|
|
4334
4360
|
? `rate limit (${errType || `HTTP ${status}`})`
|
|
4335
4361
|
: `overload (${errType || `HTTP ${status}`})`;
|
|
4336
4362
|
// Same attempt-budget guard as the auth / thinking branches: a 'retry'
|
|
@@ -4338,7 +4364,9 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
4338
4364
|
// WITHOUT emitting — runTurn reads null as "error already emitted", so a
|
|
4339
4365
|
// third consecutive 429/529/500 left the tab busy forever.
|
|
4340
4366
|
if (attempt >= MAX_RETRY_ATTEMPTS - 1) {
|
|
4341
|
-
this.emit('system_notice',
|
|
4367
|
+
this.emit('system_notice', transportError
|
|
4368
|
+
? `Anthropic could not be reached${gatewayError ? ` (HTTP ${status})` : ` (${label})`} after ${MAX_RETRY_ATTEMPTS} attempts. The conversation is intact; send a message to continue.`
|
|
4369
|
+
: `Anthropic ${label}: still failing after ${MAX_RETRY_ATTEMPTS} attempts — giving up on this turn. ${msg.slice(0, 300)}`);
|
|
4342
4370
|
this.emit('error', `claude-native: ${label} after ${MAX_RETRY_ATTEMPTS} attempts`);
|
|
4343
4371
|
return 'fatal';
|
|
4344
4372
|
}
|
|
@@ -72,6 +72,21 @@ export async function replyToOperatorQuestion(workflowId: string, requestId: str
|
|
|
72
72
|
} finally { entry.sending = false; }
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
export function dismissOperatorQuestion(workflowId: string, requestId: string): { ok: boolean; error?: string } {
|
|
76
|
+
const entry = pending.get(requestId);
|
|
77
|
+
if (!entry || entry.workflowId !== workflowId) return { ok: false, error: 'This question is no longer pending.' };
|
|
78
|
+
if (entry.sending) return { ok: false, error: 'An answer is already being delivered.' };
|
|
79
|
+
entry.sending = true;
|
|
80
|
+
try {
|
|
81
|
+
if (entry.respond && entry.respond({ answers: {} }) === false) throw new Error('Codex connection closed.');
|
|
82
|
+
if (pending.get(requestId) !== entry) return { ok: false, error: 'This question is no longer pending.' };
|
|
83
|
+
entry.owner.finish(entry, { ...entry.state, status: 'cancelled', reason: 'Dismissed by the operator.' });
|
|
84
|
+
return { ok: true };
|
|
85
|
+
} catch {
|
|
86
|
+
return { ok: false, error: 'The dismissal could not be delivered. The question is still pending.' };
|
|
87
|
+
} finally { entry.sending = false; }
|
|
88
|
+
}
|
|
89
|
+
|
|
75
90
|
export class CodexOperatorQuestions {
|
|
76
91
|
private ids = new Set<string>();
|
|
77
92
|
private asyncItems = new Set<string>();
|
|
@@ -112,6 +127,15 @@ export class CodexOperatorQuestions {
|
|
|
112
127
|
pending.delete(entry.state.requestId); this.ids.delete(entry.state.requestId); entry.publish(state);
|
|
113
128
|
}
|
|
114
129
|
|
|
130
|
+
settleTurn(threadId: string, turnId: string): void {
|
|
131
|
+
for (const id of [...this.ids]) {
|
|
132
|
+
const p = pending.get(id);
|
|
133
|
+
if (p && p.rpcId === undefined && p.state.threadId === threadId && p.state.turnId === turnId) {
|
|
134
|
+
this.finish(p, { ...p.state, status: 'cancelled', reason: "The agent's turn ended before an answer was received." });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
115
139
|
resolvedRpc(rpcId: JsonRpcId): void {
|
|
116
140
|
for (const id of [...this.ids]) {
|
|
117
141
|
const p = pending.get(id);
|
|
@@ -917,15 +917,17 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
917
917
|
//
|
|
918
918
|
// Re-queue semantics on errors mirror the §9 mapping:
|
|
919
919
|
// - activeTurnNotSteerable {turnKind: review|compact} → re-enqueue to
|
|
920
|
-
// the steer bucket; the
|
|
920
|
+
// the steer bucket; the queue engine delivers it at the next safe
|
|
921
|
+
// turn boundary, or starts a queued turn if the tab is already idle
|
|
921
922
|
// - mismatched turnId / turn already ended → re-enqueue as follow-up
|
|
922
923
|
// - any other transport error → re-enqueue to follow-up + system_notice
|
|
923
924
|
private async dispatchSteer(items: SteerItem[]): Promise<void> {
|
|
924
925
|
const config = this.config;
|
|
925
926
|
const turn = this.current;
|
|
926
927
|
if (!this.rpc || !this.threadId || !this.current.turnId) {
|
|
927
|
-
// No live turn — push everything back into follow-up so the
|
|
928
|
-
//
|
|
928
|
+
// No live turn — push everything back into follow-up so the queue
|
|
929
|
+
// engine starts it when idle, with the normal delivery receipt. A
|
|
930
|
+
// later operator message must not be needed to unpark this batch.
|
|
929
931
|
this.requeueSteer(items, 'follow-up', 'turn ended before steer dispatched', config);
|
|
930
932
|
return;
|
|
931
933
|
}
|
|
@@ -960,7 +962,8 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
960
962
|
this.requeueSteer(items, 'steer', `turn not steerable (kind=${kind})`, config);
|
|
961
963
|
} else {
|
|
962
964
|
// Anything else — mismatched expectedTurnId, transport blip, etc.
|
|
963
|
-
// Treat as follow-up; the
|
|
965
|
+
// Treat as follow-up; the queue engine delivers it after the active
|
|
966
|
+
// turn, or starts the returned batch itself when already idle.
|
|
964
967
|
const reason = err instanceof Error ? err.message : String(err);
|
|
965
968
|
this.requeueSteer(items, 'follow-up', `steer rpc failed: ${reason}`, config);
|
|
966
969
|
// Surface non-`activeTurnNotSteerable` failures so the operator sees
|
|
@@ -1628,6 +1631,7 @@ export class CodexAppServerWorker extends EventEmitter {
|
|
|
1628
1631
|
// (subsequent calls during the same turn are no-ops; the turn id is the
|
|
1629
1632
|
// gate).
|
|
1630
1633
|
private settleTurn(data: { error?: string; result?: TurnSettleData }): void {
|
|
1634
|
+
if (this.threadId && this.current.turnId) this.operatorQuestions.settleTurn(this.threadId, this.current.turnId);
|
|
1631
1635
|
this.operatorQuestions.cancel('The turn ended before an answer was received.', true);
|
|
1632
1636
|
if (!this.current.turnId && !this.current.startedAt) {
|
|
1633
1637
|
// No turn was actually in flight (e.g., kill() before turn/start).
|
|
@@ -56,7 +56,7 @@ import type {
|
|
|
56
56
|
OllamaPsModel,
|
|
57
57
|
OllamaThinkingInfo,
|
|
58
58
|
} from '@arco/shared';
|
|
59
|
-
import { ollamaThinkParam, parseOllamaThinking } from '@arco/shared';
|
|
59
|
+
import { isClusterDirector, ollamaThinkParam, parseOllamaThinking } from '@arco/shared';
|
|
60
60
|
import { readSettings } from '../settings.js';
|
|
61
61
|
import { resolveConfigValue } from '../configValue.js';
|
|
62
62
|
import type { Provider, ProviderProcess } from './types.js';
|
|
@@ -357,8 +357,7 @@ function shouldRequireClusterPeerReport(
|
|
|
357
357
|
if (!config.clusterId || !config.workflowId) return false;
|
|
358
358
|
if (observedToolNames.has('peer_send')) return false;
|
|
359
359
|
|
|
360
|
-
|
|
361
|
-
if (/\b(coordinator|director)\b/.test(role)) return false;
|
|
360
|
+
if (isClusterDirector(config.clusterRole)) return false;
|
|
362
361
|
|
|
363
362
|
return true;
|
|
364
363
|
}
|