@openclaw/codex 2026.9.7 → 2026.10.1-beta.1

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 (151) hide show
  1. package/README.md +8 -0
  2. package/dist/.setup/{account-usage-runtime-DFhbh1zz.mjs → account-usage-runtime-C4GFoef_.mjs} +5 -5
  3. package/dist/.setup/app-server-policy-Bg4FZw1f.mjs +23 -0
  4. package/dist/.setup/{apply-D3GcSoSa.mjs → apply-D02fLpgN.mjs} +48 -39
  5. package/dist/.setup/attempt-client-cleanup-yLjGwbwT.mjs +155 -0
  6. package/dist/.setup/{attempt-workspace-context-C5HigshI.mjs → attempt-workspace-context-CbSzT6V2.mjs} +11 -15
  7. package/dist/.setup/{auth-binding-BLWz7stm.mjs → auth-binding-BoMwpuPN.mjs} +17 -25
  8. package/dist/.setup/{auth-cache-key-Dbvq-QgB.mjs → auth-cache-key-CEd9QlIs.mjs} +244 -82
  9. package/dist/.setup/{auth-profile-B0okYl2D.mjs → auth-profile-CgHQ8Vot.mjs} +2 -1
  10. package/dist/.setup/{auth-profile-selection-DFu9e167.mjs → auth-profile-selection-hr8ocLtz.mjs} +5 -7
  11. package/dist/.setup/{binding-connection-DTtN1KrX.mjs → binding-connection-C-08ez1w.mjs} +2 -2
  12. package/dist/.setup/{binding-connection.runtime-6TpgD1M6.mjs → binding-connection.runtime-Dn2p-fdy.mjs} +3 -3
  13. package/dist/.setup/{bounded-turn-CbjoN2OW.mjs → bounded-turn-DlHlNTyS.mjs} +14 -13
  14. package/dist/.setup/{bounded-turn-isolation-B8K_ylqk.mjs → bounded-turn-isolation-DklXNk3k.mjs} +4 -4
  15. package/dist/.setup/{build-state-Da1_z0kd.mjs → build-state-CIi3Ckqu.mjs} +1 -1
  16. package/dist/.setup/{capabilities-B3WEZl4e.mjs → capabilities-kQntafj_.mjs} +1 -1
  17. package/dist/.setup/{client-N0JpgSzF.mjs → client-CBzEVDyb.mjs} +438 -160
  18. package/dist/.setup/{client-catalog-response-5HHLdcde.mjs → client-catalog-response-CmvIiDdj.mjs} +57 -25
  19. package/dist/.setup/command-authorization-AikPDtcc.mjs +15 -0
  20. package/dist/.setup/{command-dispatch-BeAoaovI.mjs → command-dispatch-BE_RdMou.mjs} +3 -3
  21. package/dist/.setup/{command-formatters-R3ckE3Co.mjs → command-formatters-DV3DHhdr.mjs} +7 -5
  22. package/dist/.setup/{command-handlers-ylTMS00z.mjs → command-handlers-DNoRq5Ps.mjs} +82 -144
  23. package/dist/.setup/{command-rpc-CGJGUQ6Y.mjs → command-rpc-B6xsq2dB.mjs} +23 -31
  24. package/dist/.setup/{compact-C2WamavS.mjs → compact-BLSAd-ru.mjs} +117 -65
  25. package/dist/.setup/{plugin-metadata-cache-DsjsL1dr.mjs → computer-use-DpolvQHw.mjs} +66 -203
  26. package/dist/.setup/{config-DKhXquav.mjs → config-0Gxk3_eq.mjs} +5 -6
  27. package/dist/.setup/{config-options-CzyWLTJt.mjs → config-options-HG_Rr3W_.mjs} +13 -23
  28. package/dist/.setup/{config-parsing-b088LyhT.mjs → config-parsing-BQq-CHTF.mjs} +41 -4
  29. package/dist/.setup/{config-runtime-C0NbLms1.mjs → config-runtime-cUYrqu_a.mjs} +2 -2
  30. package/dist/.setup/{config-security-CE-FcGw9.mjs → config-security-KAPScztc.mjs} +20 -36
  31. package/dist/.setup/{context-engine-projection-PezSESth.mjs → context-engine-projection-CsgYSQhW.mjs} +11 -14
  32. package/dist/.setup/{conversation-binding-3Min8qvP.mjs → conversation-binding-CgSSD1Qz.mjs} +36 -48
  33. package/dist/.setup/{conversation-binding-data-C746z5Pn.mjs → conversation-binding-data-DJ4ix-W5.mjs} +1 -1
  34. package/dist/.setup/{conversation-control-CEP8X5JC.mjs → conversation-control-tCg763cI.mjs} +19 -21
  35. package/dist/.setup/{cyber-failover-XV0nNRZu.mjs → cyber-failover-Bb1J6hS1.mjs} +1 -1
  36. package/dist/.setup/{cyber-failover-notice-RNpGpTyP.mjs → cyber-failover-notice-XR03ef31.mjs} +1 -1
  37. package/dist/.setup/doctor-start-options-DPW9JxIE.mjs +63 -0
  38. package/dist/.setup/dynamic-tool-build-CVrx02cH.mjs +463 -0
  39. package/dist/.setup/{dynamic-tools-DzlsLUuS.mjs → dynamic-tools-DdsymYGQ.mjs} +238 -878
  40. package/dist/.setup/{effective-mcp-catalog-CxUtC-xG.mjs → effective-mcp-catalog-BysTBZCW.mjs} +83 -11
  41. package/dist/.setup/{elicitation-input-DPoK8F7w.mjs → elicitation-input-r9axtppm.mjs} +4 -2
  42. package/dist/.setup/{ephemeral-turn-CDsPJOa2.mjs → ephemeral-turn-oPKxs3ia.mjs} +2 -2
  43. package/dist/.setup/{event-projector-assistant-message-CigreO4K.mjs → event-projector-assistant-message-YCL2wspu.mjs} +2 -2
  44. package/dist/.setup/{event-projector-values-DJSz8BTk.mjs → event-projector-values-DTqZHizf.mjs} +2 -12
  45. package/dist/.setup/{inference-dispatch-CMZtjQyz.mjs → inference-dispatch-B5UKEUyC.mjs} +12 -21
  46. package/dist/.setup/{inference-proxy-DhcXOgUE.mjs → inference-proxy-DUO5E2QQ.mjs} +6 -5
  47. package/dist/.setup/{isolated-completion-Dm3PzxJk.mjs → isolated-completion-D5gbKm6k.mjs} +8 -8
  48. package/dist/.setup/{managed-binary-kiWRhNRE.mjs → managed-binary-C1VFoVPf.mjs} +31 -38
  49. package/dist/.setup/mcp-app-session-preparation-CdqsXwZX.mjs +223 -0
  50. package/dist/.setup/mcp-tool-metadata-j10HhfTC.mjs +43 -0
  51. package/dist/.setup/{model-catalog-PAuZgJC6.mjs → model-catalog-Dj_uvusa.mjs} +7 -7
  52. package/dist/.setup/{models-DHXZtVVk.mjs → models-Du_i5G_t.mjs} +10 -7
  53. package/dist/.setup/{native-auth-CuG53tu4.mjs → native-auth-Cjb9y7IZ.mjs} +5 -6
  54. package/dist/.setup/{native-execution-policy-BxZJy5mP.mjs → native-execution-policy-ClzpdG3D.mjs} +1 -12
  55. package/dist/.setup/native-mcp-app-DV7VbfzF.mjs +310 -0
  56. package/dist/.setup/{native-subagent-monitor-Dpsmf2wz.mjs → native-subagent-monitor-CCEFO6qK.mjs} +235 -318
  57. package/dist/.setup/{native-subagent-pending-assignments-DwkCzLvD.mjs → native-subagent-pending-assignments-BDqhOdJp.mjs} +0 -4
  58. package/dist/.setup/{native-task-assignments-DMQ0g3hu.mjs → native-task-assignments-C6KVqiN1.mjs} +9 -8
  59. package/dist/.setup/{node-cli-sessions-HC4W6FLI.mjs → node-cli-sessions-B5oNDkUS.mjs} +11 -17
  60. package/dist/.setup/{node-exec-server.runtime-BgBfWQqo.mjs → node-exec-server.runtime-0xSEjKYt.mjs} +2 -2
  61. package/dist/.setup/{plan-Y-QIvrKB.mjs → plan-CUHSIOep.mjs} +67 -89
  62. package/dist/.setup/{plugin-activation-cNHRfaxU.mjs → plugin-activation-BcyBv8PG.mjs} +4 -4
  63. package/dist/.setup/{plugin-app-cache-key-BL9B5H0L.mjs → plugin-app-cache-key-BW8rd98k.mjs} +11 -15
  64. package/dist/.setup/plugin-approval-roundtrip-uAR-oQfr.mjs +109 -0
  65. package/dist/.setup/{plugin-inventory-Cky2XJUw.mjs → plugin-inventory-Bf0_piTw.mjs} +29 -51
  66. package/dist/.setup/{plugin-marketplace-discovery-D_dV9FXa.mjs → plugin-marketplace-discovery-SQPhSuic.mjs} +2 -16
  67. package/dist/.setup/plugin-metadata-cache-DWnB7VMj.mjs +84 -0
  68. package/dist/.setup/plugin-thread-config-deadline-CdRzGJt4.mjs +124 -0
  69. package/dist/.setup/{provider-DH8NSzGt.mjs → provider-BP8ZaZqn.mjs} +4 -4
  70. package/dist/.setup/provider-capabilities-Z5ZbBxqP.mjs +50 -0
  71. package/dist/.setup/{rate-limits-B7-X2TgG.mjs → rate-limits-CMPy24F5.mjs} +1 -5
  72. package/dist/.setup/{request-BHZ1nz8d.mjs → request-BH3FvYUE.mjs} +189 -49
  73. package/dist/.setup/rpc-error-hmWM21RB.mjs +57 -0
  74. package/dist/.setup/{run-attempt-D8RZUOzY.mjs → run-attempt-CgvFoW7R.mjs} +553 -727
  75. package/dist/.setup/{run-attempt-lifecycle-C-6O3Exn.mjs → run-attempt-lifecycle-BuZgVbDA.mjs} +19 -3
  76. package/dist/.setup/{runtime-artifact-DDQ-HGXf.mjs → runtime-artifact-CUTOOnKw.mjs} +5 -6
  77. package/dist/.setup/{runtime-artifact-connection-D68qQn1m.mjs → runtime-artifact-connection-CADz3_BY.mjs} +5 -4
  78. package/dist/.setup/{sandbox-guard-DjCz2eOw.mjs → sandbox-guard-WqE8yPge.mjs} +3 -3
  79. package/dist/.setup/service-tier-normalization-Cei89SW6.mjs +15 -0
  80. package/dist/.setup/{session-binding-DGCYAfvD.mjs → session-binding-Ce7BqiPN.mjs} +92 -102
  81. package/dist/.setup/session-binding-meta-Lkm5Lpf4.mjs +15 -0
  82. package/dist/.setup/session-binding-record-BZB8RgcF.mjs +179 -0
  83. package/dist/.setup/session-binding-record-codec-z4ZpDn6E.mjs +216 -0
  84. package/dist/.setup/{session-binding-sidecars-jo6H8dFr.mjs → session-binding-sidecars-BrdV95Fg.mjs} +8 -2
  85. package/dist/.setup/{session-catalog-adoption-BU_pHWG7.mjs → session-catalog-adoption-CPIP4S_y.mjs} +34 -18
  86. package/dist/.setup/{session-catalog-archive-spHfihri.mjs → session-catalog-archive-DcgwvSbF.mjs} +24 -29
  87. package/dist/.setup/{session-catalog-events-DePDzzjc.mjs → session-catalog-events-KIXOoSnQ.mjs} +5 -5
  88. package/dist/.setup/{session-catalog-index-CZvDzC6z.mjs → session-catalog-index-DPICGlxr.mjs} +361 -72
  89. package/dist/.setup/{session-catalog-index-order-BcQpHks3.mjs → session-catalog-index-order-nhyO0wdW.mjs} +1 -1
  90. package/dist/.setup/{session-catalog-limits-DDxOsQeC.mjs → session-catalog-limits-DEU36Qlo.mjs} +1 -1
  91. package/dist/.setup/{session-catalog-index-state-TeO7EyO-.mjs → session-catalog-list-request-tXephOB4.mjs} +180 -6
  92. package/dist/.setup/{session-catalog-native-projection-DjhwGL6x.mjs → session-catalog-native-projection-CTBd4EUm.mjs} +7 -6
  93. package/dist/.setup/{session-catalog-node-adoption-DgXvSGu0.mjs → session-catalog-node-adoption-7-WEQTB1.mjs} +12 -2
  94. package/dist/.setup/{session-catalog-node-continue-DjKXHBbi.mjs → session-catalog-node-continue-DLWBwAAO.mjs} +11 -15
  95. package/dist/.setup/{session-catalog-node-lookup-CtAXI5W5.mjs → session-catalog-node-lookup-Uufckwcm.mjs} +2 -2
  96. package/dist/.setup/{session-catalog-parsing-CPGaPYr-.mjs → session-catalog-parsing-B-qWJh2x.mjs} +70 -28
  97. package/dist/.setup/{session-catalog-projection-Cr5qP5Dj.mjs → session-catalog-projection-CE0_Hffi.mjs} +6 -122
  98. package/dist/.setup/{session-catalog-provenance-DoAvktcj.mjs → session-catalog-provenance-CmsOE5mh.mjs} +6 -1
  99. package/dist/.setup/{session-cli-Cn_nCqfq.mjs → session-cli-kH4vuGod.mjs} +1 -2
  100. package/dist/.setup/{session-history-D83lJWHG.mjs → session-history-BogBHKLk.mjs} +1 -1
  101. package/dist/.setup/{session-history-import-WhX-X33a.mjs → session-history-import-NWKPa4ZO.mjs} +4 -4
  102. package/dist/.setup/{session-history-read-Ov3StuL4.mjs → session-history-read-CNN8zwbD.mjs} +8 -19
  103. package/dist/.setup/{session-history.worker-MnPKncqP.mjs → session-history.worker-Cq_4DYgN.mjs} +3 -3
  104. package/dist/.setup/{session-initialization-6aveB9qb.mjs → session-initialization-D6dtFQkE.mjs} +2 -2
  105. package/dist/.setup/{session-permission-policy-Ci_fVX6y.mjs → session-permission-policy-BxIUJ0Zd.mjs} +8 -37
  106. package/dist/.setup/{session-retirement-qMTxkNx2.mjs → session-retirement-aC60o6P3.mjs} +14 -15
  107. package/dist/.setup/{settled-turn-context-D4yj4rxf.mjs → settled-turn-context-BZsMjkIO.mjs} +13 -6
  108. package/dist/.setup/{settled-turn-finalizer-BsvEabkw.mjs → settled-turn-finalizer-CDxCejjC.mjs} +8 -8
  109. package/dist/.setup/{shared-client-DqyTMYug.mjs → shared-client-DJJ3ljH2.mjs} +291 -272
  110. package/dist/.setup/{provider-capabilities-CAxoF-X1.mjs → shell-dynamic-tools-Do9lIAT1.mjs} +16 -55
  111. package/dist/.setup/{side-question-C4kCmQy1.mjs → side-question-B7T0_GEC.mjs} +99 -91
  112. package/dist/.setup/{source-CS_7GFJZ.mjs → source-DH70LqN0.mjs} +24 -40
  113. package/dist/.setup/{thread-lifecycle-DPflntEJ.mjs → thread-lifecycle-DkcoX9q-.mjs} +262 -305
  114. package/dist/.setup/{thread-ownership-roNP0l1c.mjs → thread-ownership-0aRHD9iK.mjs} +10 -8
  115. package/dist/.setup/{thread-policy-DTd-DtkX.mjs → thread-policy-CXZV97TS.mjs} +22 -21
  116. package/dist/.setup/{thread-requests-B_bRnMGN.mjs → thread-requests-COrRJcZb.mjs} +107 -98
  117. package/dist/.setup/{thread-resume-CdDaoc7T.mjs → thread-resume-rx7J68Rx.mjs} +10 -18
  118. package/dist/.setup/{transcript-history-projection-DRSifI-1.mjs → transcript-history-projection-B9a7HwUV.mjs} +11 -16
  119. package/dist/.setup/{transcript-mirror-kxmCYsuF.mjs → transcript-mirror-BfLRARNL.mjs} +64 -67
  120. package/dist/.setup/{transport-stdio-Bdegpn2V.mjs → transport-stdio-a0HDa2Mj.mjs} +27 -8
  121. package/dist/.setup/{transport-websocket-BTBE-LD9.mjs → transport-websocket-zqJ0Cmtn.mjs} +3 -8
  122. package/dist/.setup/{attempt-client-cleanup-DOP-cW5j.mjs → turn-router-CX1-EoCp.mjs} +75 -170
  123. package/dist/.setup/{upstream-session-fork-CBeVjBpT.mjs → upstream-session-fork-LYlaQnbt.mjs} +35 -46
  124. package/dist/.setup/{usage-BMzNxeR_.mjs → usage-Dmx7B0W2.mjs} +4 -4
  125. package/dist/.setup/{usage-limit-error-QXerDo3i.mjs → usage-limit-error-M8jVnITZ.mjs} +4 -4
  126. package/dist/.setup/{web-search-provider.runtime-P77OUeoo.mjs → web-search-provider.runtime-CsVmqbFm.mjs} +4 -20
  127. package/dist/.setup/websocket-data-XlRvt8Ys.mjs +6 -0
  128. package/dist/.setup/workspace-write-sandbox-probe-DmUHLrrl.mjs +118 -0
  129. package/dist/api.js +34 -54
  130. package/dist/catalog-page.worker.js +1 -1
  131. package/dist/cli-metadata.js +1 -1
  132. package/dist/doctor-contract-api.js +15 -27
  133. package/dist/harness.js +37 -22
  134. package/dist/index.js +2880 -276
  135. package/dist/media-understanding-provider.js +2 -2
  136. package/dist/migration-provider-api.js +1 -1
  137. package/dist/native-session-binding-api.js +2 -0
  138. package/dist/provider-discovery.js +1 -1
  139. package/dist/session-history-worker-runtime.js +33 -4
  140. package/dist/session-history.worker.js +1 -1
  141. package/openclaw.plugin.json +3 -3
  142. package/package.json +6 -6
  143. package/dist/.setup/config-utils-D0CXecki.mjs +0 -57
  144. package/dist/.setup/incognito-session-DWYapfwf.mjs +0 -2
  145. package/dist/.setup/managed-thread-store-BMqgThVL.mjs +0 -100
  146. package/dist/.setup/rpc-error-BlD2vuzn.mjs +0 -31
  147. package/dist/.setup/session-binding-meta-B7aEMU7g.mjs +0 -6
  148. package/dist/.setup/session-binding-record-Oe9L-CNY.mjs +0 -375
  149. package/dist/.setup/session-catalog-4sCdv5qx.mjs +0 -2610
  150. package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +0 -170
  151. package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +0 -153
