@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,8 +1,8 @@
1
- import { l as sessionBindingIdentity } from "./session-binding-record-Bcvslnhf.js";
2
- import { c as CatalogParamsError, f as boundedCatalogString, w as requireBoundThread } from "./thread-history-page-D0JIp48V.js";
3
- import { n as codexUpstreamBaseline, t as codexLastTerminalTurnId } from "./session-upstream-marker-D15C9NHp.js";
4
- import { i as reclaimCurrentCodexSessionGeneration } from "./session-binding-CI8UuilT.js";
5
- import { adoptionSessionKeyRest, continueOperations, runSessionActionExclusive } from "./session-catalog-node-adoption-B1tgDW-m.js";
1
+ import { m as sessionBindingIdentity } from "./session-binding-record-BGoz8wOK.mjs";
2
+ import { C as boundedCatalogString, L as requireBoundThread, v as CatalogParamsError } from "./session-catalog-native-projection-DowriLid.mjs";
3
+ import { n as codexUpstreamBaseline, t as codexLastTerminalTurnId } from "./session-upstream-marker-D15C9NHp.mjs";
4
+ import { i as reclaimCurrentCodexSessionGeneration } from "./session-binding-Cm0apEbd.mjs";
5
+ import { adoptionSessionKeyRest, continueOperations, runSessionActionExclusive } from "./session-catalog-node-adoption-ITddWx_X.mjs";
6
6
  import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
7
7
  import { listSessionCatalogEntries, sessionCatalogAdoptedSessionKey, sessionCatalogAdoptedSourceKey } from "openclaw/plugin-sdk/session-catalog";
8
8
  //#region extensions/codex/src/session-catalog-adoption.ts
@@ -32,36 +32,68 @@ function readCodexSupervisionMarker(entry) {
32
32
  };
33
33
  }
