@openclaw/codex 2026.9.8 → 2026.10.1-beta.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 (151) hide show
  1. package/README.md +8 -0
  2. package/dist/.setup/{account-usage-runtime-G348lY1q.mjs → account-usage-runtime-DGqFpAud.mjs} +5 -5
  3. package/dist/.setup/app-server-policy-Bg4FZw1f.mjs +23 -0
  4. package/dist/.setup/{apply-Cqb-YoCS.mjs → apply-CXTudl9p.mjs} +48 -39
  5. package/dist/.setup/attempt-client-cleanup-BH0hW2xU.mjs +155 -0
  6. package/dist/.setup/{attempt-workspace-context-BJ5Z_olH.mjs → attempt-workspace-context-BY0jprWJ.mjs} +11 -15
  7. package/dist/.setup/{auth-binding-BLWz7stm.mjs → auth-binding-BoMwpuPN.mjs} +17 -25
  8. package/dist/.setup/{auth-cache-key-Dnps4W4_.mjs → auth-cache-key-CGm0UJOr.mjs} +244 -82
  9. package/dist/.setup/{auth-profile-B0okYl2D.mjs → auth-profile-CgHQ8Vot.mjs} +2 -1
  10. package/dist/.setup/{auth-profile-selection-DFu9e167.mjs → auth-profile-selection-hr8ocLtz.mjs} +5 -7
  11. package/dist/.setup/{binding-connection-DTtN1KrX.mjs → binding-connection-C-08ez1w.mjs} +2 -2
  12. package/dist/.setup/{binding-connection.runtime-6TpgD1M6.mjs → binding-connection.runtime-Dn2p-fdy.mjs} +3 -3
  13. package/dist/.setup/{bounded-turn-isolation-B8K_ylqk.mjs → bounded-turn-isolation-DklXNk3k.mjs} +4 -4
  14. package/dist/.setup/{bounded-turn-BNunZPtz.mjs → bounded-turn-pGsfXcmH.mjs} +14 -13
  15. package/dist/.setup/{build-state-DIQ5O_-S.mjs → build-state-CqQnsg7T.mjs} +1 -1
  16. package/dist/.setup/{capabilities-B3WEZl4e.mjs → capabilities-kQntafj_.mjs} +1 -1
  17. package/dist/.setup/{client-qyUBJlGZ.mjs → client-C8lgBOoO.mjs} +438 -160
  18. package/dist/.setup/{client-catalog-response-DRvx_wCC.mjs → client-catalog-response-Bqp7WG51.mjs} +57 -25
  19. package/dist/.setup/command-authorization-AikPDtcc.mjs +15 -0
  20. package/dist/.setup/{command-dispatch-Btrs1D6f.mjs → command-dispatch-DhBbFIQ5.mjs} +3 -3
  21. package/dist/.setup/{command-formatters-R3ckE3Co.mjs → command-formatters-DV3DHhdr.mjs} +7 -5
  22. package/dist/.setup/{command-handlers-DvlCHJch.mjs → command-handlers-ztOOzm6O.mjs} +82 -144
  23. package/dist/.setup/{command-rpc-skzRq4wD.mjs → command-rpc-CuC5fPom.mjs} +23 -31
  24. package/dist/.setup/{compact-8ttks5U5.mjs → compact-tUb9AYfH.mjs} +117 -65
  25. package/dist/.setup/{plugin-metadata-cache-BRwtRct9.mjs → computer-use-BBN9y326.mjs} +65 -202
  26. package/dist/.setup/{config-DKhXquav.mjs → config-0Gxk3_eq.mjs} +5 -6
  27. package/dist/.setup/{config-options-CzyWLTJt.mjs → config-options-HG_Rr3W_.mjs} +13 -23
  28. package/dist/.setup/{config-parsing-b088LyhT.mjs → config-parsing-BQq-CHTF.mjs} +41 -4
  29. package/dist/.setup/{config-runtime-C0NbLms1.mjs → config-runtime-cUYrqu_a.mjs} +2 -2
  30. package/dist/.setup/{config-security-CE-FcGw9.mjs → config-security-KAPScztc.mjs} +20 -36
  31. package/dist/.setup/{context-engine-projection-PezSESth.mjs → context-engine-projection-CsgYSQhW.mjs} +11 -14
  32. package/dist/.setup/{conversation-binding-74LaGGH-.mjs → conversation-binding-B3MNMVzb.mjs} +36 -48
  33. package/dist/.setup/{conversation-binding-data-C746z5Pn.mjs → conversation-binding-data-DJ4ix-W5.mjs} +1 -1
  34. package/dist/.setup/{conversation-control-OrN6zuaY.mjs → conversation-control-CYsMlCuE.mjs} +19 -21
  35. package/dist/.setup/{cyber-failover-XV0nNRZu.mjs → cyber-failover-Bb1J6hS1.mjs} +1 -1
  36. package/dist/.setup/{cyber-failover-notice-RNpGpTyP.mjs → cyber-failover-notice-XR03ef31.mjs} +1 -1
  37. package/dist/.setup/doctor-start-options-DPW9JxIE.mjs +63 -0
  38. package/dist/.setup/dynamic-tool-build-C8xGEXmR.mjs +463 -0
  39. package/dist/.setup/{dynamic-tools-Db2sY5cZ.mjs → dynamic-tools-DyERJnR6.mjs} +238 -878
  40. package/dist/.setup/{effective-mcp-catalog-Bi6-SQ7i.mjs → effective-mcp-catalog-C26Mio5l.mjs} +83 -11
  41. package/dist/.setup/{elicitation-input-DPoK8F7w.mjs → elicitation-input-r9axtppm.mjs} +4 -2
  42. package/dist/.setup/{ephemeral-turn-DiCS1ijR.mjs → ephemeral-turn-D8VcDTNo.mjs} +2 -2
  43. package/dist/.setup/{event-projector-assistant-message-MV_1dj-3.mjs → event-projector-assistant-message-BN7CNUB5.mjs} +2 -2
  44. package/dist/.setup/{event-projector-values-DJSz8BTk.mjs → event-projector-values-DTqZHizf.mjs} +2 -12
  45. package/dist/.setup/{inference-dispatch-CMZtjQyz.mjs → inference-dispatch-B5UKEUyC.mjs} +12 -21
  46. package/dist/.setup/{inference-proxy-DhcXOgUE.mjs → inference-proxy-DUO5E2QQ.mjs} +6 -5
  47. package/dist/.setup/{isolated-completion-D80IXfQF.mjs → isolated-completion-C0jrcplS.mjs} +8 -8
  48. package/dist/.setup/{managed-binary-kiWRhNRE.mjs → managed-binary-C1VFoVPf.mjs} +31 -38
  49. package/dist/.setup/mcp-app-session-preparation-BxN0_CYe.mjs +223 -0
  50. package/dist/.setup/mcp-tool-metadata-j10HhfTC.mjs +43 -0
  51. package/dist/.setup/{model-catalog-DiC0Tkha.mjs → model-catalog-DZyNeDKG.mjs} +7 -7
  52. package/dist/.setup/{models-DfLmPV0k.mjs → models-DSseKSMg.mjs} +10 -7
  53. package/dist/.setup/{native-auth-CuG53tu4.mjs → native-auth-Cjb9y7IZ.mjs} +5 -6
  54. package/dist/.setup/{native-execution-policy-BxZJy5mP.mjs → native-execution-policy-ClzpdG3D.mjs} +1 -12
  55. package/dist/.setup/native-mcp-app-CqcPVmhH.mjs +310 -0
  56. package/dist/.setup/{native-subagent-monitor-BwkQXf9e.mjs → native-subagent-monitor-BUYOUp9X.mjs} +235 -318
  57. package/dist/.setup/{native-subagent-pending-assignments-DwkCzLvD.mjs → native-subagent-pending-assignments-BDqhOdJp.mjs} +0 -4
  58. package/dist/.setup/{native-task-assignments-DMQ0g3hu.mjs → native-task-assignments-C6KVqiN1.mjs} +9 -8
  59. package/dist/.setup/{node-cli-sessions-HC4W6FLI.mjs → node-cli-sessions-B5oNDkUS.mjs} +11 -17
  60. package/dist/.setup/{node-exec-server.runtime-BgBfWQqo.mjs → node-exec-server.runtime-0xSEjKYt.mjs} +2 -2
  61. package/dist/.setup/{plan-DPdMk1Oy.mjs → plan-BJ37d2Og.mjs} +67 -89
  62. package/dist/.setup/{plugin-activation-cNHRfaxU.mjs → plugin-activation-BcyBv8PG.mjs} +4 -4
  63. package/dist/.setup/{plugin-app-cache-key-BL9B5H0L.mjs → plugin-app-cache-key-BW8rd98k.mjs} +11 -15
  64. package/dist/.setup/plugin-approval-roundtrip-CuahdPLC.mjs +109 -0
  65. package/dist/.setup/{plugin-inventory-Cky2XJUw.mjs → plugin-inventory-Bf0_piTw.mjs} +29 -51
  66. package/dist/.setup/{plugin-marketplace-discovery-D_dV9FXa.mjs → plugin-marketplace-discovery-SQPhSuic.mjs} +2 -16
  67. package/dist/.setup/plugin-metadata-cache-DWnB7VMj.mjs +84 -0
  68. package/dist/.setup/plugin-thread-config-deadline-B8LGaZNW.mjs +124 -0
  69. package/dist/.setup/{provider-D6F_7p1I.mjs → provider-BnwHVD_z.mjs} +4 -4
  70. package/dist/.setup/provider-capabilities-D68Whix6.mjs +50 -0
  71. package/dist/.setup/{rate-limits-B7-X2TgG.mjs → rate-limits-CMPy24F5.mjs} +1 -5
  72. package/dist/.setup/{request-BZOfsSXW.mjs → request-jSbhc1sg.mjs} +189 -49
  73. package/dist/.setup/rpc-error-hmWM21RB.mjs +57 -0
  74. package/dist/.setup/{run-attempt-dYJhjZrp.mjs → run-attempt-BLDZeYLD.mjs} +553 -727
  75. package/dist/.setup/{run-attempt-lifecycle-C-6O3Exn.mjs → run-attempt-lifecycle-BuZgVbDA.mjs} +19 -3
  76. package/dist/.setup/{runtime-artifact-DDQ-HGXf.mjs → runtime-artifact-CUTOOnKw.mjs} +5 -6
  77. package/dist/.setup/{runtime-artifact-connection-D68qQn1m.mjs → runtime-artifact-connection-CADz3_BY.mjs} +5 -4
  78. package/dist/.setup/{sandbox-guard-DjCz2eOw.mjs → sandbox-guard-WqE8yPge.mjs} +3 -3
  79. package/dist/.setup/service-tier-normalization-Cei89SW6.mjs +15 -0
  80. package/dist/.setup/{session-binding-DGCYAfvD.mjs → session-binding-Ce7BqiPN.mjs} +92 -102
  81. package/dist/.setup/session-binding-meta-Lkm5Lpf4.mjs +15 -0
  82. package/dist/.setup/session-binding-record-BZB8RgcF.mjs +179 -0
  83. package/dist/.setup/session-binding-record-codec-z4ZpDn6E.mjs +216 -0
  84. package/dist/.setup/{session-binding-sidecars-jo6H8dFr.mjs → session-binding-sidecars-BrdV95Fg.mjs} +8 -2
  85. package/dist/.setup/{session-catalog-adoption-BU_pHWG7.mjs → session-catalog-adoption-CPIP4S_y.mjs} +34 -18
  86. package/dist/.setup/{session-catalog-archive-spHfihri.mjs → session-catalog-archive-DcgwvSbF.mjs} +24 -29
  87. package/dist/.setup/{session-catalog-events-BMCFMZw-.mjs → session-catalog-events-Bdjw9HEn.mjs} +5 -5
  88. package/dist/.setup/{session-catalog-index-DwJjnF5k.mjs → session-catalog-index-DufISKJ6.mjs} +361 -72
  89. package/dist/.setup/{session-catalog-index-order-BcQpHks3.mjs → session-catalog-index-order-nhyO0wdW.mjs} +1 -1
  90. package/dist/.setup/{session-catalog-limits-DDxOsQeC.mjs → session-catalog-limits-DEU36Qlo.mjs} +1 -1
  91. package/dist/.setup/{session-catalog-index-state-TeO7EyO-.mjs → session-catalog-list-request-tXephOB4.mjs} +180 -6
  92. package/dist/.setup/{session-catalog-native-projection-CuaFZuQE.mjs → session-catalog-native-projection-D6IiLtMb.mjs} +7 -6
  93. package/dist/.setup/{session-catalog-node-adoption-DgXvSGu0.mjs → session-catalog-node-adoption-7-WEQTB1.mjs} +12 -2
  94. package/dist/.setup/{session-catalog-node-continue-DjKXHBbi.mjs → session-catalog-node-continue-DLWBwAAO.mjs} +11 -15
  95. package/dist/.setup/{session-catalog-node-lookup-CtAXI5W5.mjs → session-catalog-node-lookup-Uufckwcm.mjs} +2 -2
  96. package/dist/.setup/{session-catalog-parsing-CPGaPYr-.mjs → session-catalog-parsing-B-qWJh2x.mjs} +70 -28
  97. package/dist/.setup/{session-catalog-projection-CGfzfP93.mjs → session-catalog-projection-8aHNwzWD.mjs} +6 -122
  98. package/dist/.setup/{session-catalog-provenance-DoAvktcj.mjs → session-catalog-provenance-CmsOE5mh.mjs} +6 -1
  99. package/dist/.setup/{session-cli-DlmBHYIe.mjs → session-cli-kH4vuGod.mjs} +1 -2
  100. package/dist/.setup/{session-history-D83lJWHG.mjs → session-history-BogBHKLk.mjs} +1 -1
  101. package/dist/.setup/{session-history-import-WhX-X33a.mjs → session-history-import-NWKPa4ZO.mjs} +4 -4
  102. package/dist/.setup/{session-history-read-Ov3StuL4.mjs → session-history-read-CNN8zwbD.mjs} +8 -19
  103. package/dist/.setup/{session-history.worker-MnPKncqP.mjs → session-history.worker-Cq_4DYgN.mjs} +3 -3
  104. package/dist/.setup/{session-initialization-6aveB9qb.mjs → session-initialization-D6dtFQkE.mjs} +2 -2
  105. package/dist/.setup/{session-permission-policy-Ci_fVX6y.mjs → session-permission-policy-BxIUJ0Zd.mjs} +8 -37
  106. package/dist/.setup/{session-retirement-LlYWBKTJ.mjs → session-retirement-Czbchv_O.mjs} +14 -15
  107. package/dist/.setup/{settled-turn-context-D4yj4rxf.mjs → settled-turn-context-BZsMjkIO.mjs} +13 -6
  108. package/dist/.setup/{settled-turn-finalizer-DW9W3gza.mjs → settled-turn-finalizer-DjZsIwbZ.mjs} +8 -8
  109. package/dist/.setup/{shared-client-CJCTeFpQ.mjs → shared-client-qhyYWbew.mjs} +291 -272
  110. package/dist/.setup/{provider-capabilities-DG5qbsUZ.mjs → shell-dynamic-tools-D3Brj3g9.mjs} +16 -55
  111. package/dist/.setup/{side-question-BLeGj7TQ.mjs → side-question-D3NJlgbl.mjs} +99 -91
  112. package/dist/.setup/{source-CJis_1EF.mjs → source-BYu0T780.mjs} +24 -40
  113. package/dist/.setup/{thread-lifecycle-_bAbjedG.mjs → thread-lifecycle-Cbz_7ySv.mjs} +262 -305
  114. package/dist/.setup/{thread-ownership-B6pPt21M.mjs → thread-ownership-DwuSrt3s.mjs} +10 -8
  115. package/dist/.setup/{thread-policy-gNPzzpVp.mjs → thread-policy-DoNxbhqt.mjs} +22 -21
  116. package/dist/.setup/{thread-requests-OWGOiDaV.mjs → thread-requests-CL1e8Wmx.mjs} +107 -98
  117. package/dist/.setup/{thread-resume-GOry0AYh.mjs → thread-resume-BT6NHMkM.mjs} +10 -18
  118. package/dist/.setup/{transcript-history-projection-DRSifI-1.mjs → transcript-history-projection-B9a7HwUV.mjs} +11 -16
  119. package/dist/.setup/{transcript-mirror-kxmCYsuF.mjs → transcript-mirror-BfLRARNL.mjs} +64 -67
  120. package/dist/.setup/{transport-stdio-Bdegpn2V.mjs → transport-stdio-a0HDa2Mj.mjs} +27 -8
  121. package/dist/.setup/{transport-websocket-BTBE-LD9.mjs → transport-websocket-zqJ0Cmtn.mjs} +3 -8
  122. package/dist/.setup/{attempt-client-cleanup-B-S7ngS_.mjs → turn-router-sS69wYnI.mjs} +75 -170
  123. package/dist/.setup/{upstream-session-fork-gkdRj2yH.mjs → upstream-session-fork-ChSld66u.mjs} +35 -46
  124. package/dist/.setup/{usage-CApUvLOV.mjs → usage-D8e8Xiqf.mjs} +4 -4
  125. package/dist/.setup/{usage-limit-error-wSMQkbpV.mjs → usage-limit-error-GbT-5NcW.mjs} +4 -4
  126. package/dist/.setup/{web-search-provider.runtime-UKgeiBUG.mjs → web-search-provider.runtime-dL2GD1Kl.mjs} +4 -20
  127. package/dist/.setup/websocket-data-XlRvt8Ys.mjs +6 -0
  128. package/dist/.setup/workspace-write-sandbox-probe-DmUHLrrl.mjs +118 -0
  129. package/dist/api.js +34 -54
  130. package/dist/catalog-page.worker.js +1 -1
  131. package/dist/cli-metadata.js +1 -1
  132. package/dist/doctor-contract-api.js +15 -27
  133. package/dist/harness.js +37 -22
  134. package/dist/index.js +2880 -276
  135. package/dist/media-understanding-provider.js +2 -2
  136. package/dist/migration-provider-api.js +1 -1
  137. package/dist/native-session-binding-api.js +2 -0
  138. package/dist/provider-discovery.js +1 -1
  139. package/dist/session-history-worker-runtime.js +33 -4
  140. package/dist/session-history.worker.js +1 -1
  141. package/openclaw.plugin.json +3 -3
  142. package/package.json +6 -6
  143. package/dist/.setup/config-utils-D0CXecki.mjs +0 -57
  144. package/dist/.setup/incognito-session-DWYapfwf.mjs +0 -2
  145. package/dist/.setup/managed-thread-store-BMqgThVL.mjs +0 -100
  146. package/dist/.setup/rpc-error-BlD2vuzn.mjs +0 -31
  147. package/dist/.setup/session-binding-meta-B7aEMU7g.mjs +0 -6
  148. package/dist/.setup/session-binding-record-Oe9L-CNY.mjs +0 -375
  149. package/dist/.setup/session-catalog-BFafIiF6.mjs +0 -2599
  150. package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +0 -170
  151. package/dist/.setup/shared-client-lifecycle-7xgtlo15.mjs +0 -153
