@openclaw/codex 2026.9.4 → 2026.9.6

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 (160) hide show
  1. package/assets/activity.svg +30 -0
  2. package/assets/icon.png +0 -0
  3. package/dist/.setup/account-usage-runtime-Eem_WGqY.mjs +75 -0
  4. package/dist/{apply-CvT8tW5i.js → .setup/apply-DDOi8uNx.mjs} +24 -30
  5. package/dist/.setup/async-questions-DdhOCwGi.mjs +27 -0
  6. package/dist/{attempt-client-cleanup-DKHzbwt5.js → .setup/attempt-client-cleanup-CEv1cKwF.mjs} +79 -49
  7. package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +5 -0
  8. package/dist/.setup/attempt-workspace-context-DUVEn_CS.mjs +331 -0
  9. package/dist/{auth-binding-CWlKVccJ.js → .setup/auth-binding-DhLWa_7K.mjs} +1 -1
  10. package/dist/{auth-cache-key-7orQae_j.js → .setup/auth-cache-key-B2mpaI9D.mjs} +9 -81
  11. package/dist/{auth-profile-CwzO4_RG.js → .setup/auth-profile-WqZtZfXN.mjs} +1 -1
  12. package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
  13. package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
  14. package/dist/.setup/binding-connection-ThoatDcb.mjs +50 -0
  15. package/dist/.setup/binding-connection.runtime-yoHrABt-.mjs +48 -0
  16. package/dist/{bounded-turn-C_Hneydj.js → .setup/bounded-turn-B2HScEgT.mjs} +143 -32
  17. package/dist/{build-state-BCmg9-5p.js → .setup/build-state-C7EnDVgr.mjs} +1 -1
  18. package/dist/{capabilities-8vx68WLH.js → .setup/capabilities-CDXOOFdZ.mjs} +1 -1
  19. package/dist/{client-B57KWPQx.js → .setup/client-Cs08OXVQ.mjs} +705 -512
  20. package/dist/.setup/client-catalog-response-BMgt_4q4.mjs +285 -0
  21. package/dist/{command-dispatch-BpduNGVf.js → .setup/command-dispatch-B4JuOsOk.mjs} +8 -4
  22. package/dist/{command-formatters-lxlkNZgU.js → .setup/command-formatters-Bmqvr9tO.mjs} +8 -4
  23. package/dist/{command-handlers-tiL9iWj7.js → .setup/command-handlers-DW7Lx9oH.mjs} +137 -186
  24. package/dist/{command-rpc-CR5EOEZX.js → .setup/command-rpc-DixIj3HW.mjs} +47 -23
  25. package/dist/{compact-B_H3AOd7.js → .setup/compact-Du5UvtxA.mjs} +29 -51
  26. package/dist/{config-oIORaQ5T.js → .setup/config-BoTP_mrL.mjs} +5 -4
  27. package/dist/{config-options-CXMq1T-C.js → .setup/config-options-BvaRs51b.mjs} +50 -446
  28. package/dist/{protocol-5bh1G-H7.js → .setup/config-parsing-CcB9iPoq.mjs} +9 -51
  29. package/dist/{config-runtime-D0zGNIHu.js → .setup/config-runtime-C8Rw1m1m.mjs} +2 -2
  30. package/dist/.setup/config-security-BEReZ6go.mjs +380 -0
  31. package/dist/{conversation-binding-DsB4-O7U.js → .setup/conversation-binding-DP-gMrBP.mjs} +29 -38
  32. package/dist/{conversation-binding-data-BiodpIzq.js → .setup/conversation-binding-data-CrcyZk6O.mjs} +1 -1
  33. package/dist/{conversation-control-CtUu1b3m.js → .setup/conversation-control-uK9Jomlc.mjs} +32 -67
  34. package/dist/.setup/cyber-failover-DYwbmf1o.mjs +123 -0
  35. package/dist/.setup/cyber-failover-notice-e9G3J9-e.mjs +17 -0
  36. package/dist/{dynamic-tools-CmN5RAip.js → .setup/dynamic-tools-BDXl-8Cw.mjs} +936 -620
  37. package/dist/{effective-mcp-catalog-Bd73bqA8.js → .setup/effective-mcp-catalog-CvnvnGIe.mjs} +3 -3
  38. package/dist/{ephemeral-turn-D78_VmzO.js → .setup/ephemeral-turn-poidXgek.mjs} +9 -7
  39. package/dist/{event-projector-assistant-message-BmBM4qBV.js → .setup/event-projector-assistant-message-BsruvNrH.mjs} +8 -7
  40. package/dist/{event-projector-items-5VhsECCO.js → .setup/event-projector-items-C6L_5ZiT.mjs} +42 -8
  41. package/dist/{attempt-notifications-C9XufG6l.js → .setup/event-projector-usage-CnBS8Wa3.mjs} +102 -9
  42. package/dist/{harness-C7rRa7bm.js → .setup/harness-a_MsE4-_.mjs} +81 -21
  43. package/dist/{inference-context-Dr_mzvk4.js → .setup/inference-context-D96l9-ew.mjs} +1 -1
  44. package/dist/.setup/inference-proxy-b-aJMSxm.mjs +601 -0
  45. package/dist/{isolated-completion-DWVb5U2J.js → .setup/isolated-completion-BIZFhTNG.mjs} +18 -11
  46. package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
  47. package/dist/{managed-binary-D22rNEcR.js → .setup/managed-binary-BnshlFag.mjs} +14 -3
  48. package/dist/{managed-thread-store-D1t5jh3G.js → .setup/managed-thread-store-BMqgThVL.mjs} +48 -14
  49. package/dist/{model-catalog-Dq2n8f_p.js → .setup/model-catalog-CfXJf9Ay.mjs} +36 -12
  50. package/dist/{models-PCKOim-h.js → .setup/models-KnqBv0hE.mjs} +3 -3
  51. package/dist/.setup/native-auth-rWbGbMn3.mjs +57 -0
  52. package/dist/{native-subagent-history-DjtPloaU.js → .setup/native-subagent-history-0nYYgo0k.mjs} +43 -35
  53. package/dist/.setup/native-subagent-monitor-D3filLY2.mjs +4859 -0
  54. package/dist/{native-subagent-task-ids-BzTdT0Uw.js → .setup/native-subagent-task-ids-wb8CKZGN.mjs} +98 -44
  55. package/dist/{node-cli-sessions-DKaOmVUh.js → .setup/node-cli-sessions-r3avj02l.mjs} +86 -68
  56. package/dist/.setup/node-exec-server.runtime-BDwWXVpK.mjs +247 -0
  57. package/dist/{plan-7uG-Fp36.js → .setup/plan-CN3VwfNU.mjs} +133 -119
  58. package/dist/{plugin-activation-BYQculil.js → .setup/plugin-activation-DT3MNtqj.mjs} +7 -16
  59. package/dist/{plugin-app-cache-key-d0eKxy7b.js → .setup/plugin-app-cache-key-B2CsSdnV.mjs} +32 -44
  60. package/dist/{plugin-approval-roundtrip-Bz3FT8W5.js → .setup/plugin-approval-roundtrip-C0MZzCuP.mjs} +1 -1
  61. package/dist/{plugin-inventory-oL4Na1ZG.js → .setup/plugin-inventory-BoRei8Z4.mjs} +21 -11
  62. package/dist/{plugin-marketplace-discovery-P-Vndfqq.js → .setup/plugin-marketplace-discovery-CDOi8IFs.mjs} +4 -1
  63. package/dist/{plugin-metadata-cache-ClPJpRio.js → .setup/plugin-metadata-cache-Ctmo83k_.mjs} +226 -141
  64. package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
  65. package/dist/{provider-MQ8PVkuE.js → .setup/provider-BOsxQHOM.mjs} +9 -5
  66. package/dist/{provider-capabilities-BvCUL69A.js → .setup/provider-capabilities-BfE88FZ5.mjs} +31 -3
  67. package/dist/{rate-limits-CBMmWBr9.js → .setup/rate-limits-CMU3DUD0.mjs} +174 -151
  68. package/dist/{request-B7hEkBGq.js → .setup/request-D2L0zMrq.mjs} +130 -42
  69. package/dist/{run-attempt-CvsAAGa0.js → .setup/run-attempt-BHu11r7h.mjs} +1628 -966
  70. package/dist/.setup/run-attempt-lifecycle-B7JbY4-F.mjs +71 -0
  71. package/dist/{runtime-artifact-BJ0rXBZ_.js → .setup/runtime-artifact-CLZ8udh-.mjs} +29 -45
  72. package/dist/{sandbox-guard-BxgyoM8M.js → .setup/sandbox-guard-C2sRMOEY.mjs} +3 -3
  73. package/dist/{session-binding-CI8UuilT.js → .setup/session-binding-Cm0apEbd.mjs} +36 -83
  74. package/dist/{session-binding-record-Bcvslnhf.js → .setup/session-binding-record-BGoz8wOK.mjs} +202 -5
  75. package/dist/.setup/session-binding-sidecars-BlB5EvIS.mjs +546 -0
  76. package/dist/.setup/session-catalog-Pno1xGcl.mjs +2764 -0
  77. package/dist/{session-catalog-adoption-tcZi1IfX.js → .setup/session-catalog-adoption-BI6UTDZT.mjs} +58 -26
  78. package/dist/{session-catalog-archive-CwKg8Xz2.js → .setup/session-catalog-archive-lHBqzhaO.mjs} +6 -6
  79. package/dist/.setup/session-catalog-events-Bj6j94E_.mjs +347 -0
  80. package/dist/.setup/session-catalog-index-B9_VQIUz.mjs +1170 -0
  81. package/dist/.setup/session-catalog-index-order-hcdz07yN.mjs +48 -0
  82. package/dist/.setup/session-catalog-index-state-Dgh8ORJm.mjs +183 -0
  83. package/dist/{thread-history-page-D0JIp48V.js → .setup/session-catalog-native-projection-DowriLid.mjs} +223 -95
  84. package/dist/{session-catalog-node-adoption-B1tgDW-m.js → .setup/session-catalog-node-adoption-ITddWx_X.mjs} +25 -13
  85. package/dist/{session-catalog-node-continue-Ci-DXyJP.js → .setup/session-catalog-node-continue-6g6qi4A9.mjs} +24 -15
  86. package/dist/.setup/session-catalog-projection-zK_PUsiE.mjs +422 -0
  87. package/dist/{session-cli-DNN_jhGc.js → .setup/session-cli-irrD-uo7.mjs} +3 -3
  88. package/dist/{session-history-Cz-tOOYj.js → .setup/session-history-BrqhSCf9.mjs} +19 -19
  89. package/dist/{session-history-import-DwyijFI6.js → .setup/session-history-import-D-3wAgOP.mjs} +4 -4
  90. package/dist/{session-history-read-cxPUxyVV.js → .setup/session-history-read-B3ZfSUbF.mjs} +2 -2
  91. package/dist/{session-history.worker-BeK1YOyT.js → .setup/session-history.worker-CaCh0xF_.mjs} +10 -24
  92. package/dist/{session-initialization-Ct0_Hzmg.js → .setup/session-initialization-rcgbZiid.mjs} +2 -2
  93. package/dist/{session-permission-policy-BBmXA8Eg.js → .setup/session-permission-policy-BI1QK_98.mjs} +2 -2
  94. package/dist/{session-retirement-B2YfbAAT.js → .setup/session-retirement-BH-S6qkJ.mjs} +26 -7
  95. package/dist/{settled-turn-context-Du6gdUDd.js → .setup/settled-turn-context-fmwouT5I.mjs} +2 -2
  96. package/dist/{settled-turn-finalizer-Dn91stmc.js → .setup/settled-turn-finalizer-DiAi6Kx6.mjs} +12 -12
  97. package/dist/{shared-client-CscigXXL.js → .setup/shared-client-DA4VR4Eb.mjs} +332 -221
  98. package/dist/{side-question-BGMJQf4U.js → .setup/side-question-BJ1wSDcB.mjs} +183 -230
  99. package/dist/{source-CElXU0Oy.js → .setup/source-CUzJq5WN.mjs} +11 -10
  100. package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
  101. package/dist/{thread-archive-guard-DfpBr-Sz.js → .setup/thread-archive-guard-C9frICzX.mjs} +10 -3
  102. package/dist/.setup/thread-history-page-DoVpnHim.mjs +83 -0
  103. package/dist/{thread-lifecycle-DXl1-I6b.js → .setup/thread-lifecycle-B3mfz1TG.mjs} +347 -2318
  104. package/dist/{thread-ownership-BsDRTsyp.js → .setup/thread-ownership-DcTtAcXj.mjs} +6 -4
  105. package/dist/{thread-policy-BuEQfE0g.js → .setup/thread-policy-DGuQsuFC.mjs} +19 -3
  106. package/dist/.setup/thread-requests-BLvGkP2R.mjs +2205 -0
  107. package/dist/{thread-resume-DsDOZpFg.js → .setup/thread-resume-DIBXwOpE.mjs} +8 -5
  108. package/dist/.setup/timeout-C910MdAB.mjs +80 -0
  109. package/dist/{transcript-history-projection-v17wXgdK.js → .setup/transcript-history-projection-ZZpkFkJ_.mjs} +96 -61
  110. package/dist/{transcript-mirror-C5CKgNy6.js → .setup/transcript-mirror-BtHDBp1G.mjs} +224 -195
  111. package/dist/{transcript-mirror-attestation-DibE0krH.js → .setup/transcript-mirror-attestation-CzM-94NC.mjs} +4 -1
  112. package/dist/{transport-stdio-BGjHoYLr.js → .setup/transport-stdio-h2VHOskC.mjs} +274 -89
  113. package/dist/{upstream-session-fork-BZerMte_.js → .setup/upstream-session-fork-BUr4OUbC.mjs} +51 -42
  114. package/dist/{usage-tCk-mg_x.js → .setup/usage-BML0r-ua.mjs} +5 -4
  115. package/dist/.setup/usage-limit-error-DUMbefVY.mjs +166 -0
  116. package/dist/{web-search-provider.runtime-B7bGbGWq.js → .setup/web-search-provider.runtime-CDKlN-Rv.mjs} +4 -3
  117. package/dist/api.js +23 -12
  118. package/dist/catalog-page-worker-entrypoint.js +12 -0
  119. package/dist/catalog-page.worker.js +9 -0
  120. package/dist/cli-metadata.js +1 -1
  121. package/dist/doctor-contract-api.js +8 -528
  122. package/dist/harness.js +1 -1
  123. package/dist/index.js +306 -215
  124. package/dist/media-understanding-provider.js +3 -3
  125. package/dist/migration-provider-api.js +1 -1
  126. package/dist/native-tool-policy.js +12 -0
  127. package/dist/provider-discovery.js +18 -0
  128. package/dist/session-history-worker-runtime.js +36 -35
  129. package/dist/session-history.worker.js +2 -2
  130. package/dist/web-search-contract-api.js +1 -1
  131. package/openclaw.plugin.json +354 -69
  132. package/package.json +14 -8
  133. package/dist/attempt-context-D44yeDII.js +0 -636
  134. package/dist/binding-connection-D3udKbIE.js +0 -60
  135. package/dist/event-projector-usage-BfXmpOec.js +0 -102
  136. package/dist/inference-proxy-HGXKUIre.js +0 -311
  137. package/dist/launch-args-RXQwn8zV.js +0 -90
  138. package/dist/native-subagent-history-owner-Pcp7JuVF.js +0 -34
  139. package/dist/native-subagent-monitor-fQ7eIXEf.js +0 -2978
  140. package/dist/node-exec-server.runtime-Cl2vapEi.js +0 -226
  141. package/dist/rpc-error-ttN_QjEm.js +0 -30
  142. package/dist/session-catalog-ct-AH01I.js +0 -1477
  143. package/dist/session-catalog-home-id-CwhLdC03.js +0 -18
  144. package/dist/session-catalog-provenance-D-dIfRAH.js +0 -96
  145. package/dist/timeout-BVw8aaM1.js +0 -33
  146. package/dist/version-omm6IPI3.js +0 -12
  147. /package/dist/{auth-profile-selection-DFu9e167.js → .setup/auth-profile-selection-DFu9e167.mjs} +0 -0
  148. /package/dist/{config-utils-DujwEnhg.js → .setup/config-utils-DujwEnhg.mjs} +0 -0
  149. /package/dist/{context-compaction-activity-CMla5FPJ.js → .setup/context-compaction-activity-CMla5FPJ.mjs} +0 -0
  150. /package/dist/{elicitation-input-DPoK8F7w.js → .setup/elicitation-input-DPoK8F7w.mjs} +0 -0
  151. /package/dist/{history-rejection-B4nOXNXF.js → .setup/history-rejection-B4nOXNXF.mjs} +0 -0
  152. /package/dist/{image-payload-sanitizer-tupAr-2o.js → .setup/image-payload-sanitizer-tupAr-2o.mjs} +0 -0
  153. /package/dist/{incognito-session-uhrBF6wJ.js → .setup/incognito-session-uhrBF6wJ.mjs} +0 -0
  154. /package/dist/{local-runtime-attribution-B_2mnqhb.js → .setup/local-runtime-attribution-B_2mnqhb.mjs} +0 -0
  155. /package/dist/{native-execution-policy-umd0tgh4.js → .setup/native-execution-policy-umd0tgh4.mjs} +0 -0
  156. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  157. /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
  158. /package/dist/{session-upstream-marker-D15C9NHp.js → .setup/session-upstream-marker-D15C9NHp.mjs} +0 -0
  159. /package/dist/{upstream-prompt-provenance-LphB8slG.js → .setup/upstream-prompt-provenance-LphB8slG.mjs} +0 -0
  160. /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
