@openclaw/ai 2026.10.5 → 2026.10.10-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +11 -0
  2. package/dist/{anthropic-DIIiiz99.mjs → anthropic-D6spfBri.mjs} +16 -18
  3. package/dist/{anthropic-payload-policy-DGblkHL5.d.mts → anthropic-payload-policy-Cr8xjazC.d.mts} +6 -3
  4. package/dist/{anthropic-stream-reducer-DfMVFm-r.mjs → anthropic-stream-reducer-CzPXOaLM.mjs} +55 -227
  5. package/dist/anthropic-tool-projection-BdAS3rtJ.mjs +165 -0
  6. package/dist/anthropic-tool-projection-DKH-aEWU.d.mts +51 -0
  7. package/dist/{api-registry-BhXXYdRA.d.mts → api-registry-gDt0faai.d.mts} +2 -2
  8. package/dist/{assistant-output-BuhRpLeD.mjs → assistant-output-6iFA1nbC.mjs} +2 -2
  9. package/dist/{azure-openai-responses-DGQnXRMs.mjs → azure-openai-responses-0TqHwnlD.mjs} +8 -8
  10. package/dist/{cloudflare-5qSGvIUH.mjs → cloudflare-Dttf8jKq.mjs} +1 -1
  11. package/dist/{credential-redaction-BHxruEH6.d.mts → credential-redaction-XvsPf7Yi.d.mts} +1 -0
  12. package/dist/{diagnostics-tQasYct1.mjs → diagnostics-Cv7cW3pS.mjs} +3 -3
  13. package/dist/diagnostics.d.mts +6 -6
  14. package/dist/diagnostics.mjs +2 -2
  15. package/dist/{env-api-keys-CrxwdylR.mjs → env-api-keys-Xd8dm_aV.mjs} +10 -34
  16. package/dist/event-stream-CDpFza-M.d.mts +1 -0
  17. package/dist/{event-stream-BcqWLo_u.d.mts → event-stream-CzpE1g_o.d.mts} +1 -1
  18. package/dist/event-stream.d.mts +2 -2
  19. package/dist/{github-copilot-request-facts-DEE6gcB9.mjs → github-copilot-request-facts-F-EmvkpW.mjs} +1 -1
  20. package/dist/{google-interactions-zIz70M2e.mjs → google-interactions-DVQ7AaSF.mjs} +29 -50
  21. package/dist/{google-messages-CNbUJK5E.mjs → google-messages-DfpHVTaD.mjs} +15 -5
  22. package/dist/{google-provider-stream-Cn0XF1MG.mjs → google-provider-stream-DJ8ANfsS.mjs} +6 -6
  23. package/dist/{google-shared-BPnWP4tT.mjs → google-shared-VTcCJLW3.mjs} +21 -29
  24. package/dist/{google-vertex-XQ7OQtaM.mjs → google-vertex-Bkfizj7M.mjs} +3 -3
  25. package/dist/{google-BlbTC1Xp.mjs → google-zWpkDSeN.mjs} +4 -4
  26. package/dist/{host-Bf3NjYNj.mjs → host-B2gk-d1H.mjs} +5 -11
  27. package/dist/{host-CTDz7LXD.d.mts → host-jJOffdlW.d.mts} +4 -6
  28. package/dist/{host-policy-BzZluO6_.mjs → host-policy-mpqGhbeM.mjs} +1 -1
  29. package/dist/{index-BYDvopUB.d.mts → index-DSprYWaz.d.mts} +7 -5
  30. package/dist/index.d.mts +7 -7
  31. package/dist/index.mjs +6 -6
  32. package/dist/internal/anthropic.d.mts +7 -53
  33. package/dist/internal/anthropic.mjs +6 -5
  34. package/dist/internal/google-model-family.mjs +1 -1
  35. package/dist/internal/openai-completions-compat.d.mts +1 -1
  36. package/dist/internal/openai-completions-compat.mjs +1 -1
  37. package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
  38. package/dist/internal/openai-responses-payload-policy.mjs +3 -3
  39. package/dist/internal/openai.d.mts +17 -26
  40. package/dist/internal/openai.mjs +10 -10
  41. package/dist/internal/retry-after.d.mts +1 -1
  42. package/dist/internal/retry-after.mjs +80 -55
  43. package/dist/internal/runtime.d.mts +9 -31
  44. package/dist/internal/runtime.mjs +10 -116
  45. package/dist/internal/shared.d.mts +9 -7
  46. package/dist/internal/shared.mjs +8 -6
  47. package/dist/internal/tool-schema.d.mts +83 -5
  48. package/dist/internal/tool-schema.mjs +4 -3
  49. package/dist/{mistral-dCDCR5ur.mjs → mistral-CATJrwne.mjs} +32 -35
  50. package/dist/model-request-body-BD5vy4rP.d.mts +17 -0
  51. package/dist/{number-coercion-C3hztWoY.mjs → number-coercion-37gmNkuA.mjs} +1 -1
  52. package/dist/{openai-chatgpt-responses-D8-q7cgy.mjs → openai-chatgpt-responses-CtdnpWwe.mjs} +95 -63
  53. package/dist/{openai-completions-CMN24pza.mjs → openai-completions-B6sET3oI.mjs} +10 -8
  54. package/dist/{openai-completions-compat-i-nLZxFy.d.mts → openai-completions-compat-1gsjP-KO.d.mts} +6 -3
  55. package/dist/{openai-completions-compat-CYX18uDk.mjs → openai-completions-compat-CFhQ3UVU.mjs} +7 -2
  56. package/dist/{openai-completions-transport-DuXQOxrH.mjs → openai-completions-transport-DviPEqw3.mjs} +369 -237
  57. package/dist/{openai-prompt-cache-r93BJhjm.mjs → openai-prompt-cache-DJ_P143P.mjs} +1 -1
  58. package/dist/{openai-prompt-cache-DIPMrMFy.d.mts → openai-prompt-cache-DgjD-UL5.d.mts} +2 -2
  59. package/dist/{openai-responses-BMxoJdTC.mjs → openai-responses-BXsJK-mD.mjs} +13 -15
  60. package/dist/{openai-responses-compaction-replay-B2FE4Nw8.d.mts → openai-responses-compaction-replay-Cvnl_nCq.d.mts} +5 -5
  61. package/dist/{openai-responses-contracts-DlKMMTxK.mjs → openai-responses-contracts-Bx-16mnf.mjs} +45 -6
  62. package/dist/{openai-responses-contracts-DKqMJ1Ct.d.mts → openai-responses-contracts-CQ4_AWjL.d.mts} +20 -8
  63. package/dist/{openai-responses-endpoint-CinGh4VZ.mjs → openai-responses-endpoint-D4v-eeYy.mjs} +55 -22
  64. package/dist/{openai-responses-payload-policy-C7GsA1y0.d.mts → openai-responses-payload-policy-BzM52TTH.d.mts} +9 -3
  65. package/dist/openai-responses-request-lifecycle-CTdAb2v1.mjs +246 -0
  66. package/dist/{openai-responses-shared-afo9-s16.mjs → openai-responses-shared-Bv_1NtH9.mjs} +284 -173
  67. package/dist/{openai-responses-terminal-usage-BygjiAdi.d.mts → openai-responses-terminal-usage-CpVjkqn-.d.mts} +2 -2
  68. package/dist/{openai-tool-schema-DDPXsvJP.mjs → openai-tool-schema-Buv0GXFb.mjs} +170 -237
  69. package/dist/overflow-DJHXTNBQ.mjs +117 -0
  70. package/dist/{positive-integer-CqWjqSi9.mjs → positive-integer-Bb4Evc7L.mjs} +1 -1
  71. package/dist/prompt-cache-stability-D_MeCQFI.mjs +32 -0
  72. package/dist/{provider-error-xumb1V3F.d.mts → provider-error-CnaWYTRY.d.mts} +1 -0
  73. package/dist/{provider-error-CF9GWCs2.mjs → provider-error-qtZD2inE.mjs} +75 -13
  74. package/dist/{provider-options-CVrXZBtA.d.mts → provider-options-DeYeaflL.d.mts} +52 -6
  75. package/dist/{transport-utils-34BQoXq3.mjs → provider-replay-context-J6CfU3m1.mjs} +28 -5
  76. package/dist/{provider-transport-turn-state-BYrELw8H.mjs → provider-transport-turn-state-Jxppzuc2.mjs} +5 -5
  77. package/dist/{provider-types-CHtRx0dI.d.mts → provider-types-ODq57rG_.d.mts} +3 -3
  78. package/dist/provider-types.d.mts +6 -6
  79. package/dist/providers.d.mts +2 -2
  80. package/dist/providers.mjs +11 -11
  81. package/dist/{reasoning-tag-text-partitioner-CpOy9-IQ.mjs → reasoning-tag-text-partitioner-DzlRubwU.mjs} +134 -47
  82. package/dist/{required-api-key-CFJvcFy_.mjs → required-api-key-D088S4Cd.mjs} +1 -1
  83. package/dist/{retry-after-CdCURCVg.d.mts → retry-after-sw-XX8aC.d.mts} +1 -1
  84. package/dist/sanitize-unicode-CRGuMONI.mjs +8 -0
  85. package/dist/sanitize-unicode-ZqVLLEKC.d.mts +27 -0
  86. package/dist/{session-resources-D1wgDQ8C.mjs → session-resources-vKvGIE3J.mjs} +1 -10
  87. package/dist/{simple-options-BAu4B54D.mjs → simple-options-BYgC6kse.mjs} +68 -79
  88. package/dist/{src-C44MKrW5.mjs → src-CyA0zJnt.mjs} +6 -2
  89. package/dist/{stream-Dd8DwRFL.mjs → stream-DLBirT0e.mjs} +8 -47
  90. package/dist/{stream-first-event-timeout-Dc42hKv6.mjs → stream-first-event-timeout-D_TfJHRJ.mjs} +1 -1
  91. package/dist/{string-coerce-CtgOVOSv.mjs → string-coerce-Cj8sqWHx.mjs} +26 -1
  92. package/dist/tool-schema-json-projection-B0hHDV7N.mjs +492 -0
  93. package/dist/{transport-stream-shared-BmpzDtdQ.d.mts → transport-stream-shared-8ru8eX4s.d.mts} +5 -5
  94. package/dist/{transport-stream-shared-CWGOuLcA.mjs → transport-stream-shared-CzQlAzJH.mjs} +27 -75
  95. package/dist/transports.d.mts +33 -28
  96. package/dist/transports.mjs +42 -48
  97. package/dist/{types-CQc6JNG4.mjs → types-BXd0kI8-.mjs} +1 -1
  98. package/dist/types-CBJthzJX.d.mts +1 -0
  99. package/dist/{types-Bd2T86VJ.d.mts → types-CVYzKrMl.d.mts} +20 -3
  100. package/dist/types.d.mts +6 -6
  101. package/dist/types.mjs +4 -4
  102. package/dist/{validation-ZX_sPVV0.mjs → validation-9FSkE8T-.mjs} +22 -3
  103. package/dist/{validation-DdGB1yy3.d.mts → validation-BQ5u20Ru.d.mts} +1 -1
  104. package/dist/validation.d.mts +1 -1
  105. package/dist/validation.mjs +1 -1
  106. package/package.json +3 -3
  107. package/dist/assistant-text-phase-mvdMcrY-.mjs +0 -50
  108. package/dist/event-stream-6UNs-AhN.d.mts +0 -1
  109. package/dist/expect-lbe3Hgrh.mjs +0 -8
  110. package/dist/json-schema-Bp07Qui3.mjs +0 -22
  111. package/dist/openai-responses-request-lifecycle-NSIJo9jY.mjs +0 -67
  112. package/dist/openai-tool-projection-793cE3QX.d.mts +0 -37
  113. package/dist/openai-tool-schema-a5ysBBga.d.mts +0 -32
  114. package/dist/rolldown-runtime-BhDjJH2R.mjs +0 -15
  115. package/dist/sanitize-unicode-CjDG6jJx.d.mts +0 -5
  116. package/dist/string-normalization-I3ux50s9.mjs +0 -28
  117. package/dist/text-signature-CUXnvk_c.mjs +0 -34
  118. package/dist/tool-schema-json-projection-B8sG1I9v.mjs +0 -180
  119. package/dist/types-Kdfw_04V.d.mts +0 -1
