@openclaw/codex 2026.7.2-beta.7 → 2026.7.33

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/README.md +3 -27
  2. package/dist/{command-formatters-C336eRVS.js → .setup/app-server-policy-C_qTMEMy.mjs} +51 -9
  3. package/dist/{attempt-notifications-AP-a-Q5k.js → .setup/attempt-notifications-F8krwWL4.mjs} +6 -3
  4. package/dist/{command-handlers-DAHUSry9.js → .setup/command-handlers-DSRFfor4.mjs} +1156 -1319
  5. package/dist/.setup/command-rpc-BvYsfQ7G.mjs +786 -0
  6. package/dist/{compact-D_uvHurS.js → .setup/compact-BNgh7I4t.mjs} +10 -40
  7. package/dist/.setup/computer-use-C3QkmSO3.mjs +377 -0
  8. package/dist/.setup/config-CYEDnLJ2.mjs +1138 -0
  9. package/dist/{conversation-binding-data-BHRpYbX3.js → .setup/conversation-binding-data-CrRxtDBu.mjs} +1 -1
  10. package/dist/{bounded-turn-D2ZAgZVz.js → .setup/media-understanding-provider-EbJCyDqe.mjs} +203 -109
  11. package/dist/{models-BBMKU4jA.js → .setup/models-C_aZk03A.mjs} +11 -6
  12. package/dist/.setup/notification-correlation-iYs4WieS.mjs +35 -0
  13. package/dist/.setup/plugin-app-cache-key-DR8jV9oS.mjs +99 -0
  14. package/dist/.setup/protocol-2POPqAY4.mjs +13 -0
  15. package/dist/{transcript-mirror-DzsdNCf5.js → .setup/protocol-validators-dZQ-UTOa.mjs} +112 -922
  16. package/dist/{rate-limits-CU-gVCCS.js → .setup/provider-DGxDs6g8.mjs} +269 -13
  17. package/dist/{dynamic-tools-D2gYkSBO.js → .setup/provider-capabilities-DS2N_zc1.mjs} +5632 -3953
  18. package/dist/.setup/request-DFR0JyoV.mjs +36 -0
  19. package/dist/.setup/run-attempt-C7xEKFVB.mjs +8180 -0
  20. package/dist/{sandbox-guard-NuhpXmPB.js → .setup/sandbox-guard-DA2TQfZW.mjs} +1 -14
  21. package/dist/.setup/session-binding-DuihlMJc.mjs +628 -0
  22. package/dist/.setup/shared-client-B2KmLPRw.mjs +1854 -0
  23. package/dist/{side-question-_ulBk1AL.js → .setup/side-question-Cv6JXWCS.mjs} +84 -159
  24. package/dist/.setup/thread-lifecycle-u6CZdOOH.mjs +2593 -0
  25. package/dist/{web-search-provider.runtime-CCFhg2z5.js → .setup/web-search-provider.runtime-Ce2zOHxW.mjs} +3 -3
  26. package/dist/doctor-contract-api.js +122 -88
  27. package/dist/harness.js +20 -89
  28. package/dist/index.js +436 -1615
  29. package/dist/media-understanding-provider.js +1 -173
  30. package/dist/prompt-overlay.js +15 -0
  31. package/dist/provider-catalog.js +79 -0
  32. package/dist/provider-discovery.js +34 -0
  33. package/dist/provider.js +2 -0
  34. package/dist/web-search-contract-api.js +1 -1
  35. package/openclaw.plugin.json +178 -221
  36. package/package.json +8 -9
  37. package/dist/app-server-policy-BSaO2JIT.js +0 -49
  38. package/dist/auth-binding-B4FfbcCg.js +0 -62
  39. package/dist/capabilities-BFDTVYr4.js +0 -36
  40. package/dist/cli-metadata.js +0 -20
  41. package/dist/computer-use-CYEc8U3w.js +0 -693
  42. package/dist/conversation-control-xsIeXbo4.js +0 -287
  43. package/dist/effective-mcp-catalog-Bbd98Inw.js +0 -114
  44. package/dist/event-projector-assistant-message-DTgnPPVF.js +0 -101
  45. package/dist/event-projector-usage-Xp4AlR2k.js +0 -86
  46. package/dist/incognito-session-ET_ufDH-.js +0 -2
  47. package/dist/notification-correlation-CU6_AnOb.js +0 -67
  48. package/dist/plugin-app-cache-key-DztPafOA.js +0 -408
  49. package/dist/request-qKh331yu.js +0 -157
  50. package/dist/run-attempt-CY9WlDLc.js +0 -12413
  51. package/dist/runtime-artifact-CmtG_t1L.js +0 -554
  52. package/dist/session-binding-BXpo9ymA.js +0 -2214
  53. package/dist/session-catalog-DyOgR4WH.js +0 -2668
  54. package/dist/session-cli-2PZaFLRh.js +0 -175
  55. package/dist/session-upstream-marker-B6U7tLw5.js +0 -82
  56. package/dist/settled-turn-finalizer-CXY2Z9dT.js +0 -316
  57. package/dist/shared-client-DTbvH-XV.js +0 -3069
  58. package/dist/thread-lifecycle-DF53ogiA.js +0 -3987
  59. package/dist/transport-stdio-DXgGZ7Ib.js +0 -88
  60. package/dist/upstream-session-fork-Dy4Xvuoj.js +0 -320
  61. package/dist/usage-CQ6GhD5-.js +0 -25
  62. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  63. /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
  64. /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
@@ -1,10 +1,5 @@
1
- import { embeddedAgentLog, formatErrorMessage, projectAgentHarnessTranscriptMessageForDisplay, runAgentHarnessBeforeMessageWriteHook } from "openclaw/plugin-sdk/agent-harness-runtime";
2
- import { createHash } from "node:crypto";
3
- import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
4
2
  import { Compile } from "typebox/compile";
5
- import { Buffer } from "node:buffer";
6
- import { withCodexSessionTranscriptMirrorWriteLock } from "openclaw/plugin-sdk/codex-session-transcript-runtime";
7
- import { publishSessionTranscriptUpdateByIdentity } from "openclaw/plugin-sdk/session-transcript-runtime";
8
3
  //#region extensions/codex/src/app-server/protocol-generated/json/DynamicToolCallParams.json
