@openclaw/codex 2026.9.8 → 2026.10.1-beta.2
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.
- package/README.md +8 -0
- package/dist/.setup/{account-usage-runtime-G348lY1q.mjs → account-usage-runtime-DGqFpAud.mjs} +5 -5
- package/dist/.setup/app-server-policy-Bg4FZw1f.mjs +23 -0
- package/dist/.setup/{apply-Cqb-YoCS.mjs → apply-CXTudl9p.mjs} +48 -39
- package/dist/.setup/attempt-client-cleanup-BH0hW2xU.mjs +155 -0
- package/dist/.setup/{attempt-workspace-context-BJ5Z_olH.mjs → attempt-workspace-context-BY0jprWJ.mjs} +11 -15
- package/dist/.setup/{auth-binding-BLWz7stm.mjs → auth-binding-BoMwpuPN.mjs} +17 -25
- package/dist/.setup/{auth-cache-key-Dnps4W4_.mjs → auth-cache-key-CGm0UJOr.mjs} +244 -82
- package/dist/.setup/{auth-profile-B0okYl2D.mjs → auth-profile-CgHQ8Vot.mjs} +2 -1
- package/dist/.setup/{auth-profile-selection-DFu9e167.mjs → auth-profile-selection-hr8ocLtz.mjs} +5 -7
- package/dist/.setup/{binding-connection-DTtN1KrX.mjs → binding-connection-C-08ez1w.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-6TpgD1M6.mjs → binding-connection.runtime-Dn2p-fdy.mjs} +3 -3
- package/dist/.setup/{bounded-turn-isolation-B8K_ylqk.mjs → bounded-turn-isolation-DklXNk3k.mjs} +4 -4
- package/dist/.setup/{bounded-turn-BNunZPtz.mjs → bounded-turn-pGsfXcmH.mjs} +14 -13
- package/dist/.setup/{build-state-DIQ5O_-S.mjs → build-state-CqQnsg7T.mjs} +1 -1
- package/dist/.setup/{capabilities-B3WEZl4e.mjs → capabilities-kQntafj_.mjs} +1 -1
- package/dist/.setup/{client-qyUBJlGZ.mjs → client-C8lgBOoO.mjs} +438 -160
- package/dist/.setup/{client-catalog-response-DRvx_wCC.mjs → client-catalog-response-Bqp7WG51.mjs} +57 -25
- package/dist/.setup/command-authorization-AikPDtcc.mjs +15 -0
- package/dist/.setup/{command-dispatch-Btrs1D6f.mjs → command-dispatch-DhBbFIQ5.mjs} +3 -3
- package/dist/.setup/{command-formatters-R3ckE3Co.mjs → command-formatters-DV3DHhdr.mjs} +7 -5
- package/dist/.setup/{command-handlers-DvlCHJch.mjs → command-handlers-ztOOzm6O.mjs} +82 -144
- package/dist/.setup/{command-rpc-skzRq4wD.mjs → command-rpc-CuC5fPom.mjs} +23 -31
- package/dist/.setup/{compact-8ttks5U5.mjs → compact-tUb9AYfH.mjs} +117 -65
- package/dist/.setup/{plugin-metadata-cache-BRwtRct9.mjs → computer-use-BBN9y326.mjs} +65 -202
- package/dist/.setup/{config-DKhXquav.mjs → config-0Gxk3_eq.mjs} +5 -6
- package/dist/.setup/{config-options-CzyWLTJt.mjs → config-options-HG_Rr3W_.mjs} +13 -23
- package/dist/.setup/{config-parsing-b088LyhT.mjs → config-parsing-BQq-CHTF.mjs} +41 -4
- package/dist/.setup/{config-runtime-C0NbLms1.mjs → config-runtime-cUYrqu_a.mjs} +2 -2
- package/dist/.setup/{config-security-CE-FcGw9.mjs → config-security-KAPScztc.mjs} +20 -36
- package/dist/.setup/{context-engine-projection-PezSESth.mjs → context-engine-projection-CsgYSQhW.mjs} +11 -14
- package/dist/.setup/{conversation-binding-74LaGGH-.mjs → conversation-binding-B3MNMVzb.mjs} +36 -48
- package/dist/.setup/{conversation-binding-data-C746z5Pn.mjs → conversation-binding-data-DJ4ix-W5.mjs} +1 -1
- package/dist/.setup/{conversation-control-OrN6zuaY.mjs → conversation-control-CYsMlCuE.mjs} +19 -21
- package/dist/.setup/{cyber-failover-XV0nNRZu.mjs → cyber-failover-Bb1J6hS1.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-RNpGpTyP.mjs → cyber-failover-notice-XR03ef31.mjs} +1 -1
- package/dist/.setup/doctor-start-options-DPW9JxIE.mjs +63 -0
- package/dist/.setup/dynamic-tool-build-C8xGEXmR.mjs +463 -0
- package/dist/.setup/{dynamic-tools-Db2sY5cZ.mjs → dynamic-tools-DyERJnR6.mjs} +238 -878
- package/dist/.setup/{effective-mcp-catalog-Bi6-SQ7i.mjs → effective-mcp-catalog-C26Mio5l.mjs} +83 -11
- package/dist/.setup/{elicitation-input-DPoK8F7w.mjs → elicitation-input-r9axtppm.mjs} +4 -2
- package/dist/.setup/{ephemeral-turn-DiCS1ijR.mjs → ephemeral-turn-D8VcDTNo.mjs} +2 -2
- package/dist/.setup/{event-projector-assistant-message-MV_1dj-3.mjs → event-projector-assistant-message-BN7CNUB5.mjs} +2 -2
- package/dist/.setup/{event-projector-values-DJSz8BTk.mjs → event-projector-values-DTqZHizf.mjs} +2 -12
- package/dist/.setup/{inference-dispatch-CMZtjQyz.mjs → inference-dispatch-B5UKEUyC.mjs} +12 -21
- package/dist/.setup/{inference-proxy-DhcXOgUE.mjs → inference-proxy-DUO5E2QQ.mjs} +6 -5
- package/dist/.setup/{isolated-completion-D80IXfQF.mjs → isolated-completion-C0jrcplS.mjs} +8 -8
- package/dist/.setup/{managed-binary-kiWRhNRE.mjs → managed-binary-C1VFoVPf.mjs} +31 -38
- package/dist/.setup/mcp-app-session-preparation-BxN0_CYe.mjs +223 -0
- package/dist/.setup/mcp-tool-metadata-j10HhfTC.mjs +43 -0
- package/dist/.setup/{model-catalog-DiC0Tkha.mjs → model-catalog-DZyNeDKG.mjs} +7 -7
- package/dist/.setup/{models-DfLmPV0k.mjs → models-DSseKSMg.mjs} +10 -7
- package/dist/.setup/{native-auth-CuG53tu4.mjs → native-auth-Cjb9y7IZ.mjs} +5 -6
- package/dist/.setup/{native-execution-policy-BxZJy5mP.mjs → native-execution-policy-ClzpdG3D.mjs} +1 -12
- package/dist/.setup/native-mcp-app-CqcPVmhH.mjs +310 -0
- package/dist/.setup/{native-subagent-monitor-BwkQXf9e.mjs → native-subagent-monitor-BUYOUp9X.mjs} +235 -318
- package/dist/.setup/{native-subagent-pending-assignments-DwkCzLvD.mjs → native-subagent-pending-assignments-BDqhOdJp.mjs} +0 -4
- package/dist/.setup/{native-task-assignments-DMQ0g3hu.mjs → native-task-assignments-C6KVqiN1.mjs} +9 -8
- package/dist/.setup/{node-cli-sessions-HC4W6FLI.mjs → node-cli-sessions-B5oNDkUS.mjs} +11 -17
- package/dist/.setup/{node-exec-server.runtime-BgBfWQqo.mjs → node-exec-server.runtime-0xSEjKYt.mjs} +2 -2
- package/dist/.setup/{plan-DPdMk1Oy.mjs → plan-BJ37d2Og.mjs} +67 -89
- package/dist/.setup/{plugin-activation-cNHRfaxU.mjs → plugin-activation-BcyBv8PG.mjs} +4 -4
- package/dist/.setup/{plugin-app-cache-key-BL9B5H0L.mjs → plugin-app-cache-key-BW8rd98k.mjs} +11 -15
- package/dist/.setup/plugin-approval-roundtrip-CuahdPLC.mjs +109 -0
- package/dist/.setup/{plugin-inventory-Cky2XJUw.mjs → plugin-inventory-Bf0_piTw.mjs} +29 -51
- package/dist/.setup/{plugin-marketplace-discovery-D_dV9FXa.mjs → plugin-marketplace-discovery-SQPhSuic.mjs} +2 -16
- package/dist/.setup/plugin-metadata-cache-DWnB7VMj.mjs +84 -0
- package/dist/.setup/plugin-thread-config-deadline-B8LGaZNW.mjs +124 -0
- package/dist/.setup/{provider-D6F_7p1I.mjs → provider-BnwHVD_z.mjs} +4 -4
- package/dist/.setup/provider-capabilities-D68Whix6.mjs +50 -0
- package/dist/.setup/{rate-limits-B7-X2TgG.mjs → rate-limits-CMPy24F5.mjs} +1 -5
- package/dist/.setup/{request-BZOfsSXW.mjs → request-jSbhc1sg.mjs} +189 -49
- package/dist/.setup/rpc-error-hmWM21RB.mjs +57 -0
- package/dist/.setup/{run-attempt-dYJhjZrp.mjs → run-attempt-BLDZeYLD.mjs} +553 -727
- package/dist/.setup/{run-attempt-lifecycle-C-6O3Exn.mjs → run-attempt-lifecycle-BuZgVbDA.mjs} +19 -3
- package/dist/.setup/{runtime-artifact-DDQ-HGXf.mjs → runtime-artifact-CUTOOnKw.mjs} +5 -6
- package/dist/.setup/{runtime-artifact-connection-D68qQn1m.mjs → runtime-artifact-connection-CADz3_BY.mjs} +5 -4
- package/dist/.setup/{sandbox-guard-DjCz2eOw.mjs → sandbox-guard-WqE8yPge.mjs} +3 -3
- package/dist/.setup/service-tier-normalization-Cei89SW6.mjs +15 -0
- package/dist/.setup/{session-binding-DGCYAfvD.mjs → session-binding-Ce7BqiPN.mjs} +92 -102
- package/dist/.setup/session-binding-meta-Lkm5Lpf4.mjs +15 -0
- package/dist/.setup/session-binding-record-BZB8RgcF.mjs +179 -0
- package/dist/.setup/session-binding-record-codec-z4ZpDn6E.mjs +216 -0
- package/dist/.setup/{session-binding-sidecars-jo6H8dFr.mjs → session-binding-sidecars-BrdV95Fg.mjs} +8 -2
- package/dist/.setup/{session-catalog-adoption-BU_pHWG7.mjs → session-catalog-adoption-CPIP4S_y.mjs} +34 -18
- package/dist/.setup/{session-catalog-archive-spHfihri.mjs → session-catalog-archive-DcgwvSbF.mjs} +24 -29
- package/dist/.setup/{session-catalog-events-BMCFMZw-.mjs → session-catalog-events-Bdjw9HEn.mjs} +5 -5
- package/dist/.setup/{session-catalog-index-DwJjnF5k.mjs → session-catalog-index-DufISKJ6.mjs} +361 -72
- package/dist/.setup/{session-catalog-index-order-BcQpHks3.mjs → session-catalog-index-order-nhyO0wdW.mjs} +1 -1
- package/dist/.setup/{session-catalog-limits-DDxOsQeC.mjs → session-catalog-limits-DEU36Qlo.mjs} +1 -1
- package/dist/.setup/{session-catalog-index-state-TeO7EyO-.mjs → session-catalog-list-request-tXephOB4.mjs} +180 -6
- package/dist/.setup/{session-catalog-native-projection-CuaFZuQE.mjs → session-catalog-native-projection-D6IiLtMb.mjs} +7 -6
- package/dist/.setup/{session-catalog-node-adoption-DgXvSGu0.mjs → session-catalog-node-adoption-7-WEQTB1.mjs} +12 -2
- package/dist/.setup/{session-catalog-node-continue-DjKXHBbi.mjs → session-catalog-node-continue-DLWBwAAO.mjs} +11 -15
- package/dist/.setup/{session-catalog-node-lookup-CtAXI5W5.mjs → session-catalog-node-lookup-Uufckwcm.mjs} +2 -2
- package/dist/.setup/{session-catalog-parsing-CPGaPYr-.mjs → session-catalog-parsing-B-qWJh2x.mjs} +70 -28
- package/dist/.setup/{session-catalog-projection-CGfzfP93.mjs → session-catalog-projection-8aHNwzWD.mjs} +6 -122
- package/dist/.setup/{session-catalog-provenance-DoAvktcj.mjs → session-catalog-provenance-CmsOE5mh.mjs} +6 -1
- package/dist/.setup/{session-cli-DlmBHYIe.mjs → session-cli-kH4vuGod.mjs} +1 -2
- package/dist/.setup/{session-history-D83lJWHG.mjs → session-history-BogBHKLk.mjs} +1 -1
- package/dist/.setup/{session-history-import-WhX-X33a.mjs → session-history-import-NWKPa4ZO.mjs} +4 -4
- package/dist/.setup/{session-history-read-Ov3StuL4.mjs → session-history-read-CNN8zwbD.mjs} +8 -19
- package/dist/.setup/{session-history.worker-MnPKncqP.mjs → session-history.worker-Cq_4DYgN.mjs} +3 -3
- package/dist/.setup/{session-initialization-6aveB9qb.mjs → session-initialization-D6dtFQkE.mjs} +2 -2
- package/dist/.setup/{session-permission-policy-Ci_fVX6y.mjs → session-permission-policy-BxIUJ0Zd.mjs} +8 -37
- package/dist/.setup/{session-retirement-LlYWBKTJ.mjs → session-retirement-Czbchv_O.mjs} +14 -15
- package/dist/.setup/{settled-turn-context-D4yj4rxf.mjs → settled-turn-context-BZsMjkIO.mjs} +13 -6
- package/dist/.setup/{settled-turn-finalizer-DW9W3gza.mjs → settled-turn-finalizer-DjZsIwbZ.mjs} +8 -8
- package/dist/.setup/{shared-client-CJCTeFpQ.mjs → shared-client-qhyYWbew.mjs} +291 -272
- package/dist/.setup/{provider-capabilities-DG5qbsUZ.mjs → shell-dynamic-tools-D3Brj3g9.mjs} +16 -55
- package/dist/.setup/{side-question-BLeGj7TQ.mjs → side-question-D3NJlgbl.mjs} +99 -91
- package/dist/.setup/{source-CJis_1EF.mjs → source-BYu0T780.mjs} +24 -40
- package/dist/.setup/{thread-lifecycle-_bAbjedG.mjs → thread-lifecycle-Cbz_7ySv.mjs} +262 -305
- package/dist/.setup/{thread-ownership-B6pPt21M.mjs → thread-ownership-DwuSrt3s.mjs} +10 -8
- package/dist/.setup/{thread-policy-gNPzzpVp.mjs → thread-policy-DoNxbhqt.mjs} +22 -21
- package/dist/.setup/{thread-requests-OWGOiDaV.mjs → thread-requests-CL1e8Wmx.mjs} +107 -98
- package/dist/.setup/{thread-resume-GOry0AYh.mjs → thread-resume-BT6NHMkM.mjs} +10 -18
- package/dist/.setup/{transcript-history-projection-DRSifI-1.mjs → transcript-history-projection-B9a7HwUV.mjs} +11 -16
- package/dist/.setup/{transcript-mirror-kxmCYsuF.mjs → transcript-mirror-BfLRARNL.mjs} +64 -67
- package/dist/.setup/{transport-stdio-Bdegpn2V.mjs → transport-stdio-a0HDa2Mj.mjs} +27 -8
- package/dist/.setup/{transport-websocket-BTBE-LD9.mjs → transport-websocket-zqJ0Cmtn.mjs} +3 -8
- package/dist/.setup/{attempt-client-cleanup-B-S7ngS_.mjs → turn-router-sS69wYnI.mjs} +75 -170
- package/dist/.setup/{upstream-session-fork-gkdRj2yH.mjs → upstream-session-fork-ChSld66u.mjs} +35 -46
- package/dist/.setup/{usage-CApUvLOV.mjs → usage-D8e8Xiqf.mjs} +4 -4
- package/dist/.setup/{usage-limit-error-wSMQkbpV.mjs → usage-limit-error-GbT-5NcW.mjs} +4 -4
- package/dist/.setup/{web-search-provider.runtime-UKgeiBUG.mjs → web-search-provider.runtime-dL2GD1Kl.mjs} +4 -20
- package/dist/.setup/websocket-data-XlRvt8Ys.mjs +6 -0
- package/dist/.setup/workspace-write-sandbox-probe-DmUHLrrl.mjs +118 -0
- package/dist/api.js +34 -54
- package/dist/catalog-page.worker.js +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +15 -27
- package/dist/harness.js +37 -22
- package/dist/index.js +2880 -276
- package/dist/media-understanding-provider.js +2 -2
- package/dist/migration-provider-api.js +1 -1
- package/dist/native-session-binding-api.js +2 -0
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +33 -4
- package/dist/session-history.worker.js +1 -1
- package/openclaw.plugin.json +3 -3
- package/package.json +6 -6
- package/dist/.setup/config-utils-D0CXecki.mjs +0 -57
- package/dist/.setup/incognito-session-DWYapfwf.mjs +0 -2
- package/dist/.setup/managed-thread-store-BMqgThVL.mjs +0 -100
- package/dist/.setup/rpc-error-BlD2vuzn.mjs +0 -31
- package/dist/.setup/session-binding-meta-B7aEMU7g.mjs +0 -6
- package/dist/.setup/session-binding-record-Oe9L-CNY.mjs +0 -375
- package/dist/.setup/session-catalog-BFafIiF6.mjs +0 -2599
- package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +0 -170
- package/dist/.setup/shared-client-lifecycle-7xgtlo15.mjs +0 -153
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { pt as resolveCodexGatewayTimeoutWithGraceMs } from "./shared-client-qhyYWbew.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-
|
|
2
|
-
import { c as findCodexAppById } from "./plugin-app-cache-key-
|
|
3
|
-
import "./config-
|
|
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
|
|
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 =
|
|
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)
|
|
81
|
-
const appOwnership =
|
|
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
|
-
|
|
149
|
-
|
|
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
|
|
275
|
-
const keys =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
tool
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
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")
|
|
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) ?
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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-CL1e8Wmx.mjs";
|
|
7
|
+
import { m as readCurrentCodexScheduledAppPolicy, p as intersectCodexPluginThreadConfigWithScheduledAuthority } from "./thread-lifecycle-Cbz_7ySv.mjs";
|
|
8
|
+
import { n as disableCodexPluginThreadConfig } from "./dynamic-tool-build-C8xGEXmR.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-
|
|
14
|
+
const { discoverCodexSource, hasCodexSource } = await import("./source-BYu0T780.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-
|
|
32
|
+
const { buildCodexMigrationPlan } = await import("./plan-BJ37d2Og.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-
|
|
38
|
+
return import("./apply-CXTudl9p.mjs").then(({ prepareTargetCodexAppServer }) => prepareTargetCodexAppServer(ctx));
|
|
39
39
|
},
|
|
40
40
|
async apply(ctx, plan) {
|
|
41
|
-
const { applyCodexMigrationPlan } = await import("./apply-
|
|
41
|
+
const { applyCodexMigrationPlan } = await import("./apply-CXTudl9p.mjs");
|
|
42
42
|
return await applyCodexMigrationPlan({
|
|
43
43
|
ctx,
|
|
44
44
|
plan,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-qhyYWbew.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) {
|