@openclaw/codex 2026.9.1-beta.1 → 2026.9.2

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.
Files changed (81) hide show
  1. package/dist/api.js +8 -9
  2. package/dist/{attempt-client-cleanup-bfsmcQ6m.js → attempt-client-cleanup-Bp1ZOnk2.js} +105 -75
  3. package/dist/attempt-context-CSazkWns.js +634 -0
  4. package/dist/{auth-binding-B4FfbcCg.js → auth-binding-Ds_QVm-X.js} +18 -3
  5. package/dist/{bounded-turn-B7iBUcuP.js → bounded-turn-DxGJRYbY.js} +53 -57
  6. package/dist/{capabilities-BRMh0aIq.js → capabilities-B1mgvpP8.js} +2 -1
  7. package/dist/cli-metadata.js +1 -1
  8. package/dist/{command-formatters-DEsIufkt.js → command-formatters-DSbGMXA0.js} +5 -4
  9. package/dist/{command-handlers-D_-1_qRp.js → command-handlers-DOJvGv6-.js} +243 -148
  10. package/dist/{compact-BglNFZrQ.js → compact-Y_xBqrHN.js} +109 -65
  11. package/dist/{config-giW8X0QA.js → config-CyapYSji.js} +328 -374
  12. package/dist/config-utils-C57JiJrU.js +69 -0
  13. package/dist/{context-compaction-activity-BOeJf7yo.js → context-compaction-activity-CMla5FPJ.js} +4 -1
  14. package/dist/{conversation-binding-data-CW2GuupV.js → conversation-binding-data-BiodpIzq.js} +2 -1
  15. package/dist/doctor-contract-api.js +144 -14
  16. package/dist/{dynamic-tools-Dnlfa--w.js → dynamic-tools-BwpvTxaX.js} +1119 -1135
  17. package/dist/{effective-mcp-catalog-CTeGrnfO.js → effective-mcp-catalog-CY9Jn4bA.js} +4 -3
  18. package/dist/{event-projector-assistant-message-C5-Ds8mA.js → event-projector-assistant-message-B9kp6iGC.js} +15 -6
  19. package/dist/event-projector-usage-ZqEVbAEY.js +212 -0
  20. package/dist/{harness-Csz0F-DK.js → harness-Czh2Sdoc.js} +65 -52
  21. package/dist/harness.js +1 -1
  22. package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
  23. package/dist/index.js +495 -457
  24. package/dist/{isolated-completion-Cv6FqygM.js → isolated-completion-CRh-51AK.js} +9 -21
  25. package/dist/{managed-binary-DFYK4DWq.js → managed-binary-DcpnJF9x.js} +117 -80
  26. package/dist/media-understanding-provider.js +1 -1
  27. package/dist/model-catalog-DT5vo6qo.js +101 -0
  28. package/dist/{models-TS3HBU-q.js → models-CcrgSMQR.js} +26 -29
  29. package/dist/{native-subagent-monitor-4Mfq2HDs.js → native-subagent-monitor-B3bvQGcg.js} +63 -122
  30. package/dist/{node-exec-server.runtime-BpWqJO1V.js → node-exec-server.runtime-nfbUOtUB.js} +10 -7
  31. package/dist/{plugin-approval-roundtrip-bUm777tR.js → plugin-approval-roundtrip-aQVdyL5g.js} +30 -3
  32. package/dist/{plugin-marketplace-discovery-B9DvaAG-.js → plugin-marketplace-discovery-B7gHXJ3d.js} +44 -30
  33. package/dist/{plugin-metadata-cache-CTCT3w5L.js → plugin-metadata-cache-BwCLTY_U.js} +6 -6
  34. package/dist/provider-capabilities-BpG9Ltc5.js +101 -0
  35. package/dist/{rate-limits-C5_D8Gmb.js → rate-limits-Fx_l4eNa.js} +3 -2
  36. package/dist/{sandbox-guard-kuWTn9C5.js → request-C8H22rPi.js} +195 -2
  37. package/dist/{run-attempt-DYc0QCBF.js → run-attempt-BzthFQSM.js} +1616 -2634
  38. package/dist/{runtime-artifact-BvyT1uyd.js → runtime-artifact-Bh_gf6-t.js} +22 -15
  39. package/dist/{session-binding-Bcynfd-_.js → session-binding-4Ki04sW-.js} +282 -399
  40. package/dist/session-binding-record-CyaXZvTe.js +270 -0
  41. package/dist/{session-catalog-DaLKVtpH.js → session-catalog-B47uwekb.js} +812 -504
  42. package/dist/{session-cli-DMc4oS2w.js → session-cli-BjLhpmS1.js} +1 -1
  43. package/dist/session-history-DWmMqiqW.js +93 -0
  44. package/dist/session-history-read-LHldwvyh.js +36 -0
  45. package/dist/session-history-worker-runtime.js +48 -0
  46. package/dist/session-history.worker-zZVcx0ME.js +267 -0
  47. package/dist/session-history.worker.js +2 -0
  48. package/dist/session-initialization-BCFVnLL4.js +75 -0
  49. package/dist/{session-permission-policy-BrNH1bjy.js → session-permission-policy-BaueHmSj.js} +2 -2
  50. package/dist/session-retirement-DNdmYdFc.js +97 -0
  51. package/dist/{session-upstream-marker-BIkusb95.js → session-upstream-marker-DReTpGz6.js} +20 -4
  52. package/dist/settled-turn-context-BOM3Y1pl.js +45 -0
  53. package/dist/settled-turn-finalizer-BI-b1sry.js +115 -0
  54. package/dist/{shared-client-DKz23hHY.js → shared-client-CKhX2kFt.js} +3659 -847
  55. package/dist/{side-question-DjA_jsNe.js → side-question-B6DWAw1A.js} +168 -81
  56. package/dist/{thread-lifecycle-L7oEkTlq.js → thread-lifecycle-DPK30jad.js} +2412 -2145
  57. package/dist/{thread-ownership-DZeuKH1j.js → thread-ownership-CbucAmmp.js} +27 -16
  58. package/dist/thread-policy-CTalhWFy.js +105 -0
  59. package/dist/{plugin-app-cache-key-C1CAdfcP.js → thread-resume-BLgqkUc1.js} +61 -9
  60. package/dist/{transcript-mirror-DsCMWBca.js → transcript-mirror-_njEB84z.js} +114 -110
  61. package/dist/transcript-mirror-attestation-Byl34PC-.js +76 -0
  62. package/dist/transport-stdio-CzTngV0j.js +728 -0
  63. package/dist/{upstream-prompt-provenance-CFmsKwr9.js → upstream-prompt-provenance-LphB8slG.js} +8 -4
  64. package/dist/upstream-session-fork-1fwbNKzQ.js +886 -0
  65. package/dist/{usage-ROIaW3wo.js → usage-i9fv5-4m.js} +3 -3
  66. package/dist/{web-search-provider.runtime-ClaNPV7N.js → web-search-provider.runtime-DKQn67A7.js} +3 -3
  67. package/openclaw.plugin.json +1 -30
  68. package/package.json +6 -6
  69. package/dist/binding-connection-BMvPX73o.js +0 -45
  70. package/dist/command-rpc-CCeCkf_v.js +0 -90
  71. package/dist/event-projector-usage-Bk1I90Bg.js +0 -328
  72. package/dist/incognito-session-ET_ufDH-.js +0 -2
  73. package/dist/model-catalog-i9rNBthX.js +0 -48
  74. package/dist/protocol-validators-VeJxxJ0U.js +0 -2421
  75. package/dist/request-DXXGHko0.js +0 -157
  76. package/dist/session-catalog-home-id-BNwAJ9D7.js +0 -18
  77. package/dist/session-retirement-CcNC3YSY.js +0 -36
  78. package/dist/settled-turn-finalizer-Dc3ApjU4.js +0 -328
  79. package/dist/thread-resume-BE9qNEW0.js +0 -30
  80. package/dist/transport-stdio-DhoGy33Z.js +0 -99
  81. package/dist/upstream-session-fork-DlaHxSLC.js +0 -326