@@ -1,21 +1,18 @@
1
1
  import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
2
- import { d as retireSharedCodexAppServerClientIfCurrent } from "./shared-client-lifecycle-7xgtlo15.mjs";
3
- import { n as CodexAppServerRpcError } from "./rpc-error-BlD2vuzn.mjs";
4
2
  import { n as waitForPromiseOrAbort, t as abortReason } from "./timeout-CXOfNoaX.mjs";
5
- import { J as unsubscribeCodexAppServerLiveThread, ft as isCodexAppServerStartupError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-CJCTeFpQ.mjs";
6
- import { E as readCodexTurnCompletedNotification, a as isCodexAppServerBrokenPipeError, d as isCodexAppServerRequestTimeoutError, l as isCodexAppServerOverloadError } from "./client-qyUBJlGZ.mjs";
7
- import { t as __exportAll } from "./session-binding-sidecars-jo6H8dFr.mjs";
3
+ import { x as readCodexTurnCompletedNotification } from "./client-C8lgBOoO.mjs";
8
4
  import { normalizeOptionalString, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
9
5
  import { AsyncResource } from "node:async_hooks";
10
6
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
11
7
  import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
12
- import { AgentHarnessPreflightError, embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
8
+ import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
13
9
  import { redactSensitiveText } from "openclaw/plugin-sdk/logging-core";
14
10
  //#region extensions/codex/src/app-server/event-projector-items.ts
15
11
  const itemStatuses = /* @__PURE__ */ new Map([
16
12
  ["completed", "completed"],
17
13
  ["failed", "failed"],
18
14
  ["error", "failed"],
15
+ ["interrupted", "failed"],
19
16
  ["declined", "blocked"],
20
17
  ["inProgress", "running"],
21
18
  ["in_progress", "running"],
@@ -144,6 +141,15 @@ function readCodexNotificationThreadId(record) {
144
141
  function readCodexNotificationTurnId(record) {
145
142
  return (isJsonObject(record.turn) ? normalizeOptionalString(record.turn.id) : void 0) ?? normalizeOptionalString(record.turnId);
146
143
  }
144
+ function readCodexNotificationScope(value) {
145
+ if (!isJsonObject(value)) return {};
146
+ const threadId = readCodexNotificationThreadId(value);
147
+ const turnId = readCodexNotificationTurnId(value);
148
+ return {
149
+ ...threadId ? { threadId } : {},
150
+ ...turnId ? { turnId } : {}
151
+ };
152
+ }
147
153
  //#endregion
148
154
  //#region extensions/codex/src/app-server/event-projector-diagnostics.ts
149
155
  function redactCodexEventKind(method) {
@@ -192,6 +198,52 @@ var CodexProjectionDiagnostics = class {
192
198
  }
193
199
  };
194
200
  //#endregion
201
+ //#region extensions/codex/src/app-server/mcp-request-route.ts
202
+ /** Subscope of the physical client router; there is no independent connection or registry. */
203
+ var CodexMcpRequestRoutes = class {
204
+ constructor() {
205
+ this.routes = /* @__PURE__ */ new Map();
206
+ }
207
+ hasSiblingWork(threadId) {
208
+ return [...this.routes.values()].some((route) => route.threadId !== threadId);
209
+ }
210
+ async run(options, operation) {
211
+ options.signal?.throwIfAborted();
212
+ const key = JSON.stringify([options.threadId, options.serverName]);
213
+ if (this.routes.has(key)) throw new Error("An MCP App call is already pending for this server in the conversation");
214
+ const route = {
215
+ threadId: options.threadId,
216
+ controller: new AbortController(),
217
+ onRequest: AsyncResource.bind(options.onRequest)
218
+ };
219
+ const abort = () => route.controller.abort(options.signal?.reason);
220
+ options.signal?.addEventListener("abort", abort, { once: true });
221
+ this.routes.set(key, route);
222
+ try {
223
+ return await operation();
224
+ } finally {
225
+ options.signal?.removeEventListener("abort", abort);
226
+ this.routes.delete(key);
227
+ route.controller.abort(/* @__PURE__ */ new Error("MCP App call ended"));
228
+ }
229
+ }
230
+ route(request, scope, signal, setExecutionTimeoutMs) {
231
+ if (scope.turnId || request.method !== "mcpServer/elicitation/request" || !isJsonObject(request.params) || typeof request.params.serverName !== "string") return;
232
+ const route = this.routes.get(JSON.stringify([scope.threadId, request.params.serverName]));
233
+ if (!route) return;
234
+ return (async () => {
235
+ const requestSignal = AbortSignal.any([signal, route.controller.signal]);
236
+ requestSignal.throwIfAborted();
237
+ const result = await route.onRequest(request, scope, requestSignal, setExecutionTimeoutMs);
238
+ return requestSignal.aborted ? void 0 : result;
239
+ })();
240
+ }
241
+ close(error) {
242
+ for (const route of this.routes.values()) route.controller.abort(error);
243
+ this.routes.clear();
244
+ }
245
+ };
246
+ //#endregion
195
247
  //#region extensions/codex/src/app-server/turn-router.ts
196
248
  const DEFAULT_PREBIND_NOTIFICATION_LIMIT = 256;
197
249
  const DEFAULT_GLOBAL_WARNING_LIMIT = 32;
@@ -209,18 +261,23 @@ function getCodexAppServerTurnRouter(client) {
209
261
  }
210
262
  var ClientTurnRouter = class {
211
263
  hasSiblingWork(threadId) {
212
- for (const routedThreadId of this.routes.keys()) if (routedThreadId !== threadId) return true;
213
- for (const watchedThreadId of this.nativeTurnCompletionWatchers.keys()) if (watchedThreadId !== threadId) return true;
264
+ if (this.mcpRequests.hasSiblingWork(threadId)) return true;
265
+ for (const threads of [this.routes, this.nativeTurnCompletionWatchers]) for (const siblingThreadId of threads.keys()) if (siblingThreadId !== threadId) return true;
214
266
  return false;
215
267
  }
216
268
  constructor(client) {
217
269
  this.routes = /* @__PURE__ */ new Map();
270
+ this.mcpRequests = new CodexMcpRequestRoutes();
218
271
  this.globalWarnings = [];
219
272
  this.nativeTurnCompletionWatchers = /* @__PURE__ */ new Map();
220
273
  client.addNotificationHandler((notification) => this.routeNotification(notification));
221
274
  client.addRequestHandler((request, signal, setExecutionTimeoutMs) => this.routeRequest(request, signal, setExecutionTimeoutMs));
222
275
  client.addCloseHandler((closedClient) => this.dispose(closedClient.getCloseError()));
223
276
  }
277
+ async withMcpToolCall(options, run) {
278
+ this.assertActive();
279
+ return await this.mcpRequests.run(options, run);
280
+ }
224
281
  reserveThread(options) {
225
282
  this.assertActive();
226
283
  const threadId = requireId(options.threadId, "thread id");
@@ -315,6 +372,7 @@ var ClientTurnRouter = class {
315
372
  if (this.closeError) return;
316
373
  const closeError = cause ? new Error("codex app-server turn router closed", { cause }) : /* @__PURE__ */ new Error("codex app-server turn router closed");
317
374
  this.closeError = closeError;
375
+ this.mcpRequests.close(closeError);
318
376
  for (const route of this.routes.values()) this.release(route, closeError);
319
377
  for (const watchers of this.nativeTurnCompletionWatchers.values()) for (const watcher of watchers) watcher.finish(false);
320
378
  }
@@ -383,7 +441,7 @@ var ClientTurnRouter = class {
383
441
  }
384
442
  routeNotification(notification) {
385
443
  if (this.closeError) return;
386
- const scope = readScope(notification.params);
444
+ const scope = readCodexNotificationScope(notification.params);
387
445
  if (!scope.threadId && (notification.method === "configWarning" || notification.method === "warning")) {
388
446
  if (this.globalWarnings.length === DEFAULT_GLOBAL_WARNING_LIMIT) this.globalWarnings.shift();
389
447
  this.globalWarnings.push(notification);
@@ -443,8 +501,13 @@ var ClientTurnRouter = class {
443
501
  }
444
502
  async routeRequest(request, signal = new AbortController().signal, setExecutionTimeoutMs) {
445
503
  if (this.closeError || signal.aborted) return;
446
- const scope = readScope(request.params);
504
+ const scope = readCodexNotificationScope(request.params);
447
505
  if (!scope.threadId) return;
506
+ const manual = this.mcpRequests.route(request, {
507
+ threadId: scope.threadId,
508
+ ...scope.turnId ? { turnId: scope.turnId } : {}
509
+ }, signal, setExecutionTimeoutMs);
510
+ if (manual) return await manual;
448
511
  const route = this.routes.get(scope.threadId);
449
512
  if (!route) return;
450
513
  const requestSignal = AbortSignal.any([signal, route.controller.signal]);
@@ -477,7 +540,7 @@ var ClientTurnRouter = class {
477
540
  const handler = route.handlers?.onNotification;
478
541
  if (!handler) return;
479
542
  for (const pending of route.pending.splice(0)) {
480
- if (route.gate !== "bound" && (pending.notification.method === "configWarning" || pending.notification.method === "warning" && !readScope(pending.notification.params).threadId)) {
543
+ if (route.gate !== "bound" && (pending.notification.method === "configWarning" || pending.notification.method === "warning" && !readCodexNotificationScope(pending.notification.params).threadId)) {
481
544
  route.pending.push(pending);
482
545
  continue;
483
546
  }
@@ -562,168 +625,10 @@ var ClientTurnRouter = class {
562
625
  if (route.released && !this.canDrainClosedTurn(route, completedTurnId)) throw route.released;
563
626
  }
564
627
  };
565
- function readScope(value) {
566
- if (!isJsonObject(value)) return {};
567
- const threadId = readCodexNotificationThreadId(value);
568
- const turnId = readCodexNotificationTurnId(value);
569
- return {
570
- ...threadId ? { threadId } : {},
571
- ...turnId ? { turnId } : {}
572
- };
573
- }
574
628
  function requireId(value, label) {
575
629
  const normalized = value.trim();
576
630
  if (!normalized) throw new Error(`codex app-server ${label} must not be empty`);
577
631
  return normalized;
578
632
  }
579
633
  //#endregion
580
- //#region extensions/codex/src/app-server/attempt-client-cleanup.ts
581
- var attempt_client_cleanup_exports = /* @__PURE__ */ __exportAll({
582
- CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS: () => CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS,
583
- CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS: () => CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS,
584
- CodexAppServerUnsafeSubscriptionError: () => CodexAppServerUnsafeSubscriptionError,
585
- assertCodexThreadResumeSubscription: () => assertCodexThreadResumeSubscription,
586
- closeCodexStartupClientBestEffort: () => closeCodexStartupClientBestEffort,
587
- interruptCodexTurnAndWaitBestEffort: () => interruptCodexTurnAndWaitBestEffort,
588
- isCodexAppServerUnsafeSubscriptionError: () => isCodexAppServerUnsafeSubscriptionError,
589
- isCodexNoActiveTurnInterruptError: () => isCodexNoActiveTurnInterruptError,
590
- retireUnsafeCodexTurnClientBestEffort: () => retireUnsafeCodexTurnClientBestEffort,
591
- shouldRetireCodexStartupClient: () => shouldRetireCodexStartupClient,
592
- terminateCodexBackgroundTerminals: () => terminateCodexBackgroundTerminals,
593
- unsubscribeCodexThreadBestEffort: () => unsubscribeCodexThreadBestEffort
594
- });
595
- const CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS = 5e3;
596
- const CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS = 5e3;
597
- const CODEX_NO_ACTIVE_TURN_ERROR_CODE = -32600;
598
- const CODEX_NO_ACTIVE_TURN_ERROR_MESSAGE = "no active turn to interrupt";
599
- /** Codex also reports this before an accepted turn publishes its start event. */
600
- function isCodexNoActiveTurnInterruptError(error) {
601
- return error instanceof CodexAppServerRpcError && error.code === CODEX_NO_ACTIVE_TURN_ERROR_CODE && error.message === CODEX_NO_ACTIVE_TURN_ERROR_MESSAGE;
602
- }
603
- /** Raised when a thread subscription may be live on a client OpenClaw no longer controls. */
604
- var CodexAppServerUnsafeSubscriptionError = class extends Error {
605
- constructor(message, options) {
606
- super(message, options);
607
- this.name = "CodexAppServerUnsafeSubscriptionError";
608
- }
609
- };
610
- function isCodexAppServerUnsafeSubscriptionError(error) {
611
- return error instanceof CodexAppServerUnsafeSubscriptionError;
612
- }
613
- function assertCodexThreadResumeSubscription(requestedThreadId, returnedThreadId) {
614
- if (returnedThreadId !== requestedThreadId) throw new CodexAppServerUnsafeSubscriptionError(`Codex thread/resume returned ${returnedThreadId} for ${requestedThreadId}`);
615
- }
616
- async function closeCodexStartupClientBestEffort(client) {
617
- if (!client) return;
618
- const retiredSharedClient = retireSharedCodexAppServerClientIfCurrent(client);
619
- if (!retiredSharedClient || retiredSharedClient.closed) await client.closeAndWait();
620
- }
621
- /** Retires an unsafe turn client without replacing an already-authoritative failure. */
622
- async function retireUnsafeCodexTurnClientBestEffort(client, operation) {
623
- try {
624
- await closeCodexStartupClientBestEffort(client);
625
- } catch (error) {
626
- embeddedAgentLog.debug("codex app-server unsafe turn client retirement failed", {
627
- operation,
628
- error
629
- });
630
- try {
631
- client.close();
632
- } catch (closeError) {
633
- embeddedAgentLog.debug("codex app-server unsafe turn client close failed", {
634
- operation,
635
- error: closeError
636
- });
637
- }
638
- }
639
- }
640
- /** Sends a bounded turn interrupt and waits for Codex to confirm terminal abort handling. */
641
- async function interruptCodexTurnAndWaitBestEffort(client, params) {
642
- const timeoutMs = params.timeoutMs && Number.isFinite(params.timeoutMs) && params.timeoutMs > 0 ? params.timeoutMs : CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS;
643
- const requestParams = {
644
- threadId: params.threadId,
645
- turnId: params.turnId
646
- };
647
- let cancelWatch;
648
- try {
649
- if (!params.turnId) {
650
- await client.request("turn/interrupt", requestParams, { timeoutMs });
651
- return true;
652
- }
653
- const deadline = Date.now() + timeoutMs;
654
- const started = createDeferred();
655
- const completion = getCodexAppServerTurnRouter(client).watchNativeTurnCompletion({
656
- threadId: params.threadId,
657
- turnId: params.turnId,
658
- timeoutMs,
659
- onStarted: () => started.resolve(true)
660
- });
661
- cancelWatch = completion.cancel;
662
- if (completion.state !== "pending") return await completion.completion;
663
- const requestInterrupt = async () => {
664
- try {
665
- await client.request("turn/interrupt", requestParams, {
666
- timeoutMs: Math.max(1, deadline - Date.now()),
667
- signal: completion.settledSignal
668
- });
669
- return true;
670
- } catch (error) {
671
- if (completion.state === "confirmed") return true;
672
- if (isCodexNoActiveTurnInterruptError(error)) return false;
673
- throw error;
674
- }
675
- };
676
- if (!await requestInterrupt()) {
677
- if (await Promise.race([completion.completion.then(() => false), started.promise]) && completion.state === "pending" && Date.now() < deadline) await requestInterrupt();
678
- }
679
- return await completion.completion;
680
- } catch (error) {
681
- embeddedAgentLog.debug("codex app-server turn interrupt failed during abort", { error });
682
- return false;
683
- } finally {
684
- cancelWatch?.();
685
- }
686
- }
687
- /** Stops native terminals on the cancelled thread without retiring peer threads. */
688
- async function terminateCodexBackgroundTerminals(client, threadId, oneShotCliRun = false, waitForNativeItems) {
689
- const options = {
690
- timeoutMs: CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS,
691
- signal: AbortSignal.timeout(CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS)
692
- };
693
- try {
694
- const { data } = await client.request("thread/backgroundTerminals/list", { threadId }, options);
695
- for (const { processId } of data) await client.request("thread/backgroundTerminals/terminate", {
696
- threadId,
697
- processId
698
- }, options);
699
- if (data.length > 0) {
700
- if ((await client.request("thread/backgroundTerminals/list", {
701
- threadId,
702
- limit: 1
703
- }, options)).data.length > 0) throw new Error("native background terminals remain running");
704
- if (oneShotCliRun) throw new Error("native terminal termination did not confirm process cleanup");
705
- }
706
- await waitForNativeItems?.(options.signal);
707
- } catch (cause) {
708
- throw new Error("Codex background-terminal cleanup failed; inspect the thread's running terminals before starting more work.", { cause });
709
- }
710
- }
711
- async function unsubscribeCodexThreadBestEffort(client, params) {
712
- try {
713
- await unsubscribeCodexAppServerLiveThread(client, params.threadId, params.timeoutMs, params.assertCurrent);
714
- return true;
715
- } catch (error) {
716
- params.assertCurrent?.();
717
- embeddedAgentLog.debug("codex app-server thread unsubscribe cleanup failed", {
718
- threadId: params.threadId,
719
- error
720
- });
721
- return false;
722
- }
723
- }
724
- function shouldRetireCodexStartupClient(error, spawnedBy, signal) {
725
- if (signal.aborted || isCodexAppServerStartupError(error) || isCodexAppServerRequestTimeoutError(error)) return true;
726
- return !isCodexAppServerStartSelectionChangedError(error) && !isCodexAppServerOverloadError(error) && !(error instanceof AgentHarnessPreflightError && error.scope === void 0) && (isCodexAppServerBrokenPipeError(error) || !spawnedBy);
727
- }
728
- //#endregion
729
- export { itemStatus as A, auditNativeToolUnfinishedStatus as C, isSideEffectingNativeToolItem as D, isProjectedNativeToolItem as E, matchesCodexSnapshotTurn as M, shouldClearTerminalPresentationForNativeItem as N, itemKind as O, unknownItemStatus as P, auditNativeToolTerminalStatus as S, isNonSuccessItemStatus as T, CodexProjectionDiagnostics as _, attempt_client_cleanup_exports as a, readCodexNotificationTurnId as b, isCodexAppServerUnsafeSubscriptionError as c, shouldRetireCodexStartupClient as d, terminateCodexBackgroundTerminals as f, hasCodexAppServerSiblingRouteWork as g, getCodexAppServerTurnRouter as h, assertCodexThreadResumeSubscription as i, itemTitle as j, itemName as k, isCodexNoActiveTurnInterruptError as l, CODEX_APP_SERVER_NATIVE_TURN_WAIT_TIMEOUT_MS as m, CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS as n, closeCodexStartupClientBestEffort as o, unsubscribeCodexThreadBestEffort as p, CodexAppServerUnsafeSubscriptionError as r, interruptCodexTurnAndWaitBestEffort as s, CODEX_APP_SERVER_INTERRUPT_TIMEOUT_MS as t, retireUnsafeCodexTurnClientBestEffort as u, isCodexNotificationForTurn as v, isMutatingNativeToolItem as w, auditNativeToolName as x, readCodexNotificationThreadId as y };
634
+ export { itemStatus as _, isCodexNotificationForTurn as a, shouldClearTerminalPresentationForNativeItem as b, auditNativeToolName as c, isMutatingNativeToolItem as d, isNonSuccessItemStatus as f, itemName as g, itemKind as h, CodexProjectionDiagnostics as i, auditNativeToolTerminalStatus as l, isSideEffectingNativeToolItem as m, getCodexAppServerTurnRouter as n, readCodexNotificationThreadId as o, isProjectedNativeToolItem as p, hasCodexAppServerSiblingRouteWork as r, readCodexNotificationTurnId as s, CODEX_APP_SERVER_NATIVE_TURN_WAIT_TIMEOUT_MS as t, auditNativeToolUnfinishedStatus as u, itemTitle as v, unknownItemStatus as x, matchesCodexSnapshotTurn as y };
@@ -1,37 +1,39 @@
1
1
  import { i as isJsonObject, r as flattenCodexDynamicToolFunctions } from "./protocol-CANUwXJ3.mjs";
2
- import { v as sessionBindingIdentity } from "./session-binding-record-Oe9L-CNY.mjs";
3
- import { d as readCodexPluginConfig } from "./config-parsing-b088LyhT.mjs";
4
- import { s as assertCodexModelBackedReviewerEffectiveConfig } from "./config-options-CzyWLTJt.mjs";
2
+ import { m as sessionBindingIdentity } from "./session-binding-record-BZB8RgcF.mjs";
3
+ import { d as readCodexPluginConfig } from "./config-parsing-BQq-CHTF.mjs";
4
+ import { s as assertCodexModelBackedReviewerEffectiveConfig } from "./config-options-HG_Rr3W_.mjs";
5
5
  import { t as withCodexAppServerThreadMutation } from "./thread-ownership-queue-Dp24d7-F.mjs";
6
+ import { i as CodexAppServerScopedRequestRejectedError, o as isCodexAppServerOverloadError } from "./rpc-error-hmWM21RB.mjs";
6
7
  import { i as readUpstreamUserText, r as readMirrorIdentity } from "./upstream-prompt-provenance-fXkKbPVC.mjs";
7
- import { r as projectCodexUserItemText } from "./transcript-history-projection-DRSifI-1.mjs";
8
+ import { r as projectCodexUserItemText } from "./transcript-history-projection-B9a7HwUV.mjs";
8
9
  import { n as codexUpstreamBaseline, t as codexLastTerminalTurnId } from "./session-upstream-marker-D15C9NHp.mjs";
9
- import { r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-BL9B5H0L.mjs";
10
- import { n as readCodexSessionMeta } from "./session-catalog-provenance-DoAvktcj.mjs";
11
- import { t as CodexAppServerScopedRequestRejectedError } from "./request-BZOfsSXW.mjs";
12
- import { r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-DKhXquav.mjs";
13
- import { r as resolveCodexSupervisionAppServerRuntimeOptions } from "./config-runtime-C0NbLms1.mjs";
10
+ import { r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-BW8rd98k.mjs";
11
+ import { n as readCodexSessionMeta } from "./session-catalog-provenance-CmsOE5mh.mjs";
12
+ import "./request-jSbhc1sg.mjs";
13
+ import { r as resolveOpenClawExecPolicyForCodexAppServer } from "./config-0Gxk3_eq.mjs";
14
+ import { r as resolveCodexSupervisionAppServerRuntimeOptions } from "./config-runtime-cUYrqu_a.mjs";
14
15
  import { a as fingerprintCodexMirrorSourceMessage, c as readCodexMirrorSourceFingerprint } from "./transcript-mirror-attestation-YSegaktH.mjs";
15
- import { P as claimCodexAppServerLiveThread, R as hasCodexAppServerLiveThread, f as readCodexAppServerClientDesktopGenerationFingerprint } from "./shared-client-CJCTeFpQ.mjs";
16
- import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError, v as assertCodexThreadAcceptsDirectInput, y as assertCodexThreadForkResponse } from "./client-qyUBJlGZ.mjs";
17
- import { D as buildCodexNativeHookRelayConfig, E as assertCodexNativeHookRelayAllowed, H as applyCodexNativeSkillIsolation, I as checkCodexThreadAppAvailability, K as codexDynamicToolsFingerprint, M as resolveCodexNativeHookRelayEvents, St as mergeCodexThreadConfigs, U as resolveCodexNativeSkillIsolation, V as parseCodexNativeToolCatalog, X as fingerprintJsonObject, Z as fingerprintUserMcpServersConfigPatch, a as buildCodexThreadConfiguration, h as buildDeveloperInstructions, ht as buildCodexPluginThreadConfig, k as buildCodexNativeHookRelayId, p as resolveCodexWebSearchPlan, wt as shouldBuildCodexPluginThreadConfig } from "./thread-requests-OWGOiDaV.mjs";
18
- import "./session-binding-DGCYAfvD.mjs";
19
- import { a as refreshCodexThreadPolicy, n as CodexThreadPolicyHandoffError } from "./thread-policy-gNPzzpVp.mjs";
20
- import "./thread-ownership-B6pPt21M.mjs";
21
- import { n as resolveCodexNativeExecutionPolicy } from "./native-execution-policy-BxZJy5mP.mjs";
22
- import { l as prepareCodexWorkspaceDeveloperInstructions } from "./attempt-workspace-context-BJ5Z_olH.mjs";
23
- import { d as isCodexDynamicToolExcluded, n as resolveCodexProviderWebSearchSupportForClient } from "./provider-capabilities-DG5qbsUZ.mjs";
24
- import { n as prepareCodexSessionInitialization } from "./session-initialization-6aveB9qb.mjs";
25
- import { createImportedCodexSession } from "./session-history-import-WhX-X33a.mjs";
26
- import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
16
+ import { P as claimCodexAppServerLiveThread, R as hasCodexAppServerLiveThread, f as readCodexAppServerClientDesktopGenerationFingerprint } from "./shared-client-qhyYWbew.mjs";
17
+ import { m as assertCodexThreadForkResponse, p as assertCodexThreadAcceptsDirectInput, s as isCodexAppServerPrewriteRequestCancellationError } from "./client-C8lgBOoO.mjs";
18
+ import { A as buildCodexNativeHookRelayId, Ct as mergeCodexThreadConfigs, D as assertCodexNativeHookRelayAllowed, H as parseCodexNativeToolCatalog, L as checkCodexThreadAppAvailability, N as resolveCodexNativeHookRelayEvents, O as buildCodexNativeHookRelayConfig, Q as fingerprintUserMcpServersConfigPatch, Tt as shouldBuildCodexPluginThreadConfig, U as applyCodexNativeSkillIsolation, W as resolveCodexNativeSkillIsolation, Z as fingerprintJsonObject, a as buildCodexThreadConfiguration, g as buildDeveloperInstructions, gt as buildCodexPluginThreadConfig, m as resolveCodexWebSearchPlan, q as codexDynamicToolsFingerprint } from "./thread-requests-CL1e8Wmx.mjs";
19
+ import "./session-binding-Ce7BqiPN.mjs";
20
+ import { n as CodexThreadPolicyHandoffError, o as refreshCodexThreadPolicy } from "./thread-policy-DoNxbhqt.mjs";
21
+ import "./thread-ownership-DwuSrt3s.mjs";
22
+ import { n as resolveCodexNativeExecutionPolicy } from "./native-execution-policy-ClzpdG3D.mjs";
23
+ import { l as isCodexDynamicToolExcluded } from "./shell-dynamic-tools-D3Brj3g9.mjs";
24
+ import { c as prepareCodexWorkspaceDeveloperInstructions } from "./attempt-workspace-context-BY0jprWJ.mjs";
25
+ import { n as resolveCodexProviderWebSearchSupportForClient } from "./provider-capabilities-D68Whix6.mjs";
26
+ import { n as prepareCodexSessionInitialization } from "./session-initialization-D6dtFQkE.mjs";
27
+ import { createImportedCodexSession } from "./session-history-import-NWKPa4ZO.mjs";
28
+ import { isRecord, normalizeOptionalString, readNonBlankString } from "openclaw/plugin-sdk/string-coerce-runtime";
27
29
  import { randomUUID } from "node:crypto";
28
30
  import { isDeepStrictEqual } from "node:util";
29
31
  import path from "node:path";
30
32
  import { lstat } from "node:fs/promises";
31
33
  import { root } from "openclaw/plugin-sdk/file-access-runtime";
32
34
  import { constants, createZstdDecompress } from "node:zlib";
33
- import { resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
34
35
  import { loadCodexBundleMcpThreadConfig } from "openclaw/plugin-sdk/agent-harness-runtime";
36
+ import { resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
35
37
  import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
36
38
  import { resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
37
39
  import { buildCodexUserMcpServersThreadConfigPatchForRuntime, resolveCodexMcpToolOverridesForAgent } from "openclaw/plugin-sdk/codex-mcp-projection";
@@ -726,19 +728,18 @@ async function forkCanonicalCodexSession(params) {
726
728
  }
727
729
  //#endregion
728
730
  //#region extensions/codex/src/app-server/upstream-session-fork.ts
729
- function readConnectionFingerprint(ref) {
730
- if (!isRecord(ref)) return;
731
- return typeof ref.connectionFingerprint === "string" && ref.connectionFingerprint.trim() ? ref.connectionFingerprint : void 0;
731
+ function unavailable(message) {
732
+ return {
733
+ status: "failed",
734
+ code: "upstream-unavailable",
735
+ message
736
+ };
732
737
  }
733
738
  async function forkCodexUpstreamSession(params, options) {
734
739
  try {
735
- const sourceFingerprint = params.upstream.kind === "codex-app-server" ? readConnectionFingerprint(params.upstream.ref) : void 0;
740
+ const sourceFingerprint = params.upstream.kind === "codex-app-server" && isRecord(params.upstream.ref) ? readNonBlankString(params.upstream.ref.connectionFingerprint) : void 0;
736
741
  const requestControl = sourceFingerprint ? await options.controlFactory.forUpstream(params.source.agentId, sourceFingerprint) : void 0;
737
- if (!sourceFingerprint || !requestControl) return {
738
- status: "failed",
739
- code: "upstream-unavailable",
740
- message: "This Codex thread is not available on the current connection. Reconnect to its host and try again."
741
- };
742
+ if (!sourceFingerprint || !requestControl) return unavailable("This Codex thread is not available on the current connection. Reconnect to its host and try again.");
742
743
  return await requestControl.withPinnedConnection(async (control) => {
743
744
  const sourceBinding = options.bindingStore.read(sessionBindingIdentity({
744
745
  ...params.source,
@@ -759,11 +760,7 @@ async function forkCodexUpstreamSession(params, options) {
759
760
  throw new Error("Codex fork cleanup could not be verified; inspect the retained native thread before retrying.", { cause });
760
761
  }
761
762
  });
762
- if (sourceFingerprint !== control.connectionFingerprint || supervised && (sourceBinding.supervisionSourceThreadId !== params.upstream.threadId || (sourceBinding.pendingSupervisionBranch?.connectionFingerprint ?? sourceBinding.appServerRuntimeFingerprint) !== sourceFingerprint)) return {
763
- status: "failed",
764
- code: "upstream-unavailable",
765
- message: "This Codex thread is not available on the current connection. Reconnect to its host and try again."
766
- };
763
+ if (sourceFingerprint !== control.connectionFingerprint || supervised && (sourceBinding.supervisionSourceThreadId !== params.upstream.threadId || (sourceBinding.pendingSupervisionBranch?.connectionFingerprint ?? sourceBinding.appServerRuntimeFingerprint) !== sourceFingerprint)) return unavailable("This Codex thread is not available on the current connection. Reconnect to its host and try again.");
767
764
  const resolved = await resolveCodexUpstreamForkBoundary({
768
765
  ...params.source,
769
766
  threadId: sourceThreadId,
@@ -884,19 +881,11 @@ async function forkCodexUpstreamSession(params, options) {
884
881
  };
885
882
  } catch (error) {
886
883
  if (!initializerOwnsFork) await options.bindingStore.withThreadArchiveFence(() => archiveFreshFork(forkedThreadId));
887
- return {
888
- status: "failed",
889
- code: "upstream-unavailable",
890
- message: error instanceof Error ? error.message : "The Codex fork could not be imported. Refresh sessions and try again."
891
- };
884
+ return unavailable(error instanceof Error ? error.message : "The Codex fork could not be imported. Refresh sessions and try again.");
892
885
  }
893
886
  });
894
887
  } catch (error) {
895
- return {
896
- status: "failed",
897
- code: "upstream-unavailable",
898
- message: error instanceof Error ? error.message : "The Codex thread could not be forked. Check that Codex is available, then try again."
899
- };
888
+ return unavailable(error instanceof Error ? error.message : "The Codex thread could not be forked. Check that Codex is available, then try again.");
900
889
  }
901
890
  }
902
891
  //#endregion
@@ -1,7 +1,7 @@
1
- import { t as buildCodexAppServerUsageSnapshot } from "./rate-limits-B7-X2TgG.mjs";
2
- import { n as readCodexAppServerUsage } from "./request-BZOfsSXW.mjs";
3
- import "./config-DKhXquav.mjs";
4
- import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-C0NbLms1.mjs";
1
+ import { t as buildCodexAppServerUsageSnapshot } from "./rate-limits-CMPy24F5.mjs";
2
+ import { t as readCodexAppServerUsage } from "./request-jSbhc1sg.mjs";
3
+ import "./config-0Gxk3_eq.mjs";
4
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-cUYrqu_a.mjs";
5
5
  import { CODEX_APP_SERVER_AUTH_MARKER } from "openclaw/plugin-sdk/agent-runtime";
6
6
  //#region extensions/codex/src/app-server/usage.ts
7
7
  /** Handles the synthetic usage credential for a Codex-backed OpenAI route. */
@@ -1,10 +1,10 @@
1
1
  import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
2
- import { a as shouldRefreshCodexRateLimitsForUsageLimitMessage, i as resolveCodexUsageLimitResetAtMs, n as formatCodexUsageLimitErrorMessage } from "./rate-limits-B7-X2TgG.mjs";
3
- import { t as CODEX_CONTROL_METHODS } from "./capabilities-B3WEZl4e.mjs";
4
- import { X as readRecentCodexRateLimits, Y as readCodexRateLimitsRevision, Z as rememberCodexRateLimitsRead } from "./shared-client-CJCTeFpQ.mjs";
2
+ import { a as shouldRefreshCodexRateLimitsForUsageLimitMessage, i as resolveCodexUsageLimitResetAtMs, n as formatCodexUsageLimitErrorMessage } from "./rate-limits-CMPy24F5.mjs";
3
+ import { t as CODEX_CONTROL_METHODS } from "./capabilities-kQntafj_.mjs";
4
+ import { X as readRecentCodexRateLimits, Y as readCodexRateLimitsRevision, Z as rememberCodexRateLimitsRead } from "./shared-client-qhyYWbew.mjs";
5
5
  import { readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
6
- import { markAuthProfileBlockedUntil } from "openclaw/plugin-sdk/agent-runtime";
7
6
  import { embeddedAgentLog, formatErrorMessage } from "openclaw/plugin-sdk/agent-harness-runtime";
7
+ import { markAuthProfileBlockedUntil } from "openclaw/plugin-sdk/agent-runtime";
8
8
  //#region extensions/codex/src/app-server/usage-limit-error.ts
9
9
  const CODEX_USAGE_LIMIT_RATE_LIMIT_REFRESH_TIMEOUT_MS = 5e3;
10
10
  var CodexUsageLimitPromptError = class extends Error {
@@ -1,7 +1,6 @@
1
- import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
2
- import { f as buildCodexNativeWebSearchThreadConfig } from "./thread-requests-OWGOiDaV.mjs";
3
- import { runBoundedCodexAppServerTurn } from "./bounded-turn-BNunZPtz.mjs";
4
- import { normalizeOptionalString, normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { p as buildCodexNativeWebSearchThreadConfig } from "./thread-requests-CL1e8Wmx.mjs";
2
+ import { l as projectCodexWebSearchItem } from "./native-subagent-monitor-BUYOUp9X.mjs";
3
+ import { runBoundedCodexAppServerTurn } from "./bounded-turn-pGsfXcmH.mjs";
5
4
  import { readStringParam, resolveSearchTimeoutSeconds, wrapWebContent } from "openclaw/plugin-sdk/provider-web-search";
6
5
  //#region extensions/codex/src/web-search-provider.runtime.ts
7
6
  async function executeCodexWebSearchProviderTool(ctx, args, executionContext, options) {
@@ -27,7 +26,7 @@ async function executeCodexWebSearchProviderTool(ctx, args, executionContext, op
27
26
  isolation: "private-stdio",
28
27
  threadConfig: buildCodexNativeWebSearchThreadConfig(ctx.config)
29
28
  });
30
- const searches = result.items.filter((item) => item.type === "webSearch").map(summarizeCodexWebSearchItem);
29
+ const searches = result.items.filter((item) => item.type === "webSearch").map(projectCodexWebSearchItem);
31
30
  if (searches.length === 0) throw new Error("Codex hosted search completed without invoking web search.");
32
31
  return {
33
32
  query,
@@ -44,20 +43,5 @@ async function executeCodexWebSearchProviderTool(ctx, args, executionContext, op
44
43
  searches
45
44
  };
46
45
  }
47
- function summarizeCodexWebSearchItem(item) {
48
- const action = isJsonObject(item.action) ? item.action : void 0;
49
- const actionType = normalizeOptionalString(action?.type);
50
- const queries = actionType === "search" ? normalizeTrimmedStringList(action?.queries) : [];
51
- const query = normalizeOptionalString(item.query) ?? (actionType === "search" ? normalizeOptionalString(action?.query) : void 0) ?? queries[0];
52
- const url = normalizeOptionalString(action?.url);
53
- const pattern = normalizeOptionalString(action?.pattern);
54
- return {
55
- ...query ? { query } : {},
56
- ...queries.length > 0 ? { queries } : {},
57
- ...actionType && actionType !== "search" ? { action: actionType } : {},
58
- ...url ? { url } : {},
59
- ...pattern ? { pattern } : {}
60
- };
61
- }
62
46
  //#endregion
63
47
  export { executeCodexWebSearchProviderTool };
@@ -0,0 +1,6 @@
1
+ //#region extensions/codex/src/app-server/websocket-data.ts
2
+ function codexWebSocketDataToBuffer(data) {
3
+ return Array.isArray(data) ? Buffer.concat(data) : Buffer.isBuffer(data) ? data : data instanceof Uint8Array ? Buffer.from(data.buffer, data.byteOffset, data.byteLength) : Buffer.from(data);
4
+ }
5
+ //#endregion
6
+ export { codexWebSocketDataToBuffer as t };