@openclaw/codex 2026.9.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 (67) hide show
  1. package/dist/api.js +6 -6
  2. package/dist/{attempt-client-cleanup-DYHcRQAa.js → attempt-client-cleanup-Bp1ZOnk2.js} +76 -32
  3. package/dist/{attempt-context-DmQUNWwT.js → attempt-context-CSazkWns.js} +6 -6
  4. package/dist/{bounded-turn-wzJrwKKe.js → bounded-turn-DxGJRYbY.js} +46 -45
  5. package/dist/{capabilities-dIjNVCYH.js → capabilities-B1mgvpP8.js} +2 -1
  6. package/dist/cli-metadata.js +1 -1
  7. package/dist/{command-formatters-CLHhEB1Q.js → command-formatters-DSbGMXA0.js} +2 -2
  8. package/dist/{command-handlers-CTGb2csu.js → command-handlers-DOJvGv6-.js} +146 -74
  9. package/dist/{compact-_t0HQrUS.js → compact-Y_xBqrHN.js} +83 -48
  10. package/dist/{config-BhmfC1s6.js → config-CyapYSji.js} +47 -105
  11. package/dist/config-utils-C57JiJrU.js +69 -0
  12. package/dist/doctor-contract-api.js +4 -5
  13. package/dist/{dynamic-tools-BU9tmlYm.js → dynamic-tools-BwpvTxaX.js} +678 -638
  14. package/dist/{effective-mcp-catalog-DzYBW4h1.js → effective-mcp-catalog-CY9Jn4bA.js} +4 -3
  15. package/dist/{event-projector-assistant-message-DHRFXKbS.js → event-projector-assistant-message-B9kp6iGC.js} +11 -2
  16. package/dist/{event-projector-usage-C5mcrGjp.js → event-projector-usage-ZqEVbAEY.js} +30 -13
  17. package/dist/{harness-DXVZ5II5.js → harness-Czh2Sdoc.js} +36 -13
  18. package/dist/harness.js +1 -1
  19. package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
  20. package/dist/index.js +68 -84
  21. package/dist/{isolated-completion-kg9kv4iH.js → isolated-completion-CRh-51AK.js} +9 -21
  22. package/dist/{managed-binary-4-Vjz5GH.js → managed-binary-DcpnJF9x.js} +105 -73
  23. package/dist/media-understanding-provider.js +1 -1
  24. package/dist/{model-catalog-CUM68Hkl.js → model-catalog-DT5vo6qo.js} +5 -5
  25. package/dist/{models-sYnEc0gd.js → models-CcrgSMQR.js} +4 -4
  26. package/dist/{native-subagent-monitor-CnH147jH.js → native-subagent-monitor-B3bvQGcg.js} +12 -11
  27. package/dist/{node-exec-server.runtime-CstNHCmC.js → node-exec-server.runtime-nfbUOtUB.js} +3 -3
  28. package/dist/{plugin-approval-roundtrip-CNe-Xrjx.js → plugin-approval-roundtrip-aQVdyL5g.js} +1 -1
  29. package/dist/{plugin-marketplace-discovery-CfFlKqDl.js → plugin-marketplace-discovery-B7gHXJ3d.js} +35 -22
  30. package/dist/{plugin-metadata-cache-BFrPhb2c.js → plugin-metadata-cache-BwCLTY_U.js} +5 -5
  31. package/dist/{provider-capabilities-DW5p4k9w.js → provider-capabilities-BpG9Ltc5.js} +2 -2
  32. package/dist/{rate-limits-CawQJfUS.js → rate-limits-Fx_l4eNa.js} +1 -1
  33. package/dist/{request-DYAI5FQE.js → request-C8H22rPi.js} +2 -2
  34. package/dist/{run-attempt-D1hJO4fX.js → run-attempt-BzthFQSM.js} +977 -723
  35. package/dist/{runtime-artifact-C3jVimFn.js → runtime-artifact-Bh_gf6-t.js} +3 -3
  36. package/dist/{session-binding-BHuTCRZQ.js → session-binding-4Ki04sW-.js} +94 -282
  37. package/dist/session-binding-record-CyaXZvTe.js +270 -0
  38. package/dist/{session-catalog-yyvTWFOw.js → session-catalog-B47uwekb.js} +266 -114
  39. package/dist/{session-cli-CmFEXMAM.js → session-cli-BjLhpmS1.js} +1 -1
  40. package/dist/session-history-DWmMqiqW.js +93 -0
  41. package/dist/session-history-read-LHldwvyh.js +36 -0
  42. package/dist/session-history-worker-runtime.js +48 -0
  43. package/dist/{settled-turn-context-D3SNWtUn.js → session-history.worker-zZVcx0ME.js} +30 -31
  44. package/dist/session-history.worker.js +2 -0
  45. package/dist/{session-initialization-BeWzjGiR.js → session-initialization-BCFVnLL4.js} +2 -1
  46. package/dist/{session-permission-policy-DeWVTCMj.js → session-permission-policy-BaueHmSj.js} +1 -1
  47. package/dist/{session-retirement-BujDjXVF.js → session-retirement-DNdmYdFc.js} +7 -7
  48. package/dist/{session-upstream-marker-C351-5Qw.js → session-upstream-marker-DReTpGz6.js} +4 -3
  49. package/dist/settled-turn-context-BOM3Y1pl.js +45 -0
  50. package/dist/{settled-turn-finalizer-BVJx4yoc.js → settled-turn-finalizer-BI-b1sry.js} +53 -42
  51. package/dist/{shared-client-DxcfF9KX.js → shared-client-CKhX2kFt.js} +279 -268
  52. package/dist/{side-question-BTZAII4l.js → side-question-B6DWAw1A.js} +85 -36
  53. package/dist/{thread-lifecycle-DAcEJ_Om.js → thread-lifecycle-DPK30jad.js} +382 -388
  54. package/dist/{thread-ownership-zGokd8i1.js → thread-ownership-CbucAmmp.js} +5 -5
  55. package/dist/thread-policy-CTalhWFy.js +105 -0
  56. package/dist/{thread-resume-C7pyVKeW.js → thread-resume-BLgqkUc1.js} +7 -7
  57. package/dist/{transcript-mirror-DTUxFWa_.js → transcript-mirror-_njEB84z.js} +67 -125
  58. package/dist/transcript-mirror-attestation-Byl34PC-.js +76 -0
  59. package/dist/{transport-stdio-CyPldczm.js → transport-stdio-CzTngV0j.js} +10 -8
  60. package/dist/{upstream-session-fork-CYlBIGVt.js → upstream-session-fork-1fwbNKzQ.js} +85 -165
  61. package/dist/{usage-Bj-rrzkR.js → usage-i9fv5-4m.js} +3 -3
  62. package/dist/{web-search-provider.runtime-D2FWSK4w.js → web-search-provider.runtime-DKQn67A7.js} +3 -3
  63. package/package.json +6 -6
  64. package/dist/binding-connection-E6uDsPlx.js +0 -45
  65. package/dist/launch-args-RXQwn8zV.js +0 -90
  66. package/dist/session-history-C5J1AKzG.js +0 -87
  67. package/dist/thread-policy-g4KbJPzp.js +0 -54
