@mastra/ai-sdk 1.4.2-alpha.0 → 1.4.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.
package/dist/index.cjs CHANGED
@@ -30,7 +30,7 @@ function _interopNamespace(e) {
30
30
 
31
31
  var z4__namespace = /*#__PURE__*/_interopNamespace(z4);
32
32
 
33
- // ../../packages/_vendored/ai_v5/dist/chunk-UDIOFQR2.js
33
+ // ../../packages/_vendored/ai_v5/dist/chunk-TJMMQ5MY.js
34
34
  var marker = "vercel.ai.error";
35
35
  var symbol = Symbol.for(marker);
36
36
  var _a;
@@ -209,9 +209,6 @@ var ParseError = class extends Error {
209
209
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
210
210
  }
211
211
  };
212
- var LF = 10;
213
- var CR = 13;
214
- var SPACE = 32;
215
212
  function noop(_arg) {
216
213
  }
217
214
  function createParser(callbacks) {
@@ -219,109 +216,39 @@ function createParser(callbacks) {
219
216
  throw new TypeError(
220
217
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
221
218
  );
222
- const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
223
- let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
224
- function feed(chunk) {
225
- if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
226
- const trailing2 = processLines(chunk);
227
- trailing2 !== "" && pendingFragments.push(trailing2);
228
- return;
229
- }
230
- if (chunk.indexOf(`
231
- `) === -1 && chunk.indexOf("\r") === -1) {
232
- pendingFragments.push(chunk);
233
- return;
234
- }
235
- pendingFragments.push(chunk);
236
- const input = pendingFragments.join("");
237
- pendingFragments.length = 0;
238
- const trailing = processLines(input);
239
- trailing !== "" && pendingFragments.push(trailing);
240
- }
241
- function processLines(chunk) {
242
- let searchIndex = 0;
243
- if (chunk.indexOf("\r") === -1) {
244
- let lfIndex = chunk.indexOf(`
245
- `, searchIndex);
246
- for (; lfIndex !== -1; ) {
247
- if (searchIndex === lfIndex) {
248
- dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
249
- `, searchIndex);
250
- continue;
251
- }
252
- const firstCharCode = chunk.charCodeAt(searchIndex);
253
- if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
254
- const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
255
- if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
256
- onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
257
- `, searchIndex);
258
- continue;
259
- }
260
- data = dataLines === 0 ? value : `${data}
261
- ${value}`, dataLines++;
262
- } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
263
- chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
264
- lfIndex
265
- ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
266
- searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
267
- `, searchIndex);
268
- }
269
- return chunk.slice(searchIndex);
270
- }
271
- for (; searchIndex < chunk.length; ) {
272
- const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
273
- `, searchIndex);
274
- let lineEnd = -1;
275
- if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
276
- break;
277
- parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
278
- }
279
- return chunk.slice(searchIndex);
280
- }
281
- function parseLine(chunk, start, end) {
282
- if (start === end) {
219
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
220
+ let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
221
+ function feed(newChunk) {
222
+ const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
223
+ for (const line of complete)
224
+ parseLine(line);
225
+ incompleteLine = incomplete, isFirstChunk = false;
226
+ }
227
+ function parseLine(line) {
228
+ if (line === "") {
283
229
  dispatchEvent();
284
230
  return;
285
231
  }
286
- const firstCharCode = chunk.charCodeAt(start);
287
- if (isDataPrefix(chunk, start, firstCharCode)) {
288
- const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
289
- data = dataLines === 0 ? value2 : `${data}
290
- ${value2}`, dataLines++;
291
- return;
292
- }
293
- if (isEventPrefix(chunk, start, firstCharCode)) {
294
- eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
295
- return;
296
- }
297
- if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
298
- const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
299
- id = value2.includes("\0") ? void 0 : value2;
300
- return;
301
- }
302
- if (firstCharCode === 58) {
303
- if (onComment) {
304
- const line2 = chunk.slice(start, end);
305
- onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
306
- }
232
+ if (line.startsWith(":")) {
233
+ onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
307
234
  return;
308
235
  }
309
- const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
310
- if (fieldSeparatorIndex === -1) {
311
- processField(line, "", line);
236
+ const fieldSeparatorIndex = line.indexOf(":");
237
+ if (fieldSeparatorIndex !== -1) {
238
+ const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
239
+ processField(field, value, line);
312
240
  return;
313
241
  }
314
- const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
315
- processField(field, value, line);
242
+ processField(line, "", line);
316
243
  }
317
244
  function processField(field, value, line) {
318
245
  switch (field) {
319
246
  case "event":
320
- eventType = value || void 0;
247
+ eventType = value;
321
248
  break;
322
249
  case "data":
323
- data = dataLines === 0 ? value : `${data}
324
- ${value}`, dataLines++;
250
+ data = `${data}${value}
251
+ `;
325
252
  break;
326
253
  case "id":
327
254
  id = value.includes("\0") ? void 0 : value;
@@ -346,26 +273,37 @@ ${value}`, dataLines++;
346
273
  }
347
274
  }
348
275
  function dispatchEvent() {
349
- dataLines > 0 && onEvent({
276
+ data.length > 0 && onEvent({
350
277
  id,
351
- event: eventType,
352
- data
353
- }), id = void 0, data = "", dataLines = 0, eventType = void 0;
278
+ event: eventType || void 0,
279
+ // If the data buffer's last character is a U+000A LINE FEED (LF) character,
280
+ // then remove the last character from the data buffer.
281
+ data: data.endsWith(`
282
+ `) ? data.slice(0, -1) : data
283
+ }), id = void 0, data = "", eventType = "";
354
284
  }
355
285
  function reset(options = {}) {
356
- if (options.consume && pendingFragments.length > 0) {
357
- const incompleteLine = pendingFragments.join("");
358
- parseLine(incompleteLine, 0, incompleteLine.length);
359
- }
360
- isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
286
+ incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
361
287
  }
362
288
  return { feed, reset };
363
289
  }
364
- function isDataPrefix(chunk, i, firstCharCode) {
365
- return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
366
- }
367
- function isEventPrefix(chunk, i, firstCharCode) {
368
- return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
290
+ function splitLines(chunk) {
291
+ const lines = [];
292
+ let incompleteLine = "", searchIndex = 0;
293
+ for (; searchIndex < chunk.length; ) {
294
+ const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
295
+ `, searchIndex);
296
+ let lineEnd = -1;
297
+ if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
298
+ incompleteLine = chunk.slice(searchIndex);
299
+ break;
300
+ } else {
301
+ const line = chunk.slice(searchIndex, lineEnd);
302
+ lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
303
+ ` && searchIndex++;
304
+ }
305
+ }
306
+ return [lines, incompleteLine];
369
307
  }
370
308
  var EventSourceParserStream = class extends TransformStream {
371
309
  constructor({ onError, onRetry, onComment } = {}) {
@@ -3335,7 +3273,7 @@ async function getVercelRequestId() {
3335
3273
  var _a932;
3336
3274
  return (_a932 = getContext().headers) == null ? void 0 : _a932["x-vercel-id"];
3337
3275
  }
3338
- var VERSION2 = "2.0.86";
3276
+ var VERSION2 = "2.0.88";
3339
3277
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
3340
3278
  function createGatewayProvider(options = {}) {
3341
3279
  var _a932, _b93;
@@ -5775,9 +5713,9 @@ var ParseError2 = class extends Error {
5775
5713
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
5776
5714
  }
5777
5715
  };
5778
- var LF2 = 10;
5779
- var CR2 = 13;
5780
- var SPACE2 = 32;
5716
+ var LF = 10;
5717
+ var CR = 13;
5718
+ var SPACE = 32;
5781
5719
  function noop2(_arg) {
5782
5720
  }
5783
5721
  function createParser2(callbacks) {
@@ -5816,17 +5754,17 @@ function createParser2(callbacks) {
5816
5754
  continue;
5817
5755
  }
5818
5756
  const firstCharCode = chunk.charCodeAt(searchIndex);
5819
- if (isDataPrefix2(chunk, searchIndex, firstCharCode)) {
5820
- const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE2 ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
5821
- if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF2) {
5757
+ if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
5758
+ const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
5759
+ if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
5822
5760
  onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
5823
5761
  `, searchIndex);
5824
5762
  continue;
5825
5763
  }
5826
5764
  data = dataLines === 0 ? value : `${data}
5827
5765
  ${value}`, dataLines++;
5828
- } else isEventPrefix2(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
5829
- chunk.charCodeAt(searchIndex + 6) === SPACE2 ? searchIndex + 7 : searchIndex + 6,
5766
+ } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
5767
+ chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
5830
5768
  lfIndex
5831
5769
  ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
5832
5770
  searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
@@ -5840,7 +5778,7 @@ ${value}`, dataLines++;
5840
5778
  let lineEnd = -1;
5841
5779
  if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
5842
5780
  break;
5843
- parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR2 && chunk.charCodeAt(searchIndex) === LF2 && searchIndex++;
5781
+ parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
5844
5782
  }
5845
5783
  return chunk.slice(searchIndex);
5846
5784
  }
@@ -5850,25 +5788,25 @@ ${value}`, dataLines++;
5850
5788
  return;
5851
5789
  }
