@openclaw/codex 2026.7.2-beta.1 → 2026.7.2-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 +1 -1
- package/dist/{app-server-policy-DVcxdse_.js → app-server-policy-Scc-Wevo.js} +1 -1
- package/dist/{attempt-notifications-DEv9h7iC.js → attempt-notifications-BFmNhqFl.js} +3 -6
- package/dist/cli-metadata.js +1 -1
- package/dist/{command-formatters-D6ZlGNmb.js → command-formatters-Dq9InZUK.js} +34 -3
- package/dist/{command-handlers-Cpl9fUWv.js → command-handlers-IgqmL_kv.js} +10 -13
- package/dist/{compact-FnJmiPNA.js → compact-DCTmg3id.js} +4 -5
- package/dist/{computer-use-DVzr8OP1.js → computer-use-CPcU8TjG.js} +4 -4
- package/dist/{conversation-control-DtQ-E7mr.js → conversation-control-CGkBlfc5.js} +5 -7
- package/dist/doctor-contract-api.js +1 -1
- package/dist/{dynamic-tools-BMLoaTeG.js → dynamic-tools-C_1tEs34.js} +608 -330
- package/dist/harness.js +9 -5
- package/dist/index.js +52 -31
- package/dist/{media-understanding-provider-D580L0P8.js → media-understanding-provider-D31dOJwb.js} +11 -12
- package/dist/media-understanding-provider.js +1 -1
- package/dist/{models-DuKzZA6G.js → models-uh26C8QU.js} +5 -9
- package/dist/{notification-correlation-DfaCm0mx.js → notification-correlation-KmfV4EkP.js} +3 -3
- package/dist/{plugin-app-cache-key-BKNjHMEs.js → plugin-app-cache-key-Ceb-lm2c.js} +2 -2
- package/dist/{rate-limits-Dhp04Rqo.js → rate-limits-DyXaYAxU.js} +7 -6
- package/dist/{request-DborTWgw.js → request-B_oQsCXy.js} +54 -8
- package/dist/{run-attempt-VPVJoYDP.js → run-attempt-MLzoMe_m.js} +499 -295
- package/dist/{config-c48K5HP9.js → session-binding-h1mmCGnl.js} +786 -3
- package/dist/{session-catalog-7H112Tr_.js → session-catalog-CEvoXWHA.js} +45 -29
- package/dist/{session-cli-B28RhCyp.js → session-cli-XsEuWb_C.js} +1 -1
- package/dist/{shared-client-D4mFI9al.js → shared-client-JiAnW6pc.js} +255 -81
- package/dist/{side-question-CgJBz52s.js → side-question-DqDvIwSU.js} +15 -13
- package/dist/{thread-lifecycle-BgLXzjvV.js → thread-lifecycle-CN_pPtPh.js} +1787 -1579
- package/dist/{protocol-validators-dZQ-UTOa.js → transcript-mirror-D9rTxx2P.js} +485 -2
- package/dist/usage-D5Rohxoc.js +25 -0
- package/dist/{web-search-provider.runtime-Bs-eTn5U.js → web-search-provider.runtime-CKVBn3fP.js} +3 -3
- package/npm-shrinkwrap.json +30 -30
- package/openclaw.plugin.json +10 -5
- package/package.json +6 -6
- package/dist/capabilities-42Dfn2TV.js +0 -33
- package/dist/prompt-overlay.js +0 -15
- package/dist/protocol-BMifTfdW.js +0 -15
- package/dist/provider-catalog.js +0 -118
- package/dist/provider-discovery.js +0 -34
- package/dist/provider.js +0 -307
- package/dist/session-binding-BMfX1OX-.js +0 -786
- package/dist/transcript-mirror-DhLwFIL4.js +0 -485
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as codexAppServerStartOptionsKey, f as resolveCodexAppServerRuntimeOptions, h as resolveCodexComputerUseConfig, m as resolveCodexAppServerUserHomeDir, p as resolveCodexAppServerStartOptionsForAgent } from "./config-c48K5HP9.js";
|
|
2
|
+
import { C as resolveCodexComputerUseConfig, S as resolveCodexAppServerUserHomeDir, a as isCodexAppServerNativeAuthProfile, b as resolveCodexAppServerRuntimeOptions, m as codexAppServerStartOptionsKey, x as resolveCodexAppServerStartOptionsForAgent } from "./session-binding-h1mmCGnl.js";
|
|
4
3
|
import { n as resolveCodexAppServerSpawnEnv, t as createStdioTransport } from "./transport-stdio-DXgGZ7Ib.js";
|
|
5
|
-
import { a as isCodexAppServerNativeAuthProfile } from "./session-binding-BMfX1OX-.js";
|
|
6
4
|
import { createRequire } from "node:module";
|
|
7
5
|
import fs, { access } from "node:fs/promises";
|
|
8
6
|
import path from "node:path";
|
|
9
|
-
import {
|
|
7
|
+
import { addTimerTimeoutGraceMs, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
8
|
+
import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
10
9
|
import { createHash, randomUUID } from "node:crypto";
|
|
11
10
|
import fsSync, { constants, existsSync, readFileSync, realpathSync } from "node:fs";
|
|
12
11
|
import os from "node:os";
|
|
@@ -24,6 +23,21 @@ import { hasUsableOAuthCredential } from "openclaw/plugin-sdk/provider-auth";
|
|
|
24
23
|
import { fileURLToPath } from "node:url";
|
|
25
24
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
26
25
|
import { withTimeout } from "openclaw/plugin-sdk/security-runtime";
|
|
26
|
+
//#region extensions/codex/src/app-server/protocol.ts
|
|
27
|
+
/** Namespace Codex keeps directly model-visible without exposing it to Code Mode guests. */
|
|
28
|
+
const CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE = "openclaw_direct";
|
|
29
|
+
function flattenCodexDynamicToolFunctions(tools) {
|
|
30
|
+
return (tools ?? []).flatMap((tool) => tool.type === "namespace" ? tool.tools : [tool]);
|
|
31
|
+
}
|
|
32
|
+
const CODEX_INTERACTIVE_THREAD_SOURCE_KINDS = ["cli", "vscode"];
|
|
33
|
+
const CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES = ["atlas", "chatgpt"];
|
|
34
|
+
function isJsonObject$1(value) {
|
|
35
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
36
|
+
}
|
|
37
|
+
function isRpcResponse(message) {
|
|
38
|
+
return "id" in message && !("method" in message);
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
27
41
|
//#region extensions/codex/src/app-server/transport-websocket.ts
|
|
28
42
|
/**
|
|
29
43
|
* Adapts a remote Codex app-server WebSocket endpoint to the shared stdio-like
|
|
@@ -208,16 +222,31 @@ var CodexAppServerRpcError = class extends Error {
|
|
|
208
222
|
this.name = "CodexAppServerRpcError";
|
|
209
223
|
this.code = error.code;
|
|
210
224
|
this.data = error.data;
|
|
225
|
+
this.method = method;
|
|
211
226
|
}
|
|
212
227
|
};
|
|
213
228
|
var CodexAppServerLocalRequestCancellationError = class extends Error {
|
|
214
229
|
constructor(method, reason, mayHaveWritten) {
|
|
215
230
|
super(`${method} ${reason}`);
|
|
231
|
+
this.reason = reason;
|
|
216
232
|
this.mayHaveWritten = mayHaveWritten;
|
|
217
233
|
this.code = "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED";
|
|
218
234
|
this.name = "CodexAppServerLocalRequestCancellationError";
|
|
219
235
|
}
|
|
220
236
|
};
|
|
237
|
+
function isCodexAppServerRequestTimeoutError(error) {
|
|
238
|
+
return error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED" && "reason" in error && error.reason === "timed out";
|
|
239
|
+
}
|
|
240
|
+
function isCodexAppServerBrokenPipeError(error) {
|
|
241
|
+
const seen = /* @__PURE__ */ new Set();
|
|
242
|
+
let current = error;
|
|
243
|
+
while (current && typeof current === "object" && !seen.has(current)) {
|
|
244
|
+
seen.add(current);
|
|
245
|
+
if ("code" in current && current.code === "EPIPE") return true;
|
|
246
|
+
current = "cause" in current ? current.cause : void 0;
|
|
247
|
+
}
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
221
250
|
var CodexAppServerIndeterminateTransportError = class extends Error {
|
|
222
251
|
constructor(method, cause) {
|
|
223
252
|
super(`${method} transport failed after request write: ${cause.message}`, { cause });
|
|
@@ -278,8 +307,8 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
278
307
|
this.lines.on("line", (line) => this.handleLine(line));
|
|
279
308
|
this.lines.on("error", (error) => this.closeWithError(error instanceof Error ? error : new Error(String(error))));
|
|
280
309
|
child.stdout.on("error", (error) => this.closeWithError(error instanceof Error ? error : new Error(String(error))));
|
|
281
|
-
child.stderr.
|
|
282
|
-
|
|
310
|
+
child.stderr.setEncoding("utf8");
|
|
311
|
+
child.stderr.on("data", (text) => {
|
|
283
312
|
this.stderrTail = appendBoundedTail(this.stderrTail, text, CODEX_APP_SERVER_STDERR_TAIL_MAX);
|
|
284
313
|
const trimmed = text.trim();
|
|
285
314
|
if (trimmed) embeddedAgentLog.debug(`codex app-server stderr: ${trimmed}`);
|
|
@@ -352,51 +381,54 @@ var CodexAppServerClient = class CodexAppServerClient {
|
|
|
352
381
|
if (this.closed) return Promise.reject(this.closeError ?? /* @__PURE__ */ new Error("codex app-server client is closed"));
|
|
353
382
|
if (options.signal?.aborted) return Promise.reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
354
383
|
const guard = method === "thread/start" || method === "thread/resume" || method === "thread/fork" ? this.threadSessionRequestGuard : void 0;
|
|
355
|
-
if (guard)
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
releaseGuard
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
const release = () => {
|
|
374
|
-
if (released) return;
|
|
375
|
-
released = true;
|
|
376
|
-
releaseGuard();
|
|
377
|
-
};
|
|
378
|
-
let releaseWhenRequestSettles = true;
|
|
379
|
-
let requestMayHaveWritten = false;
|
|
380
|
-
try {
|
|
381
|
-
const elapsedMs = Date.now() - guardStartedAt;
|
|
382
|
-
const remainingTimeoutMs = options.timeoutMs === void 0 ? void 0 : options.timeoutMs - elapsedMs;
|
|
383
|
-
if (remainingTimeoutMs !== void 0 && remainingTimeoutMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
384
|
-
return await this.requestWithoutThreadSessionGuard(method, params, {
|
|
385
|
-
...options,
|
|
386
|
-
...remainingTimeoutMs !== void 0 ? { timeoutMs: remainingTimeoutMs } : {}
|
|
387
|
-
}, () => {
|
|
388
|
-
requestMayHaveWritten = true;
|
|
389
|
-
});
|
|
390
|
-
} catch (error) {
|
|
391
|
-
if (requestMayHaveWritten && !(error instanceof CodexAppServerRpcError)) {
|
|
392
|
-
releaseWhenRequestSettles = false;
|
|
393
|
-
await this.closeAndRunAfterExit(release, method);
|
|
384
|
+
if (guard) {
|
|
385
|
+
if (!options.signal && !(options.timeoutMs !== void 0 && Number.isFinite(options.timeoutMs) && options.timeoutMs > 0)) return Promise.reject(/* @__PURE__ */ new TypeError(`${method} requires a positive finite timeout or abort signal`));
|
|
386
|
+
return (async () => {
|
|
387
|
+
const guardStartedAt = Date.now();
|
|
388
|
+
const timeoutMessage = `${method} timed out`;
|
|
389
|
+
const abortMessage = `${method} aborted`;
|
|
390
|
+
let releaseGuard;
|
|
391
|
+
try {
|
|
392
|
+
releaseGuard = await guard({
|
|
393
|
+
signal: options.signal,
|
|
394
|
+
timeoutMs: options.timeoutMs,
|
|
395
|
+
timeoutMessage,
|
|
396
|
+
abortMessage
|
|
397
|
+
});
|
|
398
|
+
} catch (error) {
|
|
399
|
+
if (error instanceof Error && error.message === timeoutMessage) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
400
|
+
if (error instanceof Error && error.message === abortMessage) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false);
|
|
401
|
+
throw error;
|
|
394
402
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
403
|
+
let released = false;
|
|
404
|
+
const release = () => {
|
|
405
|
+
if (released) return;
|
|
406
|
+
released = true;
|
|
407
|
+
releaseGuard();
|
|
408
|
+
};
|
|
409
|
+
let releaseWhenRequestSettles = true;
|
|
410
|
+
let requestMayHaveWritten = false;
|
|
411
|
+
try {
|
|
412
|
+
const elapsedMs = Date.now() - guardStartedAt;
|
|
413
|
+
const remainingTimeoutMs = options.timeoutMs === void 0 ? void 0 : options.timeoutMs - elapsedMs;
|
|
414
|
+
if (remainingTimeoutMs !== void 0 && remainingTimeoutMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
415
|
+
return await this.requestWithoutThreadSessionGuard(method, params, {
|
|
416
|
+
...options,
|
|
417
|
+
...remainingTimeoutMs !== void 0 ? { timeoutMs: remainingTimeoutMs } : {}
|
|
418
|
+
}, () => {
|
|
419
|
+
requestMayHaveWritten = true;
|
|
420
|
+
});
|
|
421
|
+
} catch (error) {
|
|
422
|
+
if (requestMayHaveWritten && !(error instanceof CodexAppServerRpcError)) {
|
|
423
|
+
releaseWhenRequestSettles = false;
|
|
424
|
+
await this.closeAndRunAfterExit(release, method);
|
|
425
|
+
}
|
|
426
|
+
throw error;
|
|
427
|
+
} finally {
|
|
428
|
+
if (releaseWhenRequestSettles) release();
|
|
429
|
+
}
|
|
430
|
+
})();
|
|
431
|
+
}
|
|
400
432
|
return this.requestWithoutThreadSessionGuard(method, params, options);
|
|
401
433
|
}
|
|
402
434
|
requestWithoutThreadSessionGuard(method, params, options, onWriteAttempt) {
|
|
@@ -768,7 +800,7 @@ function redactCodexAppServerLinePreview(value) {
|
|
|
768
800
|
}
|
|
769
801
|
function appendBoundedTail(current, next, maxLength) {
|
|
770
802
|
const combined = `${current}${next}`;
|
|
771
|
-
return combined.length > maxLength ?
|
|
803
|
+
return combined.length > maxLength ? sliceUtf16Safe(combined, -maxLength) : combined;
|
|
772
804
|
}
|
|
773
805
|
function buildCodexAppServerExitError(code, signal, stderrTail) {
|
|
774
806
|
const stderrPreview = redactCodexAppServerLinePreview(stderrTail);
|
|
@@ -806,6 +838,103 @@ function formatExitValue(value) {
|
|
|
806
838
|
return "unknown";
|
|
807
839
|
}
|
|
808
840
|
//#endregion
|
|
841
|
+
//#region extensions/codex/src/app-server/attempt-timeouts.ts
|
|
842
|
+
/**
|
|
843
|
+
* Timeout defaults and normalizers for Codex app-server startup and turn
|
|
844
|
+
* liveness watches.
|
|
845
|
+
*/
|
|
846
|
+
/** Minimum startup timeout accepted by the Codex app-server harness. */
|
|
847
|
+
const CODEX_APP_SERVER_STARTUP_TIMEOUT_FLOOR_MS = 100;
|
|
848
|
+
/** Default idle timeout while waiting for app-server turn completion. */
|
|
849
|
+
const CODEX_TURN_COMPLETION_IDLE_TIMEOUT_MS = 6e4;
|
|
850
|
+
/** Short guard after apparent assistant completion. */
|
|
851
|
+
const CODEX_TURN_ASSISTANT_COMPLETION_IDLE_TIMEOUT_MS = 1e4;
|
|
852
|
+
const CODEX_POST_TOOL_RAW_ASSISTANT_COMPLETION_IDLE_TIMEOUT_MS = 5 * 6e4;
|
|
853
|
+
/** Guard after reasoning/commentary progress when no tool handoff occurred. */
|
|
854
|
+
const CODEX_POST_REASONING_REPLY_IDLE_TIMEOUT_MS = 5 * 6e4;
|
|
855
|
+
/** Long terminal idle watch for app-server turns that never send completion. */
|
|
856
|
+
const CODEX_TURN_TERMINAL_IDLE_TIMEOUT_MS = 30 * 6e4;
|
|
857
|
+
var CodexAppServerStartupError = class extends Error {
|
|
858
|
+
constructor(reason, message = reason === "timed_out" ? "codex app-server startup timed out" : "codex app-server startup aborted") {
|
|
859
|
+
super(message);
|
|
860
|
+
this.reason = reason;
|
|
861
|
+
this.code = "CODEX_APP_SERVER_STARTUP_CANCELLED";
|
|
862
|
+
this.name = "CodexAppServerStartupError";
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
function isCodexAppServerStartupError(error, reason) {
|
|
866
|
+
return error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_STARTUP_CANCELLED" && "reason" in error && (error.reason === "aborted" || error.reason === "timed_out") && (reason === void 0 || error.reason === reason);
|
|
867
|
+
}
|
|
868
|
+
function resolvePositiveIntegerTimeoutMs(value, fallbackMs) {
|
|
869
|
+
return resolveTimerTimeoutMs(value, resolveTimerTimeoutMs(fallbackMs, 1));
|
|
870
|
+
}
|
|
871
|
+
/** Runs startup work with abort and timeout handling plus optional cleanup. */
|
|
872
|
+
async function withCodexStartupTimeout(params) {
|
|
873
|
+
if (params.signal.aborted) throw new CodexAppServerStartupError("aborted");
|
|
874
|
+
let timeout;
|
|
875
|
+
let abortCleanup;
|
|
876
|
+
let timeoutError;
|
|
877
|
+
let timeoutCleanup;
|
|
878
|
+
try {
|
|
879
|
+
return await Promise.race([params.operation(), new Promise((_, reject) => {
|
|
880
|
+
const rejectOnce = (error) => {
|
|
881
|
+
if (timeout) {
|
|
882
|
+
clearTimeout(timeout);
|
|
883
|
+
timeout = void 0;
|
|
884
|
+
}
|
|
885
|
+
reject(error);
|
|
886
|
+
};
|
|
887
|
+
timeout = setTimeout(() => {
|
|
888
|
+
timeoutError = new CodexAppServerStartupError("timed_out");
|
|
889
|
+
timeoutCleanup = Promise.resolve(params.onTimeout?.()).then(() => void 0, () => void 0);
|
|
890
|
+
timeoutCleanup.finally(() => {
|
|
891
|
+
rejectOnce(timeoutError);
|
|
892
|
+
});
|
|
893
|
+
}, params.timeoutMs);
|
|
894
|
+
const abortListener = () => rejectOnce(new CodexAppServerStartupError("aborted"));
|
|
895
|
+
params.signal.addEventListener("abort", abortListener, { once: true });
|
|
896
|
+
abortCleanup = () => params.signal.removeEventListener("abort", abortListener);
|
|
897
|
+
})]);
|
|
898
|
+
} catch (error) {
|
|
899
|
+
if (timeoutError) {
|
|
900
|
+
await timeoutCleanup;
|
|
901
|
+
throw timeoutError;
|
|
902
|
+
}
|
|
903
|
+
throw error;
|
|
904
|
+
} finally {
|
|
905
|
+
if (timeout) clearTimeout(timeout);
|
|
906
|
+
abortCleanup?.();
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
/** Resolves startup timeout while honoring the configured floor. */
|
|
910
|
+
function resolveCodexStartupTimeoutMs(params) {
|
|
911
|
+
const timeoutFloorMs = resolvePositiveIntegerTimeoutMs(params.timeoutFloorMs, CODEX_APP_SERVER_STARTUP_TIMEOUT_FLOOR_MS);
|
|
912
|
+
const timeoutMs = resolvePositiveIntegerTimeoutMs(params.timeoutMs, timeoutFloorMs);
|
|
913
|
+
return Math.max(timeoutFloorMs, timeoutMs);
|
|
914
|
+
}
|
|
915
|
+
/** Resolves the completion-idle timeout for an active turn. */
|
|
916
|
+
function resolveCodexTurnCompletionIdleTimeoutMs(value) {
|
|
917
|
+
return resolvePositiveIntegerTimeoutMs(value, CODEX_TURN_COMPLETION_IDLE_TIMEOUT_MS);
|
|
918
|
+
}
|
|
919
|
+
/** Resolves the short assistant-completion release timeout. */
|
|
920
|
+
function resolveCodexTurnAssistantCompletionIdleTimeoutMs(value) {
|
|
921
|
+
return resolvePositiveIntegerTimeoutMs(value, CODEX_TURN_ASSISTANT_COMPLETION_IDLE_TIMEOUT_MS);
|
|
922
|
+
}
|
|
923
|
+
/** Resolves the conservative post-tool raw assistant guard timeout. */
|
|
924
|
+
function resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs(value, fallbackMs) {
|
|
925
|
+
return resolvePositiveIntegerTimeoutMs(value, Math.max(resolvePositiveIntegerTimeoutMs(void 0, fallbackMs), CODEX_POST_TOOL_RAW_ASSISTANT_COMPLETION_IDLE_TIMEOUT_MS));
|
|
926
|
+
}
|
|
927
|
+
/** Resolves the long terminal turn idle timeout. */
|
|
928
|
+
function resolveCodexTurnTerminalIdleTimeoutMs(value, runTimeoutOverrideMs) {
|
|
929
|
+
const explicitRunBudgetMs = resolvePositiveIntegerTimeoutMs(runTimeoutOverrideMs, CODEX_TURN_TERMINAL_IDLE_TIMEOUT_MS);
|
|
930
|
+
return resolvePositiveIntegerTimeoutMs(value, Math.max(CODEX_TURN_TERMINAL_IDLE_TIMEOUT_MS, explicitRunBudgetMs));
|
|
931
|
+
}
|
|
932
|
+
/** Adds gateway grace time to a caller timeout without overflowing invalid values. */
|
|
933
|
+
function resolveCodexGatewayTimeoutWithGraceMs(timeoutMs, graceMs = 1e4) {
|
|
934
|
+
const timeout = resolvePositiveIntegerTimeoutMs(timeoutMs, 1);
|
|
935
|
+
return addTimerTimeoutGraceMs(timeout, resolveTimerTimeoutMs(graceMs, 0, 0)) ?? timeout;
|
|
936
|
+
}
|
|
937
|
+
//#endregion
|
|
809
938
|
//#region extensions/codex/src/app-server/auth-start-options.ts
|
|
810
939
|
const CODEX_APP_SERVER_HOME_DIRNAME = "codex-home";
|
|
811
940
|
const CODEX_EPHEMERAL_AUTH_STORE_OVERRIDE = "cli_auth_credentials_store=\"ephemeral\"";
|
|
@@ -1080,14 +1209,14 @@ async function resolveCodexAppServerPreparedAuthHandoff(params) {
|
|
|
1080
1209
|
authProfileId,
|
|
1081
1210
|
nativeAuthProfile
|
|
1082
1211
|
};
|
|
1083
|
-
if (!authProfileId || !nativeAuthProfile) throw
|
|
1212
|
+
if (!authProfileId || !nativeAuthProfile) throw createCodexAppServerAuthError(params.subscriptionProfileRequiredError);
|
|
1084
1213
|
const snapshot = await resolveCodexAppServerPreparedAuthProfileSnapshot({
|
|
1085
1214
|
authProfileId,
|
|
1086
1215
|
authProfileStore: params.authProfileStore,
|
|
1087
1216
|
agentDir: params.agentDir,
|
|
1088
1217
|
config: params.config
|
|
1089
1218
|
});
|
|
1090
|
-
if (!snapshot) throw
|
|
1219
|
+
if (!snapshot) throw createCodexAppServerAuthError(params.subscriptionProfileUnusableError);
|
|
1091
1220
|
return {
|
|
1092
1221
|
authProfileId,
|
|
1093
1222
|
nativeAuthProfile,
|
|
@@ -1215,15 +1344,29 @@ async function applyCodexAppServerAuthProfile(params) {
|
|
|
1215
1344
|
});
|
|
1216
1345
|
return;
|
|
1217
1346
|
}
|
|
1218
|
-
if (params.authProfileId === null)
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
}
|
|
1347
|
+
if (params.authProfileId === null) {
|
|
1348
|
+
if (params.authRequirement === "subscription") {
|
|
1349
|
+
const response = await params.client.request("account/read", { refreshToken: false });
|
|
1350
|
+
if (!isJsonObject$1(response.account) || response.account.type !== "chatgpt") throw createCodexAppServerAuthError("Codex subscription auth profile could not produce login credentials.");
|
|
1351
|
+
}
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
let loginParams;
|
|
1355
|
+
try {
|
|
1356
|
+
loginParams = await resolveCodexAppServerAuthProfileLoginParams({
|
|
1357
|
+
agentDir: params.agentDir,
|
|
1358
|
+
authProfileId: params.authProfileId,
|
|
1359
|
+
authProfileStore: params.authProfileStore,
|
|
1360
|
+
config: params.config
|
|
1361
|
+
});
|
|
1362
|
+
} catch (error) {
|
|
1363
|
+
if (params.authRequirement === "subscription" && error instanceof CodexAppServerAuthProfileUnavailableError) throw createCodexAppServerAuthError("Codex subscription auth profile could not produce login credentials.", error);
|
|
1364
|
+
throw error;
|
|
1365
|
+
}
|
|
1366
|
+
if (params.authRequirement === "subscription" && loginParams?.type !== "chatgptAuthTokens") throw createCodexAppServerAuthError("Codex subscription auth profile could not produce login credentials.");
|
|
1225
1367
|
if (!loginParams) {
|
|
1226
|
-
if (params.
|
|
1368
|
+
if (params.authRequirement === "subscription") throw createCodexAppServerAuthError("Codex subscription auth profile could not produce login credentials.");
|
|
1369
|
+
if (params.authRequirement !== "api-key" || params.startOptions?.transport !== "stdio") return;
|
|
1227
1370
|
const env = resolveCodexAppServerSpawnEnv(params.startOptions, process.env);
|
|
1228
1371
|
const fallbackLoginParams = await resolveCodexAppServerFallbackApiKeyLoginParams({
|
|
1229
1372
|
client: params.client,
|
|
@@ -1235,8 +1378,25 @@ async function applyCodexAppServerAuthProfile(params) {
|
|
|
1235
1378
|
}
|
|
1236
1379
|
await params.client.request("account/login/start", loginParams);
|
|
1237
1380
|
}
|
|
1238
|
-
function
|
|
1239
|
-
|
|
1381
|
+
function createCodexAppServerAuthError(message, cause) {
|
|
1382
|
+
const error = cause === void 0 ? new Error(message) : new Error(message, { cause });
|
|
1383
|
+
return Object.assign(error, { status: 401 });
|
|
1384
|
+
}
|
|
1385
|
+
var CodexAppServerAuthProfileUnavailableError = class extends Error {};
|
|
1386
|
+
async function resolveCodexAppServerAuthProfileLoginParams(params) {
|
|
1387
|
+
const store = resolveCodexAppServerAuthProfileStore(params);
|
|
1388
|
+
const profileId = resolveCodexAppServerAuthProfileId({
|
|
1389
|
+
authProfileId: params.authProfileId,
|
|
1390
|
+
store,
|
|
1391
|
+
config: params.config
|
|
1392
|
+
});
|
|
1393
|
+
const profile = profileId ? store.profiles[profileId] : void 0;
|
|
1394
|
+
if (profileId && !profile) throw new CodexAppServerAuthProfileUnavailableError(`Codex app-server auth profile "${profileId}" was not found.`);
|
|
1395
|
+
if (profileId && profile && !isCodexAppServerAuthProfileCredential(profile, params.config)) throw new CodexAppServerAuthProfileUnavailableError(`Codex app-server auth profile "${profileId}" must be OpenAI Codex auth or an OpenAI API-key backup.`);
|
|
1396
|
+
return await resolveCodexAppServerAuthProfileLoginParamsInternal({
|
|
1397
|
+
...params,
|
|
1398
|
+
authProfileStore: store
|
|
1399
|
+
});
|
|
1240
1400
|
}
|
|
1241
1401
|
async function refreshCodexAppServerAuthTokens(params) {
|
|
1242
1402
|
const loginParams = await resolveCodexAppServerAuthProfileLoginParamsInternal({
|
|
@@ -1273,7 +1433,7 @@ async function resolveCodexAppServerAuthProfileLoginParamsInternal(params) {
|
|
|
1273
1433
|
forceOAuthRefresh: params.forceOAuthRefresh === true,
|
|
1274
1434
|
config: params.config
|
|
1275
1435
|
});
|
|
1276
|
-
if (!loginParams) throw new
|
|
1436
|
+
if (!loginParams) throw new CodexAppServerAuthProfileUnavailableError(`Codex app-server auth profile "${profileId}" does not contain usable credentials.`);
|
|
1277
1437
|
return loginParams;
|
|
1278
1438
|
}
|
|
1279
1439
|
async function resolveCodexAppServerFallbackApiKeyLoginParams(params) {
|
|
@@ -1903,8 +2063,11 @@ async function waitForPreviousFence(previous, options) {
|
|
|
1903
2063
|
* runtime timeout helper.
|
|
1904
2064
|
*/
|
|
1905
2065
|
/** Awaits a promise with a Codex-specific timeout error message. */
|
|
1906
|
-
async function withTimeout$1(promise, timeoutMs, timeoutMessage) {
|
|
1907
|
-
return await withTimeout(promise, timeoutMs, {
|
|
2066
|
+
async function withTimeout$1(promise, timeoutMs, timeoutMessage, createError) {
|
|
2067
|
+
return await withTimeout(promise, timeoutMs, {
|
|
2068
|
+
message: timeoutMessage,
|
|
2069
|
+
...createError ? { createError } : {}
|
|
2070
|
+
});
|
|
1908
2071
|
}
|
|
1909
2072
|
//#endregion
|
|
1910
2073
|
//#region extensions/codex/src/app-server/shared-client.ts
|
|
@@ -1913,7 +2076,6 @@ async function withTimeout$1(promise, timeoutMs, timeoutMessage) {
|
|
|
1913
2076
|
* lease tracking, and teardown.
|
|
1914
2077
|
*/
|
|
1915
2078
|
var shared_client_exports = /* @__PURE__ */ __exportAll({
|
|
1916
|
-
CodexAppServerStartSelectionChangedError: () => CodexAppServerStartSelectionChangedError,
|
|
1917
2079
|
assertCodexAppServerClientStartSelectionCurrent: () => assertCodexAppServerClientStartSelectionCurrent,
|
|
1918
2080
|
clearSharedCodexAppServerClientAndWait: () => clearSharedCodexAppServerClientAndWait,
|
|
1919
2081
|
clearSharedCodexAppServerClientIfCurrent: () => clearSharedCodexAppServerClientIfCurrent,
|
|
@@ -1995,6 +2157,10 @@ function resolveCodexNativeConfigFenceKey(params) {
|
|
|
1995
2157
|
const codexHome = configuredHome ? configuredHome : startOptions.homeScope === "user" ? resolveCodexAppServerUserHomeDir() : agentDir ? resolveCodexAppServerHomeDir(agentDir) : void 0;
|
|
1996
2158
|
return codexHome ? `codex-home:${path.resolve(codexHome)}` : void 0;
|
|
1997
2159
|
}
|
|
2160
|
+
function inferAuthRequirement(preparedAuth) {
|
|
2161
|
+
if (preparedAuth?.kind === "api-key") return "api-key";
|
|
2162
|
+
return preparedAuth?.kind === "profile" ? "subscription" : void 0;
|
|
2163
|
+
}
|
|
1998
2164
|
async function resolveCodexAppServerClientStartContext(options) {
|
|
1999
2165
|
const agentDir = options?.agentDir ?? resolveDefaultAgentDir(options?.config ?? {});
|
|
2000
2166
|
const requestedStartOptions = options?.startOptions ?? resolveCodexAppServerRuntimeOptions().start;
|
|
@@ -2004,6 +2170,9 @@ async function resolveCodexAppServerClientStartContext(options) {
|
|
|
2004
2170
|
if (preparedAuth?.kind === "profile" && !preparedAuth.store.profiles[preparedAuth.profileId]) throw new Error(`Prepared Codex auth profile "${preparedAuth.profileId}" was not found.`);
|
|
2005
2171
|
if (preparedAuth?.kind === "api-key" && !preparedApiKey) throw new Error("Prepared Codex API-key auth is missing its resolved key.");
|
|
2006
2172
|
if (preparedAuth && requestedStartOptions.homeScope === "user") throw new Error("Prepared Codex auth requires an isolated app-server home.");
|
|
2173
|
+
const preparedAuthRequirement = inferAuthRequirement(preparedAuth);
|
|
2174
|
+
if (options?.authRequirement && preparedAuthRequirement && options.authRequirement !== preparedAuthRequirement) throw new Error("Prepared Codex auth does not satisfy the requested auth requirement.");
|
|
2175
|
+
const authRequirement = options?.authRequirement ?? preparedAuthRequirement;
|
|
2007
2176
|
const usesNativeAuth = !preparedAuth && (options?.authProfileId === null || requestedStartOptions.homeScope === "user");
|
|
2008
2177
|
const requestedAuthProfileId = preparedAuth?.kind === "profile" ? preparedAuth.profileId : options?.authProfileId ?? void 0;
|
|
2009
2178
|
const authProfileStore = preparedAuth?.kind === "profile" ? preparedAuth.store : !usesNativeAuth && options?.authProfileStore ? resolveCodexAppServerAuthProfileStore({
|
|
@@ -2039,6 +2208,7 @@ async function resolveCodexAppServerClientStartContext(options) {
|
|
|
2039
2208
|
authProfileStore,
|
|
2040
2209
|
requestedStartOptions,
|
|
2041
2210
|
preparedAuth: resolvedPreparedAuth,
|
|
2211
|
+
authRequirement,
|
|
2042
2212
|
startOptions: await bridgeCodexAppServerStartOptions({
|
|
2043
2213
|
startOptions: await resolveManagedCodexAppServerStartOptions(resolveCodexAppServerStartOptionsForAgent({
|
|
2044
2214
|
startOptions: requestedStartOptions,
|
|
@@ -2087,9 +2257,9 @@ async function withLeasedCodexAppServerClientStartSelectionRetry(params) {
|
|
|
2087
2257
|
const deadline = Date.now() + timeoutMs;
|
|
2088
2258
|
const signal = params.signal ?? params.options?.abandonSignal;
|
|
2089
2259
|
const requestOptions = () => {
|
|
2090
|
-
if (signal?.aborted) throw new
|
|
2260
|
+
if (signal?.aborted) throw new CodexAppServerStartupError("aborted", "Codex app-server selection retry aborted");
|
|
2091
2261
|
const remainingTimeoutMs = deadline - Date.now();
|
|
2092
|
-
if (remainingTimeoutMs <= 0) throw new
|
|
2262
|
+
if (remainingTimeoutMs <= 0) throw new CodexAppServerStartupError("timed_out", "Codex app-server selection retry timed out");
|
|
2093
2263
|
return {
|
|
2094
2264
|
timeoutMs: remainingTimeoutMs,
|
|
2095
2265
|
...signal ? { signal } : {}
|
|
@@ -2117,18 +2287,18 @@ async function withLeasedCodexAppServerClientStartSelectionRetry(params) {
|
|
|
2117
2287
|
throw new Error("Codex app-server selection retry loop exited unexpectedly");
|
|
2118
2288
|
}
|
|
2119
2289
|
async function acquireSharedCodexAppServerClient(options, leaseOptions) {
|
|
2120
|
-
if (options?.abandonSignal?.aborted) throw new
|
|
2290
|
+
if (options?.abandonSignal?.aborted) throw new CodexAppServerStartupError("aborted", "codex app-server initialize aborted");
|
|
2121
2291
|
const acquireStartedAt = Date.now();
|
|
2122
2292
|
const timeoutMs = options?.timeoutMs ?? 0;
|
|
2123
|
-
const { agentDir, usesNativeAuth, authProfileId, authProfileStore, preparedAuth, requestedStartOptions, startOptions } = await withCodexAppServerAcquireDeadline(timeoutMs, resolveCodexAppServerClientStartContext(options), options?.abandonSignal);
|
|
2293
|
+
const { agentDir, usesNativeAuth, authProfileId, authProfileStore, preparedAuth, authRequirement, requestedStartOptions, startOptions } = await withCodexAppServerAcquireDeadline(timeoutMs, resolveCodexAppServerClientStartContext(options), options?.abandonSignal);
|
|
2124
2294
|
const remainingTimeoutMs = resolveRemainingAcquireTimeout(timeoutMs, acquireStartedAt);
|
|
2125
|
-
const authIdentityCacheKey = preparedAuth?.kind === "api-key" ? resolveCodexAppServerPreparedApiKeyCacheKey(preparedAuth.apiKey) : preparedAuth?.snapshot.secretFreeCacheKey ?? (
|
|
2126
|
-
const baseKey = codexAppServerStartOptionsKey(startOptions, {
|
|
2295
|
+
const authIdentityCacheKey = preparedAuth?.kind === "api-key" ? resolveCodexAppServerPreparedApiKeyCacheKey(preparedAuth.apiKey) : preparedAuth?.snapshot.secretFreeCacheKey ?? (authRequirement === "api-key" && !authProfileId ? resolveCodexAppServerFallbackApiKeyCacheKey({ startOptions }) : void 0);
|
|
2296
|
+
const baseKey = `${codexAppServerStartOptionsKey(startOptions, {
|
|
2127
2297
|
authProfileId,
|
|
2128
2298
|
authBindingFingerprint: options?.authBindingFingerprint,
|
|
2129
2299
|
agentDir: usesNativeAuth ? void 0 : agentDir,
|
|
2130
2300
|
fallbackApiKeyCacheKey: authIdentityCacheKey
|
|
2131
|
-
})
|
|
2301
|
+
})}\0auth-requirement:${authRequirement ?? "native"}`;
|
|
2132
2302
|
const runtimeArtifactMode = options?.runtimeArtifactMode ?? (options?.expectedRuntimeArtifact ? "capture" : void 0);
|
|
2133
2303
|
const expectedRuntimeArtifactKey = options?.expectedRuntimeArtifact ? createHash("sha256").update(options.expectedRuntimeArtifact.id).update("\0").update(options.expectedRuntimeArtifact.fingerprint).digest("hex") : "mint";
|
|
2134
2304
|
const key = runtimeArtifactMode ? `${baseKey}\0runtime-artifact:capture-v1:${expectedRuntimeArtifactKey}` : baseKey;
|
|
@@ -2164,6 +2334,7 @@ async function acquireSharedCodexAppServerClient(options, leaseOptions) {
|
|
|
2164
2334
|
authProfileId: usesNativeAuth || preparedAuth?.kind === "api-key" ? null : authProfileId,
|
|
2165
2335
|
authProfileStore,
|
|
2166
2336
|
preparedAuth,
|
|
2337
|
+
authRequirement,
|
|
2167
2338
|
runtimeArtifactMode,
|
|
2168
2339
|
...options?.expectedRuntimeArtifact ? { expectedRuntimeArtifact: options.expectedRuntimeArtifact } : {},
|
|
2169
2340
|
runtimeArtifactSignal: entry.runtimeArtifactStartupAbort?.signal,
|
|
@@ -2196,11 +2367,11 @@ async function acquireSharedCodexAppServerClient(options, leaseOptions) {
|
|
|
2196
2367
|
}
|
|
2197
2368
|
}
|
|
2198
2369
|
async function withCodexAppServerAcquireDeadline(timeoutMs, promise, signal, timeoutMessage = "codex app-server initialize timed out") {
|
|
2199
|
-
if (signal?.aborted) throw new
|
|
2200
|
-
const timed = withTimeout$1(promise, timeoutMs, timeoutMessage);
|
|
2370
|
+
if (signal?.aborted) throw new CodexAppServerStartupError("aborted", "codex app-server initialize aborted");
|
|
2371
|
+
const timed = withTimeout$1(promise, timeoutMs, timeoutMessage, () => new CodexAppServerStartupError("timed_out", timeoutMessage));
|
|
2201
2372
|
if (!signal) return await timed;
|
|
2202
2373
|
return await new Promise((resolve, reject) => {
|
|
2203
|
-
const onAbort = () => reject(
|
|
2374
|
+
const onAbort = () => reject(new CodexAppServerStartupError("aborted", "codex app-server initialize aborted"));
|
|
2204
2375
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
2205
2376
|
timed.then(resolve, reject).finally(() => signal.removeEventListener("abort", onAbort));
|
|
2206
2377
|
});
|
|
@@ -2208,7 +2379,7 @@ async function withCodexAppServerAcquireDeadline(timeoutMs, promise, signal, tim
|
|
|
2208
2379
|
function resolveRemainingAcquireTimeout(timeoutMs, startedAt) {
|
|
2209
2380
|
if (!(timeoutMs > 0)) return timeoutMs;
|
|
2210
2381
|
const remaining = timeoutMs - (Date.now() - startedAt);
|
|
2211
|
-
if (remaining <= 0) throw new
|
|
2382
|
+
if (remaining <= 0) throw new CodexAppServerStartupError("timed_out", "codex app-server initialize timed out");
|
|
2212
2383
|
return remaining;
|
|
2213
2384
|
}
|
|
2214
2385
|
function createSharedCodexAppServerClientStartup(params) {
|
|
@@ -2220,6 +2391,7 @@ function createSharedCodexAppServerClientStartup(params) {
|
|
|
2220
2391
|
authProfileId: params.authProfileId,
|
|
2221
2392
|
authProfileStore: params.authProfileStore,
|
|
2222
2393
|
preparedAuth: params.preparedAuth,
|
|
2394
|
+
authRequirement: params.authRequirement,
|
|
2223
2395
|
runtimeArtifactMode: params.runtimeArtifactMode,
|
|
2224
2396
|
...params.expectedRuntimeArtifact ? { expectedRuntimeArtifact: params.expectedRuntimeArtifact } : {},
|
|
2225
2397
|
runtimeArtifactSignal: params.runtimeArtifactSignal,
|
|
@@ -2246,10 +2418,10 @@ function createSharedCodexAppServerClientStartup(params) {
|
|
|
2246
2418
|
}
|
|
2247
2419
|
/** Starts a non-shared Codex app-server client owned entirely by the caller. */
|
|
2248
2420
|
async function createIsolatedCodexAppServerClient(options) {
|
|
2249
|
-
if (options?.abandonSignal?.aborted) throw new
|
|
2421
|
+
if (options?.abandonSignal?.aborted) throw new CodexAppServerStartupError("aborted", "codex app-server initialize aborted");
|
|
2250
2422
|
const acquireStartedAt = Date.now();
|
|
2251
2423
|
const timeoutMs = options?.timeoutMs ?? 0;
|
|
2252
|
-
const { agentDir, usesNativeAuth, authProfileId, authProfileStore, preparedAuth, requestedStartOptions, startOptions } = await withCodexAppServerAcquireDeadline(timeoutMs, resolveCodexAppServerClientStartContext(options), options?.abandonSignal);
|
|
2424
|
+
const { agentDir, usesNativeAuth, authProfileId, authProfileStore, preparedAuth, authRequirement, requestedStartOptions, startOptions } = await withCodexAppServerAcquireDeadline(timeoutMs, resolveCodexAppServerClientStartContext(options), options?.abandonSignal);
|
|
2253
2425
|
return await startInitializedCodexAppServerClient({
|
|
2254
2426
|
requestedStartOptions,
|
|
2255
2427
|
startOptions,
|
|
@@ -2257,6 +2429,7 @@ async function createIsolatedCodexAppServerClient(options) {
|
|
|
2257
2429
|
authProfileId: usesNativeAuth || preparedAuth?.kind === "api-key" ? null : authProfileId,
|
|
2258
2430
|
authProfileStore,
|
|
2259
2431
|
preparedAuth,
|
|
2432
|
+
authRequirement,
|
|
2260
2433
|
runtimeArtifactMode: options?.runtimeArtifactMode ?? (options?.expectedRuntimeArtifact ? "capture" : void 0),
|
|
2261
2434
|
...options?.expectedRuntimeArtifact ? { expectedRuntimeArtifact: options.expectedRuntimeArtifact } : {},
|
|
2262
2435
|
runtimeArtifactSignal: options?.abandonSignal,
|
|
@@ -2324,6 +2497,7 @@ async function startInitializedCodexAppServerClient(params) {
|
|
|
2324
2497
|
agentDir: params.agentDir,
|
|
2325
2498
|
authProfileId: params.authProfileId,
|
|
2326
2499
|
preparedAuth: params.preparedAuth,
|
|
2500
|
+
authRequirement: params.authRequirement,
|
|
2327
2501
|
startOptions,
|
|
2328
2502
|
config: params.config,
|
|
2329
2503
|
...params.authProfileStore ? { authProfileStore: params.authProfileStore } : {}
|
|
@@ -2550,4 +2724,4 @@ function collectSharedClients(state) {
|
|
|
2550
2724
|
return [...new Set([...state.clients.values()].map((entry) => entry.client).filter((client) => Boolean(client)))];
|
|
2551
2725
|
}
|
|
2552
2726
|
//#endregion
|
|
2553
|
-
export {
|
|
2727
|
+
export { isCodexAppServerStartupError as A, isCodexAppServerApprovalRequest as B, resolveCodexAppServerFallbackApiKeyCacheKey as C, resolveCodexAppServerHomeDir as D, resolveFirstExistingMacOSDesktopCodexBundledMarketplacePath as E, resolveCodexTurnCompletionIdleTimeoutMs as F, isCodexAppServerPrewriteRequestCancellationError as G, isCodexAppServerConnectionClosedError as H, resolveCodexTurnTerminalIdleTimeoutMs as I, CODEX_INTERACTIVE_THREAD_SOURCE_KINDS as J, isCodexAppServerRequestTimeoutError as K, withCodexStartupTimeout as L, resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs as M, resolveCodexStartupTimeoutMs as N, CODEX_POST_REASONING_REPLY_IDLE_TIMEOUT_MS as O, resolveCodexTurnAssistantCompletionIdleTimeoutMs as P, CodexAppServerRpcError as R, resolveCodexAppServerAuthProfileIdForAgent as S, resolveCodexAppServerPreparedAuthHandoff as T, isCodexAppServerIndeterminateRequestCancellationError as U, isCodexAppServerBrokenPipeError as V, isCodexAppServerIndeterminateTransportError as W, flattenCodexDynamicToolFunctions as X, CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE as Y, isJsonObject$1 as Z, readCodexRateLimitsRevision as _, getLeasedSharedCodexAppServerClient as a, resolveCodexAppServerAuthAccountCacheKey as b, releaseLeasedSharedCodexAppServerClient as c, retireSharedCodexAppServerClientIfCurrent as d, shared_client_exports as f, ensureCodexAppServerClientRuntime as g, acquireCodexNativeConfigFence as h, createIsolatedCodexAppServerClient as i, resolveCodexGatewayTimeoutWithGraceMs as j, CodexAppServerStartupError as k, resolveCodexNativeConfigFenceKey as l, withTimeout$1 as m, clearSharedCodexAppServerClientIfCurrentAndUnclaimed as n, isCodexAppServerStartSelectionChangedError as o, withLeasedCodexAppServerClientStartSelectionRetry as p, CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES as q, clearSharedCodexAppServerClientIfCurrentAndWait as r, releaseCodexAppServerClientLease as s, clearSharedCodexAppServerClientIfCurrent as t, retainSharedCodexAppServerClientIfCurrent as u, readRecentCodexRateLimits as v, resolveCodexAppServerPreparedApiKeyCacheKey as w, resolveCodexAppServerAuthProfileId as x, rememberCodexRateLimitsRead as y, getCodexAppServerClientInstanceId as z };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { n as formatCodexUsageLimitErrorMessage } from "./rate-limits-Dhp04Rqo.js";
|
|
8
|
-
import { readCodexSupportedReasoningEfforts } from "./provider.js";
|
|
9
|
-
import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-DVcxdse_.js";
|
|
1
|
+
import { B as isCodexAppServerApprovalRequest, T as resolveCodexAppServerPreparedAuthHandoff, Z as isJsonObject, a as getLeasedSharedCodexAppServerClient, g as ensureCodexAppServerClientRuntime, p as withLeasedCodexAppServerClientStartSelectionRetry, s as releaseCodexAppServerClientLease, v as readRecentCodexRateLimits } from "./shared-client-JiAnW6pc.js";
|
|
2
|
+
import { D as resolveOpenClawExecPolicyForCodexAppServer, O as shouldAutoApproveCodexAppServerApprovals, c as sessionBindingIdentity, p as canUseCodexModelBackedApprovalsReviewerForModel, w as resolveCodexModelBackedReviewerPolicyContext, y as readCodexPluginConfig } from "./session-binding-h1mmCGnl.js";
|
|
3
|
+
import { f as assertCodexTurnStartResponse, g as readCodexTurn, l as assertCodexThreadForkResponse, p as readCodexDynamicToolCallParams } from "./transcript-mirror-D9rTxx2P.js";
|
|
4
|
+
import { E as resolveCodexDynamicToolsLoading, J as mergeCodexThreadConfigs, W as buildCodexPluginAppsConfigPatchFromPolicyContext, _ as resolveCodexBindingModelProviderFallback, d as resolveCodexWebSearchPlan, h as resolveCodexAppServerRequestModelSelection, l as buildCodexRuntimeThreadConfig, m as resolveCodexAppServerModelProvider, p as CODEX_NATIVE_PERSONALITY_NONE, v as resolveReasoningEffort, x as filterCodexDynamicTools, y as readCodexSupportedReasoningEfforts } from "./thread-lifecycle-CN_pPtPh.js";
|
|
5
|
+
import { n as formatCodexUsageLimitErrorMessage } from "./rate-limits-DyXaYAxU.js";
|
|
6
|
+
import { t as resolveCodexAppServerForModelProvider } from "./app-server-policy-Scc-Wevo.js";
|
|
10
7
|
import { n as resolveCodexNativeExecutionBlock } from "./sandbox-guard-D1Wky__S.js";
|
|
11
|
-
import { a as resolveCodexBindingAppServerConnection, i as requireCodexSupervisionModelSelection, n as readCodexNotificationThreadId, r as readCodexNotificationTurnId } from "./notification-correlation-
|
|
12
|
-
import { A as
|
|
8
|
+
import { a as resolveCodexBindingAppServerConnection, i as requireCodexSupervisionModelSelection, n as readCodexNotificationThreadId, r as readCodexNotificationTurnId } from "./notification-correlation-KmfV4EkP.js";
|
|
9
|
+
import { A as CODEX_NATIVE_HOOK_RELAY_EVENTS, F as emitCodexNativePreToolUseFailureDiagnostic, M as buildCodexNativeHookRelayConfig, N as buildCodexNativeHookRelayDisabledConfig, S as filterToolsForVisionInputs, U as resolveDynamicToolCallTimeoutMs, Y as resolveCodexToolAbortTerminalReason, _ as resolveCodexMessageToolProvider, a as emitDynamicToolStartedDiagnostic, c as resolveCodexProviderWebSearchSupportForClient, i as emitDynamicToolErrorDiagnostic, k as CodexNativeToolLifecycleProjector, n as handleCodexAppServerApprovalRequest, o as emitDynamicToolTerminalDiagnostic, r as handleCodexAppServerElicitationRequest, t as createCodexDynamicToolBridge, y as shouldEnableCodexAppServerNativeToolSurface, z as handleDynamicToolCallWithTimeout } from "./dynamic-tools-C_1tEs34.js";
|
|
13
10
|
import { randomUUID } from "node:crypto";
|
|
14
11
|
import { loadExecApprovals } from "openclaw/plugin-sdk/exec-approvals-runtime";
|
|
15
12
|
import { buildAgentHookContextChannelFields, embeddedAgentLog, formatErrorMessage, registerNativeHookRelay, resolveAgentDir, resolveAttemptSpawnWorkspaceDir, resolveModelAuthMode, resolveSandboxContext, resolveSessionAgentIds, supportsModelTools } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
@@ -161,6 +158,7 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
161
158
|
const clientOptions = {
|
|
162
159
|
startOptions: appServer.start,
|
|
163
160
|
timeoutMs: appServer.requestTimeoutMs,
|
|
161
|
+
authRequirement: preparedRuntimeAuth.plan.modelRoute?.authRequirement,
|
|
164
162
|
...startupPreparedAuth ? { preparedAuth: startupPreparedAuth } : { authProfileId: connection.clientAuthProfileId },
|
|
165
163
|
agentDir: params.agentDir,
|
|
166
164
|
config: params.cfg,
|
|
@@ -306,7 +304,8 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
306
304
|
call,
|
|
307
305
|
toolBridge,
|
|
308
306
|
signal: runAbortController.signal,
|
|
309
|
-
timeoutMs
|
|
307
|
+
timeoutMs,
|
|
308
|
+
observeToolTerminal: sideRunParams.observeToolTerminal
|
|
310
309
|
});
|
|
311
310
|
emitDynamicToolTerminalDiagnostic({
|
|
312
311
|
...diagnosticContext,
|
|
@@ -360,6 +359,7 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
360
359
|
}).channelId,
|
|
361
360
|
requestTimeoutMs: appServer.requestTimeoutMs,
|
|
362
361
|
completionTimeoutMs: Math.max(appServer.turnCompletionIdleTimeoutMs, SIDE_QUESTION_COMPLETION_TIMEOUT_MS),
|
|
362
|
+
loopDetectionPreToolUseRelay: appServer.loopDetectionPreToolUseRelay,
|
|
363
363
|
signal: runAbortController.signal,
|
|
364
364
|
onPreToolUseFailure: (failure) => {
|
|
365
365
|
if (nativePreToolUseFailureFallbackActive) emitNativePreToolUseFailure(failure);
|
|
@@ -371,7 +371,8 @@ async function runCodexAppServerSideQuestion(params, options) {
|
|
|
371
371
|
relay: nativeHookRelay,
|
|
372
372
|
events: nativeHookRelayEvents,
|
|
373
373
|
hookTimeoutSec: options.nativeHookRelay?.hookTimeoutSec,
|
|
374
|
-
clearOmittedEvents: true
|
|
374
|
+
clearOmittedEvents: true,
|
|
375
|
+
loopDetectionPreToolUseRelay: appServer.loopDetectionPreToolUseRelay
|
|
375
376
|
}) : options.nativeHookRelay?.enabled === false ? buildCodexNativeHookRelayDisabledConfig() : void 0;
|
|
376
377
|
const runtimeThreadConfig = buildCodexRuntimeThreadConfig(webSearchPlan.threadConfig, {
|
|
377
378
|
nativeCodeModeEnabled: nativeToolSurfaceEnabled,
|
|
@@ -500,6 +501,7 @@ function registerCodexSideNativeHookRelay(params) {
|
|
|
500
501
|
runId: params.runId,
|
|
501
502
|
...params.channelId ? { channelId: params.channelId } : {},
|
|
502
503
|
allowedEvents: params.events,
|
|
504
|
+
preToolUseLoopDetection: params.loopDetectionPreToolUseRelay,
|
|
503
505
|
ttlMs: resolveCodexSideNativeHookRelayTtlMs({
|
|
504
506
|
explicitTtlMs: params.options.ttlMs,
|
|
505
507
|
requestTimeoutMs: params.requestTimeoutMs,
|