@@ -1,6 +1,16 @@
1
- import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
- import "./provider-error-CF9GWCs2.mjs";
3
- import { t as expectDefined } from "./expect-lbe3Hgrh.mjs";
1
+ import { l as expectDefined } from "./provider-error-qtZD2inE.mjs";
2
+ //#region \0rolldown/runtime.js
3
+ var __defProp = Object.defineProperty;
4
+ var __exportAll = (all, no_symbols) => {
5
+ let target = {};
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
+ return target;
12
+ };
13
+ //#endregion
4
14
  //#region node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
5
15
  /**
6
16
  * @typedef {import('mdast').Nodes} Nodes
@@ -9794,7 +9804,7 @@ function index(value) {
9794
9804
  return value && typeof value === "number" ? value : 1;
9795
9805
  }
9796
9806
  //#endregion
9797
- //#region node_modules/.pnpm/mdast-util-from-markdown@2.0.3_supports-color@10.2.2/node_modules/mdast-util-from-markdown/lib/index.js
9807
+ //#region node_modules/.pnpm/mdast-util-from-markdown@2.1.0_supports-color@10.2.2/node_modules/mdast-util-from-markdown/lib/index.js
9798
9808
  /**
9799
9809
  * @import {
9800
9810
  * Break,
@@ -9874,6 +9884,8 @@ function fromMarkdown(value, encoding, options) {
9874
9884
  function compiler(options) {
9875
9885
  /** @type {Config} */
