@openclaw/ai 2026.9.3 → 2026.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +1 -1
  2. package/dist/{anthropic-CZy5U0NY.mjs → anthropic-COtDvgtt.mjs} +16 -16
  3. package/dist/{anthropic-payload-policy-wuRCb6MH.d.mts → anthropic-payload-policy-5Erq1Nzy.d.mts} +3 -3
  4. package/dist/{anthropic-stream-reducer-B_yo_7pf.mjs → anthropic-stream-reducer-BvdYYWL8.mjs} +56 -47
  5. package/dist/{api-registry-CB1-1oQ2.d.mts → api-registry-Ba2Cv-ut.d.mts} +2 -2
  6. package/dist/{assistant-output-iqnlJCV2.mjs → assistant-output-BsEkB-vU.mjs} +1 -1
  7. package/dist/{azure-openai-responses-Crpa40QR.mjs → azure-openai-responses-YrgnD583.mjs} +6 -9
  8. package/dist/{base64-D-su8YVo.mjs → base64-BQOzsvUH.mjs} +4 -4
  9. package/dist/credential-redaction-BKv49aiv.d.mts +24 -0
  10. package/dist/{diagnostics-dV98PqIy.mjs → diagnostics-Dm4bisWG.mjs} +89 -2
  11. package/dist/diagnostics.d.mts +4 -23
  12. package/dist/diagnostics.mjs +3 -3
  13. package/dist/{event-stream-C1Z2piyk.d.mts → event-stream-CCoa-qSI.d.mts} +1 -1
  14. package/dist/event-stream-DmSCpi1T.d.mts +1 -0
  15. package/dist/event-stream.d.mts +2 -2
  16. package/dist/expect-lbe3Hgrh.mjs +8 -0
  17. package/dist/{google-BDPriaVe.mjs → google-BuhpRO9r.mjs} +7 -10
  18. package/dist/{google-messages-CVn9eFpF.mjs → google-messages-CyWnYlh0.mjs} +3 -4
  19. package/dist/{google-shared-BedY23XS.mjs → google-shared-BT5ZeNer.mjs} +13 -13
  20. package/dist/{google-vertex-DMz8XQCn.mjs → google-vertex-C7EplRvt.mjs} +5 -8
  21. package/dist/{host-CWuF-sS3.mjs → host-B4MeUNBc.mjs} +145 -12
  22. package/dist/{host-DK3wmS3e.d.mts → host-FZ1RA_qD.d.mts} +7 -3
  23. package/dist/{host-policy-CAopLRKA.mjs → host-policy-DUnXSx0I.mjs} +1 -1
  24. package/dist/{index-CQ6LTHw8.d.mts → index-DaF2QbwS.d.mts} +5 -10
  25. package/dist/index.d.mts +7 -8
  26. package/dist/index.mjs +5 -5
  27. package/dist/internal/anthropic.d.mts +6 -7
  28. package/dist/internal/anthropic.mjs +4 -4
  29. package/dist/internal/openai-completions-compat.d.mts +2 -0
  30. package/dist/internal/openai-completions-compat.mjs +2 -0
  31. package/dist/internal/openai-responses-payload-policy.d.mts +3 -3
  32. package/dist/internal/openai-responses-payload-policy.mjs +3 -2
  33. package/dist/internal/openai.d.mts +10 -53
  34. package/dist/internal/openai.mjs +11 -10
  35. package/dist/internal/runtime.d.mts +43 -10
  36. package/dist/internal/runtime.mjs +5 -11
  37. package/dist/internal/shared.d.mts +35 -5
  38. package/dist/internal/shared.mjs +4 -4
  39. package/dist/internal/tool-schema.d.mts +3 -3
  40. package/dist/internal/tool-schema.mjs +2 -2
  41. package/dist/{mistral--m-Jm6VZ.mjs → mistral-moA-mbwl.mjs} +9 -16
  42. package/dist/{openai-chatgpt-responses-nDZccFW-.mjs → openai-chatgpt-responses-DWID3EFO.mjs} +76 -33
  43. package/dist/{openai-completions-KuoZyx0d.mjs → openai-completions-DJ1Vm-CD.mjs} +12 -13
  44. package/dist/{openai-prompt-cache-BI0rkM-5.mjs → openai-completions-compat-CkwdxTZx.mjs} +5 -50
  45. package/dist/{openai-completions-compat-CXn3T1we.d.mts → openai-completions-compat-JE7gqxb9.d.mts} +4 -4
  46. package/dist/{openai-completions-stream-BQk3SkLD.mjs → openai-completions-stream-Bu98b0Hv.mjs} +128 -99
  47. package/dist/openai-prompt-cache-1wfaIszn.mjs +46 -0
  48. package/dist/{openai-prompt-cache-rrutvqxq.d.mts → openai-prompt-cache-CJ_xEevu.d.mts} +2 -2
  49. package/dist/{openai-provider-client-ha_WxTyj.mjs → openai-provider-client-DPo0Hmak.mjs} +2 -2
  50. package/dist/{openai-reasoning-effort-BK7FbcLT.mjs → openai-reasoning-effort-NlFZmfEu.mjs} +87 -19
  51. package/dist/{openai-responses-D99dOzKI.mjs → openai-responses-BejZzQCP.mjs} +9 -13
  52. package/dist/{openai-responses-compaction-window-D5jbzCi3.mjs → openai-responses-compaction-window-D6P5oZP5.mjs} +21 -140
  53. package/dist/openai-responses-contracts-DWrfMODE.mjs +81 -0
  54. package/dist/{openai-responses-contracts-B55afwRo.d.mts → openai-responses-contracts-Dflvrfa8.d.mts} +10 -39
  55. package/dist/{openai-responses-payload-policy-rLRPsSmB.d.mts → openai-responses-payload-policy-C7GsA1y0.d.mts} +5 -3
  56. package/dist/openai-responses-prompt-observer-internal-C15_-OwV.mjs +195 -0
  57. package/dist/{openai-responses-shared-ZyQEzS5i.mjs → openai-responses-shared-CwsziD_m.mjs} +390 -183
  58. package/dist/openai-responses-terminal-usage-Dl3J6zrf.d.mts +47 -0
  59. package/dist/{openai-tool-schema-CzjyYXun.mjs → openai-tool-schema-BO8rwyAD.mjs} +92 -68
  60. package/dist/{openai-transport-params-DNasp2fU.mjs → openai-transport-params-DQeuAvBl.mjs} +162 -51
  61. package/dist/positive-integer-DtjCkbue.mjs +8 -0
  62. package/dist/{provider-error-C6TbKiey.mjs → provider-error-DDqw9Qda.mjs} +140 -36
  63. package/dist/{provider-options-BXr9Ec83.d.mts → provider-options-DprLsWh9.d.mts} +9 -6
  64. package/dist/{provider-replay-context-BuSUaAk5.mjs → provider-replay-context-CnUSOwhr.mjs} +1 -1
  65. package/dist/{provider-transcript-transform-pPmUIwKt.mjs → provider-transcript-transform-BsRAhuWJ.mjs} +1 -1
  66. package/dist/provider-transport-turn-state-CkGToCD2.mjs +42 -0
  67. package/dist/{provider-types-CAV0Og3m.d.mts → provider-types-CAKRC7N5.d.mts} +3 -3
  68. package/dist/provider-types.d.mts +6 -7
  69. package/dist/providers.d.mts +2 -2
  70. package/dist/providers.mjs +10 -10
  71. package/dist/{reasoning-tag-text-partitioner-BQBi4B9d.mjs → reasoning-tag-text-partitioner-Dy9IO8Dc.mjs} +15 -14
  72. package/dist/{session-affinity-CCH7eYdB.mjs → session-affinity-Bcunsn4I.mjs} +5 -2
  73. package/dist/{simple-options-tcKOqnpF.mjs → simple-options-C6cFWj_f.mjs} +26 -5
  74. package/dist/{src-B2Q_6G8V.mjs → src-DeKjbE8I.mjs} +3 -6
  75. package/dist/{stream-first-event-timeout-2hfrquuz.mjs → stream-first-event-timeout-C9ZadkJW.mjs} +1 -1
  76. package/dist/{string-normalization-CmLIasuf.mjs → string-normalization-J9ZiLfGO.mjs} +13 -1
  77. package/dist/tool-schema-json-projection-CD9c_fK8.mjs +134 -0
  78. package/dist/{transport-stream-shared-DOxpGJ-H.d.mts → transport-stream-shared-BbUkFaHi.d.mts} +20 -36
  79. package/dist/{transport-stream-shared-Cu3ZPhNW.mjs → transport-stream-shared-D-6FQSHm.mjs} +223 -11
  80. package/dist/{transport-utils-CCooe-cr.mjs → transport-utils-1cyq5Y7x.mjs} +4 -7
  81. package/dist/transports.d.mts +51 -165
  82. package/dist/transports.mjs +172 -507
  83. package/dist/{types-Dy1q0CSu.d.mts → types-4_uVs5WH.d.mts} +49 -3
  84. package/dist/types-DkJfb4W3.d.mts +1 -0
  85. package/dist/types-LFWwv0cF.mjs +8 -0
  86. package/dist/types.d.mts +6 -7
  87. package/dist/types.mjs +4 -4
  88. package/dist/{validation-CaFUZN9B.d.mts → validation-Ctzu2DhF.d.mts} +1 -1
  89. package/dist/{validation-BDzVDnTs.mjs → validation-Dw7cb6BV.mjs} +1 -0
  90. package/dist/validation.d.mts +1 -1
  91. package/dist/validation.mjs +1 -1
  92. package/package.json +10 -5
  93. package/dist/diagnostics-DnPnOui6.d.mts +0 -29
  94. package/dist/event-stream-I_GlBsuZ.d.mts +0 -1
  95. package/dist/hash-CHgqbJmD.mjs +0 -16
  96. package/dist/json-parse-Dw_hnxsA.mjs +0 -146
  97. package/dist/openai-responses-prompt-observer-internal-tApyTLVu.mjs +0 -32
  98. package/dist/sanitize-unicode-Bb-v9meu.mjs +0 -83
  99. package/dist/tool-schema-json-projection-ClptDdAO.mjs +0 -82
  100. package/dist/types-BADKjDBI.d.mts +0 -1
  101. package/dist/types-BDdaOVi2.mjs +0 -6
