Skip to content

Commit d34c32a

Browse files
committed
fix(codex): bound external app-server compatibility
1 parent 06f68d6 commit d34c32a

11 files changed

Lines changed: 102 additions & 78 deletions

File tree

‎docs/plugins/codex-harness-reference.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,11 @@ If the normal app-server runtime would be `danger-full-access`, enabling
317317
permission profile instead. Codex-managed network enforcement is sandboxed
318318
networking, so a full-access profile would not protect outbound traffic.
319319

320-
The plugin accepts exactly stable Codex app-server `0.147.0`. Older or newer
321-
versions, prereleases, build-suffixed versions, and unversioned app-server
322-
handshakes are rejected. The same exact-version requirement applies to explicit
323-
custom executables, remote app-servers, and macOS desktop binaries.
320+
The plugin ships Codex app-server `0.147.0` and accepts external versions through
321+
`0.148.0-alpha.15`. Versions outside that tested range and malformed or
322+
unversioned handshakes are rejected. Build metadata does not affect SemVer
323+
precedence. The same range applies to explicit custom executables, remote
324+
app-servers, and macOS desktop binaries; admission is not readiness proof.
324325

325326
OpenClaw treats non-loopback WebSocket app-server URLs as remote and requires
326327
identity-bearing WebSocket auth through `appServer.authToken` or an
@@ -369,7 +370,7 @@ configured plugin's details to reserve the denied app IDs. It does not scan
369370
unrelated marketplaces or install, enable, or authenticate the disabled plugin;
370371
missing ownership fails closed.
371372

372-
Only connect OpenClaw to a `0.147.0` remote app-server trusted to accept
373+
Only connect OpenClaw to a remote app-server in the supported range trusted to accept
373374
configured marketplace plugin installs and inventory refreshes. Missing modern
374375
inventory methods and server, authentication, or transport failures fail closed.
375376

‎docs/plugins/codex-harness.md‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ channel is the communication surface.
8989

9090
- The official `@openclaw/codex` plugin installed. Include `codex` in
9191
`plugins.allow` if your config uses an allowlist.
92-
- Codex app-server `0.147.0` or newer. The plugin still ships and manages the
92+
- Codex app-server `0.147.0` through `0.148.0-alpha.15`. The plugin still ships and manages the
9393
exact `@openai/codex` `0.147.0` artifact, so a `codex` command on `PATH` does
9494
not affect normal startup. Explicit custom, remote, and macOS desktop-owned
95-
app-servers must report valid SemVer at or above that managed baseline.
96-
Higher versions initialize with a warning; acceptance permits an attempt and
97-
is not readiness or capability proof.
95+
app-servers must report valid SemVer inside that tested external range.
96+
Versions above the managed artifact initialize with a warning; acceptance
97+
permits an attempt and is not readiness or capability proof.
9898
- Node.js on the remote Codex app-server host when `remoteWorkspaceRoot` is set
9999
and cross-machine workspace attachments must be transferred.
100100
- Codex auth through `openclaw models auth login --provider openai`, an
@@ -1355,12 +1355,13 @@ instead of a plain OpenAI API-key failure.
13551355
Doctor rewrites legacy model refs to `openai/*`, removes stale session and
13561356
whole-agent runtime pins, and preserves existing auth-profile overrides.
13571357

1358-
**The app-server is rejected:** use Codex `0.147.0` or newer. OpenClaw rejects
1359-
older, malformed, and unversioned servers. Same-version prereleases such as
1358+
**The app-server is rejected:** use Codex `0.147.0` through
1359+
`0.148.0-alpha.15`. OpenClaw rejects versions outside that tested range, plus
1360+
malformed and unversioned servers. Same-version prereleases such as
13601361
`0.147.0-alpha.2` remain below the stable minimum; build metadata such as
1361-
`0.147.0+desktop` does not affect precedence. A higher version is permitted to
1362-
initialize rather than treated as proof of compatibility, so startup and
1363-
capability operations can still fail with their normal diagnostics.
1362+
`0.147.0+desktop` does not affect precedence. An accepted external version is
1363+
permitted to initialize rather than treated as proof of compatibility, so
1364+
startup and capability operations can still fail with their normal diagnostics.
13641365

