@mastra/ai-sdk 1.4.2-alpha.1 → 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.js CHANGED
@@ -9,7 +9,7 @@ import { TripWire, MessageList, aiV5ModelMessageToV2PromptMessage } from '@mastr
9
9
  import { RequestContext } from '@mastra/core/di';
10
10
  import { WorkingMemory, MessageHistory, SemanticRecall } from '@mastra/core/processors';
11
11
 
12
- // ../../packages/_vendored/ai_v5/dist/chunk-UDIOFQR2.js
12
+ // ../../packages/_vendored/ai_v5/dist/chunk-TJMMQ5MY.js
13
13
  var marker = "vercel.ai.error";
14
14
  var symbol = Symbol.for(marker);
15
15
  var _a;
@@ -188,9 +188,6 @@ var ParseError = class extends Error {
188
188
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
189
189
  }
190
190
  };
191
- var LF = 10;
192
- var CR = 13;
193
- var SPACE = 32;
194
191
  function noop(_arg) {
195
192
  }
196
193
  function createParser(callbacks) {
@@ -198,109 +195,39 @@ function createParser(callbacks) {
198
195
  throw new TypeError(
199
196
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
200
197
  );
201
- const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
202
- let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
203
- function feed(chunk) {
204
- if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
205
- const trailing2 = processLines(chunk);
206
- trailing2 !== "" && pendingFragments.push(trailing2);
207
- return;
208
- }
209
- if (chunk.indexOf(`
210
- `) === -1 && chunk.indexOf("\r") === -1) {
211
- pendingFragments.push(chunk);
212
- return;
213
- }
214
- pendingFragments.push(chunk);
215
- const input = pendingFragments.join("");
216
- pendingFragments.length = 0;
217
- const trailing = processLines(input);
218
- trailing !== "" && pendingFragments.push(trailing);
219
- }
220
- function processLines(chunk) {
221
- let searchIndex = 0;
222
- if (chunk.indexOf("\r") === -1) {
223
- let lfIndex = chunk.indexOf(`
224
- `, searchIndex);
225
- for (; lfIndex !== -1; ) {
226
- if (searchIndex === lfIndex) {
227
- dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
228
- `, searchIndex);
229
- continue;
230
- }
231
- const firstCharCode = chunk.charCodeAt(searchIndex);
232
- if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
233
- const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
234
- if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
235
- onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
236
- `, searchIndex);
237
- continue;
238
- }
239
- data = dataLines === 0 ? value : `${data}
240
- ${value}`, dataLines++;
241
- } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
242
- chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
243
- lfIndex
244
- ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
245
- searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
246
- `, searchIndex);
247
- }
248
- return chunk.slice(searchIndex);
249
- }
250
- for (; searchIndex < chunk.length; ) {
251
- const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
252
- `, searchIndex);
253
- let lineEnd = -1;
254
- 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)
255
- break;
256
- parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
257
- }
258
- return chunk.slice(searchIndex);
259
- }
260
- function parseLine(chunk, start, end) {
261
- if (start === end) {
198
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
199
+ let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
200
+ function feed(newChunk) {
201
+ const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
202
+ for (const line of complete)
203
+ parseLine(line);
204
+ incompleteLine = incomplete, isFirstChunk = false;
205
+ }
206
+ function parseLine(line) {
207
+ if (line === "") {
262
208
  dispatchEvent();
263
209
  return;
264
210
  }
265
- const firstCharCode = chunk.charCodeAt(start);
266
- if (isDataPrefix(chunk, start, firstCharCode)) {
267
- const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
268
- data = dataLines === 0 ? value2 : `${data}
269
- ${value2}`, dataLines++;
270
- return;
271
- }
272
- if (isEventPrefix(chunk, start, firstCharCode)) {
273
- eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
274
- return;
275
- }
276
- if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
277
- const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
278
- id = value2.includes("\0") ? void 0 : value2;
279
- return;
280
- }
281
- if (firstCharCode === 58) {
282
- if (onComment) {
283
- const line2 = chunk.slice(start, end);
284
- onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
285
- }
211
+ if (line.startsWith(":")) {
212
+ onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
286
213
  return;
287
214
  }
288
- const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
289
- if (fieldSeparatorIndex === -1) {
290
- processField(line, "", line);
215
+ const fieldSeparatorIndex = line.indexOf(":");
216
+ if (fieldSeparatorIndex !== -1) {
217
+ const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
218
+ processField(field, value, line);
291
219
  return;
292
220
  }
293
- const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
294
- processField(field, value, line);
221
+ processField(line, "", line);
295
222
  }
296
223
  function processField(field, value, line) {
297
224
  switch (field) {
298
225
  case "event":
299
- eventType = value || void 0;
226
+ eventType = value;
300
227
  break;
301
228
  case "data":
302
- data = dataLines === 0 ? value : `${data}
303
- ${value}`, dataLines++;
229
+ data = `${data}${value}
230
+ `;
304
231
  break;
305
232
  case "id":
306
233
  id = value.includes("\0") ? void 0 : value;
@@ -325,26 +252,37 @@ ${value}`, dataLines++;
325
252
  }
326
253
  }
327
254
  function dispatchEvent() {
328
- dataLines > 0 && onEvent({
255
+ data.length > 0 && onEvent({
329
256
  id,
330
- event: eventType,
331
- data
332
- }), id = void 0, data = "", dataLines = 0, eventType = void 0;
257
+ event: eventType || void 0,
258
+ // If the data buffer's last character is a U+000A LINE FEED (LF) character,
259
+ // then remove the last character from the data buffer.
260
+ data: data.endsWith(`
261
+ `) ? data.slice(0, -1) : data
262
+ }), id = void 0, data = "", eventType = "";
333
263
  }
334
264
  function reset(options = {}) {
335
- if (options.consume && pendingFragments.length > 0) {
336
- const incompleteLine = pendingFragments.join("");
337
- parseLine(incompleteLine, 0, incompleteLine.length);
338
- }
339
- isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
265
+ incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
340
266
  }
341
267
  return { feed, reset };
342
268
  }
343
- function isDataPrefix(chunk, i, firstCharCode) {
344
- return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
345
- }
346
- function isEventPrefix(chunk, i, firstCharCode) {
347
- 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;
269
+ function splitLines(chunk) {
270
+ const lines = [];
271
+ let incompleteLine = "", searchIndex = 0;
272
+ for (; searchIndex < chunk.length; ) {
273
+ const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
274
+ `, searchIndex);
275
+ let lineEnd = -1;
276
+ 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) {
277
+ incompleteLine = chunk.slice(searchIndex);
278
+ break;
279
+ } else {
280
+ const line = chunk.slice(searchIndex, lineEnd);
281
+ lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
282
+ ` && searchIndex++;
283
+ }
284
+ }
285
+ return [lines, incompleteLine];
348
286
  }
349
287
  var EventSourceParserStream = class extends TransformStream {
350
288
  constructor({ onError, onRetry, onComment } = {}) {
@@ -3314,7 +3252,7 @@ async function getVercelRequestId() {
3314
3252
  var _a932;
3315
3253
  return (_a932 = getContext().headers) == null ? void 0 : _a932["x-vercel-id"];
3316
3254
  }
3317
- var VERSION2 = "2.0.86";
3255
+ var VERSION2 = "2.0.88";
3318
3256
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
3319
3257
  function createGatewayProvider(options = {}) {
3320
3258
  var _a932, _b93;
@@ -5754,9 +5692,9 @@ var ParseError2 = class extends Error {
5754
5692
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
5755
5693
  }
5756
5694
  };
5757
- var LF2 = 10;
5758
- var CR2 = 13;
5759
- var SPACE2 = 32;
5695
+ var LF = 10;
5696
+ var CR = 13;
5697
+ var SPACE = 32;
5760
5698
  function noop2(_arg) {
5761
5699
  }
5762
5700
  function createParser2(callbacks) {
@@ -5795,17 +5733,17 @@ function createParser2(callbacks) {
5795
5733
  continue;
5796
5734
  }
5797
5735
  const firstCharCode = chunk.charCodeAt(searchIndex);
5798
- if (isDataPrefix2(chunk, searchIndex, firstCharCode)) {
5799
- const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE2 ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
5800
- if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF2) {
5736
+ if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
5737
+ const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
5738
+ if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
5801
5739
  onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
5802
5740
  `, searchIndex);
5803
5741
  continue;
5804
5742
  }
5805
5743
  data = dataLines === 0 ? value : `${data}
5806
5744
  ${value}`, dataLines++;
5807
- } else isEventPrefix2(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
5808
- chunk.charCodeAt(searchIndex + 6) === SPACE2 ? searchIndex + 7 : searchIndex + 6,
5745
+ } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
5746
+ chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
5809
5747
  lfIndex
5810
5748
  ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
5811
5749
  searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
@@ -5819,7 +5757,7 @@ ${value}`, dataLines++;
5819
5757
  let lineEnd = -1;
5820
5758
  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)
5821
5759
  break;
5822
- parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR2 && chunk.charCodeAt(searchIndex) === LF2 && searchIndex++;
5760
+ parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
5823
5761
  }
5824
5762
  return chunk.slice(searchIndex);
5825
5763
  }
@@ -5829,25 +5767,25 @@ ${value}`, dataLines++;
5829
5767
  return;
5830
5768
  }