9
4
  var DynamicToolCallParams_default = {
10
5
  $schema: "http://json-schema.org/draft-07/schema#",
@@ -162,23 +157,15 @@ var ModelListResponse_default = {
162
157
  definitions: {
163
158
  "InputModality": {
164
159
  "description": "Canonical user-input modality tags advertised by a model.",
165
- "oneOf": [
166
- {
167
- "description": "Plain text turns and tool payloads.",
168
- "enum": ["text"],
169
- "type": "string"
170
- },
171
- {
172
- "description": "Image attachments included in user turns.",
173
- "enum": ["image"],
174
- "type": "string"
175
- },
176
- {
177
- "description": "Audio attachments included in user turns.",
178
- "enum": ["audio"],
179
- "type": "string"
180
- }
181
- ]
160
+ "oneOf": [{
161
+ "description": "Plain text turns and tool payloads.",
162
+ "enum": ["text"],
163
+ "type": "string"
164
+ }, {
165
+ "description": "Image attachments included in user turns.",
166
+ "enum": ["image"],
167
+ "type": "string"
168
+ }]
182
169
  },
183
170
  "Model": {
184
171
  "properties": {
@@ -586,47 +573,31 @@ var ThreadResumeResponse_default = {
586
573
  ],
587
574
  "type": "string"
588
575
  },
589
- "DynamicToolCallOutputContentItem": { "oneOf": [
590
- {
591
- "properties": {
592
- "text": { "type": "string" },
593
- "type": {
594
- "enum": ["inputText"],
595
- "title": "InputTextDynamicToolCallOutputContentItemType",
596
- "type": "string"
597
- }
598
- },
599
- "required": ["text", "type"],
600
- "title": "InputTextDynamicToolCallOutputContentItem",
601
- "type": "object"
576
+ "DynamicToolCallOutputContentItem": { "oneOf": [{
577
+ "properties": {
578
+ "text": { "type": "string" },
579
+ "type": {
580
+ "enum": ["inputText"],
581
+ "title": "InputTextDynamicToolCallOutputContentItemType",
582
+ "type": "string"
583
+ }
602
584
  },
603
- {
604
- "properties": {
605
- "imageUrl": { "type": "string" },
606
- "type": {
607
- "enum": ["inputImage"],
608
- "title": "InputImageDynamicToolCallOutputContentItemType",
609
- "type": "string"
610
- }
611
- },
612
- "required": ["imageUrl", "type"],
613
- "title": "InputImageDynamicToolCallOutputContentItem",
614
- "type": "object"
585
+ "required": ["text", "type"],
586
+ "title": "InputTextDynamicToolCallOutputContentItem",
587
+ "type": "object"
588
+ }, {
589
+ "properties": {
590
+ "imageUrl": { "type": "string" },
591
+ "type": {
592
+ "enum": ["inputImage"],
593
+ "title": "InputImageDynamicToolCallOutputContentItemType",
594
+ "type": "string"
595
+ }
615
596
  },
616
- {
617
- "properties": {
618
- "audioUrl": { "type": "string" },
619
- "type": {
620
- "enum": ["inputAudio"],
621
- "title": "InputAudioDynamicToolCallOutputContentItemType",
622
- "type": "string"
623
- }
624
- },
625
- "required": ["audioUrl", "type"],
626
- "title": "InputAudioDynamicToolCallOutputContentItem",
627
- "type": "object"
628
- }
629
- ] },
597
+ "required": ["imageUrl", "type"],
598
+ "title": "InputImageDynamicToolCallOutputContentItem",
599
+ "type": "object"
600
+ }] },
630
601
  "DynamicToolCallStatus": {
631
602
  "enum": [
632
603
  "inProgress",
@@ -680,7 +651,8 @@ var ThreadResumeResponse_default = {
680
651
  "appName": { "type": ["string", "null"] },
681
652
  "connectorId": { "type": "string" },
682
653
  "linkId": { "type": ["string", "null"] },
683
- "resourceUri": { "type": ["string", "null"] }
654
+ "resourceUri": { "type": ["string", "null"] },
655
+ "templateId": { "type": ["string", "null"] }
684
656
  },
685
657
  "required": ["connectorId"],
686
658
  "type": "object"
@@ -1006,10 +978,6 @@ var ThreadResumeResponse_default = {
1006
978
  "description": "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
1007
979
  "type": ["string", "null"]
1008
980
  },
1009
- "canAcceptDirectInput": {
1010
- "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.",
1011
- "type": ["boolean", "null"]
1012
- },
1013
981
  "cliVersion": {
1014
982
  "description": "Version of the CLI that created the thread.",
1015
983
  "type": "string"
@@ -1048,11 +1016,6 @@ var ThreadResumeResponse_default = {
1048
1016
  "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
1049
1017
  "type": "string"
1050
1018
  },
1051
- "isPinned": {
1052
- "default": false,
1053
- "description": "Whether the thread has been pinned by the user.",
1054
- "type": "boolean"
1055
- },
1056
1019
  "modelProvider": {
1057
1020
  "description": "Model provider used for this thread (for example, 'openai').",
1058
1021
  "type": "string"
@@ -1276,20 +1239,10 @@ var ThreadResumeResponse_default = {
1276
1239
  "type": ["integer", "null"]
1277
1240
  },
1278
1241
  "id": { "type": "string" },
1279
- "pluginId": {
1280
- "default": null,
1281
- "description": "Trusted first-party plugin id when this command resolves to one plugin script.",
1282
- "type": ["string", "null"]
1283
- },
1284
1242
  "processId": {
1285
1243
  "description": "Identifier for the underlying PTY process (when available).",
1286
1244
  "type": ["string", "null"]
1287
1245
  },
1288
- "scriptPath": {
1289
- "default": null,
1290
- "description": "Safe plugin-relative path when this command resolves to one plugin script.",
1291
- "type": ["string", "null"]
1292
- },
1293
1246
  "source": {
1294
1247
  "allOf": [{ "$ref": "#/definitions/CommandExecutionSource" }],
1295
1248
  "default": "agent"
@@ -1490,12 +1443,6 @@ var ThreadResumeResponse_default = {
1490
1443
  "action": { "anyOf": [{ "$ref": "#/definitions/WebSearchAction" }, { "type": "null" }] },
1491
1444
  "id": { "type": "string" },
1492
1445
  "query": { "type": "string" },
1493
- "results": {
1494
- "default": null,
1495
- "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.",
1496
- "items": true,
1497
- "type": ["array", "null"]
1498
- },
1499
1446
  "type": {
1500
1447
  "enum": ["webSearch"],
1501
1448
  "title": "WebSearchThreadItemType",
@@ -1529,7 +1476,6 @@ var ThreadResumeResponse_default = {
1529
1476
  "type": "object"
1530
1477
  },
1531
1478
  {
1532
- "description": "Display item emitted by the interruptible `clock.sleep` tool.",
1533
1479
  "properties": {
1534
1480
  "durationMs": {
1535
1481
  "format": "uint64",
@@ -1820,32 +1766,6 @@ var ThreadResumeResponse_default = {
1820
1766
  "title": "LocalImageUserInput",
1821
1767
  "type": "object"
1822
1768
  },
1823
- {
1824
- "properties": {
1825
- "type": {
1826
- "enum": ["audio"],
1827
- "title": "AudioUserInputType",
1828
- "type": "string"
1829
- },
1830
- "url": { "type": "string" }
1831
- },
1832
- "required": ["type", "url"],
1833
- "title": "AudioUserInput",
1834
- "type": "object"
1835
- },
1836
- {
1837
- "properties": {
1838
- "path": { "type": "string" },
1839
- "type": {
1840
- "enum": ["localAudio"],
1841
- "title": "LocalAudioUserInputType",
1842
- "type": "string"
1843
- }
1844
- },
1845
- "required": ["path", "type"],
1846
- "title": "LocalAudioUserInput",
1847
- "type": "object"
1848
- },
1849
1769
  {
1850
1770
  "properties": {
1851
1771
  "name": { "type": "string" },
@@ -1963,11 +1883,6 @@ var ThreadResumeResponse_default = {
1963
1883
  "items": { "$ref": "#/definitions/LegacyAppPathString" },
1964
1884
  "type": "array"
1965
1885
  },
1966
- "itemsBackwardsCursor": {
1967
- "default": null,
1968
- "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.",
1969
- "type": ["string", "null"]
1970
- },
1971
1886
  "model": { "type": "string" },
1972
1887
  "modelProvider": { "type": "string" },
1973
1888
  "multiAgentMode": {
@@ -1987,12 +1902,7 @@ var ThreadResumeResponse_default = {
1987
1902
  "description": "Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance."
1988
1903
  },
1989
1904
  "serviceTier": { "type": ["string", "null"] },
1990
- "thread": { "$ref": "#/definitions/Thread" },
1991
- "turnsBackwardsCursor": {
1992
- "default": null,
1993
- "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.",
1994
- "type": ["string", "null"]
1995
- }
1905
+ "thread": { "$ref": "#/definitions/Thread" }
1996
1906
  },
1997
1907
  required: [
1998
1908
  "approvalPolicy",
@@ -2302,47 +2212,31 @@ var ThreadStartResponse_default = {
2302
2212
  ],
2303
2213
  "type": "string"
2304
2214
  },
2305
- "DynamicToolCallOutputContentItem": { "oneOf": [
2306
- {
2307
- "properties": {
2308
- "text": { "type": "string" },
2309
- "type": {
2310
- "enum": ["inputText"],
2311
- "title": "InputTextDynamicToolCallOutputContentItemType",
2312
- "type": "string"
2313
- }
2314
- },
2315
- "required": ["text", "type"],
2316
- "title": "InputTextDynamicToolCallOutputContentItem",
2317
- "type": "object"
2215
+ "DynamicToolCallOutputContentItem": { "oneOf": [{
2216
+ "properties": {
2217
+ "text": { "type": "string" },
2218
+ "type": {
2219
+ "enum": ["inputText"],
2220
+ "title": "InputTextDynamicToolCallOutputContentItemType",
2221
+ "type": "string"
2222
+ }
2318
2223
  },
2319
- {
2320
- "properties": {
2321
- "imageUrl": { "type": "string" },
2322
- "type": {
2323
- "enum": ["inputImage"],
2324
- "title": "InputImageDynamicToolCallOutputContentItemType",
2325
- "type": "string"
2326
- }
2327
- },
2328
- "required": ["imageUrl", "type"],
2329
- "title": "InputImageDynamicToolCallOutputContentItem",
2330
- "type": "object"
2224
+ "required": ["text", "type"],
2225
+ "title": "InputTextDynamicToolCallOutputContentItem",
2226
+ "type": "object"
2227
+ }, {
2228
+ "properties": {
2229
+ "imageUrl": { "type": "string" },
2230
+ "type": {
2231
+ "enum": ["inputImage"],
2232
+ "title": "InputImageDynamicToolCallOutputContentItemType",
2233
+ "type": "string"
2234
+ }
2331
2235
  },
2332
- {
2333
- "properties": {
2334
- "audioUrl": { "type": "string" },
2335
- "type": {
2336
- "enum": ["inputAudio"],
2337
- "title": "InputAudioDynamicToolCallOutputContentItemType",
2338
- "type": "string"
2339
- }
2340
- },
2341
- "required": ["audioUrl", "type"],
2342
- "title": "InputAudioDynamicToolCallOutputContentItem",
2343
- "type": "object"
2344
- }
2345
- ] },
2236
+ "required": ["imageUrl", "type"],
2237
+ "title": "InputImageDynamicToolCallOutputContentItem",
2238
+ "type": "object"
2239
+ }] },
2346
2240
  "DynamicToolCallStatus": {
2347
2241
  "enum": [
2348
2242
  "inProgress",
@@ -2396,7 +2290,8 @@ var ThreadStartResponse_default = {
2396
2290
  "appName": { "type": ["string", "null"] },
2397
2291
  "connectorId": { "type": "string" },
2398
2292
  "linkId": { "type": ["string", "null"] },
2399
- "resourceUri": { "type": ["string", "null"] }
2293
+ "resourceUri": { "type": ["string", "null"] },
2294
+ "templateId": { "type": ["string", "null"] }
2400
2295
  },
2401
2296
  "required": ["connectorId"],
2402
2297
  "type": "object"
@@ -2722,10 +2617,6 @@ var ThreadStartResponse_default = {
2722
2617
  "description": "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
2723
2618
  "type": ["string", "null"]
2724
2619
  },
2725
- "canAcceptDirectInput": {
2726
- "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.",
2727
- "type": ["boolean", "null"]
2728
- },
2729
2620
  "cliVersion": {
2730
2621
  "description": "Version of the CLI that created the thread.",
2731
2622
  "type": "string"
@@ -2764,11 +2655,6 @@ var ThreadStartResponse_default = {
2764
2655
  "description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
2765
2656
  "type": "string"
2766
2657
  },
2767
- "isPinned": {
2768
- "default": false,
2769
- "description": "Whether the thread has been pinned by the user.",
2770
- "type": "boolean"
2771
- },
2772
2658
  "modelProvider": {
2773
2659
  "description": "Model provider used for this thread (for example, 'openai').",
2774
2660
  "type": "string"
@@ -2992,20 +2878,10 @@ var ThreadStartResponse_default = {
2992
2878
  "type": ["integer", "null"]
2993
2879
  },
2994
2880
  "id": { "type": "string" },
2995
- "pluginId": {
2996
- "default": null,
2997
- "description": "Trusted first-party plugin id when this command resolves to one plugin script.",
2998
- "type": ["string", "null"]
2999
- },
3000
2881
  "processId": {
3001
2882
  "description": "Identifier for the underlying PTY process (when available).",
3002
2883
  "type": ["string", "null"]
3003
2884
  },
3004
- "scriptPath": {
3005
- "default": null,
3006
- "description": "Safe plugin-relative path when this command resolves to one plugin script.",
3007
- "type": ["string", "null"]
3008
- },
3009
2885
  "source": {
3010
2886
  "allOf": [{ "$ref": "#/definitions/CommandExecutionSource" }],
3011
2887
  "default": "agent"
@@ -3206,12 +3082,6 @@ var ThreadStartResponse_default = {
3206
3082
  "action": { "anyOf": [{ "$ref": "#/definitions/WebSearchAction" }, { "type": "null" }] },
3207
3083
  "id": { "type": "string" },
3208
3084
  "query": { "type": "string" },
3209
- "results": {
3210
- "default": null,
3211
- "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.",
3212
- "items": true,
3213
- "type": ["array", "null"]
3214
- },
3215
3085
  "type": {
3216
3086
  "enum": ["webSearch"],
3217
3087
  "title": "WebSearchThreadItemType",
@@ -3245,7 +3115,6 @@ var ThreadStartResponse_default = {
3245
3115
  "type": "object"
3246
3116
  },
3247
3117
  {
3248
- "description": "Display item emitted by the interruptible `clock.sleep` tool.",
3249
3118
  "properties": {
3250
3119
  "durationMs": {
3251
3120
  "format": "uint64",
@@ -3524,32 +3393,6 @@ var ThreadStartResponse_default = {
3524
3393
  "title": "LocalImageUserInput",
3525
3394
  "type": "object"
3526
3395
  },
3527
- {
3528
- "properties": {
3529
- "type": {
3530
- "enum": ["audio"],
3531
- "title": "AudioUserInputType",
3532
- "type": "string"
3533
- },
3534
- "url": { "type": "string" }
3535
- },
3536
- "required": ["type", "url"],
3537
- "title": "AudioUserInput",
3538
- "type": "object"
3539
- },
3540
- {
3541
- "properties": {
3542
- "path": { "type": "string" },
3543
- "type": {
3544
- "enum": ["localAudio"],
3545
- "title": "LocalAudioUserInputType",
3546
- "type": "string"
3547
- }
3548
- },
3549
- "required": ["path", "type"],
3550
- "title": "LocalAudioUserInput",
3551
- "type": "object"
3552
- },
3553
3396
  {
3554
3397
  "properties": {
3555
3398
  "name": { "type": "string" },
@@ -3932,47 +3775,31 @@ var TurnCompletedNotification_default = {
3932
3775
  ],
3933
3776
  "type": "string"
3934
3777
  },
3935
- "DynamicToolCallOutputContentItem": { "oneOf": [
3936
- {
3937
- "properties": {
3938
- "text": { "type": "string" },
3939
- "type": {
3940
- "enum": ["inputText"],
3941
- "title": "InputTextDynamicToolCallOutputContentItemType",
3942
- "type": "string"
3943
- }
3944
- },
3945
- "required": ["text", "type"],
3946
- "title": "InputTextDynamicToolCallOutputContentItem",
3947
- "type": "object"
3778
+ "DynamicToolCallOutputContentItem": { "oneOf": [{
3779
+ "properties": {
3780
+ "text": { "type": "string" },
3781
+ "type": {
3782
+ "enum": ["inputText"],
3783
+ "title": "InputTextDynamicToolCallOutputContentItemType",
3784
+ "type": "string"
3785
+ }
3948
3786
  },
3949
- {
3950
- "properties": {
3951
- "imageUrl": { "type": "string" },
3952
- "type": {
3953
- "enum": ["inputImage"],
3954
- "title": "InputImageDynamicToolCallOutputContentItemType",
3955
- "type": "string"
3956
- }
3957
- },
3958
- "required": ["imageUrl", "type"],
3959
- "title": "InputImageDynamicToolCallOutputContentItem",
3960
- "type": "object"
3787
+ "required": ["text", "type"],
3788
+ "title": "InputTextDynamicToolCallOutputContentItem",
3789
+ "type": "object"
3790
+ }, {
3791
+ "properties": {
3792
+ "imageUrl": { "type": "string" },
3793
+ "type": {
3794
+ "enum": ["inputImage"],
3795
+ "title": "InputImageDynamicToolCallOutputContentItemType",
3796
+ "type": "string"
3797
+ }
3961
3798
  },
3962
- {
3963
- "properties": {
3964
- "audioUrl": { "type": "string" },
3965
- "type": {
3966
- "enum": ["inputAudio"],
3967
- "title": "InputAudioDynamicToolCallOutputContentItemType",
3968
- "type": "string"
3969
- }
3970
- },
3971
- "required": ["audioUrl", "type"],
3972
- "title": "InputAudioDynamicToolCallOutputContentItem",
3973
- "type": "object"
3974
- }
3975
- ] },
3799
+ "required": ["imageUrl", "type"],
3800
+ "title": "InputImageDynamicToolCallOutputContentItem",
3801
+ "type": "object"
3802
+ }] },
3976
3803
  "DynamicToolCallStatus": {
3977
3804
  "enum": [
3978
3805
  "inProgress",
@@ -4018,7 +3845,8 @@ var TurnCompletedNotification_default = {
4018
3845
  "appName": { "type": ["string", "null"] },
4019
3846
  "connectorId": { "type": "string" },
4020
3847
  "linkId": { "type": ["string", "null"] },
4021
- "resourceUri": { "type": ["string", "null"] }
3848
+ "resourceUri": { "type": ["string", "null"] },
3849
+ "templateId": { "type": ["string", "null"] }
4022
3850
  },
4023
3851
  "required": ["connectorId"],
4024
3852
  "type": "object"
@@ -4314,20 +4142,10 @@ var TurnCompletedNotification_default = {
4314
4142
  "type": ["integer", "null"]
4315
4143
  },
4316
4144
  "id": { "type": "string" },
4317
- "pluginId": {
4318
- "default": null,
4319
- "description": "Trusted first-party plugin id when this command resolves to one plugin script.",
4320
- "type": ["string", "null"]
4321
- },
4322
4145
  "processId": {
4323
4146
  "description": "Identifier for the underlying PTY process (when available).",
4324
4147
  "type": ["string", "null"]
4325
4148
  },
4326
- "scriptPath": {
4327
- "default": null,
4328
- "description": "Safe plugin-relative path when this command resolves to one plugin script.",
4329
- "type": ["string", "null"]
4330
- },
4331
4149
  "source": {
4332
4150
  "allOf": [{ "$ref": "#/definitions/CommandExecutionSource" }],
4333
4151
  "default": "agent"
@@ -4528,12 +4346,6 @@ var TurnCompletedNotification_default = {
4528
4346
  "action": { "anyOf": [{ "$ref": "#/definitions/WebSearchAction" }, { "type": "null" }] },
4529
4347
  "id": { "type": "string" },
4530
4348
  "query": { "type": "string" },
4531
- "results": {
4532
- "default": null,
4533
- "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.",
4534
- "items": true,
4535
- "type": ["array", "null"]
4536
- },
4537
4349
  "type": {
4538
4350
  "enum": ["webSearch"],
4539
4351
  "title": "WebSearchThreadItemType",
@@ -4567,7 +4379,6 @@ var TurnCompletedNotification_default = {
4567
4379
  "type": "object"
4568
4380
  },
4569
4381
  {
4570
- "description": "Display item emitted by the interruptible `clock.sleep` tool.",
4571
4382
  "properties": {
4572
4383
  "durationMs": {
4573
4384
  "format": "uint64",
@@ -4797,32 +4608,6 @@ var TurnCompletedNotification_default = {
4797
4608
  "title": "LocalImageUserInput",
4798
4609
  "type": "object"
4799
4610
  },
4800
- {
4801
- "properties": {
4802
- "type": {
4803
- "enum": ["audio"],
4804
- "title": "AudioUserInputType",
4805
- "type": "string"
4806
- },
4807
- "url": { "type": "string" }
4808
- },
4809
- "required": ["type", "url"],
4810
- "title": "AudioUserInput",
4811
- "type": "object"
4812
- },
4813
- {
4814
- "properties": {
4815
- "path": { "type": "string" },
4816
- "type": {
4817
- "enum": ["localAudio"],
4818
- "title": "LocalAudioUserInputType",
4819
- "type": "string"
4820
- }
4821
- },
4822
- "required": ["path", "type"],
4823
- "title": "LocalAudioUserInput",
4824
- "type": "object"
4825
- },
4826
4611
  {
4827
4612
  "properties": {
4828
4613
  "name": { "type": "string" },
@@ -5162,47 +4947,31 @@ var TurnStartResponse_default = {
5162
4947
  ],
5163
4948
  "type": "string"
5164
4949
  },
5165
- "DynamicToolCallOutputContentItem": { "oneOf": [
5166
- {
5167
- "properties": {
5168
- "text": { "type": "string" },
5169
- "type": {
5170
- "enum": ["inputText"],
5171
- "title": "InputTextDynamicToolCallOutputContentItemType",
5172
- "type": "string"
5173
- }
5174
- },
5175
- "required": ["text", "type"],
5176
- "title": "InputTextDynamicToolCallOutputContentItem",
5177
- "type": "object"
4950
+ "DynamicToolCallOutputContentItem": { "oneOf": [{
4951
+ "properties": {
4952
+ "text": { "type": "string" },
4953
+ "type": {
4954
+ "enum": ["inputText"],
4955
+ "title": "InputTextDynamicToolCallOutputContentItemType",
4956
+ "type": "string"
4957
+ }
5178
4958
  },
5179
- {
5180
- "properties": {
5181
- "imageUrl": { "type": "string" },
5182
- "type": {
5183
- "enum": ["inputImage"],
5184
- "title": "InputImageDynamicToolCallOutputContentItemType",
5185
- "type": "string"
5186
- }
5187
- },
5188
- "required": ["imageUrl", "type"],
5189
- "title": "InputImageDynamicToolCallOutputContentItem",
5190
- "type": "object"
4959
+ "required": ["text", "type"],
4960
+ "title": "InputTextDynamicToolCallOutputContentItem",
4961
+ "type": "object"
4962
+ }, {
4963
+ "properties": {
4964
+ "imageUrl": { "type": "string" },
4965
+ "type": {
4966
+ "enum": ["inputImage"],
4967
+ "title": "InputImageDynamicToolCallOutputContentItemType",
4968
+ "type": "string"
4969
+ }
5191
4970
  },
5192
- {
5193
- "properties": {
5194
- "audioUrl": { "type": "string" },
5195
- "type": {
5196
- "enum": ["inputAudio"],
5197
- "title": "InputAudioDynamicToolCallOutputContentItemType",
5198
- "type": "string"
5199
- }
5200
- },
5201
- "required": ["audioUrl", "type"],
5202
- "title": "InputAudioDynamicToolCallOutputContentItem",
5203
- "type": "object"
5204
- }
5205
- ] },
4971
+ "required": ["imageUrl", "type"],
4972
+ "title": "InputImageDynamicToolCallOutputContentItem",
4973
+ "type": "object"
4974
+ }] },
5206
4975
  "DynamicToolCallStatus": {
5207
4976
  "enum": [
5208
4977
  "inProgress",
@@ -5248,7 +5017,8 @@ var TurnStartResponse_default = {
5248
5017
  "appName": { "type": ["string", "null"] },
5249
5018
  "connectorId": { "type": "string" },
5250
5019
  "linkId": { "type": ["string", "null"] },
5251
- "resourceUri": { "type": ["string", "null"] }
5020
+ "resourceUri": { "type": ["string", "null"] },
5021
+ "templateId": { "type": ["string", "null"] }
5252
5022
  },
5253
5023
  "required": ["connectorId"],
5254
5024
  "type": "object"
@@ -5544,20 +5314,10 @@ var TurnStartResponse_default = {
5544
5314
  "type": ["integer", "null"]
5545
5315
  },
5546
5316
  "id": { "type": "string" },
5547
- "pluginId": {
5548
- "default": null,
5549
- "description": "Trusted first-party plugin id when this command resolves to one plugin script.",
5550
- "type": ["string", "null"]
5551
- },
5552
5317
  "processId": {
5553
5318
  "description": "Identifier for the underlying PTY process (when available).",
5554
5319
  "type": ["string", "null"]
5555
5320
  },
5556
- "scriptPath": {
5557
- "default": null,
5558
- "description": "Safe plugin-relative path when this command resolves to one plugin script.",
5559
- "type": ["string", "null"]
5560
- },
5561
5321
  "source": {
5562
5322
  "allOf": [{ "$ref": "#/definitions/CommandExecutionSource" }],
5563
5323
  "default": "agent"
@@ -5758,12 +5518,6 @@ var TurnStartResponse_default = {
5758
5518
  "action": { "anyOf": [{ "$ref": "#/definitions/WebSearchAction" }, { "type": "null" }] },
5759
5519
  "id": { "type": "string" },
5760
5520
  "query": { "type": "string" },
5761
- "results": {
5762
- "default": null,
5763
- "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.",
5764
- "items": true,
5765
- "type": ["array", "null"]
5766
- },
5767
5521
  "type": {
5768
5522
  "enum": ["webSearch"],
5769
5523
  "title": "WebSearchThreadItemType",
@@ -5797,7 +5551,6 @@ var TurnStartResponse_default = {
5797
5551
  "type": "object"
5798
5552
  },
5799
5553
  {
5800
- "description": "Display item emitted by the interruptible `clock.sleep` tool.",
5801
5554
  "properties": {
5802
5555
  "durationMs": {
5803
5556
  "format": "uint64",
@@ -6027,32 +5780,6 @@ var TurnStartResponse_default = {
6027
5780
  "title": "LocalImageUserInput",
6028
5781
  "type": "object"
6029
5782
  },
6030
- {
6031
- "properties": {
6032
- "type": {
6033
- "enum": ["audio"],
6034
- "title": "AudioUserInputType",
6035
- "type": "string"
6036
- },
6037
- "url": { "type": "string" }
6038
- },
6039
- "required": ["type", "url"],
6040
- "title": "AudioUserInput",
6041
- "type": "object"
6042
- },
6043
- {
6044
- "properties": {
6045
- "path": { "type": "string" },
6046
- "type": {
6047
- "enum": ["localAudio"],
6048
- "title": "LocalAudioUserInputType",
6049
- "type": "string"
6050
- }
6051
- },
6052
- "required": ["path", "type"],
6053
- "title": "LocalAudioUserInput",
6054
- "type": "object"
6055
- },
6056
5783
  {
6057
5784
  "properties": {
6058
5785
  "name": { "type": "string" },
@@ -6284,11 +6011,6 @@ function assertCodexThreadForkResponse(value) {
6284
6011
  const normalized = normalizeWithDefaults(ThreadStartResponse_default, value);
6285
6012
  return assertCodexShape(validateThreadStartResponse, normalized, "thread/fork response");
6286
6013
  }
6287
- /** Asserts the experimental beforeTurnId request field before it crosses the app-server boundary. */
6288
- function assertCodexThreadForkParams(value) {
6289
- 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");
6290
- return value;
6291
- }
6292
6014
  /** Asserts and normalizes a Codex thread/resume response. */
6293
6015
  function assertCodexThreadResumeResponse(value) {
6294
6016
  const normalized = normalizeWithDefaults(ThreadResumeResponse_default, value);
@@ -6389,536 +6111,4 @@ function formatValidationErrors(validate, value) {
6389
6111
  }).join("; ");
6390
6112
  }
6391
6113
  //#endregion
6392
- //#region extensions/codex/src/app-server/upstream-prompt-provenance.ts
6393
- const UPSTREAM_USER_TEXT_META_KEY = "upstreamUserText";
6394
- const MIRROR_IDENTITY_META_KEY = "mirrorIdentity";
6395
- function attachCodexMirrorIdentity(message, identity) {
6396
- const record = message;
6397
- const existing = record["__openclaw"];
6398
- const baseMeta = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
6399
- return {
6400
- ...record,
6401
- __openclaw: {
6402
- ...baseMeta,
6403
- [MIRROR_IDENTITY_META_KEY]: identity
6404
- }
6405
- };
6406
- }
6407
- function readMirrorIdentity(message) {
6408
- const meta = message["__openclaw"];
6409
- if (!meta || typeof meta !== "object" || Array.isArray(meta)) return;
6410
- const id = meta[MIRROR_IDENTITY_META_KEY];
6411
- return typeof id === "string" && id ? id : void 0;
6412
- }
6413
- function attachUpstreamUserText(message, text) {
6414
- const record = message;
6415
- const existing = record["__openclaw"];
6416
- const baseMeta = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
6417
- return {
6418
- ...record,
6419
- __openclaw: {
6420
- ...baseMeta,
6421
- [UPSTREAM_USER_TEXT_META_KEY]: text
6422
- }
6423
- };
6424
- }
6425
- function readUpstreamUserText(message) {
6426
- const meta = message?.["__openclaw"];
6427
- if (!meta || typeof meta !== "object" || Array.isArray(meta)) return;
6428
- const text = meta[UPSTREAM_USER_TEXT_META_KEY];
6429
- return typeof text === "string" && text ? text : void 0;
6430
- }
6431
- //#endregion
6432
- //#region extensions/codex/src/app-server/transcript-mirror-attestation.ts
6433
- const MIRROR_ORIGIN_META_KEY = "mirrorOrigin";
6434
- const MIRROR_SOURCE_FINGERPRINT_META_KEY = "mirrorSourceFingerprint";
6435
- const CODEX_APP_SERVER_MIRROR_ORIGIN = "codex-app-server";
6436
- function attachCodexMirrorAttestation(message, sourceFingerprint) {
6437
- const record = message;
6438
- const existing = record["__openclaw"];
6439
- const baseMeta = existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {};
6440
- return {
6441
- ...record,
6442
- __openclaw: {
6443
- ...baseMeta,
6444
- [MIRROR_ORIGIN_META_KEY]: CODEX_APP_SERVER_MIRROR_ORIGIN,
6445
- ...sourceFingerprint ? { [MIRROR_SOURCE_FINGERPRINT_META_KEY]: sourceFingerprint } : {}
6446
- }
6447
- };
6448
- }
6449
- function readCodexMirrorSourceFingerprint(message) {
6450
- const meta = message["__openclaw"];
6451
- if (!meta || typeof meta !== "object" || Array.isArray(meta)) return;
6452
- const value = meta[MIRROR_SOURCE_FINGERPRINT_META_KEY];
6453
- return typeof value === "string" && value ? value : void 0;
6454
- }
6455
- function serializeCodexMirrorSourceEvidence(message) {
6456
- const record = message;
6457
- return JSON.stringify({
6458
- role: message.role,
6459
- content: record.content,
6460
- ...message.role === "user" ? { upstreamUserText: readUpstreamUserText(message) } : {},
6461
- ...message.role === "toolResult" ? {
6462
- toolCallId: record.toolCallId,
6463
- toolName: record.toolName,
6464
- isError: record.isError === true
6465
- } : {}
6466
- });
6467
- }
6468
- function fingerprintCodexMirrorSourceMessage(message) {
6469
- return createHash("sha256").update(serializeCodexMirrorSourceEvidence(message)).digest("hex").slice(0, 32);
6470
- }
6471
- //#endregion
6472
- //#region extensions/codex/src/app-server/user-prompt-message.ts
6473
- function buildSenderLabel(params) {
6474
- const label = params.senderName ?? params.senderUsername ?? params.senderE164 ?? params.senderId;
6475
- if (!label) return;
6476
- return !params.senderId || label.includes(params.senderId) ? label : `${label} (${params.senderId})`;
6477
- }
6478
- function buildFromPrepared(params, preparedUserMessage) {
6479
- const senderId = normalizeOptionalString(params.senderId);
6480
- const senderName = normalizeOptionalString(params.senderName);
6481
- const senderUsername = normalizeOptionalString(params.senderUsername);
6482
- const senderE164 = normalizeOptionalString(params.senderE164);
6483
- const senderLabel = buildSenderLabel({
6484
- senderId,
6485
- senderName,
6486
- senderUsername,
6487
- senderE164
6488
- });
6489
- const sourceChannel = normalizeOptionalString(params.inputProvenance?.sourceChannel ?? params.messageChannel ?? params.messageProvider);
6490
- return {
6491
- role: "user",
6492
- timestamp: Date.now(),
6493
- ...params.inputProvenance ? { provenance: params.inputProvenance } : {},
6494
- ...sourceChannel ? { sourceChannel } : {},
6495
- ...senderId ? { senderId } : {},
6496
- ...senderName ? { senderName } : {},
6497
- ...senderUsername ? { senderUsername } : {},
6498
- ...senderE164 ? { senderE164 } : {},
6499
- ...senderLabel ? { senderLabel } : {},
6500
- ...preparedUserMessage ? preparedUserMessage : { content: params.prompt }
6501
- };
6502
- }
6503
- function buildCodexUserPromptMessage(params) {
6504
- return buildFromPrepared(params, params.userTurnTranscriptRecorder?.message);
6505
- }
6506
- function buildCodexUpstreamPromptMessage(params, identity, upstreamUserText) {
6507
- const message = attachCodexMirrorIdentity(buildCodexUserPromptMessage(params), identity);
6508
- return upstreamUserText ? attachUpstreamUserText(message, upstreamUserText) : message;
6509
- }
6510
- function promptSnapshot(params, turnId, upstreamUserText) {
6511
- return params.suppressNextUserMessagePersistence ? [] : [buildCodexUpstreamPromptMessage(params, `${turnId}:prompt`, upstreamUserText)];
6512
- }
6513
- async function buildResolvedCodexUserPromptMessage(params) {
6514
- return buildFromPrepared(params, await params.userTurnTranscriptRecorder?.resolveMessage() ?? params.userTurnTranscriptRecorder?.message);
6515
- }
6516
- //#endregion
6517
- //#region extensions/codex/src/app-server/transcript-mirror.ts
6518
- function isMirroredAgentMessage(message) {
6519
- return message.role === "user" || message.role === "assistant" || message.role === "toolResult";
6520
- }
6521
- const CODEX_HISTORY_IMPORT_MAX_MESSAGES = 200;
6522
- const CODEX_HISTORY_IMPORT_MAX_BYTES = 512 * 1024;
6523
- const CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES = 64 * 1024;
6524
- const CODEX_HISTORY_TRUNCATION_SUFFIX = "\n\n[Message truncated during Codex history import.]";
6525
- const CODEX_HISTORY_ASSISTANT_API = "openai-chatgpt-responses";
6526
- const CODEX_HISTORY_ASSISTANT_PROVIDER = "openai";
6527
- const CODEX_HISTORY_ASSISTANT_MODEL = "native-history";
6528
- const CODEX_HISTORY_ZERO_USAGE = {
6529
- input: 0,
6530
- output: 0,
6531
- cacheRead: 0,
6532
- cacheWrite: 0,
6533
- totalTokens: 0,
6534
- cost: {
6535
- input: 0,
6536
- output: 0,
6537
- cacheRead: 0,
6538
- cacheWrite: 0,
6539
- total: 0
6540
- }
6541
- };
6542
- function isUtf8ContinuationByte(byte) {
6543
- return byte !== void 0 && (byte & 192) === 128;
6544
- }
6545
- function truncateUtf8Prefix(value, maxBytes) {
6546
- const bytes = Buffer.from(value);
6547
- if (bytes.byteLength <= maxBytes) return value;
6548
- let end = Math.max(0, maxBytes);
6549
- while (end > 0 && isUtf8ContinuationByte(bytes[end])) end -= 1;
6550
- return bytes.subarray(0, end).toString("utf8");
6551
- }
6552
- function normalizeImportedHistoryText(value) {
6553
- if (typeof value !== "string") return;
6554
- const text = value.trim();
6555
- if (!text) return;
6556
- if (Buffer.byteLength(text, "utf8") <= CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES) return text;
6557
- const suffixBytes = Buffer.byteLength(CODEX_HISTORY_TRUNCATION_SUFFIX, "utf8");
6558
- return `${truncateUtf8Prefix(text, Math.max(0, CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES - suffixBytes))}${CODEX_HISTORY_TRUNCATION_SUFFIX}`;
6559
- }
6560
- function projectCodexUserItemText(item) {
6561
- if (!Array.isArray(item.content)) return;
6562
- const parts = [];
6563
- for (const value of item.content) {
6564
- if (!value || typeof value !== "object" || Array.isArray(value)) continue;
6565
- const input = value;
6566
- if (input.type === "text") {
6567
- const text = normalizeImportedHistoryText(input.text);
6568
- if (text) parts.push(text);
6569
- continue;
6570
- }
6571
- if (input.type === "image" || input.type === "localImage") {
6572
- parts.push("[Image attachment]");
6573
- continue;
6574
- }
6575
- if (input.type === "skill" || input.type === "mention") {
6576
- const name = normalizeOptionalString(input.name);
6577
- if (name) parts.push(`${input.type === "skill" ? "$" : "@"}${name}`);
6578
- }
6579
- }
6580
- return normalizeImportedHistoryText(parts.join("\n"));
6581
- }
6582
- function selectTurnsThroughBoundary(thread, throughTurnId) {
6583
- if (throughTurnId === null) return [];
6584
- const turns = thread.turns ?? [];
6585
- const boundaryIndex = turns.findIndex((turn) => turn.id === throughTurnId);
6586
- if (boundaryIndex < 0) throw new Error(`Codex history boundary turn not found: ${throughTurnId}`);
6587
- const boundary = turns[boundaryIndex];
6588
- if (boundary?.status !== "completed" && boundary?.status !== "interrupted" && boundary?.status !== "failed") throw new Error(`Codex history boundary turn is not terminal: ${throughTurnId}`);
6589
- return turns.slice(0, boundaryIndex + 1);
6590
- }
6591
- function projectCodexThreadHistory(params) {
6592
- const projected = [];
6593
- const threadTimestamp = typeof params.thread.createdAt === "number" && Number.isFinite(params.thread.createdAt) ? params.thread.createdAt * 1e3 : params.importedAt;
6594
- let itemOffset = 0;
6595
- for (const turn of selectTurnsThroughBoundary(params.thread, params.throughTurnId)) for (const value of turn.items) {
6596
- const item = value;
6597
- const itemId = normalizeOptionalString(item.id);
6598
- const identity = `${turn.id}:${itemId ?? itemOffset}`;
6599
- const timestampSeconds = item.type === "agentMessage" ? turn.completedAt ?? turn.startedAt : turn.startedAt ?? turn.completedAt;
6600
- const timestamp = typeof timestampSeconds === "number" && Number.isFinite(timestampSeconds) ? timestampSeconds * 1e3 + itemOffset : threadTimestamp + itemOffset;
6601
- const text = item.type === "userMessage" ? projectCodexUserItemText(item) : item.type === "agentMessage" ? normalizeImportedHistoryText(item.text) : void 0;
6602
- const role = item.type === "userMessage" ? "user" : item.type === "agentMessage" ? "assistant" : void 0;
6603
- itemOffset += 1;
6604
- if (!text || !role) continue;
6605
- const message = role === "assistant" ? attachCodexMirrorIdentity({
6606
- role,
6607
- content: [{
6608
- type: "text",
6609
- text
6610
- }],
6611
- api: CODEX_HISTORY_ASSISTANT_API,
6612
- provider: normalizeOptionalString(params.modelProvider) ?? normalizeOptionalString(params.thread.modelProvider) ?? CODEX_HISTORY_ASSISTANT_PROVIDER,
6613
- model: CODEX_HISTORY_ASSISTANT_MODEL,
6614
- usage: CODEX_HISTORY_ZERO_USAGE,
6615
- stopReason: "stop",
6616
- timestamp
6617
- }, identity) : attachCodexMirrorIdentity({
6618
- role,
6619
- content: text,
6620
- timestamp
6621
- }, identity);
6622
- const phase = item.phase === "commentary" || item.phase === "final_answer" ? item.phase : void 0;
6623
- projected.push({
6624
- message,
6625
- responseItem: {
6626
- type: "message",
6627
- role,
6628
- content: [{
6629
- type: role === "assistant" ? "output_text" : "input_text",
6630
- text
6631
- }],
6632
- ...role === "assistant" && phase ? { phase } : {}
6633
- },
6634
- textBytes: Buffer.byteLength(text, "utf8")
6635
- });
6636
- }
6637
- return projected;
6638
- }
6639
- function selectBoundedCodexHistoryTail(projected) {
6640
- const selected = [];
6641
- let selectedBytes = 0;
6642
- for (let index = projected.length - 1; index >= 0; index -= 1) {
6643
- const candidate = projected[index];
6644
- if (!candidate) continue;
6645
- if (selected.length >= CODEX_HISTORY_IMPORT_MAX_MESSAGES || selectedBytes + candidate.textBytes > CODEX_HISTORY_IMPORT_MAX_BYTES) break;
6646
- selected.push(candidate);
6647
- selectedBytes += candidate.textBytes;
6648
- }
6649
- return selected.toReversed();
6650
- }
6651
- /** Projects one terminal Codex history prefix into transcript and Responses API items. */
6652
- function projectBoundedCodexThreadHistory(params) {
6653
- const projected = projectCodexThreadHistory({
6654
- thread: params.thread,
6655
- throughTurnId: params.throughTurnId,
6656
- importedAt: params.importedAt,
6657
- ...params.modelProvider ? { modelProvider: params.modelProvider } : {}
6658
- });
6659
- const selected = selectBoundedCodexHistoryTail(projected);
6660
- return {
6661
- importedMessages: selected.length,
6662
- omittedMessages: projected.length - selected.length,
6663
- responseItems: selected.map(({ responseItem }) => responseItem),
6664
- transcriptMessages: selected.map(({ message }) => message)
6665
- };
6666
- }
6667
- /** Imports a bounded, user-visible Codex history tail into a new OpenClaw transcript. */
6668
- async function importCodexThreadHistoryToTranscript(params) {
6669
- const projection = projectBoundedCodexThreadHistory({
6670
- thread: params.thread,
6671
- throughTurnId: params.throughTurnId,
6672
- importedAt: Date.now(),
6673
- ...params.modelProvider ? { modelProvider: params.modelProvider } : {}
6674
- });
6675
- if (projection.transcriptMessages.length > 0) await mirror({
6676
- storePath: params.storePath,
6677
- sessionId: params.sessionId,
6678
- sessionKey: params.sessionKey,
6679
- ...params.agentId ? { agentId: params.agentId } : {},
6680
- ...params.cwd ? { cwd: params.cwd } : {},
6681
- ...params.config ? { config: params.config } : {},
6682
- messages: projection.transcriptMessages,
6683
- idempotencyScope: `codex-app-server:${params.thread.id}:history`
6684
- });
6685
- return {
6686
- importedMessages: projection.importedMessages,
6687
- omittedMessages: projection.omittedMessages
6688
- };
6689
- }
6690
- async function mirrorBestEffort(params) {
6691
- try {
6692
- const messages = await resolveFinalCodexMirrorMessages({
6693
- params: params.params,
6694
- messagesSnapshot: params.result.messagesSnapshot,
6695
- turnId: params.turnId
6696
- });
6697
- const mirrorResult = await mirror({
6698
- agentId: params.agentId,
6699
- sessionKey: params.sessionKey,
6700
- sessionId: params.params.sessionId,
6701
- storePath: params.params.sessionTarget?.storePath,
6702
- cwd: params.cwd,
6703
- messages,
6704
- idempotencyScope: `codex-app-server:${params.threadId}`,
6705
- config: params.params.config
6706
- });
6707
- for (const message of mirrorResult.userMessagesPresent) try {
6708
- params.notifyUserMessagePersisted(message);
6709
- } catch (error) {
6710
- embeddedAgentLog.warn("failed to notify codex app-server user-message persistence", { error: formatErrorMessage(error) });
6711
- }
6712
- const expectedFingerprints = new Map(messages.flatMap((message) => {
6713
- if (!isMirroredAgentMessage(message)) return [];
6714
- const identity = readMirrorIdentity(message);
6715
- return identity ? [[identity, fingerprintCodexMirrorSourceMessage(message)]] : [];
6716
- }));
6717
- const mirroredMessages = mirrorResult.messagesPresent.filter((message) => {
6718
- const identity = readMirrorIdentity(message);
6719
- return identity !== void 0 && readCodexMirrorSourceFingerprint(message) === expectedFingerprints.get(identity);
6720
- });
6721
- const assistantMirrorIdentity = `${params.turnId}:assistant`;
6722
- const assistantTranscriptOwned = mirrorResult.assistantMirrorIdentitiesOwned.includes(assistantMirrorIdentity);
6723
- const assistantTranscriptIdempotencyKey = normalizeOptionalString((assistantTranscriptOwned ? mirroredMessages.find((message) => readMirrorIdentity(message) === assistantMirrorIdentity) : void 0)?.idempotencyKey);
6724
- return {
6725
- assistantTranscriptOwned,
6726
- ...assistantTranscriptIdempotencyKey ? { assistantTranscriptIdempotencyKey } : {},
6727
- mirroredMessages
6728
- };
6729
- } catch (error) {
6730
- embeddedAgentLog.warn("failed to mirror codex app-server transcript", { error });
6731
- return {
6732
- assistantTranscriptOwned: false,
6733
- mirroredMessages: []
6734
- };
6735
- }
6736
- }
6737
- async function resolveFinalCodexMirrorMessages(params) {
6738
- if (params.params.suppressNextUserMessagePersistence || !params.params.userTurnTranscriptRecorder) return params.messagesSnapshot;
6739
- const promptSnapshot = params.messagesSnapshot.find((message) => message.role === "user");
6740
- const resolvedBase = attachCodexMirrorIdentity(await buildResolvedCodexUserPromptMessage(params.params), `${params.turnId}:prompt`);
6741
- const upstreamUserText = readUpstreamUserText(promptSnapshot);
6742
- const resolvedPrompt = upstreamUserText ? attachUpstreamUserText(resolvedBase, upstreamUserText) : resolvedBase;
6743
- const firstUserIndex = params.messagesSnapshot.findIndex((message) => message.role === "user");
6744
- if (firstUserIndex === -1) return [resolvedPrompt, ...params.messagesSnapshot];
6745
- const messages = params.messagesSnapshot.slice();
6746
- messages[firstUserIndex] = resolvedPrompt;
6747
- return messages;
6748
- }
6749
- function createCodexAppServerUserMessagePersistenceNotifier(runParams) {
6750
- let notified = false;
6751
- return (message) => {
6752
- if (notified) return;
6753
- notified = true;
6754
- runParams.userTurnTranscriptRecorder?.markRuntimePersisted(message);
6755
- try {
6756
- runParams.onUserMessagePersisted?.(message);
6757
- } catch (error) {
6758
- embeddedAgentLog.warn("codex app-server user persistence notification failed", { error: formatErrorMessage(error) });
6759
- }
6760
- };
6761
- }
6762
- async function mirrorPromptAtTurnStartBestEffort(params) {
6763
- if (params.params.suppressNextUserMessagePersistence) return;
6764
- try {
6765
- const mirrorPromise = (async () => {
6766
- const userPromptMessage = projectAgentHarnessTranscriptMessageForDisplay({
6767
- hidden: params.params.trigger === "memory",
6768
- message: attachUpstreamUserText(attachCodexMirrorIdentity(await buildResolvedCodexUserPromptMessage(params.params), `${params.turnId}:prompt`), params.upstreamUserText)
6769
- });
6770
- const mirrorResult = await mirror({
6771
- agentId: params.agentId,
6772
- sessionKey: params.sessionKey,
6773
- sessionId: params.params.sessionId,
6774
- storePath: params.params.sessionTarget?.storePath,
6775
- cwd: params.cwd,
6776
- messages: [userPromptMessage],
6777
- idempotencyScope: `codex-app-server:${params.threadId}`,
6778
- config: params.params.config
6779
- });
6780
- for (const message of mirrorResult.userMessagesPresent) params.notifyUserMessagePersisted(message);
6781
- })();
6782
- params.params.userTurnTranscriptRecorder?.markRuntimePersistencePending(mirrorPromise);
6783
- await mirrorPromise;
6784
- } catch (error) {
6785
- embeddedAgentLog.warn("failed to mirror codex app-server prompt at turn start", { error });
6786
- }
6787
- }
6788
- function fingerprintMirrorMessageContent(message) {
6789
- const payload = JSON.stringify({
6790
- role: message.role,
6791
- content: message.content
6792
- });
6793
- return createHash("sha256").update(payload).digest("hex").slice(0, 16);
6794
- }
6795
- function buildMirrorDedupeIdentity(message) {
6796
- const explicit = readMirrorIdentity(message);
6797
- if (explicit) return explicit;
6798
- return `${message.role}:${fingerprintMirrorMessageContent(message)}`;
6799
- }
6800
- async function mirror(params) {
6801
- const messages = params.messages.filter(isMirroredAgentMessage);
6802
- if (messages.length === 0) return {
6803
- assistantMirrorIdentitiesOwned: [],
6804
- messagesPresent: [],
6805
- userMessagesPresent: []
6806
- };
6807
- const candidates = messages.map((message) => {
6808
- const dedupeIdentity = buildMirrorDedupeIdentity(message);
6809
- const sourceFingerprint = fingerprintCodexMirrorSourceMessage(message);
6810
- return {
6811
- dedupeIdentity,
6812
- idempotencyKey: (message.role === "user" ? normalizeOptionalString(message.idempotencyKey) : void 0) ?? (params.idempotencyScope ? `${params.idempotencyScope}:${dedupeIdentity}` : void 0),
6813
- message,
6814
- sourceFingerprint
6815
- };
6816
- });
6817
- const candidateIdempotencyKeys = candidates.flatMap(({ idempotencyKey }) => idempotencyKey ? [idempotencyKey] : []);
6818
- const transcriptTarget = resolveCodexMirrorTranscriptTarget(params);
6819
- const { appendedUpdates, assistantMirrorIdentitiesOwned, messagesPresent, userMessagesPresent } = await withCodexSessionTranscriptMirrorWriteLock({
6820
- ...transcriptTarget,
6821
- config: params.config
6822
- }, async (transcript) => {
6823
- const nextAppendedUpdates = [];
6824
- const nextAssistantMirrorIdentitiesOwned = /* @__PURE__ */ new Set();
6825
- const nextMessagesPresent = [];
6826
- const nextUserMessagesPresent = [];
6827
- const mirrorFacts = await transcript.readMessageFacts({ idempotencyKeys: candidateIdempotencyKeys });
6828
- for (const { dedupeIdentity, idempotencyKey, message, sourceFingerprint } of candidates) {
6829
- const transcriptMessage = {
6830
- ...attachCodexMirrorAttestation(message, sourceFingerprint),
6831
- ...idempotencyKey ? { idempotencyKey } : {}
6832
- };
6833
- if (idempotencyKey && mirrorFacts.existingIdempotencyKeys.has(idempotencyKey)) {
6834
- const persistedMessage = mirrorFacts.messagesByIdempotencyKey.get(idempotencyKey);
6835
- if (persistedMessage && isMirroredAgentMessage(persistedMessage)) {
6836
- nextMessagesPresent.push(persistedMessage);
6837
- if (persistedMessage.role === "user") nextUserMessagesPresent.push(persistedMessage);
6838
- }
6839
- if (message.role === "assistant") nextAssistantMirrorIdentitiesOwned.add(dedupeIdentity);
6840
- continue;
6841
- }
6842
- const nextMessage = params.skipBeforeMessageWriteHooks ? transcriptMessage : runAgentHarnessBeforeMessageWriteHook({
6843
- message: transcriptMessage,
6844
- agentId: params.agentId,
6845
- sessionKey: params.sessionKey
6846
- });
6847
- if (!nextMessage) {
6848
- if (message.role === "assistant") nextAssistantMirrorIdentitiesOwned.add(dedupeIdentity);
6849
- continue;
6850
- }
6851
- let messageToAppend = idempotencyKey ? {
6852
- ...attachCodexMirrorAttestation(nextMessage, sourceFingerprint),
6853
- idempotencyKey
6854
- } : attachCodexMirrorAttestation(nextMessage, sourceFingerprint);
6855
- const mirrorIdentity = readMirrorIdentity(message);
6856
- if (mirrorIdentity) messageToAppend = attachCodexMirrorIdentity(messageToAppend, mirrorIdentity);
6857
- messageToAppend = projectAgentHarnessTranscriptMessageForDisplay({
6858
- hidden: message.display === false,
6859
- message: messageToAppend
6860
- });
6861
- const { messageSeq, result: appended } = await transcript.appendMessageWithMessageSequence({
6862
- message: messageToAppend,
6863
- idempotencyLookup: "scan",
6864
- cwd: params.cwd
6865
- });
6866
- if (!appended) continue;
6867
- const { messageId, message: appendedMessage } = appended;
6868
- if (isMirroredAgentMessage(appendedMessage)) {
6869
- nextMessagesPresent.push(appendedMessage);
6870
- if (idempotencyKey) mirrorFacts.messagesByIdempotencyKey.set(idempotencyKey, appendedMessage);
6871
- }
6872
- if (message.role === "assistant") nextAssistantMirrorIdentitiesOwned.add(dedupeIdentity);
6873
- if (appendedMessage.role === "user") nextUserMessagesPresent.push(appendedMessage);
6874
- if (appended.appended) nextAppendedUpdates.push({
6875
- messageId,
6876
- message: appendedMessage,
6877
- ...messageSeq !== void 0 ? { messageSeq } : {}
6878
- });
6879
- if (idempotencyKey) mirrorFacts.existingIdempotencyKeys.add(idempotencyKey);
6880
- }
6881
- return {
6882
- appendedUpdates: nextAppendedUpdates,
6883
- assistantMirrorIdentitiesOwned: [...nextAssistantMirrorIdentitiesOwned],
6884
- messagesPresent: nextMessagesPresent,
6885
- userMessagesPresent: nextUserMessagesPresent
6886
- };
6887
- });
6888
- for (const update of appendedUpdates) try {
6889
- await publishSessionTranscriptUpdateByIdentity({
6890
- ...transcriptTarget,
6891
- update: {
6892
- ...params.agentId ? { agentId: params.agentId } : {},
6893
- message: update.message,
6894
- messageId: update.messageId,
6895
- ...update.messageSeq !== void 0 ? { messageSeq: update.messageSeq } : {},
6896
- sessionKey: transcriptTarget.sessionKey
6897
- }
6898
- });
6899
- } catch (error) {
6900
- embeddedAgentLog.warn("failed to publish codex app-server transcript update", { error: formatErrorMessage(error) });
6901
- }
6902
- return {
6903
- assistantMirrorIdentitiesOwned,
6904
- messagesPresent,
6905
- userMessagesPresent
6906
- };
6907
- }
6908
- const codexTranscriptMirrorRuntime = {
6909
- mirror,
6910
- mirrorBestEffort
6911
- };
6912
- function resolveCodexMirrorTranscriptTarget(params) {
6913
- const sessionKey = params.sessionKey?.trim();
6914
- const storePath = params.storePath?.trim();
6915
- if (!sessionKey || !storePath) throw new Error("Codex transcript mirror requires a runtime session identity");
6916
- return {
6917
- ...params.agentId ? { agentId: params.agentId } : {},
6918
- sessionId: params.sessionId,
6919
- sessionKey,
6920
- storePath
6921
- };
6922
- }
6923
- //#endregion
6924
- export { readCodexTurnCompletedNotification as C, readCodexTurn as S, assertCodexThreadStartResponse as _, projectBoundedCodexThreadHistory as a, readCodexErrorNotification as b, fingerprintCodexMirrorSourceMessage as c, attachCodexMirrorIdentity as d, readMirrorIdentity as f, assertCodexThreadResumeResponse as g, assertCodexThreadForkResponse as h, mirrorPromptAtTurnStartBestEffort as i, readCodexMirrorSourceFingerprint as l, assertCodexThreadForkParams as m, createCodexAppServerUserMessagePersistenceNotifier as n, buildCodexUserPromptMessage as o, readUpstreamUserText as p, importCodexThreadHistoryToTranscript as r, promptSnapshot as s, codexTranscriptMirrorRuntime as t, serializeCodexMirrorSourceEvidence as u, assertCodexTurnStartResponse as v, readCodexModelListResponse as x, readCodexDynamicToolCallParams as y };
6114
+ export { readCodexDynamicToolCallParams as a, readCodexTurn as c, assertCodexTurnStartResponse as i, readCodexTurnCompletedNotification as l, assertCodexThreadResumeResponse as n, readCodexErrorNotification as o, assertCodexThreadStartResponse as r, readCodexModelListResponse as s, assertCodexThreadForkResponse as t };