@hasna/testers 0.0.33 → 0.0.34

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.
@@ -8582,33 +8582,33 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
8582
8582
  this.ssl = config.ssl || false;
8583
8583
  this._ending = false;
8584
8584
  this._emitMessage = false;
8585
- const self = this;
8585
+ const self2 = this;
8586
8586
  this.on("newListener", function(eventName) {
8587
8587
  if (eventName === "message") {
8588
- self._emitMessage = true;
8588
+ self2._emitMessage = true;
8589
8589
  }
8590
8590
  });
8591
8591
  }
8592
8592
  connect(port, host) {
8593
- const self = this;
8593
+ const self2 = this;
8594
8594
  this._connecting = true;
8595
8595
  this.stream.setNoDelay(true);
8596
8596
  this.stream.connect(port, host);
8597
8597
  this.stream.once("connect", function() {
8598
- if (self._keepAlive) {
8599
- self.stream.setKeepAlive(true, self._keepAliveInitialDelayMillis);
8598
+ if (self2._keepAlive) {
8599
+ self2.stream.setKeepAlive(true, self2._keepAliveInitialDelayMillis);
8600
8600
  }
8601
- self.emit("connect");
8601
+ self2.emit("connect");
8602
8602
  });
8603
8603
  const reportStreamError = function(error) {
8604
- if (self._ending && (error.code === "ECONNRESET" || error.code === "EPIPE")) {
8604
+ if (self2._ending && (error.code === "ECONNRESET" || error.code === "EPIPE")) {
8605
8605
  return;
8606
8606
  }
8607
- self.emit("error", error);
8607
+ self2.emit("error", error);
8608
8608
  };
8609
8609
  this.stream.on("error", reportStreamError);
8610
8610
  this.stream.on("close", function() {
8611
- self.emit("end");
8611
+ self2.emit("end");
8612
8612
  });
8613
8613
  if (!this.ssl) {
8614
8614
  return this.attachListeners(this.stream);
@@ -8619,19 +8619,19 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
8619
8619
  case "S":
8620
8620
  break;
8621
8621
  case "N":
8622
- self.stream.end();
8623
- return self.emit("error", new Error("The server does not support SSL connections"));
8622
+ self2.stream.end();
8623
+ return self2.emit("error", new Error("The server does not support SSL connections"));
8624
8624
  default:
8625
- self.stream.end();
8626
- return self.emit("error", new Error("There was an error establishing an SSL connection"));
8625
+ self2.stream.end();
8626
+ return self2.emit("error", new Error("There was an error establishing an SSL connection"));
8627
8627
  }
8628
8628
  const options = {
8629
- socket: self.stream
8629
+ socket: self2.stream
8630
8630
  };
8631
- if (self.ssl !== true) {
8632
- Object.assign(options, self.ssl);
8633
- if ("key" in self.ssl) {
8634
- options.key = self.ssl.key;
8631
+ if (self2.ssl !== true) {
8632
+ Object.assign(options, self2.ssl);
8633
+ if ("key" in self2.ssl) {
8634
+ options.key = self2.ssl.key;
8635
8635
  }
8636
8636
  }
8637
8637
  const net = __require2("net");
@@ -8639,13 +8639,13 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
8639
8639
  options.servername = host;
8640
8640
  }
8641
8641
  try {
8642
- self.stream = getSecureStream(options);
8642
+ self2.stream = getSecureStream(options);
8643
8643
  } catch (err) {
8644
- return self.emit("error", err);
8644
+ return self2.emit("error", err);
8645
8645
  }
8646
- self.attachListeners(self.stream);
8647
- self.stream.on("error", reportStreamError);
8648
- self.emit("sslconnect");
8646
+ self2.attachListeners(self2.stream);
8647
+ self2.stream.on("error", reportStreamError);
8648
+ self2.emit("sslconnect");
8649
8649
  });
8650
8650
  }
8651
8651
  attachListeners(stream) {
@@ -8780,9 +8780,9 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
8780
8780
  }
8781
8781
  cb();
8782
8782
  }
