@openclaw/codex 2026.9.8 → 2026.10.1-beta.1

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-C4GFoef_.mjs} +5 -5
  3. package/dist/.setup/app-server-policy-Bg4FZw1f.mjs +23 -0
  4. package/dist/.setup/{apply-Cqb-YoCS.mjs → apply-D02fLpgN.mjs} +48 -39
  5. package/dist/.setup/attempt-client-cleanup-yLjGwbwT.mjs +155 -0
  6. package/dist/.setup/{attempt-workspace-context-BJ5Z_olH.mjs → attempt-workspace-context-CbSzT6V2.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-CEd9QlIs.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-BNunZPtz.mjs → bounded-turn-DlHlNTyS.mjs} +14 -13
  14. package/dist/.setup/{bounded-turn-isolation-B8K_ylqk.mjs → bounded-turn-isolation-DklXNk3k.mjs} +4 -4
  15. package/dist/.setup/{build-state-DIQ5O_-S.mjs → build-state-CIi3Ckqu.mjs} +1 -1
  16. package/dist/.setup/{capabilities-B3WEZl4e.mjs → capabilities-kQntafj_.mjs} +1 -1
  17. package/dist/.setup/{client-qyUBJlGZ.mjs → client-CBzEVDyb.mjs} +438 -160
  18. package/dist/.setup/{client-catalog-response-DRvx_wCC.mjs → client-catalog-response-CmvIiDdj.mjs} +57 -25
  19. package/dist/.setup/command-authorization-AikPDtcc.mjs +15 -0
  20. package/dist/.setup/{command-dispatch-Btrs1D6f.mjs → command-dispatch-BE_RdMou.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-DNoRq5Ps.mjs} +82 -144
  23. package/dist/.setup/{command-rpc-skzRq4wD.mjs → command-rpc-B6xsq2dB.mjs} +23 -31
  24. package/dist/.setup/{compact-8ttks5U5.mjs → compact-BLSAd-ru.mjs} +117 -65
  25. package/dist/.setup/{plugin-metadata-cache-BRwtRct9.mjs → computer-use-DpolvQHw.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-CgSSD1Qz.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-tCg763cI.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-CVrx02cH.mjs +463 -0
  39. package/dist/.setup/{dynamic-tools-Db2sY5cZ.mjs → dynamic-tools-DdsymYGQ.mjs} +238 -878
  40. package/dist/.setup/{effective-mcp-catalog-Bi6-SQ7i.mjs → effective-mcp-catalog-BysTBZCW.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-oPKxs3ia.mjs} +2 -2
  43. package/dist/.setup/{event-projector-assistant-message-MV_1dj-3.mjs → event-projector-assistant-message-YCL2wspu.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-D5gbKm6k.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-CdqsXwZX.mjs +223 -0
  50. package/dist/.setup/mcp-tool-metadata-j10HhfTC.mjs +43 -0
  51. package/dist/.setup/{model-catalog-DiC0Tkha.mjs → model-catalog-Dj_uvusa.mjs} +7 -7
  52. package/dist/.setup/{models-DfLmPV0k.mjs → models-Du_i5G_t.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-DV7VbfzF.mjs +310 -0
  56. package/dist/.setup/{native-subagent-monitor-BwkQXf9e.mjs → native-subagent-monitor-CCEFO6qK.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-CUHSIOep.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-uAR-oQfr.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-CdRzGJt4.mjs +124 -0
  69. package/dist/.setup/{provider-D6F_7p1I.mjs → provider-BP8ZaZqn.mjs} +4 -4
  70. package/dist/.setup/provider-capabilities-Z5ZbBxqP.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-BH3FvYUE.mjs} +189 -49
  73. package/dist/.setup/rpc-error-hmWM21RB.mjs +57 -0
  74. package/dist/.setup/{run-attempt-dYJhjZrp.mjs → run-attempt-CgvFoW7R.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-KIXOoSnQ.mjs} +5 -5
  88. package/dist/.setup/{session-catalog-index-DwJjnF5k.mjs → session-catalog-index-DPICGlxr.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-CTBd4EUm.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-CE0_Hffi.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-aC60o6P3.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-CDxCejjC.mjs} +8 -8
  109. package/dist/.setup/{shared-client-CJCTeFpQ.mjs → shared-client-DJJ3ljH2.mjs} +291 -272
  110. package/dist/.setup/{provider-capabilities-DG5qbsUZ.mjs → shell-dynamic-tools-Do9lIAT1.mjs} +16 -55
  111. package/dist/.setup/{side-question-BLeGj7TQ.mjs → side-question-B7T0_GEC.mjs} +99 -91
  112. package/dist/.setup/{source-CJis_1EF.mjs → source-DH70LqN0.mjs} +24 -40
  113. package/dist/.setup/{thread-lifecycle-_bAbjedG.mjs → thread-lifecycle-DkcoX9q-.mjs} +262 -305
  114. package/dist/.setup/{thread-ownership-B6pPt21M.mjs → thread-ownership-0aRHD9iK.mjs} +10 -8
  115. package/dist/.setup/{thread-policy-gNPzzpVp.mjs → thread-policy-CXZV97TS.mjs} +22 -21
  116. package/dist/.setup/{thread-requests-OWGOiDaV.mjs → thread-requests-COrRJcZb.mjs} +107 -98
  117. package/dist/.setup/{thread-resume-GOry0AYh.mjs → thread-resume-rx7J68Rx.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-CX1-EoCp.mjs} +75 -170
  123. package/dist/.setup/{upstream-session-fork-gkdRj2yH.mjs → upstream-session-fork-LYlaQnbt.mjs} +35 -46
  124. package/dist/.setup/{usage-CApUvLOV.mjs → usage-Dmx7B0W2.mjs} +4 -4
  125. package/dist/.setup/{usage-limit-error-wSMQkbpV.mjs → usage-limit-error-M8jVnITZ.mjs} +4 -4
  126. package/dist/.setup/{web-search-provider.runtime-UKgeiBUG.mjs → web-search-provider.runtime-CsVmqbFm.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,9 +1,155 @@
1
- import { n as CodexAppServerRpcError } from "./rpc-error-BlD2vuzn.mjs";
2
- import { i as withTimeout, r as withAbortableTimeout } from "./timeout-CXOfNoaX.mjs";
3
- import { t as __exportAll } from "./session-binding-sidecars-jo6H8dFr.mjs";
1
+ import { i as CodexAppServerScopedRequestRejectedError, r as CodexAppServerRpcError } from "./rpc-error-hmWM21RB.mjs";
2
+ import { t as CODEX_CONTROL_METHODS } from "./capabilities-kQntafj_.mjs";
3
+ import { i as withTimeout$1, r as withAbortableTimeout } from "./timeout-CXOfNoaX.mjs";
4
+ import { t as __exportAll } from "./session-binding-sidecars-BrdV95Fg.mjs";
5
+ import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-registration";
6
+ import { areDiagnosticsEnabledForProcess } from "openclaw/plugin-sdk/diagnostic-runtime";
7
+ import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
8
+ //#region extensions/codex/src/app-server/request-diagnostics.ts
9
+ const DIAGNOSTIC_METHODS = /* @__PURE__ */ new Set([
10
+ ...Object.values(CODEX_CONTROL_METHODS),
11
+ "model/list",
12
+ "thread/start",
13
+ "plugin/installed",
14
+ "plugin/read",
15
+ "config/read",
16
+ "config/value/write",
17
+ "config/batchWrite",
18
+ "configRequirements/read",
19
+ "experimentalFeature/list"
20
+ ]);
21
+ const MAX_METHODS = 8;
22
+ function readInitializeSnapshot(read, beforeClose = false) {
23
+ try {
24
+ return read?.(beforeClose);
25
+ } catch {
26
+ return;
27
+ }
28
+ }
29
+ /** Counts awaited APIs, not native execution or proof that a request was written. */
30
+ function createCodexRequestTimeoutDiagnostics(timeoutMs) {
31
+ if (!areDiagnosticsEnabledForProcess() || !embeddedAgentLog.isEnabled("warn")) return;
32
+ const startedAt = performance.now();
33
+ let attempt = createAttempt(0);
34
+ function createAttempt(ordinal) {
35
+ return {
36
+ ordinal,
37
+ phase: "prepare",
38
+ clientInstanceId: void 0,
39
+ acquireLastObservedBoundary: void 0,
40
+ acquireBoundaryBeforeCleanup: void 0,
41
+ acquireStartup: void 0,
42
+ lastStartedClientInstanceId: void 0,
43
+ lastStartedTransportIdentity: void 0,
44
+ initializeSnapshot: void 0,
45
+ initializeBeforeCleanup: void 0,
46
+ initializeBeforeCleanupSource: void 0,
47
+ started: 0,
48
+ pending: 0,
49
+ methods: /* @__PURE__ */ new Map()
50
+ };
51
+ }
52
+ return {
53
+ beginAttempt(ordinal) {
54
+ attempt = createAttempt(ordinal);
55
+ attempt.phase = "acquire-client";
56
+ const current = attempt;
57
+ return {
58
+ onAcquireObservation(observation) {
59
+ if (attempt !== current || current.phase !== "acquire-client") return;
60
+ if (observation.boundary === "cleanup") {
61
+ if (current.acquireLastObservedBoundary !== "cleanup") {
62
+ current.acquireBoundaryBeforeCleanup = current.acquireLastObservedBoundary;
63
+ const snapshot = readInitializeSnapshot(current.initializeSnapshot);
64
+ current.initializeBeforeCleanup = snapshot?.clientClosed ? readInitializeSnapshot(current.initializeSnapshot, true) : snapshot;
65
+ current.initializeBeforeCleanupSource = current.initializeBeforeCleanup ? snapshot?.clientClosed ? "before-client-close" : "at-cleanup" : void 0;
66
+ }
67
+ } else {
68
+ current.acquireBoundaryBeforeCleanup = void 0;
69
+ current.initializeBeforeCleanup = void 0;
70
+ current.initializeBeforeCleanupSource = void 0;
71
+ }
72
+ current.acquireLastObservedBoundary = observation.boundary;
73
+ if (observation.startup) current.acquireStartup = observation.startup;
74
+ },
75
+ onStartedClient(client) {
76
+ if (attempt !== current || current.phase !== "acquire-client") return;
77
+ current.lastStartedClientInstanceId = void 0;
78
+ current.lastStartedTransportIdentity = void 0;
79
+ current.initializeSnapshot = void 0;
80
+ current.initializeBeforeCleanup = void 0;
81
+ current.initializeBeforeCleanupSource = void 0;
82
+ try {
83
+ current.lastStartedClientInstanceId = client.getInstanceId();
84
+ current.initializeSnapshot = (beforeClose) => client.getInitializeDiagnostic(beforeClose);
85
+ } catch {}
86
+ try {
87
+ const identity = client.getRegisteredTransportIdentity();
88
+ current.lastStartedTransportIdentity = identity ? {
89
+ pid: identity.pid,
90
+ startedAt: identity.startedAt
91
+ } : void 0;
92
+ } catch {}
93
+ }
94
+ };
95
+ },
96
+ acquired(client) {
97
+ attempt.phase = "callback";
98
+ try {
99
+ attempt.clientInstanceId = client.getInstanceId();
100
+ } catch {}
101
+ },
102
+ request(method) {
103
+ const current = attempt;
104
+ const label = DIAGNOSTIC_METHODS.has(method) ? method : "other";
105
+ current.started++;
106
+ current.pending++;
107
+ current.methods.set(label, (current.methods.get(label) ?? 0) + 1);
108
+ return () => {
109
+ current.pending--;
110
+ const remaining = (current.methods.get(label) ?? 1) - 1;
111
+ if (remaining === 0) current.methods.delete(label);
112
+ else current.methods.set(label, remaining);
113
+ };
114
+ },
115
+ release() {
116
+ attempt.phase = "release-client";
117
+ },
118
+ timeout() {
119
+ try {
120
+ if (!areDiagnosticsEnabledForProcess() || !embeddedAgentLog.isEnabled("warn")) return;
121
+ const methods = [...attempt.methods].toSorted(([a], [b]) => a.localeCompare(b));
122
+ const initialize = readInitializeSnapshot(attempt.initializeSnapshot);
123
+ embeddedAgentLog.warn("codex app-server scope timed out", {
124
+ phase: attempt.phase === "callback" && attempt.pending > 0 ? "client-request" : attempt.phase,
125
+ timeoutMs,
126
+ elapsedMs: Math.round(performance.now() - startedAt),
127
+ scopeAttemptOrdinal: attempt.ordinal,
128
+ ...attempt.acquireLastObservedBoundary ? { acquireLastObservedBoundary: attempt.acquireLastObservedBoundary } : {},
129
+ ...attempt.acquireStartup ? { acquireStartup: attempt.acquireStartup } : {},
130
+ ...attempt.acquireBoundaryBeforeCleanup ? { acquireBoundaryBeforeCleanup: attempt.acquireBoundaryBeforeCleanup } : {},
131
+ ...attempt.lastStartedClientInstanceId ? {
132
+ lastStartedClientInstanceId: attempt.lastStartedClientInstanceId,
133
+ lastStartedTransportIdentity: attempt.lastStartedTransportIdentity ? JSON.stringify(attempt.lastStartedTransportIdentity) : "unavailable"
134
+ } : {},
135
+ ...attempt.clientInstanceId ? { clientInstanceId: attempt.clientInstanceId } : {},
136
+ ...initialize ? { initializeSnapshot: JSON.stringify(initialize) } : {},
137
+ ...attempt.initializeBeforeCleanup ? {
138
+ initializeBeforeCleanup: JSON.stringify(attempt.initializeBeforeCleanup),
139
+ initializeBeforeCleanupSource: attempt.initializeBeforeCleanupSource
140
+ } : {},
141
+ requestStartedCount: attempt.started,
142
+ currentRequestCount: attempt.pending,
143
+ currentMethods: JSON.stringify(methods.slice(0, MAX_METHODS)),
144
+ omittedMethodCount: Math.max(0, methods.length - MAX_METHODS)
145
+ });
146
+ } catch {}
147
+ }
148
+ };
149
+ }
150
+ //#endregion
4
151
  //#region extensions/codex/src/app-server/request.ts
5
152
  var request_exports = /* @__PURE__ */ __exportAll({
6
- CodexAppServerScopedRequestRejectedError: () => CodexAppServerScopedRequestRejectedError,
7
153
  readCodexAppServerUsage: () => readCodexAppServerUsage,
8
154
  requestCodexAppServerClientJson: () => requestCodexAppServerClientJson,
9
155
  requestCodexAppServerJson: () => requestCodexAppServerJson,
@@ -29,7 +175,7 @@ async function requestCodexAppServerClientJson(params) {
29
175
  let phase = "prepare";
30
176
  observeControlPhase(params.controlObservation, phase);
31
177
  try {
32
- const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-DjCz2eOw.mjs").then((n) => n.r);
178
+ const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-WqE8yPge.mjs").then((n) => n.r);
33
179
  const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
34
180
  method: params.method,
35
181
  requestParams: params.requestParams,
@@ -45,12 +191,13 @@ async function requestCodexAppServerClientJson(params) {
45
191
  const options = {
46
192
  timeoutMs,
47
193
  signal: params.signal,
48
- ...attemptWaiterFinished ? { attemptWaiterFinished } : {},
49
- ...params.assertCurrent ? { assertCurrent: () => assertRequestOwnerCurrent(params.assertCurrent) } : {}
194
+ withCurrent: params.withCurrent,
195
+ assertCurrent: params.assertCurrent,
196
+ ...attemptWaiterFinished ? { attemptWaiterFinished } : {}
50
197
  };
51
198
  phase = "client-request";
52
199
  observeControlPhase(params.controlObservation, phase);
53
- return await withTimeout(params.client.request(method, requestParams, options), timeoutMs, `codex app-server ${params.method} timed out`);
200
+ return await withTimeout$1(params.client.request(method, requestParams, options), timeoutMs, `codex app-server ${params.method} timed out`);
54
201
  } catch (error) {
55
202
  observeControlFailure(params.controlObservation, phase, error);
56
203
  throw error;
@@ -58,7 +205,7 @@ async function requestCodexAppServerClientJson(params) {
58
205
  }
59
206
  async function requestCodexAppServerJson(params) {
60
207
  observeControlPhase(params.controlObservation, "prepare");
61
- const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-DjCz2eOw.mjs").then((n) => n.r);
208
+ const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-WqE8yPge.mjs").then((n) => n.r);
62
209
  const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
63
210
  method: params.method,
64
211
  requestParams: params.requestParams,
@@ -75,13 +222,6 @@ async function requestCodexAppServerJson(params) {
75
222
  requestParams: params.requestParams
76
223
  }));
77
224
  }
78
- /** A scoped guard rejected the request before a physical write. */
79
- var CodexAppServerScopedRequestRejectedError = class extends Error {
80
- constructor(message, options) {
81
- super(message, options);
82
- this.name = "CodexAppServerScopedRequestRejectedError";
83
- }
84
- };
85
225
  function createScopeCleanupError(message) {
86
226
  const stackTraceLimit = Error.stackTraceLimit;
87
227
  try {
@@ -136,16 +276,7 @@ async function readCodexAccountEmailBestEffort(request, deadline) {
136
276
  method: "account/read",
137
277
  requestParams: {}
138
278
  }).then(({ account }) => account?.type === "chatgpt" ? account.email?.trim() || void 0 : void 0, () => void 0);
139
- let timer;
140
- const timeout = new Promise((resolve) => {
141
- timer = setTimeout(() => resolve(void 0), boundMs);
142
- timer.unref?.();
143
- });
144
- try {
145
- return await Promise.race([read, timeout]);
146
- } finally {
147
- if (timer) clearTimeout(timer);
148
- }
279
+ return await raceWithTimeout(read, boundMs, () => void 0, { ref: false });
149
280
  }
150
281
  /**
151
282
  * Runs several guarded requests over one acquired client (shared lease or
@@ -155,9 +286,14 @@ async function readCodexAccountEmailBestEffort(request, deadline) {
155
286
  async function withCodexAppServerJsonClient(params, run) {
156
287
  const timeoutMs = params.timeoutMs ?? 6e4;
157
288
  const timeoutMessage = params.timeoutMessage ?? "codex app-server request timed out";
289
+ const timeoutDiagnostics = createCodexRequestTimeoutDiagnostics(timeoutMs);
158
290
  let activePhase = "prepare";
159
291
  let errorPhase;
160
- observeControlPhase(params.controlObservation, activePhase);
292
+ const setPhase = (phase) => {
293
+ activePhase = phase;
294
+ observeControlPhase(params.controlObservation, phase);
295
+ };
296
+ setPhase("prepare");
161
297
  const timeoutController = new AbortController();
162
298
  const abort = () => timeoutController.abort(params.signal?.reason);
163
299
  params.signal?.addEventListener("abort", abort, { once: true });
@@ -179,14 +315,14 @@ async function withCodexAppServerJsonClient(params, run) {
179
315
  timeoutMs,
180
316
  timeoutMessage,
181
317
  promise: (async () => {
182
- const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-DjCz2eOw.mjs").then((n) => n.r);
183
- const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, isCodexAppServerStartSelectionChangedError, releaseLeasedSharedCodexAppServerClient, retireSharedCodexAppServerClientIfCurrent } = await import("./shared-client-CJCTeFpQ.mjs").then((n) => n.v);
318
+ const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-WqE8yPge.mjs").then((n) => n.r);
319
+ const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, isCodexAppServerStartSelectionChangedError, releaseLeasedSharedCodexAppServerClient, retireSharedCodexAppServerClientIfCurrent } = await import("./shared-client-DJJ3ljH2.mjs").then((n) => n.v);
184
320
  for (let attempt = 0; attempt < 2; attempt += 1) {
185
321
  errorPhase = void 0;
186
- activePhase = "prepare";
187
- observeControlPhase(params.controlObservation, activePhase);
322
+ setPhase("prepare");
188
323
  throwIfAbandoned();
189
324
  const acquireClient = params.isolated ? createIsolatedCodexAppServerClient : getLeasedSharedCodexAppServerClient;
325
+ const acquireObservation = timeoutDiagnostics?.beginAttempt(attempt + 1);
190
326
  const acquireOptions = {
191
327
  startOptions: params.startOptions,
192
328
  pluginConfig: params.pluginConfig,
@@ -199,11 +335,12 @@ async function withCodexAppServerJsonClient(params, run) {
199
335
  agentDir: params.agentDir,
200
336
  config: params.config,
201
337
  abandonSignal: timeoutController.signal,
202
- assertCurrent: params.assertCurrent
338
+ assertCurrent: params.assertCurrent,
339
+ ...acquireObservation
203
340
  };
204
- activePhase = "acquire-client";
205
- observeControlPhase(params.controlObservation, activePhase);
341
+ setPhase("acquire-client");
206
342
  const client = await acquireClient(acquireOptions);
343
+ timeoutDiagnostics?.acquired(client);
207
344
  let scopeActive = true;
208
345
  const assertCurrent = () => {
209
346
  throwIfAbandoned();
@@ -211,12 +348,10 @@ async function withCodexAppServerJsonClient(params, run) {
211
348
  assertRequestOwnerCurrent(params.assertCurrent);
212
349
  };
213
350
  try {
214
- activePhase = "prepare";
215
- observeControlPhase(params.controlObservation, activePhase);
351
+ setPhase("prepare");
216
352
  assertCurrent();
217
353
  const scopedRequest = async (request) => {
218
- activePhase = "prepare";
219
- observeControlPhase(params.controlObservation, activePhase);
354
+ setPhase("prepare");
220
355
  const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
221
356
  method: request.method,
222
357
  requestParams: request.requestParams,
@@ -243,9 +378,13 @@ async function withCodexAppServerJsonClient(params, run) {
243
378
  request.assertCurrent?.();
244
379
  }
245
380
  };
246
- activePhase = "client-request";
247
- observeControlPhase(params.controlObservation, activePhase);
248
- return await client.request(method, requestParams, requestOptions);
381
+ setPhase("client-request");
382
+ const settled = timeoutDiagnostics?.request(method);
383
+ try {
384
+ return await client.request(method, requestParams, requestOptions);
385
+ } finally {
386
+ settled?.();
387
+ }
249
388
  };
250
389
  return await run(scopedRequest, client, {
251
390
  assertCurrent,
@@ -259,12 +398,10 @@ async function withCodexAppServerJsonClient(params, run) {
259
398
  errorPhase = void 0;
260
399
  try {
261
400
  if (!params.isolated) {
262
- activePhase = "release-client";
263
- observeControlPhase(params.controlObservation, activePhase);
401
+ setPhase("release-client");
264
402
  retireSharedCodexAppServerClientIfCurrent(client);
265
403
  }
266
- activePhase = "prepare";
267
- observeControlPhase(params.controlObservation, activePhase);
404
+ setPhase("prepare");
268
405
  throwIfAbandoned();
269
406
  } catch (retryError) {
270
407
  errorPhase = activePhase;
@@ -272,8 +409,8 @@ async function withCodexAppServerJsonClient(params, run) {
272
409
  }
273
410
  } finally {
274
411
  scopeActive = false;
275
- activePhase = "release-client";
276
- observeControlPhase(params.controlObservation, activePhase);
412
+ setPhase("release-client");
413
+ timeoutDiagnostics?.release();
277
414
  const requestErrorPhase = errorPhase;
278
415
  errorPhase = activePhase;
279
416
  if (params.isolated) await client.closeAndWait({
@@ -290,7 +427,10 @@ async function withCodexAppServerJsonClient(params, run) {
290
427
  } catch (error) {
291
428
  const deadlineObserved = isPastDeadline();
292
429
  observeControlFailure(params.controlObservation, deadlineObserved ? activePhase : errorPhase ?? activePhase, error, deadlineObserved);
293
- if (deadlineObserved) throw new Error(timeoutMessage, { cause: error });
430
+ if (deadlineObserved) {
431
+ timeoutDiagnostics?.timeout();
432
+ throw new Error(timeoutMessage, { cause: error });
433
+ }
294
434
  throw error;
295
435
  } finally {
296
436
  params.signal?.removeEventListener("abort", abort);
@@ -298,4 +438,4 @@ async function withCodexAppServerJsonClient(params, run) {
298
438
  }
299
439
  }
300
440
  //#endregion
301
- export { request_exports as a, requestCodexAppServerJson as i, readCodexAppServerUsage as n, withCodexAppServerJsonClient as o, requestCodexAppServerClientJson as r, CodexAppServerScopedRequestRejectedError as t };
441
+ export { withCodexAppServerJsonClient as a, request_exports as i, requestCodexAppServerClientJson as n, requestCodexAppServerJson as r, readCodexAppServerUsage as t };
@@ -0,0 +1,57 @@
1
+ import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
2
+ import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
3
+ //#region extensions/codex/src/app-server/rpc-error.ts
4
+ const CODEX_APP_SERVER_OVERLOADED_ERROR_CODE = -32001;
5
+ /** A scoped guard rejected the request before a physical write. */
6
+ var CodexAppServerScopedRequestRejectedError = class extends Error {
7
+ constructor(message, options) {
8
+ super(message, options);
9
+ this.name = "CodexAppServerScopedRequestRejectedError";
10
+ }
11
+ };
12
+ /** Only definite pre-write rejection permits recovering the original startup cause. */
13
+ function codexPrewriteRejectionCause(error) {
14
+ return error instanceof CodexAppServerScopedRequestRejectedError && error.cause !== void 0 ? error.cause : error;
15
+ }
16
+ /** RPC error wrapper that preserves app-server error code and data. */
17
+ var CodexAppServerRpcError = class extends Error {
18
+ constructor(error, method) {
19
+ super(formatCodexAppServerRpcErrorMessage(error, method));
20
+ this.name = "CodexAppServerRpcError";
21
+ this.code = error.code;
22
+ this.data = error.data;
23
+ this.method = method;
24
+ }
25
+ };
26
+ function isCodexThreadReadMissingError(error, threadId) {
27
+ return error instanceof CodexAppServerRpcError && error.method === "thread/read" && error.code === -32600 && error.message === `thread not loaded: ${threadId}`;
28
+ }
29
+ function formatCodexAppServerRpcErrorMessage(error, method) {
30
+ const message = error.message || `${method} failed`;
31
+ const detail = readCodexAppServerRpcReloginDetail(error.data);
32
+ return detail && !message.includes(detail) ? `${message}: ${detail}` : message;
33
+ }
34
+ function readCodexAppServerRpcReloginDetail(data) {
35
+ const record = isJsonObject(data) ? data : void 0;
36
+ const nested = isJsonObject(record?.error) ? record.error : record;
37
+ if (!nested) return;
38
+ const isRelogin = nested.action === "relogin" || nested.reason === "cloudRequirements" && nested.errorCode === "Auth";
39
+ const detail = typeof nested.detail === "string" ? nested.detail.trim() : "";
40
+ return isRelogin && detail ? detail : void 0;
41
+ }
42
+ var CodexAppServerLocalRequestCancellationError = class extends Error {
43
+ constructor(method, reason, mayHaveWritten, cause) {
44
+ const detail = cause instanceof Error || typeof cause === "string" ? coerceErrorMessage(cause) : void 0;
45
+ super(`${method} ${reason}${detail ? `: ${detail}` : ""}`, { cause });
46
+ this.reason = reason;
47
+ this.mayHaveWritten = mayHaveWritten;
48
+ this.code = "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED";
49
+ this.name = "CodexAppServerLocalRequestCancellationError";
50
+ }
51
+ };
52
+ /** Codex rejects this exact code before enqueueing, including mutating requests. */
53
+ function isCodexAppServerOverloadError(error) {
54
+ return error instanceof CodexAppServerRpcError && error.code === -32001;
55
+ }
56
+ //#endregion
57
+ export { codexPrewriteRejectionCause as a, CodexAppServerScopedRequestRejectedError as i, CodexAppServerLocalRequestCancellationError as n, isCodexAppServerOverloadError as o, CodexAppServerRpcError as r, isCodexThreadReadMissingError as s, CODEX_APP_SERVER_OVERLOADED_ERROR_CODE as t };