@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
@@ -0,0 +1,285 @@
1
+ import { n as projectCodexCatalogNativeResponse, r as projectCodexCatalogNativeThread } from "./session-catalog-native-projection-DowriLid.mjs";
2
+ import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
3
+ import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
4
+ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
5
+ import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
6
+ //#region extensions/codex/src/app-server/protocol-json.ts
7
+ function isRpcResponse(message) {
8
+ return message !== null && typeof message === "object" && "id" in message && (typeof message.id === "number" || typeof message.id === "string") && !("method" in message);
9
+ }
10
+ //#endregion
11
+ //#region extensions/codex/src/app-server/client-line-preview.ts
12
+ const CODEX_APP_SERVER_PARSE_LOG_MAX = 500;
13
+ function redactCodexAppServerLinePreview(value) {
14
+ const redacted = value.replace(/\s+/g, " ").trim().replace(/(Bearer\s+)[A-Za-z0-9._~+/-]+/gi, "$1<redacted>").replace(/("(?:api_?key|authorization|token|access_token|refresh_token)"\s*:\s*")([^"]+)(")/gi, "$1<redacted>$3").replace(/\b([a-z0-9_]*(?:api_?key|authorization|access_token|refresh_token|token))(\s*=\s*)(["']?)[^\s"']+(\3)/gi, "$1$2$3<redacted>$4");
15
+ return redacted.length > CODEX_APP_SERVER_PARSE_LOG_MAX ? `${truncateUtf16Safe(redacted, CODEX_APP_SERVER_PARSE_LOG_MAX)}...` : redacted;
16
+ }
17
+ //#endregion
18
+ //#region extensions/codex/src/app-server/client-message-decoder.ts
19
+ const PARSE_BUFFER_MAX = 8388608;
20
+ const PARSE_BUFFER_MAX_LINES = 1e3;
21
+ const UNICODE_ESCAPE_QUAD = /^[\da-fA-F]{4}$/u;
22
+ /** Recovers the raw newlines observed inside native JSON string values. */
23
+ var CodexAppServerMessageDecoder = class {
24
+ constructor(reportError) {
25
+ this.reportError = reportError;
26
+ }
27
+ clear() {
28
+ this.pending = void 0;
29
+ }
30
+ get hasPending() {
31
+ return this.pending !== void 0;
32
+ }
33
+ parse(line) {
34
+ const rawLine = line.endsWith("\r") ? line.slice(0, -1) : line;
35
+ if (this.pending) return this.parseContinuation(rawLine, this.pending);
36
+ const trimmed = rawLine.trim();
37
+ if (!trimmed) return;
38
+ try {
39
+ return JSON.parse(trimmed);
40
+ } catch (error) {
41
+ if (isRecoverableParseFailure(trimmed, error)) {
42
+ const text = rawLine.trimStart();
43
+ this.pending = {
44
+ fragments: [text],
45
+ length: text.length,
46
+ inString: endsInsideJsonString(text)
47
+ };
48
+ } else this.reportError(trimmed, error, 1);
49
+ }
50
+ }
51
+ parseContinuation(line, pending) {
52
+ pending.fragments.push(line);
53
+ pending.length += 2 + line.length;
54
+ const withinBounds = pending.length <= PARSE_BUFFER_MAX && pending.fragments.length <= PARSE_BUFFER_MAX_LINES;
55
+ if (withinBounds && pending.inString && scanJsonString(line, 0) === line.length) return;
56
+ const candidate = pending.fragments.join("\\n");
57
+ this.pending = void 0;
58
+ try {
59
+ return JSON.parse(candidate);
60
+ } catch (error) {
61
+ if (withinBounds && isRecoverableParseFailure(candidate, error)) {
62
+ pending.inString = endsInsideJsonString(candidate);
63
+ this.pending = pending;
64
+ } else this.reportError(candidate, error, pending.fragments.length);
65
+ }
66
+ }
67
+ };
68
+ function isRecoverableParseFailure(value, error) {
69
+ if (!value.startsWith("{") && !value.startsWith("[")) return false;
70
+ const message = coerceErrorMessage(error);
71
+ return message.includes("Unterminated string") || message.includes("Unexpected end of JSON input");
72
+ }
73
+ function endsInsideJsonString(value) {
74
+ for (let index = 0; index < value.length; index++) {
75
+ if (value[index] !== "\"") continue;
76
+ const end = scanJsonString(value, index + 1);
77
+ if (end < 0) return false;
78
+ if (end === value.length) return true;
79
+ index = end;
80
+ }
81
+ return false;
82
+ }
83
+ /** Finds a closing quote; incomplete or invalid escapes require native parsing. */
84
+ function scanJsonString(value, start) {
85
+ for (let index = start; index < value.length; index++) {
86
+ const character = value[index];
87
+ if (character === "\"") return index;
88
+ if (value.charCodeAt(index) < 32) return -1;
89
+ if (character !== "\\") continue;
90
+ const escape = value[++index];
91
+ if (escape === "u") {
92
+ if (!UNICODE_ESCAPE_QUAD.test(value.slice(index + 1, index + 5))) return -1;
93
+ index += 4;
94
+ } else if (!escape || !"\"\\/bfnrt".includes(escape)) return -1;
95
+ }
96
+ return value.length;
97
+ }
98
+ //#endregion
99
+ //#region extensions/codex/src/app-server/client-message-frames.ts
100
+ const UNPAIRED_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
101
+ /** One byte reader owns framing and stops at an asynchronous page decode. */
102
+ function listenCodexAppServerLines(input, onLine, onError) {
103
+ let fragments = [];
104
+ let length = 0;
105
+ let remainder;
106
+ let waiting = false;
107
+ let ended = false;
108
+ let closed = false;
109
+ const close = () => {
110
+ closed = true;
111
+ fragments = [];
112
+ remainder = void 0;
113
+ input.off("data", onData);
114
+ input.off("end", onEnd);
115
+ input.pause();
116
+ };
117
+ const deliver = (tail) => {
118
+ const line = fragments.length ? Buffer.concat([...fragments, tail], length + tail.length) : tail;
119
+ fragments = [];
120
+ length = 0;
121
+ const completion = onLine(line);
122
+ if (!completion) return true;
123
+ waiting = true;
124
+ input.pause();
125
+ completion.then(() => {
126
+ waiting = false;
127
+ if (!closed) {
128
+ drain();
129
+ if (!waiting && !ended && !closed) input.resume();
130
+ }
131
+ }).catch((error) => {
132
+ close();
133
+ onError(error);
134
+ });
135
+ return false;
136
+ };
137
+ const drain = () => {
138
+ try {
139
+ const chunk = remainder;
140
+ remainder = void 0;
141
+ if (chunk) {
142
+ let start = 0;
143
+ let end;
144
+ while ((end = chunk.indexOf(10, start)) !== -1) {
145
+ if (closed) return;
146
+ remainder = chunk.subarray(end + 1);
147
+ if (!deliver(chunk.subarray(start, end))) return;
148
+ remainder = void 0;
149
+ start = end + 1;
150
+ }
151
+ if (!closed && start < chunk.length) {
152
+ fragments.push(chunk.subarray(start));
153
+ length += chunk.length - start;
154
+ }
155
+ }
156
+ if (ended && !closed) {
157
+ if (length && !deliver(Buffer.alloc(0))) return;
158
+ close();
159
+ }
160
+ } catch (error) {
161
+ close();
162
+ onError(error);
163
+ }
164
+ };
165
+ const onData = (chunk) => {
166
+ remainder = chunk;
167
+ drain();
168
+ };
169
+ const onEnd = () => {
170
+ ended = true;
171
+ if (!waiting) drain();
172
+ };
173
+ input.on("data", onData);
174
+ input.once("end", onEnd);
175
+ return close;
176
+ }
177
+ function codexCatalogResponseRoute(id) {
178
+ return typeof id === "number" && Number.isSafeInteger(id) && id >= 2 ** 52 ? {
179
+ id,
180
+ kind: id % 2 === 1 ? "list" : "thread"
181
+ } : void 0;
182
+ }
183
+ /** Read bounded envelope keys and IDs; skip native payload strings as bytes. */
184
+ function readCodexCatalogDecodeRoute(line) {
185
+ let depth = 0;
186
+ let route;
187
+ let response = false;
188
+ for (let index = 0; index < line.length; index++) {
189
+ const byte = line[index];
190
+ if (byte === 123 || byte === 91) depth++;
191
+ else if (byte === 125 || byte === 93) depth--;
192
+ else if (byte === 34) {
193
+ const start = index;
194
+ for (;;) {
195
+ index = line.indexOf(34, index + 1);
196
+ if (index < 0) return "unresolved";
197
+ let slash = index - 1;
198
+ while (line[slash] === 92) slash--;
199
+ if ((index - slash) % 2 === 1) break;
200
+ }
201
+ if (depth !== 1 || index - start > 64) continue;
202
+ let colon = index + 1;
203
+ while (line[colon] === 32 || line[colon] === 9 || line[colon] === 13) colon++;
204
+ if (line[colon] !== 58) continue;
205
+ const token = line.toString("utf8", start, index + 1);
206
+ let key = token.slice(1, -1);
207
+ if (token.includes("\\")) try {
208
+ key = JSON.parse(token);
209
+ } catch {
210
+ return "unresolved";
211
+ }
212
+ if (key === "method") return;
213
+ if (key === "result" || key === "error") {
214
+ response = true;
215
+ if (route) return route;
216
+ }
217
+ if (key !== "id") continue;
218
+ const match = /^\s*:\s*(\d+)(?=\s*[,}])/u.exec(line.toString("utf8", index + 1, Math.min(index + 100, line.length)));
219
+ if (!match) continue;
220
+ route = codexCatalogResponseRoute(Number(match[1]));
221
+ if (!route || response) return route;
222
+ }
223
+ }
224
+ return response || route ? "unresolved" : void 0;
225
+ }
226
+ function stringifyCodexAppServerMessage(message) {
227
+ return JSON.stringify(message, (_key, value) => typeof value === "string" ? value.replace(UNPAIRED_SURROGATE_RE, "") : value) ?? "null";
228
+ }
229
+ //#endregion
230
+ //#region extensions/codex/src/app-server/client-catalog-response.ts
231
+ /** The worker retains recovery fragments, but never a completed native page. */
232
+ function createCodexCatalogDecoder() {
233
+ let failures = [];
234
+ const decoder = new CodexAppServerMessageDecoder((value, error, fragmentCount) => {
235
+ failures.push({
236
+ value: redactCodexAppServerLinePreview(value),
237
+ error,
238
+ fragmentCount
239
+ });
240
+ });
241
+ return (input) => {
242
+ failures = [];
243
+ const result = projectCodexCatalogMessage(decoder.parse(Buffer.from(input.bytes.buffer, input.bytes.byteOffset, input.bytes.byteLength).toString("utf8")), input);
244
+ result.pending = decoder.hasPending;
245
+ result.failures = failures;
246
+ return result;
247
+ };
248
+ }
249
+ function projectCodexCatalogMessage(parsed, input, cachedPreview) {
250
+ const result = {
251
+ pending: false,
252
+ failures: []
253
+ };
254
+ if (!isJsonObject(parsed)) return result;
255
+ result.message = parsed;
256
+ if (!isRpcResponse(parsed)) return result;
257
+ const message = parsed;
258
+ const route = codexCatalogResponseRoute(message.id);
259
+ if (message.error || !route) return result;
260
+ const remainingRows = input.route === "unresolved" ? input.catalogRows?.has(route.id) ? input.catalogRows.get(route.id) : 0 : input.remainingRows;
261
+ try {
262
+ if (!isJsonObject(message.result)) throw new Error("Codex catalog response contains an invalid result");
263
+ if (route.kind === "list") {
264
+ const raw = message.result;
265
+ message.result = projectCodexCatalogNativeResponse(raw, sanitizeTerminalText, cachedPreview, remainingRows);
266
+ if (!cachedPreview) result.previewStates = Array.isArray(raw.data) ? raw.data.slice(0, Array.isArray(message.result.data) ? message.result.data.length : 0).map((row) => isJsonObject(row) && typeof row.preview === "string" ? Boolean(row.preview) : void 0) : [];
267
+ } else {
268
+ const thread = message.result.thread;
269
+ message.result = { thread: {
270
+ ...projectCodexCatalogNativeThread(thread, sanitizeTerminalText),
271
+ ...isJsonObject(thread) && typeof thread.cwd === "string" ? { cwd: thread.cwd } : {},
272
+ ...isJsonObject(thread) && (thread.historyMode === "paginated" || thread.historyMode === "legacy") ? { historyMode: thread.historyMode } : {}
273
+ } };
274
+ }
275
+ } catch (error) {
276
+ delete result.message;
277
+ result.projectionError = {
278
+ id: route.id,
279
+ error: error instanceof Error ? error : new Error("Codex catalog projection failed", { cause: error })
280
+ };
281
+ }
282
+ return result;
283
+ }
284
+ //#endregion
285
+ export { stringifyCodexAppServerMessage as a, isRpcResponse as c, readCodexCatalogDecodeRoute as i, projectCodexCatalogMessage as n, CodexAppServerMessageDecoder as o, listenCodexAppServerLines as r, redactCodexAppServerLinePreview as s, createCodexCatalogDecoder as t };
@@ -1,11 +1,15 @@
1
- import { o as formatCodexDisplayText } from "./command-formatters-lxlkNZgU.js";
2
- import { n as describeControlFailure } from "./capabilities-8vx68WLH.js";
1
+ import { o as formatCodexDisplayText } from "./command-formatters-Bmqvr9tO.mjs";
2
+ import { n as describeControlFailure } from "./capabilities-CDXOOFdZ.mjs";
3
3
  //#region extensions/codex/src/command-dispatch.ts
