@openclaw/codex 2026.9.6 → 2026.9.8

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 (158) hide show
  1. package/README.md +2 -0
  2. package/assets/icon.png +0 -0
  3. package/dist/.setup/{account-usage-runtime-Eem_WGqY.mjs → account-usage-runtime-G348lY1q.mjs} +5 -5
  4. package/dist/.setup/{apply-DDOi8uNx.mjs → apply-Cqb-YoCS.mjs} +22 -36
  5. package/dist/.setup/{attempt-client-cleanup-CEv1cKwF.mjs → attempt-client-cleanup-B-S7ngS_.mjs} +128 -37
  6. package/dist/.setup/attempt-workspace-context-BJ5Z_olH.mjs +164 -0
  7. package/dist/.setup/{auth-binding-DhLWa_7K.mjs → auth-binding-BLWz7stm.mjs} +14 -1
  8. package/dist/.setup/{auth-cache-key-B2mpaI9D.mjs → auth-cache-key-Dnps4W4_.mjs} +36 -34
  9. package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
  10. package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
  11. package/dist/.setup/{binding-connection-ThoatDcb.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
  12. package/dist/.setup/{binding-connection.runtime-yoHrABt-.mjs → binding-connection.runtime-6TpgD1M6.mjs} +4 -4
  13. package/dist/.setup/{bounded-turn-B2HScEgT.mjs → bounded-turn-BNunZPtz.mjs} +15 -18
  14. package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
  15. package/dist/.setup/{build-state-C7EnDVgr.mjs → build-state-DIQ5O_-S.mjs} +1 -1
  16. package/dist/.setup/{capabilities-CDXOOFdZ.mjs → capabilities-B3WEZl4e.mjs} +2 -10
  17. package/dist/.setup/{client-catalog-response-BMgt_4q4.mjs → client-catalog-response-DRvx_wCC.mjs} +1 -1
  18. package/dist/.setup/{client-Cs08OXVQ.mjs → client-qyUBJlGZ.mjs} +138 -399
  19. package/dist/.setup/{command-dispatch-B4JuOsOk.mjs → command-dispatch-Btrs1D6f.mjs} +5 -8
  20. package/dist/.setup/{command-formatters-Bmqvr9tO.mjs → command-formatters-R3ckE3Co.mjs} +29 -61
  21. package/dist/.setup/{command-handlers-DW7Lx9oH.mjs → command-handlers-DvlCHJch.mjs} +222 -343
  22. package/dist/.setup/{command-rpc-DixIj3HW.mjs → command-rpc-skzRq4wD.mjs} +15 -18
  23. package/dist/.setup/compact-8ttks5U5.mjs +776 -0
  24. package/dist/.setup/{config-BoTP_mrL.mjs → config-DKhXquav.mjs} +26 -28
  25. package/dist/.setup/{config-options-BvaRs51b.mjs → config-options-CzyWLTJt.mjs} +24 -37
  26. package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
  27. package/dist/.setup/{config-runtime-C8Rw1m1m.mjs → config-runtime-C0NbLms1.mjs} +2 -2
  28. package/dist/.setup/{config-security-BEReZ6go.mjs → config-security-CE-FcGw9.mjs} +32 -111
  29. package/dist/.setup/{config-utils-DujwEnhg.mjs → config-utils-D0CXecki.mjs} +3 -13
  30. package/dist/.setup/context-engine-projection-PezSESth.mjs +387 -0
  31. package/dist/.setup/{conversation-binding-DP-gMrBP.mjs → conversation-binding-74LaGGH-.mjs} +67 -90
  32. package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
  33. package/dist/.setup/{conversation-control-uK9Jomlc.mjs → conversation-control-OrN6zuaY.mjs} +8 -8
  34. package/dist/.setup/{cyber-failover-DYwbmf1o.mjs → cyber-failover-XV0nNRZu.mjs} +1 -1
  35. package/dist/.setup/{cyber-failover-notice-e9G3J9-e.mjs → cyber-failover-notice-RNpGpTyP.mjs} +1 -1
  36. package/dist/.setup/{dynamic-tools-BDXl-8Cw.mjs → dynamic-tools-Db2sY5cZ.mjs} +2305 -2606
  37. package/dist/.setup/{effective-mcp-catalog-CvnvnGIe.mjs → effective-mcp-catalog-Bi6-SQ7i.mjs} +8 -17
  38. package/dist/.setup/{ephemeral-turn-poidXgek.mjs → ephemeral-turn-DiCS1ijR.mjs} +3 -3
  39. package/dist/.setup/event-projector-assistant-message-MV_1dj-3.mjs +69 -0
  40. package/dist/.setup/{event-projector-usage-CnBS8Wa3.mjs → event-projector-usage-03R0I2dM.mjs} +3 -25
  41. package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
  42. package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
  43. package/dist/.setup/{inference-context-D96l9-ew.mjs → inference-context-D-9gWlTR.mjs} +16 -18
  44. package/dist/.setup/inference-dispatch-CMZtjQyz.mjs +359 -0
  45. package/dist/.setup/inference-metadata-CgIf7sOx.mjs +81 -0
  46. package/dist/.setup/{inference-proxy-b-aJMSxm.mjs → inference-proxy-DhcXOgUE.mjs} +174 -214
  47. package/dist/.setup/{isolated-completion-BIZFhTNG.mjs → isolated-completion-D80IXfQF.mjs} +9 -12
  48. package/dist/.setup/{managed-binary-BnshlFag.mjs → managed-binary-kiWRhNRE.mjs} +8 -12
  49. package/dist/.setup/{model-catalog-CfXJf9Ay.mjs → model-catalog-DiC0Tkha.mjs} +11 -10
  50. package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
  51. package/dist/.setup/{models-KnqBv0hE.mjs → models-DfLmPV0k.mjs} +9 -18
  52. package/dist/.setup/{native-auth-rWbGbMn3.mjs → native-auth-CuG53tu4.mjs} +4 -4
  53. package/dist/.setup/{native-execution-policy-umd0tgh4.mjs → native-execution-policy-BxZJy5mP.mjs} +5 -30
  54. package/dist/.setup/{native-subagent-monitor-D3filLY2.mjs → native-subagent-monitor-BwkQXf9e.mjs} +4395 -3609
  55. package/dist/.setup/native-subagent-pending-assignments-DwkCzLvD.mjs +203 -0
  56. package/dist/.setup/native-task-assignments-DMQ0g3hu.mjs +194 -0
  57. package/dist/.setup/{node-cli-sessions-r3avj02l.mjs → node-cli-sessions-HC4W6FLI.mjs} +19 -49
  58. package/dist/.setup/{node-exec-server.runtime-BDwWXVpK.mjs → node-exec-server.runtime-BgBfWQqo.mjs} +3 -6
  59. package/dist/.setup/{plan-CN3VwfNU.mjs → plan-DPdMk1Oy.mjs} +49 -92
  60. package/dist/.setup/{plugin-activation-DT3MNtqj.mjs → plugin-activation-cNHRfaxU.mjs} +8 -36
  61. package/dist/.setup/{plugin-app-cache-key-B2CsSdnV.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +6 -23
  62. package/dist/.setup/{plugin-inventory-BoRei8Z4.mjs → plugin-inventory-Cky2XJUw.mjs} +21 -21
  63. package/dist/.setup/{plugin-marketplace-discovery-CDOi8IFs.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +18 -24
  64. package/dist/.setup/{plugin-metadata-cache-Ctmo83k_.mjs → plugin-metadata-cache-BRwtRct9.mjs} +116 -176
  65. package/dist/.setup/{provider-BOsxQHOM.mjs → provider-D6F_7p1I.mjs} +11 -14
  66. package/dist/.setup/{provider-capabilities-BfE88FZ5.mjs → provider-capabilities-DG5qbsUZ.mjs} +13 -18
  67. package/dist/.setup/{rate-limits-CMU3DUD0.mjs → rate-limits-B7-X2TgG.mjs} +9 -31
  68. package/dist/.setup/{request-D2L0zMrq.mjs → request-BZOfsSXW.mjs} +7 -6
  69. package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
  70. package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
  71. package/dist/.setup/{run-attempt-BHu11r7h.mjs → run-attempt-dYJhjZrp.mjs} +1035 -1023
  72. package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
  73. package/dist/.setup/{runtime-artifact-CLZ8udh-.mjs → runtime-artifact-DDQ-HGXf.mjs} +16 -4
  74. package/dist/.setup/runtime-artifact-connection-D68qQn1m.mjs +78 -0
  75. package/dist/.setup/sandbox-guard-DjCz2eOw.mjs +126 -0
  76. package/dist/.setup/scope-DOC1Xjc8.mjs +6 -0
  77. package/dist/.setup/session-binding-DGCYAfvD.mjs +443 -0
  78. package/dist/.setup/{session-binding-record-BGoz8wOK.mjs → session-binding-record-Oe9L-CNY.mjs} +52 -130
  79. package/dist/.setup/{session-binding-sidecars-BlB5EvIS.mjs → session-binding-sidecars-jo6H8dFr.mjs} +196 -17
  80. package/dist/.setup/{session-catalog-Pno1xGcl.mjs → session-catalog-BFafIiF6.mjs} +185 -350
  81. package/dist/.setup/{session-catalog-adoption-BI6UTDZT.mjs → session-catalog-adoption-BU_pHWG7.mjs} +7 -6
  82. package/dist/.setup/{session-catalog-archive-lHBqzhaO.mjs → session-catalog-archive-spHfihri.mjs} +6 -6
  83. package/dist/.setup/session-catalog-events-BMCFMZw-.mjs +139 -0
  84. package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
  85. package/dist/.setup/{session-catalog-index-B9_VQIUz.mjs → session-catalog-index-DwJjnF5k.mjs} +126 -122
  86. package/dist/.setup/{session-catalog-index-order-hcdz07yN.mjs → session-catalog-index-order-BcQpHks3.mjs} +1 -1
  87. package/dist/.setup/{session-catalog-index-state-Dgh8ORJm.mjs → session-catalog-index-state-TeO7EyO-.mjs} +3 -2
  88. package/dist/.setup/session-catalog-limits-DDxOsQeC.mjs +14 -0
  89. package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +170 -0
  90. package/dist/.setup/session-catalog-native-projection-CuaFZuQE.mjs +178 -0
  91. package/dist/.setup/{session-catalog-node-adoption-ITddWx_X.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +10 -27
  92. package/dist/.setup/{session-catalog-node-continue-6g6qi4A9.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +8 -10
  93. package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
  94. package/dist/.setup/{session-catalog-native-projection-DowriLid.mjs → session-catalog-parsing-CPGaPYr-.mjs} +11 -194
  95. package/dist/.setup/{session-catalog-projection-zK_PUsiE.mjs → session-catalog-projection-CGfzfP93.mjs} +6 -4
  96. package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
  97. package/dist/.setup/{session-cli-irrD-uo7.mjs → session-cli-DlmBHYIe.mjs} +9 -22
  98. package/dist/.setup/{session-history-BrqhSCf9.mjs → session-history-D83lJWHG.mjs} +4 -6
  99. package/dist/.setup/{session-history-import-D-3wAgOP.mjs → session-history-import-WhX-X33a.mjs} +7 -10
  100. package/dist/.setup/session-history-read-Ov3StuL4.mjs +133 -0
  101. package/dist/.setup/{session-history.worker-CaCh0xF_.mjs → session-history.worker-MnPKncqP.mjs} +9 -5
  102. package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
  103. package/dist/.setup/{session-permission-policy-BI1QK_98.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
  104. package/dist/.setup/{session-retirement-BH-S6qkJ.mjs → session-retirement-LlYWBKTJ.mjs} +17 -17
  105. package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
  106. package/dist/.setup/{settled-turn-finalizer-DiAi6Kx6.mjs → settled-turn-finalizer-DW9W3gza.mjs} +14 -10
  107. package/dist/.setup/{shared-client-DA4VR4Eb.mjs → shared-client-CJCTeFpQ.mjs} +783 -412
  108. package/dist/.setup/shared-client-lifecycle-7xgtlo15.mjs +153 -0
  109. package/dist/.setup/{side-question-BJ1wSDcB.mjs → side-question-BLeGj7TQ.mjs} +79 -143
  110. package/dist/.setup/{source-CUzJq5WN.mjs → source-CJis_1EF.mjs} +80 -137
  111. package/dist/.setup/{thread-lifecycle-B3mfz1TG.mjs → thread-lifecycle-_bAbjedG.mjs} +294 -737
  112. package/dist/.setup/{thread-ownership-DcTtAcXj.mjs → thread-ownership-B6pPt21M.mjs} +45 -10
  113. package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
  114. package/dist/.setup/{thread-policy-DGuQsuFC.mjs → thread-policy-gNPzzpVp.mjs} +46 -7
  115. package/dist/.setup/{thread-requests-BLvGkP2R.mjs → thread-requests-OWGOiDaV.mjs} +199 -302
  116. package/dist/.setup/{thread-resume-DIBXwOpE.mjs → thread-resume-GOry0AYh.mjs} +6 -6
  117. package/dist/.setup/{timeout-C910MdAB.mjs → timeout-CXOfNoaX.mjs} +1 -35
  118. package/dist/.setup/{transcript-history-projection-ZZpkFkJ_.mjs → transcript-history-projection-DRSifI-1.mjs} +17 -89
  119. package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
  120. package/dist/.setup/{transcript-mirror-BtHDBp1G.mjs → transcript-mirror-kxmCYsuF.mjs} +7 -9
  121. package/dist/.setup/{transport-stdio-h2VHOskC.mjs → transport-stdio-Bdegpn2V.mjs} +5 -22
  122. package/dist/.setup/transport-websocket-BTBE-LD9.mjs +211 -0
  123. package/dist/.setup/{upstream-prompt-provenance-LphB8slG.mjs → upstream-prompt-provenance-fXkKbPVC.mjs} +3 -9
  124. package/dist/.setup/{upstream-session-fork-BUr4OUbC.mjs → upstream-session-fork-gkdRj2yH.mjs} +23 -23
  125. package/dist/.setup/{usage-BML0r-ua.mjs → usage-CApUvLOV.mjs} +4 -4
  126. package/dist/.setup/{usage-limit-error-DUMbefVY.mjs → usage-limit-error-wSMQkbpV.mjs} +4 -19
  127. package/dist/.setup/{web-search-provider.runtime-CDKlN-Rv.mjs → web-search-provider.runtime-UKgeiBUG.mjs} +8 -19
  128. package/dist/api.js +9 -11
  129. package/dist/catalog-page.worker.js +1 -1
  130. package/dist/cli-metadata.js +1 -1
  131. package/dist/doctor-contract-api.js +50 -8
  132. package/dist/harness.js +344 -1
  133. package/dist/index.js +193 -245
  134. package/dist/media-understanding-provider.js +9 -22
  135. package/dist/migration-provider-api.js +1 -1
  136. package/dist/provider-discovery.js +1 -1
  137. package/dist/session-history-worker-runtime.js +3 -3
  138. package/dist/session-history.worker.js +1 -1
  139. package/openclaw.plugin.json +14 -2
  140. package/package.json +7 -6
  141. package/dist/.setup/attempt-workspace-context-DUVEn_CS.mjs +0 -331
  142. package/dist/.setup/compact-Du5UvtxA.mjs +0 -680
  143. package/dist/.setup/event-projector-assistant-message-BsruvNrH.mjs +0 -103
  144. package/dist/.setup/event-projector-items-C6L_5ZiT.mjs +0 -234
  145. package/dist/.setup/harness-a_MsE4-_.mjs +0 -355
  146. package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
  147. package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
  148. package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
  149. package/dist/.setup/native-subagent-history-0nYYgo0k.mjs +0 -148
  150. package/dist/.setup/native-subagent-task-ids-wb8CKZGN.mjs +0 -441
  151. package/dist/.setup/plugin-approval-roundtrip-C0MZzCuP.mjs +0 -122
  152. package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
  153. package/dist/.setup/sandbox-guard-C2sRMOEY.mjs +0 -166
  154. package/dist/.setup/session-binding-Cm0apEbd.mjs +0 -692
  155. package/dist/.setup/session-catalog-events-Bj6j94E_.mjs +0 -347
  156. package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
  157. package/dist/.setup/session-initialization-rcgbZiid.mjs +0 -75
  158. package/dist/.setup/thread-history-page-DoVpnHim.mjs +0 -83
@@ -1,347 +0,0 @@
1
- import { n as defineCodexBuildState } from "./build-state-C7EnDVgr.mjs";
2
- import { f as resolveCodexAppServerLocalHomeDir, r as inferCodexAppServerConnectionClass } from "./config-security-BEReZ6go.mjs";
3
- import { C as boundedCatalogString, b as MAX_CWD_LENGTH, r as projectCodexCatalogNativeThread, s as codexCatalogSourceForClient, u as observeCodexCatalogEphemeralThreads } from "./session-catalog-native-projection-DowriLid.mjs";
4
- import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
5
- import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-B2CsSdnV.mjs";
6
- import { createHash } from "node:crypto";
7
- import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-registration";
8
- import fs from "node:fs";
9
- import path from "node:path";
10
- import fs$1 from "node:fs/promises";
11
- import { root } from "openclaw/plugin-sdk/file-access-runtime";
12
- import { createZstdDecompress } from "node:zlib";
13
- //#region extensions/codex/src/app-server/shared-client-lifecycle.ts
14
- /** Client ownership and synchronous retirement, independent of startup/auth execution. */
15
- const createCodexAppServerStartupLifetime = () => ({
16
- controller: new AbortController(),
17
- pending: /* @__PURE__ */ new Set()
18
- });
19
- const getSharedCodexAppServerClientState = defineCodexBuildState("openclaw.codexAppServerClientState", () => ({
20
- clients: /* @__PURE__ */ new Map(),
21
- liveClients: /* @__PURE__ */ new Set(),
22
- isolatedClients: /* @__PURE__ */ new Set(),
23
- entriesByClient: /* @__PURE__ */ new WeakMap(),
24
- desktopGenerationDrainChecks: /* @__PURE__ */ new Set(),
25
- startup: createCodexAppServerStartupLifetime(),
26
- startMetadata: /* @__PURE__ */ new WeakMap()
27
- }));
28
- function hasActiveSharedCodexAppServerWork() {
29
- const state = getSharedCodexAppServerClientState();
30
- if (state.startup.pending.size > 0 || state.startup.controller.signal.aborted) return true;
31
- for (const entry of state.clients.values()) if (entry.activeLeases > 0 || entry.pendingAcquires > 0) return true;
32
- for (const client of state.liveClients) {
33
- const entry = state.entriesByClient.get(client);
34
- if (entry && (entry.activeLeases > 0 || entry.pendingAcquires > 0)) return true;
35
- }
36
- return false;
37
- }
38
- function getCurrentSharedClientEntry(client) {
39
- const state = getSharedCodexAppServerClientState();
40
- const entry = client ? state.entriesByClient.get(client) : void 0;
41
- return entry && entry.client === client && state.clients.get(entry.key) === entry ? entry : void 0;
42
- }
43
- /**
44
- * Retires a matching shared client. Default is graceful: detach from the map
45
- * (future acquisitions get a fresh client) and close once leases drain.
46
- * `failActiveLeases` is for suspect clients only (timed-out turns): it closes
47
- * the physical connection immediately so co-leased attempts hit the normal
48
- * client-closed retry path, and pending acquires reject instead of leasing
49
- * the poisoned process. Routine cleanup must NOT use it — it would abort
50
- * healthy sibling turns on a working client.
51
- */
52
- function retireSharedCodexAppServerClientIfCurrent(client, opts) {
53
- if (!client) return;
54
- const state = getSharedCodexAppServerClientState();
55
- const currentEntry = getCurrentSharedClientEntry(client);
56
- const entry = currentEntry ?? state.entriesByClient.get(client);
57
- if (!entry || entry.client !== client && !entry.closeError) return;
58
- if (currentEntry) {
59
- state.clients.delete(entry.key);
60
- entry.closeWhenIdle = true;
61
- }
62
- if (opts?.failActiveLeases && (currentEntry || !entry.closeError)) {
63
- entry.closeError = /* @__PURE__ */ new Error("codex app-server client is closed");
64
- return {
65
- activeLeases: entry.activeLeases,
66
- closed: closeRetiredSharedClientEntry(entry)
67
- };
68
- }
69
- return {
70
- activeLeases: entry.activeLeases,
71
- closed: currentEntry ? closeRetiredSharedClientEntryIfIdle(entry) : false
72
- };
73
- }
74
- /** Gracefully retires exact clients attached to an older desktop generation. */
75
- function retireSharedCodexAppServerClientsBeforeDesktopGeneration(generation) {
76
- const state = getSharedCodexAppServerClientState();
77
- for (const entry of state.clients.values()) {
78
- const client = entry.client;
79
- const attached = client ? state.startMetadata.get(client) : void 0;
80
- if (client && attached?.desktopGeneration && attached.desktopGeneration.epoch < generation.epoch) retireSharedCodexAppServerClientIfCurrent(client);
81
- }
82
- }
83
- function closeRetiredSharedClientEntryIfIdle(entry) {
84
- if (!entry.closeWhenIdle || entry.activeLeases > 0 || entry.pendingAcquires > 0 || !entry.client) return false;
85
- entry.closeWhenIdle = false;
86
- return closeRetiredSharedClientEntry(entry);
87
- }
88
- function closeRetiredSharedClientEntry(entry) {
89
- const client = entry.client;
90
- if (!client) return false;
91
- entry.client = void 0;
92
- client.close();
93
- return true;
94
- }
95
- //#endregion
96
- //#region extensions/codex/src/session-catalog-home-id.ts
97
- function canonicalCodexCatalogHome(value) {
98
- const resolved = path.resolve(value);
99
- try {
100
- return fs.realpathSync.native(resolved);
101
- } catch {
102
- return resolved;
103
- }
104
- }
105
- /** One canonical identity for catalog discovery and durable ownership rows. */
106
- function codexCatalogHomeId(codexHome) {
107
- return codexCatalogHomeIdFromCanonicalPath(canonicalCodexCatalogHome(codexHome));
108
- }
109
- /** Hashes lifecycle-prepared paths without repeating filesystem discovery. */
110
- function codexCatalogHomeIdFromCanonicalPath(codexHome) {
111
- return createHash("sha256").update("openclaw:codex-session-catalog-home:v1\0").update(codexHome).digest("hex");
112
- }
113
- //#endregion
114
- //#region extensions/codex/src/session-catalog-provenance.ts
115
- const MAX_SESSION_META_BYTES = 1048576;
116
- const SESSION_META_READ_CHUNK_BYTES = 65536;
117
- const MAX_PROVENANCE_CACHE_ENTRIES = 2e4;
118
- const provenanceByPath = /* @__PURE__ */ new Map();
119
- function cacheProvenance(key, value) {
120
- provenanceByPath.delete(key);
121
- provenanceByPath.set(key, value);
122
- while (provenanceByPath.size > MAX_PROVENANCE_CACHE_ENTRIES) {
123
- const oldest = provenanceByPath.keys().next().value;
124
- if (oldest === void 0) break;
125
- provenanceByPath.delete(oldest);
126
- }
127
- }
128
- /** Undefined means the metadata line is not durable enough to cache yet. */
129
- async function readCodexSessionMeta(sessionsRoot, rolloutPath, threadId) {
130
- let safeRoot;
131
- try {
132
- safeRoot = await root(sessionsRoot, {
133
- hardlinks: "reject",
134
- maxBytes: Number.MAX_SAFE_INTEGER,
135
- symlinks: "reject"
136
- });
137
- } catch {
138
- return;
139
- }
140
- const candidates = rolloutPath.endsWith(".zst") ? [rolloutPath, rolloutPath.slice(0, -4)] : [rolloutPath, `${rolloutPath}.zst`];
141
- for (const candidate of candidates) {
142
- let opened;
143
- try {
144
- opened = await safeRoot.open(path.relative(sessionsRoot, candidate));
145
- } catch {
146
- continue;
147
- }
148
- const input = opened.handle.createReadStream({
149
- autoClose: false,
150
- highWaterMark: SESSION_META_READ_CHUNK_BYTES
151
- });
152
- const reader = candidate.endsWith(".zst") ? input.pipe(createZstdDecompress()) : input;
153
- try {
154
- const chunks = [];
155
- let bytesReadTotal = 0;
156
- let line;
157
- for await (const value of reader) {
158
- const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
159
- const remaining = MAX_SESSION_META_BYTES - bytesReadTotal;
160
- if (remaining <= 0) break;
161
- const bounded = chunk.subarray(0, remaining);
162
- bytesReadTotal += bounded.length;
163
- const newline = bounded.indexOf(10);
164
- chunks.push(newline >= 0 ? bounded.subarray(0, newline) : bounded);
165
- if (newline >= 0) {
166
- line = Buffer.concat(chunks).toString("utf8");
167
- break;
168
- }
169
- }
170
- if (!line) continue;
171
- let parsed;
172
- try {
173
- parsed = JSON.parse(line);
174
- } catch {
175
- continue;
176
- }
177
- if (!isJsonObject(parsed) || parsed.type !== "session_meta" || !isJsonObject(parsed.payload)) return null;
178
- const payload = parsed.payload;
179
- return payload.id === threadId ? payload : null;
180
- } catch {
181
- continue;
182
- } finally {
183
- reader.destroy();
184
- input.destroy();
185
- await opened.handle.close().catch(() => void 0);
186
- }
187
- }
188
- }
189
- /** Passive local listing uses native creation provenance, with rollout fallback for older records. */
190
- async function isOpenClawManagedCodexThread(thread, localSessionsRoot, diagnostics) {
191
- const started = diagnostics ? performance.now() : 0;
192
- if (diagnostics) diagnostics.fields.provenanceChecks++;
193
- try {
194
- const rolloutPath = typeof thread.path === "string" ? thread.path.trim() : "";
195
- if (!localSessionsRoot || !rolloutPath) return false;
196
- if (typeof thread.originator === "string" && thread.originator.length > 0) return thread.originator === "openclaw";
197
- const cacheKey = `${localSessionsRoot}\0${rolloutPath}`;
198
- const cached = provenanceByPath.get(cacheKey);
199
- if (cached !== void 0) {
200
- if (diagnostics) diagnostics.fields.provenanceCacheHits++;
201
- return cached;
202
- }
203
- if (diagnostics) diagnostics.fields.provenanceReadCalls++;
204
- const metadata = await readCodexSessionMeta(localSessionsRoot, rolloutPath, thread.id);
205
- const managed = metadata === void 0 ? void 0 : metadata?.originator === "openclaw";
206
- if (managed !== void 0) cacheProvenance(cacheKey, managed);
207
- return managed ?? false;
208
- } finally {
209
- if (diagnostics) diagnostics.fields.provenanceMs = (diagnostics.fields.provenanceMs ?? 0) + performance.now() - started;
210
- }
211
- }
212
- //#endregion
213
- //#region extensions/codex/src/session-catalog-events.ts
214
- const getCatalogEvents = defineCodexBuildState("openclaw.codexCatalogEvents", () => ({
215
- listeners: /* @__PURE__ */ new Map(),
216
- clients: /* @__PURE__ */ new WeakMap()
217
- }));
218
- const CATALOG_NOTIFICATION_METHODS = /* @__PURE__ */ new Set([
219
- "thread/started",
220
- "turn/started",
221
- "turn/completed",
222
- "thread/archived",
223
- "thread/deleted",
224
- "thread/unarchived",
225
- "thread/reverted",
226
- "thread/name/updated",
227
- "thread/status/changed",
228
- "thread/settings/updated"
229
- ]);
230
- function notifyEphemeralThread(homeKey, rawId) {
231
- const id = boundedCatalogString(rawId, 256);
232
- if (!id) return;
233
- for (const listener of getCatalogEvents().listeners.get(homeKey) ?? []) try {
234
- listener.onEphemeralThread?.(id);
235
- } catch (error) {
236
- embeddedAgentLog.warn("Codex catalog ephemeral observer failed", { error });
237
- }
238
- }
239
- /** Uses prepared local identity or resolves it once during client/index startup. */
240
- async function codexCatalogResidentHomeKey(params) {
241
- if (inferCodexAppServerConnectionClass(params.startOptions) === "remote") {
242
- const fingerprint = buildCodexAppServerConnectionFingerprint({
243
- start: params.startOptions,
244
- connectionClass: "remote"
245
- }, params.agentDir);
246
- return `remote:${createHash("sha256").update(fingerprint).digest("hex")}`;
247
- }
248
- if (params.sourceHomeId) return params.sourceHomeId;
249
- const home = path.resolve(params.runtimeIdentity?.codexHome ?? resolveCodexAppServerLocalHomeDir(params.startOptions, params.agentDir));
250
- return codexCatalogHomeIdFromCanonicalPath(await fs$1.realpath(home).catch(() => home));
251
- }
252
- function subscribeCodexCatalogEvents(homeKey, listener, callbacks = {}) {
253
- const { listeners } = getCatalogEvents();
254
- let homeListeners = listeners.get(homeKey);
255
- if (!homeListeners) {
256
- homeListeners = /* @__PURE__ */ new Set();
257
- listeners.set(homeKey, homeListeners);
258
- }
259
- const subscription = {
260
- notify: listener,
261
- ...callbacks
262
- };
263
- homeListeners.add(subscription);
264
- return () => {
265
- homeListeners.delete(subscription);
266
- if (homeListeners.size === 0 && listeners.get(homeKey) === homeListeners) listeners.delete(homeKey);
267
- };
268
- }
269
- /** Observes physical clients without extending their lease or native thread lifetime. */
270
- function observeCodexCatalogClient(client, params) {
271
- const state = getCatalogEvents();
272
- const existing = state.clients.get(client);
273
- if (existing) return existing.then(() => void 0);
274
- const observing = (async () => {
275
- const homeKey = await codexCatalogResidentHomeKey({
276
- ...params,
277
- runtimeIdentity: client.getRuntimeIdentity()
278
- });
279
- if (client.getCloseError()) return;
280
- const source = codexCatalogSourceForClient(client);
281
- observeCodexCatalogEphemeralThreads(source, notifyEphemeralThread.bind(void 0, homeKey));
282
- const notifyLifecycle = (callback) => {
283
- for (const listener of state.listeners.get(homeKey) ?? []) try {
284
- listener[callback]?.(source);
285
- } catch (error) {
286
- embeddedAgentLog.warn("Codex catalog lifecycle observer failed", {
287
- callback,
288
- error
289
- });
290
- }
291
- };
292
- const readThread = async (threadId) => (await client.request("thread/read", {
293
- threadId,
294
- includeTurns: false
295
- }, {
296
- timeoutMs: 6e4,
297
- catalogPreview: true
298
- })).thread;
299
- const stopNotifications = client.addNotificationHandler((event) => {
300
- if (!CATALOG_NOTIFICATION_METHODS.has(event.method)) return;
301
- for (const listener of state.listeners.get(homeKey) ?? []) listener.notify(event, readThread, source);
302
- });
303
- const stopClose = client.addCloseHandler(() => {
304
- stopNotifications();
305
- stopClose();
306
- notifyLifecycle("onClose");
307
- });
308
- if (inferCodexAppServerConnectionClass(params.startOptions) === "remote") notifyLifecycle("onRemoteReady");
309
- return {
310
- homeKey,
311
- source
312
- };
313
- })();
314
- state.clients.set(client, observing);
315
- return observing.then(() => void 0);
316
- }
317
- /** Acknowledged resume settings may differ from the response thread's persisted metadata. */
318
- function publishCodexCatalogResume(client, response, sanitize) {
319
- try {
320
- return publishPreparedResume(client, {
321
- thread: projectCodexCatalogNativeThread(response.thread, sanitize),
322
- cwd: boundedCatalogString(response.cwd, MAX_CWD_LENGTH),
323
- modelProvider: boundedCatalogString(response.modelProvider, 500, "truncate")
324
- });
325
- } catch (error) {
326
- embeddedAgentLog.warn("Codex catalog resume publication failed", { error });
327
- return Promise.resolve();
328
- }
329
- }
330
- async function publishPreparedResume(client, response) {
331
- try {
332
- const state = getCatalogEvents();
333
- const binding = await state.clients.get(client);
334
- if (!binding || binding.source.closed) return;
335
- await Promise.all(Array.from(state.listeners.get(binding.homeKey) ?? [], async (listener) => {
336
- try {
337
- await listener.onResume?.(response, binding.source);
338
- } catch (error) {
339
- embeddedAgentLog.warn("Codex catalog resume observer failed", { error });
340
- }
341
- }));
342
- } catch (error) {
343
- embeddedAgentLog.warn("Codex catalog resume publication failed", { error });
344
- }
345
- }
346
- //#endregion
347
- export { isOpenClawManagedCodexThread as a, codexCatalogHomeIdFromCanonicalPath as c, createCodexAppServerStartupLifetime as d, getCurrentSharedClientEntry as f, retireSharedCodexAppServerClientsBeforeDesktopGeneration as g, retireSharedCodexAppServerClientIfCurrent as h, subscribeCodexCatalogEvents as i, closeRetiredSharedClientEntry as l, hasActiveSharedCodexAppServerWork as m, observeCodexCatalogClient as n, readCodexSessionMeta as o, getSharedCodexAppServerClientState as p, publishCodexCatalogResume as r, codexCatalogHomeId as s, codexCatalogResidentHomeKey as t, closeRetiredSharedClientEntryIfIdle as u };
@@ -1,50 +0,0 @@
1
- import { n as codexHistoryRejectionReason, t as CodexHistoryRejection } from "./history-rejection-B4nOXNXF.mjs";
2
- import { n as sanitizeCodexHistoryImagePayloads } from "./image-payload-sanitizer-tupAr-2o.mjs";
3
- import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
4
- import fs from "node:fs/promises";
5
- import { SessionTranscriptReadFenceError, readCodexSessionContext } from "openclaw/plugin-sdk/codex-session-transcript-runtime";
6
- //#region extensions/codex/src/app-server/session-history-read.ts
7
- function consumeCodexHistory(messages, header, sessionId, read, imageLabel = "codex mirrored history") {
8
- if (!isRecord(header) || header.type !== "session") return read([]);
9
- if (typeof header.id !== "string") throw new CodexHistoryRejection("malformed_header");
10
- if (header.id !== sessionId) return read([]);
11
- return read((function* () {
12
- for (const message of messages) yield sanitizeCodexHistoryImagePayloads(message, imageLabel);
13
- })());
14
- }
15
- /** Keeps native evidence and its synchronous consumer inside the same readonly snapshot. */
16
- async function readCodexNativeHistory(target, sessionId, read, admission, onSnapshot) {
17
- const consume = (messages, header, version) => {
18
- try {
19
- onSnapshot?.(version);
20
- return {
21
- status: "ok",
22
- value: consumeCodexHistory(messages, header, sessionId, read)
23
- };
24
- } catch (error) {
25
- return {
26
- status: "rejected",
27
- reason: codexHistoryRejectionReason(error)
28
- };
29
- }
30
- };
31
- try {
32
- if (target.kind === "empty") return consume([], void 0);
33
- if (target.kind === "sqlite") return readCodexSessionContext(target.target, consume, admission);
34
- const { buildSessionContext, migrateSessionEntries, parseSessionEntries } = await import("openclaw/plugin-sdk/agent-sessions");
35
- const entries = parseSessionEntries(await fs.readFile(target.sessionFile, "utf-8"));
36
- return consume((function* () {
37
- migrateSessionEntries(entries);
38
- const sessionEntries = entries.filter((entry) => isRecord(entry) && entry.type !== "session");
39
- yield* buildSessionContext(sessionEntries).messages;
40
- })(), entries[0]);
41
- } catch (error) {
42
- if (isRecord(error) && error.code === "ENOENT") return consume([], void 0);
43
- return {
44
- status: "rejected",
45
- reason: error instanceof SessionTranscriptReadFenceError || isRecord(error) && (error.code === "EACCES" || error.code === "EPERM") ? "access_rejected" : codexHistoryRejectionReason(error)
46
- };
47
- }
48
- }
49
- //#endregion
50
- export { readCodexNativeHistory as n, consumeCodexHistory as t };
@@ -1,75 +0,0 @@
1
- import { g as validateBindingForWrite } from "./session-binding-record-BGoz8wOK.mjs";
2
- import "./session-binding-Cm0apEbd.mjs";
3
- import { isDeepStrictEqual } from "node:util";
4
- import { deleteSessionUpstreamLink, upsertSessionUpstreamLink } from "openclaw/plugin-sdk/session-catalog";
5
- //#region extensions/codex/src/app-server/session-initialization.ts
6
- const initializations = /* @__PURE__ */ new WeakMap();
7
- /** Associate the host's exact handle before any potentially committing plugin write. */
8
- function prepareCodexSessionInitialization(params) {
9
- const { initialization, bindingStore, identity } = params;
10
- initialization.assertCurrent();
11
- let link;
12
- const ownership = {
13
- store: bindingStore,
14
- identity: structuredClone(identity),
15
- assertCleanupAllowed: params.assertCleanupAllowed,
16
- cleanup: async () => {
17
- initialization.assertRollbackCurrent();
18
- if (link && deleteSessionUpstreamLink(link.sessionKey, link.agentId, {
19
- expected: link,
20
- assertCommitAllowed: initialization.assertRollbackCurrent
21
- }) === "changed") throw new Error("Codex initialization link changed before cleanup");
22
- initialization.assertRollbackCurrent();
23
- await cleanup?.(initialization.assertRollbackCurrent);
24
- initialization.assertRollbackCurrent();
25
- }
26
- };
27
- initializations.set(initialization, ownership);
28
- const cleanup = params.prepareCleanup?.();
29
- return {
30
- assertCurrent: initialization.assertCurrent,
31
- async bind(binding) {
32
- initialization.assertCurrent();
33
- ownership.binding = validateBindingForWrite(binding);
34
- if (!await bindingStore.mutate(identity, {
35
- kind: "set",
36
- if: { kind: "absent" },
37
- binding: ownership.binding
38
- }, initialization.assertCurrent)) {
39
- ownership.binding = void 0;
40
- throw new Error("Codex session binding changed during initialization");
41
- }
42
- initialization.assertCurrent();
43
- },
44
- link(input) {
45
- initialization.assertCurrent();
46
- const now = Date.now();
47
- link = structuredClone({
48
- ...input,
49
- createdAt: now,
50
- updatedAt: now
51
- });
52
- if (!upsertSessionUpstreamLink(input, {
53
- now,
54
- ifAbsent: true,
55
- assertCommitAllowed: initialization.assertCurrent
56
- })) {
57
- link = void 0;
58
- throw new Error("Codex initialization link could not be persisted");
59
- }
60
- initialization.assertCurrent();
61
- }
62
- };
63
- }
64
- function getCodexSessionInitializationRollback(store, params, identity, binding) {
65
- const handle = params.initialization;
66
- if (!handle) return;
67
- handle.assertRollbackCurrent();
68
- const ownership = initializations.get(handle);
69
- if (!ownership && !binding) return;
70
- if (!ownership || ownership.store !== store || !isDeepStrictEqual(ownership.identity, identity) || binding && !isDeepStrictEqual(ownership.binding, binding)) throw new Error("Codex initialization binding owner changed before rollback");
71
- ownership.assertCleanupAllowed?.();
72
- return ownership.cleanup;
73
- }
74
- //#endregion
75
- export { prepareCodexSessionInitialization as n, getCodexSessionInitializationRollback as t };
@@ -1,83 +0,0 @@
1
- import { M as parseTranscriptPage, P as readControlCursor, v as CatalogParamsError } from "./session-catalog-native-projection-DowriLid.mjs";
2
- //#region extensions/codex/src/app-server/thread-history-page.ts
3
- const TURN_ITEM_CURSOR_PREFIX = "turn-item:";
4
- function encodeTurnItemCursor(turnCursor, itemId) {
5
- return TURN_ITEM_CURSOR_PREFIX + Buffer.from(JSON.stringify([turnCursor, itemId])).toString("base64url");
6
- }
7
- function decodeTurnItemCursor(cursor) {
8
- if (!cursor?.startsWith(TURN_ITEM_CURSOR_PREFIX)) return { turnCursor: cursor };
9
- let value;
10
- try {
11
- value = JSON.parse(Buffer.from(cursor.slice(10), "base64url").toString());
12
- } catch {
13
- throw new CatalogParamsError("invalid Codex transcript item cursor");
14
- }
15
- if (!Array.isArray(value) || value.length !== 2 || typeof value[0] !== "string" || !value[0] || typeof value[1] !== "string" || !value[1]) throw new CatalogParamsError("invalid Codex transcript item cursor");
16
- return {
17
- turnCursor: value[0],
18
- itemId: value[1]
19
- };
20
- }
21
- /** Legacy stores expose only turn cursors; an item identity preserves paging across appends. */
22
- async function readLegacyCodexHistoryPage(readTurns, request, projection) {
23
- const { turnCursor, itemId } = decodeTurnItemCursor(request.cursor);
24
- const page = parseTranscriptPage(await readTurns({
25
- threadId: request.threadId,
26
- limit: 1,
27
- sortDirection: "desc",
28
- itemsView: "full",
29
- ...turnCursor ? { cursor: turnCursor } : {}
30
- }));
31
- const source = page.data.flatMap(({ items, ...turn }) => items.toReversed().map((item) => ({
32
- turnId: turn.id,
33
- item,
34
- turn
35
- })));
36
- const anchorIndex = itemId ? source.findIndex(({ item }) => item.id === itemId) : -1;
37
- if (itemId && anchorIndex < 0) throw new CatalogParamsError("Codex transcript changed; refresh the session before loading older items");
38
- const remaining = source.slice(anchorIndex + 1);
39
- const items = projection.project(remaining.slice(0, request.limit), request.limit);
40
- const result = () => {
41
- const lastSource = remaining[items.length - 1];
42
- const partial = lastSource !== void 0 && items.length < remaining.length;
43
- const nativeCursor = partial ? page.backwardsCursor : page.nextCursor;
44
- const cursor = nativeCursor ? partial ? encodeTurnItemCursor(nativeCursor, lastSource.item.id) : nativeCursor : void 0;
45
- if (partial && !cursor) throw new Error("Codex app-server did not provide a transcript continuation anchor");
46
- return {
47
- items,
48
- ...cursor ? { nextCursor: cursor } : {}
49
- };
50
- };
51
- let bounded = result();
52
- while (!projection.fits(bounded)) {
53
- if (items.length <= 1) throw new Error("Codex transcript item exceeds the safe response size");
54
- items.pop();
55
- bounded = result();
56
- }
57
- return bounded;
58
- }
59
- /** Callers authorize the thread; this reader owns native cursor and response-size semantics. */
60
- async function readCodexThreadHistoryPage(control, thread, request, projection) {
61
- if (thread.historyMode !== "paginated") return readLegacyCodexHistoryPage((params) => control.listTurnPage(params), request, projection);
62
- let limit = request.limit;
63
- for (;;) {
64
- const page = await control.listItemPage({
65
- threadId: request.threadId,
66
- limit,
67
- sortDirection: "desc",
68
- ...request.cursor ? { cursor: request.cursor } : {}
69
- });
70
- const nextCursor = readControlCursor(page.nextCursor, "transcript next response");
71
- const items = projection.project(page.data, limit);
72
- const result = {
73
- items,
74
- ...nextCursor ? { nextCursor } : {}
75
- };
76
- const fittingCount = items.length - (projection.fits(result) ? 0 : 1);
77
- if (fittingCount === page.data.length) return result;
78
- if (fittingCount < 1) throw new Error("Codex transcript item exceeds the safe response size");
79
- limit = fittingCount;
80
- }
81
- }
82
- //#endregion
83
- export { readLegacyCodexHistoryPage as n, readCodexThreadHistoryPage as t };