5831
5769
  const firstCharCode = chunk.charCodeAt(start);
5832
- if (isDataPrefix2(chunk, start, firstCharCode)) {
5833
- const valueStart = chunk.charCodeAt(start + 5) === SPACE2 ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
5770
+ if (isDataPrefix(chunk, start, firstCharCode)) {
5771
+ const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
5834
5772
  data = dataLines === 0 ? value2 : `${data}
5835
5773
  ${value2}`, dataLines++;
5836
5774
  return;
5837
5775
  }
5838
- if (isEventPrefix2(chunk, start, firstCharCode)) {
5839
- eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE2 ? start + 7 : start + 6, end) || void 0;
5776
+ if (isEventPrefix(chunk, start, firstCharCode)) {
5777
+ eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
5840
5778
  return;
5841
5779
  }
5842
5780
  if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
5843
- const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE2 ? start + 4 : start + 3, end);
5781
+ const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
5844
5782
  id = value2.includes("\0") ? void 0 : value2;
5845
5783
  return;
5846
5784
  }
5847
5785
  if (firstCharCode === 58) {
5848
5786
  if (onComment) {
5849
5787
  const line2 = chunk.slice(start, end);
5850
- onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE2 ? 2 : 1));
5788
+ onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
5851
5789
  }
5852
5790
  return;