9876
9886
  const config = {
9887
+ afterExit: [],
9888
+ beforeEnter: [],
9877
9889
  transforms: [],
9878
9890
  canContainEols: [
9879
9891
  "emphasis",
@@ -9993,7 +10005,8 @@ function compiler(options) {
9993
10005
  /** @type {Root} */
9994
10006
  let tree = {
9995
10007
  type: "root",
9996
- children: []
10008
+ children: [],
10009
+ position: void 0
9997
10010
  };
9998
10011
  /** @type {Omit<CompileContext, 'sliceSerialize'>} */
9999
10012
  const context = {
@@ -10008,15 +10021,32 @@ function compiler(options) {
10008
10021
  };
10009
10022
  /** @type {Array<number>} */
10010
10023
  const listStack = [];
10024
+ /** @type {Array<Event>} */
10025
+ const prepared = [];
10011
10026
  let index = -1;
10012
- while (++index < events.length) if (events[index][1].type === "listOrdered" || events[index][1].type === "listUnordered") {
10013
- if (events[index][0] === "enter") listStack.push(index);
10014
- else index = prepareList(events, listStack.pop(), index);
10027
+ while (++index < events.length) {
10028
+ prepared.push(events[index]);
10029
+ if (events[index][1].type === "listOrdered" || events[index][1].type === "listUnordered") {
10030
+ if (events[index][0] === "enter") listStack.push(prepared.length - 1);
10031
+ else prepareList(prepared, listStack.pop());
10032
+ }
10015
10033
  }
10034
+ events = prepared;
10016
10035
  index = -1;
10017
10036
  while (++index < events.length) {
10018
10037
  const handler = config[events[index][0]];
10019
- if (own.call(handler, events[index][1].type)) handler[events[index][1].type].call(Object.assign({ sliceSerialize: events[index][2].sliceSerialize }, context), events[index][1]);
10038
+ if (events[index][0] === "enter" && config.beforeEnter.length > 0) callListeners(config.beforeEnter, {
10039
+ ...context,
10040
+ sliceSerialize: events[index][2].sliceSerialize
10041
+ }, events[index][1]);
10042
+ if (own.call(handler, events[index][1].type)) handler[events[index][1].type].call({
10043
+ ...context,
10044
+ sliceSerialize: events[index][2].sliceSerialize
10045
+ }, events[index][1]);
10046
+ if (events[index][0] === "exit" && config.afterExit.length > 0) callListeners(config.afterExit, {
10047
+ ...context,
10048
+ sliceSerialize: events[index][2].sliceSerialize
10049
+ }, events[index][1]);
10020
10050
  }
10021
10051
  if (context.tokenStack.length > 0) {
10022
10052
  const tail = context.tokenStack[context.tokenStack.length - 1];
@@ -10039,12 +10069,28 @@ function compiler(options) {
10039
10069
  return tree;
10040
10070
  }
10041
10071
  /**
10072
+ * @param {Array<Handle>} listeners
10073
+ * Listeners.
10074
+ * @param {CompileContext} context
10075
+ * Context.
10076
+ * @param {Token} token
10077
+ * Token.
10078
+ * @returns {undefined}
10079
+ * Nothing.
10080
+ */
10081
+ function callListeners(listeners, context, token) {
10082
+ let index = -1;
10083
+ while (++index < listeners.length) listeners[index].call(context, token);
10084
+ }
10085
+ /**
10042
10086
  * @param {Array<Event>} events
10087
+ * Events, ending with the list to prepare.
10043
10088
  * @param {number} start
10044
- * @param {number} length
10045
- * @returns {number}
10089
+ * Index of the list enter.
10090
+ * @returns {undefined}
10046
10091
  */
10047
- function prepareList(events, start, length) {
10092
+ function prepareList(events, start) {
10093
+ const end = events.length - 1;
10048
10094
  let index = start - 1;
10049
10095
  let containerBalance = -1;
10050
10096
  let listSpread = false;
@@ -10056,7 +10102,14 @@ function compiler(options) {
10056
10102
  let firstBlankLineIndex;
10057
10103
  /** @type {boolean | undefined} */
10058
10104
  let atMarker;
10059
- while (++index <= length) {
10105
+ /**
10106
+ * `listItem` events to insert before the event at `at`, in walk order.
10107
+ * Merged in after the walk, as inserting while walking would shift the
10108
+ * rest of the list once per item.
10109
+ * @type {Array<{at: number, event: Event}>}
10110
+ */
10111
+ const insertions = [];
10112
+ while (++index <= end) {
10060
10113
  const event = events[index];
10061
10114
  switch (event[1].type) {
10062
10115
  case "listUnordered":
@@ -10097,13 +10150,14 @@ function compiler(options) {
10097
10150
  }
10098
10151
  if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) listItem._spread = true;
10099
10152
  listItem.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end);
10100
- events.splice(lineIndex || index, 0, [
10101
- "exit",
10102
- listItem,
10103
- event[2]
10104
- ]);
10105
- index++;
10106
- length++;
10153
+ insertions.push({
10154
+ at: lineIndex || index,
10155
+ event: [
10156
+ "exit",
10157
+ listItem,
10158
+ event[2]
10159
+ ]
10160
+ });
10107
10161
  }
10108
10162
  if (event[1].type === "listItemPrefix") {
10109
10163
  /** @type {Token} */
@@ -10114,20 +10168,27 @@ function compiler(options) {
10114
10168
  end: void 0
10115
10169
  };
10116
10170
  listItem = item;
10117
- events.splice(index, 0, [
10118
- "enter",
10119
- item,
10120
- event[2]
10121
- ]);
10122
- index++;
10123
- length++;
10171
+ insertions.push({
10172
+ at: index,
10173
+ event: [
10174
+ "enter",
10175
+ item,
10176
+ event[2]
10177
+ ]
10178
+ });
10124
10179
  firstBlankLineIndex = void 0;
10125
10180
  atMarker = true;
10126
10181
  }
10127
10182
  }
10128
10183
  }
10184
+ const listEvents = events.splice(start);
10185
+ let insertion = 0;
10186
+ index = -1;
10187
+ while (++index < listEvents.length) {
10188
+ while (insertion < insertions.length && insertions[insertion].at === start + index) events.push(insertions[insertion++].event);
10189
+ events.push(listEvents[index]);
10190
+ }
10129
10191
  events[start][1]._spread = listSpread;
10130
- return length;
10131
10192
  }
10132
10193
  /**
10133
10194
  * Create an opener handle.
@@ -10202,7 +10263,7 @@ function compiler(options) {
10202
10263
  start: token.start,
10203
10264
  end: token.end
10204
10265
  }) + "): it’s not open");
10205
- else if (open[0].type !== token.type) {
10266
+ if (open[0].type !== token.type) {
10206
10267
  if (onExitError) onExitError.call(this, token, open[0]);
10207
10268
  else (open[1] || defaultOnError).call(this, token, open[0]);
10208
10269
  }
@@ -10570,7 +10631,8 @@ function compiler(options) {
10570
10631
  function blockQuote() {
10571
10632
  return {
10572
10633
  type: "blockquote",
10573
- children: []
10634
+ children: [],
10635
+ position: void 0
10574
10636
  };
10575
10637
  }
10576
10638
  /** @returns {Code} */
@@ -10579,14 +10641,16 @@ function compiler(options) {
10579
10641
  type: "code",
10580
10642
  lang: null,
10581
10643
  meta: null,
10582
- value: ""
10644
+ value: "",
10645
+ position: void 0
10583
10646
  };
10584
10647
  }
10585
10648
  /** @returns {InlineCode} */
10586
10649
  function codeText() {
10587
10650
  return {
10588
10651
  type: "inlineCode",
10589
- value: ""
10652
+ value: "",
10653
+ position: void 0
10590
10654
  };
10591
10655
  }
10592
10656
  /** @returns {Definition} */
@@ -10596,14 +10660,16 @@ function compiler(options) {
10596
10660
  identifier: "",
10597
10661
  label: null,
10598
10662
  title: null,
10599
- url: ""
10663
+ url: "",
10664
+ position: void 0
10600
10665
  };
10601
10666
  }
10602
10667
  /** @returns {Emphasis} */
10603
10668
  function emphasis() {
10604
10669
  return {
10605
10670
  type: "emphasis",
10606
- children: []
10671
+ children: [],
10672
+ position: void 0
10607
10673
  };
10608
10674
  }
10609
10675
  /** @returns {Heading} */
@@ -10611,18 +10677,23 @@ function compiler(options) {
10611
10677
  return {
10612
10678
  type: "heading",
10613
10679
  depth: 0,
10614
- children: []
10680
+ children: [],
10681
+ position: void 0
10615
10682
  };
10616
10683
  }
10617
10684
  /** @returns {Break} */
10618
10685
  function hardBreak() {
10619
- return { type: "break" };
10686
+ return {
10687
+ type: "break",
10688
+ position: void 0
10689
+ };
10620
10690
  }
10621
10691
  /** @returns {Html} */
10622
10692
  function html() {
10623
10693
  return {
10624
10694
  type: "html",
10625
- value: ""
10695
+ value: "",
10696
+ position: void 0
10626
10697
  };
10627
10698
  }
10628
10699
  /** @returns {Image} */
@@ -10631,7 +10702,8 @@ function compiler(options) {
10631
10702
  type: "image",
10632
10703
  title: null,
10633
10704
  url: "",
10634
- alt: null
10705
+ alt: null,
10706
+ position: void 0
10635
10707
  };
10636
10708
  }
10637
10709
  /** @returns {Link} */
@@ -10640,7 +10712,8 @@ function compiler(options) {
10640
10712
  type: "link",
10641
10713
  title: null,
10642
10714
  url: "",
10643
- children: []
10715
+ children: [],
10716
+ position: void 0
10644
10717
  };
10645
10718
  }
10646
10719
  /**
@@ -10653,7 +10726,8 @@ function compiler(options) {
10653
10726
  ordered: token.type === "listOrdered",
10654
10727
  start: null,
10655
10728
  spread: token._spread,
10656
- children: []
10729
+ children: [],
10730
+ position: void 0
10657
10731
  };
10658
10732
  }
10659
10733
  /**
@@ -10665,33 +10739,40 @@ function compiler(options) {
10665
10739
  type: "listItem",
10666
10740
  spread: token._spread,
10667
10741
  checked: null,
10668
- children: []
10742
+ children: [],
10743
+ position: void 0
10669
10744
  };
10670
10745
  }
10671
10746
  /** @returns {Paragraph} */
10672
10747
  function paragraph() {
10673
10748
  return {
10674
10749
  type: "paragraph",
10675
- children: []
10750
+ children: [],
10751
+ position: void 0
10676
10752
  };
10677
10753
  }
10678
10754
  /** @returns {Strong} */
10679
10755
  function strong() {
10680
10756
  return {
10681
10757
  type: "strong",
10682
- children: []
10758
+ children: [],
10759
+ position: void 0
10683
10760
  };
10684
10761
  }
10685
10762
  /** @returns {Text} */
10686
10763
  function text() {
10687
10764
  return {
10688
10765
  type: "text",
10689
- value: ""
10766
+ value: "",
10767
+ position: void 0
10690
10768
  };
10691
10769
  }
10692
10770
  /** @returns {ThematicBreak} */
10693
10771
  function thematicBreak() {
10694
- return { type: "thematicBreak" };
10772
+ return {
10773
+ type: "thematicBreak",
10774
+ position: void 0
10775
+ };
10695
10776
  }
10696
10777
  }
10697
10778
  /**
@@ -10741,6 +10822,12 @@ function extension(combined, extension) {
10741
10822
  if (right) combined[key].push(...right);
10742
10823
  break;
10743
10824
  }
10825
+ case "afterExit":
10826
+ case "beforeEnter": {
10827
+ const right = extension[key];
10828
+ if (right) combined[key].push(right);
10829
+ break;
10830
+ }
10744
10831
  case "enter":
10745
10832
  case "exit": {
10746
10833
  const right = extension[key];
@@ -10758,7 +10845,7 @@ function defaultOnError(left, right) {
10758
10845
  start: right.start,
10759
10846
  end: right.end
10760
10847
  }) + ") is open");
10761
- else throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
10848
+ throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
10762
10849
  start: right.start,
10763
10850
  end: right.end
10764
10851
  }) + ") is still open");
@@ -12507,4 +12594,4 @@ function createReasoningTagTextPartitioner() {
12507
12594
  };
12508
12595
  }
12509
12596
  //#endregion
12510
- export { createReasoningTagTextPartitioner as t };
12597
+ export { __exportAll as n, createReasoningTagTextPartitioner as t };
@@ -1,4 +1,4 @@
1
- import { n as getEnvApiKey } from "./env-api-keys-CrxwdylR.mjs";
1
+ import { n as getEnvApiKey } from "./env-api-keys-Xd8dm_aV.mjs";
2
2
  //#region packages/ai/src/utils/required-api-key.ts
3
3
  function requireApiKey(provider, apiKey) {
4
4
  const resolved = apiKey || getEnvApiKey(provider);
@@ -4,7 +4,7 @@ type HttpDateInstant = {
4
4
  leapSecond: boolean;
5
5
  };
6
6
  /** Reads only retry timing metadata, without invoking provider getters or serialization hooks. */
7
- declare function parseRetryAfterHeadersSeconds(headers: unknown, nowMs?: number): number | undefined;
7
+ declare function parseRetryAfterHeadersSeconds(headers: unknown, nowMs?: number, status?: number): number | undefined;
8
8
  /** SDK errors carry native response headers separately from their error body. */
9
9
  declare function parseRetryAfterErrorSeconds(error: unknown, nowMs?: number): number | undefined;
10
10
  /** Round leap seconds forward for Retry-After so an unrepresentable instant cannot retry early. */
@@ -0,0 +1,8 @@
1
+ //#region packages/ai/src/utils/sanitize-unicode.ts
2
+ /** Remove unpaired surrogates rejected by providers; preserve valid Unicode pairs. */
3
+ function sanitizeSurrogates(text) {
4
+ if (text.isWellFormed()) return text;
5
+ return text.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "");
6
+ }
7
+ //#endregion
8
+ export { sanitizeSurrogates as t };
@@ -0,0 +1,27 @@
1
+ import { a as AssistantMessage } from "./types-CVYzKrMl.mjs";
2
+ import "./types-CBJthzJX.mjs";
3
+ //#region packages/ai/src/utils/overflow.d.ts
4
+ declare const CONTEXT_OVERFLOW_PATTERN_SCOPES: {
5
+ readonly "assistant-error": RegExp[];
6
+ readonly "failover-explicit": RegExp[];
7
+ readonly "provider-fallback": RegExp[];
8
+ readonly "failover-hint": readonly [RegExp];
9
+ readonly "context-window-too-small": readonly [RegExp];
10
+ readonly "tpm-rate-limit-hint": readonly [RegExp];
11
+ readonly "rate-limit-hint": readonly [RegExp];
12
+ };
13
+ type ContextOverflowMessageScope = keyof typeof CONTEXT_OVERFLOW_PATTERN_SCOPES;
14
+ /** Match one canonical context-overflow wording scope without applying caller policy. */
15
+ declare function matchesContextOverflowMessage(errorMessage: string, scope: ContextOverflowMessageScope): boolean;
16
+ /**
17
+ * Match provider overflow errors, or infer overflow from reported context usage.
18
+ * A context window enables silent-overflow detection; silent truncation without
19
+ * a length stop remains undetectable because the original token count is unknown.
20
+ */
21
+ declare function isContextOverflow(message: AssistantMessage, contextWindow?: number): boolean;
22
+ //#endregion
23
+ //#region packages/ai/src/utils/sanitize-unicode.d.ts
24
+ /** Remove unpaired surrogates rejected by providers; preserve valid Unicode pairs. */
25
+ declare function sanitizeSurrogates(text: string): string;
26
+ //#endregion
27
+ export { isContextOverflow as n, matchesContextOverflowMessage as r, sanitizeSurrogates as t };
@@ -1,6 +1,5 @@
1
1
  //#region packages/ai/src/session-resources.ts