4
4
  /** Dispatches a `/codex` command to the lazily loaded handler. */
5
5
  async function handleCodexCommand(ctx, options) {
6
+ const commandContext = {
7
+ ...ctx,
8
+ gatewayClientScopes: ctx.gatewayClientScopes?.slice()
9
+ };
6
10
  const { loadSubcommandHandler, resolvePluginConfig, ...subcommandOptions } = options;
7
11
  try {
8
- return await (loadSubcommandHandler ? await loadSubcommandHandler() : await loadDefaultCodexSubcommandHandler())(ctx, {
12
+ return await (loadSubcommandHandler ? await loadSubcommandHandler() : await loadDefaultCodexSubcommandHandler())(commandContext, {
9
13
  ...subcommandOptions,
10
14
  pluginConfig: resolvePluginConfig?.() ?? subcommandOptions.pluginConfig
11
15
  });
@@ -14,7 +18,7 @@ async function handleCodexCommand(ctx, options) {
14
18
  }
15
19
  }
16
20
  async function loadDefaultCodexSubcommandHandler() {
17
- const { handleCodexSubcommand } = await import("./command-handlers-tiL9iWj7.js");
21
+ const { handleCodexSubcommand } = await import("./command-handlers-DW7Lx9oH.mjs");
18
22
  return handleCodexSubcommand;
19
23
  }
20
24
  //#endregion
@@ -1,5 +1,5 @@
1
- import { o as isJsonObject } from "./protocol-5bh1G-H7.js";
2
- import { c as summarizeCodexRateLimits, o as summarizeCodexAccountRateLimits, r as hasCodexRateLimitSnapshots } from "./rate-limits-CBMmWBr9.js";
1
+ import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
2
+ import { c as summarizeCodexRateLimits, o as summarizeCodexAccountRateLimits, r as hasCodexRateLimitSnapshots } from "./rate-limits-CMU3DUD0.mjs";
3
3
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  //#region extensions/codex/src/command-formatters.ts
5
5
  /**
@@ -42,10 +42,14 @@ function formatThreads(response) {
42
42
  }
43
43
  /** Formats account and rate-limit output for `/codex account`. */
44
44
  function formatAccount(account, limits, authOverview) {
45
- if (authOverview) return formatAccountAuthOverview(authOverview);
45
+ if (authOverview?.rows.some((row) => row.active)) return formatAccountAuthOverview(authOverview);
46
46
  const formattedLimits = limits.ok ? formatCodexRateLimitDetails(limits.value) : formatCodexDisplayText(limits.error);
47
47
  const rateLimitBlock = formattedLimits.startsWith("Codex is ") ? formattedLimits : formattedLimits.includes("\n") ? `Rate limits:\n${formattedLimits}` : `Rate limits: ${formattedLimits}`;
48
- return [`Account: ${account.ok ? formatCodexAccountSummary(account.value) : formatCodexDisplayText(account.error)}`, rateLimitBlock].join("\n\n");
48
+ return [
49
+ `Account: ${account.ok ? formatCodexAccountSummary(account.value) : formatCodexDisplayText(account.error)}`,
50
+ rateLimitBlock,
51
+ ...authOverview ? [formatAccountAuthOverview(authOverview)] : []
52
+ ].join("\n\n");
49
53
  }
50
54
  function formatAccountAuthOverview(overview) {
51
55
  const lines = [];