@@ -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.152.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
  });
@@ -158,76 +248,18 @@ function resolvePackageJsonFromRoot(packageName, root) {
158
248
  }
159
249
  }
160
250
  function resolveManagedCodexAppServerCommandCandidates(pluginRoot, platform, managedCommandOrder) {
161
- const pathApi = pathForPlatform(platform);
162
- const commandName = platform === "win32" ? "codex.cmd" : "codex";
163
- const roots = resolveManagedCodexAppServerCandidateRoots(pluginRoot, platform);
164
- const packageCommandPaths = [...roots.map((root) => pathApi.join(root, "node_modules", ".bin", commandName)), ...resolveManagedCodexPackageBinCandidates(roots, platform)];
165
- const desktopCommandPaths = resolveDesktopCodexAppServerCommandCandidates(platform);
166
- const orderedCommandPaths = managedCommandOrder === "desktop-first" ? [...desktopCommandPaths, ...packageCommandPaths] : [...packageCommandPaths, ...desktopCommandPaths];
167
- return [...new Set(orderedCommandPaths)];
168
- }
169
- function resolveDesktopCodexAppServerCommandCandidates(platform) {
170
- return resolveMacOSDesktopCodexAppServerCommandCandidates(platform);
171
- }
172
- function resolveDefaultCodexPluginRoot(moduleDir) {
173
- const moduleBaseName = path.basename(moduleDir);
174
- if (moduleBaseName === "dist" || moduleBaseName === "dist-runtime") return path.dirname(moduleDir);
175
- return path.resolve(moduleDir, "..", "..");
176
- }
177
- function resolveManagedCodexAppServerCandidateRoots(pluginRoot, platform) {
178
- const pathApi = pathForPlatform(platform);
179
- const directRoots = [
180
- pluginRoot,
181
- pathApi.dirname(pluginRoot),
182
- pathApi.dirname(pathApi.dirname(pluginRoot)),
183
- isDistExtensionRoot(pluginRoot, platform) ? pathApi.dirname(pathApi.dirname(pathApi.dirname(pluginRoot))) : null
184
- ].filter((root) => Boolean(root));
185
- return [.../* @__PURE__ */ new Set([...directRoots, ...resolveNearestNodeModulesProjectRoots(directRoots, platform)])];
186
- }
187
- function resolveNearestNodeModulesProjectRoots(roots, platform) {
188
- const pathApi = pathForPlatform(platform);
189
- const projectRoots = [];
190
- for (const root of roots) {
191
- let current = pathApi.resolve(root);
192
- while (true) {
193
- if (pathApi.basename(current) === "node_modules") {
194
- projectRoots.push(pathApi.dirname(current));
195
- break;
196
- }
197
- const parent = pathApi.dirname(current);
198
- if (parent === current) break;
199
- current = parent;
200
- }
201
- }
202
- return projectRoots;
203
- }
204
- function resolveManagedCodexPackageBinCandidates(roots, platform) {
205
- if (platform === "win32") return [];
206
- const candidates = [];
207
- for (const root of roots) {
208
- const candidate = resolveManagedCodexPackageBinCandidate(root);
209
- if (candidate) candidates.push(candidate);
210
- }
211
- 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];
212
255
  }