2
2
  const sessionResourceCleanups = /* @__PURE__ */ new Set();
3
- const sessionResourceCleanupObservers = /* @__PURE__ */ new Set();
4
3
  const sessionResourceOwnerIds = /* @__PURE__ */ new WeakMap();
5
4
  let nextSessionResourceOwnerId = 1;
6
5
  /** Returns a process-local key that keeps retained resources separated by runtime owner. */
@@ -18,13 +17,6 @@ function registerSessionResourceCleanup(cleanup) {
18
17
  sessionResourceCleanups.delete(cleanup);
19
18
  };
20
19
  }
21
- /** Registers metadata cleanup that runs only after every resource cleanup succeeds. */
22
- function registerSessionResourceCleanupObserver(observer) {
23
- sessionResourceCleanupObservers.add(observer);
24
- return () => {
25
- sessionResourceCleanupObservers.delete(observer);
26
- };
27
- }
28
20
  /** Runs all registered cleanup hooks, aggregating failures after every hook has run. */
29
21
  function cleanupSessionResources(sessionId, owner) {
30
22
  const errors = [];
@@ -34,7 +26,6 @@ function cleanupSessionResources(sessionId, owner) {
34
26
  errors.push(error);
35
27
  }
36
28
  if (errors.length > 0) throw new AggregateError(errors, "Failed to cleanup session resources");
37
- for (const observer of sessionResourceCleanupObservers) observer(sessionId, owner);
38
29
  }