8783
- function push(self, val) {
8783
+ function push(self2, val) {
8784
8784
  if (val !== undefined) {
8785
- self.push(val);
8785
+ self2.push(val);
8786
8786
  }
8787
8787
  }
8788
8788
  function noop(incoming) {
@@ -9102,7 +9102,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
9102
9102
  this._queryQueue.length = 0;
9103
9103
  }
9104
9104
  _connect(callback) {
9105
- const self = this;
9105
+ const self2 = this;
9106
9106
  const con = this.connection;
9107
9107
  this._connectionCallback = callback;
9108
9108
  if (this._connecting || this._connected) {
@@ -9128,14 +9128,14 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
9128
9128
  con.connect(this.port, this.host);
9129
9129
  }
9130
9130
  con.on("connect", function() {
9131
- if (self.ssl) {
9131
+ if (self2.ssl) {
9132
9132
  con.requestSsl();
9133
9133
  } else {
9134
- con.startup(self.getStartupConf());
9134
+ con.startup(self2.getStartupConf());
9135
9135
  }
9136
9136
  });
9137
9137
  con.on("sslconnect", function() {
9138
- con.startup(self.getStartupConf());
9138
+ con.startup(self2.getStartupConf());
9139
9139
  });
9140
9140
  this._attachListeners(con);
9141
9141
  con.once("end", () => {
@@ -10067,34 +10067,34 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
10067
10067
  };
10068
10068
  NativeQuery.prototype.submit = function(client) {
10069
10069
  this.state = "running";
10070
- const self = this;
10070
+ const self2 = this;
10071
10071
  this.native = client.native;
10072
10072
  client.native.arrayMode = this._arrayMode;
10073
10073
  let after = function(err, rows, results) {
10074
10074
  client.native.arrayMode = false;
10075
10075
  setImmediate(function() {
10076
- self.emit("_done");
10076
+ self2.emit("_done");
10077
10077
  });
10078
10078
  if (err) {
10079
- return self.handleError(err);
10079
+ return self2.handleError(err);
10080
10080
  }
10081
- if (self._emitRowEvents) {
10081
+ if (self2._emitRowEvents) {
10082
10082
  if (results.length > 1) {
10083
10083
  rows.forEach((rowOfRows, i) => {
10084
10084
  rowOfRows.forEach((row) => {
10085
- self.emit("row", row, results[i]);
10085
+ self2.emit("row", row, results[i]);
10086
10086
  });
10087
10087
  });
10088
10088
  } else {
10089
10089
  rows.forEach(function(row) {
10090
- self.emit("row", row, results);
10090
+ self2.emit("row", row, results);
10091
10091
  });
10092
10092
  }
10093
10093
  }
10094
- self.state = "end";
10095
- self.emit("end", results);
10096
- if (self.callback) {
10097
- self.callback(null, results);
10094
+ self2.state = "end";
10095
+ self2.emit("end", results);
10096
+ if (self2.callback) {
10097
+ self2.callback(null, results);
10098
10098
  }
10099
10099
  };
10100
10100
  if (process.domain) {
@@ -10117,8 +10117,8 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
10117
10117
  return client.native.prepare(this.name, this.text, values.length, function(err) {
10118
10118
  if (err)
10119
10119
  return after(err);
10120
- client.namedQueries[self.name] = self.text;
10121
- return self.native.execute(self.name, values, after);
10120
+ client.namedQueries[self2.name] = self2.text;
10121
+ return self2.native.execute(self2.name, values, after);
10122
10122
  });
10123
10123
  } else if (this.values) {
10124
10124
  if (!Array.isArray(this.values)) {
@@ -10195,36 +10195,36 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
10195
10195
  this._queryQueue.length = 0;
10196
10196
  };
10197
10197
  Client.prototype._connect = function(cb) {
10198
- const self = this;
10198
+ const self2 = this;
10199
10199
  if (this._connecting) {
10200
10200
  process.nextTick(() => cb(new Error("Client has already been connected. You cannot reuse a client.")));
10201
10201
  return;
10202
10202
  }
10203
10203
  this._connecting = true;
10204
10204
  this.connectionParameters.getLibpqConnectionString(function(err, conString) {
10205
- if (self.connectionParameters.nativeConnectionString)
10206
- conString = self.connectionParameters.nativeConnectionString;
10205
+ if (self2.connectionParameters.nativeConnectionString)
10206
+ conString = self2.connectionParameters.nativeConnectionString;
10207
10207
  if (err)
10208
10208
  return cb(err);
10209
- self.native.connect(conString, function(err2) {
10209
+ self2.native.connect(conString, function(err2) {
10210
10210
  if (err2) {
10211
- self.native.end();
10211
+ self2.native.end();
10212
10212
  return cb(err2);
10213
10213
  }
10214
- self._connected = true;
10215
- self.native.on("error", function(err3) {
10216
- self._queryable = false;
10217
- self._errorAllQueries(err3);
10218
- self.emit("error", err3);
10214
+ self2._connected = true;
10215
+ self2.native.on("error", function(err3) {
10216
+ self2._queryable = false;
10217
+ self2._errorAllQueries(err3);
10218
+ self2.emit("error", err3);
10219
10219
  });
10220
- self.native.on("notification", function(msg) {
10221
- self.emit("notification", {
10220
+ self2.native.on("notification", function(msg) {
10221
+ self2.emit("notification", {
10222
10222
  channel: msg.relname,
10223
10223
  payload: msg.extra
10224
10224
  });
10225
10225
  });
10226
- self.emit("connect");
10227
- self._pulseQueryQueue(true);
10226
+ self2.emit("connect");
10227
+ self2._pulseQueryQueue(true);
10228
10228
  cb(null, this);
10229
10229
  });
10230
10230
  });
@@ -10315,7 +10315,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
10315
10315
  return result;
10316
10316
  };
10317
10317
  Client.prototype.end = function(cb) {
10318
- const self = this;
10318
+ const self2 = this;
10319
10319
  this._ending = true;
10320
10320
  if (!this._connected) {
10321
10321
  this.once("connect", this.end.bind(this, cb));
@@ -10327,10 +10327,10 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
10327
10327
  });
10328
10328
  }
10329
10329
  this.native.end(function() {
10330
- self._connected = false;
10331
- self._errorAllQueries(new Error("Connection terminated"));
10330
+ self2._connected = false;
10331
+ self2._errorAllQueries(new Error("Connection terminated"));
10332
10332
  process.nextTick(() => {
10333
- self.emit("end");
10333
+ self2.emit("end");
10334
10334
  if (cb)
10335
10335
  cb();
10336
10336
  });
@@ -10356,9 +10356,9 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
10356
10356
  }
10357
10357
  this._activeQuery = query;
10358
10358
  query.submit(this);
10359
- const self = this;
10359
+ const self2 = this;
10360
10360
  query.once("_done", function() {
10361
- self._pulseQueryQueue();
10361
+ self2._pulseQueryQueue();
10362
10362
  });
10363
10363
  };
10364
10364
  Client.prototype.cancel = function(query) {
@@ -28623,27 +28623,34 @@ var init_v3 = __esm(() => {
28623
28623
 
28624
28624
  // node_modules/@ai-sdk/provider-utils/node_modules/eventsource-parser/dist/index.js
28625
28625
  function noop(_arg) {}
28626
- function createParser(callbacks) {
28627
- if (typeof callbacks == "function")
28628
- throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");
28629
- const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
28630
- let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
28626
+ function createParser(config2) {
28627
+ if (typeof config2 == "function")
28628
+ throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
28629
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
28630
+ let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
28631
28631
  function feed(chunk) {
28632
+ if (terminated)
28633
+ throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
28632
28634
  if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
28633
28635
  const trailing2 = processLines(chunk);
28634
- trailing2 !== "" && pendingFragments.push(trailing2);
28636
+ trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
28635
28637
  return;
28636
28638
  }
28637
28639
  if (chunk.indexOf(`
28638
28640
  `) === -1 && chunk.indexOf("\r") === -1) {
28639
- pendingFragments.push(chunk);
28641
+ pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
28640
28642
  return;
28641
28643
  }
28642
28644
  pendingFragments.push(chunk);
28643
28645
  const input = pendingFragments.join("");
28644
- pendingFragments.length = 0;
28646
+ pendingFragments.length = 0, pendingFragmentsLength = 0;
28645
28647
  const trailing = processLines(input);
28646
- trailing !== "" && pendingFragments.push(trailing);
28648
+ trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
28649
+ }
28650
+ function checkBufferSize() {
28651
+ maxBufferSize !== undefined && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = undefined, data = "", dataLines = 0, eventType = undefined, onError(new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
28652
+ type: "max-buffer-size-exceeded"
28653
+ }))));
28647
28654
  }
28648
28655
  function processLines(chunk) {
28649
28656
  let searchIndex = 0;
@@ -28755,7 +28762,7 @@ ${value}`, dataLines++;
28755
28762
  const incompleteLine = pendingFragments.join("");
28756
28763
  parseLine(incompleteLine, 0, incompleteLine.length);
28757
28764
  }
28758
- isFirstChunk = true, id = undefined, data = "", dataLines = 0, eventType = undefined, pendingFragments.length = 0;
28765
+ isFirstChunk = true, id = undefined, data = "", dataLines = 0, eventType = undefined, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
28759
28766
  }
28760
28767
  return { feed, reset };
28761
28768
  }
@@ -28779,7 +28786,7 @@ var EventSourceParserStream;
28779
28786
  var init_stream = __esm(() => {
28780
28787
  init_dist3();
28781
28788
  EventSourceParserStream = class EventSourceParserStream extends TransformStream {
28782
- constructor({ onError, onRetry, onComment } = {}) {
28789
+ constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
28783
28790
  let parser;
28784
28791
  super({
28785
28792
  start(controller) {
@@ -28788,10 +28795,11 @@ var init_stream = __esm(() => {
28788
28795
  controller.enqueue(event);
28789
28796
  },
28790
28797
  onError(error40) {
28791
- onError === "terminate" ? controller.error(error40) : typeof onError == "function" && onError(error40);
28798
+ typeof onError == "function" && onError(error40), (onError === "terminate" || error40.type === "max-buffer-size-exceeded") && controller.error(error40);
28792
28799
  },
28793
28800
  onRetry,
28794
- onComment
28801
+ onComment,
28802
+ maxBufferSize
28795
28803
  });
28796
28804
  },
28797
28805
  transform(chunk) {
@@ -30230,7 +30238,7 @@ var DelayedPromise = class {
30230
30238
  });
30231
30239
  }
30232
30240
  return () => `${prefix}${separator}${generator()}`;
30233
- }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.26", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
30241
+ }, generateId, FETCH_FAILED_ERROR_MESSAGES, BUN_ERROR_CODES, VERSION = "4.0.27", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
30234
30242
  url: url2,
30235
30243
  headers = {},
30236
30244
  successfulResponseHandler,
@@ -32369,7 +32377,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
32369
32377
  "ai-model-id": this.modelId
32370
32378
  };
32371
32379
  }
32372
- }, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.110", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
32380
+ }, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.120", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
32373
32381
  var init_dist5 = __esm(() => {
32374
32382
  init_dist4();
32375
32383
  init_dist2();
@@ -32408,13 +32416,15 @@ var init_dist5 = __esm(() => {
32408
32416
  message,
32409
32417
  statusCode = 500,
32410
32418
  cause,
32411
- generationId
32419
+ generationId,
32420
+ isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500)
32412
32421
  }) {
32413
32422
  super(generationId ? `${message} [${generationId}]` : message);
32414
32423
  this[_a17] = true;
32415
32424
  this.statusCode = statusCode;
32416
32425
  this.cause = cause;
32417
32426
  this.generationId = generationId;
32427
+ this.isRetryable = isRetryable;
32418
32428
  }
32419
32429
  static isInstance(error40) {
32420
32430
  return _GatewayError.hasMarker(error40);
@@ -32937,62 +32947,11 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
32937
32947
  gateway = createGatewayProvider();
32938
32948
  });
32939
32949
 
32940
- // node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
32941
- var require_globalThis = __commonJS((exports) => {
32942
- Object.defineProperty(exports, "__esModule", { value: true });
32943
- exports._globalThis = undefined;
32944
- exports._globalThis = typeof globalThis === "object" ? globalThis : global;
32945
- });
32946
-
32947
- // node_modules/@opentelemetry/api/build/src/platform/node/index.js
32948
- var require_node = __commonJS((exports) => {
32949
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
32950
- if (k2 === undefined)
32951
- k2 = k;
32952
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
32953
- return m[k];
32954
- } });
32955
- } : function(o, m, k, k2) {
32956
- if (k2 === undefined)
32957
- k2 = k;
32958
- o[k2] = m[k];
32959
- });
32960
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
32961
- for (var p in m)
32962
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
32963
- __createBinding(exports2, m, p);
32964
- };
32965
- Object.defineProperty(exports, "__esModule", { value: true });
32966
- __exportStar(require_globalThis(), exports);
32967
- });
32968
-
32969
- // node_modules/@opentelemetry/api/build/src/platform/index.js
32970
- var require_platform = __commonJS((exports) => {
32971
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
32972
- if (k2 === undefined)
32973
- k2 = k;
32974
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
32975
- return m[k];
32976
- } });
32977
- } : function(o, m, k, k2) {
32978
- if (k2 === undefined)
32979
- k2 = k;
32980
- o[k2] = m[k];
32981
- });
32982
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
32983
- for (var p in m)
32984
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
32985
- __createBinding(exports2, m, p);
32986
- };
32987
- Object.defineProperty(exports, "__esModule", { value: true });
32988
- __exportStar(require_node(), exports);
32989
- });
32990
-
32991
32950
  // node_modules/@opentelemetry/api/build/src/version.js
32992
32951
  var require_version = __commonJS((exports) => {
32993
32952
  Object.defineProperty(exports, "__esModule", { value: true });
32994
32953
  exports.VERSION = undefined;
32995
- exports.VERSION = "1.9.0";
32954
+ exports.VERSION = "1.9.1";
32996
32955
  });
32997
32956
 
32998
32957
  // node_modules/@opentelemetry/api/build/src/internal/semver.js
@@ -33070,12 +33029,11 @@ var require_semver = __commonJS((exports) => {
33070
33029
  var require_global_utils = __commonJS((exports) => {
33071
33030
  Object.defineProperty(exports, "__esModule", { value: true });
33072
33031
  exports.unregisterGlobal = exports.getGlobal = exports.registerGlobal = undefined;
33073
- var platform_1 = require_platform();
33074
33032
  var version_1 = require_version();
33075
33033
  var semver_1 = require_semver();
33076
33034
  var major = version_1.VERSION.split(".")[0];
33077
33035
  var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for(`opentelemetry.js.api.${major}`);
33078
- var _global = platform_1._globalThis;
33036
+ var _global = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
33079
33037
  function registerGlobal(type, instance, diag, allowOverride = false) {
33080
33038
  var _a16;
33081
33039
  const api2 = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a16 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a16 !== undefined ? _a16 : {
@@ -33147,8 +33105,7 @@ var require_ComponentLogger = __commonJS((exports) => {
33147
33105
  if (!logger) {
33148
33106
  return;
33149
33107
  }
33150
- args.unshift(namespace);
33151
- return logger[funcName](...args);
33108
+ return logger[funcName](namespace, ...args);
33152
33109
  }
33153
33110
  });
33154
33111
 
@@ -33209,6 +33166,12 @@ var require_diag = __commonJS((exports) => {
33209
33166
  var API_NAME = "diag";
33210
33167
 
33211
33168
  class DiagAPI {
33169
+ static instance() {
33170
+ if (!this._instance) {
33171
+ this._instance = new DiagAPI;
33172
+ }
33173
+ return this._instance;
33174
+ }
33212
33175
  constructor() {
33213
33176
  function _logProxy(funcName) {
33214
33177
  return function(...args) {
@@ -33218,12 +33181,12 @@ var require_diag = __commonJS((exports) => {
33218
33181
  return logger[funcName](...args);
33219
33182
  };
33220
33183
  }
33221
- const self = this;
33184
+ const self2 = this;
33222
33185
  const setLogger = (logger, optionsOrLogLevel = { logLevel: types_1.DiagLogLevel.INFO }) => {
33223
33186
  var _a16, _b16, _c;
33224
- if (logger === self) {
33187
+ if (logger === self2) {
33225
33188
  const err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
33226
- self.error((_a16 = err.stack) !== null && _a16 !== undefined ? _a16 : err.message);
33189
+ self2.error((_a16 = err.stack) !== null && _a16 !== undefined ? _a16 : err.message);
33227
33190
  return false;
33228
33191
  }
33229
33192
  if (typeof optionsOrLogLevel === "number") {
@@ -33238,26 +33201,20 @@ var require_diag = __commonJS((exports) => {
33238
33201
  oldLogger.warn(`Current logger will be overwritten from ${stack}`);
33239
33202
  newLogger.warn(`Current logger will overwrite one already registered from ${stack}`);
33240
33203
  }
33241
- return (0, global_utils_1.registerGlobal)("diag", newLogger, self, true);
33204
+ return (0, global_utils_1.registerGlobal)("diag", newLogger, self2, true);
33242
33205
  };
33243
- self.setLogger = setLogger;
33244
- self.disable = () => {
33245
- (0, global_utils_1.unregisterGlobal)(API_NAME, self);
33206
+ self2.setLogger = setLogger;
33207
+ self2.disable = () => {
33208
+ (0, global_utils_1.unregisterGlobal)(API_NAME, self2);
33246
33209
  };
33247
- self.createComponentLogger = (options) => {
33210
+ self2.createComponentLogger = (options) => {
33248
33211
  return new ComponentLogger_1.DiagComponentLogger(options);
33249
33212
  };
33250
- self.verbose = _logProxy("verbose");
33251
- self.debug = _logProxy("debug");
33252
- self.info = _logProxy("info");
33253
- self.warn = _logProxy("warn");
33254
- self.error = _logProxy("error");
33255
- }
33256
- static instance() {
33257
- if (!this._instance) {
33258
- this._instance = new DiagAPI;
33259
- }
33260
- return this._instance;
33213
+ self2.verbose = _logProxy("verbose");
33214
+ self2.debug = _logProxy("debug");
33215
+ self2.info = _logProxy("info");
33216
+ self2.warn = _logProxy("warn");
33217
+ self2.error = _logProxy("error");
33261
33218
  }
33262
33219
  }
33263
33220
  exports.DiagAPI = DiagAPI;
@@ -33280,7 +33237,7 @@ var require_baggage_impl = __commonJS((exports) => {
33280
33237
  return Object.assign({}, entry);
33281
33238
  }
33282
33239
  getAllEntries() {
33283
- return Array.from(this._entries.entries()).map(([k, v]) => [k, v]);
33240
+ return Array.from(this._entries.entries());
33284
33241
  }
33285
33242
  setEntry(key, entry) {
33286
33243
  const newBaggage = new BaggageImpl(this._entries);
@@ -33351,16 +33308,16 @@ var require_context = __commonJS((exports) => {
33351
33308
 
33352
33309
  class BaseContext {
33353
33310
  constructor(parentContext) {
33354
- const self = this;
33355
- self._currentContext = parentContext ? new Map(parentContext) : new Map;
33356
- self.getValue = (key) => self._currentContext.get(key);
33357
- self.setValue = (key, value) => {
33358
- const context = new BaseContext(self._currentContext);
33311
+ const self2 = this;
33312
+ self2._currentContext = parentContext ? new Map(parentContext) : new Map;
33313
+ self2.getValue = (key) => self2._currentContext.get(key);
33314
+ self2.setValue = (key, value) => {
33315
+ const context = new BaseContext(self2._currentContext);
33359
33316
  context._currentContext.set(key, value);
33360
33317
  return context;
33361
33318
  };
33362
- self.deleteValue = (key) => {
33363
- const context = new BaseContext(self._currentContext);
33319
+ self2.deleteValue = (key) => {
33320
+ const context = new BaseContext(self2._currentContext);
33364
33321
  context._currentContext.delete(key);
33365
33322
  return context;
33366
33323
  };
@@ -33372,7 +33329,7 @@ var require_context = __commonJS((exports) => {
33372
33329
  // node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js
33373
33330
  var require_consoleLogger = __commonJS((exports) => {
33374
33331
  Object.defineProperty(exports, "__esModule", { value: true });
33375
- exports.DiagConsoleLogger = undefined;
33332
+ exports.DiagConsoleLogger = exports._originalConsoleMethods = undefined;
33376
33333
  var consoleMap = [
33377
33334
  { n: "error", c: "error" },
33378
33335
  { n: "warn", c: "warn" },
@@ -33380,19 +33337,39 @@ var require_consoleLogger = __commonJS((exports) => {
33380
33337
  { n: "debug", c: "debug" },
33381
33338
  { n: "verbose", c: "trace" }
33382
33339
  ];
33340
+ exports._originalConsoleMethods = {};
33341
+ if (typeof console !== "undefined") {
33342
+ const keys = [
33343
+ "error",
33344
+ "warn",
33345
+ "info",
33346
+ "debug",
33347
+ "trace",
33348
+ "log"
33349
+ ];
33350
+ for (const key of keys) {
33351
+ if (typeof console[key] === "function") {
33352
+ exports._originalConsoleMethods[key] = console[key];
33353
+ }
33354
+ }
33355
+ }
33383
33356
 
33384
33357
  class DiagConsoleLogger {
33385
33358
  constructor() {
33386
33359
  function _consoleFunc(funcName) {
33387
33360
  return function(...args) {
33388
- if (console) {
33389
- let theFunc = console[funcName];
33361
+ let theFunc = exports._originalConsoleMethods[funcName];
33362
+ if (typeof theFunc !== "function") {
33363
+ theFunc = exports._originalConsoleMethods["log"];
33364
+ }
33365
+ if (typeof theFunc !== "function" && console) {
33366
+ theFunc = console[funcName];
33390
33367
  if (typeof theFunc !== "function") {
33391
33368
  theFunc = console.log;
33392
33369
  }
33393
- if (typeof theFunc === "function") {
33394
- return theFunc.apply(console, args);
33395
- }
33370
+ }
33371
+ if (typeof theFunc === "function") {
33372
+ return theFunc.apply(console, args);
33396
33373
  }
33397
33374
  };
33398
33375
  }
@@ -33630,8 +33607,8 @@ var require_NonRecordingSpan = __commonJS((exports) => {
33630
33607
  var invalid_span_constants_1 = require_invalid_span_constants();
33631
33608
 
33632
33609
  class NonRecordingSpan {
33633
- constructor(_spanContext = invalid_span_constants_1.INVALID_SPAN_CONTEXT) {
33634
- this._spanContext = _spanContext;
33610
+ constructor(spanContext = invalid_span_constants_1.INVALID_SPAN_CONTEXT) {
33611
+ this._spanContext = spanContext;
33635
33612
  }
33636
33613
  spanContext() {
33637
33614
  return this._spanContext;
@@ -33707,14 +33684,126 @@ var require_spancontext_utils = __commonJS((exports) => {
33707
33684
  exports.wrapSpanContext = exports.isSpanContextValid = exports.isValidSpanId = exports.isValidTraceId = undefined;
33708
33685
  var invalid_span_constants_1 = require_invalid_span_constants();
33709
33686
  var NonRecordingSpan_1 = require_NonRecordingSpan();
33710
- var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
33711
- var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
33687
+ var isHex = new Uint8Array([
33688
+ 0,
33689
+ 0,
33690
+ 0,
33691
+ 0,
33692
+ 0,
33693
+ 0,
33694
+ 0,
33695
+ 0,
33696
+ 0,
33697
+ 0,
33698
+ 0,
33699
+ 0,
33700
+ 0,
33701
+ 0,
33702
+ 0,
33703
+ 0,
33704
+ 0,
33705
+ 0,
33706
+ 0,
33707
+ 0,
33708
+ 0,
33709
+ 0,
33710
+ 0,
33711
+ 0,
33712
+ 0,
33713
+ 0,
33714
+ 0,
33715
+ 0,
33716
+ 0,
33717
+ 0,
33718
+ 0,
33719
+ 0,
33720
+ 0,
33721
+ 0,
33722
+ 0,
33723
+ 0,
33724
+ 0,
33725
+ 0,
33726
+ 0,
33727
+ 0,
33728
+ 0,
33729
+ 0,
33730
+ 0,
33731
+ 0,
33732
+ 0,
33733
+ 0,
33734
+ 0,
33735
+ 0,
33736
+ 1,
33737
+ 1,
33738
+ 1,
33739
+ 1,
33740
+ 1,
33741
+ 1,
33742
+ 1,
33743
+ 1,
33744
+ 1,
33745
+ 1,
33746
+ 0,
33747
+ 0,
33748
+ 0,
33749
+ 0,
33750
+ 0,
33751
+ 0,
33752
+ 0,
33753
+ 1,
33754
+ 1,
33755
+ 1,
33756
+ 1,
33757
+ 1,
33758
+ 1,
33759
+ 0,
33760
+ 0,
33761
+ 0,
33762
+ 0,
33763
+ 0,
33764
+ 0,
33765
+ 0,
33766
+ 0,
33767
+ 0,
33768
+ 0,
33769
+ 0,
33770
+ 0,
33771
+ 0,
33772
+ 0,
33773
+ 0,
33774
+ 0,
33775
+ 0,
33776
+ 0,
33777
+ 0,
33778
+ 0,
33779
+ 0,
33780
+ 0,
33781
+ 0,
33782
+ 0,
33783
+ 0,
33784
+ 0,
33785
+ 1,
33786
+ 1,
33787
+ 1,
33788
+ 1,
33789
+ 1,
33790
+ 1
33791
+ ]);
33792
+ function isValidHex(id, length) {
33793
+ if (typeof id !== "string" || id.length !== length)
33794
+ return false;
33795
+ let r = 0;
33796
+ for (let i = 0;i < id.length; i += 4) {
33797
+ r += (isHex[id.charCodeAt(i)] | 0) + (isHex[id.charCodeAt(i + 1)] | 0) + (isHex[id.charCodeAt(i + 2)] | 0) + (isHex[id.charCodeAt(i + 3)] | 0);
33798
+ }
33799
+ return r === length;
33800
+ }
33712
33801
  function isValidTraceId(traceId) {
33713
- return VALID_TRACEID_REGEX.test(traceId) && traceId !== invalid_span_constants_1.INVALID_TRACEID;
33802
+ return isValidHex(traceId, 32) && traceId !== invalid_span_constants_1.INVALID_TRACEID;
33714
33803
  }
33715
33804
  exports.isValidTraceId = isValidTraceId;
33716
33805
  function isValidSpanId(spanId) {
33717
- return VALID_SPANID_REGEX.test(spanId) && spanId !== invalid_span_constants_1.INVALID_SPANID;
33806
+ return isValidHex(spanId, 16) && spanId !== invalid_span_constants_1.INVALID_SPANID;
33718
33807
  }
33719
33808
  exports.isValidSpanId = isValidSpanId;
33720
33809
  function isSpanContextValid(spanContext) {
@@ -33774,7 +33863,7 @@ var require_NoopTracer = __commonJS((exports) => {
33774
33863
  }
33775
33864
  exports.NoopTracer = NoopTracer;
33776
33865
  function isSpanContext(spanContext) {
33777
- return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
33866
+ return spanContext !== null && typeof spanContext === "object" && "spanId" in spanContext && typeof spanContext["spanId"] === "string" && "traceId" in spanContext && typeof spanContext["traceId"] === "string" && "traceFlags" in spanContext && typeof spanContext["traceFlags"] === "number";
33778
33867
  }
33779
33868
  });
33780
33869
 
@@ -33786,8 +33875,8 @@ var require_ProxyTracer = __commonJS((exports) => {
33786
33875
  var NOOP_TRACER = new NoopTracer_1.NoopTracer;
33787
33876
 
33788
33877
  class ProxyTracer {
33789
- constructor(_provider, name15, version2, options) {
33790
- this._provider = _provider;
33878
+ constructor(provider, name15, version2, options) {
33879
+ this._provider = provider;
33791
33880
  this.name = name15;
33792
33881
  this.version = version2;
33793
33882
  this.options = options;
@@ -33947,7 +34036,7 @@ var require_tracestate_impl = __commonJS((exports) => {
33947
34036
  return this._internalState.get(key);
33948
34037
  }
33949
34038
  serialize() {
33950
- return this._keys().reduce((agg, key) => {
34039
+ return Array.from(this._internalState.keys()).reduceRight((agg, key) => {
33951
34040
  agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + this.get(key));
33952
34041
  return agg;
33953
34042
  }, []).join(LIST_MEMBERS_SEPARATOR);
@@ -33955,7 +34044,7 @@ var require_tracestate_impl = __commonJS((exports) => {
33955
34044
  _parse(rawTraceState) {
33956
34045
  if (rawTraceState.length > MAX_TRACE_STATE_LEN)
33957
34046
  return;
33958
- this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reverse().reduce((agg, part) => {
34047
+ this._internalState = rawTraceState.split(LIST_MEMBERS_SEPARATOR).reduceRight((agg, part) => {
33959
34048
  const listMember = part.trim();
33960
34049
  const i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER);
33961
34050
  if (i !== -1) {
@@ -35055,7 +35144,10 @@ function convertToLanguageModelMessage({
35055
35144
  type: "tool-result",
35056
35145
  toolCallId: part.toolCallId,
35057
35146
  toolName: part.toolName,
35058
- output: mapToolResultOutput(part.output),
35147
+ output: mapToolResultOutput({
35148
+ output: part.output,
35149
+ downloadedAssets
35150
+ }),
35059
35151
  providerOptions
35060
35152
  };
35061
35153
  }
@@ -35074,7 +35166,10 @@ function convertToLanguageModelMessage({
35074
35166
  type: "tool-result",
35075
35167
  toolCallId: part.toolCallId,
35076
35168
  toolName: part.toolName,
35077
- output: mapToolResultOutput(part.output),
35169
+ output: mapToolResultOutput({
35170
+ output: part.output,
35171
+ downloadedAssets
35172
+ }),
35078
35173
  providerOptions: part.providerOptions
35079
35174
  };
35080
35175
  }
@@ -35098,15 +35193,44 @@ function convertToLanguageModelMessage({
35098
35193
  }
35099
35194
  }
35100
35195
  async function downloadAssets(messages, download2, supportedUrls) {
35101
- const plannedDownloads = messages.filter((message) => message.role === "user").map((message) => message.content).filter((content) => Array.isArray(content)).flat().filter((part) => part.type === "image" || part.type === "file").map((part) => {
35102
- var _a21;
35103
- const mediaType = (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : undefined;
35104
- let data = part.type === "image" ? part.image : part.data;
35105
- if (typeof data === "string") {
35106
- try {
35107
- data = new URL(data);
35108
- } catch (ignored) {}
35196
+ var _a21;
35197
+ const downloadableFiles = [];
35198
+ for (const message of messages) {
35199
+ if (message.role === "user" && Array.isArray(message.content)) {
35200
+ for (const part of message.content) {
35201
+ if (part.type === "image" || part.type === "file") {
35202
+ downloadableFiles.push({
35203
+ data: part.type === "image" ? part.image : part.data,
35204
+ mediaType: (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : undefined
35205
+ });
35206
+ }
35207
+ }
35208
+ }
35209
+ if (message.role === "tool" || message.role === "assistant") {
35210
+ if (!Array.isArray(message.content)) {
35211
+ continue;
35212
+ }
35213
+ for (const part of message.content) {
35214
+ if (part.type !== "tool-result") {
35215
+ continue;
35216
+ }
35217
+ if (part.output.type !== "content") {
35218
+ continue;
35219
+ }
35220
+ for (const contentPart of part.output.value) {
35221
+ if (contentPart.type === "image-url" || contentPart.type === "file-url") {
35222
+ downloadableFiles.push({
35223
+ data: new URL(contentPart.url),
35224
+ mediaType: contentPart.type === "image-url" ? "image/*" : undefined
35225
+ });
35226
+ }
35227
+ }
35228
+ }
35109
35229
  }
35230
+ }
35231
+ const plannedDownloads = downloadableFiles.map((part) => {
35232
+ const mediaType = part.mediaType;
35233
+ const { data } = convertToLanguageModelV3DataContent(part.data);
35110
35234
  return { mediaType, data };
35111
35235
  }).filter((part) => part.data instanceof URL).map((part) => ({
35112
35236
  url: part.data,
@@ -35180,13 +35304,41 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
35180
35304
  }
35181
35305
  }
35182
35306
  }
35183
- function mapToolResultOutput(output) {
35307
+ function mapToolResultOutput({
35308
+ output,
35309
+ downloadedAssets
35310
+ }) {
35184
35311
  if (output.type !== "content") {
35185
35312
  return output;
35186
35313
  }
35187
35314
  return {
35188
35315
  type: "content",
35189
35316
  value: output.value.map((item) => {
35317
+ var _a21, _b16;
35318
+ if (item.type === "image-url") {
35319
+ const downloadedFile = downloadedAssets[new URL(item.url).toString()];
35320
+ if (downloadedFile) {
35321
+ return {
35322
+ type: "image-data",
35323
+ data: convertDataContentToBase64String(downloadedFile.data),
35324
+ mediaType: (_a21 = downloadedFile.mediaType) != null ? _a21 : "image/*",
35325
+ providerOptions: item.providerOptions
35326
+ };
35327
+ }
35328
+ return item;
35329
+ }
35330
+ if (item.type === "file-url") {
35331
+ const downloadedFile = downloadedAssets[new URL(item.url).toString()];
35332
+ if (downloadedFile) {
35333
+ return {
35334
+ type: "file-data",
35335
+ data: convertDataContentToBase64String(downloadedFile.data),
35336
+ mediaType: (_b16 = downloadedFile.mediaType) != null ? _b16 : "application/octet-stream",
35337
+ providerOptions: item.providerOptions
35338
+ };
35339
+ }
35340
+ return item;
35341
+ }
35190
35342
  if (item.type !== "media") {
35191
35343
  return item;
35192
35344
  }
@@ -35739,7 +35891,7 @@ function getRetryDelayInMs({
35739
35891
  error: error40,
35740
35892
  exponentialBackoffDelay
35741
35893
  }) {
35742
- const headers = error40.responseHeaders;
35894
+ const headers = APICallError.isInstance(error40) ? error40.responseHeaders : APICallError.isInstance(error40.cause) ? error40.cause.responseHeaders : undefined;
35743
35895
  if (!headers)
35744
35896
  return exponentialBackoffDelay;
35745
35897
  let ms;
@@ -35789,7 +35941,7 @@ async function _retryWithExponentialBackoff(f, {
35789
35941
  errors: newErrors
35790
35942
  });
35791
35943
  }
35792
- if (error40 instanceof Error && APICallError.isInstance(error40) && error40.isRetryable === true && tryNumber <= maxRetries) {
35944
+ if (error40 instanceof Error && (APICallError.isInstance(error40) && error40.isRetryable === true || GatewayError.isInstance(error40) && error40.isRetryable === true) && tryNumber <= maxRetries) {
35793
35945
  await delay(getRetryDelayInMs({
35794
35946
  error: error40,
35795
35947
  exponentialBackoffDelay: delayInMs
@@ -36007,7 +36159,8 @@ async function executeToolCall({
36007
36159
  input,
36008
36160
  error: error40,
36009
36161
  dynamic: tool2.type === "dynamic",
36010
- ...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
36162
+ ...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {},
36163
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
36011
36164
  };
36012
36165
  }
36013
36166
  const durationMs = now2() - startTime;
@@ -36037,7 +36190,8 @@ async function executeToolCall({
36037
36190
  input,
36038
36191
  output,
36039
36192
  dynamic: tool2.type === "dynamic",
36040
- ...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {}
36193
+ ...toolCall.providerMetadata != null ? { providerMetadata: toolCall.providerMetadata } : {},
36194
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
36041
36195
  };
36042
36196
  }
36043
36197
  });
@@ -36402,15 +36556,6 @@ async function parsePartialJson(jsonText) {
36402
36556
  }
36403
36557
  return { value: undefined, state: "failed-parse" };
36404
36558
  }
36405
- function mergeToolProviderMetadata(toolMetadata, callMetadata) {
36406
- if (toolMetadata == null) {
36407
- return callMetadata;
36408
- }
36409
- if (callMetadata == null) {
36410
- return toolMetadata;
36411
- }
36412
- return { ...toolMetadata, ...callMetadata };
36413
- }
36414
36559
  async function parseToolCall({
36415
36560
  toolCall,
36416
36561
  tools,
@@ -36418,7 +36563,6 @@ async function parseToolCall({
36418
36563
  system,
36419
36564
  messages
36420
36565
  }) {
36421
- var _a21, _b16;
36422
36566
  try {
36423
36567
  if (tools == null) {
36424
36568
  if (toolCall.providerExecuted && toolCall.dynamic) {
@@ -36459,6 +36603,7 @@ async function parseToolCall({
36459
36603
  } catch (error40) {
36460
36604
  const parsedInput = await safeParseJSON({ text: toolCall.input });
36461
36605
  const input = parsedInput.success ? parsedInput.value : toolCall.input;
36606
+ const tool2 = tools == null ? undefined : tools[toolCall.toolName];
36462
36607
  return {
36463
36608
  type: "tool-call",
36464
36609
  toolCallId: toolCall.toolCallId,
@@ -36467,9 +36612,10 @@ async function parseToolCall({
36467
36612
  dynamic: true,
36468
36613
  invalid: true,
36469
36614
  error: error40,
36470
- title: (_a21 = tools == null ? undefined : tools[toolCall.toolName]) == null ? undefined : _a21.title,
36615
+ title: tool2 == null ? undefined : tool2.title,
36471
36616
  providerExecuted: toolCall.providerExecuted,
36472
- providerMetadata: mergeToolProviderMetadata((_b16 = tools == null ? undefined : tools[toolCall.toolName]) == null ? undefined : _b16.providerMetadata, toolCall.providerMetadata)
36617
+ providerMetadata: toolCall.providerMetadata,
36618
+ ...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
36473
36619
  };
36474
36620
  }
36475
36621
  }
@@ -36516,14 +36662,14 @@ async function doParseToolCall({
36516
36662
  cause: parseResult.error
36517
36663
  });
36518
36664
  }
36519
- const mergedProviderMetadata = mergeToolProviderMetadata(tool2.providerMetadata, toolCall.providerMetadata);
36520
36665
  return tool2.type === "dynamic" ? {
36521
36666
  type: "tool-call",
36522
36667
  toolCallId: toolCall.toolCallId,
36523
36668
  toolName: toolCall.toolName,
36524
36669
  input: parseResult.value,
36525
36670
  providerExecuted: toolCall.providerExecuted,
36526
- providerMetadata: mergedProviderMetadata,
36671
+ providerMetadata: toolCall.providerMetadata,
36672
+ ...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},
36527
36673
  dynamic: true,
36528
36674
  title: tool2.title
36529
36675
  } : {
@@ -36532,7 +36678,8 @@ async function doParseToolCall({
36532
36678
  toolName,
36533
36679
  input: parseResult.value,
36534
36680
  providerExecuted: toolCall.providerExecuted,
36535
- providerMetadata: mergedProviderMetadata,
36681
+ providerMetadata: toolCall.providerMetadata,
36682
+ ...tool2.metadata != null ? { toolMetadata: tool2.metadata } : {},
36536
36683
  title: tool2.title
36537
36684
  };
36538
36685
  }
@@ -37364,7 +37511,8 @@ function asContent({
37364
37511
  error: part.result,
37365
37512
  providerExecuted: true,
37366
37513
  dynamic: part.dynamic,
37367
- ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
37514
+ ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
37515
+ ...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
37368
37516
  });
37369
37517
  } else {
37370
37518
  contentParts.push({
@@ -37375,7 +37523,8 @@ function asContent({
37375
37523
  output: part.result,
37376
37524
  providerExecuted: true,
37377
37525
  dynamic: part.dynamic,
37378
- ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
37526
+ ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
37527
+ ...(tool2 == null ? undefined : tool2.metadata) != null ? { toolMetadata: tool2.metadata } : {}
37379
37528
  });
37380
37529
  }
37381
37530
  break;
@@ -37389,7 +37538,8 @@ function asContent({
37389
37538
  error: part.result,
37390
37539
  providerExecuted: true,
37391
37540
  dynamic: toolCall.dynamic,
37392
- ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
37541
+ ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
37542
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
37393
37543
  });
37394
37544
  } else {
37395
37545
  contentParts.push({
@@ -37400,7 +37550,8 @@ function asContent({
37400
37550
  output: part.result,
37401
37551
  providerExecuted: true,
37402
37552
  dynamic: toolCall.dynamic,
37403
- ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
37553
+ ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
37554
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
37404
37555
  });
37405
37556
  }
37406
37557
  break;
@@ -37614,6 +37765,9 @@ function processUIMessageStream({
37614
37765
  if (options.title !== undefined) {
37615
37766
  anyPart.title = options.title;
37616
37767
  }
37768
+ if (options.toolMetadata !== undefined) {
37769
+ anyPart.toolMetadata = options.toolMetadata;
37770
+ }
37617
37771
  anyPart.providerExecuted = (_a222 = anyOptions.providerExecuted) != null ? _a222 : part.providerExecuted;
37618
37772
  const providerMetadata = anyOptions.providerMetadata;
37619
37773
  if (providerMetadata != null) {
@@ -37630,6 +37784,7 @@ function processUIMessageStream({
37630
37784
  toolCallId: options.toolCallId,
37631
37785
  state: options.state,
37632
37786
  title: options.title,
37787
+ ...options.toolMetadata !== undefined ? { toolMetadata: options.toolMetadata } : {},
37633
37788
  input: anyOptions.input,
37634
37789
  output: anyOptions.output,
37635
37790
  rawInput: anyOptions.rawInput,
@@ -37657,6 +37812,9 @@ function processUIMessageStream({
37657
37812
  if (options.title !== undefined) {
37658
37813
  anyPart.title = options.title;
37659
37814
  }
37815
+ if (options.toolMetadata !== undefined) {
37816
+ anyPart.toolMetadata = options.toolMetadata;
37817
+ }
37660
37818
  anyPart.providerExecuted = (_b23 = anyOptions.providerExecuted) != null ? _b23 : part.providerExecuted;
37661
37819
  const providerMetadata = anyOptions.providerMetadata;
37662
37820
  if (providerMetadata != null) {
@@ -37679,6 +37837,7 @@ function processUIMessageStream({
37679
37837
  preliminary: anyOptions.preliminary,
37680
37838
  providerExecuted: anyOptions.providerExecuted,
37681
37839
  title: options.title,
37840
+ ...options.toolMetadata !== undefined ? { toolMetadata: options.toolMetadata } : {},
37682
37841
  ...anyOptions.providerMetadata != null && (options.state === "output-available" || options.state === "output-error") ? { resultProviderMetadata: anyOptions.providerMetadata } : {},
37683
37842
  ...anyOptions.providerMetadata != null && !(options.state === "output-available" || options.state === "output-error") ? { callProviderMetadata: anyOptions.providerMetadata } : {}
37684
37843
  });
@@ -37823,7 +37982,8 @@ function processUIMessageStream({
37823
37982
  toolName: chunk.toolName,
37824
37983
  index: toolInvocations.length,
37825
37984
  dynamic: chunk.dynamic,
37826
- title: chunk.title
37985
+ title: chunk.title,
37986
+ toolMetadata: chunk.toolMetadata
37827
37987
  };
37828
37988
  if (chunk.dynamic) {
37829
37989
  updateDynamicToolPart({
@@ -37833,6 +37993,7 @@ function processUIMessageStream({
37833
37993
  input: undefined,
37834
37994
  providerExecuted: chunk.providerExecuted,
37835
37995
  title: chunk.title,
37996
+ toolMetadata: chunk.toolMetadata,
37836
37997
  providerMetadata: chunk.providerMetadata
37837
37998
  });
37838
37999
  } else {
@@ -37843,6 +38004,7 @@ function processUIMessageStream({
37843
38004
  input: undefined,
37844
38005
  providerExecuted: chunk.providerExecuted,
37845
38006
  title: chunk.title,
38007
+ toolMetadata: chunk.toolMetadata,
37846
38008
  providerMetadata: chunk.providerMetadata
37847
38009
  });
37848
38010
  }
@@ -37866,7 +38028,8 @@ function processUIMessageStream({
37866
38028
  toolName: partialToolCall.toolName,
37867
38029
  state: "input-streaming",
37868
38030
  input: partialArgs,
37869
- title: partialToolCall.title
38031
+ title: partialToolCall.title,
38032
+ toolMetadata: partialToolCall.toolMetadata
37870
38033
  });
37871
38034
  } else {
37872
38035
  updateToolPart({
@@ -37874,7 +38037,8 @@ function processUIMessageStream({
37874
38037
  toolName: partialToolCall.toolName,
37875
38038
  state: "input-streaming",
37876
38039
  input: partialArgs,
37877
- title: partialToolCall.title
38040
+ title: partialToolCall.title,
38041
+ toolMetadata: partialToolCall.toolMetadata
37878
38042
  });
37879
38043
  }
37880
38044
  write();
@@ -37889,7 +38053,8 @@ function processUIMessageStream({
37889
38053
  input: chunk.input,
37890
38054
  providerExecuted: chunk.providerExecuted,
37891
38055
  providerMetadata: chunk.providerMetadata,
37892
- title: chunk.title
38056
+ title: chunk.title,
38057
+ toolMetadata: chunk.toolMetadata
37893
38058
  });
37894
38059
  } else {
37895
38060
  updateToolPart({
@@ -37899,7 +38064,8 @@ function processUIMessageStream({
37899
38064
  input: chunk.input,
37900
38065
  providerExecuted: chunk.providerExecuted,
37901
38066
  providerMetadata: chunk.providerMetadata,
37902
- title: chunk.title
38067
+ title: chunk.title,
38068
+ toolMetadata: chunk.toolMetadata
37903
38069
  });
37904
38070
  }
37905
38071
  write();
@@ -37921,7 +38087,8 @@ function processUIMessageStream({
37921
38087
  input: chunk.input,
37922
38088
  errorText: chunk.errorText,
37923
38089
  providerExecuted: chunk.providerExecuted,
37924
- providerMetadata: chunk.providerMetadata
38090
+ providerMetadata: chunk.providerMetadata,
38091
+ toolMetadata: chunk.toolMetadata
37925
38092
  });
37926
38093
  } else {
37927
38094
  updateToolPart({
@@ -37932,7 +38099,8 @@ function processUIMessageStream({
37932
38099
  rawInput: chunk.input,
37933
38100
  errorText: chunk.errorText,
37934
38101
  providerExecuted: chunk.providerExecuted,
37935
- providerMetadata: chunk.providerMetadata
38102
+ providerMetadata: chunk.providerMetadata,
38103
+ toolMetadata: chunk.toolMetadata
37936
38104
  });
37937
38105
  }
37938
38106
  write();
@@ -37963,7 +38131,8 @@ function processUIMessageStream({
37963
38131
  preliminary: chunk.preliminary,
37964
38132
  providerExecuted: chunk.providerExecuted,
37965
38133
  providerMetadata: chunk.providerMetadata,
37966
- title: toolInvocation.title
38134
+ title: toolInvocation.title,
38135
+ toolMetadata: toolInvocation.toolMetadata
37967
38136
  });
37968
38137
  } else {
37969
38138
  updateToolPart({
@@ -37975,7 +38144,8 @@ function processUIMessageStream({
37975
38144
  providerExecuted: chunk.providerExecuted,
37976
38145
  preliminary: chunk.preliminary,
37977
38146
  providerMetadata: chunk.providerMetadata,
37978
- title: toolInvocation.title
38147
+ title: toolInvocation.title,
38148
+ toolMetadata: toolInvocation.toolMetadata
37979
38149
  });
37980
38150
  }
37981
38151
  write();
@@ -37992,7 +38162,8 @@ function processUIMessageStream({
37992
38162
  errorText: chunk.errorText,
37993
38163
  providerExecuted: chunk.providerExecuted,
37994
38164
  providerMetadata: chunk.providerMetadata,
37995
- title: toolInvocation.title
38165
+ title: toolInvocation.title,
38166
+ toolMetadata: toolInvocation.toolMetadata
37996
38167
  });
37997
38168
  } else {
37998
38169
  updateToolPart({
@@ -38004,7 +38175,8 @@ function processUIMessageStream({
38004
38175
  errorText: chunk.errorText,
38005
38176
  providerExecuted: chunk.providerExecuted,
38006
38177
  providerMetadata: chunk.providerMetadata,
38007
- title: toolInvocation.title
38178
+ title: toolInvocation.title,
38179
+ toolMetadata: toolInvocation.toolMetadata
38008
38180
  });
38009
38181
  }
38010
38182
  write();
@@ -38462,7 +38634,8 @@ function runToolsTransformation({
38462
38634
  input: toolCall.input,
38463
38635
  error: getErrorMessage2(toolCall.error),
38464
38636
  dynamic: true,
38465
- title: toolCall.title
38637
+ title: toolCall.title,
38638
+ ...toolCall.toolMetadata != null ? { toolMetadata: toolCall.toolMetadata } : {}
38466
38639
  });
38467
38640
  break;
38468
38641
  }
@@ -38530,6 +38703,7 @@ function runToolsTransformation({
38530
38703
  }
38531
38704
  case "tool-result": {
38532
38705
  const toolName = chunk.toolName;
38706
+ const toolCall = toolCallsByToolCallId.get(chunk.toolCallId);
38533
38707
  if (chunk.isError) {
38534
38708
  toolResultsStreamController.enqueue({
38535
38709
  type: "tool-error",
@@ -38539,7 +38713,8 @@ function runToolsTransformation({
38539
38713
  providerExecuted: true,
38540
38714
  error: chunk.result,
38541
38715
  dynamic: chunk.dynamic,
38542
- ...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
38716
+ ...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {},
38717
+ ...(toolCall == null ? undefined : toolCall.toolMetadata) != null ? { toolMetadata: toolCall.toolMetadata } : {}
38543
38718
  });
38544
38719
  } else {
38545
38720
  controller.enqueue({
@@ -38550,7 +38725,8 @@ function runToolsTransformation({
38550
38725
  output: chunk.result,
38551
38726
  providerExecuted: true,
38552
38727
  dynamic: chunk.dynamic,
38553
- ...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
38728
+ ...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {},
38729
+ ...(toolCall == null ? undefined : toolCall.toolMetadata) != null ? { toolMetadata: toolCall.toolMetadata } : {}
38554
38730
  });
38555
38731
  }
38556
38732
  break;
@@ -39333,7 +39509,7 @@ async function embed({
39333
39509
  }),
39334
39510
  tracer,
39335
39511
  fn: async (doEmbedSpan) => {
39336
- var _a21;
39512
+ var _a21, _b16;
39337
39513
  const modelResponse = await model.doEmbed({
39338
39514
  values: [value],
39339
39515
  abortSignal,
@@ -39354,7 +39530,7 @@ async function embed({
39354
39530
  return {
39355
39531
  embedding: embedding2,
39356
39532
  usage: usage2,
39357
- warnings: modelResponse.warnings,
39533
+ warnings: (_b16 = modelResponse.warnings) != null ? _b16 : [],
39358
39534
  providerMetadata: modelResponse.providerMetadata,
39359
39535
  response: modelResponse.response
39360
39536
  };
@@ -39450,7 +39626,7 @@ async function embedMany({
39450
39626
  }),
39451
39627
  tracer,
39452
39628
  fn: async (doEmbedSpan) => {
39453
- var _a222;
39629
+ var _a222, _b16;
39454
39630
  const modelResponse = await model.doEmbed({
39455
39631
  values,
39456
39632
  abortSignal,
@@ -39471,7 +39647,7 @@ async function embedMany({
39471
39647
  return {
39472
39648
  embeddings: embeddings3,
39473
39649
  usage: usage2,
39474
- warnings: modelResponse.warnings,
39650
+ warnings: (_b16 = modelResponse.warnings) != null ? _b16 : [],
39475
39651
  providerMetadata: modelResponse.providerMetadata,
39476
39652
  response: modelResponse.response
39477
39653
  };
@@ -39528,7 +39704,7 @@ async function embedMany({
39528
39704
  }),
39529
39705
  tracer,
39530
39706
  fn: async (doEmbedSpan) => {
39531
- var _a222;
39707
+ var _a222, _b16;
39532
39708
  const modelResponse = await model.doEmbed({
39533
39709
  values: chunk,
39534
39710
  abortSignal,
@@ -39549,7 +39725,7 @@ async function embedMany({
39549
39725
  return {
39550
39726
  embeddings: embeddings2,
39551
39727
  usage,
39552
- warnings: modelResponse.warnings,
39728
+ warnings: (_b16 = modelResponse.warnings) != null ? _b16 : [],
39553
39729
  providerMetadata: modelResponse.providerMetadata,
39554
39730
  response: modelResponse.response
39555
39731
  };
@@ -41663,7 +41839,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
41663
41839
  const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
41664
41840
  const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
41665
41841
  return bytes.slice(id3Size + 10);
41666
- }, VERSION3 = "6.0.175", download = async ({
41842
+ }, VERSION3 = "6.0.191", download = async ({
41667
41843
  url: url2,
41668
41844
  maxBytes,
41669
41845
  abortSignal
@@ -42171,7 +42347,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
42171
42347
  }
42172
42348
  return this._output;
42173
42349
  }
42174
- }, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
42350
+ }, JsonToSseTransformStream, UI_MESSAGE_STREAM_HEADERS, toolMetadataSchema, uiMessageChunkSchema, isToolOrDynamicToolUIPart, getToolOrDynamicToolName, originalGenerateId2, DefaultStreamTextResult = class {
42175
42351
  constructor({
42176
42352
  model,
42177
42353
  telemetry,
@@ -42401,18 +42577,18 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
42401
42577
  const error40 = (abortSignal == null ? undefined : abortSignal.aborted) ? abortSignal.reason : new NoOutputGeneratedError({
42402
42578
  message: "No output generated. Check the stream for errors."
42403
42579
  });
42404
- self._finishReason.reject(error40);
42405
- self._rawFinishReason.reject(error40);
42406
- self._totalUsage.reject(error40);
42407
- self._steps.reject(error40);
42580
+ self2._finishReason.reject(error40);
42581
+ self2._rawFinishReason.reject(error40);
42582
+ self2._totalUsage.reject(error40);
42583
+ self2._steps.reject(error40);
42408
42584
  return;
42409
42585
  }
42410
42586
  const finishReason = recordedFinishReason != null ? recordedFinishReason : "other";
42411
42587
  const totalUsage = recordedTotalUsage != null ? recordedTotalUsage : createNullLanguageModelUsage();
42412
- self._finishReason.resolve(finishReason);
42413
- self._rawFinishReason.resolve(recordedRawFinishReason);
42414
- self._totalUsage.resolve(totalUsage);
42415
- self._steps.resolve(recordedSteps);
42588
+ self2._finishReason.resolve(finishReason);
42589
+ self2._rawFinishReason.resolve(recordedRawFinishReason);
42590
+ self2._totalUsage.resolve(totalUsage);
42591
+ self2._steps.resolve(recordedSteps);
42416
42592
  const finalStep = recordedSteps[recordedSteps.length - 1];
42417
42593
  await notify({
42418
42594
  event: {
@@ -42543,7 +42719,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
42543
42719
  headers,
42544
42720
  settings: { ...callSettings, maxRetries }
42545
42721
  });
42546
- const self = this;
42722
+ const self2 = this;
42547
42723
  const modelInfo = { provider: model.provider, modelId: model.modelId };
42548
42724
  const callbackTelemetryProps = {
42549
42725
  functionId: telemetry == null ? undefined : telemetry.functionId,
@@ -42617,7 +42793,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
42617
42793
  toolExecutionStepStreamController = controller;
42618
42794
  }
42619
42795
  });
42620
- self.addStream(toolExecutionStepStream);
42796
+ self2.addStream(toolExecutionStepStream);
42621
42797
  try {
42622
42798
  for (const toolApproval of [
42623
42799
  ...localDeniedToolApprovals,
@@ -42701,7 +42877,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
42701
42877
  usage
42702
42878
  }) {
42703
42879
  var _a21, _b16, _c, _d, _e, _f, _g, _h, _i;
42704
- const includeRawChunks2 = self.includeRawChunks;
42880
+ const includeRawChunks2 = self2.includeRawChunks;
42705
42881
  const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : undefined;
42706
42882
  let chunkTimeoutId = undefined;
42707
42883
  function resetChunkTimeout() {
@@ -42873,7 +43049,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
42873
43049
  modelId: modelInfo.modelId
42874
43050
  };
42875
43051
  let activeText = "";
42876
- self.addStream(streamWithToolResults.pipeThrough(new TransformStream({
43052
+ self2.addStream(streamWithToolResults.pipeThrough(new TransformStream({
42877
43053
  async transform(chunk, controller) {
42878
43054
  var _a222, _b23, _c2, _d2, _e2;
42879
43055
  resetChunkTimeout();
@@ -43136,7 +43312,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
43136
43312
  type: "error",
43137
43313
  error: error40
43138
43314
  });
43139
- self.closeStream();
43315
+ self2.closeStream();
43140
43316
  }
43141
43317
  } else {
43142
43318
  controller.enqueue({
@@ -43145,7 +43321,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
43145
43321
  rawFinishReason: stepRawFinishReason,
43146
43322
  totalUsage: combinedUsage
43147
43323
  });
43148
- self.closeStream();
43324
+ self2.closeStream();
43149
43325
  }
43150
43326
  }
43151
43327
  })));
@@ -43161,13 +43337,13 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
43161
43337
  });
43162
43338
  }
43163
43339
  }).catch((error40) => {
43164
- self.addStream(new ReadableStream({
43340
+ self2.addStream(new ReadableStream({
43165
43341
  start(controller) {
43166
43342
  controller.enqueue({ type: "error", error: error40 });
43167
43343
  controller.close();
43168
43344
  }
43169
43345
  }));
43170
- self.closeStream();
43346
+ self2.closeStream();
43171
43347
  });
43172
43348
  }
43173
43349
  get steps() {
@@ -43419,6 +43595,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
43419
43595
  toolName: part.toolName,
43420
43596
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
43421
43597
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
43598
+ ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
43422
43599
  ...dynamic != null ? { dynamic } : {},
43423
43600
  ...part.title != null ? { title: part.title } : {}
43424
43601
  });
@@ -43442,6 +43619,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
43442
43619
  input: part.input,
43443
43620
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
43444
43621
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
43622
+ ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
43445
43623
  ...dynamic != null ? { dynamic } : {},
43446
43624
  errorText: onError(part.error),
43447
43625
  ...part.title != null ? { title: part.title } : {}
@@ -43454,6 +43632,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
43454
43632
  input: part.input,
43455
43633
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
43456
43634
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
43635
+ ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
43457
43636
  ...dynamic != null ? { dynamic } : {},
43458
43637
  ...part.title != null ? { title: part.title } : {}
43459
43638
  });
@@ -43476,6 +43655,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
43476
43655
  output: part.output,
43477
43656
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
43478
43657
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
43658
+ ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
43479
43659
  ...part.preliminary != null ? { preliminary: part.preliminary } : {},
43480
43660
  ...dynamic != null ? { dynamic } : {}
43481
43661
  });
@@ -43489,6 +43669,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
43489
43669
  errorText: part.providerExecuted ? typeof part.error === "string" ? part.error : JSON.stringify(part.error) : onError(part.error),
43490
43670
  ...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
43491
43671
  ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
43672
+ ...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
43492
43673
  ...dynamic != null ? { dynamic } : {}
43493
43674
  });
43494
43675
  break;
@@ -43662,10 +43843,21 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
43662
43843
  ...options
43663
43844
  };
43664
43845
  const preparedCallArgs = (_d = await ((_c = (_b16 = this.settings).prepareCall) == null ? undefined : _c.call(_b16, baseCallArgs))) != null ? _d : baseCallArgs;
43665
- const { instructions, messages, prompt, ...callArgs } = preparedCallArgs;
43846
+ const {
43847
+ instructions,
43848
+ allowSystemInMessages,
43849
+ messages,
43850
+ prompt,
43851
+ ...callArgs
43852
+ } = preparedCallArgs;
43666
43853
  return {
43667
43854
  ...callArgs,
43668
- ...{ system: instructions, messages, prompt }
43855
+ ...{
43856
+ system: instructions,
43857
+ allowSystemInMessages,
43858
+ messages,
43859
+ prompt
43860
+ }
43669
43861
  };
43670
43862
  }
43671
43863
  mergeOnStepFinishCallbacks(methodCallback) {
@@ -43706,7 +43898,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
43706
43898
  onStepFinish: this.mergeOnStepFinishCallbacks(onStepFinish)
43707
43899
  });
43708
43900
  }
43709
- }, uiMessagesSchema, DefaultEmbedResult = class {
43901
+ }, toolMetadataSchema2, uiMessagesSchema, DefaultEmbedResult = class {
43710
43902
  constructor(options) {
43711
43903
  this.value = options.value;
43712
43904
  this.embedding = options.embedding;
@@ -44022,7 +44214,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
44022
44214
  settings: { ...callSettings, maxRetries }
44023
44215
  });
44024
44216
  const tracer = getTracer(telemetry);
44025
- const self = this;
44217
+ const self2 = this;
44026
44218
  const stitchableStream = createStitchableStream();
44027
44219
  const eventProcessor = new TransformStream({
44028
44220
  transform(chunk, controller) {
@@ -44131,7 +44323,7 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
44131
44323
  result: await model.doStream(callOptions)
44132
44324
  })
44133
44325
  }));
44134
- self._request.resolve(request != null ? request : {});
44326
+ self2._request.resolve(request != null ? request : {});
44135
44327
  let warnings;
44136
44328
  let usage = createNullLanguageModelUsage();
44137
44329
  let finishReason;
@@ -44222,24 +44414,24 @@ var import_api2, import_api3, __defProp3, __export3 = (target, all) => {
44222
44414
  provider: model.provider,
44223
44415
  model: model.modelId
44224
44416
  });
44225
- self._usage.resolve(usage);
44226
- self._providerMetadata.resolve(providerMetadata);
44227
- self._warnings.resolve(warnings);
44228
- self._response.resolve({
44417
+ self2._usage.resolve(usage);
44418
+ self2._providerMetadata.resolve(providerMetadata);
44419
+ self2._warnings.resolve(warnings);
44420
+ self2._response.resolve({
44229
44421
  ...fullResponse,
44230
44422
  headers: response == null ? undefined : response.headers
44231
44423
  });
44232
- self._finishReason.resolve(finishReason != null ? finishReason : "other");
44424
+ self2._finishReason.resolve(finishReason != null ? finishReason : "other");
44233
44425
  try {
44234
44426
  object22 = await parseAndValidateObjectResultWithRepair(accumulatedText, outputStrategy, repairText, {
44235
44427
  response: fullResponse,
44236
44428
  usage,
44237
44429
  finishReason
44238
44430
  });
44239
- self._object.resolve(object22);
44431
+ self2._object.resolve(object22);
44240
44432
  } catch (e) {
44241
44433
  error40 = e;
44242
- self._object.reject(e);
44434
+ self2._object.reject(e);
44243
44435
  }
44244
44436
  break;
44245
44437
  }
@@ -45214,6 +45406,7 @@ var init_dist6 = __esm(() => {
45214
45406
  init_dist5();
45215
45407
  init_dist2();
45216
45408
  init_dist2();
45409
+ init_dist5();
45217
45410
  init_dist4();
45218
45411
  init_dist4();
45219
45412
  init_dist4();
@@ -46073,6 +46266,7 @@ var init_dist6 = __esm(() => {
46073
46266
  "x-vercel-ai-ui-message-stream": "v1",
46074
46267
  "x-accel-buffering": "no"
46075
46268
  };
46269
+ toolMetadataSchema = exports_external3.record(exports_external3.string(), jsonValueSchema.optional());
46076
46270
  uiMessageChunkSchema = lazySchema(() => zodSchema(exports_external3.union([
46077
46271
  exports_external3.strictObject({
46078
46272
  type: exports_external3.literal("text-start"),
@@ -46100,6 +46294,7 @@ var init_dist6 = __esm(() => {
46100
46294
  toolName: exports_external3.string(),
46101
46295
  providerExecuted: exports_external3.boolean().optional(),
46102
46296
  providerMetadata: providerMetadataSchema.optional(),
46297
+ toolMetadata: toolMetadataSchema.optional(),
46103
46298
  dynamic: exports_external3.boolean().optional(),
46104
46299
  title: exports_external3.string().optional()
46105
46300
  }),
@@ -46115,6 +46310,7 @@ var init_dist6 = __esm(() => {
46115
46310
  input: exports_external3.unknown(),
46116
46311
  providerExecuted: exports_external3.boolean().optional(),
46117
46312
  providerMetadata: providerMetadataSchema.optional(),
46313
+ toolMetadata: toolMetadataSchema.optional(),
46118
46314
  dynamic: exports_external3.boolean().optional(),
46119
46315
  title: exports_external3.string().optional()
46120
46316
  }),
@@ -46125,6 +46321,7 @@ var init_dist6 = __esm(() => {
46125
46321
  input: exports_external3.unknown(),
46126
46322
  providerExecuted: exports_external3.boolean().optional(),
46127
46323
  providerMetadata: providerMetadataSchema.optional(),
46324
+ toolMetadata: toolMetadataSchema.optional(),
46128
46325
  dynamic: exports_external3.boolean().optional(),
46129
46326
  errorText: exports_external3.string(),
46130
46327
  title: exports_external3.string().optional()
@@ -46140,6 +46337,7 @@ var init_dist6 = __esm(() => {
46140
46337
  output: exports_external3.unknown(),
46141
46338
  providerExecuted: exports_external3.boolean().optional(),
46142
46339
  providerMetadata: providerMetadataSchema.optional(),
46340
+ toolMetadata: toolMetadataSchema.optional(),
46143
46341
  dynamic: exports_external3.boolean().optional(),
46144
46342
  preliminary: exports_external3.boolean().optional()
46145
46343
  }),
@@ -46149,6 +46347,7 @@ var init_dist6 = __esm(() => {
46149
46347
  errorText: exports_external3.string(),
46150
46348
  providerExecuted: exports_external3.boolean().optional(),
46151
46349
  providerMetadata: providerMetadataSchema.optional(),
46350
+ toolMetadata: toolMetadataSchema.optional(),
46152
46351
  dynamic: exports_external3.boolean().optional()
46153
46352
  }),
46154
46353
  exports_external3.strictObject({
@@ -46236,6 +46435,7 @@ var init_dist6 = __esm(() => {
46236
46435
  prefix: "aitxt",
46237
46436
  size: 24
46238
46437
  });
46438
+ toolMetadataSchema2 = exports_external3.record(exports_external3.string(), jsonValueSchema.optional());
46239
46439
  uiMessagesSchema = lazySchema(() => zodSchema(exports_external3.array(exports_external3.object({
46240
46440
  id: exports_external3.string(),
46241
46441
  role: exports_external3.enum(["system", "user", "assistant"]),
@@ -46287,6 +46487,7 @@ var init_dist6 = __esm(() => {
46287
46487
  type: exports_external3.literal("dynamic-tool"),
46288
46488
  toolName: exports_external3.string(),
46289
46489
  toolCallId: exports_external3.string(),
46490
+ toolMetadata: toolMetadataSchema2.optional(),
46290
46491
  state: exports_external3.literal("input-streaming"),
46291
46492
  input: exports_external3.unknown().optional(),
46292
46493
  providerExecuted: exports_external3.boolean().optional(),
@@ -46299,6 +46500,7 @@ var init_dist6 = __esm(() => {
46299
46500
  type: exports_external3.literal("dynamic-tool"),
46300
46501
  toolName: exports_external3.string(),
46301
46502
  toolCallId: exports_external3.string(),
46503
+ toolMetadata: toolMetadataSchema2.optional(),
46302
46504
  state: exports_external3.literal("input-available"),
46303
46505
  input: exports_external3.unknown(),
46304
46506
  providerExecuted: exports_external3.boolean().optional(),
@@ -46311,6 +46513,7 @@ var init_dist6 = __esm(() => {
46311
46513
  type: exports_external3.literal("dynamic-tool"),
46312
46514
  toolName: exports_external3.string(),
46313
46515
  toolCallId: exports_external3.string(),
46516
+ toolMetadata: toolMetadataSchema2.optional(),
46314
46517
  state: exports_external3.literal("approval-requested"),
46315
46518
  input: exports_external3.unknown(),
46316
46519
  providerExecuted: exports_external3.boolean().optional(),
@@ -46327,6 +46530,7 @@ var init_dist6 = __esm(() => {
46327
46530
  type: exports_external3.literal("dynamic-tool"),
46328
46531
  toolName: exports_external3.string(),
46329
46532
  toolCallId: exports_external3.string(),
46533
+ toolMetadata: toolMetadataSchema2.optional(),
46330
46534
  state: exports_external3.literal("approval-responded"),
46331
46535
  input: exports_external3.unknown(),
46332
46536
  providerExecuted: exports_external3.boolean().optional(),
@@ -46343,6 +46547,7 @@ var init_dist6 = __esm(() => {
46343
46547
  type: exports_external3.literal("dynamic-tool"),
46344
46548
  toolName: exports_external3.string(),
46345
46549
  toolCallId: exports_external3.string(),
46550
+ toolMetadata: toolMetadataSchema2.optional(),
46346
46551
  state: exports_external3.literal("output-available"),
46347
46552
  input: exports_external3.unknown(),
46348
46553
  providerExecuted: exports_external3.boolean().optional(),
@@ -46361,8 +46566,9 @@ var init_dist6 = __esm(() => {
46361
46566
  type: exports_external3.literal("dynamic-tool"),
46362
46567
  toolName: exports_external3.string(),
46363
46568
  toolCallId: exports_external3.string(),
46569
+ toolMetadata: toolMetadataSchema2.optional(),
46364
46570
  state: exports_external3.literal("output-error"),
46365
- input: exports_external3.unknown(),
46571
+ input: exports_external3.unknown().optional(),
46366
46572
  rawInput: exports_external3.unknown().optional(),
46367
46573
  providerExecuted: exports_external3.boolean().optional(),
46368
46574
  output: exports_external3.never().optional(),
@@ -46379,6 +46585,7 @@ var init_dist6 = __esm(() => {
46379
46585
  type: exports_external3.literal("dynamic-tool"),
46380
46586
  toolName: exports_external3.string(),
46381
46587
  toolCallId: exports_external3.string(),
46588
+ toolMetadata: toolMetadataSchema2.optional(),
46382
46589
  state: exports_external3.literal("output-denied"),
46383
46590
  input: exports_external3.unknown(),
46384
46591
  providerExecuted: exports_external3.boolean().optional(),
@@ -46394,6 +46601,7 @@ var init_dist6 = __esm(() => {
46394
46601
  exports_external3.object({
46395
46602
  type: exports_external3.string().startsWith("tool-"),
46396
46603
  toolCallId: exports_external3.string(),
46604
+ toolMetadata: toolMetadataSchema2.optional(),
46397
46605
  state: exports_external3.literal("input-streaming"),
46398
46606
  providerExecuted: exports_external3.boolean().optional(),
46399
46607
  callProviderMetadata: providerMetadataSchema.optional(),
@@ -46405,6 +46613,7 @@ var init_dist6 = __esm(() => {
46405
46613
  exports_external3.object({
46406
46614
  type: exports_external3.string().startsWith("tool-"),
46407
46615
  toolCallId: exports_external3.string(),
46616
+ toolMetadata: toolMetadataSchema2.optional(),
46408
46617
  state: exports_external3.literal("input-available"),
46409
46618
  providerExecuted: exports_external3.boolean().optional(),
46410
46619
  input: exports_external3.unknown(),
@@ -46416,6 +46625,7 @@ var init_dist6 = __esm(() => {
46416
46625
  exports_external3.object({
46417
46626
  type: exports_external3.string().startsWith("tool-"),
46418
46627
  toolCallId: exports_external3.string(),
46628
+ toolMetadata: toolMetadataSchema2.optional(),
46419
46629
  state: exports_external3.literal("approval-requested"),
46420
46630
  input: exports_external3.unknown(),
46421
46631
  providerExecuted: exports_external3.boolean().optional(),
@@ -46431,6 +46641,7 @@ var init_dist6 = __esm(() => {
46431
46641
  exports_external3.object({
46432
46642
  type: exports_external3.string().startsWith("tool-"),
46433
46643
  toolCallId: exports_external3.string(),
46644
+ toolMetadata: toolMetadataSchema2.optional(),
46434
46645
  state: exports_external3.literal("approval-responded"),
46435
46646
  input: exports_external3.unknown(),
46436
46647
  providerExecuted: exports_external3.boolean().optional(),
@@ -46446,6 +46657,7 @@ var init_dist6 = __esm(() => {
46446
46657
  exports_external3.object({
46447
46658
  type: exports_external3.string().startsWith("tool-"),
46448
46659
  toolCallId: exports_external3.string(),
46660
+ toolMetadata: toolMetadataSchema2.optional(),
46449
46661
  state: exports_external3.literal("output-available"),
46450
46662
  providerExecuted: exports_external3.boolean().optional(),
46451
46663
  input: exports_external3.unknown(),
@@ -46463,9 +46675,10 @@ var init_dist6 = __esm(() => {
46463
46675
  exports_external3.object({
46464
46676
  type: exports_external3.string().startsWith("tool-"),
46465
46677
  toolCallId: exports_external3.string(),
46678
+ toolMetadata: toolMetadataSchema2.optional(),
46466
46679
  state: exports_external3.literal("output-error"),
46467
46680
  providerExecuted: exports_external3.boolean().optional(),
46468
- input: exports_external3.unknown(),
46681
+ input: exports_external3.unknown().optional(),
46469
46682
  rawInput: exports_external3.unknown().optional(),
46470
46683
  output: exports_external3.never().optional(),
46471
46684
  errorText: exports_external3.string(),
@@ -46480,6 +46693,7 @@ var init_dist6 = __esm(() => {
46480
46693
  exports_external3.object({
46481
46694
  type: exports_external3.string().startsWith("tool-"),
46482
46695
  toolCallId: exports_external3.string(),
46696
+ toolMetadata: toolMetadataSchema2.optional(),
46483
46697
  state: exports_external3.literal("output-denied"),
46484
46698
  providerExecuted: exports_external3.boolean().optional(),
46485
46699
  input: exports_external3.unknown(),