213
- function resolveManagedCodexPackageBinCandidate(root) {
256
+ function resolveManagedCodexPackageEntrypoint(pluginRoot) {
214
257
  try {
215
- const packageJsonPath = createRequire(path.join(root, "package.json")).resolve(`${MANAGED_CODEX_APP_SERVER_PACKAGE}/package.json`);
216
- const packageRoot = path.dirname(packageJsonPath);
217
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
218
- const packageBin = packageJson.bin && typeof packageJson.bin === "object" ? packageJson.bin : void 0;
219
- const binPath = typeof packageJson.bin === "string" ? packageJson.bin : typeof packageBin?.codex === "string" ? packageBin.codex : null;
220
- return binPath ? path.resolve(packageRoot, binPath) : null;
258
+ return createRequire(path.join(pluginRoot, "package.json")).resolve(`${MANAGED_CODEX_APP_SERVER_PACKAGE}/bin/codex.js`);
221
259
  } catch {
222
- return null;
260
+ return;
223
261
  }
224
262
  }
225
- function isDistExtensionRoot(pluginRoot, platform) {
226
- const pathApi = pathForPlatform(platform);
227
- const extensionsDir = pathApi.dirname(pluginRoot);
228
- const distDir = pathApi.dirname(extensionsDir);
229
- return pathApi.basename(extensionsDir) === "extensions" && (pathApi.basename(distDir) === "dist" || pathApi.basename(distDir) === "dist-runtime");
230
- }
231
263
  function pathForPlatform(platform) {
232
264
  return platform === "win32" ? path.win32 : path.posix;
233
265
  }
@@ -250,4 +282,4 @@ async function commandPathExists(filePath, platform) {
250
282
  }
251
283
  }
252
284
  //#endregion