39
30
  //#endregion
40
- export { registerSessionResourceCleanupObserver as i, getSessionResourceOwnerId as n, registerSessionResourceCleanup as r, cleanupSessionResources as t };
31
+ export { getSessionResourceOwnerId as n, registerSessionResourceCleanup as r, cleanupSessionResources as t };
@@ -1,38 +1,10 @@
1
1
  import { o as isRecord } from "./record-coerce-CNDovvft.mjs";
2
- import { n as normalizeLowercaseStringOrEmpty } from "./string-coerce-CtgOVOSv.mjs";
3
- import { M as hasMediaPayload, r as getAiTransportHost } from "./host-Bf3NjYNj.mjs";
4
- import { g as responsesServiceTierObserver } from "./openai-responses-contracts-DlKMMTxK.mjs";
5
- import { s as truncateUtf16Safe } from "./provider-error-CF9GWCs2.mjs";
6
- import { P as sanitizeSurrogates, i as copyProviderAcceptanceObserver } from "./transport-stream-shared-CWGOuLcA.mjs";
7
- //#region packages/ai/src/utils/prompt-cache-stability.ts
8
- /**
9
- * Prompt-cache normalization helpers. They keep generated prompt sections
10
- * deterministic across platform newlines, trailing whitespace, and input
11
- * ordering.
12
- */
13
- /** Canonicalizes provider tool order without relying on host locale settings. */
14
- function sortPromptCacheToolsByName(tools) {
15
- const compareText = (left, right) => {
16
- const leftText = left ?? "";
17
- const rightText = right ?? "";
18
- return leftText < rightText ? -1 : leftText > rightText ? 1 : 0;
19
- };
20
- return tools.toSorted((left, right) => compareText(left.wireName ?? left.name, right.wireName ?? right.name) || compareText(left.description, right.description));
21
- }
22
- /** Normalize structured prompt text before hashing or snapshot comparison. */
23
- function normalizeStructuredPromptSection(text) {
24
- return sanitizeSurrogates(text).replace(/\r\n?/g, "\n").replace(/[ \t]+$/gm, "").trim();
25
- }
26
- /** Normalize, de-dupe, and sort capability ids for stable prompt payloads. */
27
- function normalizePromptCapabilityIds(capabilities) {
28
- const seen = /* @__PURE__ */ new Set();
29
- for (const capability of capabilities) {
30
- const value = normalizeLowercaseStringOrEmpty(normalizeStructuredPromptSection(capability));
31
- if (value) seen.add(value);
32
- }
33
- return [...seen].toSorted((left, right) => left.localeCompare(right));
34
- }
35
- //#endregion
2
+ import { M as hasMediaPayload } from "./host-B2gk-d1H.mjs";
3
+ import { _ as responsesServiceTierObserver } from "./openai-responses-contracts-Bx-16mnf.mjs";
4
+ import { s as truncateUtf16Safe } from "./provider-error-qtZD2inE.mjs";
5
+ import { t as sanitizeSurrogates } from "./sanitize-unicode-CRGuMONI.mjs";
6
+ import { n as normalizeStructuredPromptSection } from "./prompt-cache-stability-D_MeCQFI.mjs";
7
+ import { i as copyProviderAcceptanceObserver } from "./transport-stream-shared-CzQlAzJH.mjs";
36
8
  //#region packages/ai/src/utils/system-prompt-cache-boundary.ts
