@openclaw/codex 2026.9.4 → 2026.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/activity.svg +30 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/account-usage-runtime-Eem_WGqY.mjs +75 -0
- package/dist/{apply-CvT8tW5i.js → .setup/apply-DDOi8uNx.mjs} +24 -30
- package/dist/.setup/async-questions-DdhOCwGi.mjs +27 -0
- package/dist/{attempt-client-cleanup-DKHzbwt5.js → .setup/attempt-client-cleanup-CEv1cKwF.mjs} +79 -49
- package/dist/.setup/attempt-terminal-gZrxQ35N.mjs +5 -0
- package/dist/.setup/attempt-workspace-context-DUVEn_CS.mjs +331 -0
- package/dist/{auth-binding-CWlKVccJ.js → .setup/auth-binding-DhLWa_7K.mjs} +1 -1
- package/dist/{auth-cache-key-7orQae_j.js → .setup/auth-cache-key-B2mpaI9D.mjs} +9 -81
- package/dist/{auth-profile-CwzO4_RG.js → .setup/auth-profile-WqZtZfXN.mjs} +1 -1
- package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
- package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
- package/dist/.setup/binding-connection-ThoatDcb.mjs +50 -0
- package/dist/.setup/binding-connection.runtime-yoHrABt-.mjs +48 -0
- package/dist/{bounded-turn-C_Hneydj.js → .setup/bounded-turn-B2HScEgT.mjs} +143 -32
- package/dist/{build-state-BCmg9-5p.js → .setup/build-state-C7EnDVgr.mjs} +1 -1
- package/dist/{capabilities-8vx68WLH.js → .setup/capabilities-CDXOOFdZ.mjs} +1 -1
- package/dist/{client-B57KWPQx.js → .setup/client-Cs08OXVQ.mjs} +705 -512
- package/dist/.setup/client-catalog-response-BMgt_4q4.mjs +285 -0
- package/dist/{command-dispatch-BpduNGVf.js → .setup/command-dispatch-B4JuOsOk.mjs} +8 -4
- package/dist/{command-formatters-lxlkNZgU.js → .setup/command-formatters-Bmqvr9tO.mjs} +8 -4
- package/dist/{command-handlers-tiL9iWj7.js → .setup/command-handlers-DW7Lx9oH.mjs} +137 -186
- package/dist/{command-rpc-CR5EOEZX.js → .setup/command-rpc-DixIj3HW.mjs} +47 -23
- package/dist/{compact-B_H3AOd7.js → .setup/compact-Du5UvtxA.mjs} +29 -51
- package/dist/{config-oIORaQ5T.js → .setup/config-BoTP_mrL.mjs} +5 -4
- package/dist/{config-options-CXMq1T-C.js → .setup/config-options-BvaRs51b.mjs} +50 -446
- package/dist/{protocol-5bh1G-H7.js → .setup/config-parsing-CcB9iPoq.mjs} +9 -51
- package/dist/{config-runtime-D0zGNIHu.js → .setup/config-runtime-C8Rw1m1m.mjs} +2 -2
- package/dist/.setup/config-security-BEReZ6go.mjs +380 -0
- package/dist/{conversation-binding-DsB4-O7U.js → .setup/conversation-binding-DP-gMrBP.mjs} +29 -38
- package/dist/{conversation-binding-data-BiodpIzq.js → .setup/conversation-binding-data-CrcyZk6O.mjs} +1 -1
- package/dist/{conversation-control-CtUu1b3m.js → .setup/conversation-control-uK9Jomlc.mjs} +32 -67
- package/dist/.setup/cyber-failover-DYwbmf1o.mjs +123 -0
- package/dist/.setup/cyber-failover-notice-e9G3J9-e.mjs +17 -0
- package/dist/{dynamic-tools-CmN5RAip.js → .setup/dynamic-tools-BDXl-8Cw.mjs} +936 -620
- package/dist/{effective-mcp-catalog-Bd73bqA8.js → .setup/effective-mcp-catalog-CvnvnGIe.mjs} +3 -3
- package/dist/{ephemeral-turn-D78_VmzO.js → .setup/ephemeral-turn-poidXgek.mjs} +9 -7
- package/dist/{event-projector-assistant-message-BmBM4qBV.js → .setup/event-projector-assistant-message-BsruvNrH.mjs} +8 -7
- package/dist/{event-projector-items-5VhsECCO.js → .setup/event-projector-items-C6L_5ZiT.mjs} +42 -8
- package/dist/{attempt-notifications-C9XufG6l.js → .setup/event-projector-usage-CnBS8Wa3.mjs} +102 -9
- package/dist/{harness-C7rRa7bm.js → .setup/harness-a_MsE4-_.mjs} +81 -21
- package/dist/{inference-context-Dr_mzvk4.js → .setup/inference-context-D96l9-ew.mjs} +1 -1
- package/dist/.setup/inference-proxy-b-aJMSxm.mjs +601 -0
- package/dist/{isolated-completion-DWVb5U2J.js → .setup/isolated-completion-BIZFhTNG.mjs} +18 -11
- package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
- package/dist/{managed-binary-D22rNEcR.js → .setup/managed-binary-BnshlFag.mjs} +14 -3
- package/dist/{managed-thread-store-D1t5jh3G.js → .setup/managed-thread-store-BMqgThVL.mjs} +48 -14
- package/dist/{model-catalog-Dq2n8f_p.js → .setup/model-catalog-CfXJf9Ay.mjs} +36 -12
- package/dist/{models-PCKOim-h.js → .setup/models-KnqBv0hE.mjs} +3 -3
- package/dist/.setup/native-auth-rWbGbMn3.mjs +57 -0
- package/dist/{native-subagent-history-DjtPloaU.js → .setup/native-subagent-history-0nYYgo0k.mjs} +43 -35
- package/dist/.setup/native-subagent-monitor-D3filLY2.mjs +4859 -0
- package/dist/{native-subagent-task-ids-BzTdT0Uw.js → .setup/native-subagent-task-ids-wb8CKZGN.mjs} +98 -44
- package/dist/{node-cli-sessions-DKaOmVUh.js → .setup/node-cli-sessions-r3avj02l.mjs} +86 -68
- package/dist/.setup/node-exec-server.runtime-BDwWXVpK.mjs +247 -0
- package/dist/{plan-7uG-Fp36.js → .setup/plan-CN3VwfNU.mjs} +133 -119
- package/dist/{plugin-activation-BYQculil.js → .setup/plugin-activation-DT3MNtqj.mjs} +7 -16
- package/dist/{plugin-app-cache-key-d0eKxy7b.js → .setup/plugin-app-cache-key-B2CsSdnV.mjs} +32 -44
- package/dist/{plugin-approval-roundtrip-Bz3FT8W5.js → .setup/plugin-approval-roundtrip-C0MZzCuP.mjs} +1 -1
- package/dist/{plugin-inventory-oL4Na1ZG.js → .setup/plugin-inventory-BoRei8Z4.mjs} +21 -11
- package/dist/{plugin-marketplace-discovery-P-Vndfqq.js → .setup/plugin-marketplace-discovery-CDOi8IFs.mjs} +4 -1
- package/dist/{plugin-metadata-cache-ClPJpRio.js → .setup/plugin-metadata-cache-Ctmo83k_.mjs} +226 -141
- package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
- package/dist/{provider-MQ8PVkuE.js → .setup/provider-BOsxQHOM.mjs} +9 -5
- package/dist/{provider-capabilities-BvCUL69A.js → .setup/provider-capabilities-BfE88FZ5.mjs} +31 -3
- package/dist/{rate-limits-CBMmWBr9.js → .setup/rate-limits-CMU3DUD0.mjs} +174 -151
- package/dist/{request-B7hEkBGq.js → .setup/request-D2L0zMrq.mjs} +130 -42
- package/dist/{run-attempt-CvsAAGa0.js → .setup/run-attempt-BHu11r7h.mjs} +1628 -966
- package/dist/.setup/run-attempt-lifecycle-B7JbY4-F.mjs +71 -0
- package/dist/{runtime-artifact-BJ0rXBZ_.js → .setup/runtime-artifact-CLZ8udh-.mjs} +29 -45
- package/dist/{sandbox-guard-BxgyoM8M.js → .setup/sandbox-guard-C2sRMOEY.mjs} +3 -3
- package/dist/{session-binding-CI8UuilT.js → .setup/session-binding-Cm0apEbd.mjs} +36 -83
- package/dist/{session-binding-record-Bcvslnhf.js → .setup/session-binding-record-BGoz8wOK.mjs} +202 -5
- package/dist/.setup/session-binding-sidecars-BlB5EvIS.mjs +546 -0
- package/dist/.setup/session-catalog-Pno1xGcl.mjs +2764 -0
- package/dist/{session-catalog-adoption-tcZi1IfX.js → .setup/session-catalog-adoption-BI6UTDZT.mjs} +58 -26
- package/dist/{session-catalog-archive-CwKg8Xz2.js → .setup/session-catalog-archive-lHBqzhaO.mjs} +6 -6
- package/dist/.setup/session-catalog-events-Bj6j94E_.mjs +347 -0
- package/dist/.setup/session-catalog-index-B9_VQIUz.mjs +1170 -0
- package/dist/.setup/session-catalog-index-order-hcdz07yN.mjs +48 -0
- package/dist/.setup/session-catalog-index-state-Dgh8ORJm.mjs +183 -0
- package/dist/{thread-history-page-D0JIp48V.js → .setup/session-catalog-native-projection-DowriLid.mjs} +223 -95
- package/dist/{session-catalog-node-adoption-B1tgDW-m.js → .setup/session-catalog-node-adoption-ITddWx_X.mjs} +25 -13
- package/dist/{session-catalog-node-continue-Ci-DXyJP.js → .setup/session-catalog-node-continue-6g6qi4A9.mjs} +24 -15
- package/dist/.setup/session-catalog-projection-zK_PUsiE.mjs +422 -0
- package/dist/{session-cli-DNN_jhGc.js → .setup/session-cli-irrD-uo7.mjs} +3 -3
- package/dist/{session-history-Cz-tOOYj.js → .setup/session-history-BrqhSCf9.mjs} +19 -19
- package/dist/{session-history-import-DwyijFI6.js → .setup/session-history-import-D-3wAgOP.mjs} +4 -4
- package/dist/{session-history-read-cxPUxyVV.js → .setup/session-history-read-B3ZfSUbF.mjs} +2 -2
- package/dist/{session-history.worker-BeK1YOyT.js → .setup/session-history.worker-CaCh0xF_.mjs} +10 -24
- package/dist/{session-initialization-Ct0_Hzmg.js → .setup/session-initialization-rcgbZiid.mjs} +2 -2
- package/dist/{session-permission-policy-BBmXA8Eg.js → .setup/session-permission-policy-BI1QK_98.mjs} +2 -2
- package/dist/{session-retirement-B2YfbAAT.js → .setup/session-retirement-BH-S6qkJ.mjs} +26 -7
- package/dist/{settled-turn-context-Du6gdUDd.js → .setup/settled-turn-context-fmwouT5I.mjs} +2 -2
- package/dist/{settled-turn-finalizer-Dn91stmc.js → .setup/settled-turn-finalizer-DiAi6Kx6.mjs} +12 -12
- package/dist/{shared-client-CscigXXL.js → .setup/shared-client-DA4VR4Eb.mjs} +332 -221
- package/dist/{side-question-BGMJQf4U.js → .setup/side-question-BJ1wSDcB.mjs} +183 -230
- package/dist/{source-CElXU0Oy.js → .setup/source-CUzJq5WN.mjs} +11 -10
- package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
- package/dist/{thread-archive-guard-DfpBr-Sz.js → .setup/thread-archive-guard-C9frICzX.mjs} +10 -3
- package/dist/.setup/thread-history-page-DoVpnHim.mjs +83 -0
- package/dist/{thread-lifecycle-DXl1-I6b.js → .setup/thread-lifecycle-B3mfz1TG.mjs} +347 -2318
- package/dist/{thread-ownership-BsDRTsyp.js → .setup/thread-ownership-DcTtAcXj.mjs} +6 -4
- package/dist/{thread-policy-BuEQfE0g.js → .setup/thread-policy-DGuQsuFC.mjs} +19 -3
- package/dist/.setup/thread-requests-BLvGkP2R.mjs +2205 -0
- package/dist/{thread-resume-DsDOZpFg.js → .setup/thread-resume-DIBXwOpE.mjs} +8 -5
- package/dist/.setup/timeout-C910MdAB.mjs +80 -0
- package/dist/{transcript-history-projection-v17wXgdK.js → .setup/transcript-history-projection-ZZpkFkJ_.mjs} +96 -61
- package/dist/{transcript-mirror-C5CKgNy6.js → .setup/transcript-mirror-BtHDBp1G.mjs} +224 -195
- package/dist/{transcript-mirror-attestation-DibE0krH.js → .setup/transcript-mirror-attestation-CzM-94NC.mjs} +4 -1
- package/dist/{transport-stdio-BGjHoYLr.js → .setup/transport-stdio-h2VHOskC.mjs} +274 -89
- package/dist/{upstream-session-fork-BZerMte_.js → .setup/upstream-session-fork-BUr4OUbC.mjs} +51 -42
- package/dist/{usage-tCk-mg_x.js → .setup/usage-BML0r-ua.mjs} +5 -4
- package/dist/.setup/usage-limit-error-DUMbefVY.mjs +166 -0
- package/dist/{web-search-provider.runtime-B7bGbGWq.js → .setup/web-search-provider.runtime-CDKlN-Rv.mjs} +4 -3
- package/dist/api.js +23 -12
- package/dist/catalog-page-worker-entrypoint.js +12 -0
- package/dist/catalog-page.worker.js +9 -0
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +8 -528
- package/dist/harness.js +1 -1
- package/dist/index.js +306 -215
- package/dist/media-understanding-provider.js +3 -3
- package/dist/migration-provider-api.js +1 -1
- package/dist/native-tool-policy.js +12 -0
- package/dist/provider-discovery.js +18 -0
- package/dist/session-history-worker-runtime.js +36 -35
- package/dist/session-history.worker.js +2 -2
- package/dist/web-search-contract-api.js +1 -1
- package/openclaw.plugin.json +354 -69
- package/package.json +14 -8
- package/dist/attempt-context-D44yeDII.js +0 -636
- package/dist/binding-connection-D3udKbIE.js +0 -60
- package/dist/event-projector-usage-BfXmpOec.js +0 -102
- package/dist/inference-proxy-HGXKUIre.js +0 -311
- package/dist/launch-args-RXQwn8zV.js +0 -90
- package/dist/native-subagent-history-owner-Pcp7JuVF.js +0 -34
- package/dist/native-subagent-monitor-fQ7eIXEf.js +0 -2978
- package/dist/node-exec-server.runtime-Cl2vapEi.js +0 -226
- package/dist/rpc-error-ttN_QjEm.js +0 -30
- package/dist/session-catalog-ct-AH01I.js +0 -1477
- package/dist/session-catalog-home-id-CwhLdC03.js +0 -18
- package/dist/session-catalog-provenance-D-dIfRAH.js +0 -96
- package/dist/timeout-BVw8aaM1.js +0 -33
- package/dist/version-omm6IPI3.js +0 -12
- /package/dist/{auth-profile-selection-DFu9e167.js → .setup/auth-profile-selection-DFu9e167.mjs} +0 -0
- /package/dist/{config-utils-DujwEnhg.js → .setup/config-utils-DujwEnhg.mjs} +0 -0
- /package/dist/{context-compaction-activity-CMla5FPJ.js → .setup/context-compaction-activity-CMla5FPJ.mjs} +0 -0
- /package/dist/{elicitation-input-DPoK8F7w.js → .setup/elicitation-input-DPoK8F7w.mjs} +0 -0
- /package/dist/{history-rejection-B4nOXNXF.js → .setup/history-rejection-B4nOXNXF.mjs} +0 -0
- /package/dist/{image-payload-sanitizer-tupAr-2o.js → .setup/image-payload-sanitizer-tupAr-2o.mjs} +0 -0
- /package/dist/{incognito-session-uhrBF6wJ.js → .setup/incognito-session-uhrBF6wJ.mjs} +0 -0
- /package/dist/{local-runtime-attribution-B_2mnqhb.js → .setup/local-runtime-attribution-B_2mnqhb.mjs} +0 -0
- /package/dist/{native-execution-policy-umd0tgh4.js → .setup/native-execution-policy-umd0tgh4.mjs} +0 -0
- /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
- /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
- /package/dist/{session-upstream-marker-D15C9NHp.js → .setup/session-upstream-marker-D15C9NHp.mjs} +0 -0
- /package/dist/{upstream-prompt-provenance-LphB8slG.js → .setup/upstream-prompt-provenance-LphB8slG.mjs} +0 -0
- /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.
|
|
2
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
+
import { i as withTimeout, o as CodexAppServerRpcError, r as withAbortableTimeout } from "./timeout-C910MdAB.mjs";
|
|
3
3
|
//#region extensions/codex/src/app-server/request.ts
|
|
4
4
|
var request_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
CodexAppServerScopedRequestRejectedError: () => CodexAppServerScopedRequestRejectedError,
|
|
@@ -8,26 +8,56 @@ var request_exports = /* @__PURE__ */ __exportAll({
|
|
|
8
8
|
requestCodexAppServerJson: () => requestCodexAppServerJson,
|
|
9
9
|
withCodexAppServerJsonClient: () => withCodexAppServerJsonClient
|
|
10
10
|
});
|
|
11
|
+
function observeControlPhase(observation, phase) {
|
|
12
|
+
try {
|
|
13
|
+
observation?.phase(phase);
|
|
14
|
+
} catch {}
|
|
15
|
+
}
|
|
16
|
+
function observeControlFailure(observation, phase, error, deadlineObserved = false) {
|
|
17
|
+
if (!observation) return;
|
|
18
|
+
try {
|
|
19
|
+
const category = deadlineObserved ? "deadline-observed" : error instanceof CodexAppServerScopedRequestRejectedError ? "scoped-rejection" : error instanceof CodexAppServerRpcError ? error.code === -32601 ? "rpc-method-unavailable" : "rpc-error" : "other";
|
|
20
|
+
observation.failed({
|
|
21
|
+
phase,
|
|
22
|
+
category
|
|
23
|
+
});
|
|
24
|
+
} catch {}
|
|
25
|
+
}
|
|
11
26
|
/** Sends one guarded request over a client lease owned by the caller. */
|
|
12
27
|
async function requestCodexAppServerClientJson(params) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
let phase = "prepare";
|
|
29
|
+
observeControlPhase(params.controlObservation, phase);
|
|
30
|
+
try {
|
|
31
|
+
const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-C2sRMOEY.mjs").then((n) => n.r);
|
|
32
|
+
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
33
|
+
method: params.method,
|
|
34
|
+
requestParams: params.requestParams,
|
|
35
|
+
config: params.config,
|
|
36
|
+
sessionKey: params.sessionKey,
|
|
37
|
+
sessionId: params.sessionId
|
|
38
|
+
});
|
|
39
|
+
if (sandboxBlock) throw new Error(sandboxBlock);
|
|
40
|
+
const timeoutMs = params.timeoutMs ?? 6e4;
|
|
41
|
+
const method = params.method;
|
|
42
|
+
const requestParams = params.requestParams;
|
|
43
|
+
const attemptWaiterFinished = method === "thread/list" ? params.controlObservation?.attemptWaiterFinished : void 0;
|
|
44
|
+
const options = {
|
|
45
|
+
timeoutMs,
|
|
46
|
+
signal: params.signal,
|
|
47
|
+
...attemptWaiterFinished ? { attemptWaiterFinished } : {},
|
|
48
|
+
...params.assertCurrent ? { assertCurrent: () => assertRequestOwnerCurrent(params.assertCurrent) } : {}
|
|
49
|
+
};
|
|
50
|
+
phase = "client-request";
|
|
51
|
+
observeControlPhase(params.controlObservation, phase);
|
|
52
|
+
return await withTimeout(params.client.request(method, requestParams, options), timeoutMs, `codex app-server ${params.method} timed out`);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
observeControlFailure(params.controlObservation, phase, error);
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
28
57
|
}
|
|
29
58
|
async function requestCodexAppServerJson(params) {
|
|
30
|
-
|
|
59
|
+
observeControlPhase(params.controlObservation, "prepare");
|
|
60
|
+
const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-C2sRMOEY.mjs").then((n) => n.r);
|
|
31
61
|
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
32
62
|
method: params.method,
|
|
33
63
|
requestParams: params.requestParams,
|
|
@@ -51,6 +81,15 @@ var CodexAppServerScopedRequestRejectedError = class extends Error {
|
|
|
51
81
|
this.name = "CodexAppServerScopedRequestRejectedError";
|
|
52
82
|
}
|
|
53
83
|
};
|
|
84
|
+
function createScopeCleanupError(message) {
|
|
85
|
+
const stackTraceLimit = Error.stackTraceLimit;
|
|
86
|
+
try {
|
|
87
|
+
Error.stackTraceLimit = 0;
|
|
88
|
+
return new CodexAppServerScopedRequestRejectedError(message);
|
|
89
|
+
} finally {
|
|
90
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
54
93
|
function assertRequestOwnerCurrent(assertCurrent) {
|
|
55
94
|
try {
|
|
56
95
|
assertCurrent?.();
|
|
@@ -66,14 +105,18 @@ const CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS = 4e3;
|
|
|
66
105
|
const CODEX_USAGE_DEADLINE_RESERVE_MS = CODEX_USAGE_ISOLATED_SHUTDOWN.forceKillDelayMs + CODEX_USAGE_ISOLATED_SHUTDOWN.exitTimeoutMs + 250;
|
|
67
106
|
/** Reads rate limits and best-effort account identity from one isolated app-server session. */
|
|
68
107
|
async function readCodexAppServerUsage(options) {
|
|
69
|
-
const deadline =
|
|
108
|
+
const deadline = performance.now() + options.timeoutMs;
|
|
70
109
|
return await withCodexAppServerJsonClient({
|
|
71
110
|
timeoutMs: options.timeoutMs,
|
|
111
|
+
signal: options.signal,
|
|
72
112
|
timeoutMessage: "codex app-server usage read timed out",
|
|
73
113
|
agentDir: options.agentDir,
|
|
74
114
|
...options.authProfileId ? { authProfileId: options.authProfileId } : {},
|
|
75
115
|
config: options.config,
|
|
76
116
|
startOptions: options.startOptions,
|
|
117
|
+
preparedAuth: options.preparedAuth,
|
|
118
|
+
authRequirement: options.authRequirement,
|
|
119
|
+
assertCurrent: options.assertCurrent,
|
|
77
120
|
isolated: true,
|
|
78
121
|
isolatedShutdown: CODEX_USAGE_ISOLATED_SHUTDOWN
|
|
79
122
|
}, async (request) => {
|
|
@@ -85,20 +128,13 @@ async function readCodexAppServerUsage(options) {
|
|
|
85
128
|
};
|
|
86
129
|
});
|
|
87
130
|
}
|
|
88
|
-
function extractCodexAccountEmail(value) {
|
|
89
|
-
if (!value || typeof value !== "object") return;
|
|
90
|
-
const record = value;
|
|
91
|
-
const account = record.account && typeof record.account === "object" ? record.account : record;
|
|
92
|
-
const email = account.email ?? account.accountEmail;
|
|
93
|
-
return typeof email === "string" && email.trim() ? email.trim() : void 0;
|
|
94
|
-
}
|
|
95
131
|
async function readCodexAccountEmailBestEffort(request, deadline) {
|
|
96
|
-
const boundMs = Math.min(CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS, deadline -
|
|
132
|
+
const boundMs = Math.min(CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS, deadline - performance.now() - CODEX_USAGE_DEADLINE_RESERVE_MS);
|
|
97
133
|
if (boundMs <= 0) return;
|
|
98
134
|
const read = request({
|
|
99
135
|
method: "account/read",
|
|
100
136
|
requestParams: {}
|
|
101
|
-
}).then((account) =>
|
|
137
|
+
}).then(({ account }) => account?.type === "chatgpt" ? account.email?.trim() || void 0 : void 0, () => void 0);
|
|
102
138
|
let timer;
|
|
103
139
|
const timeout = new Promise((resolve) => {
|
|
104
140
|
timer = setTimeout(() => resolve(void 0), boundMs);
|
|
@@ -118,28 +154,39 @@ async function readCodexAccountEmailBestEffort(request, deadline) {
|
|
|
118
154
|
async function withCodexAppServerJsonClient(params, run) {
|
|
119
155
|
const timeoutMs = params.timeoutMs ?? 6e4;
|
|
120
156
|
const timeoutMessage = params.timeoutMessage ?? "codex app-server request timed out";
|
|
157
|
+
let activePhase = "prepare";
|
|
158
|
+
let errorPhase;
|
|
159
|
+
observeControlPhase(params.controlObservation, activePhase);
|
|
121
160
|
const timeoutController = new AbortController();
|
|
122
|
-
const
|
|
123
|
-
|
|
161
|
+
const abort = () => timeoutController.abort(params.signal?.reason);
|
|
162
|
+
params.signal?.addEventListener("abort", abort, { once: true });
|
|
163
|
+
if (params.signal?.aborted) abort();
|
|
164
|
+
const deadline = Number.isFinite(timeoutMs) && timeoutMs > 0 ? performance.now() + timeoutMs : void 0;
|
|
165
|
+
const isPastDeadline = () => deadline !== void 0 && performance.now() >= deadline;
|
|
124
166
|
const throwIfAbandoned = () => {
|
|
125
167
|
if (timeoutController.signal.aborted && timeoutController.signal.reason instanceof Error) throw timeoutController.signal.reason;
|
|
126
168
|
if (timeoutController.signal.aborted || isPastDeadline()) throw new CodexAppServerScopedRequestRejectedError(timeoutMessage);
|
|
127
169
|
};
|
|
128
170
|
const remainingTimeoutMs = () => {
|
|
129
171
|
throwIfAbandoned();
|
|
130
|
-
return deadline === void 0 ? timeoutMs : Math.max(1, deadline -
|
|
172
|
+
return deadline === void 0 ? timeoutMs : Math.max(1, deadline - performance.now());
|
|
131
173
|
};
|
|
132
174
|
try {
|
|
175
|
+
throwIfAbandoned();
|
|
133
176
|
return await withAbortableTimeout({
|
|
134
177
|
signal: timeoutController.signal,
|
|
135
178
|
timeoutMs,
|
|
136
179
|
timeoutMessage,
|
|
137
180
|
promise: (async () => {
|
|
138
|
-
const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-
|
|
139
|
-
const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, isCodexAppServerStartSelectionChangedError, releaseLeasedSharedCodexAppServerClient, retireSharedCodexAppServerClientIfCurrent } = await import("./shared-client-
|
|
181
|
+
const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-C2sRMOEY.mjs").then((n) => n.r);
|
|
182
|
+
const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, isCodexAppServerStartSelectionChangedError, releaseLeasedSharedCodexAppServerClient, retireSharedCodexAppServerClientIfCurrent } = await import("./shared-client-DA4VR4Eb.mjs").then((n) => n.y);
|
|
140
183
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
184
|
+
errorPhase = void 0;
|
|
185
|
+
activePhase = "prepare";
|
|
186
|
+
observeControlPhase(params.controlObservation, activePhase);
|
|
141
187
|
throwIfAbandoned();
|
|
142
|
-
const
|
|
188
|
+
const acquireClient = params.isolated ? createIsolatedCodexAppServerClient : getLeasedSharedCodexAppServerClient;
|
|
189
|
+
const acquireOptions = {
|
|
143
190
|
startOptions: params.startOptions,
|
|
144
191
|
pluginConfig: params.pluginConfig,
|
|
145
192
|
timeoutMs: remainingTimeoutMs(),
|
|
@@ -150,8 +197,12 @@ async function withCodexAppServerJsonClient(params, run) {
|
|
|
150
197
|
authRequirement: params.authRequirement,
|
|
151
198
|
agentDir: params.agentDir,
|
|
152
199
|
config: params.config,
|
|
153
|
-
abandonSignal: timeoutController.signal
|
|
154
|
-
|
|
200
|
+
abandonSignal: timeoutController.signal,
|
|
201
|
+
assertCurrent: params.assertCurrent
|
|
202
|
+
};
|
|
203
|
+
activePhase = "acquire-client";
|
|
204
|
+
observeControlPhase(params.controlObservation, activePhase);
|
|
205
|
+
const client = await acquireClient(acquireOptions);
|
|
155
206
|
let scopeActive = true;
|
|
156
207
|
const assertCurrent = () => {
|
|
157
208
|
throwIfAbandoned();
|
|
@@ -159,8 +210,12 @@ async function withCodexAppServerJsonClient(params, run) {
|
|
|
159
210
|
assertRequestOwnerCurrent(params.assertCurrent);
|
|
160
211
|
};
|
|
161
212
|
try {
|
|
213
|
+
activePhase = "prepare";
|
|
214
|
+
observeControlPhase(params.controlObservation, activePhase);
|
|
162
215
|
assertCurrent();
|
|
163
216
|
const scopedRequest = async (request) => {
|
|
217
|
+
activePhase = "prepare";
|
|
218
|
+
observeControlPhase(params.controlObservation, activePhase);
|
|
164
219
|
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
165
220
|
method: request.method,
|
|
166
221
|
requestParams: request.requestParams,
|
|
@@ -170,14 +225,26 @@ async function withCodexAppServerJsonClient(params, run) {
|
|
|
170
225
|
});
|
|
171
226
|
if (sandboxBlock) throw new CodexAppServerScopedRequestRejectedError(sandboxBlock);
|
|
172
227
|
assertCurrent();
|
|
173
|
-
|
|
228
|
+
const method = request.method;
|
|
229
|
+
const requestParams = request.requestParams;
|
|
230
|
+
const attemptWaiterFinished = method === "thread/list" ? params.controlObservation?.attemptWaiterFinished : void 0;
|
|
231
|
+
const requestOptions = {
|
|
174
232
|
timeoutMs: remainingTimeoutMs(),
|
|
175
233
|
signal: timeoutController.signal,
|
|
234
|
+
...attemptWaiterFinished ? { attemptWaiterFinished } : {},
|
|
235
|
+
...params.catalogPreview ? {
|
|
236
|
+
catalogPreview: true,
|
|
237
|
+
catalogPreviewCache: params.catalogPreviewCache,
|
|
238
|
+
catalogRows: params.catalogRows
|
|
239
|
+
} : {},
|
|
176
240
|
assertCurrent: () => {
|
|
177
241
|
assertCurrent();
|
|
178
242
|
request.assertCurrent?.();
|
|
179
243
|
}
|
|
180
|
-
}
|
|
244
|
+
};
|
|
245
|
+
activePhase = "client-request";
|
|
246
|
+
observeControlPhase(params.controlObservation, activePhase);
|
|
247
|
+
return await client.request(method, requestParams, requestOptions);
|
|
181
248
|
};
|
|
182
249
|
return await run(scopedRequest, client, {
|
|
183
250
|
assertCurrent,
|
|
@@ -186,26 +253,47 @@ async function withCodexAppServerJsonClient(params, run) {
|
|
|
186
253
|
}
|
|
187
254
|
});
|
|
188
255
|
} catch (error) {
|
|
256
|
+
errorPhase = activePhase;
|
|
189
257
|
if (!isCodexAppServerStartSelectionChangedError(error) || attempt > 0) throw error;
|
|
190
|
-
|
|
191
|
-
|
|
258
|
+
errorPhase = void 0;
|
|
259
|
+
try {
|
|
260
|
+
if (!params.isolated) {
|
|
261
|
+
activePhase = "release-client";
|
|
262
|
+
observeControlPhase(params.controlObservation, activePhase);
|
|
263
|
+
retireSharedCodexAppServerClientIfCurrent(client);
|
|
264
|
+
}
|
|
265
|
+
activePhase = "prepare";
|
|
266
|
+
observeControlPhase(params.controlObservation, activePhase);
|
|
267
|
+
throwIfAbandoned();
|
|
268
|
+
} catch (retryError) {
|
|
269
|
+
errorPhase = activePhase;
|
|
270
|
+
throw retryError;
|
|
271
|
+
}
|
|
192
272
|
} finally {
|
|
193
273
|
scopeActive = false;
|
|
274
|
+
activePhase = "release-client";
|
|
275
|
+
observeControlPhase(params.controlObservation, activePhase);
|
|
276
|
+
const requestErrorPhase = errorPhase;
|
|
277
|
+
errorPhase = activePhase;
|
|
194
278
|
if (params.isolated) await client.closeAndWait({
|
|
195
279
|
exitTimeoutMs: params.isolatedShutdown?.exitTimeoutMs ?? 2e3,
|
|
196
280
|
forceKillDelayMs: params.isolatedShutdown?.forceKillDelayMs ?? 250
|
|
197
281
|
});
|
|
198
282
|
else releaseLeasedSharedCodexAppServerClient(client);
|
|
283
|
+
errorPhase = requestErrorPhase;
|
|
199
284
|
}
|
|
200
285
|
}
|
|
201
286
|
throw new Error("Codex app-server selection retry loop exited unexpectedly");
|
|
202
287
|
})()
|
|
203
288
|
});
|
|
204
289
|
} catch (error) {
|
|
205
|
-
|
|
290
|
+
const deadlineObserved = isPastDeadline();
|
|
291
|
+
observeControlFailure(params.controlObservation, deadlineObserved ? activePhase : errorPhase ?? activePhase, error, deadlineObserved);
|
|
292
|
+
if (deadlineObserved) throw new Error(timeoutMessage, { cause: error });
|
|
206
293
|
throw error;
|
|
207
294
|
} finally {
|
|
208
|
-
|
|
295
|
+
params.signal?.removeEventListener("abort", abort);
|
|
296
|
+
timeoutController.abort(createScopeCleanupError(timeoutMessage));
|
|
209
297
|
}
|
|
210
298
|
}
|
|
211
299
|
//#endregion
|