34
34
  async function listAdoptedSessionEntries(params) {
35
- const adopted = /* @__PURE__ */ new Map();
36
- for (const { agentId, entry, sessionKey } of listSessionCatalogEntries({
35
+ const entries = listSessionCatalogEntries({
37
36
  ...params.agentId ? { agentId: params.agentId } : {},
38
37
  config: params.config ?? {},
39
38
  runtime: params.runtime,
40
39
  sessionEntries: params.sessionEntries
41
- })) {
40
+ });
41
+ const candidateForEntry = ({ agentId, entry, sessionKey }) => {
42
42
  const sessionKeyRest = adoptionSessionKeyRest(sessionKey);
43
43
  const marker = readCodexSupervisionMarker(entry);
44
- if (!sessionKeyRest.startsWith(CODEX_SUPERVISION_SESSION_KEY_PREFIX) || !marker || entry.initializationPending === true || entry.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true) continue;
44
+ if (!sessionKeyRest.startsWith(CODEX_SUPERVISION_SESSION_KEY_PREFIX) || !marker || entry.initializationPending === true || entry.agentHarnessId !== "codex" || entry.modelSelectionLocked !== true) return;
45
45
  const sessionId = entry.sessionId?.trim();
46
- if (!sessionId) continue;
47
- const binding = params.bindingStore.read(sessionBindingIdentity({
48
- sessionId,
46
+ if (!sessionId) return;
47
+ return {
48
+ agentId,
49
49
  sessionKey,
50
- config: params.config
51
- }));
52
- const sourceThreadId = binding?.supervisionSourceThreadId?.trim();
53
- const boundThreadId = binding?.threadId.trim();
54
- if (binding?.connectionScope !== "supervision" || !sourceThreadId || !boundThreadId || sessionKeyRest !== adoptionSessionKey(sourceThreadId, marker.sourceHomeId)) continue;
55
- const sourceKey = sessionCatalogAdoptedSourceKey(marker.sourceHomeId ?? "gateway:local", sourceThreadId);
56
- if (adopted.has(sourceKey)) throw new Error(`multiple OpenClaw sessions adopt Codex thread ${sourceThreadId} from the same home`);
57
- adopted.set(sourceKey, {
58
- key: sessionKey,
50
+ sessionKeyRest,
59
51
  sessionId,
60
- agentId,
61
- boundThreadId
62
- });
52
+ marker,
53
+ identity: sessionBindingIdentity({
54
+ sessionId,
55
+ sessionKey,
56
+ config: params.config
57
+ })
58
+ };
59
+ };
60
+ function* candidates() {
61
+ for (const entry of entries) {
62
+ const candidate = candidateForEntry(entry);
63
+ if (candidate) yield candidate;
64
+ }
65
+ }
66
+ const collect = (selected, readBinding = (identity) => params.bindingStore.read(identity)) => {
67
+ const adopted = /* @__PURE__ */ new Map();
68
+ for (const { agentId, sessionKey, sessionKeyRest, sessionId, marker, identity } of selected) {
69
+ const binding = readBinding(identity);
70
+ const sourceThreadId = binding?.supervisionSourceThreadId?.trim();
71
+ const boundThreadId = binding?.threadId.trim();
72
+ if (binding?.connectionScope !== "supervision" || !sourceThreadId || !boundThreadId || sessionKeyRest !== adoptionSessionKey(sourceThreadId, marker.sourceHomeId)) continue;
73
+ const sourceKey = sessionCatalogAdoptedSourceKey(marker.sourceHomeId ?? "gateway:local", sourceThreadId);
74
+ if (adopted.has(sourceKey)) throw new Error(`multiple OpenClaw sessions adopt Codex thread ${sourceThreadId} from the same home`);
75
+ adopted.set(sourceKey, {
76
+ key: sessionKey,
77
+ sessionId,
78
+ agentId,
79
+ boundThreadId
80
+ });
81
+ }
82
+ return adopted;
83
+ };
84
+ if (!params.bindingStore.readMany) return collect(candidates());
85
+ let prepared;
86
+ try {
87
+ prepared = [...candidates()];
88
+ } catch {
89
+ return collect(candidates());
90
+ }
91
+ const bindings = params.bindingStore.readMany(prepared.map(({ identity }) => identity));
92
+ try {
93
+ return collect(prepared, () => bindings.next().value);
94
+ } finally {
95
+ bindings.return(void 0);
63
96
  }
64
- return adopted;
65
97
  }
66
98
  async function findAdoptedSessionEntry(params) {
67
99
  const adopted = await listAdoptedSessionEntries(params);
@@ -119,7 +151,7 @@ async function createOrReuseAdoptedSession(params) {
119
151
  sourceThreadId: params.sourceThread.id,
120
152
  ...params.sourceHomeId ? { sourceHomeId: params.sourceHomeId } : {}
121
153
  };
122
- const { createImportedCodexSession } = await import("./session-history-import-DwyijFI6.js");
154
+ const { createImportedCodexSession } = await import("./session-history-import-D-3wAgOP.mjs");
123
155
  const created = await createImportedCodexSession({
124
156
  runtime: params.api.runtime,
125
157
  bindingStore: params.bindingStore,
@@ -1,9 +1,9 @@
1
- import { l as sessionBindingIdentity } from "./session-binding-record-Bcvslnhf.js";
2
- import { t as assertCodexArchiveDescendantsUnowned } from "./thread-archive-guard-DfpBr-Sz.js";
3
- import { c as CatalogParamsError } from "./thread-history-page-D0JIp48V.js";
4
- import "./session-binding-CI8UuilT.js";
5
- import { runSessionActionExclusive } from "./session-catalog-node-adoption-B1tgDW-m.js";
6
- import { isAdoptionSessionKeyForThread, requireIdleThread } from "./session-catalog-adoption-tcZi1IfX.js";
1
+ import { m as sessionBindingIdentity } from "./session-binding-record-BGoz8wOK.mjs";
2
+ import { v as CatalogParamsError } from "./session-catalog-native-projection-DowriLid.mjs";
3
+ import { t as assertCodexArchiveDescendantsUnowned } from "./thread-archive-guard-C9frICzX.mjs";
4
+ import "./session-binding-Cm0apEbd.mjs";
5
+ import { runSessionActionExclusive } from "./session-catalog-node-adoption-ITddWx_X.mjs";
6
+ import { isAdoptionSessionKeyForThread, requireIdleThread } from "./session-catalog-adoption-BI6UTDZT.mjs";
7
7
  import { listAgentIds } from "openclaw/plugin-sdk/agent-scope-runtime";
8
8
  import { sessionCatalogAdoptedSourceKey } from "openclaw/plugin-sdk/session-catalog";
9
9
  //#region extensions/codex/src/session-catalog-archive.ts
@@ -0,0 +1,347 @@
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 };