37
9
  const SYSTEM_PROMPT_CACHE_BOUNDARY = "\n<!-- OPENCLAW_CACHE_BOUNDARY -->\n";
38
10
  /** Producer-delimited Runtime facts; instructions must remain outside this region. */
@@ -79,6 +51,55 @@ function prependSystemPromptAdditionAfterCacheBoundary(params) {
79
51
  return `${split.stablePrefix}${SYSTEM_PROMPT_CACHE_BOUNDARY}${systemPromptAddition}${dynamicSuffix ? `\n\n${dynamicSuffix}` : ""}`;
80
52
  }
81
53
  //#endregion
54
+ //#region packages/ai/src/provider-options.ts
55
+ const CODE_MODE_TOOL_SURFACE_OBSERVER = Symbol("openaiCodeModeToolSurfaceObserver");
56
+ const CODE_MODE_TOOL_SURFACE_COLLECTOR = Symbol("openaiCodeModeToolSurfaceCollector");
57
+ const STRICT_REASONING_TAG_TEXT = Symbol("openaiStrictReasoningTagText");
58
+ function markStrictReasoningTagText(options) {
59
+ Reflect.set(options, STRICT_REASONING_TAG_TEXT, true);
60
+ }
61
+ function isStrictReasoningTagText(options) {
62
+ return options ? Reflect.get(options, STRICT_REASONING_TAG_TEXT) === true : false;
63
+ }
64
+ const codeModeToolSurfaceObserver = {
65
+ set(options, observer, collector) {
66
+ Reflect.set(options, CODE_MODE_TOOL_SURFACE_OBSERVER, observer);
67
+ if (collector) Reflect.set(options, CODE_MODE_TOOL_SURFACE_COLLECTOR, collector);
68
+ },
69
+ get(options) {
70
+ if (!options) return;
71
+ const observer = Reflect.get(options, CODE_MODE_TOOL_SURFACE_OBSERVER);
72
+ return typeof observer === "function" ? (observation) => observer(observation) : void 0;
73
+ },
74
+ getCollector(options) {
75
+ if (!options) return;
76
+ const collector = Reflect.get(options, CODE_MODE_TOOL_SURFACE_COLLECTOR);
77
+ return typeof collector === "function" ? (observation) => collector(observation) : void 0;
78
+ }
79
+ };
80
+ /** Internal output policy for callers that must not recover ambiguous reasoning as visible text. */
81
+ const reasoningTagTextPolicy = {
82
+ markStrict: markStrictReasoningTagText,
83
+ isStrict: isStrictReasoningTagText,
84
+ copy(source, target) {
85
+ if (isStrictReasoningTagText(source)) markStrictReasoningTagText(target);
86
+ }
87
+ };
88
+ const PREPARED_REQUEST_SUFFIX = Symbol("preparedRequestSuffix");
89
+ /** The caller supplies a captured wire prefix; transport repair must retain its late tool results. */
90
+ const preparedRequestSuffix = {
91
+ mark(context, toolCallIds) {
92
+ Reflect.set(context, PREPARED_REQUEST_SUFFIX, toolCallIds);
93
+ },
94
+ has(context) {
95
+ return Reflect.has(context, PREPARED_REQUEST_SUFFIX);
96
+ },
97
+ toolCallId(context, id, normalized) {
98
+ const ids = Reflect.get(context, PREPARED_REQUEST_SUFFIX);
99
+ return ids && !ids.has(id) && ids.has(normalized) ? normalized : id;
100
+ }
101
+ };
102
+ //#endregion
82
103
  //#region packages/ai/src/providers/tool-result-text.ts