13651366
**`/codex status` cannot connect:** check that the `codex` plugin
13661367
is enabled, that `plugins.allow` includes it when an allowlist is

‎docs/plugins/codex-native-plugins.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ working.
2222
- The agent runtime must be the native Codex harness.
2323
- `plugins.entries.codex.enabled` is `true`.
2424
- `plugins.entries.codex.config.codexPlugins.enabled` is `true`.
25-
- Codex app-server reports exactly stable `0.147.0`. The official plugin ships
26-
`@openai/codex` `0.147.0`; custom, remote, and macOS desktop-owned binaries
27-
must use the same exact version.
25+
- Codex app-server reports a version from `0.147.0` through
26+
`0.148.0-alpha.15`. The official plugin still ships `@openai/codex`
27+
`0.147.0`; accepted external versions remain subject to normal startup and
28+
capability validation.
2829
- The target Codex app-server can see the expected marketplace, plugin, and
2930
app inventory.
3031
- Migration supports only `openai-curated` plugins that it observed as

‎docs/plugins/sdk-agent-harness.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,9 @@ For operator setup, model prefix examples, and Codex-only configs, see
319319

320320
The Codex plugin enforces the minimum app-server version documented in
321321
[Codex Harness](/plugins/codex-harness). It checks the initialize handshake and
322-
blocks older or unversioned servers, so OpenClaw only runs against the protocol
323-
surface it has tested.
322+
blocks versions outside the tested external range plus malformed or unversioned
323+
servers. Admission permits startup to continue; it does not prove later runtime
324+
or capability operations will succeed.
324325

325326
### Tool-result middleware
326327

‎extensions/codex/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"type": "module",
1010
"dependencies": {
1111
"@openai/codex": "0.147.0",
12+
"semver": "7.8.5",
1213
"smol-toml": "1.7.1",
1314
"typebox": "1.3.6",
1415
"ws": "8.21.1",

‎extensions/codex/src/app-server/client.test.ts‎

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import {
88
} from "./client.js";
99
import { resetSharedCodexAppServerClientForTests } from "./shared-client.js";
1010
import { createClientHarness } from "./test-support.js";
11-
import { CODEX_APP_SERVER_VERSION, MIN_SUPPORTED_CODEX_APP_SERVER_VERSION } from "./version.js";
11+
import {
12+
CODEX_APP_SERVER_VERSION,
13+
MAX_SUPPORTED_CODEX_APP_SERVER_VERSION,
14+
MIN_SUPPORTED_CODEX_APP_SERVER_VERSION,
15+
} from "./version.js";
1216

1317
const CODEX_DYNAMIC_TOOL_SERVER_REQUEST_TIMEOUT_MS = 660_000;
1418

@@ -361,7 +365,7 @@ describe("CodexAppServerClient", () => {
361365
});
362366

363367
await expect(initializing).rejects.toThrow(
364-
`Codex app-server ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} or newer is required, but detected 0.146.9`,
368+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required, but detected 0.146.9`,
365369
);
366370
expect(harness.writes).toHaveLength(1);
367371
});
@@ -374,7 +378,7 @@ describe("CodexAppServerClient", () => {
374378
});
375379

376380
await expect(initializing).rejects.toThrow(
377-
`Codex app-server ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} or newer is required, but detected 0.146.0`,
381+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required, but detected 0.146.0`,
378382
);
379383
expect(harness.writes).toHaveLength(1);
380384
});
@@ -387,7 +391,7 @@ describe("CodexAppServerClient", () => {
387391
});
388392

