@openclaw/codex 2026.7.2-beta.3 → 2026.7.2-beta.5

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 (43) hide show
  1. package/dist/{app-server-policy-DUMF2Xyr.js → app-server-policy-BmDgseo_.js} +1 -1
  2. package/dist/attempt-client-cleanup-Ia52yRWc.js +127 -0
  3. package/dist/{attempt-notifications-Ecjyzufe.js → attempt-notifications-CMR2_fmR.js} +1 -1
  4. package/dist/{media-understanding-provider-IPNNQre6.js → bounded-turn-FEbUXoYT.js} +71 -188
  5. package/dist/capabilities-BHRSI6Cn.js +36 -0
  6. package/dist/cli-metadata.js +1 -1
  7. package/dist/{command-formatters-NCTL7A2q.js → command-formatters-ico4ZFnk.js} +3 -37
  8. package/dist/{command-handlers-DtFbZiba.js → command-handlers-CRmnwI2N.js} +1233 -1221
  9. package/dist/{compact-Kgy26gIM.js → compact-dEN49UH6.js} +8 -7
  10. package/dist/{computer-use-C7x4ZaqR.js → computer-use-BjGylO-E.js} +16 -6
  11. package/dist/{conversation-control-B0s3aIjT.js → conversation-control-DE7d9DOj.js} +6 -5
  12. package/dist/doctor-contract-api.js +24 -86
  13. package/dist/{dynamic-tools-D_vSVmv9.js → dynamic-tools-LIt9ojep.js} +135 -2696
  14. package/dist/event-projector-assistant-message-DTgnPPVF.js +101 -0
  15. package/dist/event-projector-usage-tvgb1NCX.js +69 -0
  16. package/dist/harness.js +31 -11
  17. package/dist/incognito-session-ET_ufDH-.js +2 -0
  18. package/dist/index.js +250 -275
  19. package/dist/media-understanding-provider.js +173 -1
  20. package/dist/{models-DD5zBdX5.js → models-BA01NEez.js} +2 -2
  21. package/dist/{notification-correlation-C8DVQ_Bq.js → notification-correlation-Bj_Ak_jI.js} +3 -3
  22. package/dist/{plugin-app-cache-key-DJbhLYSK.js → plugin-app-cache-key-DSXX-rXO.js} +5 -5
  23. package/dist/{transcript-mirror-D9rTxx2P.js → protocol-validators-Dm4eXZmt.js} +335 -595
  24. package/dist/{rate-limits-CqhWQ2R9.js → rate-limits-S_PXs0ul.js} +1 -1
  25. package/dist/realtime-voice-api-BPcA1uN9.js +494 -0
  26. package/dist/realtime-voice-api.js +2 -0
  27. package/dist/{request-9yf9pZjf.js → request-CXpPennK.js} +1 -1
  28. package/dist/{run-attempt-BIoO8ISr.js → run-attempt-C5GTPJOE.js} +3111 -387
  29. package/dist/{session-binding-Bmt20HfB.js → session-binding-DlVQ-Pxs.js} +957 -890
  30. package/dist/{session-catalog-CA7R-hX2.js → session-catalog-CP2oCcEb.js} +98 -87
  31. package/dist/{session-cli-Bxk3-Wqz.js → session-cli-CqZ0Fp2a.js} +2 -2
  32. package/dist/session-upstream-marker-QE-m5QFG.js +82 -0
  33. package/dist/settled-turn-finalizer-CA_2QXIE.js +303 -0
  34. package/dist/{shared-client-CSXLtCLE.js → shared-client-BVKE40c-.js} +1870 -1694
  35. package/dist/{side-question-DtzquMOb.js → side-question-CO12sHxo.js} +24 -16
  36. package/dist/{thread-lifecycle-CQ_9mAa1.js → thread-lifecycle-DRg_FdzC.js} +127 -153
  37. package/dist/transcript-mirror-uKA-A4tB.js +550 -0
  38. package/dist/upstream-session-fork-_Vrz4WJr.js +320 -0
  39. package/dist/{usage-CuPpFgTc.js → usage-UpVbdX5G.js} +3 -3
  40. package/dist/{web-search-provider.runtime-_x5XTeqh.js → web-search-provider.runtime-CaQMYDbp.js} +3 -3
  41. package/package.json +7 -8
  42. package/npm-shrinkwrap.json +0 -202
  43. package/dist/{auth-binding-C1czuHPA.js → auth-binding-B4FfbcCg.js} +1 -1
@@ -1,9 +1,5 @@
1
- import { createHash } from "node:crypto";
2
- import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
2
  import { Compile } from "typebox/compile";
4
- import { embeddedAgentLog, formatErrorMessage, runAgentHarnessBeforeMessageWriteHook } from "openclaw/plugin-sdk/agent-harness-runtime";
5
- import { Buffer } from "node:buffer";
6
- import { publishSessionTranscriptUpdateByIdentity, withSessionTranscriptWriteLock } from "openclaw/plugin-sdk/session-transcript-runtime";
7
3
  //#region extensions/codex/src/app-server/protocol-generated/json/DynamicToolCallParams.json