5852
5790
  const firstCharCode = chunk.charCodeAt(start);
5853
- if (isDataPrefix2(chunk, start, firstCharCode)) {
5854
- const valueStart = chunk.charCodeAt(start + 5) === SPACE2 ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
5791
+ if (isDataPrefix(chunk, start, firstCharCode)) {
5792
+ const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
5855
5793
  data = dataLines === 0 ? value2 : `${data}
5856
5794
  ${value2}`, dataLines++;
5857
5795
  return;
5858
5796
  }
5859
- if (isEventPrefix2(chunk, start, firstCharCode)) {
5860
- eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE2 ? start + 7 : start + 6, end) || void 0;
5797
+ if (isEventPrefix(chunk, start, firstCharCode)) {
5798
+ eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
5861
5799
  return;
5862
5800
  }
5863
5801
  if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
5864
- const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE2 ? start + 4 : start + 3, end);
5802
+ const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
5865
5803
  id = value2.includes("\0") ? void 0 : value2;
5866
5804
  return;
5867
5805
  }
5868
5806
  if (firstCharCode === 58) {
5869
5807
  if (onComment) {
5870
5808
  const line2 = chunk.slice(start, end);
5871
- onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE2 ? 2 : 1));
5809
+ onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
5872
5810
  }
5873
5811
  return;