253
- export { setManagedCodexPluginRoot as a, resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath as c, resolveMacOSDesktopCodexComputerUseServiceAppCandidates as d, resolvePackagedCodexNativeCommand as i, resolveMacOSDesktopCodexAppPathCandidates as l, resolveManagedCodexAppServerStartOptions as n, CODEX_APP_SERVER_VERSION as o, resolveManagedCodexNativeCommand as r, MIN_SUPPORTED_CODEX_APP_SERVER_VERSION as s, isManagedCodexDesktopCommand as t, resolveMacOSDesktopCodexBundledMarketplaceCandidates 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-wzJrwKKe.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
@@ -1,8 +1,8 @@
1
- import { r as buildCodexRuntimeModelParams } from "./harness-DXVZ5II5.js";
2
- import { $t as isJsonObject, r as captureSharedCodexAppServerCatalogLifetime } from "./shared-client-DxcfF9KX.js";
3
- import { E as readCodexPluginConfig, i as resolveCodexAppServerRuntimeOptions } from "./config-BhmfC1s6.js";
4
- import { t as listAllCodexAppServerModels } from "./models-sYnEc0gd.js";
5
- import { o as withCodexAppServerJsonClient } from "./request-DYAI5FQE.js";
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
6
  //#region extensions/codex/src/app-server/model-catalog.ts
7
7
  const DEFAULT_MODEL_DISCOVERY_TIMEOUT_MS = 2500;
8
8
  const INPUT_TYPES = /* @__PURE__ */ new Set([
@@ -1,4 +1,4 @@
1
- import { Y as assertCodexModelListResponse } from "./shared-client-DxcfF9KX.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
  /**
@@ -37,8 +37,8 @@ async function withCodexAppServerModelRequest(options, run) {
37
37
  if (options.request) return await run(options.request);
38
38
  const timeoutMs = options.timeoutMs ?? 2500;
39
39
  const useSharedClient = options.sharedClient !== false;
40
- const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, releaseLeasedSharedCodexAppServerClient } = await import("./shared-client-DxcfF9KX.js").then((n) => n.x);
41
- const { requestCodexAppServerClientJson } = await import("./request-DYAI5FQE.js").then((n) => n.a);
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
42
  const client = await (useSharedClient ? getLeasedSharedCodexAppServerClient : createIsolatedCodexAppServerClient)({
43
43
  startOptions: options.startOptions,
44
44
  timeoutMs,
@@ -56,7 +56,7 @@ async function withCodexAppServerModelRequest(options, run) {
56
56
  }));
57
57
  } finally {
58
58
  if (useSharedClient) releaseLeasedSharedCodexAppServerClient(client);
59
- else client.close();
59
+ else await client.closeAndWait();
60
60
  }
61
61
  }
62
62
  async function requestModelListPage(request, options) {
@@ -1,12 +1,13 @@
1
- import { $t as isJsonObject, At as retainCodexAppServerLiveThread, kt as releaseCodexAppServerLiveThread, xt as claimCodexAppServerLiveThread } from "./shared-client-DxcfF9KX.js";
2
- import { A as shouldRecordNativeToolTranscript, C as isSideEffectingNativeToolItem, D as itemTitle, E as itemStatus, F as readHookOutputEntries, I as readItem, N as normalizeOptionalString$1, R as readNonEmptyString, S as isNonSuccessItemStatus, T as itemName, V as readNullableString$1, j as shouldSynthesizeToolProgressForItem, w as itemKind, x as isMutatingNativeToolItem, y as auditNativeToolTerminalStatus, z as readNonEmptyStringArray } from "./attempt-client-cleanup-DYHcRQAa.js";
1
+ import { B as isJsonObject } from "./config-CyapYSji.js";
2
+ import { Ct as claimCodexAppServerLiveThread, Mt as retainCodexAppServerLiveThread, jt as releaseCodexAppServerLiveThread } from "./shared-client-CKhX2kFt.js";
3
+ import { A as shouldRecordNativeToolTranscript, B as readNonEmptyStringArray, C as isSideEffectingNativeToolItem, D as itemTitle, E as itemStatus, H as readNullableString$1, I as readHookOutputEntries, L as readItem, N as normalizeOptionalString$1, S as isNonSuccessItemStatus, T as itemName, j as shouldSynthesizeToolProgressForItem, w as itemKind, x as isMutatingNativeToolItem, y as auditNativeToolTerminalStatus, z as readNonEmptyString } from "./attempt-client-cleanup-Bp1ZOnk2.js";
3
4
  import { t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
5
+ import { t as readCodexMirroredSessionHistoryMessages } from "./session-history-DWmMqiqW.js";
4
6
  import { t as resolveCodexLocalRuntimeAttribution } from "./local-runtime-attribution-B_2mnqhb.js";
5
- import { n as codexApprovalTimeoutText } from "./plugin-approval-roundtrip-CNe-Xrjx.js";
6
- import { n as readCodexMirroredSessionHistoryMessages } from "./session-history-C5J1AKzG.js";
7
+ import { n as codexApprovalTimeoutText } from "./plugin-approval-roundtrip-aQVdyL5g.js";
7
8
  import { asFiniteNumber, asNonArrayRecord, normalizeOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
8
- import path from "node:path";
9
9
  import { asDateTimestampMs } from "openclaw/plugin-sdk/number-runtime";
10
+ import path from "node:path";
10
11
  import { TOOL_PROGRESS_OUTPUT_MAX_CHARS, embeddedAgentLog, emitAgentEvent, formatErrorMessage, formatToolAggregate, formatToolProgressOutput, inferToolMetaFromArgs, runAgentHarnessAfterToolCallHook } from "openclaw/plugin-sdk/agent-harness-runtime";
11
12
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
12
13
  import { redactSensitiveFieldValue, redactToolPayloadText } from "openclaw/plugin-sdk/logging-core";
@@ -947,21 +948,20 @@ var CodexToolTranscriptProjection = class {
947
948
  isError: result.isError
948
949
  }).content;
949
950
  }
950
- async recordNativeToolResultWithDetails(item) {
951
+ async prepareNativeToolResultDetails(item) {
951
952
  const preparedDetails = await this.prepareNativeMcpAppResultDetails(item);
952
953
  const approvalReviewState = item ? this.approvalReviewsByCallId.get(item.id) : void 0;
953
954
  const reviewDetails = approvalReviewState ? {
954
955
  approvalReviews: approvalReviewState.reviews,
955
956
  approvalReviewOutcome: toolApprovalReviewOutcome(approvalReviewState)
956
957
  } : void 0;
957
- const details = reviewDetails ? isJsonObject(preparedDetails) ? {
958
+ return reviewDetails ? isJsonObject(preparedDetails) ? {
958
959
  ...preparedDetails,
959
960
  ...reviewDetails
960
961
  } : {
961
962
  ...preparedDetails !== void 0 ? { toolDetails: preparedDetails } : {},
962
963
  ...reviewDetails
963
964
  } : preparedDetails;
964
- this.recordNativeToolResult(item, details);
965
965
  }
966
966
  async prepareNativeMcpAppResultDetails(item) {
967
967
  if (!item || item.type !== "mcpToolCall" || itemStatus(item) === "running") return;
@@ -1084,13 +1084,14 @@ var CodexToolTranscriptProjection = class {
1084
1084
  const missingCount = (/* @__PURE__ */ new Set([...missingTranscriptIds, ...missingTrajectoryIds])).size;
1085
1085
  return missingCount === 1 ? MISSING_TOOL_RESULT_ERROR : `${MISSING_TOOL_RESULT_ERROR} missingToolResultCount=${missingCount}`;
1086
1086
  }
1087
- async readMirroredSessionMessages() {
1087
+ async readMirroredSessionMessages(signal) {
1088
1088
  return await readCodexMirroredSessionHistoryMessages({
1089
1089
  agentId: this.params.agentId,
1090
1090
  sessionFile: this.params.sessionFile,
1091
1091
  sessionId: this.params.sessionId,
1092
- sessionKey: this.params.sessionKey
1093
- }) ?? [];
1092
+ sessionKey: this.params.sessionKey,
1093
+ sessionTarget: this.params.sessionTarget
1094
+ }, void 0, "native-evidence", signal) ?? [];
1094
1095
  }