83
104
  const STRUCTURED_TOOL_RESULT_MAX_CHARS = 8e3;
84
105
  const IMAGE_TOOL_RESULT_TYPES = /* @__PURE__ */ new Set([
@@ -120,9 +141,7 @@ function redactInlineDataUris(value) {
120
141
  function stringifyStructuredBlock(block) {
121
142
  const seen = /* @__PURE__ */ new WeakSet();
122
143
  try {
123
- const host = getAiTransportHost();
124
- const redactedBlock = host.redactModelVisibleSecrets({ structuredToolResult: block }).structuredToolResult;
125
- const serialized = JSON.stringify(redactedBlock, function structuredToolResultReplacer(key, value) {
144
+ const serialized = JSON.stringify(block, function structuredToolResultReplacer(key, value) {
126
145
  if (OPAQUE_OR_BINARY_FIELD_RE.test(key)) return `[omitted ${key}]`;
127
146
  if (key === "data") {
128
147
  const mimeType = readMimeType(this);
@@ -132,7 +151,7 @@ function stringifyStructuredBlock(block) {
132
151
  }
133
152
  }
134
153
  if (typeof value === "bigint") return value.toString();
135
- if (typeof value === "string") return redactInlineDataUris(host.redactModelVisibleSecrets(value));
154
+ if (typeof value === "string") return redactInlineDataUris(value);
136
155
  if (typeof value === "function" || typeof value === "symbol" || value === void 0) return;
137
156
  if (!value || typeof value !== "object") return value;
138
157
  if (seen.has(value)) return "[Circular]";
@@ -217,41 +236,6 @@ function formatToolResultText(params) {
217
236
  return `${params.isError ? "[tool error] " : ""}${body}`;
218
237
  }
219
238
  //#endregion
220
- //#region packages/ai/src/provider-options.ts
221
- const CODE_MODE_TOOL_SURFACE_OBSERVER = Symbol("openaiCodeModeToolSurfaceObserver");
222
- const CODE_MODE_TOOL_SURFACE_COLLECTOR = Symbol("openaiCodeModeToolSurfaceCollector");
223
- const STRICT_REASONING_TAG_TEXT = Symbol("openaiStrictReasoningTagText");
224
- function markStrictReasoningTagText(options) {
225
- Reflect.set(options, STRICT_REASONING_TAG_TEXT, true);
226
- }
227
- function isStrictReasoningTagText(options) {
228
- return options ? Reflect.get(options, STRICT_REASONING_TAG_TEXT) === true : false;
229
- }
230
- const codeModeToolSurfaceObserver = {
231
- set(options, observer, collector) {
232
- Reflect.set(options, CODE_MODE_TOOL_SURFACE_OBSERVER, observer);
233
- if (collector) Reflect.set(options, CODE_MODE_TOOL_SURFACE_COLLECTOR, collector);
234
- },
235
- get(options) {
236
- if (!options) return;
237
- const observer = Reflect.get(options, CODE_MODE_TOOL_SURFACE_OBSERVER);
238
- return typeof observer === "function" ? (observation) => observer(observation) : void 0;
239
- },
240
- getCollector(options) {
241
- if (!options) return;
242
- const collector = Reflect.get(options, CODE_MODE_TOOL_SURFACE_COLLECTOR);
243
- return typeof collector === "function" ? (observation) => collector(observation) : void 0;
244
- }
245
- };
246
- /** Internal output policy for callers that must not recover ambiguous reasoning as visible text. */
247
- const reasoningTagTextPolicy = {
248
- markStrict: markStrictReasoningTagText,
249
- isStrict: isStrictReasoningTagText,
250
- copy(source, target) {
251
- if (isStrictReasoningTagText(source)) markStrictReasoningTagText(target);
252
- }
253
- };
254
- //#endregion
255
239
  //#region packages/ai/src/transports/model-request-body.ts
256
240
  const REQUEST_BODY = Symbol("modelRequestBody");
257
241
  /** Call-local state survives option spreads; no payload is cached across requests. */
@@ -260,11 +244,14 @@ function modelRequestBodyState(options, inheritFrom) {
260
244
  Reflect.set(options, REQUEST_BODY, state);
261
245
  return state;
262
246
  }
263
- function serializeModelRequestBody(payload) {
247
+ function serializeModelRequestBody(payload, onSerializedPayload) {
264
248
  const json = JSON.stringify(payload);
249
+ const serialized = json === void 0 ? void 0 : JSON.parse(json);
250
+ const stream = typeof serialized === "object" && serialized !== null && "stream" in serialized && serialized.stream === true;
251
+ onSerializedPayload?.(serialized);
265
252
  return {
266
253
  body: new TextEncoder().encode(json),
267
- stream: json !== void 0 && JSON.parse(json)?.stream === true
254
+ stream
268
255
  };
269
256
  }
270
257
  const encodedBodyStreams = /* @__PURE__ */ new WeakMap();
@@ -277,10 +264,12 @@ function prepareModelRequestBody(options) {
277
264
  state.enabled = true;
278
265
  return async (payload) => {
279
266
  const encoded = state.encode ? await state.encode(payload) : serializeModelRequestBody(payload);
280
- state.onBytes?.(encoded.body.byteLength);
281
- encodedBodyStreams.set(encoded.body, encoded.stream);
267
+ const body = new Blob([encoded.body]);
268
+ state.onEncoded?.(body, payload);
269
+ state.onBytes?.(body.size);
270
+ encodedBodyStreams.set(body, encoded.stream);
282
271
  return {
283
- body: encoded.body,
272
+ body,
284
273
  headers: { "content-type": "application/json" }
285
274
  };
286
275
  };
@@ -340,4 +329,4 @@ function adjustMaxTokensForThinking(baseMaxTokens, modelMaxTokens, reasoningLeve
340
329
  };
341
330
  }
342
331
  //#endregion
343
- export { stripSystemPromptCacheBoundary as C, sortPromptCacheToolsByName as D, normalizeStructuredPromptSection as E, splitSystemPromptRelocatableBoundary as S, normalizePromptCapabilityIds as T, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY as _, encodedModelRequestBodyStream as a, prependSystemPromptAdditionAfterCacheBoundary as b, serializeModelRequestBody as c, describeToolResultMediaPlaceholder as d, describeUnsupportedToolResultMedia as f, SYSTEM_PROMPT_CACHE_BOUNDARY as g, formatToolResultText as h, clampReasoning as i, codeModeToolSurfaceObserver as l, extractToolResultText as m, buildBaseOptions as n, modelRequestBodyState as o, extractToolResultBlockText as p, clampMaxTokensToModel as r, prepareModelRequestBody as s, adjustMaxTokensForThinking as t, reasoningTagTextPolicy as u, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END as v, stripSystemPromptRelocatableBoundary as w, splitSystemPromptCacheBoundary as x, ensureSystemPromptCacheBoundary as y };
332
+ export { splitSystemPromptRelocatableBoundary as C, splitSystemPromptCacheBoundary as S, stripSystemPromptRelocatableBoundary as T, SYSTEM_PROMPT_CACHE_BOUNDARY as _, encodedModelRequestBodyStream as a, ensureSystemPromptCacheBoundary as b, serializeModelRequestBody as c, extractToolResultBlockText as d, extractToolResultText as f, reasoningTagTextPolicy as g, preparedRequestSuffix as h, clampReasoning as i, describeToolResultMediaPlaceholder as l, codeModeToolSurfaceObserver as m, buildBaseOptions as n, modelRequestBodyState as o, formatToolResultText as p, clampMaxTokensToModel as r, prepareModelRequestBody as s, adjustMaxTokensForThinking as t, describeUnsupportedToolResultMedia as u, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY as v, stripSystemPromptCacheBoundary as w, prependSystemPromptAdditionAfterCacheBoundary as x, SYSTEM_PROMPT_RELOCATABLE_BOUNDARY_END as y };