@openclaw/codex 2026.9.8 → 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-G348lY1q.mjs → account-usage-runtime-C4GFoef_.mjs} +5 -5
  3. package/dist/.setup/app-server-policy-Bg4FZw1f.mjs +23 -0
  4. package/dist/.setup/{apply-Cqb-YoCS.mjs → apply-D02fLpgN.mjs} +48 -39
  5. package/dist/.setup/attempt-client-cleanup-yLjGwbwT.mjs +155 -0
  6. package/dist/.setup/{attempt-workspace-context-BJ5Z_olH.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-Dnps4W4_.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-BNunZPtz.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-DIQ5O_-S.mjs → build-state-CIi3Ckqu.mjs} +1 -1
  16. package/dist/.setup/{capabilities-B3WEZl4e.mjs → capabilities-kQntafj_.mjs} +1 -1
  17. package/dist/.setup/{client-qyUBJlGZ.mjs → client-CBzEVDyb.mjs} +438 -160
  18. package/dist/.setup/{client-catalog-response-DRvx_wCC.mjs → client-catalog-response-CmvIiDdj.mjs} +57 -25
  19. package/dist/.setup/command-authorization-AikPDtcc.mjs +15 -0
  20. package/dist/.setup/{command-dispatch-Btrs1D6f.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-DvlCHJch.mjs → command-handlers-DNoRq5Ps.mjs} +82 -144
  23. package/dist/.setup/{command-rpc-skzRq4wD.mjs → command-rpc-B6xsq2dB.mjs} +23 -31
  24. package/dist/.setup/{compact-8ttks5U5.mjs → compact-BLSAd-ru.mjs} +117 -65
  25. package/dist/.setup/{plugin-metadata-cache-BRwtRct9.mjs → computer-use-DpolvQHw.mjs} +65 -202
  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-74LaGGH-.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-OrN6zuaY.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-Db2sY5cZ.mjs → dynamic-tools-DdsymYGQ.mjs} +238 -878
  40. package/dist/.setup/{effective-mcp-catalog-Bi6-SQ7i.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-DiCS1ijR.mjs → ephemeral-turn-oPKxs3ia.mjs} +2 -2
  43. package/dist/.setup/{event-projector-assistant-message-MV_1dj-3.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-D80IXfQF.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-DiC0Tkha.mjs → model-catalog-Dj_uvusa.mjs} +7 -7
  52. package/dist/.setup/{models-DfLmPV0k.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-BwkQXf9e.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-DPdMk1Oy.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-D6F_7p1I.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-BZOfsSXW.mjs → request-BH3FvYUE.mjs} +189 -49
  73. package/dist/.setup/rpc-error-hmWM21RB.mjs +57 -0
  74. package/dist/.setup/{run-attempt-dYJhjZrp.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-BMCFMZw-.mjs → session-catalog-events-KIXOoSnQ.mjs} +5 -5
  88. package/dist/.setup/{session-catalog-index-DwJjnF5k.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-CuaFZuQE.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-CGfzfP93.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-DlmBHYIe.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-LlYWBKTJ.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-DW9W3gza.mjs → settled-turn-finalizer-CDxCejjC.mjs} +8 -8
  109. package/dist/.setup/{shared-client-CJCTeFpQ.mjs → shared-client-DJJ3ljH2.mjs} +291 -272
  110. package/dist/.setup/{provider-capabilities-DG5qbsUZ.mjs → shell-dynamic-tools-Do9lIAT1.mjs} +16 -55
  111. package/dist/.setup/{side-question-BLeGj7TQ.mjs → side-question-B7T0_GEC.mjs} +99 -91
  112. package/dist/.setup/{source-CJis_1EF.mjs → source-DH70LqN0.mjs} +24 -40
  113. package/dist/.setup/{thread-lifecycle-_bAbjedG.mjs → thread-lifecycle-DkcoX9q-.mjs} +262 -305
  114. package/dist/.setup/{thread-ownership-B6pPt21M.mjs → thread-ownership-0aRHD9iK.mjs} +10 -8
  115. package/dist/.setup/{thread-policy-gNPzzpVp.mjs → thread-policy-CXZV97TS.mjs} +22 -21
  116. package/dist/.setup/{thread-requests-OWGOiDaV.mjs → thread-requests-COrRJcZb.mjs} +107 -98
  117. package/dist/.setup/{thread-resume-GOry0AYh.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-B-S7ngS_.mjs → turn-router-CX1-EoCp.mjs} +75 -170
  123. package/dist/.setup/{upstream-session-fork-gkdRj2yH.mjs → upstream-session-fork-LYlaQnbt.mjs} +35 -46
  124. package/dist/.setup/{usage-CApUvLOV.mjs → usage-Dmx7B0W2.mjs} +4 -4
  125. package/dist/.setup/{usage-limit-error-wSMQkbpV.mjs → usage-limit-error-M8jVnITZ.mjs} +4 -4
  126. package/dist/.setup/{web-search-provider.runtime-UKgeiBUG.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-BFafIiF6.mjs +0 -2599
  150. package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +0 -170
  151. package/dist/.setup/shared-client-lifecycle-7xgtlo15.mjs +0 -153
@@ -0,0 +1,109 @@
1
+ import { pt as resolveCodexGatewayTimeoutWithGraceMs } from "./shared-client-DJJ3ljH2.mjs";
2
+ import { isApprovalNotFoundError, toErrorObject } from "openclaw/plugin-sdk/error-runtime";
3
+ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
4
+ import { racePromiseWithAbortSignal } from "openclaw/plugin-sdk/time-runtime";
5
+ //#region extensions/codex/src/app-server/plugin-approval-roundtrip.ts
6
+ const DEFAULT_CODEX_APPROVAL_TIMEOUT_MS = 12e4;
7
+ const MAX_PLUGIN_APPROVAL_TITLE_LENGTH = 80;
8
+ const MAX_PLUGIN_APPROVAL_DESCRIPTION_LENGTH = 512;
9
+ const ANSI_OSC_SEQUENCE_RE = new RegExp(String.raw`(?:\u001b]|\u009d)[^\u001b\u009c\u0007]*(?:\u0007|\u001b\\|\u009c)`, "g");
10
+ const ANSI_CONTROL_SEQUENCE_RE = new RegExp(String.raw`(?:\u001b\[[0-?]*[ -/]*[@-~]|\u009b[0-?]*[ -/]*[@-~]|\u001b[@-Z\\-_])`, "g");
11
+ const CONTROL_CHARACTER_RE = new RegExp(String.raw`[\u0000-\u001f\u007f-\u009f]+`, "g");
12
+ const INVISIBLE_FORMATTING_CONTROL_RE = new RegExp(String.raw`[\u00ad\u034f\u061c\u200b-\u200f\u202a-\u202e\u2060-\u206f\ufeff\ufe00-\ufe0f\u{e0100}-\u{e01ef}]`, "gu");
13
+ const DANGLING_TERMINAL_SEQUENCE_SUFFIX_RE = new RegExp(String.raw`(?:\u001b\][^\u001b\u009c\u0007]*|\u009d[^\u001b\u009c\u0007]*|\u001b\[[0-?]*[ -/]*|\u009b[0-?]*[ -/]*|\u001b)$`);
14
+ const CODEX_APPROVAL_TIMEOUT_SUBJECTS = {
15
+ command: "Command approval",
16
+ "file-change": "File change approval",
17
+ permissions: "Permission approval",
18
+ other: "Approval"
19
+ };
20
+ function codexApprovalTimeoutText(kind) {
21
+ return `${CODEX_APPROVAL_TIMEOUT_SUBJECTS[kind]} timed out before an operator responded.`;
22
+ }
23
+ /** Starts a two-phase plugin approval request through the OpenClaw gateway. */
24
+ async function requestPluginApproval(params) {
25
+ const timeoutMs = DEFAULT_CODEX_APPROVAL_TIMEOUT_MS;
26
+ return params.hostCapabilities.requestApproval({
27
+ signal: params.signal,
28
+ title: truncateCodexApprovalDisplayText(params.title, MAX_PLUGIN_APPROVAL_TITLE_LENGTH),
29
+ description: truncateCodexApprovalDisplayText(params.description, MAX_PLUGIN_APPROVAL_DESCRIPTION_LENGTH),
30
+ severity: params.severity,
31
+ toolName: params.toolName,
32
+ toolCallId: params.toolCallId,
33
+ ...params.mcpTool ? {
34
+ mcpTool: params.mcpTool,
35
+ isMcpToolApprovalActive: params.isMcpToolApprovalActive
36
+ } : {},
37
+ timeoutMs,
38
+ transportTimeoutMs: resolveCodexGatewayTimeoutWithGraceMs(timeoutMs),
39
+ ...params.allowedDecisions ? { allowedDecisions: params.allowedDecisions } : {}
40
+ });
41
+ }
42
+ /** Detects the gateway's explicit null-decision marker for unavailable approvals. */
43
+ function approvalRequestExplicitlyUnavailable(result) {
44
+ if (result === null || result === void 0 || typeof result !== "object") return false;
45
+ let descriptor;
46
+ try {
47
+ descriptor = Object.getOwnPropertyDescriptor(result, "decision");
48
+ } catch {
49
+ return false;
50
+ }
51
+ return descriptor !== void 0 && "value" in descriptor && descriptor.value === null;
52
+ }
53
+ /** Waits for the gateway's final approval decision, respecting turn aborts. */
54
+ async function waitForPluginApprovalDecision(params) {
55
+ const timeoutMs = DEFAULT_CODEX_APPROVAL_TIMEOUT_MS;
56
+ const waitPromise = params.hostCapabilities.waitForApproval({
57
+ approvalId: params.approvalId,
58
+ timeoutMs,
59
+ transportTimeoutMs: resolveCodexGatewayTimeoutWithGraceMs(timeoutMs),
60
+ signal: params.signal
61
+ }).catch((error) => {
62
+ if (isApprovalNotFoundError(error)) return;
63
+ throw error;
64
+ });
65
+ return await racePromiseWithAbortSignal(waitPromise, params.signal, ({ reason }) => toErrorObject(reason, "Non-Error rejection"));
66
+ }
67
+ /** Converts a gateway exec approval decision into the app-server approval outcome enum. */
68
+ function mapExecDecisionToOutcome(decision) {
69
+ switch (decision) {
70
+ case "allow-once": return "approved-once";
71
+ case "allow-always": return "approved-session";
72
+ case "deny": return "denied";
73
+ default: return "unavailable";
74
+ }
75
+ }
76
+ /** Runs one complete host approval request and maps transport failures to a closed outcome. */
77
+ async function requestPluginApprovalOutcome(params) {
78
+ try {
79
+ const requestResult = await requestPluginApproval({
80
+ ...params,
81
+ severity: "warning"
82
+ });
83
+ const approvalId = requestResult?.id;
84
+ if (!approvalId) return "unavailable";
85
+ const approvalResult = approvalRequestExplicitlyUnavailable(requestResult) ? void 0 : await waitForPluginApprovalDecision({
86
+ hostCapabilities: params.hostCapabilities,
87
+ approvalId,
88
+ signal: params.signal
89
+ });
90
+ if (params.signal?.aborted) return "cancelled";
91
+ if (approvalResult?.terminalReason === "timeout") return "timed-out";
92
+ const decision = approvalResult?.decision;
93
+ return mapExecDecisionToOutcome(decision === "allow-always" && params.allowedDecisions?.includes("allow-always") === false ? "allow-once" : decision);
94
+ } catch {
95
+ return params.signal?.aborted ? "cancelled" : "denied";
96
+ }
97
+ }
98
+ function truncateCodexApprovalDisplayText(value, maxLength) {
99
+ return value.length <= maxLength ? value : `${truncateUtf16Safe(value, maxLength - 3)}...`;
100
+ }
101
+ function stripDanglingCodexApprovalTerminalSequence(value) {
102
+ return value.replace(DANGLING_TERMINAL_SEQUENCE_SUFFIX_RE, "");
103
+ }
104
+ function sanitizeCodexApprovalVisibleText(value, options = {}) {
105
+ const terminalSafe = value.replace(ANSI_OSC_SEQUENCE_RE, "").replace(ANSI_CONTROL_SEQUENCE_RE, "");
106
+ return (options.stripDanglingTerminalSequence ? stripDanglingCodexApprovalTerminalSequence(terminalSafe) : terminalSafe).replace(INVISIBLE_FORMATTING_CONTROL_RE, " ").replace(CONTROL_CHARACTER_RE, " ").replace(/\s+/g, " ").trim();
107
+ }
108
+ //#endregion
109
+ export { requestPluginApprovalOutcome as a, truncateCodexApprovalDisplayText as c, requestPluginApproval as i, waitForPluginApprovalDecision as l, codexApprovalTimeoutText as n, sanitizeCodexApprovalVisibleText as o, mapExecDecisionToOutcome as r, stripDanglingCodexApprovalTerminalSequence as s, approvalRequestExplicitlyUnavailable as t };
@@ -1,6 +1,6 @@
1
- import { f as resolveCodexPluginsPolicy } from "./config-parsing-b088LyhT.mjs";
2
- import { c as findCodexAppById } from "./plugin-app-cache-key-BL9B5H0L.mjs";
3
- import "./config-DKhXquav.mjs";
1
+ import { f as resolveCodexPluginsPolicy } from "./config-parsing-BQq-CHTF.mjs";
2
+ import { c as findCodexAppById } from "./plugin-app-cache-key-BW8rd98k.mjs";
3
+ import "./config-0Gxk3_eq.mjs";
4
4
  import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
5
5
  //#region extensions/codex/src/app-server/config-contracts.ts
6
6
  const CODEX_PLUGINS_MARKETPLACE_NAME = "openai-curated";
@@ -40,14 +40,13 @@ async function readCodexPluginInventory(params) {
40
40
  let listed = installedPlugins;
41
41
  let resolvedPlugin = findConfiguredMarketplacePlugin(listed, pluginPolicy);
42
42
  if (!resolvedPlugin && pluginPolicy.enabled && pluginPolicy.marketplaceName !== "workspace-directory") {
43
- const requestParams = buildPluginCatalogRequestParams(params, pluginPolicy.marketplaceName);
44
- const catalogKey = JSON.stringify([requestParams, pluginMetadataCatalogScope(pluginPolicy.marketplaceName)]);
43
+ const catalogKey = pluginMetadataCatalogScope(pluginPolicy.marketplaceName);
45
44
  let catalog = pluginCatalogs.get(catalogKey);
46
45
  if (!catalog) {
47
- catalog = listCodexPluginMetadata(params, pluginPolicy.marketplaceName);
46
+ catalog = await listCodexPluginMetadata(params, pluginPolicy.marketplaceName);
48
47
  pluginCatalogs.set(catalogKey, catalog);
49
48
  }
50
- listed = await catalog;
49
+ listed = catalog;
51
50
  resolvedPlugin = findConfiguredMarketplacePlugin(listed, pluginPolicy);
52
51
  }
53
52
  if (!listed.marketplaces.some((marketplace) => marketplaceMatchesConfiguredName(marketplace, pluginPolicy.marketplaceName))) {
@@ -77,12 +76,8 @@ async function readCodexPluginInventory(params) {
77
76
  if (!summary.installed) continue;
78
77
  }
79
78
  const detail = await readPluginDetail(params, marketplaceRef(resolvedPlugin.marketplace, pluginPolicy.marketplaceName), pluginPolicy, summary, diagnostics);
80
- const ownedAppIds = detail?.apps.map((app) => app.id).filter(Boolean).toSorted() ?? [];
81
- const appOwnership = resolveAppOwnership({
82
- detail,
83
- appInventory,
84
- summary
85
- });
79
+ const ownedAppIds = detail?.apps.map((app) => app.id).filter(Boolean) ?? [];
80
+ const appOwnership = detail?.apps.length ? "proven" : appInventory?.snapshot?.apps.some((app) => app.pluginDisplayNames.includes(summary.name)) ? "ambiguous" : "none";
86
81
  if (appOwnership === "ambiguous") diagnostics.push({
87
82
  code: "app_ownership_ambiguous",
88
83
  plugin: pluginPolicy,
@@ -145,10 +140,8 @@ function pluginReadParams(marketplace, pluginName) {
145
140
  }
146
141
  function resolveRecoverableCodexPluginConfigKeys(params) {
147
142
  return params.policy.pluginPolicies.filter((pluginPolicy) => pluginPolicy.enabled && !isSettledMissingPluginPolicy({
148
- pluginPolicy,
149
- metadataCache: params.metadataCache,
150
- appCacheKey: params.appCacheKey,
151
- configCwd: params.configCwd
143
+ ...params,
144
+ pluginPolicy
152
145
  })).map((pluginPolicy) => pluginPolicy.configKey).toSorted();
153
146
  }
154
147
  async function listCodexPluginMetadata(params, marketplaceName, options = {}) {
@@ -208,7 +201,6 @@ function readCachedAppInventory(params) {
208
201
  });
209
202
  }
210
203
  async function readPluginDetail(params, marketplace, pluginPolicy, summary, diagnostics) {
211
- if (params.readPluginDetails === false) return;
212
204
  if (marketplace.remoteMarketplaceName && !summary.remotePluginId) {
213
205
  diagnostics.push({
214
206
  code: "plugin_detail_unavailable",
@@ -228,10 +220,6 @@ async function readPluginDetail(params, marketplace, pluginPolicy, summary, diag
228
220
  return;
229
221
  }
230
222
  }
231
- function resolveAppOwnership(params) {
232
- if (params.detail && params.detail.apps.length > 0) return "proven";
233
- return (params.appInventory?.snapshot?.apps ?? []).some((app) => app.pluginDisplayNames.includes(params.summary.name)) ? "ambiguous" : "none";
234
- }
235
223
  function resolveOwnedApps(params) {
236
224
  const detailApps = params.detail?.apps ?? [];
237
225
  if (detailApps.length === 0) return [];
@@ -271,20 +259,15 @@ function toCodexPluginOwnedAccountApp(app, installedApp) {
271
259
  function resolveOwnedAppApprovalOverrideKeys(app) {
272
260
  if (!app.toolSummaries) return {};
273
261
  const appName = app.name.trim();
274
- const appNameLower = appName.toLowerCase();
275
- const keys = app.toolSummaries.filter((tool) => !tool.isReadOnly).flatMap((tool) => resolveAppToolConfigKeys({
276
- appName,
277
- appNameLower,
278
- tool
279
- }));
280
- return { approvalOverrideToolConfigKeys: Array.from(new Set(keys)).toSorted() };
281
- }
282
- function resolveAppToolConfigKeys(params) {
283
- const keys = [params.tool.name];
284
- if (params.tool.title) keys.push(params.tool.title);
285
- if (params.appName) keys.push(`${params.appName}_${params.tool.name}`);
286
- if (params.appNameLower && params.appNameLower !== params.appName) keys.push(`${params.appNameLower}_${params.tool.name}`);
287
- return keys;
262
+ const prefixes = [.../* @__PURE__ */ new Set([appName, appName.toLowerCase()])].filter(Boolean);
263
+ const keys = /* @__PURE__ */ new Set();
264
+ for (const tool of app.toolSummaries) {
265
+ if (tool.isReadOnly) continue;
266
+ keys.add(tool.name);
267
+ if (tool.title) keys.add(tool.title);
268
+ for (const prefix of prefixes) keys.add(`${prefix}_${tool.name}`);
269
+ }
270
+ return { approvalOverrideToolConfigKeys: Array.from(keys).toSorted() };
288
271
  }
289
272
  function findPluginSummary(marketplace, pluginName) {
290
273
  const exact = marketplace.plugins.find((plugin) => plugin.id === pluginName || plugin.id === `${pluginName}@${marketplace.name}`);
@@ -293,7 +276,14 @@ function findPluginSummary(marketplace, pluginName) {
293
276
  return matches.length === 1 ? matches[0] : void 0;
294
277
  }
295
278
  function findConfiguredMarketplacePlugin(listed, plugin) {
296
- if (plugin.marketplaceName === "workspace-directory") return findWorkspaceMarketplacePlugin(listed, plugin.pluginName);
279
+ if (plugin.marketplaceName === "workspace-directory") {
280
+ const marketplace = listed.marketplaces.find((entry) => entry.name === CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME);
281
+ const summary = marketplace?.plugins.find((entry) => entry.id === plugin.pluginName);
282
+ return marketplace && summary ? {
283
+ marketplace,
284
+ summary
285
+ } : void 0;
286
+ }
297
287
  for (const marketplace of listed.marketplaces) {
298
288
  if (!marketplaceMatchesConfiguredName(marketplace, plugin.marketplaceName)) continue;
299
289
  const summary = findPluginSummary(marketplace, plugin.pluginName);
@@ -304,15 +294,7 @@ function findConfiguredMarketplacePlugin(listed, plugin) {
304
294
  }
305
295
  }
306
296
  function marketplaceMatchesConfiguredName(marketplace, configuredMarketplaceName) {
307
- return isOpenAiCuratedMarketplaceName(configuredMarketplaceName) ? isOpenAiCuratedMarketplace(marketplace) : marketplace.name === configuredMarketplaceName;
308
- }
309
- function findWorkspaceMarketplacePlugin(listed, pluginName) {
310
- const marketplace = listed.marketplaces.find((entry) => entry.name === CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME);
311
- const summary = marketplace?.plugins.find((plugin) => plugin.id === pluginName);
312
- return marketplace && summary ? {
313
- marketplace,
314
- summary
315
- } : void 0;
297
+ return isOpenAiCuratedMarketplaceName(configuredMarketplaceName) ? isOpenAiCuratedMarketplaceName(marketplace.name) : marketplace.name === configuredMarketplaceName;
316
298
  }
317
299
  function pluginNameFromPluginId(pluginId, marketplaceName) {
318
300
  const trimmed = pluginId.trim();
@@ -327,12 +309,8 @@ function marketplaceRef(marketplace, name) {
327
309
  ...!marketplace.path ? { remoteMarketplaceName: marketplace.name } : {}
328
310
  };
329
311
  }
330
- /** True for any supported OpenAI curated marketplace wire name, matching Codex's own curated predicate. */
331
- function isOpenAiCuratedMarketplace(marketplace) {
332
- return isOpenAiCuratedMarketplaceName(marketplace.name);
333
- }
334
312
  function isOpenAiCuratedMarketplaceName(marketplaceName) {
335
313
  return marketplaceName === "openai-curated" || marketplaceName === CODEX_PLUGINS_REMOTE_MARKETPLACE_NAME || marketplaceName === CODEX_PLUGINS_API_MARKETPLACE_NAME;
336
314
  }
337
315
  //#endregion
338
- export { marketplaceRef as a, resolveRecoverableCodexPluginConfigKeys as c, CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME as d, listCodexPluginMetadata as i, toCodexPluginOwnedAccountApp as l, isOpenAiCuratedMarketplace as n, pluginReadParams as o, isOpenAiCuratedMarketplaceName as r, readCodexPluginInventory as s, findCodexMarketplacePluginSummary as t, CODEX_PLUGINS_MARKETPLACE_NAME as u };
316
+ export { pluginReadParams as a, toCodexPluginOwnedAccountApp as c, marketplaceRef as i, CODEX_PLUGINS_MARKETPLACE_NAME as l, isOpenAiCuratedMarketplaceName as n, readCodexPluginInventory as o, listCodexPluginMetadata as r, resolveRecoverableCodexPluginConfigKeys as s, findCodexMarketplacePluginSummary as t, CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME as u };
@@ -1,19 +1,5 @@
1
- import { d as CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN } from "./config-utils-D0CXecki.mjs";
1
+ import { n as CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN } from "./service-tier-normalization-Cei89SW6.mjs";
2
2
  import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
- //#region extensions/codex/src/command-authorization.ts
4
- const CODEX_NATIVE_EXECUTION_AUTH_ERROR = "Only an owner or operator.admin can control Codex native execution.";
5
- const CODEX_HOST_INSPECTION_AUTH_ERROR = "Only an owner or operator.admin can inspect Codex host state.";
6
- 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.";
7
- function hasCodexAdminScope(ctx) {
8
- return ctx.gatewayClientScopes?.includes("operator.admin") === true;
9
- }
10
- function canMutateCodexHost(ctx) {
11
- return ctx.senderIsOwner === true || hasCodexAdminScope(ctx);
12
- }
13
- function assertCodexHostOwnerCurrent(ctx) {
14
- if (!hasCodexAdminScope(ctx)) ctx.assertOwnerCurrent?.();
15
- }
16
- //#endregion
17
3
  //#region extensions/codex/src/plugin-marketplace-discovery.ts
18
4
  /** Read-only discovery of Codex-owned local, curated, and remote plugin marketplaces. */
19
5
  const PLUGIN_NAME_PATTERN = /^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$/;
@@ -131,4 +117,4 @@ function boundedCatalogText(value) {
131
117
  return value.replace(/\p{Cc}/gu, " ").replace(/\s+/g, " ").trim().slice(0, MAX_PLUGIN_METADATA_LENGTH);
132
118
  }
133
119
  //#endregion
134
- export { CODEX_HOST_INSPECTION_AUTH_ERROR as a, canMutateCodexHost as c, CODEX_FULL_PERMISSIONS_AUTH_ERROR as i, hasCodexAdminScope as l, filterCodexMarketplacePlugins as n, CODEX_NATIVE_EXECUTION_AUTH_ERROR as o, parseCodexPluginMarketplaceId as r, assertCodexHostOwnerCurrent as s, discoverCodexMarketplacePlugins as t };
120
+ export { filterCodexMarketplacePlugins as n, parseCodexPluginMarketplaceId as r, discoverCodexMarketplacePlugins as t };
@@ -0,0 +1,84 @@
1
+ //#region extensions/codex/src/app-server/plugin-metadata-cache.ts
2
+ const CODEX_PLUGIN_METADATA_CACHE_TTL_MS = 36e5;
3
+ var CodexPluginMetadataCache = class {
4
+ constructor(nowMs = Date.now) {
5
+ this.nowMs = nowMs;
6
+ this.entries = /* @__PURE__ */ new Map();
7
+ this.inFlight = /* @__PURE__ */ new Map();
8
+ this.generations = /* @__PURE__ */ new Map();
9
+ this.clearGeneration = 0;
10
+ }
11
+ read(appCacheKey, queryKind, requestParams, catalogScope) {
12
+ const entryKey = buildMetadataCacheEntryKey(appCacheKey, queryKind, requestParams, catalogScope);
13
+ const entry = this.entries.get(entryKey);
14
+ if (!entry) return;
15
+ if (entry.expiresAtMs <= this.nowMs()) {
16
+ this.entries.delete(entryKey);
17
+ return;
18
+ }
19
+ return entry.snapshot;
20
+ }
21
+ /** Returns a fresh snapshot or coalesces one catalog or installed-plugin request. */
22
+ async load(params) {
23
+ const entryKey = buildMetadataCacheEntryKey(params.appCacheKey, params.queryKind, params.requestParams, params.catalogScope);
24
+ const cached = this.read(params.appCacheKey, params.queryKind, params.requestParams, params.catalogScope);
25
+ if (cached) return cached;
26
+ const pending = this.inFlight.get(entryKey);
27
+ if (pending) try {
28
+ return await pending.promise;
29
+ } catch {
30
+ if (this.inFlight.get(entryKey) === pending) this.inFlight.delete(entryKey);
31
+ return await this.load(params);
32
+ }
33
+ const generation = this.generations.get(params.appCacheKey) ?? 0;
34
+ const clearGeneration = this.clearGeneration;
35
+ const promise = (async () => {
36
+ const method = params.queryKind === "installed" ? "plugin/installed" : "plugin/list";
37
+ const response = await params.request(method, params.requestParams);
38
+ const snapshot = {
39
+ appCacheKey: params.appCacheKey,
40
+ queryKind: params.queryKind,
41
+ response
42
+ };
43
+ if (generation === (this.generations.get(params.appCacheKey) ?? 0) && clearGeneration === this.clearGeneration && response.marketplaceLoadErrors.length === 0 && (params.cacheable?.(response) ?? true)) this.entries.set(entryKey, {
44
+ snapshot,
45
+ expiresAtMs: this.nowMs() + CODEX_PLUGIN_METADATA_CACHE_TTL_MS
46
+ });
47
+ return snapshot;
48
+ })();
49
+ this.inFlight.set(entryKey, {
50
+ appCacheKey: params.appCacheKey,
51
+ promise
52
+ });
53
+ try {
54
+ return await promise;
55
+ } finally {
56
+ if (this.inFlight.get(entryKey)?.promise === promise) this.inFlight.delete(entryKey);
57
+ }
58
+ }
59
+ invalidate(appCacheKey) {
60
+ this.generations.set(appCacheKey, (this.generations.get(appCacheKey) ?? 0) + 1);
61
+ for (const [entryKey, entry] of this.entries) if (entry.snapshot.appCacheKey === appCacheKey) this.entries.delete(entryKey);
62
+ for (const [entryKey, pending] of this.inFlight) if (pending.appCacheKey === appCacheKey) this.inFlight.delete(entryKey);
63
+ }
64
+ /** Clears snapshots and prevents late in-flight loads from repopulating them. */
65
+ clear() {
66
+ this.clearGeneration += 1;
67
+ this.generations.clear();
68
+ this.entries.clear();
69
+ this.inFlight.clear();
70
+ }
71
+ };
72
+ const defaultCodexPluginMetadataCache = new CodexPluginMetadataCache();
73
+ function buildMetadataCacheEntryKey(appCacheKey, queryKind, requestParams, catalogScope) {
74
+ const names = queryKind === "installed" ? requestParams?.installSuggestionPluginNames : requestParams?.marketplaceKinds;
75
+ return JSON.stringify([
76
+ appCacheKey,
77
+ queryKind,
78
+ requestParams?.cwds ?? [],
79
+ Array.from(new Set(names ?? [])).toSorted(),
80
+ ...queryKind !== "installed" && catalogScope ? [catalogScope] : []
81
+ ]);
82
+ }
83
+ //#endregion
84
+ export { defaultCodexPluginMetadataCache as t };
@@ -0,0 +1,124 @@
1
+ import { f as resolveCodexPluginsPolicy } from "./config-parsing-BQq-CHTF.mjs";
2
+ import { r as withAbortableTimeout } from "./timeout-CXOfNoaX.mjs";
3
+ import { a as defaultCodexAppInventoryCache } from "./plugin-app-cache-key-BW8rd98k.mjs";
4
+ import { s as resolveRecoverableCodexPluginConfigKeys } from "./plugin-inventory-Bf0_piTw.mjs";
5
+ import "./config-0Gxk3_eq.mjs";
6
+ import { Tt as shouldBuildCodexPluginThreadConfig, gt as buildCodexPluginThreadConfig, vt as buildCodexPluginThreadConfigTimeoutFallback } from "./thread-requests-COrRJcZb.mjs";
7
+ import { m as readCurrentCodexScheduledAppPolicy, p as intersectCodexPluginThreadConfigWithScheduledAuthority } from "./thread-lifecycle-DkcoX9q-.mjs";
8
+ import { n as disableCodexPluginThreadConfig } from "./dynamic-tool-build-CVrx02cH.mjs";
9
+ import { t as defaultCodexPluginMetadataCache } from "./plugin-metadata-cache-DWnB7VMj.mjs";
10
+ import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-runtime";
11
+ //#region extensions/codex/src/app-server/plugin-thread-config-deadline.ts
12
+ /** Enforces one bounded startup budget across Codex plugin config discovery. */
13
+ const CODEX_PLUGIN_THREAD_CONFIG_MAX_TIMEOUT_MS = 6e4;
14
+ const CODEX_PLUGIN_THREAD_CONFIG_TIMEOUT_DIVISOR = 4;
15
+ const CODEX_PLUGIN_THREAD_CONFIG_MIN_TIMEOUT_MS = 100;
16
+ var CodexPluginThreadConfigDeadlineError = class extends Error {
17
+ constructor() {
18
+ super("Codex plugin thread config deadline elapsed");
19
+ this.name = "CodexPluginThreadConfigDeadlineError";
20
+ }
21
+ };
22
+ /** Resolves the plugin policy state reused throughout app-server startup. */
23
+ function resolveCodexPluginThreadConfigStartupPolicy(params) {
24
+ const pluginThreadConfigRequired = params.hostedAppsSupported === false || Boolean(params.scheduledRuntimeAuthority) || !params.nativeToolSurfaceEnabled || shouldBuildCodexPluginThreadConfig(params.pluginConfig);
25
+ const pluginThreadConfigPluginConfig = params.hostedAppsSupported !== false && (params.nativeToolSurfaceEnabled || params.scheduledRuntimeAuthority) ? params.pluginConfig : disableCodexPluginThreadConfig(params.pluginConfig);
26
+ const resolvedPluginPolicy = pluginThreadConfigRequired ? resolveCodexPluginsPolicy(pluginThreadConfigPluginConfig) : void 0;
27
+ return {
28
+ pluginThreadConfigRequired,
29
+ pluginThreadConfigPluginConfig,
30
+ resolvedPluginPolicy,
31
+ enabledPluginConfigKeys: resolvedPluginPolicy ? resolvedPluginPolicy.pluginPolicies.filter((plugin) => plugin.enabled).map((plugin) => plugin.configKey).toSorted() : void 0
32
+ };
33
+ }
34
+ /** Builds plugin config without allowing sequential RPC timeouts to consume the turn. */
35
+ async function buildCodexPluginThreadConfigWithinDeadline(params) {
36
+ const { requestTimeoutMs, signal, request, failClosedOnTimeout, transform, ...buildParams } = params;
37
+ signal.throwIfAborted();
38
+ const timeoutMs = resolveCodexPluginThreadConfigTimeoutMs(requestTimeoutMs);
39
+ const deadlineMs = performance.now() + timeoutMs;
40
+ let requestTimedOut = false;
41
+ const boundedRequest = async (method, requestParams) => {
42
+ const remainingTimeoutMs = deadlineMs - performance.now();
43
+ if (requestTimedOut || remainingTimeoutMs <= 0) throw new CodexPluginThreadConfigDeadlineError();
44
+ try {
45
+ return await request(method, requestParams, {
46
+ timeoutMs: remainingTimeoutMs,
47
+ signal
48
+ });
49
+ } catch (error) {
50
+ requestTimedOut ||= isCodexPluginThreadConfigTimeoutError(error);
51
+ throw error;
52
+ }
53
+ };
54
+ try {
55
+ return await withAbortableTimeout({
56
+ signal,
57
+ timeoutMs,
58
+ promise: (async () => {
59
+ const config = await buildCodexPluginThreadConfig({
60
+ ...buildParams,
61
+ request: boundedRequest
62
+ });
63
+ const result = transform ? await transform(config, boundedRequest) : config;
64
+ if (requestTimedOut || performance.now() >= deadlineMs) throw new CodexPluginThreadConfigDeadlineError();
65
+ return result;
66
+ })(),
67
+ timeoutMessage: "Codex plugin thread config deadline elapsed",
68
+ createTimeoutError: () => new CodexPluginThreadConfigDeadlineError()
69
+ });
70
+ } catch (error) {
71
+ if (signal.aborted || !requestTimedOut && !isCodexPluginThreadConfigTimeoutError(error) && performance.now() < deadlineMs) throw error;
72
+ if (failClosedOnTimeout) throw new AgentHarnessPreflightError(`Codex app policy verification exceeded its ${timeoutMs} ms startup budget. No app tools were executed. Retry after Codex app inventory is responsive.`);
73
+ return buildCodexPluginThreadConfigTimeoutFallback({
74
+ pluginConfig: buildParams.pluginConfig,
75
+ appCacheKey: buildParams.appCacheKey,
76
+ message: `Codex plugin discovery exceeded its ${timeoutMs} ms startup budget; plugin apps were disabled for this turn.`
77
+ });
78
+ }
79
+ }
80
+ /** Creates the recovery metadata and bounded builder used by thread startup. */
81
+ function createCodexPluginThreadConfigStartupProvider(params) {
82
+ const { client, policy, inputFingerprint, enabledPluginConfigKeys, appCache, metadataCache: configuredMetadataCache, ...buildParams } = params;
83
+ const metadataCache = configuredMetadataCache ?? defaultCodexPluginMetadataCache;
84
+ return {
85
+ enabled: true,
86
+ requiresCurrentPolicyCheck: Boolean(policy?.enabled || params.scheduledRuntimeAuthority),
87
+ inputFingerprint,
88
+ enabledPluginConfigKeys,
89
+ accountAppRecoveryEnabled: policy?.allowAllPlugins,
90
+ recoverablePluginConfigKeys: policy ? resolveRecoverableCodexPluginConfigKeys({
91
+ policy,
92
+ metadataCache,
93
+ appCacheKey: params.appCacheKey,
94
+ configCwd: params.configCwd
95
+ }) : void 0,
96
+ build: async (buildOptions) => {
97
+ const config = await buildCodexPluginThreadConfigWithinDeadline({
98
+ ...buildParams,
99
+ threadId: buildOptions?.threadId,
100
+ appCache: appCache ?? defaultCodexAppInventoryCache,
101
+ metadataCache,
102
+ failClosedOnTimeout: Boolean(params.scheduledRuntimeAuthority),
103
+ transform: params.scheduledRuntimeAuthority ? async (builtConfig, request) => intersectCodexPluginThreadConfigWithScheduledAuthority(builtConfig, params.scheduledRuntimeAuthority, await readCurrentCodexScheduledAppPolicy({
104
+ request,
105
+ configCwd: params.configCwd,
106
+ threadId: buildOptions?.threadId
107
+ })) : void 0,
108
+ request: (method, requestParams, options) => client.request(method, requestParams, options)
109
+ });
110
+ return params.scheduledRuntimeAuthority && params.inputFingerprint ? {
111
+ ...config,
112
+ inputFingerprint: params.inputFingerprint
113
+ } : config;
114
+ }
115
+ };
116
+ }
117
+ function resolveCodexPluginThreadConfigTimeoutMs(requestTimeoutMs) {
118
+ return Math.min(CODEX_PLUGIN_THREAD_CONFIG_MAX_TIMEOUT_MS, Math.max(CODEX_PLUGIN_THREAD_CONFIG_MIN_TIMEOUT_MS, Math.floor((Number.isFinite(requestTimeoutMs) && requestTimeoutMs > 0 ? requestTimeoutMs : CODEX_PLUGIN_THREAD_CONFIG_MAX_TIMEOUT_MS * CODEX_PLUGIN_THREAD_CONFIG_TIMEOUT_DIVISOR) / CODEX_PLUGIN_THREAD_CONFIG_TIMEOUT_DIVISOR)));
119
+ }
120
+ function isCodexPluginThreadConfigTimeoutError(error) {
121
+ return error instanceof CodexPluginThreadConfigDeadlineError || error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED" && error.message.endsWith(" timed out");
122
+ }
123
+ //#endregion
124
+ export { resolveCodexPluginThreadConfigStartupPolicy as n, createCodexPluginThreadConfigStartupProvider as t };
@@ -11,7 +11,7 @@ function buildCodexMigrationProvider(params = {}) {
11
11
  ].join(" "),
12
12
  supportedItemKinds: ["memory", "auth"],
13
13
  async detect(ctx) {
14
- const { discoverCodexSource, hasCodexSource } = await import("./source-CJis_1EF.mjs").then((n) => n.a);
14
+ const { discoverCodexSource, hasCodexSource } = await import("./source-DH70LqN0.mjs").then((n) => n.a);
15
15
  const memoryOnly = isOnlyMigrationKind(ctx, "memory");
16
16
  const authOnly = isOnlyMigrationKind(ctx, "auth");
17
17
  const source = await discoverCodexSource({
@@ -29,16 +29,16 @@ function buildCodexMigrationProvider(params = {}) {
29
29
  };
30
30
  },
31
31
  async plan(ctx) {
32
- const { buildCodexMigrationPlan } = await import("./plan-DPdMk1Oy.mjs");
32
+ const { buildCodexMigrationPlan } = await import("./plan-CUHSIOep.mjs");
33
33
  return buildCodexMigrationPlan(ctx);
34
34
  },
35
35
  deferredApply: { retrySafe: true },
36
36
  prepareApply(ctx) {
37
37
  if (isOnlyMigrationKind(ctx, "memory") || isOnlyMigrationKind(ctx, "auth")) return;
38
- return import("./apply-Cqb-YoCS.mjs").then(({ prepareTargetCodexAppServer }) => prepareTargetCodexAppServer(ctx));
38
+ return import("./apply-D02fLpgN.mjs").then(({ prepareTargetCodexAppServer }) => prepareTargetCodexAppServer(ctx));
39
39
  },
40
40
  async apply(ctx, plan) {
41
- const { applyCodexMigrationPlan } = await import("./apply-Cqb-YoCS.mjs");
41
+ const { applyCodexMigrationPlan } = await import("./apply-D02fLpgN.mjs");
42
42
  return await applyCodexMigrationPlan({
43
43
  ctx,
44
44
  plan,
@@ -0,0 +1,50 @@
1
+ import { h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-DJJ3ljH2.mjs";
2
+ //#region extensions/codex/src/app-server/provider-capabilities.ts
3
+ function resolveOverriddenProviderWebSearchSupport(modelProviderOverride) {
4
+ const provider = modelProviderOverride?.trim().toLowerCase();
5
+ if (!provider) return;
6
+ return provider === "openai" ? "supported" : "unsupported";
7
+ }
8
+ async function resolveCodexProviderWebSearchSupportForClient(params) {
9
+ const overrideSupport = resolveOverriddenProviderWebSearchSupport(params.modelProviderOverride);
10
+ if (overrideSupport) return overrideSupport;
11
+ try {
12
+ const options = {
13
+ timeoutMs: params.timeoutMs,
14
+ signal: params.signal
15
+ };
16
+ if (params.expectedNativeModelProvider) {
17
+ if (((await params.client.request("config/read", { includeLayers: false }, options)).config.model_provider ?? "openai") !== params.expectedNativeModelProvider) return "unknown";
18
+ }
19
+ return (await params.client.request("modelProvider/capabilities/read", {}, options)).webSearch ? "supported" : "unsupported";
20
+ } catch {
21
+ return "unknown";
22
+ }
23
+ }
24
+ async function resolveCodexProviderWebSearchSupport(params) {
25
+ const overrideSupport = resolveOverriddenProviderWebSearchSupport(params.modelProviderOverride);
26
+ if (overrideSupport) return overrideSupport;
27
+ let client;
28
+ try {
29
+ client = await params.clientFactory({
30
+ startOptions: params.appServer.start,
31
+ ...params.preparedAuth ? { preparedAuth: params.preparedAuth } : { authProfileId: params.authProfileId },
32
+ agentDir: params.agentDir,
33
+ config: params.config,
34
+ timeoutMs: params.appServer.requestTimeoutMs
35
+ });
36
+ return await resolveCodexProviderWebSearchSupportForClient({
37
+ client,
38
+ timeoutMs: params.appServer.requestTimeoutMs,
39
+ modelProviderOverride: params.modelProviderOverride,
40
+ expectedNativeModelProvider: params.expectedNativeModelProvider,
41
+ signal: params.signal
42
+ });
43
+ } catch {
44
+ return "unknown";
45
+ } finally {
46
+ if (client) releaseLeasedSharedCodexAppServerClient(client);
47
+ }
48
+ }
49
+ //#endregion
50
+ export { resolveCodexProviderWebSearchSupportForClient as n, resolveCodexProviderWebSearchSupport as t };
@@ -222,7 +222,6 @@ function buildCodexAppServerUsageSnapshot(value, options = {}) {
222
222
  }
223
223
  function selectNextRateLimitReset(value, nowMs) {
224
224
  const futureWindows = collectCodexRateLimitSnapshots(value).flatMap((snapshot) => LIMIT_WINDOW_KEYS.flatMap((key) => snapshot[key] ?? [])).filter((window) => window.resetsAtMs > nowMs);
225
- if (futureWindows.length === 0) return;
226
225
  const exhaustedWindows = futureWindows.filter((window) => window.usedPercent !== void 0 && window.usedPercent >= 100);
227
226
  return (exhaustedWindows.length > 0 ? exhaustedWindows : futureWindows).toSorted((left, right) => left.resetsAtMs - right.resetsAtMs)[0];
228
227
  }
@@ -334,10 +333,7 @@ function selectBlockingWindowEntry(entries, nowMs) {
334
333
  const futureEntries = entries.filter((entry) => entry.window.resetsAtMs > nowMs);
335
334
  const exhaustedFutureEntries = futureEntries.filter((entry) => entry.window.usedPercent !== void 0 && entry.window.usedPercent >= 100);
336
335
  const resetCandidates = exhaustedFutureEntries.length > 0 ? exhaustedFutureEntries : futureEntries;
337
- if (resetCandidates.length > 0) {
338
- const resetSort = exhaustedFutureEntries.length > 0 ? (left, right) => right.window.resetsAtMs - left.window.resetsAtMs : (left, right) => left.window.resetsAtMs - right.window.resetsAtMs;
339
- return resetCandidates.toSorted(resetSort)[0];
340
- }
336
+ if (resetCandidates.length > 0) return resetCandidates.toSorted((left, right) => exhaustedFutureEntries.length > 0 ? right.window.resetsAtMs - left.window.resetsAtMs : left.window.resetsAtMs - right.window.resetsAtMs)[0];
341
337
  return entries.filter((entry) => entry.window.usedPercent !== void 0 && entry.window.usedPercent >= 100).toSorted((left, right) => (right.window.windowDurationMins ?? 0) - (left.window.windowDurationMins ?? 0))[0];
342
338
  }
343
339
  function readWindowEntries(snapshot) {