389393
await expect(initializing).rejects.toThrow(
390-
`Codex app-server ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} or newer is required, but detected 0.147.0-alpha.2`,
394+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required, but detected 0.147.0-alpha.2`,
391395
);
392396
expect(harness.writes).toHaveLength(1);
393397
});
@@ -414,7 +418,7 @@ describe("CodexAppServerClient", () => {
414418
});
415419

416420
await expect(initializing).rejects.toThrow(
417-
`Codex app-server ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} or newer is required`,
421+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
418422
);
419423
expect(harness.writes).toHaveLength(1);
420424
});
@@ -427,31 +431,49 @@ describe("CodexAppServerClient", () => {
427431
});
428432

429433
await expect(initializing).rejects.toThrow(
430-
`Codex app-server ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} or newer is required`,
434+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
431435
);
432436
expect(harness.writes).toHaveLength(1);
433437
});
434438

435-
it("accepts a newer Codex Desktop prerelease for capability validation", async () => {
436-
const newerVersion = "0.148.0-alpha.9";
437-
const warn = vi.spyOn(embeddedAgentLog, "warn").mockImplementation(() => undefined);
438-
const { harness, initializing, outbound } = startInitialize();
439-
harness.send({
440-
id: outbound.id,
441-
result: { userAgent: `openclaw/${newerVersion} (macOS; test)` },
442-
});
439+
it.each(["0.148.0-alpha.9", MAX_SUPPORTED_CODEX_APP_SERVER_VERSION])(
440+
"accepts tested Codex Desktop prerelease %s for normal startup validation",
441+
async (newerVersion) => {
442+
const warn = vi.spyOn(embeddedAgentLog, "warn").mockImplementation(() => undefined);
443+
const { harness, initializing, outbound } = startInitialize();
444+
harness.send({
445+
id: outbound.id,
446+
result: { userAgent: `openclaw/${newerVersion} (macOS; test)` },
447+
});
443448

444-
await expect(initializing).resolves.toBeUndefined();
445-
expect(harness.client.getServerVersion()).toBe(newerVersion);
446-
expect(JSON.parse(harness.writes[1] ?? "{}")).toEqual({ method: "initialized" });
447-
expect(warn).toHaveBeenCalledWith(
448-
"codex app-server is newer than OpenClaw's validated managed runtime; continuing with capability validation",
449-
{
450-
detectedVersion: newerVersion,
451-
validatedVersion: CODEX_APP_SERVER_VERSION,
452-
},
453-
);
454-
});
449+
await expect(initializing).resolves.toBeUndefined();
450+
expect(harness.client.getServerVersion()).toBe(newerVersion);
451+
expect(JSON.parse(harness.writes[1] ?? "{}")).toEqual({ method: "initialized" });
452+
expect(warn).toHaveBeenCalledWith(
453+
"codex app-server is newer than OpenClaw's managed runtime; continuing with normal startup validation",
454+
{
455+
detectedVersion: newerVersion,
456+
validatedVersion: CODEX_APP_SERVER_VERSION,
457+
},
458+
);
459+
},
460+
);
461+
462+
it.each(["0.148.0-alpha.16", "0.148.0", "1.0.0"])(
463+
"blocks unverified future app-server version %s during initialize",
464+
async (version) => {
465+
const { harness, initializing, outbound } = startInitialize();
466+
harness.send({
467+
id: outbound.id,
468+
result: { userAgent: `openclaw/${version} (macOS; test)` },
469+
});
470+
471+
await expect(initializing).rejects.toThrow(
472+
`through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
473+
);
474+
expect(harness.writes).toHaveLength(1);
475+
},
476+
);
455477

456478
it.each(["0.147.00", "0.148.0-alpha..9", "0.148.0-alpha.09"])(
457479
"blocks malformed app-server version %s during initialize",
@@ -463,7 +485,7 @@ describe("CodexAppServerClient", () => {
463485
});
464486

465487
await expect(initializing).rejects.toThrow(
466-
`Codex app-server ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} or newer is required`,
488+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
467489
);
468490
expect(harness.writes).toHaveLength(1);
469491
},
@@ -474,7 +496,7 @@ describe("CodexAppServerClient", () => {
474496
harness.send({ id: outbound.id, result: {} });
475497

476498
await expect(initializing).rejects.toThrow(
477-
`Codex app-server ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} or newer is required`,
499+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
478500
);
479501
expect(harness.writes).toHaveLength(1);
480502
});

