@commonlyai/cli 0.1.277 → 0.1.279
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/package.json
CHANGED
|
@@ -788,28 +788,28 @@ const parseEvent = (line) => {
|
|
|
788
788
|
}
|
|
789
789
|
};
|
|
790
790
|
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
//
|
|
794
|
-
//
|
|
795
|
-
//
|
|
791
|
+
const STOPPED_TURN = 'the turn stopped before it finished';
|
|
792
|
+
|
|
793
|
+
// The reply is the `result` event's text. A turn with no result event stopped
|
|
794
|
+
// before it finished: SIGINT exits 0 without printing one (claude 2.1.318), with
|
|
795
|
+
// or without assistant text, and before startup it prints nothing at all. That
|
|
796
|
+
// text isn't an answer, since each assistant event may be an interim message on
|
|
797
|
+
// the way to a tool, and empty text would read as a turn with nothing to say.
|
|
798
|
+
// Other output with no JSON lines is plain text and returned as it arrived. A
|
|
799
|
+
// result flagged `is_error` is a failed turn, whatever its exit code, so it is
|
|
800
|
+
// raised here, outside the parse guard, and never returned as a reply.
|
|
796
801
|
export const claudeResultText = (stdout, { credentials = [] } = {}) => {
|
|
797
802
|
const text = String(stdout || '');
|
|
798
803
|
const events = text.split('\n').map(parseEvent);
|
|
799
|
-
if (!events.some(Boolean)) return text.trim();
|
|
804
|
+
if (text.trim() && !events.some(Boolean)) return text.trim();
|
|
800
805
|
for (let i = events.length - 1; i >= 0; i -= 1) {
|
|
801
806
|
if (events[i]?.type !== 'result') continue;
|
|
802
807
|
const reply = String(events[i].result ?? '').trim();
|
|
803
|
-
|
|
808
|
+
// An interrupted request reports error_during_execution with empty text.
|
|
809
|
+
if (events[i].is_error === true) throw adapterFailure('claude', reply || STOPPED_TURN, { credentials });
|
|
804
810
|
return reply;
|
|
805
811
|
}
|
|
806
|
-
|
|
807
|
-
.filter((event) => event?.type === 'assistant')
|
|
808
|
-
.flatMap((event) => event.message?.content || [])
|
|
809
|
-
.filter((block) => block?.type === 'text')
|
|
810
|
-
.map((block) => block.text)
|
|
811
|
-
.join('')
|
|
812
|
-
.trim();
|
|
812
|
+
throw adapterFailure('claude', STOPPED_TURN, { credentials });
|
|
813
813
|
};
|
|
814
814
|
|
|
815
815
|
// TASK-256: what a public seat's own stream says about its Commonly MCP server.
|
|
@@ -42,8 +42,7 @@ import { describeTurnReap, markTurn, turnReapEnabled } from '@commonlyai/seats/t
|
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
import { requireSeatModel, seatModelRequired } from './seat-model.js';
|
|
45
|
-
import { probeVersion } from './tested-version.js';
|
|
46
|
-
import { parseVersion } from '../mcp-server-version.js';
|
|
45
|
+
import { meetsMinimumVersion, probeVersion, publicCodexVersionError } from './tested-version.js';
|
|
47
46
|
import { spawn as childSpawn, spawnSync } from 'child_process';
|
|
48
47
|
import { createHash } from 'crypto';
|
|
49
48
|
import { accessSync, constants, existsSync, realpathSync } from 'fs';
|
|
@@ -577,7 +576,7 @@ const writePublicCodexInstructions = async (publicHome, ctx) => {
|
|
|
577
576
|
// from the `exec` tool of code-mode models.
|
|
578
577
|
// - `features.multi_agent` removes the agent tools from a model on the v1 agent
|
|
579
578
|
// tools, but a thread started without it keeps them when resumed, so
|
|
580
|
-
// `agents.max_depth=0`
|
|
579
|
+
// `agents.max_depth=0` covers that thread. A model whose catalog entry says
|
|
581
580
|
// `multi_agent_version: "v2"` keeps `collaboration.*` in its tool list whatever
|
|
582
581
|
// these say, so the v2 cap is what stops it: at 1 the root thread fills it, and
|
|
583
582
|
// spawn_agent returns "agent thread limit reached". `agents.max_threads` doesn't
|
|
@@ -586,34 +585,31 @@ const writePublicCodexInstructions = async (publicHome, ctx) => {
|
|
|
586
585
|
// - `features.goals` removes the goal tools. A goal is kept on the thread and
|
|
587
586
|
// comes back in the next turn's context.
|
|
588
587
|
//
|
|
589
|
-
// Measured
|
|
590
|
-
// gpt-5.5, gpt-5.6 and gpt-6 models
|
|
591
|
-
//
|
|
592
|
-
// know. Of these, only the `web_search` value could fail a start, as it's an
|
|
593
|
-
// enum, and "disabled" is valid on all four.
|
|
588
|
+
// Measured against the tool list sent to the model, on codex-cli 0.162.1 with
|
|
589
|
+
// gpt-5.5, gpt-5.6 and gpt-6 models and on 0.159.3 with gpt-5.5 and gpt-6 models
|
|
590
|
+
// (adapters.codex.public-tools.test.mjs).
|
|
594
591
|
const PUBLIC_BUILTIN_TOOL_FLAGS = Object.freeze([
|
|
595
592
|
'-c', 'web_search="disabled"',
|
|
596
593
|
'-c', 'features.multi_agent=false',
|
|
597
594
|
'-c', 'features.multi_agent_v2.max_concurrent_threads_per_session=1',
|
|
598
595
|
'-c', 'features.goals=false',
|
|
596
|
+
'-c', 'agents.max_depth=0',
|
|
599
597
|
]);
|
|
600
598
|
|
|
601
|
-
//
|
|
602
|
-
//
|
|
603
|
-
//
|
|
604
|
-
//
|
|
605
|
-
//
|
|
606
|
-
|
|
607
|
-
|
|
599
|
+
// A public seat needs a tested Codex version: below this one it runs no turn.
|
|
600
|
+
// Tested on macOS with the real binary, through this adapter's public flags: the
|
|
601
|
+
// permission profile (shell and view_image, read and write, network off) and the
|
|
602
|
+
// tool list, on new and resumed threads, on 0.159.3 and 0.162.1. An older version
|
|
603
|
+
// isn't tested to this bar. A later one runs as it is, so the BYO workflows'
|
|
604
|
+
// 0.164.0 is allowed, though these checks have not been run on it, nor on Linux
|
|
605
|
+
// on any version.
|
|
606
|
+
export const PUBLIC_CODEX_MIN_VERSION = '0.159.3';
|
|
608
607
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
const parseCodexVersion = (stdout) => String(stdout).match(/\d+\.\d+\.\d+/)?.[0] || null;
|
|
608
|
+
// The exact line `codex --version` printed on every version tested. Anything else
|
|
609
|
+
// counts as unread: a looser match could take a number from another line.
|
|
610
|
+
const parseCodexVersion = (stdout) => (
|
|
611
|
+
/^codex-cli (\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)\s*$/m.exec(String(stdout))?.[1] || null
|
|
612
|
+
);
|
|
617
613
|
|
|
618
614
|
const publicPermissionProfileFlags = (
|
|
619
615
|
mode,
|
|
@@ -791,7 +787,6 @@ const buildArgs = ({
|
|
|
791
787
|
modelBaseUrl = null,
|
|
792
788
|
platform = process.platform,
|
|
793
789
|
workspacePath = null,
|
|
794
|
-
zeroAgentDepth = false,
|
|
795
790
|
}) => {
|
|
796
791
|
const publicSandbox = publicSandboxMode !== null;
|
|
797
792
|
// `--dangerously-bypass-approvals-and-sandbox` disables codex CLI's
|
|
@@ -803,8 +798,9 @@ const buildArgs = ({
|
|
|
803
798
|
// The pod is the security perimeter — agent identity is isolated, workspace
|
|
804
799
|
// is PVC-scoped, no host mounts. bwrap inside the pod is redundant.
|
|
805
800
|
// Public laptop wrappers are different: untrusted pod content must never
|
|
806
|
-
// inherit that bypass. Codex
|
|
807
|
-
// deny-by-default read/write/network boundary on macOS and Linux
|
|
801
|
+
// inherit that bypass. Codex permission profiles provide a native
|
|
802
|
+
// deny-by-default read/write/network boundary on macOS and Linux, on the
|
|
803
|
+
// versions spawn admits (PUBLIC_CODEX_MIN_VERSION). Do not
|
|
808
804
|
// pass legacy `--sandbox` alongside them: Codex documents that the legacy
|
|
809
805
|
// mode disables permission-profile composition.
|
|
810
806
|
const executionPolicy = publicSandbox
|
|
@@ -820,7 +816,6 @@ const buildArgs = ({
|
|
|
820
816
|
workspacePath,
|
|
821
817
|
),
|
|
822
818
|
...PUBLIC_BUILTIN_TOOL_FLAGS,
|
|
823
|
-
...(zeroAgentDepth ? ZERO_AGENT_DEPTH_FLAGS : []),
|
|
824
819
|
]
|
|
825
820
|
: ['--dangerously-bypass-approvals-and-sandbox'];
|
|
826
821
|
const common = [
|
|
@@ -916,6 +911,21 @@ const CODEX_PROVIDER_KEY_ENVS = [
|
|
|
916
911
|
'CODEX_API_KEY',
|
|
917
912
|
];
|
|
918
913
|
|
|
914
|
+
// What the turn will launch, asked for its version. 30 s, as in goose: a first
|
|
915
|
+
// launch after an upgrade can be slow. A failed probe isn't cached, so the next
|
|
916
|
+
// turn reads it again. `_codexVersion` and `_versionProbe` are test seams only.
|
|
917
|
+
const readCodexVersion = async (ctx, env) => {
|
|
918
|
+
if (ctx._codexVersion !== undefined) return ctx._codexVersion;
|
|
919
|
+
try {
|
|
920
|
+
const { command, args } = resolveLaunch('codex', [], { env, ...ctx._commandResolution });
|
|
921
|
+
return await probeVersion(command, {
|
|
922
|
+
args, env, timeoutMs: 30000, parse: parseCodexVersion, ...ctx._versionProbe,
|
|
923
|
+
});
|
|
924
|
+
} catch {
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
|
|
919
929
|
// `ownGroup`: see runClaude in claude.js.
|
|
920
930
|
const runCodex = ({
|
|
921
931
|
args, cwd, env, timeoutMs, credentials = [], spawnImpl = childSpawn, onSpawn, controls = {}, ownGroup = false,
|
|
@@ -1092,15 +1102,16 @@ export default {
|
|
|
1092
1102
|
else if (authKind === 'login') process.stderr.write(`[codex] ${CHATGPT_ROUTE_IGNORED}\n`);
|
|
1093
1103
|
}
|
|
1094
1104
|
const childEnv = { ...(ctx.env || process.env), ...mcp.forwardedEnv };
|
|
1105
|
+
// Before the public home is prepared, so a refused seat changes nothing.
|
|
1106
|
+
if (publicSandboxMode !== null) {
|
|
1107
|
+
const codexVersion = await readCodexVersion(ctx, childEnv);
|
|
1108
|
+
if (!meetsMinimumVersion(codexVersion, PUBLIC_CODEX_MIN_VERSION)) {
|
|
1109
|
+
throw publicCodexVersionError({ found: codexVersion, required: PUBLIC_CODEX_MIN_VERSION });
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1095
1112
|
const publicCodexHome = publicSandboxMode !== null
|
|
1096
1113
|
? await preparePublicCodexHome(ctx, childEnv)
|
|
1097
1114
|
: null;
|
|
1098
|
-
// 30 s, as in goose: a first launch after an upgrade can be slow, and an
|
|
1099
|
-
// unread version drops agents.max_depth=0 for this turn. A failed probe
|
|
1100
|
-
// isn't cached, so the next turn reads it again.
|
|
1101
|
-
const codexVersion = publicSandboxMode === null ? null
|
|
1102
|
-
: ctx._codexVersion !== undefined ? ctx._codexVersion // test seam only
|
|
1103
|
-
: await probeVersion('codex', { env: childEnv, timeoutMs: 30000, parse: parseCodexVersion }).catch(() => null);
|
|
1104
1115
|
const args = buildArgs({
|
|
1105
1116
|
sessionId: ctx.sessionId || null,
|
|
1106
1117
|
prompt: fullPrompt,
|
|
@@ -1115,7 +1126,6 @@ export default {
|
|
|
1115
1126
|
modelBaseUrl,
|
|
1116
1127
|
platform: ctx._platform || process.platform,
|
|
1117
1128
|
workspacePath,
|
|
1118
|
-
zeroAgentDepth: acceptsZeroAgentDepth(codexVersion),
|
|
1119
1129
|
});
|
|
1120
1130
|
// childEnv is derived from the process environment, so the bootstrap export has to be
|
|
1121
1131
|
// taken back out: the declaration above moved our server onto the file,
|
package/src/lib/adapters/pi.js
CHANGED
|
@@ -52,6 +52,7 @@ import { homedir } from 'os';
|
|
|
52
52
|
import { dirname, isAbsolute, join } from 'path';
|
|
53
53
|
import { fileURLToPath } from 'url';
|
|
54
54
|
import {
|
|
55
|
+
adapterFailure,
|
|
55
56
|
readUpstreamRefusal,
|
|
56
57
|
spawnCredentials,
|
|
57
58
|
} from '../upstream-refusal.js';
|
|
@@ -450,10 +451,18 @@ export const buildArgs = ({
|
|
|
450
451
|
prompt,
|
|
451
452
|
];
|
|
452
453
|
|
|
453
|
-
/**
|
|
454
|
+
/**
|
|
455
|
+
* The reply is the last assistant `message_end`'s text parts; tool calls are not
|
|
456
|
+
* text. `finished` means pi ended the turn on an answer: `agent_end`, not retried,
|
|
457
|
+
* after an assistant message that stopped with `stop`. An overflow's `agent_end`
|
|
458
|
+
* says `willRetry: false` and then pi compacts and continues, so `agent_end` after
|
|
459
|
+
* an `error` or `length` stop doesn't count; the continuation's message decides.
|
|
460
|
+
*/
|
|
454
461
|
export const extractReply = (stdout) => {
|
|
455
462
|
let text = '';
|
|
456
463
|
let sawAssistant = false;
|
|
464
|
+
let finished = false;
|
|
465
|
+
let lastStop = null;
|
|
457
466
|
const errors = [];
|
|
458
467
|
for (const line of String(stdout).split('\n')) {
|
|
459
468
|
if (!line.trim()) continue;
|
|
@@ -462,10 +471,33 @@ export const extractReply = (stdout) => {
|
|
|
462
471
|
if (event?.type === 'message_end' && event.message?.role === 'assistant') {
|
|
463
472
|
const parts = (event.message.content || []).filter((c) => c?.type === 'text').map((c) => c.text || '');
|
|
464
473
|
if (parts.length) { text = parts.join('\n').trim(); sawAssistant = true; }
|
|
474
|
+
lastStop = event.message.stopReason;
|
|
475
|
+
finished = false;
|
|
465
476
|
}
|
|
477
|
+
if (event?.type === 'agent_end') finished = event.willRetry !== true && lastStop === 'stop';
|
|
466
478
|
if (event?.type === 'error') errors.push(String(event.message || event.error || 'error'));
|
|
467
479
|
}
|
|
468
|
-
return { text, sawAssistant, errors };
|
|
480
|
+
return { text, sawAssistant, finished, errors };
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
// A turn that printed an interim message and then ended without finishing. A
|
|
484
|
+
// crash keeps its cause, so a quota line in stderr or a refusal on the stream
|
|
485
|
+
// still classifies. A signal (143, 129, or a null code) has neither: stderr then
|
|
486
|
+
// holds pi's startup warnings, and a refusal on the stream may be one pi was
|
|
487
|
+
// recovering from, like an overflow's 400.
|
|
488
|
+
const stoppedTurnFailure = (reply, {
|
|
489
|
+
code, signal, stderr, credentials,
|
|
490
|
+
}) => {
|
|
491
|
+
const killed = Boolean(signal) || code === 143 || code === 129;
|
|
492
|
+
const upstream = killed ? null : reply.upstream;
|
|
493
|
+
const failure = adapterFailure(
|
|
494
|
+
'pi',
|
|
495
|
+
reply.errors.join(' | ') || (killed ? '' : stderr.trim().slice(-600)) || upstream?.detail
|
|
496
|
+
|| 'the turn stopped before it finished',
|
|
497
|
+
{ credentials, exitCode: code, limit: 600 },
|
|
498
|
+
);
|
|
499
|
+
if (upstream) failure.status ??= upstream.status;
|
|
500
|
+
return failure;
|
|
469
501
|
};
|
|
470
502
|
|
|
471
503
|
/**
|
|
@@ -538,7 +570,7 @@ const runPi = ({
|
|
|
538
570
|
});
|
|
539
571
|
proc.stderr.on('data', (chunk) => { stderr += chunk.toString(); });
|
|
540
572
|
proc.on('error', (err) => { clearTimeout(timer); reject(err); });
|
|
541
|
-
proc.on('close', (code) => {
|
|
573
|
+
proc.on('close', (code, signal) => {
|
|
542
574
|
clearTimeout(timer);
|
|
543
575
|
if (hookError) return reject(hookError);
|
|
544
576
|
if (timedOut) return reject(new Error(`pi timed out after ${timeoutMs}ms`));
|
|
@@ -548,7 +580,16 @@ const runPi = ({
|
|
|
548
580
|
// on the stream rather than on the exit code (TASK-096, measured 2026-09-22).
|
|
549
581
|
const upstream = readUpstreamRefusal(stdout, { credentials });
|
|
550
582
|
if (upstream) reply.upstream = upstream;
|
|
551
|
-
|
|
583
|
+
// Without `finished`, the text pi printed was an interim message, so posting
|
|
584
|
+
// it would answer with half a turn and acknowledge what it held. An error
|
|
585
|
+
// event fails the turn even after `finished`, which could otherwise read as
|
|
586
|
+
// silent. A tool-only turn that finished stays silent, whatever the exit.
|
|
587
|
+
if (code !== 0 && (!reply.finished || reply.errors.length)) {
|
|
588
|
+
if (reply.sawAssistant) {
|
|
589
|
+
return reject(stoppedTurnFailure(reply, {
|
|
590
|
+
code, signal, stderr, credentials,
|
|
591
|
+
}));
|
|
592
|
+
}
|
|
552
593
|
const tail = (reply.errors.join(' | ') || stderr).trim().slice(-600);
|
|
553
594
|
return reject(new Error(`pi exited ${code}: ${tail}`));
|
|
554
595
|
}
|
|
@@ -12,6 +12,7 @@ import { resolveOnPath } from '../resolve-on-path.js';
|
|
|
12
12
|
// A newer minor or major, an older patch, an older line, or a prerelease still
|
|
13
13
|
// refuses until it is smoke-tested and added to the adapter's list.
|
|
14
14
|
const STABLE = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
15
|
+
const SEMVER = /^(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?$/;
|
|
15
16
|
|
|
16
17
|
export const isPatchAfterNewestTested = (version, tested) => {
|
|
17
18
|
const installed = STABLE.exec(String(version || ''));
|
|
@@ -22,6 +23,36 @@ export const isPatchAfterNewestTested = (version, tested) => {
|
|
|
22
23
|
&& Number(installed[3]) > Number(newest[3]);
|
|
23
24
|
};
|
|
24
25
|
|
|
26
|
+
// A floor rather than a list: the version, or anything later, prereleases of a
|
|
27
|
+
// later version included, so the list's prerelease rule above doesn't apply. A
|
|
28
|
+
// prerelease of the floor comes before it, and an unreadable version meets nothing.
|
|
29
|
+
export const meetsMinimumVersion = (version, minimum) => {
|
|
30
|
+
const installed = SEMVER.exec(String(version ?? ''));
|
|
31
|
+
const floor = STABLE.exec(String(minimum ?? ''));
|
|
32
|
+
if (!installed || !floor) return false;
|
|
33
|
+
for (let part = 1; part <= 3; part += 1) {
|
|
34
|
+
const difference = Number(installed[part]) - Number(floor[part]);
|
|
35
|
+
if (difference !== 0) return difference > 0;
|
|
36
|
+
}
|
|
37
|
+
return !installed[4];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const PUBLIC_CODEX_VERSION_CODE = 'public_codex_version';
|
|
41
|
+
|
|
42
|
+
// `found` stays in this message, which only the seat's log shows. The line a pod
|
|
43
|
+
// sees is built from `requiredVersion` (turn-failure-notice.js).
|
|
44
|
+
export const publicCodexVersionError = ({ found, required }) => {
|
|
45
|
+
const error = new Error(found
|
|
46
|
+
? `public seat refused this turn: Codex ${found} is older than this seat needs. `
|
|
47
|
+
+ `Upgrade Codex to at least ${required} and start the agent again.`
|
|
48
|
+
: 'public seat refused this turn: could not read the Codex version. '
|
|
49
|
+
+ `Check that \`codex --version\` works for this agent, upgrade Codex to at least ${required} `
|
|
50
|
+
+ 'if it is older, and start the agent again.');
|
|
51
|
+
error.code = PUBLIC_CODEX_VERSION_CODE;
|
|
52
|
+
error.requiredVersion = required;
|
|
53
|
+
return error;
|
|
54
|
+
};
|
|
55
|
+
|
|
25
56
|
// The harness's own `--version`, asked without blocking the event loop and
|
|
26
57
|
// remembered per binary. A daemon runs every seat in one process, beside the
|
|
27
58
|
// loopback provider proxies of other seats' live turns, so a synchronous probe
|
|
@@ -36,6 +67,10 @@ export const isPatchAfterNewestTested = (version, tested) => {
|
|
|
36
67
|
// cwd lookup missed the cache every turn and could key it on a same-named file
|
|
37
68
|
// there. What runs is that resolved real path, so the binary that answers is
|
|
38
69
|
// the one the key names. A name that does not resolve runs as given, uncached.
|
|
70
|
+
//
|
|
71
|
+
// `args` come before `--version`, for a launch that is an interpreter and a
|
|
72
|
+
// script (a Windows npm shim). The interpreter's path says nothing about which
|
|
73
|
+
// script it would run, so that probe is never cached.
|
|
39
74
|
const versionCache = new Map();
|
|
40
75
|
|
|
41
76
|
const resolveBinary = (binary, env) => {
|
|
@@ -52,14 +87,14 @@ const resolveBinary = (binary, env) => {
|
|
|
52
87
|
};
|
|
53
88
|
|
|
54
89
|
export const probeVersion = async (binary, {
|
|
55
|
-
env, timeoutMs = 30000, parse, execFileImpl = childProcess.execFile, cache = versionCache,
|
|
90
|
+
args = [], env, timeoutMs = 30000, parse, execFileImpl = childProcess.execFile, cache = versionCache,
|
|
56
91
|
} = {}) => {
|
|
57
|
-
const resolved = resolveBinary(binary, env);
|
|
92
|
+
const resolved = args.length ? null : resolveBinary(binary, env);
|
|
58
93
|
const key = resolved?.key || null;
|
|
59
94
|
const hit = key ? cache.get(key) : null;
|
|
60
95
|
if (hit && hit.mtimeMs === resolved.mtimeMs) return hit.version;
|
|
61
96
|
const stdout = await new Promise((resolve) => {
|
|
62
|
-
execFileImpl(key || binary, ['--version'], { encoding: 'utf8', env, timeout: timeoutMs }, (error, out) => {
|
|
97
|
+
execFileImpl(key || binary, [...args, '--version'], { encoding: 'utf8', env, timeout: timeoutMs }, (error, out) => {
|
|
63
98
|
resolve(error ? null : out);
|
|
64
99
|
});
|
|
65
100
|
});
|
package/src/lib/spawn-retry.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { PUBLIC_MCP_NOT_READY_CODE, PUBLIC_TOOL_FAILED_CODE } from './public-tool-error.js';
|
|
11
|
+
import { PUBLIC_CODEX_VERSION_CODE } from './adapters/tested-version.js';
|
|
11
12
|
|
|
12
13
|
export const SPAWN_FAILURE_CLASS = Object.freeze({
|
|
13
14
|
// The provider refused the request's CONTENT. Re-sending the same content
|
|
@@ -138,6 +139,8 @@ export const classifySpawnFailure = (error) => {
|
|
|
138
139
|
? SPAWN_FAILURE_CLASS.RATE_LIMIT
|
|
139
140
|
: SPAWN_FAILURE_CLASS.RUNTIME;
|
|
140
141
|
}
|
|
142
|
+
// Only whoever runs the seat can change this, so it waits as a missing CLI does.
|
|
143
|
+
if (error?.code === PUBLIC_CODEX_VERSION_CODE) return SPAWN_FAILURE_CLASS.CONFIGURATION;
|
|
141
144
|
// First: the refusal text carries none of the words below today, but a
|
|
142
145
|
// refusal must never be read as a transient condition and retried.
|
|
143
146
|
if (CONTENT_REFUSED_RE.test(text)) return SPAWN_FAILURE_CLASS.CONTENT_REFUSED;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* which is what it did before.
|
|
17
17
|
*/
|
|
18
18
|
import { PUBLIC_MCP_NOT_READY_CODE, PUBLIC_TOOL_FAILED_CODE } from './public-tool-error.js';
|
|
19
|
+
import { PUBLIC_CODEX_VERSION_CODE } from './adapters/tested-version.js';
|
|
19
20
|
import { classifySpawnFailure, GATEWAY_BUDGET_RE, SPAWN_FAILURE_CLASS } from './spawn-retry.js';
|
|
20
21
|
|
|
21
22
|
/** How long one cause stays posted in a pod before the seat may post it again. */
|
|
@@ -54,12 +55,18 @@ export const WONT_START_NOTICE = 'I can’t answer right now: the tool I run on
|
|
|
54
55
|
export const OUT_OF_ALLOWANCE_NOTICE = 'I can’t answer right now: the AI account I run on has used up its allowance. '
|
|
55
56
|
+ `It needs to reset, or whoever runs me needs to add more. ${AGAIN}`;
|
|
56
57
|
|
|
58
|
+
export const codexVersionNotice = (required) => 'I can’t answer right now: the computer I run on needs '
|
|
59
|
+
+ `Codex ${required} or newer. Whoever runs me needs to upgrade it and start me again. ${AGAIN}`;
|
|
60
|
+
|
|
57
61
|
const matches = (wordings, text) => wordings.some((wording) => wording.test(text));
|
|
58
62
|
|
|
59
63
|
/** The cause a pod should hear about, and its line, or null when it should hear nothing. */
|
|
60
64
|
export const cantAnswerNotice = (error) => {
|
|
61
65
|
// A public seat's withheld turn quotes a TOOL's error, not its own provider's.
|
|
62
66
|
if (error?.code === PUBLIC_TOOL_FAILED_CODE || error?.code === PUBLIC_MCP_NOT_READY_CODE) return null;
|
|
67
|
+
if (error?.code === PUBLIC_CODEX_VERSION_CODE) {
|
|
68
|
+
return { cause: 'codex-version', text: codexVersionNotice(error.requiredVersion) };
|
|
69
|
+
}
|
|
63
70
|
// A crashed claude turn keeps assistant and tool JSON lines in its tail, and
|
|
64
71
|
// those are the model's words, or a tool's.
|
|
65
72
|
const text = String(error?.message ?? '').split(/(?:^|: | \| |\n)\{"type":/)[0];
|