@@ -1,26 +1,11 @@
1
- import { h as readCodexPluginConfig, r as resolveCodexAppServerHomeScope } from "./config-giW8X0QA.js";
2
- import { pt as resolveCodexAppServerPreparedAuthHandoff, vt as isJsonObject } from "./shared-client-DKz23hHY.js";
3
- import { t as runBoundedCodexAppServerTurn } from "./bounded-turn-B7iBUcuP.js";
4
- import { a as createAttributedCodexAssistantMessage } from "./event-projector-assistant-message-C5-Ds8mA.js";
1
+ import { O as readCodexPluginConfig, r as resolveCodexAppServerHomeScope } from "./config-CyapYSji.js";
2
+ import { Kt as resolveCodexAppServerPreparedAuthHandoff, Z as assertCodexPassiveTurnItems } from "./shared-client-CKhX2kFt.js";
3
+ import { t as runBoundedCodexAppServerTurn } from "./bounded-turn-DxGJRYbY.js";
4
+ import { a as createAttributedCodexAssistantMessage } from "./event-projector-assistant-message-B9kp6iGC.js";
5
5
  //#region extensions/codex/src/app-server/isolated-completion.ts
6
- const ISOLATED_PASSIVE_ITEM_TYPES = /* @__PURE__ */ new Set(["agentMessage", "reasoning"]);
7
- function assertIsolatedCompletionItems(items, prompt) {
8
- let promptEchoSeen = false;
9
- for (const item of items) {
10
- if (ISOLATED_PASSIVE_ITEM_TYPES.has(item.type)) continue;
11
- if (item.type === "userMessage" && !promptEchoSeen) {
12
- const content = Array.isArray(item.content) ? item.content : [];
13
- const input = content[0];
14
- if (content.length === 1 && isJsonObject(input) && input.type === "text" && input.text === prompt) {
15
- promptEchoSeen = true;
16
- continue;
17
- }
18
- }
19
- throw new Error(`Codex isolated completion returned unexpected native item: ${item.type}`);
20
- }
21
- }
22
6
  /** Runs prompt-only Codex inference on an ephemeral, ring-zero native thread. */