8
4
  var DynamicToolCallParams_default = {
9
5
  $schema: "http://json-schema.org/draft-07/schema#",
@@ -161,15 +157,23 @@ var ModelListResponse_default = {
161
157
  definitions: {
162
158
  "InputModality": {
163
159
  "description": "Canonical user-input modality tags advertised by a model.",
164
- "oneOf": [{
165
- "description": "Plain text turns and tool payloads.",
166
- "enum": ["text"],
167
- "type": "string"
168
- }, {
169
- "description": "Image attachments included in user turns.",
170
- "enum": ["image"],
171
- "type": "string"
172
- }]
160
+ "oneOf": [
161
+ {
162
+ "description": "Plain text turns and tool payloads.",
163
+ "enum": ["text"],
164
+ "type": "string"
165
+ },
166
+ {
167
+ "description": "Image attachments included in user turns.",
168
+ "enum": ["image"],
169
+ "type": "string"
170
+ },
171
+ {
172
+ "description": "Audio attachments included in user turns.",
173
+ "enum": ["audio"],
174
+ "type": "string"
175
+ }
176
+ ]
173
177
  },
174
178
  "Model": {
175
179
  "properties": {
@@ -577,31 +581,47 @@ var ThreadResumeResponse_default = {
577
581
  ],
578
582
  "type": "string"
579
583
  },
580
- "DynamicToolCallOutputContentItem": { "oneOf": [{
581
- "properties": {
582
- "text": { "type": "string" },
583
- "type": {
584
- "enum": ["inputText"],
585
- "title": "InputTextDynamicToolCallOutputContentItemType",
586
- "type": "string"
587
- }
584
+ "DynamicToolCallOutputContentItem": { "oneOf": [
585
+ {
586
+ "properties": {
587
+ "text": { "type": "string" },
588
+ "type": {
589
+ "enum": ["inputText"],
590
+ "title": "InputTextDynamicToolCallOutputContentItemType",
591
+ "type": "string"
592
+ }
593
+ },
594
+ "required": ["text", "type"],
595
+ "title": "InputTextDynamicToolCallOutputContentItem",
596
+ "type": "object"
588
597
  },
589
- "required": ["text", "type"],
590
- "title": "InputTextDynamicToolCallOutputContentItem",
591
- "type": "object"
592
- }, {
593
- "properties": {
594
- "imageUrl": { "type": "string" },
595
- "type": {
596
- "enum": ["inputImage"],
597
- "title": "InputImageDynamicToolCallOutputContentItemType",
598
- "type": "string"
599
- }
598
+ {
599
+ "properties": {
600
+ "imageUrl": { "type": "string" },
601
+ "type": {
602
+ "enum": ["inputImage"],
603
+ "title": "InputImageDynamicToolCallOutputContentItemType",
604
+ "type": "string"
605
+ }
606
+ },
607
+ "required": ["imageUrl", "type"],
608
+ "title": "InputImageDynamicToolCallOutputContentItem",
609
+ "type": "object"
600
610
  },
601
- "required": ["imageUrl", "type"],
602
- "title": "InputImageDynamicToolCallOutputContentItem",
603
- "type": "object"
604
- }] },
611
+ {
612
+ "properties": {
613
+ "audioUrl": { "type": "string" },
614
+ "type": {
615
+ "enum": ["inputAudio"],
616
+ "title": "InputAudioDynamicToolCallOutputContentItemType",
617
+ "type": "string"
618
+ }
619
+ },
620
+ "required": ["audioUrl", "type"],
621
+ "title": "InputAudioDynamicToolCallOutputContentItem",
622
+ "type": "object"
623
+ }
624
+ ] },
605
625
  "DynamicToolCallStatus": {
606
626
  "enum": [
607
627
  "inProgress",
@@ -655,8 +675,7 @@ var ThreadResumeResponse_default = {
655
675
  "appName": { "type": ["string", "null"] },
656
676
  "connectorId": { "type": "string" },
657
677
  "linkId": { "type": ["string", "null"] },
658
- "resourceUri": { "type": ["string", "null"] },
659
- "templateId": { "type": ["string", "null"] }
678
+ "resourceUri": { "type": ["string", "null"] }
660
679
  },
661
680
  "required": ["connectorId"],
662
681
  "type": "object"
@@ -982,6 +1001,10 @@ var ThreadResumeResponse_default = {
982
1001
  "description": "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
983
1002
  "type": ["string", "null"]
984
1003
  },
1004
+ "canAcceptDirectInput": {
1005
+ "description": "Whether the app server accepts direct turn input for this loaded thread. `None` means the capability is unavailable, such as for an unloaded stored thread.",
1006
+ "type": ["boolean", "null"]
1007
+ },
985
1008
  "cliVersion": {
986
1009
  "description": "Version of the CLI that created the thread.",
987
1010
  "type": "string"
@@ -1447,6 +1470,12 @@ var ThreadResumeResponse_default = {
1447
1470
  "action": { "anyOf": [{ "$ref": "#/definitions/WebSearchAction" }, { "type": "null" }] },
1448
1471
  "id": { "type": "string" },
1449
1472
  "query": { "type": "string" },
1473
+ "results": {
1474
+ "default": null,
1475
+ "description": "Structured search results returned out-of-band by standalone web search.\n\nThese stay as opaque JSON at the extension/app-server boundary so new result fields and result types can pass through without a Codex release.",
1476
+ "items": true,
1477
+ "type": ["array", "null"]
1478
+ },
1450
1479
  "type": {
1451
1480
  "enum": ["webSearch"],
1452
1481
  "title": "WebSearchThreadItemType",
@@ -1480,6 +1509,7 @@ var ThreadResumeResponse_default = {
1480
1509
  "type": "object"
1481
1510
  },
1482
1511
  {
1512
+ "description": "Display item emitted by the interruptible `clock.sleep` tool.",
1483
1513
  "properties": {
1484
1514
  "durationMs": {
1485
1515
  "format": "uint64",
@@ -1770,6 +1800,32 @@ var ThreadResumeResponse_default = {
1770
1800
  "title": "LocalImageUserInput",
1771
1801
  "type": "object"
1772
1802
  },
1803
+ {
1804
+ "properties": {
1805
+ "type": {
1806
+ "enum": ["audio"],
1807
+ "title": "AudioUserInputType",
1808
+ "type": "string"
1809
+ },
1810
+ "url": { "type": "string" }
1811
+ },
1812
+ "required": ["type", "url"],
1813
+ "title": "AudioUserInput",
1814
+ "type": "object"
1815
+ },
1816
+ {
1817
+ "properties": {
1818
+ "path": { "type": "string" },
1819
+ "type": {
1820
+ "enum": ["localAudio"],
1821
+ "title": "LocalAudioUserInputType",
1822
+ "type": "string"
1823
+ }
1824
+ },
1825
+ "required": ["path", "type"],
1826
+ "title": "LocalAudioUserInput",
1827
+ "type": "object"
1828
+ },
1773
1829
  {
1774
1830
  "properties": {
1775
1831
  "name": { "type": "string" },
@@ -1887,6 +1943,11 @@ var ThreadResumeResponse_default = {
1887
1943
  "items": { "$ref": "#/definitions/LegacyAppPathString" },
1888
1944
  "type": "array"
1889
1945
  },
1946
+ "itemsBackwardsCursor": {
1947
+ "default": null,
1948
+ "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.",
1949
+ "type": ["string", "null"]
1950
+ },
1890
1951
  "model": { "type": "string" },
1891
1952
  "modelProvider": { "type": "string" },
1892
1953
  "multiAgentMode": {
@@ -1906,7 +1967,12 @@ var ThreadResumeResponse_default = {
1906
1967
  "description": "Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance."
1907
1968
  },
1908
1969
  "serviceTier": { "type": ["string", "null"] },
1909
- "thread": { "$ref": "#/definitions/Thread" }
1970
+ "thread": { "$ref": "#/definitions/Thread" },
1971
+ "turnsBackwardsCursor": {
1972
+ "default": null,
1973
+ "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.",
1974
+ "type": ["string", "null"]
1975
+ }
1910
1976
  },
1911
1977
  required: [
1912
1978
  "approvalPolicy",
@@ -2216,31 +2282,47 @@ var ThreadStartResponse_default = {
2216
2282
  ],
2217
2283
  "type": "string"
2218
2284
  },
2219
- "DynamicToolCallOutputContentItem": { "oneOf": [{
2220
- "properties": {
2221
- "text": { "type": "string" },
2222
- "type": {
2223
- "enum": ["inputText"],
2224
- "title": "InputTextDynamicToolCallOutputContentItemType",
2225
- "type": "string"
2226
- }
2285
+ "DynamicToolCallOutputContentItem": { "oneOf": [
2286
+ {
2287
+ "properties": {
2288
+ "text": { "type": "string" },
2289
+ "type": {
2290
+ "enum": ["inputText"],
2291
+ "title": "InputTextDynamicToolCallOutputContentItemType",
2292
+ "type": "string"
2293
+ }
2294
+ },
2295
+ "required": ["text", "type"],
2296
+ "title": "InputTextDynamicToolCallOutputContentItem",
2297
+ "type": "object"
2227
2298
  },
2228
- "required": ["text", "type"],
2229
- "title": "InputTextDynamicToolCallOutputContentItem",
2230
- "type": "object"
2231
- }, {
2232
- "properties": {
2233
- "imageUrl": { "type": "string" },
2234
- "type": {
2235
- "enum": ["inputImage"],
2236
- "title": "InputImageDynamicToolCallOutputContentItemType",
2237
- "type": "string"
2238
- }
2299
+ {
2300
+ "properties": {
2301
+ "imageUrl": { "type": "string" },
2302
+ "type": {
2303
+ "enum": ["inputImage"],
2304
+ "title": "InputImageDynamicToolCallOutputContentItemType",
2305
+ "type": "string"
2306
+ }
2307
+ },
2308
+ "required": ["imageUrl", "type"],
2309
+ "title": "InputImageDynamicToolCallOutputContentItem",
2310
+ "type": "object"
2239
2311
  },
2240
- "required": ["imageUrl", "type"],
2241
- "title": "InputImageDynamicToolCallOutputContentItem",
2242
- "type": "object"
2243
- }] },
2312
+ {
2313
+ "properties": {
2314
+ "audioUrl": { "type": "string" },
2315
+ "type": {
2316
+ "enum": ["inputAudio"],
2317
+ "title": "InputAudioDynamicToolCallOutputContentItemType",
2318
+ "type": "string"
2319
+ }
2320
+ },
2321
+ "required": ["audioUrl", "type"],
2322
+ "title": "InputAudioDynamicToolCallOutputContentItem",
2323
+ "type": "object"
2324
+ }
2325
+ ] },
2244
2326
  "DynamicToolCallStatus": {
2245
2327
  "enum": [
2246
2328
  "inProgress",
@@ -2294,8 +2376,7 @@ var ThreadStartResponse_default = {
2294
2376
  "appName": { "type": ["string", "null"] },
2295
2377
  "connectorId": { "type": "string" },
2296
2378
  "linkId": { "type": ["string", "null"] },
2297
- "resourceUri": { "type": ["string", "null"] },
2298
- "templateId": { "type": ["string", "null"] }
2379
+ "resourceUri": { "type": ["string", "null"] }
2299
2380
  },
2300
2381
  "required": ["connectorId"],
2301
2382
  "type": "object"
@@ -2621,6 +2702,10 @@ var ThreadStartResponse_default = {
2621
2702
  "description": "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
2622
2703
  "type": ["string", "null"]
2623
2704
  },
2705
+ "canAcceptDirectInput": {
2706
+ "description": "Whether the app server accepts direct turn input for this loaded thread. `None` means the capability is unavailable, such as for an unloaded stored thread.",
2707
+ "type": ["boolean", "null"]
2708
+ },
2624
2709
  "cliVersion": {
2625
2710
  "description": "Version of the CLI that created the thread.",
2626
2711
  "type": "string"
@@ -3086,6 +3171,12 @@ var ThreadStartResponse_default = {
3086
3171
  "action": { "anyOf": [{ "$ref": "#/definitions/WebSearchAction" }, { "type": "null" }] },
3087
3172
  "id": { "type": "string" },
3088
3173
  "query": { "type": "string" },
3174
+ "results": {
3175
+ "default": null,
3176
+ "description": "Structured search results returned out-of-band by standalone web search.\n\nThese stay as opaque JSON at the extension/app-server boundary so new result fields and result types can pass through without a Codex release.",
3177
+ "items": true,
3178
+ "type": ["array", "null"]
3179
+ },
3089
3180
  "type": {
3090
3181
  "enum": ["webSearch"],
3091
3182
  "title": "WebSearchThreadItemType",
@@ -3119,6 +3210,7 @@ var ThreadStartResponse_default = {
3119
3210
  "type": "object"
3120
3211
  },
3121
3212
  {
3213
+ "description": "Display item emitted by the interruptible `clock.sleep` tool.",
3122
3214
  "properties": {
3123
3215
  "durationMs": {
3124
3216
  "format": "uint64",
@@ -3397,6 +3489,32 @@ var ThreadStartResponse_default = {
3397
3489
  "title": "LocalImageUserInput",
3398
3490
  "type": "object"
3399
3491
  },
3492
+ {
3493
+ "properties": {
3494
+ "type": {
3495
+ "enum": ["audio"],
3496
+ "title": "AudioUserInputType",
3497
+ "type": "string"
3498
+ },
3499
+ "url": { "type": "string" }
3500
+ },
3501
+ "required": ["type", "url"],
3502
+ "title": "AudioUserInput",
3503
+ "type": "object"
3504
+ },
3505
+ {
3506
+ "properties": {
3507
+ "path": { "type": "string" },
3508
+ "type": {
3509
+ "enum": ["localAudio"],
3510
+ "title": "LocalAudioUserInputType",
3511
+ "type": "string"
3512
+ }
3513
+ },
3514
+ "required": ["path", "type"],
3515
+ "title": "LocalAudioUserInput",
3516
+ "type": "object"
3517
+ },
3400
3518
  {
3401
3519
  "properties": {
3402
3520
  "name": { "type": "string" },
@@ -3779,31 +3897,47 @@ var TurnCompletedNotification_default = {
3779
3897
  ],
3780
3898
  "type": "string"
3781
3899
  },
3782
- "DynamicToolCallOutputContentItem": { "oneOf": [{
3783
- "properties": {
3784
- "text": { "type": "string" },
3785
- "type": {
3786
- "enum": ["inputText"],
3787
- "title": "InputTextDynamicToolCallOutputContentItemType",
3788
- "type": "string"
3789
- }
3900
+ "DynamicToolCallOutputContentItem": { "oneOf": [
3901
+ {
3902
+ "properties": {
3903
+ "text": { "type": "string" },
3904
+ "type": {
3905
+ "enum": ["inputText"],
3906
+ "title": "InputTextDynamicToolCallOutputContentItemType",
3907
+ "type": "string"
3908
+ }
3909
+ },
3910
+ "required": ["text", "type"],
3911
+ "title": "InputTextDynamicToolCallOutputContentItem",
3912
+ "type": "object"
3790
3913
  },
3791
- "required": ["text", "type"],
3792
- "title": "InputTextDynamicToolCallOutputContentItem",
3793
- "type": "object"
3794
- }, {
3795
- "properties": {
3796
- "imageUrl": { "type": "string" },
3797
- "type": {
3798
- "enum": ["inputImage"],
3799
- "title": "InputImageDynamicToolCallOutputContentItemType",
3800
- "type": "string"
3801
- }
3914
+ {
3915
+ "properties": {
3916
+ "imageUrl": { "type": "string" },
3917
+ "type": {
3918
+ "enum": ["inputImage"],
3919
+ "title": "InputImageDynamicToolCallOutputContentItemType",
3920
+ "type": "string"
3921
+ }
3922
+ },
3923
+ "required": ["imageUrl", "type"],
3924
+ "title": "InputImageDynamicToolCallOutputContentItem",
3925
+ "type": "object"
3802
3926
  },
3803
- "required": ["imageUrl", "type"],
3804
- "title": "InputImageDynamicToolCallOutputContentItem",
3805
- "type": "object"
3806
- }] },
3927
+ {
3928
+ "properties": {
3929
+ "audioUrl": { "type": "string" },
3930
+ "type": {
3931
+ "enum": ["inputAudio"],
3932
+ "title": "InputAudioDynamicToolCallOutputContentItemType",
3933
+ "type": "string"
3934
+ }
3935
+ },
3936
+ "required": ["audioUrl", "type"],
3937
+ "title": "InputAudioDynamicToolCallOutputContentItem",
3938
+ "type": "object"
3939
+ }
3940
+ ] },
3807
3941
  "DynamicToolCallStatus": {
3808
3942
  "enum": [
3809
3943
  "inProgress",
@@ -3849,8 +3983,7 @@ var TurnCompletedNotification_default = {
3849
3983
  "appName": { "type": ["string", "null"] },
3850
3984
  "connectorId": { "type": "string" },
3851
3985
  "linkId": { "type": ["string", "null"] },
3852
- "resourceUri": { "type": ["string", "null"] },
3853
- "templateId": { "type": ["string", "null"] }
3986
+ "resourceUri": { "type": ["string", "null"] }
3854
3987
  },
3855
3988
  "required": ["connectorId"],
3856
3989
  "type": "object"
@@ -4350,6 +4483,12 @@ var TurnCompletedNotification_default = {
4350
4483
  "action": { "anyOf": [{ "$ref": "#/definitions/WebSearchAction" }, { "type": "null" }] },
4351
4484
  "id": { "type": "string" },
4352
4485
  "query": { "type": "string" },
4486
+ "results": {
4487
+ "default": null,
4488
+ "description": "Structured search results returned out-of-band by standalone web search.\n\nThese stay as opaque JSON at the extension/app-server boundary so new result fields and result types can pass through without a Codex release.",
4489
+ "items": true,
4490
+ "type": ["array", "null"]
4491
+ },
4353
4492
  "type": {
4354
4493
  "enum": ["webSearch"],
4355
4494
  "title": "WebSearchThreadItemType",
@@ -4383,6 +4522,7 @@ var TurnCompletedNotification_default = {
4383
4522
  "type": "object"
4384
4523
  },
4385
4524
  {
4525
+ "description": "Display item emitted by the interruptible `clock.sleep` tool.",
4386
4526
  "properties": {
4387
4527
  "durationMs": {
4388
4528
  "format": "uint64",
@@ -4612,6 +4752,32 @@ var TurnCompletedNotification_default = {
4612
4752
  "title": "LocalImageUserInput",
4613
4753
  "type": "object"
4614
4754
  },
4755
+ {
4756
+ "properties": {
4757
+ "type": {
4758
+ "enum": ["audio"],
4759
+ "title": "AudioUserInputType",
4760
+ "type": "string"
4761
+ },
4762
+ "url": { "type": "string" }
4763
+ },
4764
+ "required": ["type", "url"],
4765
+ "title": "AudioUserInput",
4766
+ "type": "object"
4767
+ },
4768
+ {
4769
+ "properties": {
4770
+ "path": { "type": "string" },
4771
+ "type": {
4772
+ "enum": ["localAudio"],
4773
+ "title": "LocalAudioUserInputType",
4774
+ "type": "string"
4775
+ }
4776
+ },
4777
+ "required": ["path", "type"],
4778
+ "title": "LocalAudioUserInput",
4779
+ "type": "object"
4780
+ },
4615
4781
  {
4616
4782
  "properties": {
4617
4783
  "name": { "type": "string" },
@@ -4951,31 +5117,47 @@ var TurnStartResponse_default = {
4951
5117
  ],
4952
5118
  "type": "string"
4953
5119
  },
4954
- "DynamicToolCallOutputContentItem": { "oneOf": [{
4955
- "properties": {
4956
- "text": { "type": "string" },
4957
- "type": {
4958
- "enum": ["inputText"],
4959
- "title": "InputTextDynamicToolCallOutputContentItemType",
4960
- "type": "string"
4961
- }
5120
+ "DynamicToolCallOutputContentItem": { "oneOf": [
5121
+ {
5122
+ "properties": {
5123
+ "text": { "type": "string" },
5124
+ "type": {
5125
+ "enum": ["inputText"],
5126
+ "title": "InputTextDynamicToolCallOutputContentItemType",
5127
+ "type": "string"
5128
+ }
5129
+ },
5130
+ "required": ["text", "type"],
5131
+ "title": "InputTextDynamicToolCallOutputContentItem",
5132
+ "type": "object"
4962
5133
  },
4963
- "required": ["text", "type"],
4964
- "title": "InputTextDynamicToolCallOutputContentItem",
4965
- "type": "object"
4966
- }, {
4967
- "properties": {
4968
- "imageUrl": { "type": "string" },
4969
- "type": {
4970
- "enum": ["inputImage"],
4971
- "title": "InputImageDynamicToolCallOutputContentItemType",
4972
- "type": "string"
4973
- }
5134
+ {
5135
+ "properties": {
5136
+ "imageUrl": { "type": "string" },
5137
+ "type": {
5138
+ "enum": ["inputImage"],
5139
+ "title": "InputImageDynamicToolCallOutputContentItemType",
5140
+ "type": "string"
5141
+ }
5142
+ },
5143
+ "required": ["imageUrl", "type"],
5144
+ "title": "InputImageDynamicToolCallOutputContentItem",
5145
+ "type": "object"
4974
5146
  },
4975
- "required": ["imageUrl", "type"],
4976
- "title": "InputImageDynamicToolCallOutputContentItem",
4977
- "type": "object"
4978
- }] },
5147
+ {
5148
+ "properties": {
5149
+ "audioUrl": { "type": "string" },
5150
+ "type": {
5151
+ "enum": ["inputAudio"],
5152
+ "title": "InputAudioDynamicToolCallOutputContentItemType",
5153
+ "type": "string"
5154
+ }
5155
+ },
5156
+ "required": ["audioUrl", "type"],
5157
+ "title": "InputAudioDynamicToolCallOutputContentItem",
5158
+ "type": "object"
5159
+ }
5160
+ ] },
4979
5161
  "DynamicToolCallStatus": {
4980
5162
  "enum": [
4981
5163
  "inProgress",
@@ -5021,8 +5203,7 @@ var TurnStartResponse_default = {
5021
5203
  "appName": { "type": ["string", "null"] },
5022
5204
  "connectorId": { "type": "string" },
5023
5205
  "linkId": { "type": ["string", "null"] },
5024
- "resourceUri": { "type": ["string", "null"] },
5025
- "templateId": { "type": ["string", "null"] }
5206
+ "resourceUri": { "type": ["string", "null"] }
5026
5207
  },
5027
5208
  "required": ["connectorId"],
5028
5209
  "type": "object"
@@ -5522,6 +5703,12 @@ var TurnStartResponse_default = {
5522
5703
  "action": { "anyOf": [{ "$ref": "#/definitions/WebSearchAction" }, { "type": "null" }] },
5523
5704
  "id": { "type": "string" },
5524
5705
  "query": { "type": "string" },
5706
+ "results": {
5707
+ "default": null,
5708
+ "description": "Structured search results returned out-of-band by standalone web search.\n\nThese stay as opaque JSON at the extension/app-server boundary so new result fields and result types can pass through without a Codex release.",
5709
+ "items": true,
5710
+ "type": ["array", "null"]
5711
+ },
5525
5712
  "type": {
5526
5713
  "enum": ["webSearch"],
5527
5714
  "title": "WebSearchThreadItemType",
@@ -5555,6 +5742,7 @@ var TurnStartResponse_default = {
5555
5742
  "type": "object"
5556
5743
  },
5557
5744
  {
5745
+ "description": "Display item emitted by the interruptible `clock.sleep` tool.",
5558
5746
  "properties": {
5559
5747
  "durationMs": {
5560
5748
  "format": "uint64",
@@ -5784,6 +5972,32 @@ var TurnStartResponse_default = {
5784
5972
  "title": "LocalImageUserInput",
5785
5973
  "type": "object"
5786
5974
  },
5975
+ {
5976
+ "properties": {
5977
+ "type": {
5978
+ "enum": ["audio"],
5979
+ "title": "AudioUserInputType",
5980
+ "type": "string"
5981
+ },
5982
+ "url": { "type": "string" }
5983
+ },
5984
+ "required": ["type", "url"],
5985
+ "title": "AudioUserInput",
5986
+ "type": "object"
5987
+ },
5988
+ {
5989
+ "properties": {
5990
+ "path": { "type": "string" },
5991
+ "type": {
5992
+ "enum": ["localAudio"],
5993
+ "title": "LocalAudioUserInputType",
5994
+ "type": "string"
5995
+ }
5996
+ },
5997
+ "required": ["path", "type"],
5998
+ "title": "LocalAudioUserInput",
5999
+ "type": "object"
6000
+ },
5787
6001
  {
5788
6002
  "properties": {
5789
6003
  "name": { "type": "string" },
@@ -6015,6 +6229,11 @@ function assertCodexThreadForkResponse(value) {
6015
6229
  const normalized = normalizeWithDefaults(ThreadStartResponse_default, value);
6016
6230
  return assertCodexShape(validateThreadStartResponse, normalized, "thread/fork response");
6017
6231
  }
6232
+ /** Asserts the experimental beforeTurnId request field before it crosses the app-server boundary. */
6233
+ function assertCodexThreadForkParams(value) {
6234
+ if (!isRecord(value) || typeof value.threadId !== "string" || !value.threadId.trim() || value.beforeTurnId !== void 0 && value.beforeTurnId !== null && typeof value.beforeTurnId !== "string") throw new Error("Invalid Codex app-server thread/fork params");
6235
+ return value;
6236
+ }
6018
6237
  /** Asserts and normalizes a Codex thread/resume response. */
6019
6238
  function assertCodexThreadResumeResponse(value) {
6020
6239
  const normalized = normalizeWithDefaults(ThreadResumeResponse_default, value);
@@ -6115,483 +6334,4 @@ function formatValidationErrors(validate, value) {
6115
6334
  }).join("; ");
6116
6335
  }
6117
6336
  //#endregion
6118
- //#region extensions/codex/src/app-server/upstream-prompt-provenance.ts
6119
- const UPSTREAM_USER_TEXT_META_KEY = "upstreamUserText";
6120
- const MIRROR_IDENTITY_META_KEY = "mirrorIdentity";
6121
- function attachCodexMirrorIdentity(message, identity) {
6122
- const record = message;
6123
- const existing = record["__openclaw"];
6124
- const baseMeta = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
6125
- return {
6126
- ...record,
6127
- __openclaw: {
6128
- ...baseMeta,
6129
- [MIRROR_IDENTITY_META_KEY]: identity
6130
- }
6131
- };
6132
- }
6133
- function readMirrorIdentity(message) {
6134
- const meta = message["__openclaw"];
6135
- if (!meta || typeof meta !== "object" || Array.isArray(meta)) return;
6136
- const id = meta[MIRROR_IDENTITY_META_KEY];
6137
- return typeof id === "string" && id ? id : void 0;
6138
- }
6139
- function attachUpstreamUserText(message, text) {
6140
- const record = message;
6141
- const existing = record["__openclaw"];
6142
- const baseMeta = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
6143
- return {
6144
- ...record,
6145
- __openclaw: {
6146
- ...baseMeta,
6147
- [UPSTREAM_USER_TEXT_META_KEY]: text
6148
- }
6149
- };
6150
- }
6151
- function readUpstreamUserText(message) {
6152
- const meta = message?.["__openclaw"];
6153
- if (!meta || typeof meta !== "object" || Array.isArray(meta)) return;
6154
- const text = meta[UPSTREAM_USER_TEXT_META_KEY];
6155
- return typeof text === "string" && text ? text : void 0;
6156
- }
6157
- //#endregion
6158
- //#region extensions/codex/src/app-server/user-prompt-message.ts
6159
- function buildSenderLabel(params) {
6160
- const label = params.senderName ?? params.senderUsername ?? params.senderE164 ?? params.senderId;
6161
- if (!label) return;
6162
- return !params.senderId || label.includes(params.senderId) ? label : `${label} (${params.senderId})`;
6163
- }
6164
- function buildFromPrepared(params, preparedUserMessage) {
6165
- const senderId = normalizeOptionalString(params.senderId);
6166
- const senderName = normalizeOptionalString(params.senderName);
6167
- const senderUsername = normalizeOptionalString(params.senderUsername);
6168
- const senderE164 = normalizeOptionalString(params.senderE164);
6169
- const senderLabel = buildSenderLabel({
6170
- senderId,
6171
- senderName,
6172
- senderUsername,
6173
- senderE164
6174
- });
6175
- const sourceChannel = normalizeOptionalString(params.inputProvenance?.sourceChannel ?? params.messageChannel ?? params.messageProvider);
6176
- return {
6177
- role: "user",
6178
- timestamp: Date.now(),
6179
- ...params.inputProvenance ? { provenance: params.inputProvenance } : {},
6180
- ...sourceChannel ? { sourceChannel } : {},
6181
- ...senderId ? { senderId } : {},
6182
- ...senderName ? { senderName } : {},
6183
- ...senderUsername ? { senderUsername } : {},
6184
- ...senderE164 ? { senderE164 } : {},
6185
- ...senderLabel ? { senderLabel } : {},
6186
- ...preparedUserMessage ? preparedUserMessage : { content: params.prompt }
6187
- };
6188
- }
6189
- function buildCodexUserPromptMessage(params) {
6190
- return buildFromPrepared(params, params.userTurnTranscriptRecorder?.message);
6191
- }
6192
- function buildCodexUpstreamPromptMessage(params, identity, upstreamUserText) {
6193
- const message = attachCodexMirrorIdentity(buildCodexUserPromptMessage(params), identity);
6194
- return upstreamUserText ? attachUpstreamUserText(message, upstreamUserText) : message;
6195
- }
6196
- function promptSnapshot(params, turnId, upstreamUserText) {
6197
- return params.suppressNextUserMessagePersistence ? [] : [buildCodexUpstreamPromptMessage(params, `${turnId}:prompt`, upstreamUserText)];
6198
- }
6199
- async function buildResolvedCodexUserPromptMessage(params) {
6200
- return buildFromPrepared(params, await params.userTurnTranscriptRecorder?.resolveMessage() ?? params.userTurnTranscriptRecorder?.message);
6201
- }
6202
- //#endregion
6203
- //#region extensions/codex/src/app-server/transcript-mirror.ts
6204
- const MIRROR_ORIGIN_META_KEY = "mirrorOrigin";
6205
- const CODEX_APP_SERVER_MIRROR_ORIGIN = "codex-app-server";
6206
- const CODEX_HISTORY_IMPORT_MAX_MESSAGES = 200;
6207
- const CODEX_HISTORY_IMPORT_MAX_BYTES = 512 * 1024;
6208
- const CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES = 64 * 1024;
6209
- const CODEX_HISTORY_TRUNCATION_SUFFIX = "\n\n[Message truncated during Codex history import.]";
6210
- const CODEX_HISTORY_ASSISTANT_API = "openai-chatgpt-responses";
6211
- const CODEX_HISTORY_ASSISTANT_PROVIDER = "openai";
6212
- const CODEX_HISTORY_ASSISTANT_MODEL = "native-history";
6213
- const CODEX_HISTORY_ZERO_USAGE = {
6214
- input: 0,
6215
- output: 0,
6216
- cacheRead: 0,
6217
- cacheWrite: 0,
6218
- totalTokens: 0,
6219
- cost: {
6220
- input: 0,
6221
- output: 0,
6222
- cacheRead: 0,
6223
- cacheWrite: 0,
6224
- total: 0
6225
- }
6226
- };
6227
- function isUtf8ContinuationByte(byte) {
6228
- return byte !== void 0 && (byte & 192) === 128;
6229
- }
6230
- function truncateUtf8Prefix(value, maxBytes) {
6231
- const bytes = Buffer.from(value);
6232
- if (bytes.byteLength <= maxBytes) return value;
6233
- let end = Math.max(0, maxBytes);
6234
- while (end > 0 && isUtf8ContinuationByte(bytes[end])) end -= 1;
6235
- return bytes.subarray(0, end).toString("utf8");
6236
- }
6237
- function normalizeImportedHistoryText(value) {
6238
- if (typeof value !== "string") return;
6239
- const text = value.trim();
6240
- if (!text) return;
6241
- if (Buffer.byteLength(text, "utf8") <= CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES) return text;
6242
- const suffixBytes = Buffer.byteLength(CODEX_HISTORY_TRUNCATION_SUFFIX, "utf8");
6243
- return `${truncateUtf8Prefix(text, Math.max(0, CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES - suffixBytes))}${CODEX_HISTORY_TRUNCATION_SUFFIX}`;
6244
- }
6245
- function projectCodexUserItemText(item) {
6246
- if (!Array.isArray(item.content)) return;
6247
- const parts = [];
6248
- for (const value of item.content) {
6249
- if (!value || typeof value !== "object" || Array.isArray(value)) continue;
6250
- const input = value;
6251
- if (input.type === "text") {
6252
- const text = normalizeImportedHistoryText(input.text);
6253
- if (text) parts.push(text);
6254
- continue;
6255
- }
6256
- if (input.type === "image" || input.type === "localImage") {
6257
- parts.push("[Image attachment]");
6258
- continue;
6259
- }
6260
- if (input.type === "skill" || input.type === "mention") {
6261
- const name = normalizeOptionalString(input.name);
6262
- if (name) parts.push(`${input.type === "skill" ? "$" : "@"}${name}`);
6263
- }
6264
- }
6265
- return normalizeImportedHistoryText(parts.join("\n"));
6266
- }
6267
- function selectTurnsThroughBoundary(thread, throughTurnId) {
6268
- if (throughTurnId === null) return [];
6269
- const turns = thread.turns ?? [];
6270
- const boundaryIndex = turns.findIndex((turn) => turn.id === throughTurnId);
6271
- if (boundaryIndex < 0) throw new Error(`Codex history boundary turn not found: ${throughTurnId}`);
6272
- const boundary = turns[boundaryIndex];
6273
- if (boundary?.status !== "completed" && boundary?.status !== "interrupted" && boundary?.status !== "failed") throw new Error(`Codex history boundary turn is not terminal: ${throughTurnId}`);
6274
- return turns.slice(0, boundaryIndex + 1);
6275
- }
6276
- function projectCodexThreadHistory(params) {
6277
- const projected = [];
6278
- const threadTimestamp = typeof params.thread.createdAt === "number" && Number.isFinite(params.thread.createdAt) ? params.thread.createdAt * 1e3 : params.importedAt;
6279
- let itemOffset = 0;
6280
- for (const turn of selectTurnsThroughBoundary(params.thread, params.throughTurnId)) for (const value of turn.items) {
6281
- const item = value;
6282
- const itemId = normalizeOptionalString(item.id);
6283
- const identity = `${turn.id}:${itemId ?? itemOffset}`;
6284
- const timestampSeconds = item.type === "agentMessage" ? turn.completedAt ?? turn.startedAt : turn.startedAt ?? turn.completedAt;
6285
- const timestamp = typeof timestampSeconds === "number" && Number.isFinite(timestampSeconds) ? timestampSeconds * 1e3 + itemOffset : threadTimestamp + itemOffset;
6286
- const text = item.type === "userMessage" ? projectCodexUserItemText(item) : item.type === "agentMessage" ? normalizeImportedHistoryText(item.text) : void 0;
6287
- const role = item.type === "userMessage" ? "user" : item.type === "agentMessage" ? "assistant" : void 0;
6288
- itemOffset += 1;
6289
- if (!text || !role) continue;
6290
- const message = role === "assistant" ? attachCodexMirrorIdentity({
6291
- role,
6292
- content: [{
6293
- type: "text",
6294
- text
6295
- }],
6296
- api: CODEX_HISTORY_ASSISTANT_API,
6297
- provider: normalizeOptionalString(params.modelProvider) ?? normalizeOptionalString(params.thread.modelProvider) ?? CODEX_HISTORY_ASSISTANT_PROVIDER,
6298
- model: CODEX_HISTORY_ASSISTANT_MODEL,
6299
- usage: CODEX_HISTORY_ZERO_USAGE,
6300
- stopReason: "stop",
6301
- timestamp
6302
- }, identity) : attachCodexMirrorIdentity({
6303
- role,
6304
- content: text,
6305
- timestamp
6306
- }, identity);
6307
- const phase = item.phase === "commentary" || item.phase === "final_answer" ? item.phase : void 0;
6308
- projected.push({
6309
- message,
6310
- responseItem: {
6311
- type: "message",
6312
- role,
6313
- content: [{
6314
- type: role === "assistant" ? "output_text" : "input_text",
6315
- text
6316
- }],
6317
- ...role === "assistant" && phase ? { phase } : {}
6318
- },
6319
- textBytes: Buffer.byteLength(text, "utf8")
6320
- });
6321
- }
6322
- return projected;
6323
- }
6324
- function selectBoundedCodexHistoryTail(projected) {
6325
- const selected = [];
6326
- let selectedBytes = 0;
6327
- for (let index = projected.length - 1; index >= 0; index -= 1) {
6328
- const candidate = projected[index];
6329
- if (!candidate) continue;
6330
- if (selected.length >= CODEX_HISTORY_IMPORT_MAX_MESSAGES || selectedBytes + candidate.textBytes > CODEX_HISTORY_IMPORT_MAX_BYTES) break;
6331
- selected.push(candidate);
6332
- selectedBytes += candidate.textBytes;
6333
- }
6334
- return selected.toReversed();
6335
- }
6336
- /** Projects one terminal Codex history prefix into transcript and Responses API items. */
6337
- function projectBoundedCodexThreadHistory(params) {
6338
- const projected = projectCodexThreadHistory({
6339
- thread: params.thread,
6340
- throughTurnId: params.throughTurnId,
6341
- importedAt: params.importedAt,
6342
- ...params.modelProvider ? { modelProvider: params.modelProvider } : {}
6343
- });
6344
- const selected = selectBoundedCodexHistoryTail(projected);
6345
- return {
6346
- importedMessages: selected.length,
6347
- omittedMessages: projected.length - selected.length,
6348
- responseItems: selected.map(({ responseItem }) => responseItem),
6349
- transcriptMessages: selected.map(({ message }) => message)
6350
- };
6351
- }
6352
- /** Imports a bounded, user-visible Codex history tail into a new OpenClaw transcript. */
6353
- async function importCodexThreadHistoryToTranscript(params) {
6354
- const projection = projectBoundedCodexThreadHistory({
6355
- thread: params.thread,
6356
- throughTurnId: params.throughTurnId,
6357
- importedAt: Date.now(),
6358
- ...params.modelProvider ? { modelProvider: params.modelProvider } : {}
6359
- });
6360
- if (projection.transcriptMessages.length > 0) await mirror({
6361
- storePath: params.storePath,
6362
- sessionId: params.sessionId,
6363
- sessionKey: params.sessionKey,
6364
- ...params.agentId ? { agentId: params.agentId } : {},
6365
- ...params.cwd ? { cwd: params.cwd } : {},
6366
- ...params.config ? { config: params.config } : {},
6367
- messages: projection.transcriptMessages,
6368
- idempotencyScope: `codex-app-server:${params.thread.id}:history`
6369
- });
6370
- return {
6371
- importedMessages: projection.importedMessages,
6372
- omittedMessages: projection.omittedMessages
6373
- };
6374
- }
6375
- function attachCodexMirrorOrigin(message) {
6376
- const record = message;
6377
- const existing = record["__openclaw"];
6378
- const baseMeta = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
6379
- return {
6380
- ...record,
6381
- __openclaw: {
6382
- ...baseMeta,
6383
- [MIRROR_ORIGIN_META_KEY]: CODEX_APP_SERVER_MIRROR_ORIGIN
6384
- }
6385
- };
6386
- }
6387
- async function mirrorBestEffort(params) {
6388
- try {
6389
- const messages = await resolveFinalCodexMirrorMessages({
6390
- params: params.params,
6391
- messagesSnapshot: params.result.messagesSnapshot,
6392
- turnId: params.turnId
6393
- });
6394
- const mirrorResult = await mirror({
6395
- agentId: params.agentId,
6396
- sessionKey: params.sessionKey,
6397
- sessionId: params.params.sessionId,
6398
- storePath: params.params.sessionTarget?.storePath,
6399
- cwd: params.cwd,
6400
- messages,
6401
- idempotencyScope: `codex-app-server:${params.threadId}`,
6402
- config: params.params.config
6403
- });
6404
- for (const message of mirrorResult.userMessagesPresent) try {
6405
- params.notifyUserMessagePersisted(message);
6406
- } catch (error) {
6407
- embeddedAgentLog.warn("failed to notify codex app-server user-message persistence", { error: formatErrorMessage(error) });
6408
- }
6409
- return mirrorResult.assistantMirrorIdentitiesOwned.includes(`${params.turnId}:assistant`);
6410
- } catch (error) {
6411
- embeddedAgentLog.warn("failed to mirror codex app-server transcript", { error });
6412
- return false;
6413
- }
6414
- }
6415
- async function resolveFinalCodexMirrorMessages(params) {
6416
- if (params.params.suppressNextUserMessagePersistence || !params.params.userTurnTranscriptRecorder) return params.messagesSnapshot;
6417
- const promptSnapshot = params.messagesSnapshot.find((message) => message.role === "user");
6418
- const resolvedBase = attachCodexMirrorIdentity(await buildResolvedCodexUserPromptMessage(params.params), `${params.turnId}:prompt`);
6419
- const upstreamUserText = readUpstreamUserText(promptSnapshot);
6420
- const resolvedPrompt = upstreamUserText ? attachUpstreamUserText(resolvedBase, upstreamUserText) : resolvedBase;
6421
- const firstUserIndex = params.messagesSnapshot.findIndex((message) => message.role === "user");
6422
- if (firstUserIndex === -1) return [resolvedPrompt, ...params.messagesSnapshot];
6423
- const messages = params.messagesSnapshot.slice();
6424
- messages[firstUserIndex] = resolvedPrompt;
6425
- return messages;
6426
- }
6427
- function createCodexAppServerUserMessagePersistenceNotifier(runParams) {
6428
- let notified = false;
6429
- return (message) => {
6430
- if (notified) return;
6431
- notified = true;
6432
- runParams.userTurnTranscriptRecorder?.markRuntimePersisted(message);
6433
- try {
6434
- runParams.onUserMessagePersisted?.(message);
6435
- } catch (error) {
6436
- embeddedAgentLog.warn("codex app-server user persistence notification failed", { error: formatErrorMessage(error) });
6437
- }
6438
- };
6439
- }
6440
- async function mirrorPromptAtTurnStartBestEffort(params) {
6441
- if (params.params.suppressNextUserMessagePersistence) return;
6442
- try {
6443
- const mirrorPromise = (async () => {
6444
- const userPromptMessage = attachUpstreamUserText(attachCodexMirrorIdentity(await buildResolvedCodexUserPromptMessage(params.params), `${params.turnId}:prompt`), params.upstreamUserText);
6445
- const mirrorResult = await mirror({
6446
- agentId: params.agentId,
6447
- sessionKey: params.sessionKey,
6448
- sessionId: params.params.sessionId,
6449
- storePath: params.params.sessionTarget?.storePath,
6450
- cwd: params.cwd,
6451
- messages: [userPromptMessage],
6452
- idempotencyScope: `codex-app-server:${params.threadId}`,
6453
- config: params.params.config
6454
- });
6455
- for (const message of mirrorResult.userMessagesPresent) params.notifyUserMessagePersisted(message);
6456
- })();
6457
- params.params.userTurnTranscriptRecorder?.markRuntimePersistencePending(mirrorPromise);
6458
- await mirrorPromise;
6459
- } catch (error) {
6460
- embeddedAgentLog.warn("failed to mirror codex app-server prompt at turn start", { error });
6461
- }
6462
- }
6463
- function fingerprintMirrorMessageContent(message) {
6464
- const payload = JSON.stringify({
6465
- role: message.role,
6466
- content: message.content
6467
- });
6468
- return createHash("sha256").update(payload).digest("hex").slice(0, 16);
6469
- }
6470
- function buildMirrorDedupeIdentity(message) {
6471
- const explicit = readMirrorIdentity(message);
6472
- if (explicit) return explicit;
6473
- return `${message.role}:${fingerprintMirrorMessageContent(message)}`;
6474
- }
6475
- async function mirror(params) {
6476
- const messages = params.messages.filter((message) => message.role === "user" || message.role === "assistant" || message.role === "toolResult");
6477
- if (messages.length === 0) return {
6478
- assistantMirrorIdentitiesOwned: [],
6479
- userMessagesPresent: []
6480
- };
6481
- const transcriptTarget = resolveCodexMirrorTranscriptTarget(params);
6482
- const { appendedUpdates, assistantMirrorIdentitiesOwned, userMessagesPresent } = await withSessionTranscriptWriteLock({
6483
- ...transcriptTarget,
6484
- config: params.config
6485
- }, async (transcript) => {
6486
- const nextAppendedUpdates = [];
6487
- const nextAssistantMirrorIdentitiesOwned = /* @__PURE__ */ new Set();
6488
- const nextUserMessagesPresent = [];
6489
- const mirrorState = readTranscriptMirrorState(await transcript.readEvents());
6490
- let nextMessageSeq = mirrorState.messageCount;
6491
- for (const message of messages) {
6492
- const dedupeIdentity = buildMirrorDedupeIdentity(message);
6493
- const idempotencyKey = (message.role === "user" ? normalizeOptionalString(message.idempotencyKey) : void 0) ?? (params.idempotencyScope ? `${params.idempotencyScope}:${dedupeIdentity}` : void 0);
6494
- const transcriptMessage = {
6495
- ...attachCodexMirrorOrigin(message),
6496
- ...idempotencyKey ? { idempotencyKey } : {}
6497
- };
6498
- if (idempotencyKey && mirrorState.idempotencyKeys.has(idempotencyKey)) {
6499
- const persistedUserMessage = mirrorState.userMessagesByIdempotencyKey.get(idempotencyKey);
6500
- if (persistedUserMessage) nextUserMessagesPresent.push(persistedUserMessage);
6501
- if (message.role === "assistant") nextAssistantMirrorIdentitiesOwned.add(dedupeIdentity);
6502
- continue;
6503
- }
6504
- const nextMessage = runAgentHarnessBeforeMessageWriteHook({
6505
- message: transcriptMessage,
6506
- agentId: params.agentId,
6507
- sessionKey: params.sessionKey
6508
- });
6509
- if (!nextMessage) {
6510
- if (message.role === "assistant") nextAssistantMirrorIdentitiesOwned.add(dedupeIdentity);
6511
- continue;
6512
- }
6513
- const messageToAppend = idempotencyKey ? {
6514
- ...attachCodexMirrorOrigin(nextMessage),
6515
- idempotencyKey
6516
- } : attachCodexMirrorOrigin(nextMessage);
6517
- const appended = await transcript.appendMessage({
6518
- message: messageToAppend,
6519
- idempotencyLookup: idempotencyKey ? "caller-checked" : "scan",
6520
- cwd: params.cwd
6521
- });
6522
- if (!appended) continue;
6523
- const { messageId, message: appendedMessage } = appended;
6524
- if (message.role === "assistant") nextAssistantMirrorIdentitiesOwned.add(dedupeIdentity);
6525
- if (appendedMessage.role === "user") {
6526
- nextUserMessagesPresent.push(appendedMessage);
6527
- if (idempotencyKey) mirrorState.userMessagesByIdempotencyKey.set(idempotencyKey, appendedMessage);
6528
- }
6529
- nextMessageSeq += 1;
6530
- nextAppendedUpdates.push({
6531
- messageId,
6532
- message: appendedMessage,
6533
- messageSeq: nextMessageSeq
6534
- });
6535
- if (idempotencyKey) mirrorState.idempotencyKeys.add(idempotencyKey);
6536
- }
6537
- return {
6538
- appendedUpdates: nextAppendedUpdates,
6539
- assistantMirrorIdentitiesOwned: [...nextAssistantMirrorIdentitiesOwned],
6540
- userMessagesPresent: nextUserMessagesPresent
6541
- };
6542
- });
6543
- for (const update of appendedUpdates) try {
6544
- await publishSessionTranscriptUpdateByIdentity({
6545
- ...transcriptTarget,
6546
- update: {
6547
- ...params.agentId ? { agentId: params.agentId } : {},
6548
- message: update.message,
6549
- messageId: update.messageId,
6550
- messageSeq: update.messageSeq,
6551
- sessionKey: transcriptTarget.sessionKey
6552
- }
6553
- });
6554
- } catch (error) {
6555
- embeddedAgentLog.warn("failed to publish codex app-server transcript update", { error: formatErrorMessage(error) });
6556
- }
6557
- return {
6558
- assistantMirrorIdentitiesOwned,
6559
- userMessagesPresent
6560
- };
6561
- }
6562
- const codexTranscriptMirrorRuntime = {
6563
- mirror,
6564
- mirrorBestEffort
6565
- };
6566
- function resolveCodexMirrorTranscriptTarget(params) {
6567
- const sessionKey = params.sessionKey?.trim();
6568
- const storePath = params.storePath?.trim();
6569
- if (!sessionKey || !storePath) throw new Error("Codex transcript mirror requires a runtime session identity");
6570
- return {
6571
- ...params.agentId ? { agentId: params.agentId } : {},
6572
- sessionId: params.sessionId,
6573
- sessionKey,
6574
- storePath
6575
- };
6576
- }
6577
- function readTranscriptMirrorState(events) {
6578
- const idempotencyKeys = /* @__PURE__ */ new Set();
6579
- const userMessagesByIdempotencyKey = /* @__PURE__ */ new Map();
6580
- let messageCount = 0;
6581
- for (const event of events) {
6582
- if (!event || typeof event !== "object" || Array.isArray(event)) continue;
6583
- const parsed = event;
6584
- if (parsed.type === "message") messageCount += 1;
6585
- if (typeof parsed.message?.idempotencyKey === "string") {
6586
- idempotencyKeys.add(parsed.message.idempotencyKey);
6587
- if (parsed.message.role === "user") userMessagesByIdempotencyKey.set(parsed.message.idempotencyKey, parsed.message);
6588
- }
6589
- }
6590
- return {
6591
- idempotencyKeys,
6592
- messageCount,
6593
- userMessagesByIdempotencyKey
6594
- };
6595
- }
6596
- //#endregion
6597
- export { readCodexTurnCompletedNotification as _, projectBoundedCodexThreadHistory as a, attachCodexMirrorIdentity as c, assertCodexThreadStartResponse as d, assertCodexTurnStartResponse as f, readCodexTurn as g, readCodexModelListResponse as h, mirrorPromptAtTurnStartBestEffort as i, assertCodexThreadForkResponse as l, readCodexErrorNotification as m, createCodexAppServerUserMessagePersistenceNotifier as n, buildCodexUserPromptMessage as o, readCodexDynamicToolCallParams as p, importCodexThreadHistoryToTranscript as r, promptSnapshot as s, codexTranscriptMirrorRuntime as t, assertCodexThreadResumeResponse as u };
6337
+ export { assertCodexTurnStartResponse as a, readCodexModelListResponse as c, assertCodexThreadStartResponse as i, readCodexTurn as l, assertCodexThreadForkResponse as n, readCodexDynamicToolCallParams as o, assertCodexThreadResumeResponse as r, readCodexErrorNotification as s, assertCodexThreadForkParams as t, readCodexTurnCompletedNotification as u };