@openclaw/codex 2026.8.1-beta.2 → 2026.8.1

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.
Files changed (64) hide show
  1. package/dist/api.js +146 -0
  2. package/dist/{attempt-client-cleanup-DMLXUfa8.js → attempt-client-cleanup-CVPvp9dL.js} +47 -5
  3. package/dist/{auth-binding-B4FfbcCg.js → auth-binding-Ds_QVm-X.js} +18 -3
  4. package/dist/{binding-connection-I5Bo-AsX.js → binding-connection-CCQFs8lf.js} +15 -3
  5. package/dist/{bounded-turn-qgZmzy_4.js → bounded-turn-rq5tiSXk.js} +27 -26
  6. package/dist/{capabilities-CybGI1oz.js → capabilities-CGm_94eL.js} +1 -1
  7. package/dist/cli-metadata.js +1 -1
  8. package/dist/{command-formatters-B1AEz8ZA.js → command-formatters-C54Yg3eA.js} +2 -2
  9. package/dist/{command-handlers-Db8pu_ds.js → command-handlers-BvOAHTrA.js} +111 -67
  10. package/dist/{compact-LspQaGfl.js → compact-Hd7SAc0N.js} +35 -30
  11. package/dist/{session-binding-DPxIvMgE.js → config-Cxw3Cl3k.js} +361 -1161
  12. package/dist/context-compaction-activity-BOeJf7yo.js +58 -0
  13. package/dist/doctor-contract-api.js +128 -26
  14. package/dist/{dynamic-tools-BVdyWkUD.js → dynamic-tools-BFoUcRdx.js} +1341 -1464
  15. package/dist/{effective-mcp-catalog-DIIhAtOZ.js → effective-mcp-catalog-BTJHnDSx.js} +2 -2
  16. package/dist/elicitation-input-DMkeki8d.js +71 -0
  17. package/dist/{event-projector-assistant-message-BwxV4d6N.js → event-projector-assistant-message-C5-Ds8mA.js} +18 -1
  18. package/dist/{event-projector-usage-e5huIQWu.js → event-projector-usage-D3PHFFXh.js} +18 -18
  19. package/dist/harness-DVfUQBlQ.js +248 -0
  20. package/dist/harness.js +2 -226
  21. package/dist/index.js +405 -299
  22. package/dist/{isolated-completion-C58NbL40.js → isolated-completion-Cbbx_5Ed.js} +4 -4
  23. package/dist/launch-args-sXOAg0SX.js +84 -0
  24. package/dist/managed-binary-ZkGodW19.js +248 -0
  25. package/dist/media-understanding-provider.js +2 -2
  26. package/dist/model-catalog-o6Cgjoss.js +101 -0
  27. package/dist/{models-BFlpn1Ex.js → models-DgFWSuxA.js} +25 -28
  28. package/dist/{native-subagent-monitor-DyTGmTUx.js → native-subagent-monitor-CwFyoylz.js} +385 -94
  29. package/dist/node-exec-server.runtime-DXrqpw1c.js +195 -0
  30. package/dist/plugin-approval-roundtrip-D80UZiJ_.js +95 -0
  31. package/dist/{plugin-marketplace-discovery-CzrGJdCR.js → plugin-marketplace-discovery-mdmScYOj.js} +60 -55
  32. package/dist/{plugin-metadata-cache-CNJPj4_b.js → plugin-metadata-cache-CulOABwu.js} +164 -134
  33. package/dist/{protocol-validators-B4F7L8Rf.js → protocol-validators-Bg5rpNxk.js} +203 -7
  34. package/dist/{rate-limits-DZXmOL8-.js → rate-limits-hFtzt2Up.js} +1 -1
  35. package/dist/{sandbox-guard-Cmwc9eIk.js → request-CCm4LaED.js} +207 -20
  36. package/dist/{run-attempt-P8BdxC1I.js → run-attempt-BwNQDH2u.js} +1506 -836
  37. package/dist/{runtime-artifact-BVSPdd6g.js → runtime-artifact-DeBvleJw.js} +4 -7
  38. package/dist/session-binding-q2WSTVmC.js +947 -0
  39. package/dist/{session-catalog-xwNi_SDM.js → session-catalog-C2Tae4rI.js} +1698 -1346
  40. package/dist/session-catalog-home-id-DAKUrm3C.js +112 -0
  41. package/dist/{session-cli-7hgXZDV7.js → session-cli-BuDjm5Ou.js} +20 -7
  42. package/dist/session-permission-policy-gLm40Vtq.js +160 -0
  43. package/dist/session-retirement-CdkI0bvb.js +90 -0
  44. package/dist/{session-upstream-marker-CrIFX06J.js → session-upstream-marker-Bcy33kam.js} +2 -3
  45. package/dist/{settled-turn-finalizer-BRWBO4MO.js → settled-turn-finalizer-B8JJcxCi.js} +27 -22
  46. package/dist/{shared-client-kIBbGjk4.js → shared-client-kNkljY-R.js} +2023 -607
  47. package/dist/{side-question-9HAL26l9.js → side-question-GwD73tX6.js} +109 -57
  48. package/dist/{thread-lifecycle-Bu1BTDXr.js → thread-lifecycle-Ss-uwnC4.js} +1208 -497
  49. package/dist/{thread-ownership-6kOQHlyC.js → thread-ownership-CeYBqg_4.js} +18 -8
  50. package/dist/{plugin-app-cache-key-C3H2CVp6.js → thread-resume-DF54hagX.js} +64 -6
  51. package/dist/{transcript-mirror-B9gGgnJS.js → transcript-mirror-CkEQIna-.js} +158 -41
  52. package/dist/transport-stdio-C7-s9TLG.js +708 -0
  53. package/dist/{upstream-prompt-provenance-ClRBije0.js → upstream-prompt-provenance-CFmsKwr9.js} +12 -14
  54. package/dist/{upstream-session-fork-CE-_LdnP.js → upstream-session-fork-BACGlOFa.js} +86 -88
  55. package/dist/{usage-CHlV0e-o.js → usage-C2l8Mils.js} +3 -3
  56. package/dist/{web-search-provider.runtime-DRw2Vl42.js → web-search-provider.runtime-B2XgRdFv.js} +3 -3
  57. package/openclaw.plugin.json +50 -2
  58. package/package.json +9 -8
  59. package/dist/app-server-policy-zcBDc1JU.js +0 -49
  60. package/dist/incognito-session-ET_ufDH-.js +0 -2
  61. package/dist/request-BRl5_UfX.js +0 -157
  62. package/dist/session-retirement-DoMMJFKm.js +0 -36
  63. package/dist/thread-resume-CPrJNQVM.js +0 -30
  64. package/dist/transport-stdio-DIImwDVS.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,8 +232,10 @@ var definitions = {
228
232
  "contextWindowExceeded",
229
233
  "sessionBudgetExceeded",
230
234
  "usageLimitExceeded",
235
+ "rateLimitExceeded",
231
236
  "serverOverloaded",
232
237
  "cyberPolicy",
238
+ "misalignmentPolicyViolation",
233
239
  "internalServerError",
234
240
  "unauthorized",
235
241
  "badRequest",
@@ -267,7 +273,11 @@ var definitions = {
267
273
  "sendInput",
268
274
  "resumeAgent",
269
275
  "wait",
270
- "closeAgent"
276
+ "closeAgent",
277
+ "sendMessage",
278
+ "followupTask",
279
+ "interruptAgent",
280
+ "listAgents"
271
281
  ],
272
282
  "type": "string"
273
283
  },
