@openclaw/codex 2026.9.5 → 2026.9.7

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 (174) hide show
  1. package/README.md +2 -0
  2. package/assets/icon.png +0 -0
  3. package/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-DFhbh1zz.mjs} +6 -6
  4. package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-D3GcSoSa.mjs} +35 -55
  5. package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-DOP-cW5j.mjs} +179 -73
  6. package/dist/.setup/attempt-workspace-context-C5HigshI.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-QirmgiCo.mjs → auth-cache-key-Dbvq-QgB.mjs} +41 -111
  9. package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
  10. package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
  11. package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
  12. package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
  13. package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
  14. package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-6TpgD1M6.mjs} +5 -5
  15. package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-CbjoN2OW.mjs} +140 -37
  16. package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
  17. package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-Da1_z0kd.mjs} +1 -1
  18. package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-B3WEZl4e.mjs} +2 -10
  19. package/dist/.setup/{client-vXs2929Q.mjs → client-N0JpgSzF.mjs} +635 -872
  20. package/dist/.setup/client-catalog-response-5HHLdcde.mjs +285 -0
  21. package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-BeAoaovI.mjs} +9 -8
  22. package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-R3ckE3Co.mjs} +36 -64
  23. package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-ylTMS00z.mjs} +301 -488
  24. package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-CGJGUQ6Y.mjs} +40 -28
  25. package/dist/.setup/compact-C2WamavS.mjs +776 -0
  26. package/dist/.setup/{config-CedDWjM-.mjs → config-DKhXquav.mjs} +26 -28
  27. package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-CzyWLTJt.mjs} +68 -65
  28. package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
  29. package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C0NbLms1.mjs} +2 -2
  30. package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-CE-FcGw9.mjs} +51 -215
  31. package/dist/.setup/{config-utils-DujwEnhg.mjs → config-utils-D0CXecki.mjs} +3 -13
  32. package/dist/.setup/context-engine-projection-PezSESth.mjs +387 -0
  33. package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-3Min8qvP.mjs} +71 -105
  34. package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
  35. package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-CEP8X5JC.mjs} +30 -69
  36. package/dist/.setup/{cyber-failover-DYwbmf1o.mjs → cyber-failover-XV0nNRZu.mjs} +1 -1
  37. package/dist/.setup/{cyber-failover-notice-e9G3J9-e.mjs → cyber-failover-notice-RNpGpTyP.mjs} +1 -1
  38. package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-DzlsLUuS.mjs} +3136 -3167
  39. package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CxUtC-xG.mjs} +8 -17
  40. package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-CDsPJOa2.mjs} +9 -6
  41. package/dist/.setup/event-projector-assistant-message-CigreO4K.mjs +69 -0
  42. package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-03R0I2dM.mjs} +4 -26
  43. package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
  44. package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
  45. package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D-9gWlTR.mjs} +16 -18
  46. package/dist/.setup/inference-dispatch-CMZtjQyz.mjs +359 -0
  47. package/dist/.setup/inference-metadata-CgIf7sOx.mjs +81 -0
  48. package/dist/.setup/inference-proxy-DhcXOgUE.mjs +561 -0
  49. package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-Dm3PzxJk.mjs} +15 -11
  50. package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
  51. package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-kiWRhNRE.mjs} +16 -9
  52. package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-PAuZgJC6.mjs} +14 -14
  53. package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
  54. package/dist/.setup/{models-BDFgm_G-.mjs → models-DHXZtVVk.mjs} +9 -18
  55. package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-CuG53tu4.mjs} +5 -5
  56. package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-BxZJy5mP.mjs} +6 -31
  57. package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-Dpsmf2wz.mjs} +4422 -3808
  58. package/dist/.setup/native-subagent-pending-assignments-DwkCzLvD.mjs +203 -0
  59. package/dist/.setup/native-task-assignments-DMQ0g3hu.mjs +194 -0
  60. package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-HC4W6FLI.mjs} +99 -111
  61. package/dist/.setup/node-exec-server.runtime-BgBfWQqo.mjs +244 -0
  62. package/dist/.setup/{plan-xD7WKYTM.mjs → plan-Y-QIvrKB.mjs} +118 -163
  63. package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-cNHRfaxU.mjs} +10 -47
  64. package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +9 -42
  65. package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-Cky2XJUw.mjs} +32 -23
  66. package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +22 -25
  67. package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-DsjsL1dr.mjs} +328 -318
  68. package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
  69. package/dist/.setup/provider-DH8NSzGt.mjs +51 -0
  70. package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-CAxoF-X1.mjs} +35 -12
  71. package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-B7-X2TgG.mjs} +123 -166
  72. package/dist/.setup/{request-BioXJLYa.mjs → request-BHZ1nz8d.mjs} +25 -16
  73. package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
  74. package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
  75. package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-D8RZUOzY.mjs} +2046 -1454
  76. package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
  77. package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-DDQ-HGXf.mjs} +43 -47
  78. package/dist/.setup/runtime-artifact-connection-D68qQn1m.mjs +78 -0
  79. package/dist/.setup/sandbox-guard-DjCz2eOw.mjs +126 -0
  80. package/dist/.setup/scope-DOC1Xjc8.mjs +6 -0
  81. package/dist/.setup/session-binding-DGCYAfvD.mjs +443 -0
  82. package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-Oe9L-CNY.mjs} +73 -132
  83. package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-jo6H8dFr.mjs} +242 -60
  84. package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-4sCdv5qx.mjs} +598 -452
  85. package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BU_pHWG7.mjs} +59 -26
  86. package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-spHfihri.mjs} +7 -7
  87. package/dist/.setup/session-catalog-events-DePDzzjc.mjs +139 -0
  88. package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
  89. package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-CZvDzC6z.mjs} +286 -182
  90. package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-BcQpHks3.mjs} +2 -2
  91. package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-TeO7EyO-.mjs} +6 -2
  92. package/dist/.setup/session-catalog-limits-DDxOsQeC.mjs +14 -0
  93. package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +170 -0
  94. package/dist/.setup/session-catalog-native-projection-DjhwGL6x.mjs +178 -0
  95. package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +30 -35
  96. package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +25 -18
  97. package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
  98. package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-parsing-CPGaPYr-.mjs} +14 -180
  99. package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-Cr5qP5Dj.mjs} +15 -5
  100. package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
  101. package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-Cn_nCqfq.mjs} +11 -24
  102. package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-D83lJWHG.mjs} +16 -23
  103. package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-WhX-X33a.mjs} +7 -10
  104. package/dist/.setup/session-history-read-Ov3StuL4.mjs +133 -0
  105. package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-MnPKncqP.mjs} +14 -23
  106. package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
  107. package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
  108. package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-qMTxkNx2.mjs} +31 -12
  109. package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
  110. package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-BsvEabkw.mjs} +17 -13
  111. package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DqyTMYug.mjs} +826 -485
  112. package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +153 -0
  113. package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-C4kCmQy1.mjs} +206 -334
  114. package/dist/.setup/{source-Bjp4UQij.mjs → source-CS_7GFJZ.mjs} +82 -139
  115. package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
  116. package/dist/.setup/{thread-archive-guard-jmecf6OJ.mjs → thread-archive-guard-C9frICzX.mjs} +10 -3
  117. package/dist/.setup/thread-lifecycle-DPflntEJ.mjs +2362 -0
  118. package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
  119. package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-roNP0l1c.mjs} +47 -10
  120. package/dist/.setup/thread-policy-DTd-DtkX.mjs +109 -0
  121. package/dist/.setup/thread-requests-B_bRnMGN.mjs +2102 -0
  122. package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-CdDaoc7T.mjs} +6 -6
  123. package/dist/.setup/timeout-CXOfNoaX.mjs +46 -0
  124. package/dist/.setup/transcript-history-projection-DRSifI-1.mjs +201 -0
  125. package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
  126. package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-kxmCYsuF.mjs} +224 -206
  127. package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-Bdegpn2V.mjs} +138 -75
  128. package/dist/.setup/transport-websocket-BTBE-LD9.mjs +211 -0
  129. package/dist/.setup/{upstream-prompt-provenance-LphB8slG.mjs → upstream-prompt-provenance-fXkKbPVC.mjs} +3 -9
  130. package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-CBeVjBpT.mjs} +48 -40
  131. package/dist/.setup/{usage-BOgBEKso.mjs → usage-BMzNxeR_.mjs} +5 -4
  132. package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-QXerDo3i.mjs} +5 -20
  133. package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-P77OUeoo.mjs} +10 -20
  134. package/dist/api.js +25 -16
  135. package/dist/catalog-page-worker-entrypoint.js +12 -0
  136. package/dist/catalog-page.worker.js +9 -0
  137. package/dist/cli-metadata.js +1 -1
  138. package/dist/doctor-contract-api.js +50 -8
  139. package/dist/harness.js +344 -1
  140. package/dist/index.js +345 -346
  141. package/dist/media-understanding-provider.js +9 -22
  142. package/dist/migration-provider-api.js +1 -1
  143. package/dist/provider-discovery.js +1 -1
  144. package/dist/session-history-worker-runtime.js +16 -33
  145. package/dist/session-history.worker.js +1 -1
  146. package/openclaw.plugin.json +14 -2
  147. package/package.json +11 -7
  148. package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
  149. package/dist/.setup/compact-C3i3qlzj.mjs +0 -687
  150. package/dist/.setup/event-projector-assistant-message-DNUR1s0A.mjs +0 -105
  151. package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +0 -200
  152. package/dist/.setup/harness-rxaaoN-o.mjs +0 -349
  153. package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
  154. package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
  155. package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
  156. package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
  157. package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
  158. package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +0 -135
  159. package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +0 -411
  160. package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
  161. package/dist/.setup/plugin-approval-roundtrip-CjfzafAZ.mjs +0 -122
  162. package/dist/.setup/provider-fFh_-VR3.mjs +0 -50
  163. package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
  164. package/dist/.setup/sandbox-guard-BBP-RbTf.mjs +0 -166
  165. package/dist/.setup/session-binding-_0W_fHRr.mjs +0 -721
  166. package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +0 -250
  167. package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
  168. package/dist/.setup/session-initialization-DH1z6fXn.mjs +0 -75
  169. package/dist/.setup/thread-history-page-BTx-4xsg.mjs +0 -83
  170. package/dist/.setup/thread-lifecycle-Cik28qWn.mjs +0 -4904
  171. package/dist/.setup/thread-policy-Cjs4B8xf.mjs +0 -54
  172. package/dist/.setup/timeout-DZF05XrR.mjs +0 -63
  173. package/dist/.setup/transcript-history-projection-DHNBDhCU.mjs +0 -243
  174. package/dist/.setup/version-CoqzXPgK.mjs +0 -12