‎extensions/codex/src/app-server/client.ts‎

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { embeddedAgentLog, OPENCLAW_VERSION } from "openclaw/plugin-sdk/agent-ha
88
import { coerceErrorMessage, toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
99
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
1010
import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
11+
import { parse as parseSemver } from "semver";
1112
import { resolveCodexAppServerRuntimeOptions, type CodexAppServerStartOptions } from "./config.js";
1213
import {
1314
type CodexAppServerRequestMethod,
@@ -30,7 +31,11 @@ import {
3031
closeCodexAppServerTransportAndWait,
3132
type CodexAppServerTransport,
3233
} from "./transport.js";
33-
import { CODEX_APP_SERVER_VERSION, MIN_SUPPORTED_CODEX_APP_SERVER_VERSION } from "./version.js";
34+
import {
35+
CODEX_APP_SERVER_VERSION,
36+
MAX_SUPPORTED_CODEX_APP_SERVER_VERSION,
37+
MIN_SUPPORTED_CODEX_APP_SERVER_VERSION,
38+
} from "./version.js";
3439

3540
const CODEX_APP_SERVER_PARSE_LOG_MAX = 500;
3641
const CODEX_APP_SERVER_PARSE_BUFFER_MAX = 8 * 1024 * 1024;
@@ -999,7 +1004,7 @@ class CodexAppServerVersionError extends Error {
9991004
? `detected ${detectedVersion}`
10001005
: "OpenClaw could not determine the running Codex version";
10011006
super(
1002-
`Codex app-server ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} or newer is required, but ${detected}. Update the configured Codex app-server binary, or remove custom command overrides to use the managed binary.`,
1007+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required, but ${detected}. Update the configured Codex app-server binary, or remove custom command overrides to use the managed binary.`,
10031008
);
10041009
this.name = "CodexAppServerVersionError";
10051010
this.detectedVersion = detectedVersion;
@@ -1008,34 +1013,20 @@ class CodexAppServerVersionError extends Error {
10081013

10091014
function assertSupportedCodexAppServerVersion(response: CodexInitializeResponse): string {
10101015
const detectedVersion = readCodexVersionFromUserAgent(response.userAgent);
1011-
const detected = detectedVersion?.match(
1012-
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u,
1013-
);
1014-
const minimum = MIN_SUPPORTED_CODEX_APP_SERVER_VERSION.split(".").map(Number);
1015-
let precedence = 0;
1016-
if (detected) {
1017-
for (let index = 0; index < minimum.length; index += 1) {
1018-
precedence = Number(detected[index + 1]) - (minimum[index] ?? 0);
1019-
if (precedence !== 0) {
1020-
break;
1021-
}
1022-
}
1016+
if (!detectedVersion) {
1017+
throw new CodexAppServerVersionError(detectedVersion);
10231018
}
1024-
const invalidNumericPrerelease = detected?.[4]
1025-
?.split(".")
1026-
.some((identifier) => /^\d+$/u.test(identifier) && /^0\d/u.test(identifier));
1019+
const detected = parseSemver(detectedVersion);
10271020
if (
1028-
!detectedVersion ||
10291021
!detected ||
1030-
invalidNumericPrerelease ||
1031-
precedence < 0 ||
1032-
(precedence === 0 && Boolean(detected[4]))
1022+
detected.compare(MIN_SUPPORTED_CODEX_APP_SERVER_VERSION) < 0 ||
1023+
detected.compare(MAX_SUPPORTED_CODEX_APP_SERVER_VERSION) > 0
10331024
) {
10341025
throw new CodexAppServerVersionError(detectedVersion);
10351026
}
1036-
if (precedence > 0) {
1027+
if (detected.compare(CODEX_APP_SERVER_VERSION) > 0) {
10371028
embeddedAgentLog.warn(
1038-
"codex app-server is newer than OpenClaw's validated managed runtime; continuing with capability validation",
1029+
"codex app-server is newer than OpenClaw's managed runtime; continuing with normal startup validation",
10391030
{
10401031
detectedVersion,
10411032
validatedVersion: CODEX_APP_SERVER_VERSION,

‎extensions/codex/src/app-server/shared-client.test.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import type { CodexAppServerStartOptions } from "./config.js";
99
import { acquireCodexNativeConfigFence } from "./native-config-fence.js";
1010
import { codexNativeSubagentMonitorRuntime } from "./native-subagent-monitor.js";
1111
import { createClientHarness } from "./test-support.js";
12-
import { CODEX_APP_SERVER_VERSION, MIN_SUPPORTED_CODEX_APP_SERVER_VERSION } from "./version.js";
12+
import {
13+
CODEX_APP_SERVER_VERSION,
14+
MAX_SUPPORTED_CODEX_APP_SERVER_VERSION,
15+
MIN_SUPPORTED_CODEX_APP_SERVER_VERSION,
16+
} from "./version.js";
1317

1418
const mocks = vi.hoisted(() => ({
1519
bridgeCodexAppServerStartOptions: vi.fn(async ({ startOptions }) => startOptions),
@@ -279,7 +283,7 @@ describe("shared Codex app-server client", () => {
279283
await sendInitializeResult(harness, "openclaw/0.117.9 (macOS; test)");
280284

281285
await expect(listPromise).rejects.toThrow(
282-
`Codex app-server ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} or newer is required`,
286+
`A Codex app-server from ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} through ${MAX_SUPPORTED_CODEX_APP_SERVER_VERSION} is required`,
283287
);
284288
expect(harness.process.stdin.destroyed).toBe(true);
285289
startSpy.mockRestore();
@@ -526,7 +530,7 @@ describe("shared Codex app-server client", () => {
526530
});
527531
expect(desktop.process.stdin.destroyed).toBe(false);
528532
expect(mocks.embeddedAgentLog.warn).toHaveBeenCalledWith(
529-
"codex app-server is newer than OpenClaw's validated managed runtime; continuing with capability validation",
533+
"codex app-server is newer than OpenClaw's managed runtime; continuing with normal startup validation",
530534
{
531535
detectedVersion: "0.148.0-alpha.9",
532536
validatedVersion: CODEX_APP_SERVER_VERSION,

‎extensions/codex/src/app-server/version.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
export const CODEX_APP_SERVER_VERSION = "0.147.0";
66
/** Inclusive runtime compatibility floor for external app-server binaries. */
77
export const MIN_SUPPORTED_CODEX_APP_SERVER_VERSION = "0.147.0";
8+
/** Inclusive runtime compatibility ceiling for external app-server binaries. */
9+
// The ceiling is the newest Desktop build covered by upstream source inspection and
10+
// a live Computer Use flow. Raising it requires equivalent protocol and live proof.
11+
export const MAX_SUPPORTED_CODEX_APP_SERVER_VERSION = "0.148.0-alpha.15";
812
/** npm package name for the managed Codex app-server binary. */
913
export const MANAGED_CODEX_APP_SERVER_PACKAGE = "@openai/codex";

‎extensions/codex/src/manifest.test.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
// Codex tests cover manifest plugin behavior.
22
import fs from "node:fs";
33
import { describe, expect, it } from "vitest";
4-
import {
5-
CODEX_APP_SERVER_VERSION,
6-
MIN_SUPPORTED_CODEX_APP_SERVER_VERSION,
7-
} from "./app-server/version.js";
4+
import { CODEX_APP_SERVER_VERSION } from "./app-server/version.js";
85

96
type CodexPackageManifest = {
107
dependencies?: Record<string, string>;
@@ -27,8 +24,6 @@ describe("codex package manifest", () => {
2724

2825
expect(packageJson.devDependencies).toHaveProperty("@openclaw/plugin-sdk");
2926
expect(packageJson.dependencies?.["@openai/codex"]).toBe(CODEX_APP_SERVER_VERSION);
30-
expect(MIN_SUPPORTED_CODEX_APP_SERVER_VERSION).toBe(CODEX_APP_SERVER_VERSION);
31-
expect(packageJson.dependencies).not.toHaveProperty("semver");
3227
expect(packageJson.openclaw?.release?.requireLatestDependencies).toEqual(["@openai/codex"]);
3328
expect(packageJson.openclaw?.install?.requiredPlatformPackages).toEqual([
3429
"@openai/codex-linux-x64",

0 commit comments

Comments
 (0)