@@ -1,7 +1,8 @@
1
1
  import { o as normalizeStringifiedOptionalString } from "./string-coerce-fsri9iCu.mjs";
2
2
  import { i as asOptionalRecord } from "./record-coerce-DwRYMj3t.mjs";
3
3
  import { t as truncateUtf16Safe } from "./utf16-slice-CvGodqok.mjs";
4
- import { n as estimateBase64DecodedBytes } from "./base64-D-su8YVo.mjs";
4
+ import { t as expectDefined } from "./expect-lbe3Hgrh.mjs";
5
+ import { n as estimateBase64DecodedBytes } from "./base64-BQOzsvUH.mjs";
5
6
  import { parseRetryAfterErrorSeconds, parseRetryAfterHeadersSeconds } from "./internal/retry-after.mjs";
6
7
  //#region packages/normalization-core/src/balanced-json.ts
7
8
  function isJsonOpeningDelimiter(char, openers) {
@@ -47,6 +48,55 @@ function extractBalancedJsonFragments(raw, opts = {}) {
47
48
  return fragments;
48
49
  }
49
50
  //#endregion
51
+ //#region packages/normalization-core/src/cjk-chars.ts
52
+ const WEIGHTED_CJK_RANGES = [
53
+ [
54
+ [183, 183],
55
+ [12288, 12703],
56
+ [19968, 40869],
57
+ [44032, 55215],
58
+ [65281, 65376]
59
+ ],
60
+ [
61
+ [4352, 4607],
62
+ [11904, 12287],
63
+ [12704, 19967],
64
+ [40870, 40959],
65
+ [40960, 42239],
66
+ [42752, 42759],
67
+ [43360, 43391],
68
+ [55216, 55295],
69
+ [63744, 64255]
70
+ ],
71
+ [
72
+ [711, 711],
73
+ [713, 715],
74
+ [729, 729],
75
+ [746, 747],
76
+ [773, 773],
77
+ [803, 803],
78
+ [65040, 65103],
79
+ [65377, 65500],
80
+ [65504, 65510]
81
+ ],
82
+ [[119648, 119665]],
83
+ [
84
+ [94176, 94207],
85
+ [110576, 110591],
86
+ [110592, 110959],
87
+ [127488, 127743],
88
+ [131072, 195103],
89
+ [196608, 210047]
90
+ ]
91
+ ];
92
+ new RegExp(`[${WEIGHTED_CJK_RANGES.flatMap((ranges) => ranges.map(([start, end]) => `\\u{${start.toString(16)}}-\\u{${end.toString(16)}}`)).join("")}]`, "u");
93
+ (() => {
94
+ const maxCodePoint = Math.max(...WEIGHTED_CJK_RANGES.flatMap((ranges) => ranges.map(([, end]) => end)));
95
+ const categories = new Uint8Array(maxCodePoint + 1);
96
+ for (const [bucket, ranges] of WEIGHTED_CJK_RANGES.entries()) for (const [start, end] of ranges) categories.fill(bucket + 1, start, end + 1);
97
+ return categories;
98
+ })();
99
+ //#endregion
50
100
  //#region packages/normalization-core/src/stable-stringify.ts
51
101
  const preserveString = (value) => value;
52
102
  /** Deterministically stringifies values, optionally normalizing strings before key ordering. */
@@ -84,14 +134,15 @@ function stringifyObjectValue(value, stack, normalizeString) {
84
134
  }
85
135
  const record = value;
86
136
  if (normalizeString === preserveString) {
87
- const fields = [];
88
- for (const key of Object.keys(record).toSorted()) fields.push(`${JSON.stringify(key)}:${stringifyStableValue(record[key], stack, normalizeString)}`);
137
+ const fields = Object.keys(record).sort();
138
+ let fieldIndex = 0;
139
+ for (const key of fields) fields[fieldIndex++] = `${JSON.stringify(key)}:${stringifyStableValue(record[key], stack, normalizeString)}`;
89
140
  return `{${fields.join(",")}}`;
90
141
  }
91
142
  const entries = Object.keys(record).map((key) => ({
92
143
  key,
93
144
  normalizedKey: normalizeString(key)
94
- })).toSorted((left, right) => {
145
+ })).sort((left, right) => {
95
146
  return compareStableStrings(left.normalizedKey, right.normalizedKey) || compareStableStrings(left.key, right.key);
96
147
  });
97
148
  const serializedFields = [];
@@ -121,6 +172,19 @@ const MEDIA_PAYLOAD_SUFFIXES = "base64|blob|buffer|bytes|data|delta|frames?|outp
121
172
  const MEDIA_FIELD_NAME_RE = new RegExp(`^(?:input|output)?(?:audio|image|video)s?(?:${MEDIA_PAYLOAD_SUFFIXES})*$`, "u");
122
173
  const MEDIA_PAYLOAD_SUFFIX_RE = new RegExp(`^(?:${MEDIA_PAYLOAD_SUFFIXES})$`, "u");
123
174
  const MEDIA_WRAPPER_NAME_RE = /^(?:input_|output_)?(?:audio|image|video)s?(?:_|$)/iu;
175
+ const DIAGNOSTIC_FIELD_SEPARATOR_RE = /[^a-z0-9]/g;
176
+ const MEDIA_TYPE_RE = /^(?:input|output)?(?:audio|image|video)/u;
177
+ const MEDIA_MIME_RE = /^(?:audio|image|video)\//iu;
178
+ const MEDIA_ARRAY_INDEX_RE = /^(?:0|[1-9]\d*)$/u;
179
+ const MEDIA_URL_SUFFIX_RE = /(?:uri|url)$/u;
180
+ const MEDIA_MIME_FIELDS = [
181
+ "mimeType",
182
+ "mime_type",
183
+ "mediaType",
184
+ "media_type",
185
+ "contentType",
186
+ "content_type"
187
+ ];
124
188
  const AUTHORIZATION_VALUE_RE = /\b(Bearer|Basic)\s+[A-Za-z0-9+/._~=-]{8,}/giu;