23
7
  async function runCodexIsolatedCompletion(params, options) {
8
+ params.assertCurrent?.();
24
9
  const authorization = params.authorization;
25
10
  if (authorization.owner !== "harness") throw new Error("Codex native isolated completion requires harness-owned authorization.");
26
11
  const pluginConfig = readCodexPluginConfig(options.pluginConfig);
@@ -35,6 +20,7 @@ async function runCodexIsolatedCompletion(params, options) {
35
20
  subscriptionProfileRequiredError: "Prepared Codex subscription route requires a scoped native OAuth or token profile.",
36
21
  subscriptionProfileUnusableError: `Prepared Codex auth profile "${authorization.plan.forwardedAuthProfileId}" is unusable.`
37
22
  });
23
+ params.assertCurrent?.();
38
24
  const authSelection = authHandoff.preparedAuth ? { preparedAuth: authHandoff.preparedAuth } : { profile: authHandoff.authProfileId };
39
25
  const result = await runBoundedCodexAppServerTurn({
40
26
  config: params.config,
@@ -46,6 +32,7 @@ async function runCodexIsolatedCompletion(params, options) {
46
32
  authRequirement,
47
33
  timeoutMs: params.timeoutMs,
48
34
  signal: params.abortSignal,
35
+ assertCurrent: params.assertCurrent,
49
36
  agentDir: params.agentDir,
50
37
  authProfileStore: authorization.authProfileStore,
51
38
  options,
@@ -60,7 +47,8 @@ async function runCodexIsolatedCompletion(params, options) {
60
47
  isolation: "configured-transport",
61
48
  requireNoExternalCapabilities: true
62
49
  });
63
- assertIsolatedCompletionItems(result.items, params.prompt);
50
+ params.assertCurrent?.();
51
+ assertCodexPassiveTurnItems(result.items, params.prompt, "isolated completion");
64
52
  return { assistant: createAttributedCodexAssistantMessage({
65
53
  api: "openai-chatgpt-responses",
66
54
  provider: params.provider,
@@ -1,9 +1,98 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { access } from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { constants, existsSync, readFileSync, realpathSync } from "node:fs";
5
- import { fileURLToPath } from "node:url";
4
+ import { constants, existsSync, realpathSync } from "node:fs";
6
5
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
6
+ import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
7
+ //#region extensions/codex/src/app-server/launch-args.ts
8
+ const CODEX_VALUE_OPTIONS = /* @__PURE__ */ new Set([
9
+ "-m",
10
+ "--model",
11
+ "--local-provider",
12
+ "-p",
13
+ "--profile",
14
+ "-s",
15
+ "--sandbox",
16
+ "-a",
17
+ "--ask-for-approval",
18
+ "-C",
19
+ "--cd",
20
+ "--add-dir",
21
+ "--remote",
22
+ "--remote-auth-token-env",
23
+ "-c",
24
+ "--config",
25
+ "--enable",
26
+ "--disable",
27
+ "--listen",
28
+ "--code-mode-host",
29
+ "--ws-auth",
30
+ "--ws-token-file",
31
+ "--ws-token-sha256",
32
+ "--ws-shared-secret-file",
33
+ "--ws-issuer",
34
+ "--ws-audience",
35
+ "--ws-max-clock-skew-seconds"
36
+ ]);
37
+ /** One tokenization owner for launch, turn policy, reviewer trust, and private turns. */
38
+ function readCodexArgs(args) {
39
+ const tokens = [];
40
+ let nativeSubcommand = false;
41
+ let end = 0;
42
+ for (const [index, arg] of args.entries()) {
43
+ if (index < end) continue;
44
+ end = index + 1;
45
+ const attached = /^(--[^=]+)=([\s\S]*)$/u.exec(arg) ?? /^(-[cmpisaC])=?([\s\S]+)$/u.exec(arg);
46
+ const name = attached?.[1] ?? arg;
47
+ let value = attached?.[2];
48
+ if (name === "-i" || name === "--image") while (args[end]?.startsWith("-") === false) end += 1;
49
+ else if (!attached && CODEX_VALUE_OPTIONS.has(name)) {
50
+ value = args[end];
51
+ if (value !== void 0) end += 1;
52
+ }
53
+ tokens.push({
54
+ index,
55
+ end,
56
+ name,
57
+ value
58
+ });
59
+ if (name === "app-server") nativeSubcommand = true;
60
+ if (name === "--" && nativeSubcommand) break;
61
+ }
62
+ return tokens;
63
+ }
64
+ function readCodexAppServerConfigOptions(args) {
65
+ return readCodexArgs(args).filter(({ name }) => name === "-c" || name === "--config" || name === "-p" || name === "--profile");
66
+ }
67
+ /** The stdio proxy forwards to an external server; it does not own that runtime. */
68
+ function isCodexAppServerProxyLaunch(args) {
69
+ const tokens = readCodexArgs(args);
70
+ const server = tokens.findLastIndex(({ name }) => name === "app-server");
71
+ return server >= 0 && tokens.slice(server + 1).find(({ name }) => !name.startsWith("-"))?.name === "proxy";
72
+ }
73
+ /** Keeps Codex overrides in one CLI scope without rewriting raw TOML or wrapper prefixes. */
74
+ function normalizeCodexAppServerArgs(rawArgs, enforcedOverride) {
75
+ const tokens = readCodexArgs(rawArgs);
76
+ const subcommandIndex = tokens.findLast(({ name }) => name === "app-server")?.index ?? -1;
77
+ const prefix = subcommandIndex < 0 ? [...rawArgs] : rawArgs.slice(0, subcommandIndex);
78
+ const suffix = [];
79
+ if (subcommandIndex >= 0) for (const token of tokens) {
80
+ if (token.index <= subcommandIndex) continue;
81
+ if (token.name === "--") {
82
+ suffix.push(...rawArgs.slice(token.index));
83
+ break;
84
+ }
85
+ (token.name === "-c" || token.name === "--config" ? prefix : suffix).push(...rawArgs.slice(token.index, token.end));
86
+ }
87
+ if (enforcedOverride && !(prefix.at(-2) === "-c" && prefix.at(-1) === enforcedOverride)) prefix.push("-c", enforcedOverride);
88
+ const normalized = subcommandIndex < 0 ? prefix : [
89
+ ...prefix,
90
+ "app-server",
91
+ ...suffix
92
+ ];
93
+ return normalized.length === rawArgs.length && normalized.every((arg, index) => arg === rawArgs[index]) ? rawArgs : normalized;
94
+ }
95
+ //#endregion
7
96
  //#region extensions/codex/src/app-server/desktop-app-paths.ts
8
97
  /** Shared path candidates for Codex's macOS desktop app bundle. */
9
98
  const MACOS_DESKTOP_CODEX_APP_PATH_CANDIDATES = [{
@@ -46,7 +135,7 @@ function resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath(params = {}
46
135
  * Version and package pins for the managed Codex app-server runtime.
47
136
  */
48
137
  /** Exact Codex app-server version shipped by the OpenClaw Codex bridge. */
49
- const CODEX_APP_SERVER_VERSION = "0.150.1";
138
+ const CODEX_APP_SERVER_VERSION = "0.153.4";
50
139
  /** Inclusive runtime compatibility floor for external app-server binaries. */
51
140
  const MIN_SUPPORTED_CODEX_APP_SERVER_VERSION = "0.149.0";
52
141
  /** npm package name for the managed Codex app-server binary. */
@@ -57,18 +146,19 @@ const MANAGED_CODEX_APP_SERVER_PACKAGE = "@openai/codex";
57
146
  * Resolves the managed Codex app-server binary shipped with or installed beside
58
147
  * the Codex plugin before stdio startup.
59
148
  */
60
- const CODEX_PLUGIN_ROOT = resolveDefaultCodexPluginRoot(path.dirname(fileURLToPath(import.meta.url)));
61
- let registeredCodexPluginRoot;
149
+ const registeredCodexPlugin = resolveGlobalSingleton(Symbol.for("openclaw.codexManagedPluginRoot"), () => ({}));
62
150
  /** Records the process-stable plugin root prepared by OpenClaw's plugin loader. */
63
151
  function setManagedCodexPluginRoot(pluginRoot) {
64
- registeredCodexPluginRoot = pluginRoot;
152
+ registeredCodexPlugin.root = pluginRoot;
65
153
  }
66
154
  /** Rewrites managed stdio start options to point at an executable Codex binary path. */
67
155
  async function resolveManagedCodexAppServerStartOptions(startOptions, options = {}) {
68
156
  if (startOptions.transport !== "stdio" || startOptions.commandSource !== "managed") return startOptions;
157
+ const pluginRoot = options.pluginRoot ?? registeredCodexPlugin.root;
158
+ if (!pluginRoot) throw new Error("Codex plugin root is unavailable. Load the Codex plugin before starting its managed app-server.");
69
159
  const platform = options.platform ?? process.platform;
70
160
  const commandPaths = await findManagedCodexAppServerCommandPaths({
71
- candidateCommandPaths: resolveManagedCodexAppServerCommandCandidates(options.pluginRoot ?? registeredCodexPluginRoot ?? CODEX_PLUGIN_ROOT, platform, startOptions.managedCommandOrder ?? "package-first"),
161
+ candidateCommandPaths: resolveManagedCodexAppServerCommandCandidates(pluginRoot, platform, startOptions.managedCommandOrder ?? "package-first"),
72
162
  pathExists: options.pathExists ?? commandPathExists,
73
163
  platform
74
164
  });
@@ -91,12 +181,16 @@ function resolveManagedCodexNativeCommand(command, options = {}) {
91
181
  if (!packageRoot) return;
92
182
  const resolvePackageJson = options.resolvePackageJson ?? resolvePackageJsonFromRoot;
93
183
  const pathExists = options.pathExists ?? existsSync;
94
- for (const packageName of [target.packageName, MANAGED_CODEX_APP_SERVER_PACKAGE]) {
95
- const packageJsonPath = resolvePackageJson(packageName, packageRoot);
96
- if (!packageJsonPath) continue;
97
- const candidate = path.join(path.dirname(packageJsonPath), "vendor", target.triple, "bin", platform === "win32" ? "codex.exe" : "codex");
98
- if (pathExists(candidate)) return candidate;
99
- }
184
+ const packageJsonPath = resolvePackageJson(target.packageName, packageRoot) ?? resolvePackageJson("@openai/codex", packageRoot);
185
+ if (!packageJsonPath) return;
186
+ const candidate = path.join(path.dirname(packageJsonPath), "vendor", target.triple, "bin", platform === "win32" ? "codex.exe" : "codex");
187
+ return pathExists(candidate) ? candidate : void 0;
188
+ }
189
+ /** Recognizes only the official npm entrypoint, not arbitrary configured wrappers. */
190
+ function resolvePackagedCodexNativeCommand(entrypoint) {
191
+ const packageRoot = path.dirname(path.dirname(entrypoint));
192
+ if (path.basename(packageRoot) !== "codex" || path.basename(path.dirname(packageRoot)) !== "@openai" || path.relative(packageRoot, entrypoint) !== path.join("bin", "codex.js")) return;
193
+ return resolveManagedCodexNativeCommand(entrypoint);
100
194
  }
101
195
  /** Returns whether a command is one of the standard macOS desktop app executables. */
102
196
  function isManagedCodexDesktopCommand(command, platform = process.platform) {
@@ -147,82 +241,25 @@ function resolveCodexNativeTarget(platform, arch) {
147
241
  }
148
242
  function resolvePackageJsonFromRoot(packageName, root) {
149
243
  try {
150
- return createRequire(path.join(root, "package.json")).resolve(`${packageName}/package.json`);
244
+ const manifestPath = realpathSync(path.join(root, "package.json"));
245
+ return createRequire(manifestPath).resolve(`${packageName}/package.json`);
151
246
  } catch {
152
247
  return;
153
248
  }
154
249
  }
155
250
  function resolveManagedCodexAppServerCommandCandidates(pluginRoot, platform, managedCommandOrder) {
156
- const pathApi = pathForPlatform(platform);
157
- const commandName = platform === "win32" ? "codex.cmd" : "codex";
158
- const roots = resolveManagedCodexAppServerCandidateRoots(pluginRoot, platform);
159
- const packageCommandPaths = [...roots.map((root) => pathApi.join(root, "node_modules", ".bin", commandName)), ...resolveManagedCodexPackageBinCandidates(roots, platform)];
160
- const desktopCommandPaths = resolveDesktopCodexAppServerCommandCandidates(platform);
161
- const orderedCommandPaths = managedCommandOrder === "desktop-first" ? [...desktopCommandPaths, ...packageCommandPaths] : [...packageCommandPaths, ...desktopCommandPaths];
162
- return [...new Set(orderedCommandPaths)];
163
- }
164
- function resolveDesktopCodexAppServerCommandCandidates(platform) {
165
- return resolveMacOSDesktopCodexAppServerCommandCandidates(platform);
166
- }
167
- function resolveDefaultCodexPluginRoot(moduleDir) {
168
- const moduleBaseName = path.basename(moduleDir);
169
- if (moduleBaseName === "dist" || moduleBaseName === "dist-runtime") return path.dirname(moduleDir);
170
- return path.resolve(moduleDir, "..", "..");
171
- }
172
- function resolveManagedCodexAppServerCandidateRoots(pluginRoot, platform) {
173
- const pathApi = pathForPlatform(platform);
174
- const directRoots = [
175
- pluginRoot,
176
- pathApi.dirname(pluginRoot),
177
- pathApi.dirname(pathApi.dirname(pluginRoot)),
178
- isDistExtensionRoot(pluginRoot, platform) ? pathApi.dirname(pathApi.dirname(pathApi.dirname(pluginRoot))) : null
179
- ].filter((root) => Boolean(root));
180
- return [.../* @__PURE__ */ new Set([...directRoots, ...resolveNearestNodeModulesProjectRoots(directRoots, platform)])];
181
- }
182
- function resolveNearestNodeModulesProjectRoots(roots, platform) {
183
- const pathApi = pathForPlatform(platform);
184
- const projectRoots = [];
185
- for (const root of roots) {
186
- let current = pathApi.resolve(root);
187
- while (true) {
188
- if (pathApi.basename(current) === "node_modules") {
189
- projectRoots.push(pathApi.dirname(current));
190
- break;
191
- }
192
- const parent = pathApi.dirname(current);
193
- if (parent === current) break;
194
- current = parent;
195
- }
196
- }
197
- return projectRoots;
198
- }
199
- function resolveManagedCodexPackageBinCandidates(roots, platform) {
200
- if (platform === "win32") return [];
201
- const candidates = [];
202
- for (const root of roots) {
203
- const candidate = resolveManagedCodexPackageBinCandidate(root);
204
- if (candidate) candidates.push(candidate);
205
- }
206
- return candidates;
251
+ const packageCommand = resolveManagedCodexPackageEntrypoint(pluginRoot);
252
+ const packageCommandPaths = packageCommand ? [packageCommand] : [];
253
+ const desktopCommandPaths = resolveMacOSDesktopCodexAppServerCommandCandidates(platform);
254
+ return managedCommandOrder === "desktop-first" ? [...desktopCommandPaths, ...packageCommandPaths] : [...packageCommandPaths, ...desktopCommandPaths];
207
255
  }
208
- function resolveManagedCodexPackageBinCandidate(root) {
256
+ function resolveManagedCodexPackageEntrypoint(pluginRoot) {
209
257
  try {
210
- const packageJsonPath = createRequire(path.join(root, "package.json")).resolve(`${MANAGED_CODEX_APP_SERVER_PACKAGE}/package.json`);
211
- const packageRoot = path.dirname(packageJsonPath);
212
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
213
- const packageBin = packageJson.bin && typeof packageJson.bin === "object" ? packageJson.bin : void 0;
214
- const binPath = typeof packageJson.bin === "string" ? packageJson.bin : typeof packageBin?.codex === "string" ? packageBin.codex : null;
215
- return binPath ? path.resolve(packageRoot, binPath) : null;
258
+ return createRequire(path.join(pluginRoot, "package.json")).resolve(`${MANAGED_CODEX_APP_SERVER_PACKAGE}/bin/codex.js`);
216
259
  } catch {
217
- return null;
260
+ return;
218
261
  }
219
262
  }
220
- function isDistExtensionRoot(pluginRoot, platform) {
221
- const pathApi = pathForPlatform(platform);
222
- const extensionsDir = pathApi.dirname(pluginRoot);
223
- const distDir = pathApi.dirname(extensionsDir);
224
- return pathApi.basename(extensionsDir) === "extensions" && (pathApi.basename(distDir) === "dist" || pathApi.basename(distDir) === "dist-runtime");
225
- }
226
263
  function pathForPlatform(platform) {
227
264
  return platform === "win32" ? path.win32 : path.posix;
228
265
  }
@@ -245,4 +282,4 @@ async function commandPathExists(filePath, platform) {
245
282
  }
246
283
  }
247
284
  //#endregion
248
- export { CODEX_APP_SERVER_VERSION as a, resolveMacOSDesktopCodexAppPathCandidates as c, setManagedCodexPluginRoot as i, resolveMacOSDesktopCodexBundledMarketplaceCandidates as l, resolveManagedCodexAppServerStartOptions as n, MIN_SUPPORTED_CODEX_APP_SERVER_VERSION as o, resolveManagedCodexNativeCommand as r, resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath as s, isManagedCodexDesktopCommand as t, resolveMacOSDesktopCodexComputerUseServiceAppCandidates as u };
285
+ export { setManagedCodexPluginRoot as a, resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath as c, resolveMacOSDesktopCodexComputerUseServiceAppCandidates as d, isCodexAppServerProxyLaunch as f, resolvePackagedCodexNativeCommand as i, resolveMacOSDesktopCodexAppPathCandidates as l, readCodexAppServerConfigOptions as m, resolveManagedCodexAppServerStartOptions as n, CODEX_APP_SERVER_VERSION as o, normalizeCodexAppServerArgs as p, resolveManagedCodexNativeCommand as r, MIN_SUPPORTED_CODEX_APP_SERVER_VERSION as s, isManagedCodexDesktopCommand as t, resolveMacOSDesktopCodexBundledMarketplaceCandidates as u };
@@ -1,4 +1,4 @@
1
- import { t as runBoundedCodexAppServerTurn } from "./bounded-turn-B7iBUcuP.js";
1
+ import { t as runBoundedCodexAppServerTurn } from "./bounded-turn-DxGJRYbY.js";
2
2
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
4
4
  //#region extensions/codex/media-understanding-provider.ts
@@ -0,0 +1,101 @@
1
+ import { r as buildCodexRuntimeModelParams } from "./harness-Czh2Sdoc.js";
2
+ import { B as isJsonObject, O as readCodexPluginConfig, i as resolveCodexAppServerRuntimeOptions } from "./config-CyapYSji.js";
3
+ import { r as captureSharedCodexAppServerCatalogLifetime } from "./shared-client-CKhX2kFt.js";
4
+ import { t as listAllCodexAppServerModels } from "./models-CcrgSMQR.js";
5
+ import { o as withCodexAppServerJsonClient } from "./request-C8H22rPi.js";
6
+ //#region extensions/codex/src/app-server/model-catalog.ts
7
+ const DEFAULT_MODEL_DISCOVERY_TIMEOUT_MS = 2500;
8
+ const INPUT_TYPES = /* @__PURE__ */ new Set([
9
+ "text",
10
+ "image",
11
+ "audio",
12
+ "video",
13
+ "document"
14
+ ]);
15
+ function isModelInputType(value) {
16
+ return INPUT_TYPES.has(value);
17
+ }
18
+ function codexAppServerModelsToCatalogEntries(models, runtime) {
19
+ return models.map((model, providerOrder) => {
20
+ const input = model.inputModalities.filter(isModelInputType);
21
+ const runtimeParams = buildCodexRuntimeModelParams(model.id, model.model);
22
+ return {
23
+ provider: "openai",
24
+ id: model.id,
25
+ name: model.displayName ?? model.id,
26
+ providerOrder,
27
+ nativeRuntime: runtime,
28
+ reasoning: model.supportedReasoningEfforts.length > 0,
29
+ ...input.length > 0 ? { input } : {},
30
+ ...runtimeParams ? { params: runtimeParams } : {},
31
+ compat: {
32
+ supportsReasoningEffort: model.supportedReasoningEfforts.length > 0,
33
+ supportedReasoningEfforts: model.supportedReasoningEfforts
34
+ }
35
+ };
36
+ });
37
+ }
38
+ /** One harness registration owns its observations; none travel with worker snapshots. */
39
+ function createCodexAppServerModelCatalog(runtime) {
40
+ const scopes = /* @__PURE__ */ new WeakMap();
41
+ const scopeKey = (params) => JSON.stringify([
42
+ params.agentId,
43
+ params.agentDir,
44
+ params.workspaceDir
45
+ ]);
46
+ let disposed = false;
47
+ return {
48
+ dispose() {
49
+ disposed = true;
50
+ },
51
+ read(params, pluginConfig) {
52
+ const observation = scopes.get(params.config)?.get(scopeKey(params));
53
+ return !disposed && params.provider === "openai" && observation !== void 0 && observation.pluginConfig === pluginConfig && observation.models?.has(params.modelId) && observation.accountType && observation.isCurrent?.() ? { accountType: observation.accountType } : void 0;
54
+ },
55
+ async load(params, pluginConfig) {
56
+ if (disposed) return [];
57
+ let observations = scopes.get(params.config);
58
+ if (!observations) {
59
+ observations = /* @__PURE__ */ new Map();
60
+ scopes.set(params.config, observations);
61
+ }
62
+ const key = scopeKey(params);
63
+ const observation = { pluginConfig };
64
+ observations.set(key, observation);
65
+ const discovery = readCodexPluginConfig(pluginConfig).discovery;
66
+ if (discovery?.enabled === false) return [];
67
+ const { start } = resolveCodexAppServerRuntimeOptions({ pluginConfig });
68
+ const timeoutMs = discovery?.timeoutMs ?? DEFAULT_MODEL_DISCOVERY_TIMEOUT_MS;
69
+ const result = await withCodexAppServerJsonClient({
70
+ startOptions: start,
71
+ config: params.config,
72
+ agentDir: params.agentDir,
73
+ timeoutMs
74
+ }, async (request, client) => {
75
+ const isCurrent = captureSharedCodexAppServerCatalogLifetime(client);
76
+ const models = (await listAllCodexAppServerModels({
77
+ request,
78
+ limit: 100,
79
+ includeHidden: true
80
+ })).models.filter((model) => !model.hidden || params.configuredModelRefs?.some((ref) => ref.provider === "openai" && ref.model === model.id));
81
+ const account = await request({
82
+ method: "account/read",
83
+ requestParams: { refreshToken: false }
84
+ });
85
+ const observedType = isJsonObject(account.account) ? account.account.type : void 0;
86
+ return {
87
+ models,
88
+ isCurrent,
89
+ accountType: account.requiresOpenaiAuth === true ? observedType === "apiKey" || observedType === "chatgpt" ? observedType : void 0 : void 0
90
+ };
91
+ });
92
+ if (disposed || observations.get(key) !== observation || !result.isCurrent()) return [];
93
+ observation.models = new Set(result.models.map((model) => model.id));
94
+ observation.accountType = result.accountType;
95
+ observation.isCurrent = result.isCurrent;
96
+ return codexAppServerModelsToCatalogEntries(result.models, runtime);
97
+ }
98
+ };
99
+ }
100
+ //#endregion
101
+ export { createCodexAppServerModelCatalog };
@@ -1,4 +1,4 @@
1
- import { t as assertCodexModelListResponse } from "./protocol-validators-VeJxxJ0U.js";
1
+ import { X as assertCodexModelListResponse } from "./shared-client-CKhX2kFt.js";
2
2
  import { normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  //#region extensions/codex/src/app-server/models.ts
4
4
  /**
@@ -7,22 +7,18 @@ import { normalizeOptionalString, uniqueStrings } from "openclaw/plugin-sdk/stri
7
7
  */
8
8
  /** Lists one Codex app-server model page using the configured auth/client options. */
9
9
  async function listCodexAppServerModels(options = {}) {
10
- return await withCodexAppServerModelClient(options, async ({ client, timeoutMs }) => requestModelListPage(client, {
11
- ...options,
12
- timeoutMs
13
- }));
10
+ return await withCodexAppServerModelRequest(options, async (request) => requestModelListPage(request, options));
14
11
  }
15
12
  /** Walks Codex app-server model pages until exhaustion or the max-page guard. */
16
13
  async function listAllCodexAppServerModels(options = {}) {
17
14
  const maxPages = normalizeMaxPages(options.maxPages);
18
- return await withCodexAppServerModelClient(options, async ({ client, timeoutMs }) => {
15
+ return await withCodexAppServerModelRequest(options, async (request) => {
19
16
  const models = [];
20
17
  let cursor = options.cursor;
21
18
  let nextCursor;
22
19
  for (let page = 0; page < maxPages; page += 1) {
23
- const result = await requestModelListPage(client, {
20
+ const result = await requestModelListPage(request, {
24
21
  ...options,
25
- timeoutMs,
26
22
  cursor
27
23
  });
28
24
  models.push(...result.models);
@@ -37,18 +33,13 @@ async function listAllCodexAppServerModels(options = {}) {
37
33
  };
38
34
  });
39
35
  }
40
- async function withCodexAppServerModelClient(options, run) {
36
+ async function withCodexAppServerModelRequest(options, run) {
37
+ if (options.request) return await run(options.request);
41
38
  const timeoutMs = options.timeoutMs ?? 2500;
42
39
  const useSharedClient = options.sharedClient !== false;
43
- const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-DKz23hHY.js").then((n) => n.y);
44
- const client = useSharedClient ? await getLeasedSharedCodexAppServerClient({
45
- startOptions: options.startOptions,
46
- timeoutMs,
47
- authProfileId: options.authProfileId,
48
- authRequirement: options.authRequirement,
49
- agentDir: options.agentDir,
50
- config: options.config
51
- }) : await createIsolatedCodexAppServerClient({
40
+ const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-CKhX2kFt.js").then((n) => n.x);
41
+ const { requestCodexAppServerClientJson } = await import("./request-C8H22rPi.js").then((n) => n.a);
42
+ const client = await (useSharedClient ? getLeasedSharedCodexAppServerClient : createIsolatedCodexAppServerClient)({
52
43
  startOptions: options.startOptions,
53
44
  timeoutMs,
54
45
  authProfileId: options.authProfileId,
@@ -57,21 +48,26 @@ async function withCodexAppServerModelClient(options, run) {
57
48
  config: options.config
58
49
  });
59
50
  try {
60
- return await run({
51
+ return await run((request) => requestCodexAppServerClientJson({
52
+ ...request,
61
53
  client,
62
- timeoutMs
63
- });
54
+ timeoutMs,
55
+ config: options.config
56
+ }));
64
57
  } finally {
65
58
  if (useSharedClient) releaseLeasedSharedCodexAppServerClient(client);
66
- else client.close();
59
+ else await client.closeAndWait();
67
60
  }
68
61
  }
69
- async function requestModelListPage(client, options) {
70
- return readModelListResult(await client.request("model/list", {
71
- limit: options.limit ?? null,
72
- cursor: options.cursor ?? null,
73
- includeHidden: options.includeHidden ?? null
74
- }, { timeoutMs: options.timeoutMs }));
62
+ async function requestModelListPage(request, options) {
63
+ return readModelListResult(await request({
64
+ method: "model/list",
65
+ requestParams: {
66
+ limit: options.limit ?? null,
67
+ cursor: options.cursor ?? null,
68
+ includeHidden: options.includeHidden ?? null
69
+ }
70
+ }));
75
71
  }
76
72
  /** Parses a raw Codex app-server model/list response into OpenClaw's normalized shape. */
77
73
  function readModelListResult(value) {
@@ -101,7 +97,8 @@ function readCodexModel(value) {
101
97
  };
102
98
  }
103
99
  function readReasoningEfforts(value) {
104
- return uniqueStrings(value.map((entry) => normalizeOptionalString(entry.reasoningEffort)).filter((entry) => entry !== void 0));
100
+ const efforts = value.map((entry) => normalizeOptionalString(entry.reasoningEffort)).filter((entry) => entry !== void 0);
101
+ return uniqueStrings(efforts);
105
102
  }
106
103
  function normalizeMaxPages(value) {
107
104
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : 20;