@@ -275,7 +285,8 @@ var definitions = {
275
285
  "enum": [
276
286
  "inProgress",
277
287
  "completed",
278
- "failed"
288
+ "failed",
289
+ "interrupted"
279
290
  ],
280
291
  "type": "string"
281
292
  },
@@ -423,6 +434,68 @@ var definitions = {
423
434
  ],
424
435
  "type": "object"
425
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
+ },
426
499
  "GitInfo": {
427
500
  "properties": {
428
501
  "branch": { "type": ["string", "null"] },
@@ -448,6 +521,23 @@ var definitions = {
448
521
  ],
449
522
  "type": "string"
450
523
  },
524
+ "ImageGenerationFailure": { "oneOf": [{
525
+ "properties": {
526
+ "limitId": { "type": "string" },
527
+ "resetsAt": {
528
+ "format": "int64",
529
+ "type": ["integer", "null"]
530
+ },
531
+ "type": {
532
+ "enum": ["usageLimitExceeded"],
533
+ "title": "UsageLimitExceededImageGenerationFailureType",
534
+ "type": "string"
535
+ }
536
+ },
537
+ "required": ["limitId", "type"],
538
+ "title": "UsageLimitExceededImageGenerationFailure",
539
+ "type": "object"
540
+ }] },
451
541
  "InputModality": {
452
542
  "description": "Canonical user-input modality tags advertised by a model.",
453
543
  "oneOf": [
@@ -554,6 +644,28 @@ var definitions = {
554
644
  "type": "string"
555
645
  }]
556
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
+ },
557
669
  "Model": {
558
670
  "properties": {
559
671
  "additionalSpeedTiers": {
@@ -584,6 +696,10 @@ var definitions = {
584
696
  "default": null,
585
697
  "type": ["string", "null"]
586
698
  },
699
+ "multiAgentVersion": {
700
+ "anyOf": [{ "$ref": "#/definitions/MultiAgentVersion" }, { "type": "null" }],
701
+ "description": "Multi-agent runtime declared by this model, when available."
702
+ },
587
703
  "serviceTiers": {
588
704
  "default": [],
589
705
  "items": { "$ref": "#/definitions/ModelServiceTier" },
@@ -635,6 +751,11 @@ var definitions = {
635
751
  "migrationMarkdown": { "type": ["string", "null"] },
636
752
  "model": { "type": "string" },
637
753
  "modelLink": { "type": ["string", "null"] },
754
+ "retirementAt": {
755
+ "description": "Informational Unix timestamp for this upgrade's scheduled retirement, if known.",
756
+ "format": "int64",
757
+ "type": ["integer", "null"]
758
+ },
638
759
  "upgradeCopy": { "type": ["string", "null"] }
639
760
  },
640
761
  "required": ["model"],
@@ -653,6 +774,15 @@ var definitions = {
653
774
  "type": "string"
654
775
  }]
655
776
  },
777
+ "MultiAgentVersion": {
778
+ "description": "Multi-agent runtime supported by a model.",
779
+ "enum": [
780
+ "disabled",
781
+ "v1",
782
+ "v2"
783
+ ],
784
+ "type": "string"
785
+ },
656
786
  "NetworkAccess": {
657
787
  "enum": ["restricted", "enabled"],
658
788
  "type": "string"
@@ -721,6 +851,8 @@ var definitions = {
721
851
  "enterprise_cbp_usage_based",
722
852
  "enterprise",
723
853
  "edu",
854
+ "edu_plus",
855
+ "edu_pro",
724
856
  "unknown"
725
857
  ],
726
858
  "type": "string"
@@ -841,7 +973,8 @@ var definitions = {
841
973
  "enum": [
842
974
  "started",
843
975
  "interacted",
844
- "interrupted"
976
+ "interrupted",
977
+ "completed"
845
978
  ],
846
979
  "type": "string"
847
980
  },
@@ -977,6 +1110,10 @@ var definitions = {
977
1110
  "description": "Usually the first user message in the thread, if available.",
978
1111
  "type": "string"
979
1112
  },
1113
+ "projectId": {
1114
+ "description": "Canonical project assignment owned by app-server, if any.",
1115
+ "type": ["string", "null"]
1116
+ },
980
1117
  "recencyAt": {
981
1118
  "description": "Unix timestamp (in seconds) used for thread recency ordering.",
982
1119
  "format": "int64",
@@ -1028,6 +1165,7 @@ var definitions = {
1028
1165
  "id",
1029
1166
  "modelProvider",
1030
1167
  "preview",
1168
+ "projectId",
1031
1169
  "sessionId",
1032
1170
  "source",
1033
1171
  "status",
@@ -1095,6 +1233,10 @@ var definitions = {
1095
1233
  },
1096
1234
  {
1097
1235
  "properties": {
1236
+ "delivery": {
1237
+ "anyOf": [{ "$ref": "#/definitions/AgentMessageDelivery" }, { "type": "null" }],
1238
+ "default": null
1239
+ },
1098
1240
  "id": { "type": "string" },
1099
1241
  "memoryCitation": {
1100
1242
  "anyOf": [{ "$ref": "#/definitions/MemoryCitation" }, { "type": "null" }],
@@ -1119,6 +1261,27 @@ var definitions = {
1119
1261
  "title": "AgentMessageThreadItem",
1120
1262
  "type": "object"
1121
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
+ },
1122
1285
  {
1123
1286
  "description": "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
1124
1287
  "properties": {
@@ -1469,6 +1632,10 @@ var definitions = {
1469
1632
  },
1470
1633
  {
1471
1634
  "properties": {
1635
+ "failure": {
1636
+ "anyOf": [{ "$ref": "#/definitions/ImageGenerationFailure" }, { "type": "null" }],
1637
+ "default": null
1638
+ },
1472
1639
  "id": { "type": "string" },
1473
1640
  "result": { "type": "string" },
1474
1641
  "revisedPrompt": { "type": ["string", "null"] },
@@ -1546,6 +1713,11 @@ var definitions = {
1546
1713
  "ThreadSection": {
1547
1714
  "description": "An independently persisted, user-visible thread section.",
1548
1715
  "properties": {
1716
+ "appearance": {
1717
+ "anyOf": [{ "$ref": "#/definitions/ThreadSectionAppearance" }, { "type": "null" }],
1718
+ "default": null,
1719
+ "description": "Optional appearance synchronized across clients."
1720
+ },
1549
1721
  "id": {
1550
1722
  "description": "Opaque UUIDv7 identity that remains stable when the section is renamed.",
1551
1723
  "type": "string"
@@ -1558,6 +1730,14 @@ var definitions = {
1558
1730
  "required": ["id", "name"],
1559
1731
  "type": "object"
1560
1732
  },
1733
+ "ThreadSectionAppearance": {
1734
+ "description": "Extensible visual presentation for a custom thread section.",
1735
+ "properties": {
1736
+ "color": { "type": ["string", "null"] },
1737
+ "icon": { "type": ["string", "null"] }
1738
+ },
1739
+ "type": "object"
1740
+ },
1561
1741
  "ThreadSource": { "type": "string" },
1562
1742
  "ThreadStatus": { "oneOf": [
1563
1743
  {
@@ -1658,7 +1838,12 @@ var definitions = {
1658
1838
  "type": ["string", "null"]
1659
1839
  },
1660
1840
  "codexErrorInfo": { "anyOf": [{ "$ref": "#/definitions/CodexErrorInfo" }, { "type": "null" }] },
1661
- "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
+ }
1662
1847
  },
1663
1848
  "required": ["message"],
1664
1849
  "type": "object"
@@ -1941,7 +2126,7 @@ var ThreadResumeResponse_default = {
1941
2126
  },
1942
2127
  "itemsBackwardsCursor": {
1943
2128
  "default": null,
1944
- "description": "Opaque head cursor for hydrating paginated items backwards.\n\nPass this as `cursor` to `thread/items/list` with `sortDirection: \"desc\"`. The first page includes the cursor's head item.",
2129
+ "description": "Opaque cursor for hydrating paginated items backwards.\n\nPass this as `cursor` to `thread/items/list` with `sortDirection: \"desc\"`. The first page includes the item identified by the cursor.",
1945
2130
  "type": ["string", "null"]
1946
2131
  },
1947
2132
  "model": { "type": "string" },
@@ -1966,7 +2151,7 @@ var ThreadResumeResponse_default = {
1966
2151
  "thread": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/Thread" },
1967
2152
  "turnsBackwardsCursor": {
1968
2153
  "default": null,
1969
- "description": "Opaque head cursor for hydrating paginated turns backwards.\n\nPass this as `cursor` to `thread/turns/list` with `sortDirection: \"desc\"`. The first page includes the cursor's head turn.",
2154
+ "description": "Opaque cursor for hydrating paginated turns backwards.\n\nPass this as `cursor` to `thread/turns/list` with `sortDirection: \"desc\"`. The first page includes the turn identified by the cursor.",
1970
2155
  "type": ["string", "null"]
1971
2156
  }
1972
2157
  },
@@ -2248,6 +2433,16 @@ function assertCodexThreadResumeResponse(value) {
2248
2433
  const normalized = normalizeWithDefaults(threadResumeResponseSchema, value);
2249
2434
  return assertCodexShape(validateThreadResumeResponse, normalized, "thread/resume response");
2250
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
+ }
2251
2446
  /** Asserts and normalizes a Codex turn/start response. */
2252
2447
  function assertCodexTurnStartResponse(value) {
2253
2448
  const normalized = normalizeWithDefaults(turnStartResponseSchema, normalizeTurnStartResponse(value));
@@ -2296,6 +2491,7 @@ function normalizeThreadItem(value) {
2296
2491
  switch (value.type) {
2297
2492
  case "agentMessage": return {
2298
2493
  phase: null,
2494
+ delivery: null,
2299
2495
  memoryCitation: null,
2300
2496
  ...value
2301
2497
  };
@@ -2343,4 +2539,4 @@ function formatValidationErrors(validate, value) {
2343
2539
  }).join("; ");
2344
2540
  }
2345
2541
  //#endregion
2346
- export { assertCodexThreadStartResponse as a, readCodexErrorNotification as c, assertCodexThreadResumeResponse as i, readCodexTurn as l, assertCodexThreadForkParams as n, assertCodexTurnStartResponse as o, assertCodexThreadForkResponse as r, readCodexDynamicToolCallParams as s, assertCodexModelListResponse as t, readCodexTurnCompletedNotification as u };
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 { ct as isJsonObject } from "./shared-client-kIBbGjk4.js";
1
+ import { Ht as isJsonObject } from "./shared-client-kNkljY-R.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";
@@ -1,6 +1,9 @@
1
- import { C as isCodexRemoteExecPlacementSandbox } from "./session-binding-DPxIvMgE.js";
2
- import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { C as isCodexRemoteExecPlacementSandbox } from "./config-Cxw3Cl3k.js";
3
+ import { Et as withTimeout, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient, s as createIsolatedCodexAppServerClient, u as isCodexAppServerStartSelectionChangedError, y as retireSharedCodexAppServerClientIfCurrent } from "./shared-client-kNkljY-R.js";
4
+ import { resolveAgentConfig, tryResolveDefaultAgentId } from "openclaw/plugin-sdk/agent-scope-runtime";
3
5
  import { getSessionEntry } from "openclaw/plugin-sdk/session-store-runtime";
6
+ import { normalizeAgentId, parseAgentSessionKey } from "openclaw/plugin-sdk/routing";
4
7
  import { resolveSandboxRuntimeStatus } from "openclaw/plugin-sdk/sandbox";
5
8
  //#region extensions/codex/src/app-server/native-execution-policy.ts
6
9
  /** Projects node execution ownership into the runtime tool factory options. */
@@ -21,23 +24,26 @@ function resolveCodexNativeExecutionPolicy(params) {
21
24
  sessionKey,
22
25
  agentId: params.agentId
23
26
  });
24
- const canReadSessionEntry = params.readRuntimeSessionEntry && shouldReadRuntimeSessionEntry({
27
+ const canReadSessionEntry = Boolean(agentId) && params.readRuntimeSessionEntry && shouldReadRuntimeSessionEntry({
25
28
  config,
26
29
  sessionKey,
27
- agentId: params.agentId
30
+ agentId
28
31
  });
29
- const sessionEntry = params.sessionEntry ?? (canReadSessionEntry && sessionKey ? readRuntimeSessionEntryBestEffort({
32
+ const sessionEntry = params.sessionEntry ?? (canReadSessionEntry && sessionKey && agentId ? readRuntimeSessionEntryBestEffort({
30
33
  sessionKey,
31
34
  agentId
32
35
  }) : void 0);
33
- const sandboxAvailable = params.sandboxAvailable ?? (sessionKey ? resolveSandboxRuntimeStatus({
36
+ const sandboxAgentId = parseAgentSessionKey(sessionKey)?.agentId ?? agentId;
37
+ const sandboxAvailable = params.sandboxAvailable ?? (sessionKey && sandboxAgentId ? resolveSandboxRuntimeStatus({
34
38
  cfg: config,
35
- sessionKey
39
+ sessionKey,
40
+ agentId: sandboxAgentId,
41
+ classificationAgentId: sandboxAgentId
36
42
  }).sandboxed : false);
37
- const agentExec = resolvePolicyAgentExec({
43
+ const agentExec = agentId ? resolvePolicyAgentExec({
38
44
  config,
39
45
  agentId
40
- });
46
+ }) : void 0;
41
47
  const globalExec = config.tools?.exec;
42
48
  const requestedExecHost = normalizeExecTarget(params.execOverrides?.host) ?? normalizeExecTarget(sessionEntry?.execHost) ?? normalizeExecTarget(agentExec?.host) ?? normalizeExecTarget(globalExec?.host) ?? "auto";
43
49
  const effectiveExecHost = resolveEffectiveExecHost({
@@ -72,13 +78,10 @@ function resolvePolicyAgentId(params) {
72
78
  if (explicitAgentId) return explicitAgentId;
73
79
  const sessionAgentId = parseAgentIdFromSessionKey(params.sessionKey);
74
80
  if (sessionAgentId) return sessionAgentId;
75
- return resolveDefaultPolicyAgentId(listAgentEntries(params.config));
81
+ return tryResolveDefaultAgentId(params.config);
76
82
  }
77
83
  function resolvePolicyAgentExec(params) {
78
- return listAgentEntries(params.config).find((entry) => normalizeAgentId(entry?.id) === params.agentId)?.tools?.exec;
79
- }
80
- function listAgentEntries(config) {
81
- return (config.agents?.list ?? []).filter((entry) => entry !== null && typeof entry === "object");
84
+ return resolveAgentConfig(params.config, params.agentId)?.tools?.exec;
82
85
  }
83
86
  function parseAgentIdFromSessionKey(sessionKey) {
84
87
  const raw = sessionKey?.trim();
@@ -99,10 +102,7 @@ function shouldReadRuntimeSessionEntry(params) {
99
102
  return sessionAgentId === explicitAgentId;
100
103
  }
101
104
  function isDefaultAgentSessionKeyForAgent(params) {
102
- return normalizeAgentId(params.agentId) === resolveDefaultPolicyAgentId(listAgentEntries(params.config));
103
- }
104
- function resolveDefaultPolicyAgentId(agents) {
105
- return normalizeAgentId((agents.find((entry) => entry?.default) ?? agents[0])?.id);
105
+ return normalizeAgentId(params.agentId) === tryResolveDefaultAgentId(params.config);
106
106
  }
107
107
  function normalizeAgentIdOrDefault(value) {
108
108
  const normalized = normalizeAgentId(value);
@@ -129,6 +129,10 @@ function readRuntimeSessionEntryBestEffort(params) {
129
129
  }
130
130
  //#endregion
131
131
  //#region extensions/codex/src/app-server/sandbox-guard.ts
132
+ /**
133
+ * Blocks direct Codex app-server requests that would bypass OpenClaw sandbox or
134
+ * node-exec routing guarantees.
135
+ */
132
136
  const DIRECT_METHOD_POLICIES = /* @__PURE__ */ new Map([
133
137
  ["account/rateLimits/read", "allowed-control-plane"],
134
138
  ["account/read", "allowed-control-plane"],
@@ -230,9 +234,13 @@ function resolveCodexNativeSandboxBlock(params) {
230
234
  const sessionKey = params.sessionKey?.trim() || params.sessionId?.trim();
231
235
  if (!sessionKey) return;
232
236
  if (isCodexRemoteExecPlacementSandbox(params.sandbox) || params.sandbox?.enabled === true) return formatCodexNativeSandboxBlock({ surface: params.surface });
237
+ const sandboxAgentId = parseAgentSessionKey(sessionKey)?.agentId ?? params.agentId ?? tryResolveDefaultAgentId(params.config ?? {});
238
+ if (!sandboxAgentId) return;
233
239
  if (!resolveSandboxRuntimeStatus({
234
240
  cfg: params.config,
235
- sessionKey
241
+ sessionKey,
242
+ agentId: sandboxAgentId,
243
+ classificationAgentId: sandboxAgentId
236
244
  }).sandboxed) return;
237
245
  return formatCodexNativeSandboxBlock({ surface: params.surface });
238
246
  }
@@ -273,4 +281,183 @@ function resolveCodexNativeNodeExecBlock(params) {
273
281
  });
274
282
  }
275
283
  //#endregion
276
- export { resolveCodexNodeExecToolOverrides as a, resolveCodexNativeExecutionPolicy as i, resolveCodexNativeExecutionBlock as n, resolveCodexNativeSandboxBlock as r, resolveCodexAppServerDirectSandboxBypassBlock as t };
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 };