125
189
  const JWT_VALUE_RE = /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/gu;
126
190
  const COOKIE_HEADER_RE = /\b((?:set-)?cookie\s*:\s*)([^\r\n]+)/giu;
@@ -130,14 +194,40 @@ const LOOSE_QUOTED_CREDENTIAL_PAIR_RE = /\b((?!(?:api|endpoint|method|model|prov
130
194
  const LOOSE_CREDENTIAL_PAIR_RE = /\b((?!(?:api|endpoint|method|model|provider|status|type)=)[A-Za-z][A-Za-z0-9_.-]{0,64})=([A-Za-z0-9+/._~%=-]{16,})(?=[;&#'"\s]|$)/giu;
131
195
  const MEDIA_DATA_URL_RE = /data:(?:audio|image|video)\/[a-z0-9.+-]+(?:;[^,;\s]+)*;base64,[ \t]*(?:\r?\n[ \t]*)?[a-z0-9+/_=-]+(?:[ \t]*\r?\n[ \t]*[a-z0-9+/_=-]+)*/giu;
132
196
  const MAX_DIAGNOSTIC_JSON_LENGTH = 16384;
133
- const PLAIN_BRACKET_TAG_RE = /^\[[A-Za-z0-9][A-Za-z0-9 _.-]*\]$/u;
197
+ const BRACKET_PROSE_PATTERN = String.raw`(\[+)([A-Za-z][A-Za-z0-9 _.-]*|\s*\d+\s+(?!(?:true|false|null)(?![\w-]))[A-Za-z][A-Za-z0-9 _.=-]*)(\]+)`;
198
+ const BRACKET_PROSE_RE = new RegExp(`^${BRACKET_PROSE_PATTERN}$`, "u");
199
+ const BRACKET_PROSE_PART_RE = new RegExp(String.raw`(?<!\[)${BRACKET_PROSE_PATTERN}`, "gu");
200
+ const JSON_LITERAL_PROSE_START_RE = /^(?:true|false|null)\b(?!-)/u;
201
+ const PROSE_ASSIGNMENT_RE = /(?<![A-Za-z0-9_.-])([A-Za-z0-9_.-]+)\s*(?:=\s*)+(?=([^=;&\s\]'"},]+))/gu;
202
+ const PRIVATE_KEY_HEADER_RE = /-----BEGIN [A-Z ]*PRIVATE KEY/iu;
134
203
  const JSON_ARRAY_START_RE = /\[\s*(?:[{"\d\]-]|true\b|false\b|null\b)/u;
135
204
  const MALFORMED_JSON_RE = /\{|(?:"[^"]+"|\b(?:b64_json|data|(?:input|output)?(?:audio|image|video)[\w-]*))\s*:/iu;
136
205
  function looksLikeDiagnosticJson(value) {
137
206
  return JSON_ARRAY_START_RE.test(value) || MALFORMED_JSON_RE.test(value);
138
207
  }
208
+ function isPlainBracketProse(value) {
209
+ const match = BRACKET_PROSE_RE.exec(value);
210
+ return match !== null && expectDefined(match[1], "opening brackets").length === expectDefined(match[3], "closing brackets").length && !JSON_LITERAL_PROSE_START_RE.test(expectDefined(match[2], "bracket prose"));
211
+ }
212
+ function hasSensitiveProseContent(value) {
213
+ if (PRIVATE_KEY_HEADER_RE.test(value)) return true;
214
+ let mediaContext = false;
215
+ let contextualPayload = false;
216
+ for (const match of value.matchAll(PROSE_ASSIGNMENT_RE)) {
217
+ const assigned = expectDefined(match[2], "diagnostic assignment value");
218
+ const valueEnd = match.index + match[0].length + assigned.length;
219
+ if (assigned === "<redacted>" && value[valueEnd] !== "=") continue;
220
+ const key = expectDefined(match[1], "diagnostic assignment field");
221
+ const normalized = normalizeDiagnosticFieldName(key);
222
+ if (isCredentialFieldName(normalized) || extractDiagnosticMediaField(key, normalized, void 0, false)) return true;
223
+ mediaContext ||= isDiagnosticMediaPayload({ [key]: { value: assigned } });
224
+ contextualPayload ||= Boolean(extractDiagnosticMediaField(key, normalized, void 0, true));
225
+ if (mediaContext && contextualPayload) return true;
226
+ }
227
+ return false;
228
+ }
139
229
  function normalizeDiagnosticFieldName(value) {
140
- return value.toLowerCase().replaceAll(/[^a-z0-9]/g, "");
230
+ return value.toLowerCase().replaceAll(DIAGNOSTIC_FIELD_SEPARATOR_RE, "");
141
231
  }
142
232
  function isCredentialFieldName(normalized) {
143
233
  if (!normalized || NON_CREDENTIAL_FIELD_NAMES.has(normalized)) return false;
@@ -151,27 +241,19 @@ function diagnosticBytes(value, numericArrays = false) {
151
241
  }
152
242
  function isDiagnosticMediaPayload(descriptors) {
153
243
  const type = descriptors.type?.value;
154
- return typeof type === "string" && /^(?:input|output)?(?:audio|image|video)/u.test(normalizeDiagnosticFieldName(type)) || [
155
- "mimeType",
156
- "mime_type",
157
- "mediaType",
158
- "media_type",
159
- "contentType",
160
- "content_type"
161
- ].some((key) => {
244
+ if (typeof type === "string" && MEDIA_TYPE_RE.test(normalizeDiagnosticFieldName(type))) return true;
245
+ for (const key of MEDIA_MIME_FIELDS) {
162
246
  const mime = descriptors[key]?.value;
163
- return typeof mime === "string" && /^(?:audio|image|video)\//iu.test(mime);
164
- });
247
+ if (typeof mime === "string" && MEDIA_MIME_RE.test(mime)) return true;
248
+ }
249
+ return false;
165
250
  }
166
251
  function extractDiagnosticMediaField(key, normalized, value, parentMedia) {
167
252
  const privateField = normalized === "b64json";
168
253
  const mediaField = MEDIA_FIELD_NAME_RE.test(normalized) || MEDIA_WRAPPER_NAME_RE.test(key);
169
254
  const contextualPayload = parentMedia && MEDIA_PAYLOAD_SUFFIX_RE.test(normalized);
170
- if (!privateField && !mediaField && !contextualPayload) {
171
- const nestedMedia = value !== null && (typeof value === "object" || /^(?:0|[1-9]\d*)$/u.test(key));
172
- return parentMedia && nestedMedia ? { kind: "context" } : void 0;
173
- }
174
- if (/(?:uri|url)$/u.test(normalized)) return { kind: "redacted" };
255
+ if (!privateField && !mediaField && !contextualPayload) return parentMedia && value !== null && (typeof value === "object" || MEDIA_ARRAY_INDEX_RE.test(key)) ? { kind: "context" } : void 0;
256
+ if (MEDIA_URL_SUFFIX_RE.test(normalized)) return { kind: "redacted" };
175
257
  const encoded = diagnosticBytes(value, true) ?? (typeof value === "string" ? value : void 0);
176
258
  if (encoded === void 0) return { kind: privateField || Array.isArray(value) ? "redacted" : "context" };
177
259
  return {
@@ -180,6 +262,13 @@ function extractDiagnosticMediaField(key, normalized, value, parentMedia) {
180
262
  source: encoded
181
263
  };
182
264
  }
265
+ const diagnosticRecords = /* @__PURE__ */ new WeakSet();
266
+ /** Fresh records need no native-object probe while their prototype stays ordinary. */
267
+ function createDiagnosticRecord() {
268
+ const record = {};
269
+ diagnosticRecords.add(record);
270
+ return record;
271
+ }
183
272
  function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new WeakSet(), mediaPayload = false, state = {
184
273
  changed: false,
185
274
  nodesRemaining: 64
@@ -204,24 +293,28 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
204
293
  state.changed = true;
205
294
  return "[Truncated]";
206
295
  }
207
- try {
296
+ if (!diagnosticRecords.has(value) || Object.getPrototypeOf(value) !== Object.prototype) try {
208
297
  Headers.prototype.has.call(value, "retry-after");
209
298
  const seconds = parseRetryAfterHeadersSeconds(value);
210
299
  state.changed = true;
211
300
  return seconds === void 0 ? {} : { "retry-after-ms": seconds * 1e3 };
212
301
  } catch {}
213
- const keys = Reflect.ownKeys(value).slice(0, 65);
214
- const descriptors = Object.fromEntries(keys.slice(0, 64).flatMap((key) => {
215
- const descriptor = typeof key === "string" && Object.getOwnPropertyDescriptor(value, key);
216
- return descriptor ? [[key, descriptor]] : [];
217
- }));
302
+ const keys = Reflect.ownKeys(value);
303
+ const descriptors = Object.create(null);
304
+ for (let index = 0; index < Math.min(keys.length, 64); index += 1) {
305
+ const key = keys[index];
306
+ if (typeof key !== "string") continue;
307
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
308
+ if (descriptor) descriptors[key] = descriptor;
309
+ }
218
310
  state.changed ||= keys.length > 64;
219
311
  seen.add(value);
220
312
  const out = Array.isArray(value) ? [] : {};
221
313
  const rawName = typeof descriptors.name?.value === "string" ? descriptors.name.value : descriptors.key?.value;
222
314
  const redactValueField = keys.length > 64 || typeof rawName === "string" && isCredentialFieldName(normalizeDiagnosticFieldName(rawName));
223
315
  const redactMedia = mediaPayload || keys.length > 64 || isDiagnosticMediaPayload(descriptors);
224
- for (const [key, descriptor] of Object.entries(descriptors)) {
316
+ for (const key in descriptors) {
317
+ const descriptor = expectDefined(descriptors[key], "diagnostic descriptor");
225
318
  if (!("value" in descriptor) || !descriptor.enumerable && (policy.propertyScope === "enumerable" || ![
226
319
  "cause",
227
320
  "errors",
@@ -262,7 +355,12 @@ function projectDiagnosticValue(value, policy = {}, seen = /* @__PURE__ */ new W
262
355
  function redactDiagnosticText(value) {
263
356
  const text = redactCredentialText(value).replace(MEDIA_DATA_URL_RE, "<redacted>");
264
357
  if (!looksLikeDiagnosticJson(text)) return text;
265
- if (text.length > MAX_DIAGNOSTIC_JSON_LENGTH) return "[Oversized diagnostic JSON redacted]";
358
+ const allowProse = !hasSensitiveProseContent(text);
359
+ if (text.length > MAX_DIAGNOSTIC_JSON_LENGTH) {
360
+ const remaining = allowProse && !MALFORMED_JSON_RE.test(text) ? text.replace(BRACKET_PROSE_PART_RE, (part) => isPlainBracketProse(part) ? "" : part) : text;
361
+ if (allowProse && !/[[\]{}]/u.test(remaining) && !MALFORMED_JSON_RE.test(text)) return text;
362
+ return "[Oversized diagnostic JSON redacted]";
363
+ }
266
364
  let cursor = 0;
267
365
  let redacted = "";
268
366
  let unstructured = "";
@@ -270,6 +368,11 @@ function redactDiagnosticText(value) {
270
368
  const plainText = text.slice(cursor, fragment.startIndex);
271
369
  unstructured += plainText;
272
370
  redacted += plainText;
371
+ if (allowProse && isPlainBracketProse(fragment.json)) {
372
+ redacted += fragment.json;
373
+ cursor = fragment.endIndex + 1;
374
+ continue;
375
+ }
273
376
  try {
274
377
  const state = {
275
378
  changed: false,
@@ -278,8 +381,7 @@ function redactDiagnosticText(value) {
278
381
  const projected = projectDiagnosticValue(JSON.parse(fragment.json), {}, /* @__PURE__ */ new WeakSet(), false, state);
279
382
  redacted += state.changed ? stableStringify(projected) : fragment.json;
280
383
  } catch {
281
- if (!PLAIN_BRACKET_TAG_RE.test(fragment.json) || JSON_ARRAY_START_RE.test(fragment.json)) return "[Malformed diagnostic JSON redacted]";
282
- redacted += fragment.json;
384
+ return "[Malformed diagnostic JSON redacted]";
283
385
  }
284
386
  cursor = fragment.endIndex + 1;
285
387
  }
@@ -307,11 +409,14 @@ function readCauseCode(error) {
307
409
  if (code) return code;
308
410
  }
309
411
  }
412
+ function truncateField(text, maxLength) {
413
+ return text.length <= maxLength ? text : `${truncateUtf16Safe(text, maxLength)}... [truncated]`;
414
+ }
310
415
  function stringifyField(value, maxLength) {
311
416
  if (value === void 0 || value === null) return;
312
417
  const text = redactDiagnosticText((typeof value === "string" ? value : stableStringify(value)).trim());
313
418
  if (!text) return;
314
- return text.length <= maxLength ? text : `${truncateUtf16Safe(text, maxLength)}... [truncated]`;
419
+ return maxLength === void 0 ? text : truncateField(text, maxLength);
315
420
  }
316
421
  function buildProjection(snapshot, signal) {
317
422
  const error = asOptionalRecord(snapshot);
@@ -323,8 +428,7 @@ function buildProjection(snapshot, signal) {
323
428
  response?.status,
324
429
  response?.statusCode
325
430
  ].find((value) => typeof value === "number" && Number.isFinite(value));
326
- const bodyValue = error?.errorBody ?? error?.body ?? response?.body ?? response?.data ?? nestedError;
327
- const body = stringifyField(bodyValue, MAX_ERROR_BODY_LENGTH);
431
+ const body = stringifyField(error?.errorBody ?? error?.body ?? response?.body ?? response?.data ?? nestedError);
328
432
  const originalMessage = (typeof snapshot === "string" ? snapshot : void 0) ?? readProviderErrorField(error, "message") ?? readProviderErrorField(nestedError, "message");
329
433
  const genericMessage = originalMessage === `${status} status code (no body)`;
330
434
  let errorMessage = status !== void 0 && body && (!originalMessage || genericMessage) ? `${status}: ${body}` : originalMessage ?? body ?? stringifyField(snapshot, MAX_ERROR_BODY_LENGTH) ?? "Unknown provider error";
@@ -338,7 +442,7 @@ function buildProjection(snapshot, signal) {
338
442
  errorMessage: stringifyField(errorMessage, 4096) ?? "Unknown provider error",
339
443
  ...errorCode ? { errorCode: truncateUtf16Safe(errorCode, 256) } : {},
340
444
  ...errorType ? { errorType: truncateUtf16Safe(errorType, 256) } : {},
341
- ...body ? { errorBody: stringifyField(bodyValue, 500) } : {}
445
+ ...body ? { errorBody: truncateField(body, 500) } : {}
342
446
  };
343
447
  }
344
448
  /** Projects one hostile provider throw into final, bounded assistant terminal fields. */
@@ -364,4 +468,4 @@ function projectProviderError(error, signal) {
364
468
  }
365
469
  }
366
470
  //#endregion
367
- export { stableStringify as i, projectProviderError as n, projectDiagnosticValue as r, configureProviderErrorRedactor as t };
471
+ export { redactDiagnosticText as a, projectDiagnosticValue as i, projectProviderError as n, stableStringify as o, createDiagnosticRecord as r, configureProviderErrorRedactor as t };
@@ -1,9 +1,10 @@
1
- import { J as StreamOptions } from "./types-Dy1q0CSu.mjs";
1
+ import { Y as StreamOptions } from "./types-4_uVs5WH.mjs";
2
2
  import { t as OpenAICompletionsToolChoice } from "./openai-tool-projection-793cE3QX.mjs";
3
- import "./types-BADKjDBI.mjs";
3
+ import "./types-DkJfb4W3.mjs";
4
4
  import Anthropic from "@anthropic-ai/sdk";
5
5
  //#region packages/ai/src/providers/openai-reasoning-effort.d.ts
6
- type OpenAIReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
6
+ declare const ENABLED_REASONING_EFFORTS: readonly ["minimal", "low", "medium", "high", "xhigh", "max"];
7
+ type OpenAIReasoningEffort = "none" | (typeof ENABLED_REASONING_EFFORTS)[number];
7
8
  type OpenAIApiReasoningEffort = OpenAIReasoningEffort | (string & {});
8
9
  type OpenAIReasoningModel = {
9
10
  provider?: unknown;
@@ -32,6 +33,8 @@ declare function resolveOpenAIModelReasoningEfforts(model: OpenAIReasoningModel)
32
33
  declare function supportsOpenAITemperature(model: OpenAIReasoningModel): boolean;
33
34
  /** Return whether a model accepts a requested reasoning effort. */
34
35
  declare function supportsOpenAIReasoningEffort(model: OpenAIReasoningModel, effort: string): boolean;
36
+ /** Read provider mappings without folding provider-native labels. */
37
+ declare function resolveOpenAIReasoningEffortMapping(effort: string, mapping: Record<string, string> | undefined): string | undefined;
35
38
  /** Resolve a requested reasoning effort to the closest value supported by the model. */
36
39
  declare function resolveOpenAIReasoningEffortForModel(params: {
37
40
  model: OpenAIReasoningModel;
@@ -139,8 +142,8 @@ type BaseOpenAIStreamOptions = StreamOptions & {
139
142
  /** Superset retained under the provider's published compatibility type name. */
140
143
  type OpenAICompletionsOptions = BaseOpenAIStreamOptions & {
141
144
  toolChoice?: OpenAICompletionsToolChoice;
142
- reasoning?: OpenAIReasoningEffort;
143
- reasoningEffort?: OpenAIReasoningEffort;
145
+ reasoning?: OpenAIReasoningEffort | "off";
146
+ reasoningEffort?: OpenAIReasoningEffort | "off";
144
147
  };
145
148
  //#endregion
146
- export { resolveOpenAIModelReasoningEfforts as _, BaseOpenAIStreamOptions as a, supportsOpenAIReasoningEffort as b, OpenAIResponsesCompactionRejection as c, OpenAIApiReasoningEffort as d, OpenAIReasoningEffort as f, normalizeOpenAIReasoningEffort as g, isOpenAIGpt56Model as h, AnthropicThinkingDisplay as i, codeModeToolSurfaceObserver as l, isOpenAIGpt55Model as m, AnthropicEffort as n, CodeModeToolSurfaceObservation as o, isOpenAIGpt54MiniModel as p, AnthropicOptions as r, OpenAICompletionsOptions as s, AnthropicContextManagementOptions as t, reasoningTagTextPolicy as u, resolveOpenAIReasoningEffortForModel as v, supportsOpenAITemperature as x, resolveOpenAISupportedReasoningEfforts as y };
149
+ export { supportsOpenAITemperature as S, resolveOpenAIModelReasoningEfforts as _, BaseOpenAIStreamOptions as a, resolveOpenAISupportedReasoningEfforts as b, OpenAIResponsesCompactionRejection as c, OpenAIApiReasoningEffort as d, OpenAIReasoningEffort as f, normalizeOpenAIReasoningEffort as g, isOpenAIGpt56Model as h, AnthropicThinkingDisplay as i, codeModeToolSurfaceObserver as l, isOpenAIGpt55Model as m, AnthropicEffort as n, CodeModeToolSurfaceObservation as o, isOpenAIGpt54MiniModel as p, AnthropicOptions as r, OpenAICompletionsOptions as s, AnthropicContextManagementOptions as t, reasoningTagTextPolicy as u, resolveOpenAIReasoningEffortForModel as v, supportsOpenAIReasoningEffort as x, resolveOpenAIReasoningEffortMapping as y };
@@ -1,4 +1,4 @@
1
- import { t as shortHash } from "./hash-CHgqbJmD.mjs";
1
+ import { k as shortHash } from "./transport-stream-shared-D-6FQSHm.mjs";
2
2
  //#region packages/ai/src/transports/provider-replay-context.ts
3
3
  function hashReplayContextValue(value) {
4
4
  const normalized = value?.trim();
@@ -1,4 +1,4 @@
1
- import { i as transformMessages } from "./host-CWuF-sS3.mjs";
1
+ import { i as transformMessages } from "./host-B4MeUNBc.mjs";
2
2
  //#region packages/ai/src/provider-transcript-transform.ts
3
3
  const IMAGE_OMISSION = "(image omitted: model does not support images)";
4
4
  const VIDEO_OMISSION = "(video omitted: provider does not support video input)";
@@ -0,0 +1,42 @@
1
+ import { n as getAiTransportHost } from "./host-B4MeUNBc.mjs";
2
+ import { n as resolveOpencodeSessionHeaders, t as hasOpencodeSessionHeader } from "./session-affinity-Bcunsn4I.mjs";
3
+ import { randomUUID } from "node:crypto";
4
+ //#region packages/ai/src/transports/provider-transport-turn-state.ts
5
+ function resolveProviderTransportTurnState(model, params) {
6
+ const normalizedProvider = model.provider.trim().toLowerCase();
7
+ const allowRuntimePluginLoad = normalizedProvider === "openai" || normalizedProvider === "azure-openai" || normalizedProvider === "azure-openai-responses";
8
+ return getAiTransportHost().plugin.resolveTransportTurnState({
9
+ provider: model.provider,
10
+ modelId: model.id,
11
+ allowRuntimePluginLoad,
12
+ context: {
13
+ provider: model.provider,
14
+ modelId: model.id,
15
+ model,
16
+ sessionId: params.sessionId,
17
+ turnId: params.turnId,
18
+ attempt: params.attempt,
19
+ transport: params.transport
20
+ }
21
+ });
22
+ }
23
+ function filterProviderTurnHeadersForExplicitOpencodeSession(model, options, turnHeaders) {
24
+ if (!turnHeaders || !hasOpencodeSessionHeader(model, options)) return turnHeaders;
25
+ const filtered = Object.fromEntries(Object.entries(turnHeaders).filter(([name]) => name.toLowerCase() !== "x-opencode-session"));
26
+ return Object.keys(filtered).length > 0 ? filtered : void 0;
27
+ }
28
+ function resolveProviderSimpleCompletionHeaders(model, options) {
29
+ const optionHeaders = resolveOpencodeSessionHeaders(model, options);
30
+ const turnState = resolveProviderTransportTurnState(model, {
31
+ sessionId: options?.sessionId,
32
+ turnId: randomUUID(),
33
+ attempt: 1,
34
+ transport: "stream"
35
+ });
36
+ return {
37
+ ...filterProviderTurnHeadersForExplicitOpencodeSession(model, { headers: optionHeaders }, turnState?.headers),
38
+ ...optionHeaders
39
+ };
40
+ }
41
+ //#endregion
42
+ export { resolveProviderSimpleCompletionHeaders as n, resolveProviderTransportTurnState as r, filterProviderTurnHeadersForExplicitOpencodeSession as t };
@@ -1,6 +1,6 @@
1
- import { t as index_d_exports } from "./index-CQ6LTHw8.mjs";
2
- import { D as Model, J as StreamOptions, Y as TextContent, a as AssistantMessage, d as Context, f as ImageContent, n as Api, ot as UserMessage, rt as ToolResultMessage, s as AssistantMessageEventStreamContract } from "./types-Dy1q0CSu.mjs";
3
- import "./types-BADKjDBI.mjs";
1
+ import { t as index_d_exports } from "./index-DaF2QbwS.mjs";
2
+ import { O as Model, X as TextContent, Y as StreamOptions, a as AssistantMessage, d as Context, f as ImageContent, it as ToolResultMessage, n as Api, s as AssistantMessageEventStreamContract, st as UserMessage } from "./types-4_uVs5WH.mjs";
3
+ import "./types-DkJfb4W3.mjs";
4
4
  //#region packages/ai/src/provider-types.d.ts
5
5
  declare const PROVIDER_CONTEXT_HANDOFF: unique symbol;
6
6
  type VideoContent = Omit<ImageContent, "type"> & {
@@ -1,7 +1,6 @@
1
- import { _ as supportsClaude1MContext, a as CLAUDE_FABLE_5_THINKING_PROFILE, b as supportsClaudeNativeMaxEffort, c as bindsClaudeThinkingPrefix, d as resolveClaudeFable5ModelIdentity, f as resolveClaudeModelIdentity, g as resolveClaudeSonnet5ModelIdentity, h as resolveClaudeOpus5ModelIdentity, i as normalizeResolvedPricing, l as requiresClaudeDefaultSampling, m as resolveClaudeNativeThinkingLevelMap, n as calculateUsageCost, o as CLAUDE_OPUS_5_THINKING_PROFILE, p as resolveClaudeMythos5ModelIdentity, r as normalizeModelCostConfig, s as CLAUDE_SONNET_5_THINKING_PROFILE, u as requiresClaudeMandatoryAdaptiveThinking, v as supportsClaudeAdaptiveThinking, x as supportsClaudeNativeXhighEffort, y as supportsClaudeFastMode } from "./index-CQ6LTHw8.mjs";
2
- import { $ as ThinkingLevel, A as ModelThinkingLevel, B as ProviderResponse, C as KnownImagesApi, F as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, G as StopReason, H as RawModelCostConfig, I as PricingTier, J as StreamOptions, K as StreamFn, L as Provider, M as OpenAIResponsesCompat, N as OpenRouterRouting, O as ModelCostConfig, P as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, Q as ThinkingContent, R as ProviderImagesOptions, S as KnownApi, T as MaybePromise, U as RawPricingTier, W as SimpleStreamOptions, X as TextSignatureV1, Y as TextContent, Z as ThinkingBudgets, _ as ImagesModel, a as AssistantMessage, at as Usage, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as VercelGatewayRouting, et as ThinkingLevelMap, f as ImageContent, g as ImagesInputContent, h as ImagesFunction, i as AssistantImages, it as Transport, j as OpenAICompletionsCompat, k as ModelCostRates, l as CacheRetention, m as ImagesContext, n as Api, nt as ToolCall, o as AssistantMessageEvent, ot as UserMessage, p as ImagesApi, r as AssistantDeliveryTtsFacts, rt as ToolResultMessage, s as AssistantMessageEventStreamContract, st as ValidateToolArgumentsFn, t as AnthropicMessagesCompat, tt as Tool, u as CompleteSimpleFn, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderReplayState } from "./types-Dy1q0CSu.mjs";
3
- import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, s as isProviderRefusalAssistantError, t as AssistantMessageDiagnostic } from "./diagnostics-DnPnOui6.mjs";
4
- import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-C1Z2piyk.mjs";
5
- import { n as validateToolCall, t as validateToolArguments } from "./validation-CaFUZN9B.mjs";
6
- import { a as ProviderContextHandoff, c as ProviderStreamFunction, d as VideoContent, f as resolveProviderContext, i as ProviderContext, l as ProviderStreamOptions, n as ModelInputContent, o as ProviderMessage, r as PROVIDER_CONTEXT_HANDOFF, s as ProviderModel, t as MediaContent, u as ProviderUserMessage } from "./provider-types-CAV0Og3m.mjs";
7
- export { type AnthropicMessagesCompat, type Api, type AssistantDeliveryTtsFacts, type AssistantImages, type AssistantMessage, type AssistantMessageDiagnostic, type AssistantMessageEvent, type AssistantMessageEventStream, type AssistantMessageEventStreamContract, type AssistantMessageEventStreamLike, type CLAUDE_FABLE_5_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DiagnosticErrorInfo, type EventStream, type ImageContent, type ImagesApi, type ImagesContext, type ImagesFunction, type ImagesInputContent, type ImagesModel, type ImagesOptions, type ImagesOutputContent, type ImagesProvider, type ImagesStopReason, type KnownApi, type KnownImagesApi, type KnownImagesProvider, type MaybePromise, MediaContent, type ProviderMessage as Message, ProviderMessage, type ProviderModel as Model, ProviderModel, type ModelCostConfig, type ModelCostRates, ModelInputContent, type ModelThinkingLevel, type OpenAICompletionsCompat, type OpenAIResponsesCompat, type OpenRouterRouting, PROVIDER_CONTEXT_HANDOFF, type PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, type PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, type PricingTier, type Provider, ProviderContextHandoff, type ProviderImagesOptions, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RawModelCostConfig, type RawPricingTier, type SimpleStreamOptions, type StopReason, type StreamFn, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingBudgets, type ThinkingContent, type ThinkingLevel, type ThinkingLevelMap, type Tool, type ToolCall, type ToolResultMessage, type Transport, type Usage, type UserMessage, type ValidateToolArgumentsFn, type VercelGatewayRouting, VideoContent, type appendAssistantMessageDiagnostic, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type extractDiagnosticError, type formatThrownValue, type isProviderRefusalAssistantError, type normalizeModelCostConfig, type normalizeResolvedPricing, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type validateToolArguments, type validateToolCall };
1
+ import { _ as supportsClaude1MContext, a as CLAUDE_FABLE_5_THINKING_PROFILE, b as supportsClaudeNativeMaxEffort, c as bindsClaudeThinkingPrefix, d as resolveClaudeFable5ModelIdentity, f as resolveClaudeModelIdentity, g as resolveClaudeSonnet5ModelIdentity, h as resolveClaudeOpus5ModelIdentity, i as normalizeResolvedPricing, l as requiresClaudeDefaultSampling, m as resolveClaudeNativeThinkingLevelMap, n as calculateUsageCost, o as CLAUDE_OPUS_5_THINKING_PROFILE, p as resolveClaudeMythos5ModelIdentity, r as normalizeModelCostConfig, s as CLAUDE_SONNET_5_THINKING_PROFILE, u as requiresClaudeMandatoryAdaptiveThinking, v as supportsClaudeAdaptiveThinking, x as supportsClaudeNativeXhighEffort, y as supportsClaudeFastMode } from "./index-DaF2QbwS.mjs";
2
+ import { $ as ThinkingContent, A as ModelCostRates, B as ProviderReplayState, C as KnownImagesApi, E as MaybePromise, F as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, G as SimpleStreamOptions, I as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, K as StopReason, L as PricingTier, M as OpenAICompletionsCompat, N as OpenAIResponsesCompat, P as OpenRouterRouting, Q as ThinkingBudgets, R as Provider, S as KnownApi, T as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, U as RawModelCostConfig, V as ProviderResponse, W as RawPricingTier, X as TextContent, Y as StreamOptions, Z as TextSignatureV1, _ as ImagesModel, a as AssistantMessage, at as Transport, b as ImagesProvider, c as AssistantMessageEventStreamLike, ct as ValidateToolArgumentsFn, dt as DiagnosticErrorInfo, et as ThinkingLevel, f as ImageContent, ft as appendAssistantMessageDiagnostic, g as ImagesInputContent, gt as isProviderRefusalAssistantError, h as ImagesFunction, ht as formatThrownValue, i as AssistantImages, it as ToolResultMessage, j as ModelThinkingLevel, k as ModelCostConfig, l as CacheRetention, lt as VercelGatewayRouting, m as ImagesContext, mt as extractDiagnosticError, n as Api, nt as Tool, o as AssistantMessageEvent, ot as Usage, p as ImagesApi, pt as createAssistantMessageDiagnostic, q as StreamFn, r as AssistantDeliveryTtsFacts, rt as ToolCall, s as AssistantMessageEventStreamContract, st as UserMessage, t as AnthropicMessagesCompat, tt as ThinkingLevelMap, u as CompleteSimpleFn, ut as AssistantMessageDiagnostic, v as ImagesOptions, w as KnownImagesProvider, x as ImagesStopReason, y as ImagesOutputContent, z as ProviderImagesOptions } from "./types-4_uVs5WH.mjs";
3
+ import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-CCoa-qSI.mjs";
4
+ import { n as validateToolCall, t as validateToolArguments } from "./validation-Ctzu2DhF.mjs";
5
+ import { a as ProviderContextHandoff, c as ProviderStreamFunction, d as VideoContent, f as resolveProviderContext, i as ProviderContext, l as ProviderStreamOptions, n as ModelInputContent, o as ProviderMessage, r as PROVIDER_CONTEXT_HANDOFF, s as ProviderModel, t as MediaContent, u as ProviderUserMessage } from "./provider-types-CAKRC7N5.mjs";
6
+ export { type AnthropicMessagesCompat, type Api, type AssistantDeliveryTtsFacts, type AssistantImages, type AssistantMessage, type AssistantMessageDiagnostic, type AssistantMessageEvent, type AssistantMessageEventStream, type AssistantMessageEventStreamContract, type AssistantMessageEventStreamLike, type CLAUDE_FABLE_5_THINKING_PROFILE, type CLAUDE_OPUS_5_THINKING_PROFILE, type CLAUDE_SONNET_5_THINKING_PROFILE, type CacheRetention, type CompleteSimpleFn, type ProviderContext as Context, ProviderContext, type DiagnosticErrorInfo, type EventStream, type ImageContent, type ImagesApi, type ImagesContext, type ImagesFunction, type ImagesInputContent, type ImagesModel, type ImagesOptions, type ImagesOutputContent, type ImagesProvider, type ImagesStopReason, type KnownApi, type KnownImagesApi, type KnownImagesProvider, type MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, type MaybePromise, MediaContent, type ProviderMessage as Message, ProviderMessage, type ProviderModel as Model, ProviderModel, type ModelCostConfig, type ModelCostRates, ModelInputContent, type ModelThinkingLevel, type OpenAICompletionsCompat, type OpenAIResponsesCompat, type OpenRouterRouting, PROVIDER_CONTEXT_HANDOFF, type PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, type PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, type PricingTier, type Provider, ProviderContextHandoff, type ProviderImagesOptions, type ProviderReplayState, type ProviderResponse, ProviderStreamFunction, type ProviderStreamFunction as StreamFunction, ProviderStreamOptions, ProviderUserMessage, type RawModelCostConfig, type RawPricingTier, type SimpleStreamOptions, type StopReason, type StreamFn, type StreamOptions, type TextContent, type TextSignatureV1, type ThinkingBudgets, type ThinkingContent, type ThinkingLevel, type ThinkingLevelMap, type Tool, type ToolCall, type ToolResultMessage, type Transport, type Usage, type UserMessage, type ValidateToolArgumentsFn, type VercelGatewayRouting, VideoContent, type appendAssistantMessageDiagnostic, type bindsClaudeThinkingPrefix, type calculateUsageCost, type createAssistantMessageDiagnostic, type createAssistantMessageEventStream, type extractDiagnosticError, type formatThrownValue, type isProviderRefusalAssistantError, type normalizeModelCostConfig, type normalizeResolvedPricing, type requiresClaudeDefaultSampling, type requiresClaudeMandatoryAdaptiveThinking, type resolveClaudeFable5ModelIdentity, type resolveClaudeModelIdentity, type resolveClaudeMythos5ModelIdentity, type resolveClaudeNativeThinkingLevelMap, type resolveClaudeOpus5ModelIdentity, type resolveClaudeSonnet5ModelIdentity, resolveProviderContext, type supportsClaude1MContext, type supportsClaudeAdaptiveThinking, type supportsClaudeFastMode, type supportsClaudeNativeMaxEffort, type supportsClaudeNativeXhighEffort, type validateToolArguments, type validateToolCall };
@@ -1,5 +1,5 @@
1
- import { n as ApiRegistry } from "./api-registry-CB1-1oQ2.mjs";
2
- import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-rrutvqxq.mjs";
1
+ import { n as ApiRegistry } from "./api-registry-Ba2Cv-ut.mjs";
2
+ import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-CJ_xEevu.mjs";
3
3
  //#region packages/ai/src/providers/register-builtins.d.ts
4
4
  /** Source id used for built-in API provider registrations. */
5
5
  export declare const BUILT_IN_API_PROVIDER_SOURCE_ID = "core:built-in";
@@ -1,6 +1,6 @@
1
1
  import { t as AssistantMessageEventStream } from "./event-stream-D8PARQfL.mjs";
2
- import { n as projectProviderError } from "./provider-error-C6TbKiey.mjs";
3
- import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-BI0rkM-5.mjs";
2
+ import { n as projectProviderError } from "./provider-error-DDqw9Qda.mjs";
3
+ import { n as clampOpenAIPromptCacheKey, t as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH } from "./openai-prompt-cache-1wfaIszn.mjs";
4
4
  //#region packages/ai/src/providers/register-builtins.ts
5
5
  /** Source id used for built-in API provider registrations. */
6
6
  const BUILT_IN_API_PROVIDER_SOURCE_ID = "core:built-in";
@@ -62,35 +62,35 @@ function createLazyRegistration(api, importModule, select) {
62
62
  };
63
63
  }
64
64
  const registerBuiltIns = [
65
- createLazyRegistration("anthropic-messages", () => import("./anthropic-CZy5U0NY.mjs").then((n) => n.t), (module) => ({
65
+ createLazyRegistration("anthropic-messages", () => import("./anthropic-COtDvgtt.mjs").then((n) => n.t), (module) => ({
66
66
  stream: module.streamAnthropic,
67
67
  streamSimple: module.streamSimpleAnthropic
68
68
  })),
69
- createLazyRegistration("openai-completions", () => import("./openai-completions-KuoZyx0d.mjs").then((n) => n.t), (module) => ({
69
+ createLazyRegistration("openai-completions", () => import("./openai-completions-DJ1Vm-CD.mjs").then((n) => n.t), (module) => ({
70
70
  stream: module.streamOpenAICompletions,
71
71
  streamSimple: module.streamSimpleOpenAICompletions
72
72
  })),
73
- createLazyRegistration("mistral-conversations", () => import("./mistral--m-Jm6VZ.mjs"), (module) => ({
73
+ createLazyRegistration("mistral-conversations", () => import("./mistral-moA-mbwl.mjs"), (module) => ({
74
74
  stream: module.streamMistral,
75
75
  streamSimple: module.streamSimpleMistral
76
76
  })),
77
- createLazyRegistration("openai-responses", () => import("./openai-responses-D99dOzKI.mjs").then((n) => n.t), (module) => ({
77
+ createLazyRegistration("openai-responses", () => import("./openai-responses-BejZzQCP.mjs").then((n) => n.t), (module) => ({
78
78
  stream: module.streamOpenAIResponses,
79
79
  streamSimple: module.streamSimpleOpenAIResponses
80
80
  })),
81
- createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-Crpa40QR.mjs"), (module) => ({
81
+ createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-YrgnD583.mjs"), (module) => ({
82
82
  stream: module.streamAzureOpenAIResponses,
83
83
  streamSimple: module.streamSimpleAzureOpenAIResponses
84
84
  })),
85
- createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-nDZccFW-.mjs"), (module) => ({
85
+ createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-DWID3EFO.mjs"), (module) => ({
86
86
  stream: module.streamOpenAICodexResponses,
87
87
  streamSimple: module.streamSimpleOpenAICodexResponses
88
88
  })),
89
- createLazyRegistration("google-generative-ai", () => import("./google-BDPriaVe.mjs"), (module) => ({
89
+ createLazyRegistration("google-generative-ai", () => import("./google-BuhpRO9r.mjs"), (module) => ({
90
90
  stream: module.streamGoogle,
91
91
  streamSimple: module.streamSimpleGoogle
92
92
  })),
93
- createLazyRegistration("google-vertex", () => import("./google-vertex-DMz8XQCn.mjs"), (module) => ({
93
+ createLazyRegistration("google-vertex", () => import("./google-vertex-C7EplRvt.mjs"), (module) => ({
94
94
  stream: module.streamGoogleVertex,
95
95
  streamSimple: module.streamSimpleGoogleVertex
96
96
  }))
@@ -1,12 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
- import "./base64-D-su8YVo.mjs";
3
- //#region packages/normalization-core/src/expect.ts
4
- /** Returns the value or throws with the named context; use for genuine invariants only. */
5
- function expectDefined(value, context) {
6
- if (value === null || value === void 0) throw new Error("expected " + context + " to be defined");
7
- return value;
8
- }
9
- //#endregion
2
+ import "./provider-error-DDqw9Qda.mjs";
3
+ import { t as expectDefined } from "./expect-lbe3Hgrh.mjs";
10
4
  //#region node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
11
5
  /**
12
6
  * @typedef {import('mdast').Nodes} Nodes
@@ -11739,6 +11733,7 @@ function parseMarkdownOwnership(text, options) {
11739
11733
  if (!text) return {
11740
11734
  regions: [],
11741
11735
  codeSpans: [],
11736
+ textSpans: [],
11742
11737
  retainStart: 0
11743
11738
  };
11744
11739
  const sources = /* @__PURE__ */ new Map();
@@ -11748,11 +11743,13 @@ function parseMarkdownOwnership(text, options) {
11748
11743
  mdastExtensions: [...tables ? [gfmTableFromMarkdown()] : [], ...options?.includeSource ? [captureInlineSources(text, sources)] : []]
11749
11744
  });
11750
11745
  const regions = [];
11746
+ const textSpans = [];
11751
11747
  const pending = [tree];
11752
11748
  while (pending.length > 0) {
11753
11749
  const node = expectDefined(pending.pop(), "Markdown ownership node");
11754
11750
  const start = node.position?.start?.offset;
11755
11751
  const end = node.position?.end?.offset;
11752
+ if (options?.includeText && node.type === "text" && start !== void 0 && end !== void 0) textSpans.push([start, end]);
11756
11753
  if ((node.type === "code" || node.type === "inlineCode") && start !== void 0 && end !== void 0) {
11757
11754
  const source = sources.get(start);
11758
11755
  if (source) while (source.offsets.length <= end - start) source.offsets.push(source.value.length);
@@ -11769,6 +11766,7 @@ function parseMarkdownOwnership(text, options) {
11769
11766
  return {
11770
11767
  regions,
11771
11768
  codeSpans: regions.map(({ start, end }) => [start, end]),
11769
+ textSpans,
11772
11770
  retainStart: tree.children?.at(-1)?.position?.start?.offset ?? text.length
11773
11771
  };
11774
11772
  }
@@ -11974,7 +11972,7 @@ function createReasoningTagTextPartitioner() {
11974
11972
  else target.push({ ...addition });
11975
11973
  }
11976
11974
  };
11977
- const emitSafePrefix = (limit, output) => {
11975
+ const emitSafePrefix = (limit, output, appended) => {
11978
11976
  if (strictMode) {
11979
11977
  holdStart ??= emitted;
11980
11978
  return;
@@ -12005,10 +12003,14 @@ function createReasoningTagTextPartitioner() {
12005
12003
  return;
12006
12004
  }
12007
12005
  if (holdStart !== void 0 || emitted >= limit) return;
12006
+ const appendedStart = source.length - (appended?.length ?? 0);
12007
+ const useAppended = appended !== void 0 && emitted >= appendedStart;
12008
+ const scanSource = useAppended ? appended : source;
12009
+ const scanOffset = useAppended ? appendedStart : 0;
12008
12010
  while (emitted < limit && holdStart === void 0) {
12009
12011
  let special = -1;
12010
12012
  for (let index = emitted; index < limit; index += 1) {
12011
- const char = source.charAt(index);
12013
+ const char = scanSource.charAt(index - scanOffset);
12012
12014
  if (char === "<" || char === "`") {
12013
12015
  special = index;
12014
12016
  break;
@@ -12020,7 +12022,7 @@ function createReasoningTagTextPartitioner() {
12020
12022
  holdStart = emitted;
12021
12023
  return;
12022
12024
  }
12023
- const text = source.slice(emitted, end);
12025
+ const text = scanSource.slice(emitted - scanOffset, end - scanOffset);
12024
12026
  if (text) {
12025
12027
  merge(output, [{
12026
12028
  kind: "text",
@@ -12193,14 +12195,13 @@ function createReasoningTagTextPartitioner() {
12193
12195
  const output = [];
12194
12196
  if (final) processBlock(source.length, true, output);
12195
12197
  else {
12196
- emitSafePrefix(source.length, output);
12198
+ emitSafePrefix(source.length, output, appended);
12197
12199
  if (!strictMode && holdStart !== void 0 && holdStart < source.length) {
12198
12200
  const ownershipStart = heldBacktickStart ?? holdStart;
12199
12201
  const heldLineStart = Math.max(source.lastIndexOf("\n", Math.max(0, ownershipStart - 1)), source.lastIndexOf("\r", Math.max(0, ownershipStart - 1))) + 1;
12200
12202
  const heldLineEnd = findNextLineEnding(source, ownershipStart);
12201
12203
  const tableLookaheadPending = source.slice(heldLineStart, heldLineEnd === -1 ? source.length : heldLineEnd).includes("|") && (heldLineEnd === -1 || findNextLineEnding(source, heldLineEnd + (source.charAt(heldLineEnd) === "\r" && source.charAt(heldLineEnd + 1) === "\n" ? 2 : 1)) === -1);
12202
12204
  const completedBlankBlock = endedBlankBlock;
12203
- const retainedContainerContext = MARKDOWN_CONTAINER_LINE_RE.test(source.slice(nonFinalRetainStart));
12204
12205
  const heldBacktick = heldBacktickStart !== void 0;
12205
12206
  let openingRunEnd = ownershipStart;
12206
12207
  while (source.charAt(openingRunEnd) === "`") openingRunEnd += 1;
@@ -12209,7 +12210,7 @@ function createReasoningTagTextPartitioner() {
12209
12210
  const shouldTryParser = pendingTagProbe ? pendingTagProbe.resolved : reduction.depth > 0 ? appended.includes("<") : !heldBacktick || hasLaterBacktick && terminatedBacktickTail || completedBlankBlock;
12210
12211
  const mayResolveHeldReasoning = reduction.depth > 0 && !nonFinalCloseReparseUsed && (appended.includes("<") || appended.includes(">")) && scanReasoningTags(source.slice(holdStart), false).tags.some((tag) => tag.isClose);
12211
12212
  const reusableCodeSpans = nonFinalCodeSpansEnd === source.length ? nonFinalCodeSpans : void 0;
12212
- const mayCloseTopLevelBlock = completedBlankBlock && (!retainedContainerContext || appendedStartsTopLevelBlock) && !nonFinalOpenEndedCode;
12213
+ const mayCloseTopLevelBlock = completedBlankBlock && !nonFinalOpenEndedCode && (appendedStartsTopLevelBlock || !MARKDOWN_CONTAINER_LINE_RE.test(source.slice(nonFinalRetainStart)));
12213
12214
  if ((shouldTryParser || mayResolveHeldReasoning) && !tableLookaheadPending && (reusableCodeSpans !== void 0 || nonFinalFullParses < 1 || mayCloseTopLevelBlock || mayResolveHeldReasoning)) {
12214
12215
  if (!reusableCodeSpans) nonFinalFullParses += 1;
12215
12216
  const ownership = reusableCodeSpans ? void 0 : parseMarkdownOwnership(source);
@@ -10,11 +10,14 @@ function isOpencodeEndpoint(baseUrl) {
10
10
  /** Required conversation identity is independent of optional prompt caching. */
11
11
  function resolveOpencodeSessionHeaders(model, options) {
12
12
  if (!options?.sessionId || !isOpencodeEndpoint(model.baseUrl)) return options?.headers;
13
- if ([model.headers, options.headers].some((headers) => Object.keys(headers ?? {}).some((name) => name.toLowerCase() === "x-opencode-session"))) return options.headers;
13
+ if (hasOpencodeSessionHeader(model, options)) return options.headers;
14
14
  return {
15
15
  ...options.headers,
16
16
  "x-opencode-session": options.sessionId
17
17
  };
18
18
  }
19
+ function hasOpencodeSessionHeader(model, options) {
20
+ return [model.headers, options?.headers].some((headers) => Object.keys(headers ?? {}).some((name) => name.toLowerCase() === "x-opencode-session"));
21
+ }
19
22
  //#endregion
20
- export { resolveOpencodeSessionHeaders as t };
23
+ export { resolveOpencodeSessionHeaders as n, hasOpencodeSessionHeader as t };