1095
1096
  recordToolCall(params) {
1096
1097
  if (!params.id || !params.name || this.callIds.has(params.id)) return;
@@ -1,10 +1,10 @@
1
- import { n as resolveManagedCodexAppServerStartOptions, r as resolveManagedCodexNativeCommand, t as isManagedCodexDesktopCommand } from "./managed-binary-4-Vjz5GH.js";
2
- import { i as closeCodexAppServerTransportAndWait, t as createStdioTransport } from "./transport-stdio-CyPldczm.js";
1
+ import { n as resolveManagedCodexAppServerStartOptions, r as resolveManagedCodexNativeCommand, t as isManagedCodexDesktopCommand } from "./managed-binary-DcpnJF9x.js";
2
+ import { i as closeCodexAppServerTransportAndWait, t as createStdioTransport } from "./transport-stdio-CzTngV0j.js";
3
3
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import { killProcessTree } from "openclaw/plugin-sdk/process-runtime";
4
5
  import { mkdir } from "node:fs/promises";
5
6
  import path from "node:path";
6
7
  import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
7
- import { killProcessTree } from "openclaw/plugin-sdk/process-runtime";
8
8
  import { once } from "node:events";
9
9
  import { sanitizeEnvVars } from "openclaw/plugin-sdk/sandbox";
10
10
  //#region extensions/codex/src/node-exec-server.runtime.ts
@@ -1,4 +1,4 @@
1
- import { N as resolveCodexGatewayTimeoutWithGraceMs } from "./shared-client-DxcfF9KX.js";
1
+ import { N as resolveCodexGatewayTimeoutWithGraceMs } from "./shared-client-CKhX2kFt.js";
2
2
  import { isApprovalNotFoundError, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
3
3
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
4
4
  //#region extensions/codex/src/app-server/plugin-approval-roundtrip.ts
@@ -1,12 +1,14 @@
1
- import { c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-DxcfF9KX.js";
2
- import { A as isCodexFastServiceTier } from "./config-BhmfC1s6.js";
3
- import { o as isCodexAppServerNativeAuthProfile, r as bindingStoreKey, s as normalizeCodexAppServerBindingModelProvider } from "./session-binding-BHuTCRZQ.js";
4
- import { E as resolveCodexAppServerRequestModelSelection, O as resolveCodexBindingModelProviderFallback } from "./thread-lifecycle-DAcEJ_Om.js";
5
- import { a as formatCodexDisplayText } from "./command-formatters-CLHhEB1Q.js";
6
- import { n as resolveCodexBindingAppServerConnection } from "./binding-connection-E6uDsPlx.js";
1
+ import { n as isCodexFastServiceTier } from "./config-utils-C57JiJrU.js";
2
+ import { t as bindingStoreKey } from "./session-binding-record-CyaXZvTe.js";
3
+ import "./config-CyapYSji.js";
4
+ import { c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-CKhX2kFt.js";
5
+ import { a as isCodexAppServerNativeAuthProfile, o as normalizeCodexAppServerBindingModelProvider } from "./session-binding-4Ki04sW-.js";
6
+ import { E as resolveCodexAppServerRequestModelSelection, O as resolveCodexBindingModelProviderFallback } from "./thread-lifecycle-DPK30jad.js";
7
+ import { s as resolveCodexBindingAppServerConnection } from "./thread-policy-CTalhWFy.js";
8
+ import { a as formatCodexDisplayText } from "./command-formatters-DSbGMXA0.js";
7
9
  import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
8
- import { resolveAgentDir } from "openclaw/plugin-sdk/agent-runtime";
9
10
  import { getSessionEntry, patchSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
11
+ import { resolveAgentDir } from "openclaw/plugin-sdk/agent-runtime";
10
12
  import { ModelSelectionLockedError, applyModelOverrideWithAuthProfileCompatibility } from "openclaw/plugin-sdk/model-session-runtime";
11
13
  //#region extensions/codex/src/command-authorization.ts
12
14
  const CODEX_NATIVE_EXECUTION_AUTH_ERROR = "Only an owner or operator.admin can control Codex native execution.";
@@ -44,7 +46,7 @@ async function stopCodexConversationTurn(params) {
44
46
  message: "No active Codex run to stop."
45
47
  };
46
48
  const lookup = buildBindingLookup(params);
47
- const binding = await params.bindingStore.read(params.identity);
49
+ const binding = params.binding;
48
50
  if (binding?.threadId !== active.threadId) return {
49
51
  stopped: false,
50
52
  message: "The active Codex run no longer matches this session binding."
@@ -65,7 +67,10 @@ async function stopCodexConversationTurn(params) {
65
67
  await client.request("turn/interrupt", {
66
68
  threadId: active.threadId,
67
69
  turnId: active.turnId
68
- }, { timeoutMs: runtime.requestTimeoutMs });
70
+ }, {
71
+ timeoutMs: runtime.requestTimeoutMs,
72
+ assertCurrent: params.assertCurrent
73
+ });
69
74
  } finally {
70
75
  if (!active.client) releaseLeasedSharedCodexAppServerClient(client);
71
76
  }
@@ -86,7 +91,7 @@ async function steerCodexConversationTurn(params) {
86
91
  message: "No active Codex run to steer."
87
92
  };
88
93
  const lookup = buildBindingLookup(params);
89
- const binding = await params.bindingStore.read(params.identity);
94
+ const binding = params.binding;
90
95
  if (binding?.threadId !== active.threadId) return {
91
96
  steered: false,
92
97
  message: "The active Codex run no longer matches this session binding."
@@ -112,7 +117,10 @@ async function steerCodexConversationTurn(params) {
112
117
  text,
113
118
  text_elements: []
114
119
  }]
115
- }, { timeoutMs: runtime.requestTimeoutMs });
120
+ }, {
121
+ timeoutMs: runtime.requestTimeoutMs,
122
+ assertCurrent: params.assertCurrent
123
+ });
116
124
  } finally {
117
125
  if (!active.client) releaseLeasedSharedCodexAppServerClient(client);
118
126
  }