5853
5791
  }
@@ -5856,7 +5794,7 @@ ${value2}`, dataLines++;
5856
5794
  processField(line, "", line);
5857
5795
  return;
5858
5796
  }
5859
- const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE2 ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
5797
+ const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
5860
5798
  processField(field, value, line);
5861
5799
  }
5862
5800
  function processField(field, value, line) {
@@ -5906,10 +5844,10 @@ ${value}`, dataLines++;
5906
5844
  }
5907
5845
  return { feed, reset };
5908
5846
  }
5909
- function isDataPrefix2(chunk, i, firstCharCode) {
5847
+ function isDataPrefix(chunk, i, firstCharCode) {
5910
5848
  return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
5911
5849
  }
5912
- function isEventPrefix2(chunk, i, firstCharCode) {
5850
+ function isEventPrefix(chunk, i, firstCharCode) {
5913
5851
  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;
5914
5852
  }
5915
5853
  var EventSourceParserStream2 = class extends TransformStream {
@@ -6094,7 +6032,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
6094
6032
  );
6095
6033
  return Object.fromEntries(normalizedHeaders.entries());
6096
6034
  }
6097
- var VERSION4 = "4.0.26";
6035
+ var VERSION4 = "4.0.27";
6098
6036
  var getOriginalFetch3 = () => globalThis.fetch;
6099
6037
  var getFromApi2 = async ({
6100
6038
  url,
@@ -9261,7 +9199,7 @@ async function getVercelRequestId2() {
9261
9199
  var _a932;
9262
9200
  return (_a932 = getContext2().headers) == null ? void 0 : _a932["x-vercel-id"];
9263
9201
  }
9264
- var VERSION5 = "3.0.110";
9202
+ var VERSION5 = "3.0.112";
9265
9203
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
9266
9204
  function createGatewayProvider2(options = {}) {
9267
9205
  var _a932, _b93;
@@ -11162,6 +11100,10 @@ function createUIMessageStreamResponse2({
11162
11100
  headers: prepareHeaders2(headers, UI_MESSAGE_STREAM_HEADERS2)
11163
11101
  });
11164
11102
  }
11103
+ z.record(
11104
+ z.string(),
11105
+ jsonValueSchema2.optional()
11106
+ );
11165
11107
  function isDataUIMessageChunk2(chunk) {
11166
11108
  return chunk.type.startsWith("data-");
11167
11109
  }
@@ -11238,6 +11180,9 @@ function processUIMessageStream2({
11238
11180
  if (options.title !== void 0) {
11239
11181
  anyPart.title = options.title;
11240
11182
  }
11183
+ if (options.toolMetadata !== void 0) {
11184
+ anyPart.toolMetadata = options.toolMetadata;
11185
+ }
11241
11186
  anyPart.providerExecuted = (_a2222 = anyOptions.providerExecuted) != null ? _a2222 : part.providerExecuted;
11242
11187
  const providerMetadata = anyOptions.providerMetadata;
11243
11188
  if (providerMetadata != null) {
@@ -11254,6 +11199,7 @@ function processUIMessageStream2({
11254
11199
  toolCallId: options.toolCallId,
11255
11200
  state: options.state,
11256
11201
  title: options.title,
11202
+ ...options.toolMetadata !== void 0 ? { toolMetadata: options.toolMetadata } : {},
11257
11203
  input: anyOptions.input,
11258
11204
  output: anyOptions.output,
11259
11205
  rawInput: anyOptions.rawInput,
@@ -11283,6 +11229,9 @@ function processUIMessageStream2({
11283
11229
  if (options.title !== void 0) {
11284
11230
  anyPart.title = options.title;
11285
11231
  }
11232
+ if (options.toolMetadata !== void 0) {
11233
+ anyPart.toolMetadata = options.toolMetadata;
11234
+ }
11286
11235
  anyPart.providerExecuted = (_b222 = anyOptions.providerExecuted) != null ? _b222 : part.providerExecuted;
11287
11236
  const providerMetadata = anyOptions.providerMetadata;
11288
11237
  if (providerMetadata != null) {
@@ -11305,6 +11254,7 @@ function processUIMessageStream2({
11305
11254
  preliminary: anyOptions.preliminary,
11306
11255
  providerExecuted: anyOptions.providerExecuted,
11307
11256
  title: options.title,
11257
+ ...options.toolMetadata !== void 0 ? { toolMetadata: options.toolMetadata } : {},
11308
11258
  ...anyOptions.providerMetadata != null && (options.state === "output-available" || options.state === "output-error") ? { resultProviderMetadata: anyOptions.providerMetadata } : {},
11309
11259
  ...anyOptions.providerMetadata != null && !(options.state === "output-available" || options.state === "output-error") ? { callProviderMetadata: anyOptions.providerMetadata } : {}
11310
11260
  });
@@ -11449,7 +11399,8 @@ function processUIMessageStream2({
11449
11399
  toolName: chunk.toolName,
11450
11400
  index: toolInvocations.length,
11451
11401
  dynamic: chunk.dynamic,
11452
- title: chunk.title
11402
+ title: chunk.title,
11403
+ toolMetadata: chunk.toolMetadata
11453
11404
  };
11454
11405
  if (chunk.dynamic) {
11455
11406
  updateDynamicToolPart({
@@ -11459,6 +11410,7 @@ function processUIMessageStream2({
11459
11410
  input: void 0,
11460
11411
  providerExecuted: chunk.providerExecuted,
11461
11412
  title: chunk.title,
11413
+ toolMetadata: chunk.toolMetadata,
11462
11414
  providerMetadata: chunk.providerMetadata
11463
11415
  });
11464
11416
  } else {
@@ -11469,6 +11421,7 @@ function processUIMessageStream2({
11469
11421
  input: void 0,
11470
11422
  providerExecuted: chunk.providerExecuted,
11471
11423
  title: chunk.title,
11424
+ toolMetadata: chunk.toolMetadata,
11472
11425
  providerMetadata: chunk.providerMetadata
11473
11426
  });
11474
11427
  }
@@ -11494,7 +11447,8 @@ function processUIMessageStream2({
11494
11447
  toolName: partialToolCall.toolName,
11495
11448
  state: "input-streaming",
11496
11449
  input: partialArgs,
11497
- title: partialToolCall.title
11450
+ title: partialToolCall.title,
11451
+ toolMetadata: partialToolCall.toolMetadata
11498
11452
  });
11499
11453
  } else {
11500
11454
  updateToolPart({
@@ -11502,7 +11456,8 @@ function processUIMessageStream2({
11502
11456
  toolName: partialToolCall.toolName,
11503
11457
  state: "input-streaming",
11504
11458
  input: partialArgs,
11505
- title: partialToolCall.title
11459
+ title: partialToolCall.title,
11460
+ toolMetadata: partialToolCall.toolMetadata
11506
11461
  });
11507
11462
  }
11508
11463
  write();
@@ -11517,7 +11472,8 @@ function processUIMessageStream2({
11517
11472
  input: chunk.input,
11518
11473
  providerExecuted: chunk.providerExecuted,
11519
11474
  providerMetadata: chunk.providerMetadata,
11520
- title: chunk.title
11475
+ title: chunk.title,
11476
+ toolMetadata: chunk.toolMetadata
11521
11477
  });
11522
11478
  } else {
11523
11479
  updateToolPart({
@@ -11527,7 +11483,8 @@ function processUIMessageStream2({
11527
11483
  input: chunk.input,
11528
11484
  providerExecuted: chunk.providerExecuted,
11529
11485
  providerMetadata: chunk.providerMetadata,
11530
- title: chunk.title
11486
+ title: chunk.title,
11487
+ toolMetadata: chunk.toolMetadata
11531
11488
  });
11532
11489
  }
11533
11490
  write();
@@ -11549,7 +11506,8 @@ function processUIMessageStream2({
11549
11506
  input: chunk.input,
11550
11507
  errorText: chunk.errorText,
11551
11508
  providerExecuted: chunk.providerExecuted,
11552
- providerMetadata: chunk.providerMetadata
11509
+ providerMetadata: chunk.providerMetadata,
11510
+ toolMetadata: chunk.toolMetadata
11553
11511
  });
11554
11512
  } else {
11555
11513
  updateToolPart({
@@ -11560,7 +11518,8 @@ function processUIMessageStream2({
11560
11518
  rawInput: chunk.input,
11561
11519
  errorText: chunk.errorText,
11562
11520
  providerExecuted: chunk.providerExecuted,
11563
- providerMetadata: chunk.providerMetadata
11521
+ providerMetadata: chunk.providerMetadata,
11522
+ toolMetadata: chunk.toolMetadata
11564
11523
  });
11565
11524
  }
11566
11525
  write();
@@ -11591,7 +11550,8 @@ function processUIMessageStream2({
11591
11550
  preliminary: chunk.preliminary,
11592
11551
  providerExecuted: chunk.providerExecuted,
11593
11552
  providerMetadata: chunk.providerMetadata,
11594
- title: toolInvocation.title
11553
+ title: toolInvocation.title,
11554
+ toolMetadata: toolInvocation.toolMetadata
11595
11555
  });
11596
11556
  } else {
11597
11557
  updateToolPart({
@@ -11603,7 +11563,8 @@ function processUIMessageStream2({
11603
11563
  providerExecuted: chunk.providerExecuted,
11604
11564
  preliminary: chunk.preliminary,
11605
11565
  providerMetadata: chunk.providerMetadata,
11606
- title: toolInvocation.title
11566
+ title: toolInvocation.title,
11567
+ toolMetadata: toolInvocation.toolMetadata
11607
11568
  });
11608
11569
  }
11609
11570
  write();
@@ -11620,7 +11581,8 @@ function processUIMessageStream2({
11620
11581
  errorText: chunk.errorText,
11621
11582
  providerExecuted: chunk.providerExecuted,
11622
11583
  providerMetadata: chunk.providerMetadata,
11623
- title: toolInvocation.title
11584
+ title: toolInvocation.title,
11585
+ toolMetadata: toolInvocation.toolMetadata
11624
11586
  });
11625
11587
  } else {
11626
11588
  updateToolPart({
@@ -11632,7 +11594,8 @@ function processUIMessageStream2({
11632
11594
  errorText: chunk.errorText,
11633
11595
  providerExecuted: chunk.providerExecuted,
11634
11596
  providerMetadata: chunk.providerMetadata,
11635
- title: toolInvocation.title
11597
+ title: toolInvocation.title,
11598
+ toolMetadata: toolInvocation.toolMetadata
11636
11599
  });
11637
11600
  }
11638
11601
  write();
@@ -11909,6 +11872,10 @@ function createUIMessageStream2({
11909
11872
  onError
11910
11873
  });
11911
11874
  }
11875
+ z.record(
11876
+ z.string(),
11877
+ jsonValueSchema2.optional()
11878
+ );
11912
11879
  createIdGenerator2({ prefix: "aiobj", size: 24 });
11913
11880
  createIdGenerator2({ prefix: "aiobj", size: 24 });
11914
11881
  var wrapLanguageModel2 = ({