@@ -1,8 +1,8 @@
1
1
  import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
2
- import { n as projectCodexCatalogNativeResponse, r as projectCodexCatalogNativeThread } from "./session-catalog-native-projection-DjhwGL6x.mjs";
3
- import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
2
+ import { n as projectCodexCatalogNativeResponse, r as projectCodexCatalogNativeThread } from "./session-catalog-native-projection-CTBd4EUm.mjs";
4
3
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
5
4
  import { sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
5
+ import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
6
6
  //#region extensions/codex/src/app-server/protocol-json.ts
7
7
  function isRpcResponse(message) {
8
8
  return message !== null && typeof message === "object" && "id" in message && (typeof message.id === "number" || typeof message.id === "string") && !("method" in message);
@@ -38,14 +38,14 @@ var CodexAppServerMessageDecoder = class {
38
38
  try {
39
39
  return JSON.parse(trimmed);
40
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);
41
+ const text = rawLine.trimStart();
42
+ const inString = recoverableJsonStringState(text, error);
43
+ if (inString !== void 0) this.pending = {
44
+ fragments: [text],
45
+ length: text.length,
46
+ inString
47
+ };
48
+ else this.reportError(trimmed, error, 1);
49
49
  }
50
50
  }
51
51
  parseContinuation(line, pending) {
@@ -58,27 +58,35 @@ var CodexAppServerMessageDecoder = class {
58
58
  try {
59
59
  return JSON.parse(candidate);
60
60
  } catch (error) {
61
- if (withinBounds && isRecoverableParseFailure(candidate, error)) {
62
- pending.inString = endsInsideJsonString(candidate);
61
+ const inString = withinBounds ? recoverableJsonStringState(candidate, error) : void 0;
62
+ if (inString !== void 0) {
63
+ pending.inString = inString;
63
64
  this.pending = pending;
64
65
  } else this.reportError(candidate, error, pending.fragments.length);
65
66
  }
66
67
  }
67
68
  };
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) {
69
+ /** Undefined rejects malformed JSON; false retains a trailing escape for native parsing. */
70
+ function recoverableJsonStringState(value, error) {
71
+ if (!(error instanceof SyntaxError) || !value.startsWith("{") && !value.startsWith("[")) return;
72
+ const closers = [];
74
73
  for (let index = 0; index < value.length; index++) {
75
- if (value[index] !== "\"") continue;
74
+ const character = value[index];
75
+ if (character === "{" || character === "[") closers.push(character === "{" ? "}" : "]");
76
+ else if (character === "}" || character === "]") closers.pop();
77
+ if (character !== "\"") continue;
76
78
  const end = scanJsonString(value, index + 1);
77
- if (end < 0) return false;
78
- if (end === value.length) return true;
79
+ if (end < 0) return;
80
+ if (end >= value.length) {
81
+ const closing = closers.toReversed().join("");
82
+ for (const suffix of ["\"", "\":null"]) try {
83
+ JSON.parse(`${value}\\n${suffix}${closing}`);
84
+ return end === value.length;
85
+ } catch {}
86
+ return;
87
+ }
79
88
  index = end;
80
89
  }
81
- return false;
82
90
  }
83
91
  /** Finds a closing quote; incomplete or invalid escapes require native parsing. */
84
92
  function scanJsonString(value, start) {
@@ -88,15 +96,39 @@ function scanJsonString(value, start) {
88
96
  if (value.charCodeAt(index) < 32) return -1;
89
97
  if (character !== "\\") continue;
90
98
  const escape = value[++index];
91
- if (escape === "u") {
99
+ if (!escape) return value.length + 1;
100
+ else if (escape === "u") {
92
101
  if (!UNICODE_ESCAPE_QUAD.test(value.slice(index + 1, index + 5))) return -1;
93
102
  index += 4;
94
- } else if (!escape || !"\"\\/bfnrt".includes(escape)) return -1;
103
+ } else if (!"\"\\/bfnrt".includes(escape)) return -1;
95
104
  }
96
105
  return value.length;
97
106
  }
98
107
  //#endregion
99
108
  //#region extensions/codex/src/app-server/client-message-frames.ts
109
+ function createCodexAppServerMessageWriter(options) {
110
+ return (message, onError, beforeWrite, onWriteResult) => {
111
+ if (options.isClosed()) return;
112
+ const child = options.getTransport();
113
+ const id = "id" in message ? message.id : void 0;
114
+ const method = "method" in message ? message.method : void 0;
115
+ const frame = stringifyCodexAppServerMessage(message);
116
+ if (child.maxFrameBytes && Buffer.byteLength(frame) > child.maxFrameBytes) throw new Error("Codex request exceeds the transport frame limit; reduce attached images or context.");
117
+ beforeWrite?.();
118
+ if (method === "command/exec") options.onNativeExecution();
119
+ child.stdin.write(`${frame}\n`, (error) => {
120
+ onWriteResult?.(error);
121
+ if (error) {
122
+ embeddedAgentLog.warn("codex app-server write failed", {
123
+ error,
124
+ id,
125
+ method
126
+ });
127
+ onError?.(error);
128
+ }
129
+ });
130
+ };
131
+ }
100
132
  const UNPAIRED_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
101
133
  /** One byte reader owns framing and stops at an asynchronous page decode. */
102
134
  function listenCodexAppServerLines(input, onLine, onError) {
@@ -282,4 +314,4 @@ function projectCodexCatalogMessage(parsed, input, cachedPreview) {
282
314
  return result;
283
315
  }
284
316
  //#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 };
317
+ export { readCodexCatalogDecodeRoute as a, isRpcResponse as c, listenCodexAppServerLines as i, projectCodexCatalogMessage as n, CodexAppServerMessageDecoder as o, createCodexAppServerMessageWriter as r, redactCodexAppServerLinePreview as s, createCodexCatalogDecoder as t };
@@ -0,0 +1,15 @@
1
+ //#region extensions/codex/src/command-authorization.ts
2
+ const CODEX_NATIVE_EXECUTION_AUTH_ERROR = "Only an owner or operator.admin can control Codex native execution.";
3
+ const CODEX_HOST_INSPECTION_AUTH_ERROR = "Only an owner or operator.admin can inspect Codex host state.";
4
+ const CODEX_FULL_PERMISSIONS_AUTH_ERROR = "Full Codex permissions require operator.admin. Choose Admin in the Control UI permission picker, or use an admin-authenticated CLI.";
5
+ function hasCodexAdminScope(ctx) {
6
+ return ctx.gatewayClientScopes?.includes("operator.admin") === true;
7
+ }
8
+ function canMutateCodexHost(ctx) {
9
+ return ctx.senderIsOwner === true || hasCodexAdminScope(ctx);
10
+ }
11
+ function assertCodexHostOwnerCurrent(ctx) {
12
+ if (!hasCodexAdminScope(ctx)) ctx.assertOwnerCurrent?.();
13
+ }
14
+ //#endregion
15
+ export { canMutateCodexHost as a, assertCodexHostOwnerCurrent as i, CODEX_HOST_INSPECTION_AUTH_ERROR as n, hasCodexAdminScope as o, CODEX_NATIVE_EXECUTION_AUTH_ERROR as r, CODEX_FULL_PERMISSIONS_AUTH_ERROR as t };
@@ -1,5 +1,5 @@
1
- import { o as formatCodexDisplayText } from "./command-formatters-R3ckE3Co.mjs";
2
- import { n as describeControlFailure } from "./capabilities-B3WEZl4e.mjs";
1
+ import { o as formatCodexDisplayText } from "./command-formatters-DV3DHhdr.mjs";
2
+ import { n as describeControlFailure } from "./capabilities-kQntafj_.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) {
@@ -9,7 +9,7 @@ async function handleCodexCommand(ctx, options) {
9
9
  };
10
10
  const { resolvePluginConfig, ...subcommandOptions } = options;
11
11
  try {
12
- const { handleCodexSubcommand } = await import("./command-handlers-ylTMS00z.mjs");
12
+ const { handleCodexSubcommand } = await import("./command-handlers-DNoRq5Ps.mjs");
13
13
  return await handleCodexSubcommand(commandContext, {
14
14
  ...subcommandOptions,
15
15
  pluginConfig: resolvePluginConfig?.() ?? subcommandOptions.pluginConfig
@@ -1,6 +1,11 @@
1
1
  import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
2
- import { c as summarizeCodexRateLimits, o as summarizeCodexAccountRateLimits, r as hasCodexRateLimitSnapshots } from "./rate-limits-B7-X2TgG.mjs";
2
+ import { c as summarizeCodexRateLimits, o as summarizeCodexAccountRateLimits, r as hasCodexRateLimitSnapshots } from "./rate-limits-CMPy24F5.mjs";
3
3
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ //#region extensions/codex/src/command-account-email.ts
5
+ function isLikelyEmailAddress(value) {
6
+ return /^[^\s@<>()[\]`]+@[^\s@<>()[\]`]+\.[^\s@<>()[\]`]+$/.test(value);
7
+ }
8
+ //#endregion
4
9
  //#region extensions/codex/src/command-formatters.ts
5
10
  /**
6
11
  * Formats Codex command responses for safe chat display, including status,
@@ -141,9 +146,6 @@ function formatCodexAccountLine(value) {
141
146
  formatted += escapeCodexChatText(safe.slice(lastIndex));
142
147
  return formatted;
143
148
  }
144
- function isLikelyEmailAddress(value) {
145
- return /^[^\s@<>()[\]`]+@[^\s@<>()[\]`]+\.[^\s@<>()[\]`]+$/.test(value);
146
- }
147
149
  function buildHelp() {
148
150
  return [
149
151
  "Codex commands:",
@@ -252,4 +254,4 @@ function extractArray(value) {
252
254
  return [];
253
255
  }
254
256
  //#endregion
255
- export { formatCodexAccountLine as a, formatCodexTextForDisplay as c, formatModels as d, formatSkills as f, formatAccount as i, formatComputerUseStatus as l, buildHelp as n, formatCodexDisplayText as o, formatThreads as p, escapeCodexChatText as r, formatCodexStatus as s, CODEX_RESUME_SAFE_THREAD_ID_PATTERN as t, formatList as u };
257
+ export { formatCodexAccountLine as a, formatCodexTextForDisplay as c, formatModels as d, formatSkills as f, formatAccount as i, formatComputerUseStatus as l, isLikelyEmailAddress as m, buildHelp as n, formatCodexDisplayText as o, formatThreads as p, escapeCodexChatText as r, formatCodexStatus as s, CODEX_RESUME_SAFE_THREAD_ID_PATTERN as t, formatList as u };
@@ -1,48 +1,51 @@
1
- import { n as isCodexFastServiceTier } from "./config-utils-D0CXecki.mjs";
2
- import { o as pluginReadParams, r as isOpenAiCuratedMarketplaceName, t as findCodexMarketplacePluginSummary, u as CODEX_PLUGINS_MARKETPLACE_NAME } from "./plugin-inventory-Cky2XJUw.mjs";
3
1
  import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
4
- import { n as assertCodexBindingMayBeReplaced, r as bindingStoreKey, v as sessionBindingIdentity } from "./session-binding-record-Oe9L-CNY.mjs";
5
- import { c as resolveCodexAppServerPreparedApiKeyCacheKey, s as resolveCodexAppServerFallbackApiKeyCacheKey } from "./auth-cache-key-Dbvq-QgB.mjs";
2
+ import { m as sessionBindingIdentity, n as assertCodexBindingMayBeReplaced, r as bindingStoreKey } from "./session-binding-record-BZB8RgcF.mjs";
3
+ import { m as isCodexFastServiceTier } from "./config-parsing-BQq-CHTF.mjs";
4
+ import { c as resolveCodexAppServerPreparedApiKeyCacheKey, s as resolveCodexAppServerFallbackApiKeyCacheKey } from "./auth-cache-key-CEd9QlIs.mjs";
6
5
  import { n as withCodexConversationThreadActivity } from "./thread-ownership-queue-Dp24d7-F.mjs";
7
- import { a as CODEX_HOST_INSPECTION_AUTH_ERROR, c as canMutateCodexHost, i as CODEX_FULL_PERMISSIONS_AUTH_ERROR, l as hasCodexAdminScope, n as filterCodexMarketplacePlugins, o as CODEX_NATIVE_EXECUTION_AUTH_ERROR, r as parseCodexPluginMarketplaceId, s as assertCodexHostOwnerCurrent, t as discoverCodexMarketplacePlugins } from "./plugin-marketplace-discovery-D_dV9FXa.mjs";
8
- import { l as formatRelativeDuration, s as summarizeCodexAccountUsage } from "./rate-limits-B7-X2TgG.mjs";
9
- import { a as formatCodexAccountLine, c as formatCodexTextForDisplay, d as formatModels, f as formatSkills, i as formatAccount, l as formatComputerUseStatus, n as buildHelp, o as formatCodexDisplayText, p as formatThreads, r as escapeCodexChatText, s as formatCodexStatus, t as CODEX_RESUME_SAFE_THREAD_ID_PATTERN, u as formatList } from "./command-formatters-R3ckE3Co.mjs";
10
- import { i as readCodexConversationBindingData, n as createCodexCliNodeConversationBindingData, o as resolveCodexDefaultWorkspaceDir, r as createCodexConversationBindingData } from "./conversation-binding-data-C746z5Pn.mjs";
11
- import { t as isIncognitoSessionKey } from "./incognito-session-DWYapfwf.mjs";
12
- import { n as CodexAppServerRpcError } from "./rpc-error-BlD2vuzn.mjs";
13
- import { t as CODEX_CONTROL_METHODS } from "./capabilities-B3WEZl4e.mjs";
14
- import { o as formatCodexCliSessions } from "./node-cli-sessions-HC4W6FLI.mjs";
15
- import { a as defaultCodexAppInventoryCache, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-BL9B5H0L.mjs";
16
- import { i as resolveCodexBindingAppServerConnection } from "./binding-connection-DTtN1KrX.mjs";
17
- import { o as withCodexAppServerJsonClient } from "./request-BHZ1nz8d.mjs";
18
- import "./config-DKhXquav.mjs";
19
- import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-C0NbLms1.mjs";
20
- import { a as resolveCodexAppServerAuthProfileStore, i as resolveCodexAppServerAuthProfileIdForAgent, n as normalizeCodexAppServerBindingModelProvider } from "./auth-profile-B0okYl2D.mjs";
21
- import { F as consumeCodexAppServerLiveThread, R as hasCodexAppServerLiveThread, c as getLeasedSharedCodexAppServerClient, et as resolveCodexAppServerAuthAccountCacheKey, h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-DqyTMYug.mjs";
22
- import { b as assertCodexThreadResumeResponse, s as isCodexAppServerIndeterminateRequestCancellationError, u as isCodexAppServerPrewriteRequestCancellationError, v as assertCodexThreadAcceptsDirectInput } from "./client-N0JpgSzF.mjs";
23
- import { o as closeCodexStartupClientBestEffort } from "./attempt-client-cleanup-DOP-cW5j.mjs";
24
- import { n as fingerprintCodexAppServerAuthBinding } from "./auth-binding-BLWz7stm.mjs";
25
- import { n as listAllCodexAppServerModels } from "./models-DHXZtVVk.mjs";
26
- import { n as refreshCodexAppRuntimeState, r as refreshCodexPluginRuntimeState } from "./plugin-activation-cNHRfaxU.mjs";
27
- import { n as createCodexSessionGenerationSupersededError, o as resolveCodexSessionBinding } from "./session-binding-DGCYAfvD.mjs";
28
- import { i as assertCodexSupervisionThreadLineage } from "./thread-policy-DTd-DtkX.mjs";
29
- import { a as rollbackCodexAppServerBindingSubscription, c as withExclusiveCodexAppServerThread, i as retireCodexConversationThreadBinding, n as releaseCodexAppServerBindingSubscription, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-roNP0l1c.mjs";
30
- import { n as resolveCodexNativeSandboxBlock, t as resolveCodexNativeExecutionBlock } from "./sandbox-guard-DjCz2eOw.mjs";
31
- import { i as readCodexComputerUseStatus, r as installCodexComputerUse, t as defaultCodexPluginMetadataCache } from "./plugin-metadata-cache-DsjsL1dr.mjs";
32
- import { a as requestOptions, i as readCodexStatusProbes, o as safeCodexControlRequest, r as prepareCodexControlSessionAuth, t as codexControlRequest } from "./command-rpc-CGJGUQ6Y.mjs";
33
- import { a as setCodexConversationFastMode, c as steerCodexConversationTurn, i as readCodexConversationActiveTurn, l as stopCodexConversationTurn, n as parseCodexFastModeArg, o as setCodexConversationModel, r as parseCodexPermissionsModeArg, s as setCodexConversationPermissions, t as formatPermissionsMode } from "./conversation-control-CEP8X5JC.mjs";
6
+ import { a as canMutateCodexHost, i as assertCodexHostOwnerCurrent, n as CODEX_HOST_INSPECTION_AUTH_ERROR, o as hasCodexAdminScope, r as CODEX_NATIVE_EXECUTION_AUTH_ERROR, t as CODEX_FULL_PERMISSIONS_AUTH_ERROR } from "./command-authorization-AikPDtcc.mjs";
7
+ import { l as formatRelativeDuration, s as summarizeCodexAccountUsage } from "./rate-limits-CMPy24F5.mjs";
8
+ import { a as formatCodexAccountLine, c as formatCodexTextForDisplay, d as formatModels, f as formatSkills, i as formatAccount, l as formatComputerUseStatus, m as isLikelyEmailAddress, n as buildHelp, o as formatCodexDisplayText, p as formatThreads, r as escapeCodexChatText, s as formatCodexStatus, t as CODEX_RESUME_SAFE_THREAD_ID_PATTERN, u as formatList } from "./command-formatters-DV3DHhdr.mjs";
9
+ import { i as readCodexConversationBindingData, n as createCodexCliNodeConversationBindingData, o as resolveCodexDefaultWorkspaceDir, r as createCodexConversationBindingData } from "./conversation-binding-data-DJ4ix-W5.mjs";
10
+ import { r as CodexAppServerRpcError } from "./rpc-error-hmWM21RB.mjs";
11
+ import { t as CODEX_CONTROL_METHODS } from "./capabilities-kQntafj_.mjs";
12
+ import { n as filterCodexMarketplacePlugins, r as parseCodexPluginMarketplaceId, t as discoverCodexMarketplacePlugins } from "./plugin-marketplace-discovery-SQPhSuic.mjs";
13
+ import { o as formatCodexCliSessions } from "./node-cli-sessions-B5oNDkUS.mjs";
14
+ import { a as defaultCodexAppInventoryCache, r as buildCodexPluginAppCacheKey } from "./plugin-app-cache-key-BW8rd98k.mjs";
15
+ import { i as resolveCodexBindingAppServerConnection } from "./binding-connection-C-08ez1w.mjs";
16
+ import { a as withCodexAppServerJsonClient } from "./request-BH3FvYUE.mjs";
17
+ import { a as pluginReadParams, l as CODEX_PLUGINS_MARKETPLACE_NAME, n as isOpenAiCuratedMarketplaceName, t as findCodexMarketplacePluginSummary } from "./plugin-inventory-Bf0_piTw.mjs";
18
+ import "./config-0Gxk3_eq.mjs";
19
+ import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-cUYrqu_a.mjs";
20
+ import { a as resolveCodexAppServerAuthProfileStore, i as resolveCodexAppServerAuthProfileIdForAgent, n as normalizeCodexAppServerBindingModelProvider } from "./auth-profile-CgHQ8Vot.mjs";
21
+ import { F as consumeCodexAppServerLiveThread, R as hasCodexAppServerLiveThread, c as getLeasedSharedCodexAppServerClient, et as resolveCodexAppServerAuthAccountCacheKey, h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-DJJ3ljH2.mjs";
22
+ import { a as isCodexAppServerIndeterminateRequestCancellationError, h as assertCodexThreadResumeResponse, p as assertCodexThreadAcceptsDirectInput, s as isCodexAppServerPrewriteRequestCancellationError } from "./client-CBzEVDyb.mjs";
23
+ import { o as closeCodexStartupClientBestEffort } from "./attempt-client-cleanup-yLjGwbwT.mjs";
24
+ import { n as fingerprintCodexAppServerAuthBinding } from "./auth-binding-BoMwpuPN.mjs";
25
+ import { n as listAllCodexAppServerModels } from "./models-Du_i5G_t.mjs";
26
+ import { n as refreshCodexAppRuntimeState, r as refreshCodexPluginRuntimeState } from "./plugin-activation-BcyBv8PG.mjs";
27
+ import { o as createCodexSessionGenerationSupersededError, r as resolveCodexSessionBinding } from "./session-binding-Ce7BqiPN.mjs";
28
+ import { i as assertCodexSupervisionThreadLineage } from "./thread-policy-CXZV97TS.mjs";
29
+ import { a as rollbackCodexAppServerBindingSubscription, c as withExclusiveCodexAppServerThread, i as retireCodexConversationThreadBinding, n as releaseCodexAppServerBindingSubscription, r as retainCodexAppServerBindingSubscription, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-0aRHD9iK.mjs";
30
+ import { n as resolveCodexNativeSandboxBlock, t as resolveCodexNativeExecutionBlock } from "./sandbox-guard-WqE8yPge.mjs";
31
+ import { t as defaultCodexPluginMetadataCache } from "./plugin-metadata-cache-DWnB7VMj.mjs";
32
+ import { n as installCodexComputerUse, r as readCodexComputerUseStatus } from "./computer-use-DpolvQHw.mjs";
33
+ import { a as requestOptions, i as readCodexStatusProbes, o as safeCodexControlRequest, r as prepareCodexControlSessionAuth, t as codexControlRequest } from "./command-rpc-B6xsq2dB.mjs";
34
+ import { a as readCodexConversationActiveTurn, c as setCodexConversationModel, d as stopCodexConversationTurn, i as parseCodexPermissionsModeArg, l as setCodexConversationPermissions, n as formatPermissionsMode, r as parseCodexFastModeArg, s as setCodexConversationFastMode, u as steerCodexConversationTurn } from "./conversation-control-tCg763cI.mjs";
34
35
  import { normalizeOptionalString, normalizeUniqueStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
35
36
  import crypto from "node:crypto";
36
37
  import { isDeepStrictEqual } from "node:util";
37
38
  import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
38
39
  import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
39
40
  import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
41
+ import { isIncognitoSessionKey } from "openclaw/plugin-sdk/session-key-runtime";
40
42
  import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
41
43
  import { parseAgentSessionKey } from "openclaw/plugin-sdk/routing";
42
44
  import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
43
45
  import { ensureAuthProfileStore, resolveAgentDir as resolveAgentDir$1, resolveAgentWorkspaceDir, resolveAuthProfileEligibility, resolveProfileUnusableUntilForDisplay } from "openclaw/plugin-sdk/agent-runtime";
44
46
  import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
45
47
  import { findNormalizedProviderValue, resolveAuthProfileOrder } from "openclaw/plugin-sdk/provider-auth";
48
+ import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
46
49
  import { renderMessagePresentationFallbackText } from "openclaw/plugin-sdk/interactive-runtime";
47
50
  import { MODEL_SELECTION_LOCKED_MESSAGE, isModelSelectionLocked, resolvePersistedSessionRuntimeId } from "openclaw/plugin-sdk/model-session-runtime";
48
51
  //#region extensions/codex/src/command-account.ts
@@ -173,15 +176,13 @@ function isChatGptSubscriptionProfile(credential) {
173
176
  }
174
177
  function formatProfileKind(credential) {
175
178
  if (!credential) return "credential";
176
- if (isChatGptSubscriptionProfile(credential)) return "ChatGPT subscription";
177
- if (credential.type === "api_key") return "API key";
178
- return "credential";
179
+ return credential.type === "api_key" ? "API key" : "ChatGPT subscription";
179
180
  }
180
181
  function formatProfileLabel(profileId, credential) {
181
182
  const tail = profileId.includes(":") ? profileId.slice(profileId.indexOf(":") + 1) : profileId;
182
183
  const displayName = credential?.displayName?.trim();
183
184
  if (displayName) return credential?.type === "api_key" ? simplifyApiKeyDisplayName(displayName, tail) : displayName;
184
- const email = credential?.email?.trim() ?? extractEmailFromProfileId(profileId);
185
+ const email = credential?.email?.trim() ?? (isLikelyEmailAddress(tail) ? tail : void 0);
185
186
  if (email) return email;
186
187
  if (credential?.type === "api_key") return tail || "API key";
187
188
  return humanizeProfileTail(tail);
@@ -210,10 +211,6 @@ function splitProfileTail(tail) {
210
211
  function titleCase(value) {
211
212
  return value ? `${value[0]?.toUpperCase() ?? ""}${value.slice(1)}` : value;
212
213
  }
213
- function extractEmailFromProfileId(profileId) {
214
- const tail = profileId.includes(":") ? profileId.slice(profileId.indexOf(":") + 1) : profileId;
215
- return /^[^\s@<>()[\]`]+@[^\s@<>()[\]`]+\.[^\s@<>()[\]`]+$/.test(tail) ? tail : void 0;
216
- }
217
214
  function describeFailureStatus(reason, credential) {
218
215
  if (reason === "auth" || reason === "auth_permanent" || reason === "session_expired") return credential?.type === "api_key" ? "auth failed - check key" : "sign-in expired";
219
216
  if (reason === "billing") return "billing unavailable";
@@ -290,14 +287,11 @@ function buildCodexPluginStatusButtons(pluginId, canRefreshHostedApps) {
290
287
  }
291
288
  function safeCodexAppLink(value) {
292
289
  if (!value || value.length > 2048 || /[\s\p{Cc}\p{Cf}<>]/u.test(value)) return;
293
- try {
294
- const url = new URL(value);
295
- const host = url.hostname;
296
- const hosted = host === "chatgpt.com" || host === "chatgpt-staging.com" || host.endsWith(".chatgpt.com") || host.endsWith(".chatgpt-staging.com");
297
- return url.protocol === "https:" && !url.username && !url.password && hosted ? value : void 0;
298
- } catch {
299
- return;
300
- }
290
+ const url = URL.parse(value);
291
+ if (!url) return;
292
+ const host = url.hostname;
293
+ const hosted = host === "chatgpt.com" || host === "chatgpt-staging.com" || host.endsWith(".chatgpt.com") || host.endsWith(".chatgpt-staging.com");
294
+ return url.protocol === "https:" && !url.username && !url.password && hosted ? value : void 0;
301
295
  }
302
296
  //#endregion
303
297
  //#region extensions/codex/src/command-plugin-config.ts
@@ -997,7 +991,8 @@ function parseComputerUseArgs(args) {
997
991
  parsed.help = true;
998
992
  continue;
999
993
  }
1000
- parsed.overrides[option] = value;
994
+ parsed.overrides[option] = value.trim();
995
+ parsed.hasOverrides = true;
1001
996
  index += 1;
1002
997
  continue;
1003
998
  }
@@ -1014,19 +1009,6 @@ function parseComputerUseArgs(args) {
1014
1009
  }
1015
1010
  parsed.help = true;
1016
1011
  }
1017
- const overrides = parsed.overrides;
1018
- parsed.overrides = {};
1019
- for (const key of [
1020
- "marketplaceSource",
1021
- "marketplacePath",
1022
- "marketplaceName"
1023
- ]) {
1024
- const value = normalizeOptionalString(overrides[key]);
1025
- if (value) {
1026
- parsed.overrides[key] = value;
1027
- parsed.hasOverrides = true;
1028
- }
1029
- }
1030
1012
  return parsed;
1031
1013
  }
1032
1014
  function formatComputerUsePersistentIdentityMigration(parsed) {
@@ -1097,20 +1079,11 @@ function createCodexDiagnosticsConfirmation(params) {
1097
1079
  const token = crypto.randomBytes(6).toString("hex");
1098
1080
  scopeTokens.push(token);
1099
1081
  pendingCodexDiagnosticsConfirmationTokensByScope.set(params.scopeKey, scopeTokens);
1082
+ const { now, ...confirmation } = params;
1100
1083
  pendingCodexDiagnosticsConfirmations.set(token, {
1084
+ ...confirmation,
1101
1085
  token,
1102
- targets: params.targets,
1103
- note: params.note,
1104
- senderId: params.senderId,
1105
- channel: params.channel,
1106
- accountId: params.accountId,
1107
- channelId: params.channelId,
1108
- messageThreadId: params.messageThreadId,
1109
- threadParentId: params.threadParentId,
1110
- sessionKey: params.sessionKey,
1111
- scopeKey: params.scopeKey,
1112
- ...params.privateRouted === void 0 ? {} : { privateRouted: params.privateRouted },
1113
- createdAt: params.now
1086
+ createdAt: now
1114
1087
  });
1115
1088
  return token;
1116
1089
  }
@@ -1186,19 +1159,15 @@ function formatCodexDiagnosticsUploadResult(sent, failed) {
1186
1159
  }
1187
1160
  function formatCodexDiagnosticsTargetLines(targets) {
1188
1161
  return targets.flatMap((target, index) => {
1189
- const lines = formatCodexDiagnosticsTargetBlock(target, index);
1162
+ const lines = [`Session ${index + 1}`];
1163
+ if (target.channel) lines.push(`Channel: ${formatCodexDisplayText(target.channel)}`);
1164
+ if (target.sessionKey) lines.push(`OpenClaw session key: ${formatCodexCopyableValueForDisplay(target.sessionKey)}`);
1165
+ if (target.sessionId) lines.push(`OpenClaw session id: ${formatCodexCopyableValueForDisplay(target.sessionId)}`);
1166
+ lines.push(`Codex thread id: ${formatCodexCopyableValueForDisplay(target.threadId)}`);
1167
+ lines.push(`Inspect locally: ${formatCodexResumeCommandForDisplay(target.threadId)}`);
1190
1168
  return index < targets.length - 1 ? [...lines, ""] : lines;
1191
1169
  });
1192
1170
  }
1193
- function formatCodexDiagnosticsTargetBlock(target, index) {
1194
- const lines = [`Session ${index + 1}`];
1195
- if (target.channel) lines.push(`Channel: ${formatCodexDisplayText(target.channel)}`);
1196
- if (target.sessionKey) lines.push(`OpenClaw session key: ${formatCodexCopyableValueForDisplay(target.sessionKey)}`);
1197
- if (target.sessionId) lines.push(`OpenClaw session id: ${formatCodexCopyableValueForDisplay(target.sessionId)}`);
1198
- lines.push(`Codex thread id: ${formatCodexCopyableValueForDisplay(target.threadId)}`);
1199
- lines.push(`Inspect locally: ${formatCodexResumeCommandForDisplay(target.threadId)}`);
1200
- return lines;
1201
- }
1202
1171
  function formatCodexDiagnosticsTargetLine(target) {
1203
1172
  const parts = [];
1204
1173
  if (target.channel) parts.push(`channel ${formatCodexDisplayText(target.channel)}`);
@@ -1219,7 +1188,7 @@ function readCodexDiagnosticsTargetsCooldownMessage(targets, ctx, now, options =
1219
1188
  if (scopeCooldownMs > 0) return `Codex diagnostics were already sent for this account or channel recently. Try again in ${Math.ceil(scopeCooldownMs / 1e3)}s.`;
1220
1189
  }
1221
1190
  function recordCodexDiagnosticsUpload(threadId, ctx, now, cooldownScope) {
1222
- pruneCodexDiagnosticsCooldowns(now);
1191
+ for (const map of [lastCodexDiagnosticsUploadByThread, lastCodexDiagnosticsUploadByScope]) for (const [key, lastSentAt] of map) if (now - lastSentAt >= CODEX_DIAGNOSTICS_COOLDOWN_MS) map.delete(key);
1223
1192
  recordBoundedCodexDiagnosticsCooldown(lastCodexDiagnosticsUploadByScope, cooldownScope ?? readCodexDiagnosticsCooldownScope(ctx), CODEX_DIAGNOSTICS_COOLDOWN_MAX_SCOPES, now);
1224
1193
  recordBoundedCodexDiagnosticsCooldown(lastCodexDiagnosticsUploadByThread, threadId, CODEX_DIAGNOSTICS_COOLDOWN_MAX_THREADS, now);
1225
1194
  }
@@ -1256,20 +1225,9 @@ function readCodexDiagnosticsCooldownMs(map, key, now) {
1256
1225
  return remainingMs;
1257
1226
  }
1258
1227
  function recordBoundedCodexDiagnosticsCooldown(map, key, maxSize, now) {
1259
- if (!map.has(key)) while (map.size >= maxSize) {
1260
- const oldestKey = map.keys().next().value;
1261
- if (typeof oldestKey !== "string") break;
1262
- map.delete(oldestKey);
1263
- }
1228
+ if (!map.has(key)) pruneMapToMaxSize(map, maxSize - 1);
1264
1229
  map.set(key, now);
1265
1230
  }
1266
- function pruneCodexDiagnosticsCooldowns(now) {
1267
- pruneCodexDiagnosticsCooldownMap(lastCodexDiagnosticsUploadByThread, now);
1268
- pruneCodexDiagnosticsCooldownMap(lastCodexDiagnosticsUploadByScope, now);
1269
- }
1270
- function pruneCodexDiagnosticsCooldownMap(map, now) {
1271
- for (const [key, lastSentAt] of map) if (now - lastSentAt >= CODEX_DIAGNOSTICS_COOLDOWN_MS) map.delete(key);
1272
- }
1273
1231
  function formatCodexErrorForDisplay(error) {
1274
1232
  const safe = truncateUtf16Safe(formatCodexTextForDisplay(error), CODEX_DIAGNOSTICS_ERROR_MAX_CHARS);
1275
1233
  return escapeCodexChatText(safe) || "unknown error";
@@ -1358,7 +1316,7 @@ async function resolvePreparedCodexCommandAuthority(deps, ctx) {
1358
1316
  config: ctx.config,
1359
1317
  storePath
1360
1318
  }) : void 0;
1361
- const assertHostCurrent = currentSession?.assertCurrent ?? (() => {});
1319
+ const assertHostCurrent = currentSession?.authority.assertLegacyCurrent ?? (() => {});
1362
1320
  const binding = (target && (!sessionIdentity || !isDeepStrictEqual(target.identity, sessionIdentity)) ? await resolveCodexSessionBinding({
1363
1321
  bindingStore: deps.bindingStore,
1364
1322
  identity: target.identity,
@@ -1454,13 +1412,13 @@ async function handleCodexDiagnosticsFeedback(deps, context, pluginConfig, args,
1454
1412
  if (parsed.action === "usage") return { text: formatDiagnosticsUsage(commandPrefix) };
1455
1413
  if (parsed.action === "confirm") return { text: await confirmCodexDiagnosticsFeedback(deps, ctx, pluginConfig, parsed.token) };
1456
1414
  if (parsed.action === "cancel") return { text: cancelCodexDiagnosticsFeedback(ctx, parsed.token) };
1457
- if (ctx.diagnosticsUploadApproved === true) return { text: await sendCodexDiagnosticsFeedbackForContext(deps, ctx, pluginConfig, parsed.note) };
1458
- if (ctx.diagnosticsPreviewOnly === true) return { text: await previewCodexDiagnosticsFeedbackApproval(deps, ctx, parsed.note) };
1459
- return await requestCodexDiagnosticsFeedbackApproval(deps, ctx, parsed.note, commandPrefix);
1460
- }
1461
- async function requestCodexDiagnosticsFeedbackApproval(deps, ctx, note, commandPrefix) {
1462
1415
  const targets = await requireCodexDiagnosticsTargets(deps, ctx);
1463
1416
  if (typeof targets === "string") return { text: targets };
1417
+ if (ctx.diagnosticsUploadApproved === true) return { text: await sendCodexDiagnosticsFeedbackForTargets(deps, ctx, pluginConfig, parsed.note, targets) };
1418
+ if (ctx.diagnosticsPreviewOnly === true) return { text: previewCodexDiagnosticsFeedbackApproval(targets, ctx, parsed.note) };
1419
+ return requestCodexDiagnosticsFeedbackApproval(targets, ctx, parsed.note, commandPrefix);
1420
+ }
1421
+ function requestCodexDiagnosticsFeedbackApproval(targets, ctx, note, commandPrefix) {
1464
1422
  const now = Date.now();
1465
1423
  const cooldownMessage = readCodexDiagnosticsTargetsCooldownMessage(targets, ctx, now);
1466
1424
  if (cooldownMessage) return { text: cooldownMessage };
@@ -1513,9 +1471,7 @@ async function requestCodexDiagnosticsFeedbackApproval(deps, ctx, note, commandP
1513
1471
  }] }
1514
1472
  };
1515
1473
  }
1516
- async function previewCodexDiagnosticsFeedbackApproval(deps, ctx, note) {
1517
- const targets = await requireCodexDiagnosticsTargets(deps, ctx);
1518
- if (typeof targets === "string") return targets;
1474
+ function previewCodexDiagnosticsFeedbackApproval(targets, ctx, note) {
1519
1475
  const cooldownMessage = readCodexDiagnosticsTargetsCooldownMessage(targets, ctx, Date.now(), { includeThreadId: false });
1520
1476
  if (cooldownMessage) return cooldownMessage;
1521
1477
  const reason = normalizeDiagnosticsReason(note);
@@ -1534,7 +1490,7 @@ async function confirmCodexDiagnosticsFeedback(deps, ctx, pluginConfig, token) {
1534
1490
  if (!pending.privateRouted && !await hasAnyCodexDiagnosticsIdentity(ctx)) return "Cannot send Codex diagnostics because this command did not include a stable session identity.";
1535
1491
  const currentTargets = pending.privateRouted ? resolvePendingCodexDiagnosticsTargets(deps, pending.targets, ctx.config) : await resolveCodexDiagnosticsTargets(deps, ctx);
1536
1492
  if (!codexDiagnosticsTargetsMatch(pending.targets, currentTargets)) return "The Codex diagnostics sessions changed before confirmation. Run /diagnostics again for the current threads.";
1537
- return await sendCodexDiagnosticsFeedbackForTargets(deps, ctx, pluginConfig, pending.note ?? "", currentTargets, { cooldownScope: pending.scopeKey });
1493
+ return await sendCodexDiagnosticsFeedbackForTargets(deps, ctx, pluginConfig, pending.note ?? "", currentTargets, pending.scopeKey);
1538
1494
  }
1539
1495
  function cancelCodexDiagnosticsFeedback(ctx, token) {
1540
1496
  const pending = consumeCodexDiagnosticsConfirmation(ctx, token, "cancel");
@@ -1545,15 +1501,10 @@ function cancelCodexDiagnosticsFeedback(ctx, token) {
1545
1501
  ...formatCodexDiagnosticsTargetLines(pending.targets)
1546
1502
  ].join("\n");
1547
1503
  }
1548
- async function sendCodexDiagnosticsFeedbackForContext(deps, ctx, pluginConfig, note) {
1549
- const targets = await requireCodexDiagnosticsTargets(deps, ctx);
1550
- if (typeof targets === "string") return targets;
1551
- return await sendCodexDiagnosticsFeedbackForTargets(deps, ctx, pluginConfig, note, targets);
1552
- }
1553
- async function sendCodexDiagnosticsFeedbackForTargets(deps, ctx, pluginConfig, note, targets, options = {}) {
1504
+ async function sendCodexDiagnosticsFeedbackForTargets(deps, ctx, pluginConfig, note, targets, cooldownScope) {
1554
1505
  if (targets.length === 0) return NO_DIAGNOSTICS_THREAD;
1555
1506
  const now = Date.now();
1556
- const cooldownMessage = readCodexDiagnosticsTargetsCooldownMessage(targets, ctx, now, { cooldownScope: options.cooldownScope });
1507
+ const cooldownMessage = readCodexDiagnosticsTargetsCooldownMessage(targets, ctx, now, { cooldownScope });
1557
1508
  if (cooldownMessage) return cooldownMessage;
1558
1509
  const reason = normalizeDiagnosticsReason(note);
1559
1510
  const sent = [];
@@ -1608,7 +1559,7 @@ async function sendCodexDiagnosticsFeedbackForTargets(deps, ctx, pluginConfig, n
1608
1559
  ...target,
1609
1560
  threadId: responseThreadId ?? target.threadId
1610
1561
  });
1611
- recordCodexDiagnosticsUpload(target.threadId, ctx, now, options.cooldownScope);
1562
+ recordCodexDiagnosticsUpload(target.threadId, ctx, now, cooldownScope);
1612
1563
  }
1613
1564
  return formatCodexDiagnosticsUploadResult(sent, failed);
1614
1565
  }
@@ -1891,13 +1842,14 @@ async function resumeThread(deps, ctx, pluginConfig, args) {
1891
1842
  agentId: scope.agentId,
1892
1843
  config: ctx.config
1893
1844
  });
1894
- const { assertCurrent: assertHostGeneration } = await resolveCodexSessionBinding({
1845
+ const { authority } = await resolveCodexSessionBinding({
1895
1846
  reclaimStale: true,
1896
1847
  bindingStore: deps.bindingStore,
1897
1848
  identity,
1898
1849
  config: ctx.config,
1899
1850
  storePath: ctx.sessionTarget?.storePath
1900
1851
  });
1852
+ const assertHostGeneration = authority.assertLegacyCurrent;
1901
1853
  return await withExclusiveCodexAppServerThread({
1902
1854
  bindingStore: deps.bindingStore,
1903
1855
  identity,
@@ -2055,9 +2007,7 @@ const CODEX_NATIVE_CONTROL_SUBCOMMANDS = /* @__PURE__ */ new Set([
2055
2007
  "stop"
2056
2008
  ]);
2057
2009
  function resolveCodexNativeCommandSandboxBlock(ctx, subcommand, args) {
2058
- if (isReadOnlyCodexGoalCommand(subcommand, args)) return;
2059
- if (!CODEX_NATIVE_EXECUTION_SUBCOMMANDS.has(subcommand)) return;
2060
- if (returnsBeforeNativeCodexExecution(subcommand, args)) return;
2010
+ if (isReadOnlyCodexGoalCommand(subcommand, args) || !CODEX_NATIVE_EXECUTION_SUBCOMMANDS.has(subcommand) || returnsBeforeNativeCodexExecution(subcommand, args)) return;
2061
2011
  if (isCodexCliNodeResumeBind(subcommand, args)) return resolveCodexNativeSandboxBlock({
2062
2012
  config: ctx.config,
2063
2013
  sessionKey: ctx.sessionKey,
@@ -2100,10 +2050,8 @@ function isCodexCliNodeResumeBind(subcommand, args) {
2100
2050
  }
2101
2051
  function returnsBeforeNativeCodexResume(args) {
2102
2052
  const parsed = parseResumeArgs([...args]);
2103
- const normalizedThreadId = parsed.threadId?.trim();
2104
- if (parsed.help) return true;
2105
- if (parsed.host) return !normalizedThreadId || parsed.bindHere !== true;
2106
- return !normalizedThreadId || args.length !== 1;
2053
+ if (parsed.help || !parsed.threadId) return true;
2054
+ return parsed.host ? parsed.bindHere !== true : args.length !== 1;
2107
2055
  }
2108
2056
  async function handleComputerUseCommand(deps, ctx, pluginConfig, args) {
2109
2057
  const parsed = parseComputerUseArgs(args);
@@ -2188,28 +2136,21 @@ function formatNativeGoal(response) {
2188
2136
  `- Tokens: ${tokensUsed}${tokenBudget === void 0 ? "" : ` / ${tokenBudget}`}`
2189
2137
  ].join("\n");
2190
2138
  }
2191
- async function stopConversationTurn(deps, ctx) {
2192
- const authority = await resolvePreparedCodexCommandAuthority(deps, ctx);
2193
- const { target, binding } = authority;
2194
- if (!target) return "Cannot stop Codex because this command did not include a stable binding identity.";
2195
- return (await deps.stopCodexConversationTurn({
2196
- identity: target.identity,
2197
- binding,
2198
- assertCurrent: authority.assertMutationCurrent
2199
- })).message;
2200
- }
2201
- async function steerConversationTurn(deps, ctx, message) {
2139
+ async function controlConversationTurn(deps, ctx, command, message) {
2202
2140
  const authority = await resolvePreparedCodexCommandAuthority(deps, ctx);
2203
2141
  const { target, binding } = authority;
2204
- if (!target) return "Cannot steer Codex because this command did not include a stable binding identity.";
2205
- return (await deps.steerCodexConversationTurn({
2142
+ if (!target) return `Cannot ${command} Codex because this command did not include a stable binding identity.`;
2143
+ const params = {
2206
2144
  identity: target.identity,
2207
2145
  binding,
2208
- message,
2209
2146
  assertCurrent: authority.assertMutationCurrent
2147
+ };
2148
+ return (command === "stop" ? await deps.stopCodexConversationTurn(params) : await deps.steerCodexConversationTurn({
2149
+ ...params,
2150
+ message
2210
2151
  })).message;
2211
2152
  }
2212
- async function setConversationModel(deps, ctx, pluginConfig, args) {
2153
+ async function setConversationModel(deps, ctx, args) {
2213
2154
  if (args.length > 1) return "Usage: /codex model <model>";
2214
2155
  const [model = ""] = args;
2215
2156
  const normalized = model.trim();
@@ -2232,7 +2173,6 @@ async function setConversationModel(deps, ctx, pluginConfig, args) {
2232
2173
  return await deps.setCodexConversationModel({
2233
2174
  identity: target.identity,
2234
2175
  bindingStore: deps.bindingStore,
2235
- pluginConfig,
2236
2176
  model: normalized,
2237
2177
  agentDir: target.agentDir,
2238
2178
  config: ctx.config,
@@ -2417,7 +2357,7 @@ async function handleCodexPluginsSubcommand(input, rest, io, runtime) {
2417
2357
  if (normalized === "list") {
2418
2358
  if (args.length > 0) return { text: "Usage: /codex plugins list" };
2419
2359
  const current = await io.readConfig();
2420
- return { text: formatPluginList(current.plugins ?? {}, { globalEnabled: current.enabled === true }) };
2360
+ return { text: formatPluginList(current.plugins ?? {}, current.enabled === true) };
2421
2361
  }
2422
2362
  if (normalized === "available") {
2423
2363
  if (!canMutateCodexHost(ctx)) return { text: "Only an owner or operator.admin gateway client can list available Codex plugins." };
@@ -2724,8 +2664,7 @@ async function installCodexPlugin(requestedId, io, runtime, ctx) {
2724
2664
  const status = alreadyInstalled ? "bundle was already installed in Codex" : "bundle was installed in Codex";
2725
2665
  return { text: `${formatCodexDisplayText(requestedId)} ${status}. OpenClaw app access is configured.${refreshWarning} ${POLICY_REFRESH_HINT}` };
2726
2666
  }
2727
- function formatPluginList(plugins, options = {}) {
2728
- const globalEnabled = options.globalEnabled === true;
2667
+ function formatPluginList(plugins, globalEnabled) {
2729
2668
  const keys = Object.keys(plugins).toSorted();
2730
2669
  if (keys.length === 0) return "No Codex sub-plugins configured under plugins.entries.codex.config.codexPlugins.plugins";
2731
2670
  const rows = keys.map((key) => {
@@ -3004,9 +2943,8 @@ async function handleCodexSubcommand(ctx, options) {
3004
2943
  if (normalized === "bind") return await bindConversation(deps, ctx, options.pluginConfig, rest);
3005
2944
  if (normalized === "detach" || normalized === "unbind") return { text: await detachConversation(deps, ctx) };
3006
2945
  if (normalized === "binding") return { text: await describeConversationBinding(deps, ctx) };
3007
- if (normalized === "stop") return { text: await stopConversationTurn(deps, ctx) };
3008
- if (normalized === "steer") return { text: await steerConversationTurn(deps, ctx, rest.join(" ")) };
3009
- if (normalized === "model") return { text: await setConversationModel(deps, ctx, options.pluginConfig, rest) };
2946
+ if (normalized === "stop" || normalized === "steer") return { text: await controlConversationTurn(deps, ctx, normalized, rest.join(" ")) };
2947
+ if (normalized === "model") return { text: await setConversationModel(deps, ctx, rest) };
3010
2948
  if (normalized === "fast") {
3011
2949
  if (isMenuVerb(rest)) return buildCodexFastMenuReply();
3012
2950
  return { text: await setConversationFastMode(deps, ctx, rest) };