@@ -1,60 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { x as readCodexPluginConfig } from "./protocol-5bh1G-H7.js";
3
- import { a as resolveCodexCatalogConnectionHome, t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-d0eKxy7b.js";
4
- import { n as resolveCodexAppServerRuntimeOptions, r as resolveCodexSupervisionAppServerRuntimeOptions } from "./config-runtime-D0zGNIHu.js";
5
- import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-registration";
6
- //#region extensions/codex/src/app-server/binding-connection.ts
7
- var binding_connection_exports = /* @__PURE__ */ __exportAll({
8
- assertCodexSessionRuntimeOwnership: () => assertCodexSessionRuntimeOwnership,
9
- requireCodexSupervisionModelSelection: () => requireCodexSupervisionModelSelection,
10
- resolveCodexBindingAppServerConnection: () => resolveCodexBindingAppServerConnection
11
- });
12
- /** Prevents a prepared native session from becoming a fresh thread after its binding changes. */
13
- function assertCodexSessionRuntimeOwnership(binding, expected) {
14
- if (!expected) return;
15
- const auth = binding?.connectionScope === "supervision" ? "native" : "host";
16
- const hostModelChanged = expected.auth === "host" && (!expected.modelRef || binding?.model !== expected.modelRef.model || binding?.modelProvider !== expected.modelRef.provider);
17
- if (binding?.preserveNativeModel !== true || auth !== expected.auth || hostModelChanged) throw new AgentHarnessPreflightError("Codex native session ownership is missing or changed. Reattach the original native session or create a new chat with a concrete model; no replacement thread was started.");
18
- }
19
- /** Requires the native model pair after a supervised pending branch has materialized. */
20
- function requireCodexSupervisionModelSelection(binding) {
21
- const model = binding.model?.trim();
22
- const modelProvider = binding.modelProvider?.trim();
23
- if (binding.connectionScope !== "supervision" || !model || !modelProvider) throw new Error("Codex supervised binding is missing its native model and provider; refusing request selection");
24
- return {
25
- model,
26
- modelProvider
27
- };
28
- }
29
- /** Resolves connection and auth ownership exclusively from the private thread binding. */
30
- function resolveCodexBindingAppServerConnection(params) {
31
- const { binding, authProfileId, ...runtimeParams } = params;
32
- const usesSupervisionConnection = binding?.connectionScope === "supervision";
33
- if (usesSupervisionConnection && readCodexPluginConfig(runtimeParams.pluginConfig).supervision?.enabled !== true) throw new Error("Codex supervision is disabled; refusing to open a native user-home supervised session");
34
- let appServer = (usesSupervisionConnection ? resolveCodexSupervisionAppServerRuntimeOptions : resolveCodexAppServerRuntimeOptions)(runtimeParams);
35
- if (usesSupervisionConnection) {
36
- const persistedFingerprint = binding.pendingSupervisionBranch?.connectionFingerprint ?? binding.appServerRuntimeFingerprint;
37
- const catalogHome = persistedFingerprint ? resolveCodexCatalogConnectionHome(persistedFingerprint, runtimeParams.agentDir) : void 0;
38
- if (catalogHome) appServer = {
39
- ...appServer,
40
- start: {
41
- ...appServer.start,
42
- homeScope: "user",
43
- env: {
44
- ...appServer.start.env,
45
- CODEX_HOME: catalogHome
46
- }
47
- }
48
- };
49
- const currentFingerprint = buildCodexAppServerConnectionFingerprint(appServer, runtimeParams.agentDir);
50
- if (!persistedFingerprint || persistedFingerprint !== currentFingerprint) throw new Error("Codex supervision connection changed; refusing to operate on its bound native thread");
51
- }
52
- return {
53
- appServer,
54
- usesSupervisionConnection,
55
- requestAuthProfileId: usesSupervisionConnection ? void 0 : authProfileId,
56
- clientAuthProfileId: usesSupervisionConnection ? null : authProfileId
57
- };
58
- }
59
- //#endregion
60
- export { resolveCodexBindingAppServerConnection as i, binding_connection_exports as n, requireCodexSupervisionModelSelection as r, assertCodexSessionRuntimeOwnership as t };
@@ -1,102 +0,0 @@
1
- import { o as isJsonObject } from "./protocol-5bh1G-H7.js";
2
- import { asSafeIntegerInRange, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
3
- import { normalizeUsage } from "openclaw/plugin-sdk/agent-harness-runtime";
4
- //#region extensions/codex/src/app-server/event-projector-usage.ts
5
- function readTokenCount(record, key) {
6
- return asSafeIntegerInRange(record[key], { min: 0 });
7
- }
8
- function readCodexThreadTokenUsage(params) {
9
- const tokenUsage = isJsonObject(params.tokenUsage) ? params.tokenUsage : void 0;
10
- const last = tokenUsage && isJsonObject(tokenUsage.last) ? tokenUsage.last : void 0;
11
- return last ? normalizeCodexResponseTokenUsage(last) : void 0;
12
- }
13
- function readCodexThreadContextSnapshot(params) {
14
- const tokenUsage = isJsonObject(params.tokenUsage) ? params.tokenUsage : void 0;
15
- const last = tokenUsage && isJsonObject(tokenUsage.last) ? tokenUsage.last : void 0;
16
- const modelContextWindow = tokenUsage ? readTokenCount(tokenUsage, "modelContextWindow") : void 0;
17
- const activeContextTokens = last ? readTokenCount(last, "totalTokens") : void 0;
18
- const inputTokens = last ? readTokenCount(last, "inputTokens") : void 0;
19
- const cachedInputTokens = last ? readTokenCount(last, "cachedInputTokens") : void 0;
20
- const cacheWriteInputTokens = last ? readTokenCount(last, "cacheWriteInputTokens") : void 0;
21
- const reasoningOutputTokens = last ? readTokenCount(last, "reasoningOutputTokens") : void 0;
22
- return {
23
- ...activeContextTokens !== void 0 ? { activeContextTokens } : {},
24
- ...cachedInputTokens !== void 0 ? { cachedInputTokens } : {},
25
- ...cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens } : {},
26
- ...inputTokens !== void 0 ? { inputTokens } : {},
27
- ...modelContextWindow && modelContextWindow > 0 ? { modelContextWindow } : {},
28
- ...inputTokens !== void 0 ? { promptTokens: inputTokens } : {},
29
- ...reasoningOutputTokens !== void 0 ? { reasoningOutputTokens } : {}
30
- };
31
- }
32
- function normalizeCodexResponseTokenUsage(record) {
33
- const totalTokens = readTokenCount(record, "totalTokens");
34
- const inputTokens = readTokenCount(record, "inputTokens");
35
- const cacheRead = readTokenCount(record, "cachedInputTokens");
36
- const output = readTokenCount(record, "outputTokens");
37
- const reasoningTokens = readTokenCount(record, "reasoningOutputTokens");
38
- const cacheWrite = record.cacheWriteInputTokens === void 0 ? 0 : readTokenCount(record, "cacheWriteInputTokens");
39
- const hasCoherentInput = inputTokens !== void 0 && cacheRead !== void 0 && cacheWrite !== void 0 && cacheRead + cacheWrite <= inputTokens;
40
- const hasCoherentContext = hasCoherentInput && totalTokens !== void 0 && output !== void 0 && totalTokens === inputTokens + output;
41
- const usage = normalizeUsage({
42
- input: hasCoherentInput ? inputTokens - cacheRead - cacheWrite : void 0,
43
- output,
44
- cacheRead,
45
- cacheWrite,
46
- reasoningTokens,
47
- total: totalTokens
48
- });
49
- if (!usage) return;
50
- return {
51
- ...usage,
52
- contextUsage: hasCoherentContext ? {
53
- state: "available",
54
- promptTokens: inputTokens,
55
- totalTokens
56
- } : { state: "unavailable" }
57
- };
58
- }
59
- var CodexUsageProjection = class {
60
- constructor() {
61
- this.responseIds = /* @__PURE__ */ new Set();
62
- }
63
- get usage() {
64
- const usage = this.responseUsage ?? this.threadUsage;
65
- return usage ? {
66
- ...usage,
67
- contextUsage: this.contextUsage
68
- } : void 0;
69
- }
70
- get modelIterations() {
71
- return this.responseIds.size;
72
- }
73
- invalidateContext() {
74
- this.contextUsage = { state: "unavailable" };
75
- }
76
- recordThread(params) {
77
- const usage = readCodexThreadTokenUsage(params);
78
- this.threadUsage = usage ?? this.threadUsage;
79
- if (!this.responseUsage && usage) this.contextUsage = usage.contextUsage;
80
- return readCodexThreadContextSnapshot(params);
81
- }
82
- record(params, reportOutputTokens) {
83
- const responseId = readStringField(params, "responseId");
84
- if (!responseId || this.responseIds.has(responseId)) return;
85
- this.responseIds.add(responseId);
86
- const usage = isJsonObject(params.usage) ? normalizeCodexResponseTokenUsage(params.usage) : void 0;
87
- this.contextUsage = usage?.contextUsage ?? { state: "unavailable" };
88
- this.responseUsage ??= {};
89
- for (const field of [
90
- "input",
91
- "output",
92
- "cacheRead",
93
- "cacheWrite",
94
- "reasoningTokens",
95
- "total"
96
- ]) if (usage?.[field] !== void 0) this.responseUsage[field] = (this.responseUsage[field] ?? 0) + usage[field];
97
- const outputTokens = usage?.output;
98
- if (outputTokens !== void 0) reportOutputTokens?.(outputTokens);
99
- }
100
- };
101
- //#endregion
102
- export { readCodexThreadContextSnapshot as n, CodexUsageProjection as t };
@@ -1,311 +0,0 @@
1
- import { o as isJsonObject } from "./protocol-5bh1G-H7.js";
2
- import { n as createCodexInferenceContext } from "./inference-context-Dr_mzvk4.js";
3
- import { zstdCompress, zstdDecompress } from "node:zlib";
4
- import { promisify } from "node:util";
5
- import { Writable } from "node:stream";
6
- import WebSocket, { WebSocketServer } from "ws";
7
- import { createServer } from "node:http";
8
- import { createNodeProxyAgent } from "openclaw/plugin-sdk/fetch-runtime";
9
- import { generateSecureToken } from "openclaw/plugin-sdk/secure-random-runtime";
10
- import { fetchWithSsrFGuard, isBlockedHostnameOrIp, resolvePinnedHostnameWithPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
11
- //#region extensions/codex/src/app-server/inference-proxy.ts
12
- const MAX_BODY_BYTES = 33554432;
13
- const MAX_ERROR_BODY_BYTES = 1048576;
14
- const MAX_CONNECTIONS = 16;
15
- const compress = promisify(zstdCompress);
16
- const decompress = promisify(zstdDecompress);
17
- const HOP_HEADERS = /* @__PURE__ */ new Set([
18
- "connection",
19
- "keep-alive",
20
- "proxy-authenticate",
21
- "proxy-authorization",
22
- "te",
23
- "trailer",
24
- "transfer-encoding",
25
- "upgrade",
26
- "host",
27
- "content-length"
28
- ]);
29
- const FAILURE = "Codex parent-local inference transport failed; retry on a fresh connection.";
30
- /** Private, fixed-destination relay. No upstream credentials or model content are retained. */
31
- async function createCodexInferenceProxy(params) {
32
- const upstream = new URL(params.upstream);
33
- if (upstream.protocol !== "https:" || upstream.username || upstream.password || upstream.hash) throw new Error("Codex inference requires a credential-free HTTPS upstream URL");
34
- const lifetime = new AbortController();
35
- const assertCurrent = () => {
36
- lifetime.signal.throwIfAborted();
37
- params.assertCurrent();
38
- };
39
- const context = createCodexInferenceContext(assertCurrent);
40
- const pathPrefix = "/" + generateSecureToken({
41
- bytes: 32,
42
- redact: true
43
- }) + upstream.pathname.replace(/\/$/, "");
44
- const active = /* @__PURE__ */ new Set();
45
- const sockets = /* @__PURE__ */ new Set();
46
- const wss = new WebSocketServer({
47
- noServer: true,
48
- maxPayload: MAX_BODY_BYTES,
49
- perMessageDeflate: false
50
- });
51
- const handshakeHeaders = /* @__PURE__ */ new WeakMap();
52
- wss.on("headers", (headers, request) => {
53
- for (const [key, value] of Object.entries(handshakeHeaders.get(request) ?? {})) if (!key.startsWith("sec-websocket-")) headers.push(key + ": " + value);
54
- handshakeHeaders.delete(request);
55
- });
56
- const resolveTarget = (request) => {
57
- assertCurrent();
58
- if (request.headers.origin || !request.url?.startsWith(pathPrefix + "/") || isBlockedHostnameOrIp(upstream.hostname)) throw new Error(FAILURE);
59
- const suffix = request.url.slice(pathPrefix.length);
60
- if (suffix.startsWith("//") || suffix.includes("\\") || /%2e|%2f|%5c|(?:^|\/)\.\.?(?:\/|\?|$)/i.test(suffix)) throw new Error(FAILURE);
61
- const target = new URL(upstream);
62
- const incoming = new URL(suffix, "http://localhost");
63
- target.pathname = upstream.pathname.replace(/\/$/, "") + incoming.pathname;
64
- for (const [key, value] of incoming.searchParams) target.searchParams.append(key, value);
65
- return {
66
- target,
67
- sampling: incoming.pathname === "/responses"
68
- };
69
- };
70
- const prepare = (bytes, sampling) => {
71
- assertCurrent();
72
- if (!sampling) return {
73
- bytes,
74
- assertCurrent,
75
- signal: void 0
76
- };
77
- const value = JSON.parse(bytes.toString("utf8"));
78
- if (!isJsonObject(value)) throw new Error(FAILURE);
79
- const prepared = context.prepare(value);
80
- const rewritten = Buffer.from(JSON.stringify(prepared.body));
81
- if (rewritten.length > MAX_BODY_BYTES) throw new Error(FAILURE);
82
- return {
83
- ...prepared,
84
- bytes: rewritten
85
- };
86
- };
87
- const server = createServer((req, res) => {
88
- const controller = new AbortController();
89
- let guarded;
90
- const abort = () => controller.abort();
91
- req.once("aborted", abort);
92
- res.once("close", abort);
93
- (async () => {
94
- try {
95
- const { target, sampling } = resolveTarget(req);
96
- if (req.method !== "POST" || active.size >= MAX_CONNECTIONS) throw new Error(FAILURE);
97
- active.add(controller);
98
- const wire = await readProxyBody(req, MAX_BODY_BYTES);
99
- const encoding = req.headers["content-encoding"];
100
- if (encoding && encoding !== "identity" && encoding !== "zstd") throw new Error(FAILURE);
101
- const decoded = encoding === "zstd" ? await decompress(wire, { maxOutputLength: MAX_BODY_BYTES }) : wire;
102
- assertCurrent();
103
- const prepared = prepare(decoded, sampling);
104
- const body = Buffer.from(encoding === "zstd" ? await compress(prepared.bytes) : prepared.bytes);
105
- prepared.assertCurrent();
106
- const signal = AbortSignal.any([
107
- lifetime.signal,
108
- controller.signal,
109
- ...prepared.signal ? [prepared.signal] : []
110
- ]);
111
- guarded = await fetchWithSsrFGuard({
112
- url: target.toString(),
113
- init: {
114
- method: "POST",
115
- headers: relayHeaders(req.headers),
116
- body,
117
- signal
118
- },
119
- signal,
120
- beforeRequest: prepared.assertCurrent,
121
- requireHttps: true,
122
- maxRedirects: 0,
123
- capture: false,
124
- mode: "trusted_env_proxy",
125
- auditContext: "codex-parent-local-inference"
126
- });
127
- prepared.assertCurrent();
128
- const headers = Object.fromEntries(guarded.response.headers);
129
- delete headers["content-encoding"];
130
- res.writeHead(guarded.response.status, relayHeaders(headers));
131
- if (!guarded.response.body) res.end();
132
- else await guarded.response.body.pipeTo(Writable.toWeb(res), { signal });
133
- } catch {
134
- if (!res.headersSent && !res.destroyed) res.writeHead(502, { "content-type": "text/plain" }).end(FAILURE);
135
- else res.destroy();
136
- } finally {
137
- active.delete(controller);
138
- req.off("aborted", abort);
139
- res.off("close", abort);
140
- await guarded?.release().catch(() => void 0);
141
- }
142
- })();
143
- });
144
- server.maxConnections = MAX_CONNECTIONS;
145
- server.requestTimeout = 3e4;
146
- server.headersTimeout = 1e4;
147
- server.on("upgrade", (req, socket, head) => {
148
- (async () => {
149
- let remote;
150
- let local;
151
- let proxyAgent;
152
- const controller = new AbortController();
153
- const close = () => {
154
- controller.abort();
155
- active.delete(controller);
156
- remote?.terminate();
157
- local?.terminate();
158
- proxyAgent?.destroy();
159
- if (remote) sockets.delete(remote);
160
- if (local) sockets.delete(local);
161
- socket.destroy();
162
- };
163
- try {
164
- const { target, sampling } = resolveTarget(req);
165
- if (!sampling || active.size >= MAX_CONNECTIONS) throw new Error(FAILURE);
166
- active.add(controller);
167
- socket.once("close", close);
168
- socket.once("error", close);
169
- const signal = AbortSignal.any([lifetime.signal, controller.signal]);
170
- proxyAgent = createNodeProxyAgent({
171
- mode: "env",
172
- targetUrl: target.href
173
- });
174
- const lookup = proxyAgent ? void 0 : (await resolvePinnedHostnameWithPolicy(target.hostname, { signal })).lookup;
175
- assertCurrent();
176
- signal.throwIfAborted();
177
- target.protocol = "wss:";
178
- const headers = relayHeaders(req.headers);
179
- for (const key of Object.keys(headers)) if (key.startsWith("sec-websocket-")) delete headers[key];
180
- remote = new WebSocket(target, {
181
- headers,
182
- ...proxyAgent ? { agent: proxyAgent } : { lookup },
183
- followRedirects: false,
184
- perMessageDeflate: false,
185
- maxPayload: MAX_BODY_BYTES,
186
- handshakeTimeout: 1e4
187
- });
188
- sockets.add(remote);
189
- remote.once("upgrade", (response) => {
190
- handshakeHeaders.set(req, relayHeaders(response.headers));
191
- });
192
- remote.once("error", close);
193
- remote.once("close", close);
194
- remote.once("unexpected-response", (_request, response) => {
195
- (async () => {
196
- try {
197
- const body = await readProxyBody(response, MAX_ERROR_BODY_BYTES);
198
- assertCurrent();
199
- signal.throwIfAborted();
200
- const failureHeaders = Object.entries(relayHeaders(response.headers)).map(([key, value]) => key + ": " + value);
201
- failureHeaders.push("Connection: close", "Content-Length: " + body.length);
202
- const status = "HTTP/1.1 " + response.statusCode + " " + (response.statusMessage ?? "Upstream refused");
203
- socket.end(Buffer.concat([Buffer.from(status + "\r\n" + failureHeaders.join("\r\n") + "\r\n\r\n"), body]), close);
204
- } catch {
205
- close();
206
- }
207
- })();
208
- });
209
- remote.once("open", () => {
210
- try {
211
- assertCurrent();
212
- signal.throwIfAborted();
213
- wss.handleUpgrade(req, socket, head, (accepted) => {
214
- local = accepted;
215
- sockets.add(accepted);
216
- accepted.once("error", close);
217
- accepted.once("close", close);
218
- let releaseFrame = () => {};
219
- accepted.on("message", (data, binary) => {
220
- try {
221
- if (binary) throw new Error(FAILURE);
222
- const prepared = prepare(rawBytes(data), true);
223
- prepared.assertCurrent();
224
- releaseFrame();
225
- const onAbort = () => close();
226
- prepared.signal?.addEventListener("abort", onAbort, { once: true });
227
- releaseFrame = () => prepared.signal?.removeEventListener("abort", onAbort);
228
- if (!remote || remote.readyState !== WebSocket.OPEN || remote.bufferedAmount + prepared.bytes.length > MAX_BODY_BYTES) throw new Error(FAILURE);
229
- remote.send(prepared.bytes, { binary: false }, (error) => {
230
- if (error) close();
231
- });
232
- } catch {
233
- close();
234
- }
235
- });
236
- accepted.once("close", () => releaseFrame());
237
- remote.on("message", (data, binary) => {
238
- if (accepted.readyState !== WebSocket.OPEN || accepted.bufferedAmount + rawBytes(data).length > MAX_BODY_BYTES) {
239
- close();
240
- return;
241
- }
242
- accepted.send(data, { binary }, (error) => {
243
- if (error) close();
244
- });
245
- });
246
- });
247
- } catch {
248
- close();
249
- }
250
- });
251
- } catch {
252
- close();
253
- }
254
- })();
255
- });
256
- const close = () => {
257
- lifetime.abort();
258
- context.close();
259
- for (const controller of active) controller.abort();
260
- for (const socket of sockets) socket.terminate();
261
- server.close();
262
- server.closeAllConnections();
263
- wss.close();
264
- };
265
- try {
266
- await new Promise((resolve, reject) => {
267
- server.once("error", reject);
268
- server.listen(0, "127.0.0.1", () => {
269
- server.off("error", reject);
270
- resolve();
271
- });
272
- });
273
- assertCurrent();
274
- server.on("error", close);
275
- const address = server.address();
276
- if (!address || typeof address === "string") throw new Error(FAILURE);
277
- return {
278
- context,
279
- upstream: upstream.toString(),
280
- baseUrl: "http://127.0.0.1:" + address.port + pathPrefix,
281
- assertCurrent,
282
- close
283
- };
284
- } catch (error) {
285
- close();
286
- throw error;
287
- }
288
- }
289
- async function readProxyBody(stream, maxBytes) {
290
- const chunks = [];
291
- let size = 0;
292
- for await (const chunk of stream) {
293
- const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
294
- size += bytes.length;
295
- if (size > maxBytes) throw new Error(FAILURE);
296
- chunks.push(bytes);
297
- }
298
- return Buffer.concat(chunks);
299
- }
300
- function rawBytes(data) {
301
- return Array.isArray(data) ? Buffer.concat(data) : Buffer.isBuffer(data) ? data : Buffer.from(data);
302
- }
303
- function relayHeaders(input) {
304
- const excluded = new Set(HOP_HEADERS);
305
- for (const token of (input.connection ?? "").split(",")) excluded.add(token.trim().toLowerCase());
306
- const output = {};
307
- for (const [key, value] of Object.entries(input)) if (value !== void 0 && !excluded.has(key.toLowerCase())) output[key.toLowerCase()] = Array.isArray(value) ? value.join(", ") : value;
308
- return output;
309
- }
310
- //#endregion
311
- export { createCodexInferenceProxy };
@@ -1,90 +0,0 @@
1
- //#region extensions/codex/src/app-server/launch-args.ts
2
- const CODEX_VALUE_OPTIONS = /* @__PURE__ */ new Set([
3
- "-m",
4
- "--model",
5
- "--local-provider",
6
- "-p",
7
- "--profile",
8
- "-s",
9
- "--sandbox",
10
- "-a",
11
- "--ask-for-approval",
12
- "-C",
13
- "--cd",
14
- "--add-dir",
15
- "--remote",
16
- "--remote-auth-token-env",
17
- "-c",
18
- "--config",
19
- "--enable",
20
- "--disable",
21
- "--listen",
22
- "--code-mode-host",
23
- "--ws-auth",
24
- "--ws-token-file",
25
- "--ws-token-sha256",
26
- "--ws-shared-secret-file",
27
- "--ws-issuer",
28
- "--ws-audience",
29
- "--ws-max-clock-skew-seconds"
30
- ]);
31
- /** One tokenization owner for launch, turn policy, reviewer trust, and private turns. */
32
- function readCodexArgs(args) {
33
- const tokens = [];
34
- let nativeSubcommand = false;
35
- let end = 0;
36
- for (const [index, arg] of args.entries()) {
37
- if (index < end) continue;
38
- end = index + 1;
39
- const attached = /^(--[^=]+)=([\s\S]*)$/u.exec(arg) ?? /^(-[cmpisaC])=?([\s\S]+)$/u.exec(arg);
40
- const name = attached?.[1] ?? arg;
41
- let value = attached?.[2];
42
- if (name === "-i" || name === "--image") while (args[end]?.startsWith("-") === false) end += 1;
43
- else if (!attached && CODEX_VALUE_OPTIONS.has(name)) {
44
- value = args[end];
45
- if (value !== void 0) end += 1;
46
- }
47
- tokens.push({
48
- index,
49
- end,
50
- name,
51
- value
52
- });
53
- if (name === "app-server") nativeSubcommand = true;
54
- if (name === "--" && nativeSubcommand) break;
55
- }
56
- return tokens;
57
- }
58
- function readCodexAppServerConfigOptions(args) {
59
- return readCodexArgs(args).filter(({ name }) => name === "-c" || name === "--config" || name === "-p" || name === "--profile");
60
- }
61
- /** The stdio proxy forwards to an external server; it does not own that runtime. */
62
- function isCodexAppServerProxyLaunch(args) {
63
- const tokens = readCodexArgs(args);
64
- const server = tokens.findLastIndex(({ name }) => name === "app-server");
65
- return server >= 0 && tokens.slice(server + 1).find(({ name }) => !name.startsWith("-"))?.name === "proxy";
66
- }
67
- /** Keeps Codex overrides in one CLI scope without rewriting raw TOML or wrapper prefixes. */
68
- function normalizeCodexAppServerArgs(rawArgs, enforcedOverride) {
69
- const tokens = readCodexArgs(rawArgs);
70
- const subcommandIndex = tokens.findLast(({ name }) => name === "app-server")?.index ?? -1;
71
- const prefix = subcommandIndex < 0 ? [...rawArgs] : rawArgs.slice(0, subcommandIndex);
72
- const suffix = [];
73
- if (subcommandIndex >= 0) for (const token of tokens) {
74
- if (token.index <= subcommandIndex) continue;
75
- if (token.name === "--") {
76
- suffix.push(...rawArgs.slice(token.index));
77
- break;
78
- }
79
- (token.name === "-c" || token.name === "--config" ? prefix : suffix).push(...rawArgs.slice(token.index, token.end));
80
- }
81
- if (enforcedOverride && !(prefix.at(-2) === "-c" && prefix.at(-1) === enforcedOverride)) prefix.push("-c", enforcedOverride);
82
- const normalized = subcommandIndex < 0 ? prefix : [
83
- ...prefix,
84
- "app-server",
85
- ...suffix
86
- ];
87
- return normalized.length === rawArgs.length && normalized.every((arg, index) => arg === rawArgs[index]) ? rawArgs : normalized;
88
- }
89
- //#endregion
90
- export { normalizeCodexAppServerArgs as n, readCodexAppServerConfigOptions as r, isCodexAppServerProxyLaunch as t };
@@ -1,34 +0,0 @@
1
- import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
2
- import { createHash } from "node:crypto";
3
- //#region extensions/codex/src/app-server/native-subagent-history-owner.ts
4
- function codexNativeSubagentHistoryConnectionFingerprint(binding) {
5
- if (!binding.appServerRuntimeFingerprint) return;
6
- return createHash("sha256").update(JSON.stringify([
7
- binding.appServerRuntimeFingerprint,
8
- binding.connectionScope ?? null,
9
- binding.authProfileId ?? null
10
- ])).digest("hex");
11
- }
12
- function createCodexNativeSubagentHistoryOwner(params) {
13
- const connectionFingerprint = codexNativeSubagentHistoryConnectionFingerprint(params.binding);
14
- return connectionFingerprint ? {
15
- parentThreadId: params.parentThreadId,
16
- sessionId: params.sessionId,
17
- ...params.lifecycleRevision ? { lifecycleRevision: params.lifecycleRevision } : {},
18
- connectionFingerprint
19
- } : void 0;
20
- }
21
- function readCodexNativeSubagentHistoryOwner(detail) {
22
- const value = asOptionalRecord(detail)?.nativeHistory;
23
- if (value === void 0) return;
24
- const owner = asOptionalRecord(value);
25
- if (typeof owner?.parentThreadId !== "string" || !owner.parentThreadId.trim() || typeof owner.sessionId !== "string" || !owner.sessionId.trim() || owner.lifecycleRevision !== void 0 && (typeof owner.lifecycleRevision !== "string" || !owner.lifecycleRevision.trim()) || typeof owner.connectionFingerprint !== "string" || !/^[a-f0-9]{64}$/u.test(owner.connectionFingerprint)) throw new Error("Subagent history owner is invalid.");
26
- return {
27
- parentThreadId: owner.parentThreadId,
28
- sessionId: owner.sessionId,
29
- ...typeof owner.lifecycleRevision === "string" ? { lifecycleRevision: owner.lifecycleRevision } : {},
30
- connectionFingerprint: owner.connectionFingerprint
31
- };
32
- }
33
- //#endregion
34
- export { createCodexNativeSubagentHistoryOwner as n, readCodexNativeSubagentHistoryOwner as r, codexNativeSubagentHistoryConnectionFingerprint as t };