@openclaw/codex 2026.9.2 → 2026.9.4
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 +2 -0
- package/dist/api.js +29 -26
- package/dist/apply-CvT8tW5i.js +356 -0
- package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-DKHzbwt5.js} +38 -214
- package/dist/{attempt-context-CSazkWns.js → attempt-context-D44yeDII.js} +9 -7
- package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications-C9XufG6l.js} +3 -106
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-CWlKVccJ.js} +2 -2
- package/dist/auth-cache-key-7orQae_j.js +498 -0
- package/dist/auth-profile-CwzO4_RG.js +43 -0
- package/dist/auth-profile-selection-DFu9e167.js +45 -0
- package/dist/binding-connection-D3udKbIE.js +60 -0
- package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-C_Hneydj.js} +28 -125
- package/dist/build-state-BCmg9-5p.js +19 -0
- package/dist/{capabilities-B1mgvpP8.js → capabilities-8vx68WLH.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-B57KWPQx.js +4005 -0
- package/dist/command-dispatch-BpduNGVf.js +21 -0
- package/dist/{command-formatters-DSbGMXA0.js → command-formatters-lxlkNZgU.js} +4 -3
- package/dist/{command-handlers-DOJvGv6-.js → command-handlers-tiL9iWj7.js} +788 -135
- package/dist/command-rpc-CR5EOEZX.js +233 -0
- package/dist/{compact-Y_xBqrHN.js → compact-B_H3AOd7.js} +19 -14
- package/dist/config-oIORaQ5T.js +106 -0
- package/dist/{config-CyapYSji.js → config-options-CXMq1T-C.js} +205 -593
- package/dist/config-runtime-D0zGNIHu.js +11 -0
- package/dist/{config-utils-C57JiJrU.js → config-utils-DujwEnhg.js} +2 -4
- package/dist/conversation-binding-DsB4-O7U.js +900 -0
- package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CtUu1b3m.js} +11 -143
- package/dist/doctor-contract-api.js +5 -5
- package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-CmN5RAip.js} +133 -76
- package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-Bd73bqA8.js} +3 -3
- package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
- package/dist/ephemeral-turn-D78_VmzO.js +101 -0
- package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
- package/dist/event-projector-items-5VhsECCO.js +200 -0
- package/dist/event-projector-usage-BfXmpOec.js +102 -0
- package/dist/{harness-Czh2Sdoc.js → harness-C7rRa7bm.js} +48 -24
- package/dist/harness.js +1 -1
- package/dist/history-rejection-B4nOXNXF.js +13 -0
- package/dist/incognito-session-uhrBF6wJ.js +15 -0
- package/dist/index.js +406 -2915
- package/dist/inference-context-Dr_mzvk4.js +94 -0
- package/dist/inference-proxy-HGXKUIre.js +311 -0
- package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DWVb5U2J.js} +7 -4
- package/dist/launch-args-RXQwn8zV.js +90 -0
- package/dist/{managed-binary-DcpnJF9x.js → managed-binary-D22rNEcR.js} +13 -103
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/migration-provider-api.js +2 -0
- package/dist/{model-catalog-DT5vo6qo.js → model-catalog-Dq2n8f_p.js} +6 -5
- package/dist/{models-CcrgSMQR.js → models-PCKOim-h.js} +3 -3
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/native-subagent-history-DjtPloaU.js +140 -0
- package/dist/native-subagent-history-owner-Pcp7JuVF.js +34 -0
- package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-fQ7eIXEf.js} +115 -460
- package/dist/native-subagent-task-ids-BzTdT0Uw.js +387 -0
- package/dist/node-cli-sessions-DKaOmVUh.js +527 -0
- package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-Cl2vapEi.js} +55 -24
- package/dist/plan-7uG-Fp36.js +947 -0
- package/dist/plugin-activation-BYQculil.js +138 -0
- package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-d0eKxy7b.js} +4 -52
- package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-Bz3FT8W5.js} +1 -1
- package/dist/plugin-inventory-oL4Na1ZG.js +328 -0
- package/dist/plugin-marketplace-discovery-P-Vndfqq.js +137 -0
- package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-ClPJpRio.js} +17 -9
- package/dist/protocol-5bh1G-H7.js +275 -0
- package/dist/provider-MQ8PVkuE.js +50 -0
- package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-BvCUL69A.js} +2 -2
- package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-CBMmWBr9.js} +1 -1
- package/dist/request-B7hEkBGq.js +212 -0
- package/dist/rpc-error-ttN_QjEm.js +30 -0
- package/dist/{run-attempt-BzthFQSM.js → run-attempt-CvsAAGa0.js} +664 -377
- package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-BJ0rXBZ_.js} +27 -27
- package/dist/sandbox-guard-BxgyoM8M.js +166 -0
- package/dist/{session-binding-4Ki04sW-.js → session-binding-CI8UuilT.js} +30 -48
- package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-Bcvslnhf.js} +12 -26
- package/dist/session-catalog-adoption-tcZi1IfX.js +251 -0
- package/dist/session-catalog-archive-CwKg8Xz2.js +56 -0
- package/dist/session-catalog-ct-AH01I.js +1477 -0
- package/dist/session-catalog-home-id-CwhLdC03.js +18 -0
- package/dist/session-catalog-node-adoption-B1tgDW-m.js +182 -0
- package/dist/session-catalog-node-continue-Ci-DXyJP.js +238 -0
- package/dist/session-catalog-provenance-D-dIfRAH.js +96 -0
- package/dist/{session-cli-BjLhpmS1.js → session-cli-DNN_jhGc.js} +3 -2
- package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
- package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DwyijFI6.js} +5 -50
- package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
- package/dist/session-history-worker-runtime.js +18 -6
- package/dist/session-history.worker-BeK1YOyT.js +378 -0
- package/dist/session-history.worker.js +1 -1
- package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Ct0_Hzmg.js} +2 -2
- package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-BBmXA8Eg.js} +4 -7
- package/dist/{session-retirement-DNdmYdFc.js → session-retirement-B2YfbAAT.js} +6 -5
- package/dist/session-upstream-marker-D15C9NHp.js +46 -0
- package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
- package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-Dn91stmc.js} +8 -7
- package/dist/shared-client-CscigXXL.js +3109 -0
- package/dist/{side-question-B6DWAw1A.js → side-question-BGMJQf4U.js} +65 -170
- package/dist/source-CElXU0Oy.js +518 -0
- package/dist/thread-archive-guard-DfpBr-Sz.js +53 -0
- package/dist/thread-history-page-D0JIp48V.js +361 -0
- package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-DXl1-I6b.js} +187 -639
- package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-BsDRTsyp.js} +13 -15
- package/dist/thread-policy-BuEQfE0g.js +54 -0
- package/dist/thread-resume-DsDOZpFg.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/transcript-history-projection-v17wXgdK.js +238 -0
- package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-C5CKgNy6.js} +50 -260
- package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
- package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
- package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-BZerMte_.js} +27 -19
- package/dist/{usage-i9fv5-4m.js → usage-tCk-mg_x.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-B7bGbGWq.js} +3 -3
- package/openclaw.plugin.json +23 -1
- package/package.json +4 -4
- package/dist/request-C8H22rPi.js +0 -475
- package/dist/session-catalog-B47uwekb.js +0 -3272
- package/dist/session-history.worker-zZVcx0ME.js +0 -267
- package/dist/shared-client-CKhX2kFt.js +0 -7505
- package/dist/thread-policy-CTalhWFy.js +0 -105
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { n as withTimeout, t as withAbortableTimeout } from "./timeout-BVw8aaM1.js";
|
|
3
|
+
//#region extensions/codex/src/app-server/request.ts
|
|
4
|
+
var request_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
CodexAppServerScopedRequestRejectedError: () => CodexAppServerScopedRequestRejectedError,
|
|
6
|
+
readCodexAppServerUsage: () => readCodexAppServerUsage,
|
|
7
|
+
requestCodexAppServerClientJson: () => requestCodexAppServerClientJson,
|
|
8
|
+
requestCodexAppServerJson: () => requestCodexAppServerJson,
|
|
9
|
+
withCodexAppServerJsonClient: () => withCodexAppServerJsonClient
|
|
10
|
+
});
|
|
11
|
+
/** Sends one guarded request over a client lease owned by the caller. */
|
|
12
|
+
async function requestCodexAppServerClientJson(params) {
|
|
13
|
+
const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-BxgyoM8M.js").then((n) => n.r);
|
|
14
|
+
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
15
|
+
method: params.method,
|
|
16
|
+
requestParams: params.requestParams,
|
|
17
|
+
config: params.config,
|
|
18
|
+
sessionKey: params.sessionKey,
|
|
19
|
+
sessionId: params.sessionId
|
|
20
|
+
});
|
|
21
|
+
if (sandboxBlock) throw new Error(sandboxBlock);
|
|
22
|
+
const timeoutMs = params.timeoutMs ?? 6e4;
|
|
23
|
+
return await withTimeout(params.client.request(params.method, params.requestParams, {
|
|
24
|
+
timeoutMs,
|
|
25
|
+
signal: params.signal,
|
|
26
|
+
...params.assertCurrent ? { assertCurrent: () => assertRequestOwnerCurrent(params.assertCurrent) } : {}
|
|
27
|
+
}), timeoutMs, `codex app-server ${params.method} timed out`);
|
|
28
|
+
}
|
|
29
|
+
async function requestCodexAppServerJson(params) {
|
|
30
|
+
const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-BxgyoM8M.js").then((n) => n.r);
|
|
31
|
+
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
32
|
+
method: params.method,
|
|
33
|
+
requestParams: params.requestParams,
|
|
34
|
+
config: params.config,
|
|
35
|
+
sessionKey: params.sessionKey,
|
|
36
|
+
sessionId: params.sessionId
|
|
37
|
+
});
|
|
38
|
+
if (sandboxBlock) throw new Error(sandboxBlock);
|
|
39
|
+
return await withCodexAppServerJsonClient({
|
|
40
|
+
...params,
|
|
41
|
+
timeoutMessage: `codex app-server ${params.method} timed out`
|
|
42
|
+
}, async (request) => await request({
|
|
43
|
+
method: params.method,
|
|
44
|
+
requestParams: params.requestParams
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
/** A scoped guard rejected the request before a physical write. */
|
|
48
|
+
var CodexAppServerScopedRequestRejectedError = class extends Error {
|
|
49
|
+
constructor(message, options) {
|
|
50
|
+
super(message, options);
|
|
51
|
+
this.name = "CodexAppServerScopedRequestRejectedError";
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
function assertRequestOwnerCurrent(assertCurrent) {
|
|
55
|
+
try {
|
|
56
|
+
assertCurrent?.();
|
|
57
|
+
} catch (cause) {
|
|
58
|
+
throw new CodexAppServerScopedRequestRejectedError(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const CODEX_USAGE_ISOLATED_SHUTDOWN = {
|
|
62
|
+
forceKillDelayMs: 200,
|
|
63
|
+
exitTimeoutMs: 300
|
|
64
|
+
};
|
|
65
|
+
const CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS = 4e3;
|
|
66
|
+
const CODEX_USAGE_DEADLINE_RESERVE_MS = CODEX_USAGE_ISOLATED_SHUTDOWN.forceKillDelayMs + CODEX_USAGE_ISOLATED_SHUTDOWN.exitTimeoutMs + 250;
|
|
67
|
+
/** Reads rate limits and best-effort account identity from one isolated app-server session. */
|
|
68
|
+
async function readCodexAppServerUsage(options) {
|
|
69
|
+
const deadline = Date.now() + options.timeoutMs;
|
|
70
|
+
return await withCodexAppServerJsonClient({
|
|
71
|
+
timeoutMs: options.timeoutMs,
|
|
72
|
+
timeoutMessage: "codex app-server usage read timed out",
|
|
73
|
+
agentDir: options.agentDir,
|
|
74
|
+
...options.authProfileId ? { authProfileId: options.authProfileId } : {},
|
|
75
|
+
config: options.config,
|
|
76
|
+
startOptions: options.startOptions,
|
|
77
|
+
isolated: true,
|
|
78
|
+
isolatedShutdown: CODEX_USAGE_ISOLATED_SHUTDOWN
|
|
79
|
+
}, async (request) => {
|
|
80
|
+
const rateLimits = await request({ method: "account/rateLimits/read" });
|
|
81
|
+
const accountEmail = await readCodexAccountEmailBestEffort(request, deadline);
|
|
82
|
+
return {
|
|
83
|
+
rateLimits,
|
|
84
|
+
...accountEmail ? { accountEmail } : {}
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
}
|
|
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
|
+
async function readCodexAccountEmailBestEffort(request, deadline) {
|
|
96
|
+
const boundMs = Math.min(CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS, deadline - Date.now() - CODEX_USAGE_DEADLINE_RESERVE_MS);
|
|
97
|
+
if (boundMs <= 0) return;
|
|
98
|
+
const read = request({
|
|
99
|
+
method: "account/read",
|
|
100
|
+
requestParams: {}
|
|
101
|
+
}).then((account) => extractCodexAccountEmail(account), () => void 0);
|
|
102
|
+
let timer;
|
|
103
|
+
const timeout = new Promise((resolve) => {
|
|
104
|
+
timer = setTimeout(() => resolve(void 0), boundMs);
|
|
105
|
+
timer.unref?.();
|
|
106
|
+
});
|
|
107
|
+
try {
|
|
108
|
+
return await Promise.race([read, timeout]);
|
|
109
|
+
} finally {
|
|
110
|
+
if (timer) clearTimeout(timer);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Runs several guarded requests over one acquired client (shared lease or
|
|
115
|
+
* isolated child) so related reads see the same app-server session. The whole
|
|
116
|
+
* callback re-runs once when the client's start selection changed underneath it.
|
|
117
|
+
*/
|
|
118
|
+
async function withCodexAppServerJsonClient(params, run) {
|
|
119
|
+
const timeoutMs = params.timeoutMs ?? 6e4;
|
|
120
|
+
const timeoutMessage = params.timeoutMessage ?? "codex app-server request timed out";
|
|
121
|
+
const timeoutController = new AbortController();
|
|
122
|
+
const deadline = Number.isFinite(timeoutMs) && timeoutMs > 0 ? Date.now() + timeoutMs : void 0;
|
|
123
|
+
const isPastDeadline = () => deadline !== void 0 && Date.now() >= deadline;
|
|
124
|
+
const throwIfAbandoned = () => {
|
|
125
|
+
if (timeoutController.signal.aborted && timeoutController.signal.reason instanceof Error) throw timeoutController.signal.reason;
|
|
126
|
+
if (timeoutController.signal.aborted || isPastDeadline()) throw new CodexAppServerScopedRequestRejectedError(timeoutMessage);
|
|
127
|
+
};
|
|
128
|
+
const remainingTimeoutMs = () => {
|
|
129
|
+
throwIfAbandoned();
|
|
130
|
+
return deadline === void 0 ? timeoutMs : Math.max(1, deadline - Date.now());
|
|
131
|
+
};
|
|
132
|
+
try {
|
|
133
|
+
return await withAbortableTimeout({
|
|
134
|
+
signal: timeoutController.signal,
|
|
135
|
+
timeoutMs,
|
|
136
|
+
timeoutMessage,
|
|
137
|
+
promise: (async () => {
|
|
138
|
+
const { resolveCodexAppServerDirectSandboxBypassBlock } = await import("./sandbox-guard-BxgyoM8M.js").then((n) => n.r);
|
|
139
|
+
const { createIsolatedCodexAppServerClient, getLeasedSharedCodexAppServerClient, isCodexAppServerStartSelectionChangedError, releaseLeasedSharedCodexAppServerClient, retireSharedCodexAppServerClientIfCurrent } = await import("./shared-client-CscigXXL.js").then((n) => n.y);
|
|
140
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
141
|
+
throwIfAbandoned();
|
|
142
|
+
const client = await (params.isolated ? createIsolatedCodexAppServerClient : getLeasedSharedCodexAppServerClient)({
|
|
143
|
+
startOptions: params.startOptions,
|
|
144
|
+
pluginConfig: params.pluginConfig,
|
|
145
|
+
timeoutMs: remainingTimeoutMs(),
|
|
146
|
+
authProfileId: params.authProfileId,
|
|
147
|
+
authProfileStore: params.authProfileStore,
|
|
148
|
+
authBindingFingerprint: params.authBindingFingerprint,
|
|
149
|
+
preparedAuth: params.preparedAuth,
|
|
150
|
+
authRequirement: params.authRequirement,
|
|
151
|
+
agentDir: params.agentDir,
|
|
152
|
+
config: params.config,
|
|
153
|
+
abandonSignal: timeoutController.signal
|
|
154
|
+
});
|
|
155
|
+
let scopeActive = true;
|
|
156
|
+
const assertCurrent = () => {
|
|
157
|
+
throwIfAbandoned();
|
|
158
|
+
if (!scopeActive) throw new CodexAppServerScopedRequestRejectedError("Codex app-server request scope is closed");
|
|
159
|
+
assertRequestOwnerCurrent(params.assertCurrent);
|
|
160
|
+
};
|
|
161
|
+
try {
|
|
162
|
+
assertCurrent();
|
|
163
|
+
const scopedRequest = async (request) => {
|
|
164
|
+
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
165
|
+
method: request.method,
|
|
166
|
+
requestParams: request.requestParams,
|
|
167
|
+
config: params.config,
|
|
168
|
+
sessionKey: params.sessionKey,
|
|
169
|
+
sessionId: params.sessionId
|
|
170
|
+
});
|
|
171
|
+
if (sandboxBlock) throw new CodexAppServerScopedRequestRejectedError(sandboxBlock);
|
|
172
|
+
assertCurrent();
|
|
173
|
+
return await client.request(request.method, request.requestParams, {
|
|
174
|
+
timeoutMs: remainingTimeoutMs(),
|
|
175
|
+
signal: timeoutController.signal,
|
|
176
|
+
assertCurrent: () => {
|
|
177
|
+
assertCurrent();
|
|
178
|
+
request.assertCurrent?.();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
return await run(scopedRequest, client, {
|
|
183
|
+
assertCurrent,
|
|
184
|
+
abort: (reason) => {
|
|
185
|
+
if (scopeActive) timeoutController.abort(reason);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
} catch (error) {
|
|
189
|
+
if (!isCodexAppServerStartSelectionChangedError(error) || attempt > 0) throw error;
|
|
190
|
+
if (!params.isolated) retireSharedCodexAppServerClientIfCurrent(client);
|
|
191
|
+
throwIfAbandoned();
|
|
192
|
+
} finally {
|
|
193
|
+
scopeActive = false;
|
|
194
|
+
if (params.isolated) await client.closeAndWait({
|
|
195
|
+
exitTimeoutMs: params.isolatedShutdown?.exitTimeoutMs ?? 2e3,
|
|
196
|
+
forceKillDelayMs: params.isolatedShutdown?.forceKillDelayMs ?? 250
|
|
197
|
+
});
|
|
198
|
+
else releaseLeasedSharedCodexAppServerClient(client);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
throw new Error("Codex app-server selection retry loop exited unexpectedly");
|
|
202
|
+
})()
|
|
203
|
+
});
|
|
204
|
+
} catch (error) {
|
|
205
|
+
if (isPastDeadline()) throw new Error(timeoutMessage, { cause: error });
|
|
206
|
+
throw error;
|
|
207
|
+
} finally {
|
|
208
|
+
timeoutController.abort(new CodexAppServerScopedRequestRejectedError(timeoutMessage));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
export { request_exports as a, requestCodexAppServerJson as i, readCodexAppServerUsage as n, withCodexAppServerJsonClient as o, requestCodexAppServerClientJson as r, CodexAppServerScopedRequestRejectedError as t };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { o as isJsonObject } from "./protocol-5bh1G-H7.js";
|
|
2
|
+
//#region extensions/codex/src/app-server/rpc-error.ts
|
|
3
|
+
/** RPC error wrapper that preserves app-server error code and data. */
|
|
4
|
+
var CodexAppServerRpcError = class extends Error {
|
|
5
|
+
constructor(error, method) {
|
|
6
|
+
super(formatCodexAppServerRpcErrorMessage(error, method));
|
|
7
|
+
this.name = "CodexAppServerRpcError";
|
|
8
|
+
this.code = error.code;
|
|
9
|
+
this.data = error.data;
|
|
10
|
+
this.method = method;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
function isCodexThreadReadMissingError(error, threadId) {
|
|
14
|
+
return error instanceof CodexAppServerRpcError && error.method === "thread/read" && error.code === -32600 && error.message === `thread not loaded: ${threadId}`;
|
|
15
|
+
}
|
|
16
|
+
function formatCodexAppServerRpcErrorMessage(error, method) {
|
|
17
|
+
const message = error.message || `${method} failed`;
|
|
18
|
+
const detail = readCodexAppServerRpcReloginDetail(error.data);
|
|
19
|
+
return detail && !message.includes(detail) ? `${message}: ${detail}` : message;
|
|
20
|
+
}
|
|
21
|
+
function readCodexAppServerRpcReloginDetail(data) {
|
|
22
|
+
const record = isJsonObject(data) ? data : void 0;
|
|
23
|
+
const nested = isJsonObject(record?.error) ? record.error : record;
|
|
24
|
+
if (!nested) return;
|
|
25
|
+
const isRelogin = nested.action === "relogin" || nested.reason === "cloudRequirements" && nested.errorCode === "Auth";
|
|
26
|
+
const detail = typeof nested.detail === "string" ? nested.detail.trim() : "";
|
|
27
|
+
return isRelogin && detail ? detail : void 0;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { isCodexThreadReadMissingError as n, CodexAppServerRpcError as t };
|