@@ -125,7 +133,8 @@ async function setCodexConversationModel(params) {
125
133
  const model = params.model.trim();
126
134
  if (!model) return "Usage: /codex model <model>";
127
135
  const lookup = buildBindingLookup(params);
128
- const binding = await requireThreadBinding(params.bindingStore, params.identity);
136
+ params.assertCurrent();
137
+ const binding = requirePreparedThreadBinding(params.binding);
129
138
  if (binding.connectionScope === "supervision") throw new ModelSelectionLockedError();
130
139
  const modelProvider = resolveConversationControlModelProvider({
131
140
  authProfileId: binding.authProfileId,
@@ -155,10 +164,11 @@ async function setCodexConversationModel(params) {
155
164
  if (identity.kind === "session" && identity.sessionKey) {
156
165
  if (!await patchSessionEntry({
157
166
  agentId: identity.agentId,
158
- storePath: resolveStorePath(params.config?.session?.store, { agentId: identity.agentId }),
167
+ storePath: params.storePath ?? resolveStorePath(params.config?.session?.store, { agentId: identity.agentId }),
159
168
  sessionKey: identity.sessionKey,
160
169
  requireWriteSuccess: true,
161
170
  replaceEntry: true,
171
+ assertCommitAllowed: params.assertCurrent,
162
172
  update: (entry) => {
163
173
  if (entry.sessionId !== identity.sessionId) throw new Error("Codex session changed while applying the model selection.");
164
174
  applyModelOverrideWithAuthProfileCompatibility({
@@ -175,23 +185,25 @@ async function setCodexConversationModel(params) {
175
185
  return entry;
176
186
  }
177
187
  })) throw new Error("Codex session changed while applying the model selection.");
178
- if (modelChanged && binding.contextEngine?.projection) await patchThreadBinding(params.bindingStore, identity, binding.threadId, projectionPatch);
188
+ if (modelChanged && binding.contextEngine?.projection) await patchThreadBinding(params.bindingStore, identity, binding.threadId, projectionPatch, params.assertCurrent);
179
189
  } else await patchThreadBinding(params.bindingStore, params.identity, binding.threadId, {
180
190
  model: nextModel,
181
191
  modelProvider: nextModelProvider,
182
192
  ...projectionPatch
183
- });
193
+ }, params.assertCurrent);
184
194
  return `Codex model set to ${formatCodexDisplayText(nextModel)}.`;
185
195
  }
186
196
  async function setCodexConversationFastMode(params) {
187
- const binding = await requireThreadBinding(params.bindingStore, params.identity);
197
+ params.assertCurrent();
198
+ const binding = requirePreparedThreadBinding(params.binding);
188
199
  if (params.enabled == null) return `Codex fast mode: ${isCodexFastServiceTier(binding.serviceTier) ? "on" : "off"}.`;
189
200
  const serviceTier = params.enabled ? "priority" : "flex";
190
- await patchThreadBinding(params.bindingStore, params.identity, binding.threadId, { serviceTier });
201
+ await patchThreadBinding(params.bindingStore, params.identity, binding.threadId, { serviceTier }, params.assertCurrent);
191
202
  return `Codex fast mode ${params.enabled ? "enabled" : "disabled"}.`;
192
203
  }
193
204
  async function setCodexConversationPermissions(params) {
194
- const storePath = resolveStorePath(params.config?.session?.store, { agentId: params.session.agentId });
205
+ params.assertCurrent();
206
+ const storePath = params.storePath ?? resolveStorePath(params.config?.session?.store, { agentId: params.session.agentId });
195
207
  if (!params.mode) {
196
208
  const entry = getSessionEntry({
197
209
  agentId: params.session.agentId,
@@ -200,6 +212,7 @@ async function setCodexConversationPermissions(params) {
200
212
  sessionKey: params.session.sessionKey,
201
213
  storePath
202
214
  });
215
+ params.assertCurrent();
203
216
  if (entry?.sessionId !== params.session.sessionId) throw new Error("Codex session changed while reading the permission mode.");
204
217
  return `Codex permissions: ${formatPermissionsMode(entry.permissionMode)}.`;
205
218
  }
@@ -209,6 +222,7 @@ async function setCodexConversationPermissions(params) {
209
222
  sessionKey: params.session.sessionKey,
210
223
  requireWriteSuccess: true,
211
224
  replaceEntry: true,
225
+ assertCommitAllowed: params.assertCurrent,
212
226
  update: (entry) => {
213
227
  if (entry.sessionId !== params.session.sessionId) throw new Error("Codex session changed while applying the permission mode.");
214
228
  entry.permissionMode = params.mode === "yolo" ? "full" : "guarded";
@@ -237,17 +251,16 @@ function parseCodexPermissionsModeArg(arg) {
237
251
  function formatPermissionsMode(mode) {
238
252
  return mode === "full" ? "full access" : mode ?? "default";
239
253
  }
240
- async function requireThreadBinding(bindingStore, identity) {
241
- const binding = await bindingStore.read(identity);
254
+ function requirePreparedThreadBinding(binding) {
242
255
  if (!binding?.threadId) throw new Error("No Codex thread is attached to this OpenClaw session yet.");
243
256
  return binding;
244
257
  }
245
- async function patchThreadBinding(bindingStore, identity, threadId, patch) {
258
+ async function patchThreadBinding(bindingStore, identity, threadId, patch, assertCurrent) {
246
259
  if (!await bindingStore.mutate(identity, {
247
260
  kind: "patch",
248
261
  threadId,
249
262
  patch
250
- })) throw new Error("Codex thread binding changed while applying the control update.");
263
+ }, assertCurrent)) throw new Error("Codex thread binding changed while applying the control update.");
251
264
  }
252
265
  function buildBindingLookup(params) {
253
266
  const agentDir = params.agentDir?.trim();
@@ -1,8 +1,8 @@
1
- import { B as isCodexAppServerIndeterminateRequestCancellationError, D as acquireCodexNativeConfigFence, Gt as resolveCodexManagedBundledMarketplacePath, Kt as assertNotSymlink, Lt as reconcileCodexComputerUseStartArtifacts, S as waitForCodexAppServerClientDesktopGenerationDrain, V as isCodexAppServerIndeterminateTransportError, c as getLeasedSharedCodexAppServerClient, d as readCodexAppServerClientDesktopGeneration, g as resolveCodexNativeConfigFenceKey, h as releaseLeasedSharedCodexAppServerClient, p as readCodexAppServerClientProcessIdentity, t as assertCodexAppServerClientStartSelectionCurrent, u as isCodexAppServerStartSelectionChangedError, z as isCodexAppServerConnectionClosedError } from "./shared-client-DxcfF9KX.js";
2
- import { F as resolveCodexAppServerHomeDir, i as resolveCodexAppServerRuntimeOptions, o as resolveCodexComputerUseConfig } from "./config-BhmfC1s6.js";
3
- import { c as resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath, t as isManagedCodexDesktopCommand, u as resolveMacOSDesktopCodexBundledMarketplaceCandidates } from "./managed-binary-4-Vjz5GH.js";
4
- import { i as requestCodexAppServerJson } from "./request-DYAI5FQE.js";
5
- import { n as describeControlFailure } from "./capabilities-dIjNVCYH.js";
1
+ import { M as resolveCodexAppServerHomeDir, i as resolveCodexAppServerRuntimeOptions, o as resolveCodexComputerUseConfig } from "./config-CyapYSji.js";
2
+ import { B as isCodexAppServerIndeterminateRequestCancellationError, D as acquireCodexNativeConfigFence, Jt as assertNotSymlink, S as waitForCodexAppServerClientDesktopGenerationDrain, V as isCodexAppServerIndeterminateTransportError, c as getLeasedSharedCodexAppServerClient, d as readCodexAppServerClientDesktopGeneration, g as resolveCodexNativeConfigFenceKey, h as releaseLeasedSharedCodexAppServerClient, p as readCodexAppServerClientProcessIdentity, qt as resolveCodexManagedBundledMarketplacePath, t as assertCodexAppServerClientStartSelectionCurrent, u as isCodexAppServerStartSelectionChangedError, z as isCodexAppServerConnectionClosedError, zt as reconcileCodexComputerUseStartArtifacts } from "./shared-client-CKhX2kFt.js";
3
+ import { c as resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath, t as isManagedCodexDesktopCommand, u as resolveMacOSDesktopCodexBundledMarketplaceCandidates } from "./managed-binary-DcpnJF9x.js";
4
+ import { i as requestCodexAppServerJson } from "./request-C8H22rPi.js";
5
+ import { n as describeControlFailure } from "./capabilities-B1mgvpP8.js";
6
6
  import fs from "node:fs/promises";
7
7
  import path from "node:path";
8
8
  import { existsSync } from "node:fs";
@@ -1,5 +1,5 @@
1
- import { h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-DxcfF9KX.js";
2
- import { ut as normalizeCodexDynamicToolName } from "./thread-lifecycle-DAcEJ_Om.js";
1
+ import { h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-CKhX2kFt.js";
2
+ import { ut as normalizeCodexDynamicToolName } from "./thread-lifecycle-DPK30jad.js";
3
3
  import { pinExecToolTarget } from "openclaw/plugin-sdk/codex-mcp-projection";
4
4
  import { loadNodeExecAvailability } from "openclaw/plugin-sdk/node-selection-runtime";
5
5
  //#region extensions/codex/src/app-server/shell-dynamic-tools.ts
@@ -1,4 +1,4 @@
1
- import { $t as isJsonObject } from "./shared-client-DxcfF9KX.js";
1
+ import { B as isJsonObject } from "./config-CyapYSji.js";
2
2
  import { asBoolean, asFiniteNumber, normalizeOptionalString, parseStrictFiniteNumber } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import { MAX_DATE_TIMESTAMP_MS, resolveExpiresAtMsFromEpochSeconds } from "openclaw/plugin-sdk/number-runtime";
4
4
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { Nt as withTimeout, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient, s as createIsolatedCodexAppServerClient, u as isCodexAppServerStartSelectionChangedError, y as retireSharedCodexAppServerClientIfCurrent } from "./shared-client-DxcfF9KX.js";
3
- import { w as isCodexRemoteExecPlacementSandbox } from "./config-BhmfC1s6.js";
2
+ import { E as isCodexRemoteExecPlacementSandbox } from "./config-CyapYSji.js";
3
+ import { Ft as withTimeout, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient, s as createIsolatedCodexAppServerClient, u as isCodexAppServerStartSelectionChangedError, y as retireSharedCodexAppServerClientIfCurrent } from "./shared-client-CKhX2kFt.js";
4
4
  import { resolveAgentConfig, tryResolveDefaultAgentId } from "openclaw/plugin-sdk/agent-scope-runtime";
5
5
  import { getSessionEntry } from "openclaw/plugin-sdk/session-store-runtime";
6
6
  import { normalizeAgentId, parseAgentSessionKey } from "openclaw/plugin-sdk/routing";