5874
5812
  }
@@ -5877,7 +5815,7 @@ ${value2}`, dataLines++;
5877
5815
  processField(line, "", line);
5878
5816
  return;
5879
5817
  }
5880
- const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE2 ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
5818
+ const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
5881
5819
  processField(field, value, line);
5882
5820
  }
5883
5821
  function processField(field, value, line) {
@@ -5927,10 +5865,10 @@ ${value}`, dataLines++;
5927
5865
  }
5928
5866
  return { feed, reset };
5929
5867
  }
5930
- function isDataPrefix2(chunk, i, firstCharCode) {
5868
+ function isDataPrefix(chunk, i, firstCharCode) {
5931
5869
  return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
5932
5870
  }
5933
- function isEventPrefix2(chunk, i, firstCharCode) {
5871
+ function isEventPrefix(chunk, i, firstCharCode) {
5934
5872
  return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
5935
5873
  }
5936
5874
  var EventSourceParserStream2 = class extends TransformStream {
@@ -6115,7 +6053,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
6115
6053
  );
6116
6054
  return Object.fromEntries(normalizedHeaders.entries());
6117
6055
  }
6118
- var VERSION4 = "4.0.26";
6056
+ var VERSION4 = "4.0.27";
6119
6057
  var getOriginalFetch3 = () => globalThis.fetch;
6120
6058
  var getFromApi2 = async ({
6121
6059
  url,
@@ -9282,7 +9220,7 @@ async function getVercelRequestId2() {
9282
9220
  var _a932;
9283
9221
  return (_a932 = getContext2().headers) == null ? void 0 : _a932["x-vercel-id"];
9284
9222
  }
9285
- var VERSION5 = "3.0.110";
9223
+ var VERSION5 = "3.0.112";
9286
9224
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
9287
9225
  function createGatewayProvider2(options = {}) {
9288
9226
  var _a932, _b93;
@@ -11183,6 +11121,10 @@ function createUIMessageStreamResponse2({
11183
11121
  headers: prepareHeaders2(headers, UI_MESSAGE_STREAM_HEADERS2)
11184
11122
  });
11185
11123
  }
11124
+ z4.z.record(
11125
+ z4.z.string(),
11126
+ jsonValueSchema2.optional()
11127
+ );
11186
11128
  function isDataUIMessageChunk2(chunk) {
11187
11129
  return chunk.type.startsWith("data-");
11188
11130
  }
@@ -11259,6 +11201,9 @@ function processUIMessageStream2({
11259
11201
  if (options.title !== void 0) {
11260
11202
  anyPart.title = options.title;
11261
11203
  }
11204
+ if (options.toolMetadata !== void 0) {
11205
+ anyPart.toolMetadata = options.toolMetadata;
11206
+ }
11262
11207
  anyPart.providerExecuted = (_a2222 = anyOptions.providerExecuted) != null ? _a2222 : part.providerExecuted;
11263
11208
  const providerMetadata = anyOptions.providerMetadata;
11264
11209
  if (providerMetadata != null) {
@@ -11275,6 +11220,7 @@ function processUIMessageStream2({
11275
11220
  toolCallId: options.toolCallId,
11276
11221
  state: options.state,
11277
11222
  title: options.title,
11223
+ ...options.toolMetadata !== void 0 ? { toolMetadata: options.toolMetadata } : {},
11278
11224
  input: anyOptions.input,
11279
11225
  output: anyOptions.output,
11280
11226
  rawInput: anyOptions.rawInput,
@@ -11304,6 +11250,9 @@ function processUIMessageStream2({
11304
11250
  if (options.title !== void 0) {
11305
11251
  anyPart.title = options.title;
11306
11252
  }
11253
+ if (options.toolMetadata !== void 0) {
11254
+ anyPart.toolMetadata = options.toolMetadata;
11255
+ }
11307
11256
  anyPart.providerExecuted = (_b222 = anyOptions.providerExecuted) != null ? _b222 : part.providerExecuted;
11308
11257
  const providerMetadata = anyOptions.providerMetadata;
11309
11258
  if (providerMetadata != null) {
@@ -11326,6 +11275,7 @@ function processUIMessageStream2({
11326
11275
  preliminary: anyOptions.preliminary,
11327
11276
  providerExecuted: anyOptions.providerExecuted,
11328
11277
  title: options.title,
11278
+ ...options.toolMetadata !== void 0 ? { toolMetadata: options.toolMetadata } : {},
11329
11279
  ...anyOptions.providerMetadata != null && (options.state === "output-available" || options.state === "output-error") ? { resultProviderMetadata: anyOptions.providerMetadata } : {},
11330
11280
  ...anyOptions.providerMetadata != null && !(options.state === "output-available" || options.state === "output-error") ? { callProviderMetadata: anyOptions.providerMetadata } : {}
11331
11281
  });
@@ -11470,7 +11420,8 @@ function processUIMessageStream2({
11470
11420
  toolName: chunk.toolName,
11471
11421
  index: toolInvocations.length,
11472
11422
  dynamic: chunk.dynamic,
11473
- title: chunk.title
11423
+ title: chunk.title,
11424
+ toolMetadata: chunk.toolMetadata
11474
11425
  };
11475
11426
  if (chunk.dynamic) {
11476
11427
  updateDynamicToolPart({
@@ -11480,6 +11431,7 @@ function processUIMessageStream2({
11480
11431
  input: void 0,
11481
11432
  providerExecuted: chunk.providerExecuted,
11482
11433
  title: chunk.title,
11434
+ toolMetadata: chunk.toolMetadata,
11483
11435
  providerMetadata: chunk.providerMetadata
11484
11436
  });
11485
11437
  } else {
@@ -11490,6 +11442,7 @@ function processUIMessageStream2({
11490
11442
  input: void 0,
11491
11443
  providerExecuted: chunk.providerExecuted,
11492
11444
  title: chunk.title,
11445
+ toolMetadata: chunk.toolMetadata,
11493
11446
  providerMetadata: chunk.providerMetadata
11494
11447
  });
11495
11448
  }
@@ -11515,7 +11468,8 @@ function processUIMessageStream2({
11515
11468
  toolName: partialToolCall.toolName,
11516
11469
  state: "input-streaming",
11517
11470
  input: partialArgs,
11518
- title: partialToolCall.title
11471
+ title: partialToolCall.title,
11472
+ toolMetadata: partialToolCall.toolMetadata
11519
11473
  });
11520
11474
  } else {
11521
11475
  updateToolPart({
@@ -11523,7 +11477,8 @@ function processUIMessageStream2({
11523
11477
  toolName: partialToolCall.toolName,
11524
11478
  state: "input-streaming",
11525
11479
  input: partialArgs,
11526
- title: partialToolCall.title
11480
+ title: partialToolCall.title,
11481
+ toolMetadata: partialToolCall.toolMetadata
11527
11482
  });
11528
11483
  }
11529
11484
  write();
@@ -11538,7 +11493,8 @@ function processUIMessageStream2({
11538
11493
  input: chunk.input,
11539
11494
  providerExecuted: chunk.providerExecuted,
11540
11495
  providerMetadata: chunk.providerMetadata,
11541
- title: chunk.title
11496
+ title: chunk.title,
11497
+ toolMetadata: chunk.toolMetadata
11542
11498
  });
11543
11499
  } else {
11544
11500
  updateToolPart({
@@ -11548,7 +11504,8 @@ function processUIMessageStream2({
11548
11504
  input: chunk.input,
11549
11505
  providerExecuted: chunk.providerExecuted,
11550
11506
  providerMetadata: chunk.providerMetadata,
11551
- title: chunk.title
11507
+ title: chunk.title,
11508
+ toolMetadata: chunk.toolMetadata
11552
11509
  });
11553
11510
  }
11554
11511
  write();
@@ -11570,7 +11527,8 @@ function processUIMessageStream2({
11570
11527
  input: chunk.input,
11571
11528
  errorText: chunk.errorText,
11572
11529
  providerExecuted: chunk.providerExecuted,
11573
- providerMetadata: chunk.providerMetadata
11530
+ providerMetadata: chunk.providerMetadata,
11531
+ toolMetadata: chunk.toolMetadata
11574
11532
  });
11575
11533
  } else {
11576
11534
  updateToolPart({
@@ -11581,7 +11539,8 @@ function processUIMessageStream2({
11581
11539
  rawInput: chunk.input,
11582
11540
  errorText: chunk.errorText,
11583
11541
  providerExecuted: chunk.providerExecuted,
11584
- providerMetadata: chunk.providerMetadata
11542
+ providerMetadata: chunk.providerMetadata,
11543
+ toolMetadata: chunk.toolMetadata
11585
11544
  });
11586
11545
  }
11587
11546
  write();
@@ -11612,7 +11571,8 @@ function processUIMessageStream2({
11612
11571
  preliminary: chunk.preliminary,
11613
11572
  providerExecuted: chunk.providerExecuted,
11614
11573
  providerMetadata: chunk.providerMetadata,
11615
- title: toolInvocation.title
11574
+ title: toolInvocation.title,
11575
+ toolMetadata: toolInvocation.toolMetadata
11616
11576
  });
11617
11577
  } else {
11618
11578
  updateToolPart({
@@ -11624,7 +11584,8 @@ function processUIMessageStream2({
11624
11584
  providerExecuted: chunk.providerExecuted,
11625
11585
  preliminary: chunk.preliminary,
11626
11586
  providerMetadata: chunk.providerMetadata,
11627
- title: toolInvocation.title
11587
+ title: toolInvocation.title,
11588
+ toolMetadata: toolInvocation.toolMetadata
11628
11589
  });
11629
11590
  }
11630
11591
  write();
@@ -11641,7 +11602,8 @@ function processUIMessageStream2({
11641
11602
  errorText: chunk.errorText,
11642
11603
  providerExecuted: chunk.providerExecuted,
11643
11604
  providerMetadata: chunk.providerMetadata,
11644
- title: toolInvocation.title
11605
+ title: toolInvocation.title,
11606
+ toolMetadata: toolInvocation.toolMetadata
11645
11607
  });
11646
11608
  } else {
11647
11609
  updateToolPart({
@@ -11653,7 +11615,8 @@ function processUIMessageStream2({
11653
11615
  errorText: chunk.errorText,
11654
11616
  providerExecuted: chunk.providerExecuted,
11655
11617
  providerMetadata: chunk.providerMetadata,
11656
- title: toolInvocation.title
11618
+ title: toolInvocation.title,
11619
+ toolMetadata: toolInvocation.toolMetadata
11657
11620
  });
11658
11621
  }
11659
11622
  write();
@@ -11930,6 +11893,10 @@ function createUIMessageStream2({
11930
11893
  onError
11931
11894
  });
11932
11895
  }
11896
+ z4.z.record(
11897
+ z4.z.string(),
11898
+ jsonValueSchema2.optional()
11899
+ );
11933
11900
  createIdGenerator2({ prefix: "aiobj", size: 24 });
11934
11901
  createIdGenerator2({ prefix: "aiobj", size: 24 });
11935
11902
  var wrapLanguageModel2 = ({