@@ -1,250 +0,0 @@
1
- import { n as defineCodexBuildState } from "./build-state-Xx9ybZqa.mjs";
2
- import { g as resolveCodexAppServerLocalHomeDir, m as isJsonObject, r as inferCodexAppServerConnectionClass } from "./config-security-BRQ2mgW9.mjs";
3
- import { o as codexCatalogSourceForClient, r as projectCodexCatalogNativeThread, v as MAX_CWD_LENGTH, x as boundedCatalogString } from "./session-catalog-native-projection-ChV3cCtm.mjs";
4
- import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-BOxKP7db.mjs";
5
- import { createHash } from "node:crypto";
6
- import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-registration";
7
- import fs from "node:fs";
8
- import path from "node:path";
9
- import fs$1 from "node:fs/promises";
10
- import { createZstdDecompress } from "node:zlib";
11
- import { root } from "openclaw/plugin-sdk/file-access-runtime";
12
- //#region extensions/codex/src/session-catalog-provenance.ts
13
- const MAX_SESSION_META_BYTES = 1048576;
14
- const SESSION_META_READ_CHUNK_BYTES = 65536;
15
- const MAX_PROVENANCE_CACHE_ENTRIES = 2e4;
16
- const provenanceByPath = /* @__PURE__ */ new Map();
17
- function cacheProvenance(key, value) {
18
- provenanceByPath.delete(key);
19
- provenanceByPath.set(key, value);
20
- while (provenanceByPath.size > MAX_PROVENANCE_CACHE_ENTRIES) {
21
- const oldest = provenanceByPath.keys().next().value;
22
- if (oldest === void 0) break;
23
- provenanceByPath.delete(oldest);
24
- }
25
- }
26
- /** Undefined means the metadata line is not durable enough to cache yet. */
27
- async function readCodexSessionMeta(sessionsRoot, rolloutPath, threadId) {
28
- let safeRoot;
29
- try {
30
- safeRoot = await root(sessionsRoot, {
31
- hardlinks: "reject",
32
- maxBytes: Number.MAX_SAFE_INTEGER,
33
- symlinks: "reject"
34
- });
35
- } catch {
36
- return;
37
- }
38
- const candidates = rolloutPath.endsWith(".zst") ? [rolloutPath, rolloutPath.slice(0, -4)] : [rolloutPath, `${rolloutPath}.zst`];
39
- for (const candidate of candidates) {
40
- let opened;
41
- try {
42
- opened = await safeRoot.open(path.relative(sessionsRoot, candidate));
43
- } catch {
44
- continue;
45
- }
46
- const input = opened.handle.createReadStream({
47
- autoClose: false,
48
- highWaterMark: SESSION_META_READ_CHUNK_BYTES
49
- });
50
- const reader = candidate.endsWith(".zst") ? input.pipe(createZstdDecompress()) : input;
51
- try {
52
- const chunks = [];
53
- let bytesReadTotal = 0;
54
- let line;
55
- for await (const value of reader) {
56
- const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value);
57
- const remaining = MAX_SESSION_META_BYTES - bytesReadTotal;
58
- if (remaining <= 0) break;
59
- const bounded = chunk.subarray(0, remaining);
60
- bytesReadTotal += bounded.length;
61
- const newline = bounded.indexOf(10);
62
- chunks.push(newline >= 0 ? bounded.subarray(0, newline) : bounded);
63
- if (newline >= 0) {
64
- line = Buffer.concat(chunks).toString("utf8");
65
- break;
66
- }
67
- }
68
- if (!line) continue;
69
- let parsed;
70
- try {
71
- parsed = JSON.parse(line);
72
- } catch {
73
- continue;
74
- }
75
- if (!isJsonObject(parsed) || parsed.type !== "session_meta" || !isJsonObject(parsed.payload)) return null;
76
- const payload = parsed.payload;
77
- return payload.id === threadId ? payload : null;
78
- } catch {
79
- continue;
80
- } finally {
81
- reader.destroy();
82
- input.destroy();
83
- await opened.handle.close().catch(() => void 0);
84
- }
85
- }
86
- }
87
- /** Passive local listing uses native creation provenance, with rollout fallback for older records. */
88
- async function isOpenClawManagedCodexThread(thread, localSessionsRoot, diagnostics) {
89
- const started = diagnostics ? performance.now() : 0;
90
- if (diagnostics) diagnostics.fields.provenanceChecks++;
91
- try {
92
- const rolloutPath = typeof thread.path === "string" ? thread.path.trim() : "";
93
- if (!localSessionsRoot || !rolloutPath) return false;
94
- if (typeof thread.originator === "string" && thread.originator.length > 0) return thread.originator === "openclaw";
95
- const cacheKey = `${localSessionsRoot}\0${rolloutPath}`;
96
- const cached = provenanceByPath.get(cacheKey);
97
- if (cached !== void 0) {
98
- if (diagnostics) diagnostics.fields.provenanceCacheHits++;
99
- return cached;
100
- }
101
- if (diagnostics) diagnostics.fields.provenanceReadCalls++;
102
- const metadata = await readCodexSessionMeta(localSessionsRoot, rolloutPath, thread.id);
103
- const managed = metadata === void 0 ? void 0 : metadata?.originator === "openclaw";
104
- if (managed !== void 0) cacheProvenance(cacheKey, managed);
105
- return managed ?? false;
106
- } finally {
107
- if (diagnostics) diagnostics.fields.provenanceMs = (diagnostics.fields.provenanceMs ?? 0) + performance.now() - started;
108
- }
109
- }
110
- //#endregion
111
- //#region extensions/codex/src/session-catalog-home-id.ts
112
- function canonicalCodexCatalogHome(value) {
113
- const resolved = path.resolve(value);
114
- try {
115
- return fs.realpathSync.native(resolved);
116
- } catch {
117
- return resolved;
118
- }
119
- }
120
- /** One canonical identity for catalog discovery and durable ownership rows. */
121
- function codexCatalogHomeId(codexHome) {
122
- return codexCatalogHomeIdFromCanonicalPath(canonicalCodexCatalogHome(codexHome));
123
- }
124
- /** Hashes lifecycle-prepared paths without repeating filesystem discovery. */
125
- function codexCatalogHomeIdFromCanonicalPath(codexHome) {
126
- return createHash("sha256").update("openclaw:codex-session-catalog-home:v1\0").update(codexHome).digest("hex");
127
- }
128
- //#endregion
129
- //#region extensions/codex/src/session-catalog-events.ts
130
- const getCatalogEvents = defineCodexBuildState("openclaw.codexCatalogEvents", () => ({
131
- listeners: /* @__PURE__ */ new Map(),
132
- clients: /* @__PURE__ */ new WeakMap()
133
- }));
134
- const CATALOG_NOTIFICATION_METHODS = /* @__PURE__ */ new Set([
135
- "thread/started",
136
- "turn/started",
137
- "turn/completed",
138
- "thread/archived",
139
- "thread/deleted",
140
- "thread/unarchived",
141
- "thread/reverted",
142
- "thread/name/updated",
143
- "thread/status/changed",
144
- "thread/settings/updated"
145
- ]);
146
- /** Uses prepared local identity or resolves it once during client/index startup. */
147
- async function codexCatalogResidentHomeKey(params) {
148
- if (inferCodexAppServerConnectionClass(params.startOptions) === "remote") {
149
- const fingerprint = buildCodexAppServerConnectionFingerprint({
150
- start: params.startOptions,
151
- connectionClass: "remote"
152
- }, params.agentDir);
153
- return `remote:${createHash("sha256").update(fingerprint).digest("hex")}`;
154
- }
155
- if (params.sourceHomeId) return params.sourceHomeId;
156
- const home = path.resolve(params.runtimeIdentity?.codexHome ?? resolveCodexAppServerLocalHomeDir(params.startOptions, params.agentDir));
157
- return codexCatalogHomeIdFromCanonicalPath(await fs$1.realpath(home).catch(() => home));
158
- }
159
- function subscribeCodexCatalogEvents(homeKey, listener, callbacks = {}) {
160
- const { listeners } = getCatalogEvents();
161
- let homeListeners = listeners.get(homeKey);
162
- if (!homeListeners) {
163
- homeListeners = /* @__PURE__ */ new Set();
164
- listeners.set(homeKey, homeListeners);
165
- }
166
- const subscription = {
167
- notify: listener,
168
- ...callbacks
169
- };
170
- homeListeners.add(subscription);
171
- return () => {
172
- homeListeners.delete(subscription);
173
- if (homeListeners.size === 0 && listeners.get(homeKey) === homeListeners) listeners.delete(homeKey);
174
- };
175
- }
176
- /** Observes physical clients without extending their lease or native thread lifetime. */
177
- function observeCodexCatalogClient(client, params) {
178
- const state = getCatalogEvents();
179
- const existing = state.clients.get(client);
180
- if (existing) return existing.then(() => void 0);
181
- const observing = (async () => {
182
- const homeKey = await codexCatalogResidentHomeKey({
183
- ...params,
184
- runtimeIdentity: client.getRuntimeIdentity()
185
- });
186
- if (client.getCloseError()) return;
187
- const source = codexCatalogSourceForClient(client);
188
- const notifyLifecycle = (callback) => {
189
- for (const listener of state.listeners.get(homeKey) ?? []) try {
190
- listener[callback]?.(source);
191
- } catch (error) {
192
- embeddedAgentLog.warn("Codex catalog lifecycle observer failed", {
193
- callback,
194
- error
195
- });
196
- }
197
- };
198
- const readThread = async (threadId) => (await client.request("thread/read", {
199
- threadId,
200
- includeTurns: false
201
- }, { timeoutMs: 6e4 })).thread;
202
- const stopNotifications = client.addNotificationHandler((event) => {
203
- if (!CATALOG_NOTIFICATION_METHODS.has(event.method)) return;
204
- for (const listener of state.listeners.get(homeKey) ?? []) listener.notify(event, readThread, source);
205
- });
206
- const stopClose = client.addCloseHandler(() => {
207
- stopNotifications();
208
- stopClose();
209
- notifyLifecycle("onClose");
210
- });
211
- if (inferCodexAppServerConnectionClass(params.startOptions) === "remote") notifyLifecycle("onRemoteReady");
212
- return {
213
- homeKey,
214
- source
215
- };
216
- })();
217
- state.clients.set(client, observing);
218
- return observing.then(() => void 0);
219
- }
220
- /** Acknowledged resume settings may differ from the response thread's persisted metadata. */
221
- function publishCodexCatalogResume(client, response, sanitize) {
222
- try {
223
- return publishPreparedResume(client, {
224
- thread: projectCodexCatalogNativeThread(response.thread, sanitize),
225
- cwd: boundedCatalogString(response.cwd, MAX_CWD_LENGTH),
226
- modelProvider: boundedCatalogString(response.modelProvider, 500, "truncate")
227
- });
228
- } catch (error) {
229
- embeddedAgentLog.warn("Codex catalog resume publication failed", { error });
230
- return Promise.resolve();
231
- }
232
- }
233
- async function publishPreparedResume(client, response) {
234
- try {
235
- const state = getCatalogEvents();
236
- const binding = await state.clients.get(client);
237
- if (!binding || binding.source.closed) return;
238
- await Promise.all(Array.from(state.listeners.get(binding.homeKey) ?? [], async (listener) => {
239
- try {
240
- await listener.onResume?.(response, binding.source);
241
- } catch (error) {
242
- embeddedAgentLog.warn("Codex catalog resume observer failed", { error });
243
- }
244
- }));
245
- } catch (error) {
246
- embeddedAgentLog.warn("Codex catalog resume publication failed", { error });
247
- }
248
- }
249
- //#endregion
250
- export { codexCatalogHomeId as a, readCodexSessionMeta as c, subscribeCodexCatalogEvents as i, observeCodexCatalogClient as n, codexCatalogHomeIdFromCanonicalPath as o, publishCodexCatalogResume as r, isOpenClawManagedCodexThread as s, codexCatalogResidentHomeKey as t };
@@ -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 { h as validateBindingForWrite } from "./session-binding-record-TH3xA0zj.mjs";
2
- import "./session-binding-_0W_fHRr.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 { A as parseTranscriptPage, M as readControlCursor, g as CatalogParamsError } from "./session-catalog-native-projection-ChV3cCtm.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 };