@openclaw/codex 2026.8.1-beta.3 → 2026.8.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/dist/api.js +5 -6
- package/dist/{attempt-client-cleanup-URjUlCHg.js → attempt-client-cleanup-CpVfwctT.js} +47 -5
- package/dist/{auth-binding-B4FfbcCg.js → auth-binding-Ds_QVm-X.js} +18 -3
- package/dist/{binding-connection-DAvZwp96.js → binding-connection-CF7BmrDk.js} +2 -2
- package/dist/{bounded-turn-4BjrZEwW.js → bounded-turn-DRC3hcjm.js} +16 -20
- package/dist/{capabilities-CH3K57v4.js → capabilities-D6m_TdVy.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/{command-formatters-D0nZ3qtd.js → command-formatters--UToCokS.js} +4 -3
- package/dist/{command-handlers-DC86lgT4.js → command-handlers-CLFx2Ypa.js} +114 -79
- package/dist/{compact-COqgBRny.js → compact-5xqW1oCh.js} +13 -12
- package/dist/{config-CpNeo5AE.js → config-CcYL77O6.js} +350 -288
- package/dist/{conversation-binding-data-CW2GuupV.js → conversation-binding-data-BiodpIzq.js} +2 -1
- package/dist/doctor-contract-api.js +121 -16
- package/dist/{dynamic-tools-fJZhl4CE.js → dynamic-tools-BmeXjwNZ.js} +243 -1002
- package/dist/{effective-mcp-catalog-4YKn51aG.js → effective-mcp-catalog-XXQKgK1U.js} +2 -2
- package/dist/{event-projector-assistant-message-BwxV4d6N.js → event-projector-assistant-message-C5-Ds8mA.js} +18 -1
- package/dist/{event-projector-usage-CLwNEJqW.js → event-projector-usage-B2r5vhWH.js} +9 -14
- package/dist/{harness-DoKQcF8n.js → harness-BgeB7LnD.js} +42 -52
- package/dist/harness.js +1 -1
- package/dist/index.js +308 -306
- package/dist/{isolated-completion-DPMtlH9r.js → isolated-completion-CxTus3vZ.js} +4 -4
- package/dist/launch-args-sXOAg0SX.js +84 -0
- package/dist/{managed-binary-By4FZC6i.js → managed-binary-ZkGodW19.js} +43 -7
- package/dist/media-understanding-provider.js +1 -1
- package/dist/model-catalog-DULBcniB.js +101 -0
- package/dist/{models-CZw1wClT.js → models-DaWfETQk.js} +27 -29
- package/dist/{native-subagent-monitor-GGq3RnOo.js → native-subagent-monitor-vXYUZH37.js} +226 -129
- package/dist/{node-exec-server.runtime-Bsu1LdFZ.js → node-exec-server.runtime-DirKVZ5h.js} +9 -6
- package/dist/{plugin-approval-roundtrip-C75Yiiwc.js → plugin-approval-roundtrip-CCWQGlAI.js} +2 -1
- package/dist/{plugin-marketplace-discovery-CSWDkMrP.js → plugin-marketplace-discovery-BXjIFEiw.js} +38 -46
- package/dist/{plugin-metadata-cache-BXH5NF-4.js → plugin-metadata-cache-DQQm4gWT.js} +163 -136
- package/dist/{protocol-validators-VAVyEnDp.js → protocol-validators-Bg5rpNxk.js} +148 -5
- package/dist/{rate-limits-BI1dMHDG.js → rate-limits-BqHEHXQJ.js} +3 -2
- package/dist/{sandbox-guard-C1qEeZ5C.js → request-BWxweEdK.js} +183 -2
- package/dist/{run-attempt-BV3HzuCf.js → run-attempt-BVLE4Gbi.js} +706 -517
- package/dist/{runtime-artifact-BvyT1uyd.js → runtime-artifact-D9pYp4zL.js} +3 -3
- package/dist/{session-binding-BTrLf9Qm.js → session-binding-D0zinCP1.js} +195 -122
- package/dist/{session-catalog-ezP_UcRM.js → session-catalog-eMhVm0Ql.js} +448 -313
- package/dist/session-catalog-home-id-Dt2GiG5o.js +112 -0
- package/dist/{session-cli-B1hKvfkI.js → session-cli-B2lyjJA0.js} +1 -1
- package/dist/session-history-C5J1AKzG.js +87 -0
- package/dist/session-permission-policy-ScnAyG90.js +160 -0
- package/dist/session-retirement-CtUtUTr9.js +90 -0
- package/dist/{session-upstream-marker-D_2npHlA.js → session-upstream-marker-gqrYIRHk.js} +2 -3
- package/dist/settled-turn-context-Bk3IUwod.js +290 -0
- package/dist/settled-turn-finalizer-BXLN9PfJ.js +104 -0
- package/dist/{shared-client-Dw-rzii0.js → shared-client-B1tT5U6r.js} +1738 -806
- package/dist/{side-question-DbXkJZzg.js → side-question-CZ-mCw-t.js} +76 -43
- package/dist/{thread-lifecycle-DKdrnTMX.js → thread-lifecycle-CGGKP720.js} +991 -455
- package/dist/{thread-ownership-i2NBwDUL.js → thread-ownership-RkaoZCmQ.js} +18 -8
- package/dist/{plugin-app-cache-key-DMNQ8Zi8.js → thread-resume-BFt1-ZDa.js} +55 -8
- package/dist/{transcript-mirror-BU0_LKAL.js → transcript-mirror-1ep4XjzF.js} +124 -18
- package/dist/transport-stdio-NT_Dpd9V.js +724 -0
- package/dist/{upstream-prompt-provenance-CFmsKwr9.js → upstream-prompt-provenance-LphB8slG.js} +8 -4
- package/dist/{upstream-session-fork-BDVJCLAD.js → upstream-session-fork-Dc8BFExw.js} +76 -90
- package/dist/{usage-9dKJCgcy.js → usage-DUhd58gI.js} +3 -3
- package/dist/{web-search-provider.runtime-DCdx4DGu.js → web-search-provider.runtime-BEmlE7ov.js} +3 -3
- package/openclaw.plugin.json +19 -1
- package/package.json +8 -8
- package/dist/app-server-policy-bg5QPSVP.js +0 -25
- package/dist/command-rpc-xUIIonsO.js +0 -90
- package/dist/incognito-session-ET_ufDH-.js +0 -2
- package/dist/model-catalog-CmGoqVKB.js +0 -48
- package/dist/request-DSK0W6YI.js +0 -157
- package/dist/session-catalog-home-id-BNwAJ9D7.js +0 -18
- package/dist/session-retirement-CE4iMiLh.js +0 -36
- package/dist/settled-turn-finalizer-Dx1onIqg.js +0 -328
- package/dist/thread-resume-CdJk2Ehf.js +0 -30
- package/dist/transport-stdio-DhoGy33Z.js +0 -99
|
@@ -89,6 +89,10 @@ var definitions = {
|
|
|
89
89
|
"required": ["id"],
|
|
90
90
|
"type": "object"
|
|
91
91
|
},
|
|
92
|
+
"AgentMessageDelivery": {
|
|
93
|
+
"enum": ["async"],
|
|
94
|
+
"type": "string"
|
|
95
|
+
},
|
|
92
96
|
"AgentPath": { "type": "string" },
|
|
93
97
|
"ApprovalsReviewer": {
|
|
94
98
|
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
|
|
@@ -228,6 +232,7 @@ var definitions = {
|
|
|
228
232
|
"contextWindowExceeded",
|
|
229
233
|
"sessionBudgetExceeded",
|
|
230
234
|
"usageLimitExceeded",
|
|
235
|
+
"rateLimitExceeded",
|
|
231
236
|
"serverOverloaded",
|
|
232
237
|
"cyberPolicy",
|
|
233
238
|
"misalignmentPolicyViolation",
|
|
@@ -268,7 +273,11 @@ var definitions = {
|
|
|
268
273
|
"sendInput",
|
|
269
274
|
"resumeAgent",
|
|
270
275
|
"wait",
|
|
271
|
-
"closeAgent"
|
|
276
|
+
"closeAgent",
|
|
277
|
+
"sendMessage",
|
|
278
|
+
"followupTask",
|
|
279
|
+
"interruptAgent",
|
|
280
|
+
"listAgents"
|
|
272
281
|
],
|
|
273
282
|
"type": "string"
|
|
274
283
|
},
|
|
@@ -276,7 +285,8 @@ var definitions = {
|
|
|
276
285
|
"enum": [
|
|
277
286
|
"inProgress",
|
|
278
287
|
"completed",
|
|
279
|
-
"failed"
|
|
288
|
+
"failed",
|
|
289
|
+
"interrupted"
|
|
280
290
|
],
|
|
281
291
|
"type": "string"
|
|
282
292
|
},
|
|
@@ -424,6 +434,68 @@ var definitions = {
|
|
|
424
434
|
],
|
|
425
435
|
"type": "object"
|
|
426
436
|
},
|
|
437
|
+
"FunctionCallOutputBody": { "anyOf": [{
|
|
438
|
+
"items": { "$ref": "#/definitions/FunctionCallOutputContentItem" },
|
|
439
|
+
"type": "array"
|
|
440
|
+
}, { "type": "string" }] },
|
|
441
|
+
"FunctionCallOutputContentItem": {
|
|
442
|
+
"description": "Responses API compatible content items that can be returned by a tool call. This is a subset of ContentItem with the types we support as function call outputs.",
|
|
443
|
+
"oneOf": [
|
|
444
|
+
{
|
|
445
|
+
"properties": {
|
|
446
|
+
"text": { "type": "string" },
|
|
447
|
+
"type": {
|
|
448
|
+
"enum": ["input_text"],
|
|
449
|
+
"title": "InputTextFunctionCallOutputContentItemType",
|
|
450
|
+
"type": "string"
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
"required": ["text", "type"],
|
|
454
|
+
"title": "InputTextFunctionCallOutputContentItem",
|
|
455
|
+
"type": "object"
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
"properties": {
|
|
459
|
+
"detail": { "anyOf": [{ "$ref": "#/definitions/ImageDetail" }, { "type": "null" }] },
|
|
460
|
+
"image_url": { "type": "string" },
|
|
461
|
+
"type": {
|
|
462
|
+
"enum": ["input_image"],
|
|
463
|
+
"title": "InputImageFunctionCallOutputContentItemType",
|
|
464
|
+
"type": "string"
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
"required": ["image_url", "type"],
|
|
468
|
+
"title": "InputImageFunctionCallOutputContentItem",
|
|
469
|
+
"type": "object"
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
"properties": {
|
|
473
|
+
"audio_url": { "type": "string" },
|
|
474
|
+
"type": {
|
|
475
|
+
"enum": ["input_audio"],
|
|
476
|
+
"title": "InputAudioFunctionCallOutputContentItemType",
|
|
477
|
+
"type": "string"
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
"required": ["audio_url", "type"],
|
|
481
|
+
"title": "InputAudioFunctionCallOutputContentItem",
|
|
482
|
+
"type": "object"
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
"properties": {
|
|
486
|
+
"encrypted_content": { "type": "string" },
|
|
487
|
+
"type": {
|
|
488
|
+
"enum": ["encrypted_content"],
|
|
489
|
+
"title": "EncryptedContentFunctionCallOutputContentItemType",
|
|
490
|
+
"type": "string"
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
"required": ["encrypted_content", "type"],
|
|
494
|
+
"title": "EncryptedContentFunctionCallOutputContentItem",
|
|
495
|
+
"type": "object"
|
|
496
|
+
}
|
|
497
|
+
]
|
|
498
|
+
},
|
|
427
499
|
"GitInfo": {
|
|
428
500
|
"properties": {
|
|
429
501
|
"branch": { "type": ["string", "null"] },
|
|
@@ -572,6 +644,28 @@ var definitions = {
|
|
|
572
644
|
"type": "string"
|
|
573
645
|
}]
|
|
574
646
|
},
|
|
647
|
+
"MisalignmentErrorDetails": {
|
|
648
|
+
"properties": {
|
|
649
|
+
"detailedExplanation": {
|
|
650
|
+
"description": "A substantive localized explanation is required before offering continuation.",
|
|
651
|
+
"type": ["string", "null"]
|
|
652
|
+
},
|
|
653
|
+
"errorType": {
|
|
654
|
+
"description": "Open-ended classification; clients must accept categories added by Responses.",
|
|
655
|
+
"type": ["string", "null"]
|
|
656
|
+
},
|
|
657
|
+
"steer": {
|
|
658
|
+
"anyOf": [{ "$ref": "#/definitions/MisalignmentSteer" }, { "type": "null" }],
|
|
659
|
+
"description": "Instruction to submit as the next turn's user input if continuation is confirmed."
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
"type": "object"
|
|
663
|
+
},
|
|
664
|
+
"MisalignmentSteer": {
|
|
665
|
+
"properties": { "message": { "type": "string" } },
|
|
666
|
+
"required": ["message"],
|
|
667
|
+
"type": "object"
|
|
668
|
+
},
|
|
575
669
|
"Model": {
|
|
576
670
|
"properties": {
|
|
577
671
|
"additionalSpeedTiers": {
|
|
@@ -757,6 +851,8 @@ var definitions = {
|
|
|
757
851
|
"enterprise_cbp_usage_based",
|
|
758
852
|
"enterprise",
|
|
759
853
|
"edu",
|
|
854
|
+
"edu_plus",
|
|
855
|
+
"edu_pro",
|
|
760
856
|
"unknown"
|
|
761
857
|
],
|
|
762
858
|
"type": "string"
|
|
@@ -877,7 +973,8 @@ var definitions = {
|
|
|
877
973
|
"enum": [
|
|
878
974
|
"started",
|
|
879
975
|
"interacted",
|
|
880
|
-
"interrupted"
|
|
976
|
+
"interrupted",
|
|
977
|
+
"completed"
|
|
881
978
|
],
|
|
882
979
|
"type": "string"
|
|
883
980
|
},
|
|
@@ -1013,6 +1110,10 @@ var definitions = {
|
|
|
1013
1110
|
"description": "Usually the first user message in the thread, if available.",
|
|
1014
1111
|
"type": "string"
|
|
1015
1112
|
},
|
|
1113
|
+
"projectId": {
|
|
1114
|
+
"description": "Canonical project assignment owned by app-server, if any.",
|
|
1115
|
+
"type": ["string", "null"]
|
|
1116
|
+
},
|
|
1016
1117
|
"recencyAt": {
|
|
1017
1118
|
"description": "Unix timestamp (in seconds) used for thread recency ordering.",
|
|
1018
1119
|
"format": "int64",
|
|
@@ -1064,6 +1165,7 @@ var definitions = {
|
|
|
1064
1165
|
"id",
|
|
1065
1166
|
"modelProvider",
|
|
1066
1167
|
"preview",
|
|
1168
|
+
"projectId",
|
|
1067
1169
|
"sessionId",
|
|
1068
1170
|
"source",
|
|
1069
1171
|
"status",
|
|
@@ -1131,6 +1233,10 @@ var definitions = {
|
|
|
1131
1233
|
},
|
|
1132
1234
|
{
|
|
1133
1235
|
"properties": {
|
|
1236
|
+
"delivery": {
|
|
1237
|
+
"anyOf": [{ "$ref": "#/definitions/AgentMessageDelivery" }, { "type": "null" }],
|
|
1238
|
+
"default": null
|
|
1239
|
+
},
|
|
1134
1240
|
"id": { "type": "string" },
|
|
1135
1241
|
"memoryCitation": {
|
|
1136
1242
|
"anyOf": [{ "$ref": "#/definitions/MemoryCitation" }, { "type": "null" }],
|
|
@@ -1155,6 +1261,27 @@ var definitions = {
|
|
|
1155
1261
|
"title": "AgentMessageThreadItem",
|
|
1156
1262
|
"type": "object"
|
|
1157
1263
|
},
|
|
1264
|
+
{
|
|
1265
|
+
"properties": {
|
|
1266
|
+
"id": { "type": "string" },
|
|
1267
|
+
"name": { "type": "string" },
|
|
1268
|
+
"namespace": { "type": ["string", "null"] },
|
|
1269
|
+
"output": { "$ref": "#/definitions/FunctionCallOutputBody" },
|
|
1270
|
+
"type": {
|
|
1271
|
+
"enum": ["functionCallOutput"],
|
|
1272
|
+
"title": "FunctionCallOutputThreadItemType",
|
|
1273
|
+
"type": "string"
|
|
1274
|
+
}
|
|
1275
|
+
},
|
|
1276
|
+
"required": [
|
|
1277
|
+
"id",
|
|
1278
|
+
"name",
|
|
1279
|
+
"output",
|
|
1280
|
+
"type"
|
|
1281
|
+
],
|
|
1282
|
+
"title": "FunctionCallOutputThreadItem",
|
|
1283
|
+
"type": "object"
|
|
1284
|
+
},
|
|
1158
1285
|
{
|
|
1159
1286
|
"description": "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
|
|
1160
1287
|
"properties": {
|
|
@@ -1711,7 +1838,12 @@ var definitions = {
|
|
|
1711
1838
|
"type": ["string", "null"]
|
|
1712
1839
|
},
|
|
1713
1840
|
"codexErrorInfo": { "anyOf": [{ "$ref": "#/definitions/CodexErrorInfo" }, { "type": "null" }] },
|
|
1714
|
-
"message": { "type": "string" }
|
|
1841
|
+
"message": { "type": "string" },
|
|
1842
|
+
"misalignment": {
|
|
1843
|
+
"anyOf": [{ "$ref": "#/definitions/MisalignmentErrorDetails" }, { "type": "null" }],
|
|
1844
|
+
"default": null,
|
|
1845
|
+
"description": "Optional public explanation and continuation instruction for a misalignment block."
|
|
1846
|
+
}
|
|
1715
1847
|
},
|
|
1716
1848
|
"required": ["message"],
|
|
1717
1849
|
"type": "object"
|
|
@@ -2301,6 +2433,16 @@ function assertCodexThreadResumeResponse(value) {
|
|
|
2301
2433
|
const normalized = normalizeWithDefaults(threadResumeResponseSchema, value);
|
|
2302
2434
|
return assertCodexShape(validateThreadResumeResponse, normalized, "thread/resume response");
|
|
2303
2435
|
}
|
|
2436
|
+
var CodexThreadDirectInputError = class extends Error {
|
|
2437
|
+
constructor(threadId) {
|
|
2438
|
+
super(`Codex thread ${threadId} is controlled by its parent and cannot accept direct input. Continue its parent thread, or use /new for a separate OpenClaw session.`);
|
|
2439
|
+
this.name = "CodexThreadDirectInputError";
|
|
2440
|
+
}
|
|
2441
|
+
};
|
|
2442
|
+
/** Native V2 children allow observation, but only their parent may supply turn input. */
|
|
2443
|
+
function assertCodexThreadAcceptsDirectInput(thread) {
|
|
2444
|
+
if (thread.canAcceptDirectInput === false) throw new CodexThreadDirectInputError(thread.id);
|
|
2445
|
+
}
|
|
2304
2446
|
/** Asserts and normalizes a Codex turn/start response. */
|
|
2305
2447
|
function assertCodexTurnStartResponse(value) {
|
|
2306
2448
|
const normalized = normalizeWithDefaults(turnStartResponseSchema, normalizeTurnStartResponse(value));
|
|
@@ -2349,6 +2491,7 @@ function normalizeThreadItem(value) {
|
|
|
2349
2491
|
switch (value.type) {
|
|
2350
2492
|
case "agentMessage": return {
|
|
2351
2493
|
phase: null,
|
|
2494
|
+
delivery: null,
|
|
2352
2495
|
memoryCitation: null,
|
|
2353
2496
|
...value
|
|
2354
2497
|
};
|
|
@@ -2396,4 +2539,4 @@ function formatValidationErrors(validate, value) {
|
|
|
2396
2539
|
}).join("; ");
|
|
2397
2540
|
}
|
|
2398
2541
|
//#endregion
|
|
2399
|
-
export {
|
|
2542
|
+
export { assertCodexThreadForkResponse as a, assertCodexTurnStartResponse as c, readCodexTurn as d, readCodexTurnCompletedNotification as f, assertCodexThreadForkParams as i, readCodexDynamicToolCallParams as l, assertCodexModelListResponse as n, assertCodexThreadResumeResponse as o, assertCodexThreadAcceptsDirectInput as r, assertCodexThreadStartResponse as s, CodexThreadDirectInputError as t, readCodexErrorNotification as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ht as isJsonObject } from "./shared-client-B1tT5U6r.js";
|
|
2
2
|
import { asBoolean, asFiniteNumber, normalizeOptionalString, parseStrictFiniteNumber } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { MAX_DATE_TIMESTAMP_MS, resolveExpiresAtMsFromEpochSeconds } from "openclaw/plugin-sdk/number-runtime";
|
|
4
4
|
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
@@ -186,8 +186,9 @@ function isRateLimitSnapshot(value) {
|
|
|
186
186
|
function readRateLimitWindow(snapshot, key) {
|
|
187
187
|
const window = snapshot[key];
|
|
188
188
|
if (!isJsonObject(window)) return;
|
|
189
|
+
const resetsAt = asFiniteNumber(window.resetsAt) ?? asFiniteNumber(window.resets_at);
|
|
189
190
|
return {
|
|
190
|
-
resetsAtMs: resolveExpiresAtMsFromEpochSeconds(
|
|
191
|
+
resetsAtMs: resolveExpiresAtMsFromEpochSeconds(resetsAt, { maxMs: MAX_DATE_TIMESTAMP_MS }) ?? 0,
|
|
191
192
|
...readOptionalNumberField(window, "usedPercent", "used_percent"),
|
|
192
193
|
...readOptionalNumberField(window, "windowDurationMins", "window_duration_mins", "windowMinutes", "window_minutes")
|
|
193
194
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { C as isCodexRemoteExecPlacementSandbox } from "./config-CcYL77O6.js";
|
|
3
|
+
import { Et as withTimeout, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient, s as createIsolatedCodexAppServerClient, u as isCodexAppServerStartSelectionChangedError, y as retireSharedCodexAppServerClientIfCurrent } from "./shared-client-B1tT5U6r.js";
|
|
2
4
|
import { resolveAgentConfig, tryResolveDefaultAgentId } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
3
5
|
import { getSessionEntry } from "openclaw/plugin-sdk/session-store-runtime";
|
|
4
6
|
import { normalizeAgentId, parseAgentSessionKey } from "openclaw/plugin-sdk/routing";
|
|
@@ -279,4 +281,183 @@ function resolveCodexNativeNodeExecBlock(params) {
|
|
|
279
281
|
});
|
|
280
282
|
}
|
|
281
283
|
//#endregion
|
|
282
|
-
|
|
284
|
+
//#region extensions/codex/src/app-server/request.ts
|
|
285
|
+
var request_exports = /* @__PURE__ */ __exportAll({
|
|
286
|
+
CodexAppServerScopedRequestRejectedError: () => CodexAppServerScopedRequestRejectedError,
|
|
287
|
+
readCodexAppServerUsage: () => readCodexAppServerUsage,
|
|
288
|
+
requestCodexAppServerClientJson: () => requestCodexAppServerClientJson,
|
|
289
|
+
requestCodexAppServerJson: () => requestCodexAppServerJson,
|
|
290
|
+
withCodexAppServerJsonClient: () => withCodexAppServerJsonClient
|
|
291
|
+
});
|
|
292
|
+
/** Sends one guarded request over a client lease owned by the caller. */
|
|
293
|
+
async function requestCodexAppServerClientJson(params) {
|
|
294
|
+
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
295
|
+
method: params.method,
|
|
296
|
+
requestParams: params.requestParams,
|
|
297
|
+
config: params.config,
|
|
298
|
+
sessionKey: params.sessionKey,
|
|
299
|
+
sessionId: params.sessionId
|
|
300
|
+
});
|
|
301
|
+
if (sandboxBlock) throw new Error(sandboxBlock);
|
|
302
|
+
const timeoutMs = params.timeoutMs ?? 6e4;
|
|
303
|
+
return await withTimeout(params.client.request(params.method, params.requestParams, { timeoutMs }), timeoutMs, `codex app-server ${params.method} timed out`);
|
|
304
|
+
}
|
|
305
|
+
async function requestCodexAppServerJson(params) {
|
|
306
|
+
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
307
|
+
method: params.method,
|
|
308
|
+
requestParams: params.requestParams,
|
|
309
|
+
config: params.config,
|
|
310
|
+
sessionKey: params.sessionKey,
|
|
311
|
+
sessionId: params.sessionId
|
|
312
|
+
});
|
|
313
|
+
if (sandboxBlock) throw new Error(sandboxBlock);
|
|
314
|
+
return await withCodexAppServerJsonClient({
|
|
315
|
+
...params,
|
|
316
|
+
timeoutMessage: `codex app-server ${params.method} timed out`
|
|
317
|
+
}, async (request) => await request({
|
|
318
|
+
method: params.method,
|
|
319
|
+
requestParams: params.requestParams
|
|
320
|
+
}));
|
|
321
|
+
}
|
|
322
|
+
/** A scoped guard rejected the request before it reached the physical client. */
|
|
323
|
+
var CodexAppServerScopedRequestRejectedError = class extends Error {
|
|
324
|
+
constructor(message) {
|
|
325
|
+
super(message);
|
|
326
|
+
this.name = "CodexAppServerScopedRequestRejectedError";
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
const CODEX_USAGE_ISOLATED_SHUTDOWN = {
|
|
330
|
+
forceKillDelayMs: 200,
|
|
331
|
+
exitTimeoutMs: 300
|
|
332
|
+
};
|
|
333
|
+
const CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS = 4e3;
|
|
334
|
+
const CODEX_USAGE_DEADLINE_RESERVE_MS = CODEX_USAGE_ISOLATED_SHUTDOWN.forceKillDelayMs + CODEX_USAGE_ISOLATED_SHUTDOWN.exitTimeoutMs + 250;
|
|
335
|
+
/** Reads rate limits and best-effort account identity from one isolated app-server session. */
|
|
336
|
+
async function readCodexAppServerUsage(options) {
|
|
337
|
+
const deadline = Date.now() + options.timeoutMs;
|
|
338
|
+
return await withCodexAppServerJsonClient({
|
|
339
|
+
timeoutMs: options.timeoutMs,
|
|
340
|
+
timeoutMessage: "codex app-server usage read timed out",
|
|
341
|
+
agentDir: options.agentDir,
|
|
342
|
+
...options.authProfileId ? { authProfileId: options.authProfileId } : {},
|
|
343
|
+
config: options.config,
|
|
344
|
+
startOptions: options.startOptions,
|
|
345
|
+
isolated: true,
|
|
346
|
+
isolatedShutdown: CODEX_USAGE_ISOLATED_SHUTDOWN
|
|
347
|
+
}, async (request) => {
|
|
348
|
+
const rateLimits = await request({ method: "account/rateLimits/read" });
|
|
349
|
+
const accountEmail = await readCodexAccountEmailBestEffort(request, deadline);
|
|
350
|
+
return {
|
|
351
|
+
rateLimits,
|
|
352
|
+
...accountEmail ? { accountEmail } : {}
|
|
353
|
+
};
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
function extractCodexAccountEmail(value) {
|
|
357
|
+
if (!value || typeof value !== "object") return;
|
|
358
|
+
const record = value;
|
|
359
|
+
const account = record.account && typeof record.account === "object" ? record.account : record;
|
|
360
|
+
const email = account.email ?? account.accountEmail;
|
|
361
|
+
return typeof email === "string" && email.trim() ? email.trim() : void 0;
|
|
362
|
+
}
|
|
363
|
+
async function readCodexAccountEmailBestEffort(request, deadline) {
|
|
364
|
+
const boundMs = Math.min(CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS, deadline - Date.now() - CODEX_USAGE_DEADLINE_RESERVE_MS);
|
|
365
|
+
if (boundMs <= 0) return;
|
|
366
|
+
const read = request({
|
|
367
|
+
method: "account/read",
|
|
368
|
+
requestParams: {}
|
|
369
|
+
}).then((account) => extractCodexAccountEmail(account), () => void 0);
|
|
370
|
+
let timer;
|
|
371
|
+
const timeout = new Promise((resolve) => {
|
|
372
|
+
timer = setTimeout(() => resolve(void 0), boundMs);
|
|
373
|
+
timer.unref?.();
|
|
374
|
+
});
|
|
375
|
+
try {
|
|
376
|
+
return await Promise.race([read, timeout]);
|
|
377
|
+
} finally {
|
|
378
|
+
if (timer) clearTimeout(timer);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Runs several guarded requests over one acquired client (shared lease or
|
|
383
|
+
* isolated child) so related reads see the same app-server session. The whole
|
|
384
|
+
* callback re-runs once when the client's start selection changed underneath it.
|
|
385
|
+
*/
|
|
386
|
+
async function withCodexAppServerJsonClient(params, run) {
|
|
387
|
+
const timeoutMs = params.timeoutMs ?? 6e4;
|
|
388
|
+
const timeoutMessage = params.timeoutMessage ?? "codex app-server request timed out";
|
|
389
|
+
const timeoutController = new AbortController();
|
|
390
|
+
const deadline = Number.isFinite(timeoutMs) && timeoutMs > 0 ? Date.now() + timeoutMs : void 0;
|
|
391
|
+
const isPastDeadline = () => deadline !== void 0 && Date.now() >= deadline;
|
|
392
|
+
const throwIfAbandoned = () => {
|
|
393
|
+
if (timeoutController.signal.aborted || isPastDeadline()) throw new CodexAppServerScopedRequestRejectedError(timeoutMessage);
|
|
394
|
+
};
|
|
395
|
+
const remainingTimeoutMs = () => {
|
|
396
|
+
throwIfAbandoned();
|
|
397
|
+
return deadline === void 0 ? timeoutMs : Math.max(1, deadline - Date.now());
|
|
398
|
+
};
|
|
399
|
+
try {
|
|
400
|
+
return await withTimeout((async () => {
|
|
401
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
402
|
+
throwIfAbandoned();
|
|
403
|
+
const client = await (params.isolated ? createIsolatedCodexAppServerClient : getLeasedSharedCodexAppServerClient)({
|
|
404
|
+
startOptions: params.startOptions,
|
|
405
|
+
pluginConfig: params.pluginConfig,
|
|
406
|
+
timeoutMs: remainingTimeoutMs(),
|
|
407
|
+
authProfileId: params.authProfileId,
|
|
408
|
+
authProfileStore: params.authProfileStore,
|
|
409
|
+
authBindingFingerprint: params.authBindingFingerprint,
|
|
410
|
+
preparedAuth: params.preparedAuth,
|
|
411
|
+
authRequirement: params.authRequirement,
|
|
412
|
+
agentDir: params.agentDir,
|
|
413
|
+
config: params.config,
|
|
414
|
+
abandonSignal: timeoutController.signal
|
|
415
|
+
});
|
|
416
|
+
let scopeActive = true;
|
|
417
|
+
const assertCurrent = () => {
|
|
418
|
+
throwIfAbandoned();
|
|
419
|
+
if (!scopeActive) throw new CodexAppServerScopedRequestRejectedError("Codex app-server request scope is closed");
|
|
420
|
+
};
|
|
421
|
+
try {
|
|
422
|
+
assertCurrent();
|
|
423
|
+
const scopedRequest = async (request) => {
|
|
424
|
+
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
425
|
+
method: request.method,
|
|
426
|
+
requestParams: request.requestParams,
|
|
427
|
+
config: params.config,
|
|
428
|
+
sessionKey: params.sessionKey,
|
|
429
|
+
sessionId: params.sessionId
|
|
430
|
+
});
|
|
431
|
+
if (sandboxBlock) throw new CodexAppServerScopedRequestRejectedError(sandboxBlock);
|
|
432
|
+
assertCurrent();
|
|
433
|
+
return await client.request(request.method, request.requestParams, {
|
|
434
|
+
timeoutMs: remainingTimeoutMs(),
|
|
435
|
+
signal: timeoutController.signal,
|
|
436
|
+
assertCurrent
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
return await run(scopedRequest, client, { assertCurrent });
|
|
440
|
+
} catch (error) {
|
|
441
|
+
if (!isCodexAppServerStartSelectionChangedError(error) || attempt > 0) throw error;
|
|
442
|
+
if (!params.isolated) retireSharedCodexAppServerClientIfCurrent(client);
|
|
443
|
+
throwIfAbandoned();
|
|
444
|
+
} finally {
|
|
445
|
+
scopeActive = false;
|
|
446
|
+
if (params.isolated) await client.closeAndWait({
|
|
447
|
+
exitTimeoutMs: params.isolatedShutdown?.exitTimeoutMs ?? 2e3,
|
|
448
|
+
forceKillDelayMs: params.isolatedShutdown?.forceKillDelayMs ?? 250
|
|
449
|
+
});
|
|
450
|
+
else releaseLeasedSharedCodexAppServerClient(client);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
throw new Error("Codex app-server selection retry loop exited unexpectedly");
|
|
454
|
+
})(), timeoutMs, timeoutMessage);
|
|
455
|
+
} catch (error) {
|
|
456
|
+
if (isPastDeadline()) throw new Error(timeoutMessage, { cause: error });
|
|
457
|
+
throw error;
|
|
458
|
+
} finally {
|
|
459
|
+
timeoutController.abort();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
//#endregion
|
|
463
|
+
export { request_exports as a, resolveCodexNativeSandboxBlock as c, requestCodexAppServerJson as i, resolveCodexNativeExecutionPolicy as l, readCodexAppServerUsage as n, withCodexAppServerJsonClient as o, requestCodexAppServerClientJson as r, resolveCodexNativeExecutionBlock as s, CodexAppServerScopedRequestRejectedError as t, resolveCodexNodeExecToolOverrides as u };
|