@openclaw/codex 2026.9.1 → 2026.9.3

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 (109) hide show
  1. package/README.md +2 -0
  2. package/dist/api.js +18 -23
  3. package/dist/apply-B6el6hdO.js +357 -0
  4. package/dist/{attempt-client-cleanup-DYHcRQAa.js → attempt-client-cleanup-D6cR54TV.js} +113 -49
  5. package/dist/{attempt-context-DmQUNWwT.js → attempt-context-AO4DSjE0.js} +11 -9
  6. package/dist/{event-projector-usage-C5mcrGjp.js → attempt-notifications--H8zXR5-.js} +3 -89
  7. package/dist/auth-cache-key-Kq6oerr6.js +498 -0
  8. package/dist/auth-profile-CwzO4_RG.js +43 -0
  9. package/dist/auth-profile-selection-DFu9e167.js +45 -0
  10. package/dist/{binding-connection-E6uDsPlx.js → binding-connection-QqgcPCgk.js} +18 -3
  11. package/dist/{bounded-turn-wzJrwKKe.js → bounded-turn-lRpmZHFv.js} +54 -150
  12. package/dist/build-state-6RL6qohz.js +19 -0
  13. package/dist/{capabilities-dIjNVCYH.js → capabilities-BeqLPbtM.js} +2 -1
  14. package/dist/cli-metadata.js +1 -1
  15. package/dist/client-BEKu4yDx.js +3983 -0
  16. package/dist/command-dispatch-CisT9Jqq.js +21 -0
  17. package/dist/{command-formatters-CLHhEB1Q.js → command-formatters-DeTfrapr.js} +2 -2
  18. package/dist/{command-handlers-CTGb2csu.js → command-handlers-BfIsJEuA.js} +158 -76
  19. package/dist/command-rpc-BMqRQOFX.js +226 -0
  20. package/dist/{compact-_t0HQrUS.js → compact-CGJZ2rlb.js} +89 -49
  21. package/dist/config-JDfTI4VI.js +106 -0
  22. package/dist/{config-BhmfC1s6.js → config-options-jnIFvwxD.js} +208 -654
  23. package/dist/config-runtime-BWf6JLWG.js +11 -0
  24. package/dist/config-utils-C57JiJrU.js +69 -0
  25. package/dist/conversation-binding-CxOlHiix.js +889 -0
  26. package/dist/{plugin-marketplace-discovery-CfFlKqDl.js → conversation-control-CUCrSIQI.js} +36 -155
  27. package/dist/doctor-contract-api.js +8 -9
  28. package/dist/{dynamic-tools-BU9tmlYm.js → dynamic-tools-D-JBoaLt.js} +734 -698
  29. package/dist/{effective-mcp-catalog-DzYBW4h1.js → effective-mcp-catalog-J_5Ep5Um.js} +4 -3
  30. package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
  31. package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
  32. package/dist/{event-projector-assistant-message-DHRFXKbS.js → event-projector-assistant-message-BmBM4qBV.js} +23 -27
  33. package/dist/event-projector-usage-CIyrYYid.js +102 -0
  34. package/dist/{harness-DXVZ5II5.js → harness-FR6eQgyO.js} +47 -17
  35. package/dist/harness.js +1 -1
  36. package/dist/history-rejection-B4nOXNXF.js +13 -0
  37. package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
  38. package/dist/incognito-session-uhrBF6wJ.js +15 -0
  39. package/dist/index.js +413 -2893
  40. package/dist/{isolated-completion-kg9kv4iH.js → isolated-completion-DHBefrzg.js} +12 -21
  41. package/dist/{managed-binary-4-Vjz5GH.js → managed-binary-DrjjRRUD.js} +17 -84
  42. package/dist/managed-thread-store-D1t5jh3G.js +66 -0
  43. package/dist/media-understanding-provider.js +4 -1
  44. package/dist/{model-catalog-CUM68Hkl.js → model-catalog-B_6M04Wo.js} +6 -5
  45. package/dist/{models-sYnEc0gd.js → models-P9k2qAof.js} +4 -4
  46. package/dist/native-execution-policy-umd0tgh4.js +128 -0
  47. package/dist/{native-subagent-monitor-CnH147jH.js → native-subagent-monitor-BbCUKRwC.js} +76 -48
  48. package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
  49. package/dist/{node-exec-server.runtime-CstNHCmC.js → node-exec-server.runtime-BY_ctYnT.js} +54 -23
  50. package/dist/plan-BMJdMOEF.js +711 -0
  51. package/dist/plugin-activation-BQK-f5sV.js +133 -0
  52. package/dist/{thread-resume-C7pyVKeW.js → plugin-app-cache-key-CdSQzWyX.js} +5 -53
  53. package/dist/{plugin-approval-roundtrip-CNe-Xrjx.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
  54. package/dist/plugin-inventory-CoRCzWW4.js +325 -0
  55. package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
  56. package/dist/{plugin-metadata-cache-BFrPhb2c.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
  57. package/dist/protocol-CAAcVIKF.js +275 -0
  58. package/dist/{provider-capabilities-DW5p4k9w.js → provider-capabilities-W4tfK5Y5.js} +2 -2
  59. package/dist/{rate-limits-CawQJfUS.js → rate-limits-Bqnx1N4z.js} +1 -1
  60. package/dist/request-CGvGOpeR.js +198 -0
  61. package/dist/{run-attempt-D1hJO4fX.js → run-attempt-DwKds3DN.js} +1498 -1028
  62. package/dist/{runtime-artifact-C3jVimFn.js → runtime-artifact-T-NwqeSH.js} +28 -28
  63. package/dist/sandbox-guard-BcT66fWy.js +165 -0
  64. package/dist/{session-binding-BHuTCRZQ.js → session-binding-CKSepwIC.js} +118 -324
  65. package/dist/session-binding-record-CaZjYwNS.js +256 -0
  66. package/dist/session-catalog-HaDcp7Sv.js +1533 -0
  67. package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
  68. package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
  69. package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
  70. package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
  71. package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
  72. package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
  73. package/dist/session-catalog-provenance-DkJHo735.js +124 -0
  74. package/dist/{session-cli-CmFEXMAM.js → session-cli-CbgaHh0f.js} +3 -2
  75. package/dist/session-history-Cz-tOOYj.js +96 -0
  76. package/dist/{session-upstream-marker-C351-5Qw.js → session-history-import-DFN7sWRU.js} +5 -49
  77. package/dist/session-history-read-cxPUxyVV.js +50 -0
  78. package/dist/session-history-worker-runtime.js +60 -0
  79. package/dist/{settled-turn-context-D3SNWtUn.js → session-history.worker-CNEvGaU5.js} +75 -69
  80. package/dist/session-history.worker.js +2 -0
  81. package/dist/{session-initialization-BeWzjGiR.js → session-initialization-Jo86C60I.js} +2 -1
  82. package/dist/{session-permission-policy-DeWVTCMj.js → session-permission-policy-B22InTp_.js} +4 -7
  83. package/dist/{session-retirement-BujDjXVF.js → session-retirement-BSNG_mhf.js} +8 -7
  84. package/dist/session-upstream-marker-D15C9NHp.js +46 -0
  85. package/dist/settled-turn-context-Du6gdUDd.js +45 -0
  86. package/dist/{settled-turn-finalizer-BVJx4yoc.js → settled-turn-finalizer-BuLUrZl2.js} +54 -42
  87. package/dist/shared-client-CVhez2Uo.js +2911 -0
  88. package/dist/{side-question-BTZAII4l.js → side-question-DLbr2vUU.js} +135 -191
  89. package/dist/source-Da-h6f7e.js +518 -0
  90. package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
  91. package/dist/{thread-lifecycle-DAcEJ_Om.js → thread-lifecycle-D1pzRwHB.js} +467 -977
  92. package/dist/{thread-ownership-zGokd8i1.js → thread-ownership-D6oASVRu.js} +15 -17
  93. package/dist/{thread-policy-g4KbJPzp.js → thread-policy-D8kI7yAO.js} +2 -2
  94. package/dist/thread-resume-T5cveyxA.js +52 -0
  95. package/dist/timeout-BVw8aaM1.js +33 -0
  96. package/dist/transcript-mirror-attestation-DibE0krH.js +89 -0
  97. package/dist/{transcript-mirror-DTUxFWa_.js → transcript-mirror-t5TOccct.js} +111 -379
  98. package/dist/{transport-stdio-CyPldczm.js → transport-stdio-BGjHoYLr.js} +80 -48
  99. package/dist/{upstream-session-fork-CYlBIGVt.js → upstream-session-fork-De-sLJ2r.js} +94 -166
  100. package/dist/{usage-Bj-rrzkR.js → usage-CPPTmBvZ.js} +4 -3
  101. package/dist/version-omm6IPI3.js +12 -0
  102. package/dist/{web-search-provider.runtime-D2FWSK4w.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
  103. package/openclaw.plugin.json +22 -1
  104. package/package.json +6 -6
  105. package/dist/request-DYAI5FQE.js +0 -475
  106. package/dist/session-catalog-yyvTWFOw.js +0 -3120
  107. package/dist/session-history-C5J1AKzG.js +0 -87
  108. package/dist/shared-client-DxcfF9KX.js +0 -7494
  109. package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
@@ -1,26 +1,14 @@
1
- import { $t as isJsonObject, Wt as resolveCodexAppServerPreparedAuthHandoff } from "./shared-client-DxcfF9KX.js";
2
- import { E as readCodexPluginConfig, r as resolveCodexAppServerHomeScope } from "./config-BhmfC1s6.js";
3
- import { t as runBoundedCodexAppServerTurn } from "./bounded-turn-wzJrwKKe.js";
4
- import { a as createAttributedCodexAssistantMessage } from "./event-projector-assistant-message-DHRFXKbS.js";
1
+ import { i as resolveCodexAppServerHomeScope } from "./config-options-jnIFvwxD.js";
2
+ import { x as readCodexPluginConfig } from "./protocol-CAAcVIKF.js";
3
+ import { g as assertCodexPassiveTurnItems } from "./client-BEKu4yDx.js";
4
+ import "./config-JDfTI4VI.js";
5
+ import { Z as resolveCodexAppServerPreparedAuthHandoff } from "./shared-client-CVhez2Uo.js";
6
+ import { runBoundedCodexAppServerTurn } from "./bounded-turn-lRpmZHFv.js";
7
+ import { a as createAttributedCodexAssistantMessage } from "./event-projector-assistant-message-BmBM4qBV.js";
5
8
  //#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
9
  /** Runs prompt-only Codex inference on an ephemeral, ring-zero native thread. */
23
10
  async function runCodexIsolatedCompletion(params, options) {
11
+ params.assertCurrent?.();
24
12
  const authorization = params.authorization;
25
13
  if (authorization.owner !== "harness") throw new Error("Codex native isolated completion requires harness-owned authorization.");
26
14
  const pluginConfig = readCodexPluginConfig(options.pluginConfig);
@@ -35,6 +23,7 @@ async function runCodexIsolatedCompletion(params, options) {
35
23
  subscriptionProfileRequiredError: "Prepared Codex subscription route requires a scoped native OAuth or token profile.",
36
24
  subscriptionProfileUnusableError: `Prepared Codex auth profile "${authorization.plan.forwardedAuthProfileId}" is unusable.`
37
25
  });
26
+ params.assertCurrent?.();
38
27
  const authSelection = authHandoff.preparedAuth ? { preparedAuth: authHandoff.preparedAuth } : { profile: authHandoff.authProfileId };
39
28
  const result = await runBoundedCodexAppServerTurn({
40
29
  config: params.config,
@@ -46,6 +35,7 @@ async function runCodexIsolatedCompletion(params, options) {
46
35
  authRequirement,
47
36
  timeoutMs: params.timeoutMs,
48
37
  signal: params.abortSignal,
38
+ assertCurrent: params.assertCurrent,
49
39
  agentDir: params.agentDir,
50
40
  authProfileStore: authorization.authProfileStore,
51
41
  options,
@@ -60,7 +50,8 @@ async function runCodexIsolatedCompletion(params, options) {
60
50
  isolation: "configured-transport",
61
51
  requireNoExternalCapabilities: true
62
52
  });
63
- assertIsolatedCompletionItems(result.items, params.prompt);
53
+ params.assertCurrent?.();
54
+ assertCodexPassiveTurnItems(result.items, params.prompt, "isolated completion");
64
55
  return { assistant: createAttributedCodexAssistantMessage({
65
56
  api: "openai-chatgpt-responses",
66
57
  provider: params.provider,
@@ -1,9 +1,10 @@
1
+ import { n as MANAGED_CODEX_APP_SERVER_PACKAGE } from "./version-omm6IPI3.js";
1
2
  import { createRequire } from "node:module";
2
- import { access } from "node:fs/promises";
3
+ import { constants, existsSync, realpathSync } from "node:fs";
3
4
  import path from "node:path";
4
- import { constants, existsSync, readFileSync, realpathSync } from "node:fs";
5
- import { fileURLToPath } from "node:url";
5
+ import { access } from "node:fs/promises";
6
6
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
7
+ import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
7
8
  //#region extensions/codex/src/app-server/desktop-app-paths.ts
8
9
  /** Shared path candidates for Codex's macOS desktop app bundle. */
9
10
  const MACOS_DESKTOP_CODEX_APP_PATH_CANDIDATES = [{
@@ -41,34 +42,24 @@ function resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath(params = {}
41
42
  return candidates.find((candidate) => pathExists(candidate));
42
43
  }
43
44
  //#endregion
44
- //#region extensions/codex/src/app-server/version.ts
45
- /**
46
- * Version and package pins for the managed Codex app-server runtime.
47
- */
48
- /** Exact Codex app-server version shipped by the OpenClaw Codex bridge. */
49
- const CODEX_APP_SERVER_VERSION = "0.152.1";
50
- /** Inclusive runtime compatibility floor for external app-server binaries. */
51
- const MIN_SUPPORTED_CODEX_APP_SERVER_VERSION = "0.149.0";
52
- /** npm package name for the managed Codex app-server binary. */
53
- const MANAGED_CODEX_APP_SERVER_PACKAGE = "@openai/codex";
54
- //#endregion
55
45
  //#region extensions/codex/src/app-server/managed-binary.ts
56
46
  /**
57
47
  * Resolves the managed Codex app-server binary shipped with or installed beside
58
48
  * the Codex plugin before stdio startup.
59
49
  */
60
- const CODEX_PLUGIN_ROOT = resolveDefaultCodexPluginRoot(path.dirname(fileURLToPath(import.meta.url)));
61
- let registeredCodexPluginRoot;
50
+ const registeredCodexPlugin = resolveGlobalSingleton(Symbol.for("openclaw.codexManagedPluginRoot"), () => ({}));
62
51
  /** Records the process-stable plugin root prepared by OpenClaw's plugin loader. */
63
52
  function setManagedCodexPluginRoot(pluginRoot) {
64
- registeredCodexPluginRoot = pluginRoot;
53
+ registeredCodexPlugin.root = pluginRoot;
65
54
  }
66
55
  /** Rewrites managed stdio start options to point at an executable Codex binary path. */
67
56
  async function resolveManagedCodexAppServerStartOptions(startOptions, options = {}) {
68
57
  if (startOptions.transport !== "stdio" || startOptions.commandSource !== "managed") return startOptions;
58
+ const pluginRoot = options.pluginRoot ?? registeredCodexPlugin.root;
59
+ if (!pluginRoot) throw new Error("Codex plugin root is unavailable. Load the Codex plugin before starting its managed app-server.");
69
60
  const platform = options.platform ?? process.platform;
70
61
  const commandPaths = await findManagedCodexAppServerCommandPaths({
71
- candidateCommandPaths: resolveManagedCodexAppServerCommandCandidates(options.pluginRoot ?? registeredCodexPluginRoot ?? CODEX_PLUGIN_ROOT, platform, startOptions.managedCommandOrder ?? "package-first"),
62
+ candidateCommandPaths: resolveManagedCodexAppServerCommandCandidates(pluginRoot, platform, startOptions.managedCommandOrder ?? "package-first"),
72
63
  pathExists: options.pathExists ?? commandPathExists,
73
64
  platform
74
65
  });
@@ -158,76 +149,18 @@ function resolvePackageJsonFromRoot(packageName, root) {
158
149
  }
159
150
  }
160
151
  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;
152
+ const packageCommand = resolveManagedCodexPackageEntrypoint(pluginRoot);
153
+ const packageCommandPaths = packageCommand ? [packageCommand] : [];
154
+ const desktopCommandPaths = resolveMacOSDesktopCodexAppServerCommandCandidates(platform);
155
+ return managedCommandOrder === "desktop-first" ? [...desktopCommandPaths, ...packageCommandPaths] : [...packageCommandPaths, ...desktopCommandPaths];
212
156
  }
213
- function resolveManagedCodexPackageBinCandidate(root) {
157
+ function resolveManagedCodexPackageEntrypoint(pluginRoot) {
214
158
  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;
159
+ return createRequire(path.join(pluginRoot, "package.json")).resolve(`${MANAGED_CODEX_APP_SERVER_PACKAGE}/bin/codex.js`);
221
160
  } catch {
222
- return null;
161
+ return;
223
162
  }
224
163
  }
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
164
  function pathForPlatform(platform) {
232
165
  return platform === "win32" ? path.win32 : path.posix;
233
166
  }
@@ -250,4 +183,4 @@ async function commandPathExists(filePath, platform) {
250
183
  }
251
184
  }
252
185
  //#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 };
186
+ export { setManagedCodexPluginRoot as a, resolveMacOSDesktopCodexBundledMarketplaceCandidates as c, resolvePackagedCodexNativeCommand as i, resolveMacOSDesktopCodexComputerUseServiceAppCandidates as l, resolveManagedCodexAppServerStartOptions as n, resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath as o, resolveManagedCodexNativeCommand as r, resolveMacOSDesktopCodexAppPathCandidates as s, isManagedCodexDesktopCommand as t };
@@ -0,0 +1,66 @@
1
+ import { createHash } from "node:crypto";
2
+ import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-registration";
3
+ import { z } from "zod";
4
+ //#region extensions/codex/src/app-server/managed-thread-store.ts
5
+ const CODEX_MANAGED_THREAD_NAMESPACE = "app-server-managed-threads";
6
+ const CODEX_MANAGED_THREAD_MAX_ENTRIES = 2e4;
7
+ const managedThreadSchema = z.object({
8
+ version: z.literal(1),
9
+ kind: z.literal("managed-thread"),
10
+ sourceHomeId: z.string().min(1),
11
+ threadId: z.string().min(1),
12
+ rolloutPath: z.string().min(1).optional()
13
+ });
14
+ async function markStartedCodexManagedThread(store, params) {
15
+ if (!store) return;
16
+ try {
17
+ await store.mark({
18
+ sourceHomeId: params.sourceHomeId,
19
+ threadId: params.threadId,
20
+ ...params.rolloutPath ? { rolloutPath: params.rolloutPath } : {}
21
+ });
22
+ } catch (error) {
23
+ embeddedAgentLog.warn("failed to record Codex managed thread ownership", { error });
24
+ }
25
+ }
26
+ function managedThreadStoreKey(sourceHomeId, threadId) {
27
+ return `sha256:${createHash("sha256").update("openclaw:codex-managed-thread:v1\0").update(sourceHomeId).update("\0").update(threadId).digest("hex")}`;
28
+ }
29
+ /** Durable ownership index for Codex threads created by OpenClaw. */
30
+ function createCodexManagedThreadStore(state) {
31
+ return {
32
+ async has(sourceHomeId, threadId) {
33
+ const parsed = managedThreadSchema.safeParse(state.lookup(managedThreadStoreKey(sourceHomeId, threadId)));
34
+ return parsed.success && parsed.data.sourceHomeId === sourceHomeId && parsed.data.threadId === threadId;
35
+ },
36
+ async mark(params) {
37
+ try {
38
+ const value = managedThreadSchema.parse({
39
+ version: 1,
40
+ kind: "managed-thread",
41
+ sourceHomeId: params.sourceHomeId.trim(),
42
+ threadId: params.threadId.trim(),
43
+ ...params.rolloutPath?.trim() ? { rolloutPath: params.rolloutPath.trim() } : {}
44
+ });
45
+ state.registerIfAbsent(managedThreadStoreKey(value.sourceHomeId, value.threadId), value);
46
+ return true;
47
+ } catch (error) {
48
+ embeddedAgentLog.warn("failed to record Codex managed thread ownership", { error });
49
+ return false;
50
+ }
51
+ },
52
+ async snapshot() {
53
+ const byHome = /* @__PURE__ */ new Map();
54
+ for (const entry of state.entries()) {
55
+ const parsed = managedThreadSchema.safeParse(entry.value);
56
+ if (!parsed.success) continue;
57
+ const ids = byHome.get(parsed.data.sourceHomeId) ?? /* @__PURE__ */ new Set();
58
+ ids.add(parsed.data.threadId);
59
+ byHome.set(parsed.data.sourceHomeId, ids);
60
+ }
61
+ return byHome;
62
+ }
63
+ };
64
+ }
65
+ //#endregion
66
+ export { markStartedCodexManagedThread as i, CODEX_MANAGED_THREAD_NAMESPACE as n, createCodexManagedThreadStore as r, CODEX_MANAGED_THREAD_MAX_ENTRIES as t };
@@ -1,4 +1,3 @@
1
- import { t as runBoundedCodexAppServerTurn } from "./bounded-turn-wzJrwKKe.js";
2
1
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
2
  import { validateJsonSchemaValue } from "openclaw/plugin-sdk/json-schema-runtime";
4
3
  //#region extensions/codex/media-understanding-provider.ts
@@ -44,6 +43,8 @@ async function describeCodexImages(req, options) {
44
43
  const model = req.model.trim();
45
44
  if (!model) throw new Error("Codex image understanding requires model id.");
46
45
  req.signal?.throwIfAborted();
46
+ const { runBoundedCodexAppServerTurn } = await import("./bounded-turn-lRpmZHFv.js");
47
+ req.signal?.throwIfAborted();
47
48
  const { text } = await runBoundedCodexAppServerTurn({
48
49
  config: req.cfg,
49
50
  model: {
@@ -82,6 +83,8 @@ async function extractCodexStructured(req, options) {
82
83
  if (req.input.length === 0) throw new Error("Codex structured extraction requires at least one input.");
83
84
  if (!req.input.some((entry) => entry.type === "image")) throw new Error("Codex structured extraction requires at least one image input.");
84
85
  req.signal?.throwIfAborted();
86
+ const { runBoundedCodexAppServerTurn } = await import("./bounded-turn-lRpmZHFv.js");
87
+ req.signal?.throwIfAborted();
85
88
  const { text } = await runBoundedCodexAppServerTurn({
86
89
  config: req.cfg,
87
90
  model: {
@@ -1,8 +1,9 @@
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-FR6eQgyO.js";
2
+ import { o as isJsonObject, x as readCodexPluginConfig } from "./protocol-CAAcVIKF.js";
3
+ import { o as withCodexAppServerJsonClient } from "./request-CGvGOpeR.js";
4
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-BWf6JLWG.js";
5
+ import { r as captureSharedCodexAppServerCatalogLifetime } from "./shared-client-CVhez2Uo.js";
6
+ import { t as listAllCodexAppServerModels } from "./models-P9k2qAof.js";
6
7
  //#region extensions/codex/src/app-server/model-catalog.ts
7
8
  const DEFAULT_MODEL_DISCOVERY_TIMEOUT_MS = 2500;
8
9
  const INPUT_TYPES = /* @__PURE__ */ new Set([
@@ -1,4 +1,4 @@
1
- import { Y as assertCodexModelListResponse } from "./shared-client-DxcfF9KX.js";
1
+ import { h as assertCodexModelListResponse } from "./client-BEKu4yDx.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-CVhez2Uo.js").then((n) => n.y);
41
+ const { requestCodexAppServerClientJson } = await import("./request-CGvGOpeR.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) {
@@ -0,0 +1,128 @@
1
+ import { resolveAgentConfig, tryResolveDefaultAgentId } from "openclaw/plugin-sdk/agent-scope-runtime";
2
+ import { normalizeAgentId, parseAgentSessionKey } from "openclaw/plugin-sdk/routing";
3
+ import { getSessionEntry } from "openclaw/plugin-sdk/session-store-runtime";
4
+ import { resolveSandboxRuntimeStatus } from "openclaw/plugin-sdk/sandbox";
5
+ //#region extensions/codex/src/app-server/native-execution-policy.ts
6
+ /** Projects node execution ownership into the runtime tool factory options. */
7
+ function resolveCodexNodeExecToolOverrides(policy) {
8
+ if (policy.effectiveExecHost !== "node") return;
9
+ const node = policy.node?.trim();
10
+ return {
11
+ host: "node",
12
+ ...node ? { node } : {}
13
+ };
14
+ }
15
+ /** Resolves node/gateway/sandbox execution ownership from overrides, session, agent, and config. */
16
+ function resolveCodexNativeExecutionPolicy(params) {
17
+ const config = params.config ?? {};
18
+ const sessionKey = params.sessionKey?.trim() || params.sessionId?.trim() || void 0;
19
+ const agentId = resolvePolicyAgentId({
20
+ config,
21
+ sessionKey,
22
+ agentId: params.agentId
23
+ });
24
+ const canReadSessionEntry = Boolean(agentId) && params.readRuntimeSessionEntry && shouldReadRuntimeSessionEntry({
25
+ config,
26
+ sessionKey,
27
+ agentId
28
+ });
29
+ const sessionEntry = params.sessionEntry ?? (canReadSessionEntry && sessionKey && agentId ? readRuntimeSessionEntryBestEffort({
30
+ sessionKey,
31
+ agentId
32
+ }) : void 0);
33
+ const sandboxAgentId = parseAgentSessionKey(sessionKey)?.agentId ?? agentId;
34
+ const sandboxAvailable = params.sandboxAvailable ?? (sessionKey && sandboxAgentId ? resolveSandboxRuntimeStatus({
35
+ cfg: config,
36
+ sessionKey,
37
+ agentId: sandboxAgentId,
38
+ classificationAgentId: sandboxAgentId
39
+ }).sandboxed : false);
40
+ const agentExec = agentId ? resolvePolicyAgentExec({
41
+ config,
42
+ agentId
43
+ }) : void 0;
44
+ const globalExec = config.tools?.exec;
45
+ const requestedExecHost = normalizeExecTarget(params.execOverrides?.host) ?? normalizeExecTarget(sessionEntry?.execHost) ?? normalizeExecTarget(agentExec?.host) ?? normalizeExecTarget(globalExec?.host) ?? "auto";
46
+ const effectiveExecHost = resolveEffectiveExecHost({
47
+ requestedExecHost,
48
+ sandboxAvailable
49
+ });
50
+ const node = params.execOverrides?.node ?? sessionEntry?.execNode ?? agentExec?.node ?? globalExec?.node;
51
+ if (effectiveExecHost !== "node") return {
52
+ nativeToolSurfaceAllowed: true,
53
+ requestedExecHost,
54
+ effectiveExecHost,
55
+ node
56
+ };
57
+ return {
58
+ nativeToolSurfaceAllowed: false,
59
+ requestedExecHost,
60
+ effectiveExecHost,
61
+ node,
62
+ blockReason: "OpenClaw exec host=node is active for this session. Codex app-server native execution cannot route shell, filesystem, MCP, or app-backed work through the selected OpenClaw node."
63
+ };
64
+ }
65
+ /** Formats the user-facing explanation shown when native tools are blocked by exec host=node. */
66
+ function formatCodexNativeNodeExecBlock(params) {
67
+ return [
68
+ `Codex-native ${params.surface} is unavailable because OpenClaw exec host=node is active for this session.`,
69
+ params.reason ?? "Codex app-server native execution cannot route execution through the selected OpenClaw node.",
70
+ "Use a normal Codex harness turn so OpenClaw exec/process tools run on the node, or switch exec host to gateway for native Codex app-server execution."
71
+ ].join(" ");
72
+ }
73
+ function resolvePolicyAgentId(params) {
74
+ const explicitAgentId = normalizeAgentIdOrDefault(params.agentId);
75
+ if (explicitAgentId) return explicitAgentId;
76
+ const sessionAgentId = parseAgentIdFromSessionKey(params.sessionKey);
77
+ if (sessionAgentId) return sessionAgentId;
78
+ return tryResolveDefaultAgentId(params.config);
79
+ }
80
+ function resolvePolicyAgentExec(params) {
81
+ return resolveAgentConfig(params.config, params.agentId)?.tools?.exec;
82
+ }
83
+ function parseAgentIdFromSessionKey(sessionKey) {
84
+ const raw = sessionKey?.trim();
85
+ if (!raw) return;
86
+ const parts = raw.toLowerCase().split(":").filter(Boolean);
87
+ if (parts.length < 3 || parts[0] !== "agent" || !parts[2]) return;
88
+ return normalizeAgentIdOrDefault(parts[1]);
89
+ }
90
+ function shouldReadRuntimeSessionEntry(params) {
91
+ if (!params.sessionKey) return false;
92
+ const explicitAgentId = normalizeAgentIdOrDefault(params.agentId);
93
+ if (!explicitAgentId) return true;
94
+ const sessionAgentId = parseAgentIdFromSessionKey(params.sessionKey);
95
+ if (!sessionAgentId) return isDefaultAgentSessionKeyForAgent({
96
+ config: params.config,
97
+ agentId: explicitAgentId
98
+ });
99
+ return sessionAgentId === explicitAgentId;
100
+ }
101
+ function isDefaultAgentSessionKeyForAgent(params) {
102
+ return normalizeAgentId(params.agentId) === tryResolveDefaultAgentId(params.config);
103
+ }
104
+ function normalizeAgentIdOrDefault(value) {
105
+ const normalized = normalizeAgentId(value);
106
+ return normalized === "main" && !(value ?? "").trim() ? void 0 : normalized;
107
+ }
108
+ function normalizeExecTarget(value) {
109
+ const normalized = value?.trim().toLowerCase();
110
+ if (normalized === "auto" || normalized === "sandbox" || normalized === "gateway" || normalized === "node") return normalized;
111
+ }
112
+ function resolveEffectiveExecHost(params) {
113
+ if (params.requestedExecHost === "auto") return params.sandboxAvailable ? "sandbox" : "gateway";
114
+ return params.requestedExecHost;
115
+ }
116
+ function readRuntimeSessionEntryBestEffort(params) {
117
+ try {
118
+ return getSessionEntry({
119
+ sessionKey: params.sessionKey,
120
+ agentId: params.agentId,
121
+ hydrateSkillPromptRefs: false
122
+ });
123
+ } catch {
124
+ return;
125
+ }
126
+ }
127
+ //#endregion
128
+ export { resolveCodexNativeExecutionPolicy as n, resolveCodexNodeExecToolOverrides as r, formatCodexNativeNodeExecBlock as t };