@mastra/memory 1.8.2 → 1.8.3-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/chunk-3PUO6DLX.js +439 -0
  3. package/dist/chunk-3PUO6DLX.js.map +1 -0
  4. package/dist/{chunk-23EXJLET.cjs → chunk-CK4U3AYR.cjs} +4 -4
  5. package/dist/{chunk-23EXJLET.cjs.map → chunk-CK4U3AYR.cjs.map} +1 -1
  6. package/dist/chunk-DAJJSFVA.cjs +441 -0
  7. package/dist/chunk-DAJJSFVA.cjs.map +1 -0
  8. package/dist/{chunk-BSDWQEU3.js → chunk-SVPZMV27.js} +4 -4
  9. package/dist/{chunk-BSDWQEU3.js.map → chunk-SVPZMV27.js.map} +1 -1
  10. package/dist/docs/SKILL.md +1 -1
  11. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  12. package/dist/index.cjs +876 -246
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.js +870 -240
  15. package/dist/index.js.map +1 -1
  16. package/dist/{token-6GSAFR2W-TW2P7HCS.cjs → token-APYSY3BW-POD4OUWN.cjs} +14 -14
  17. package/dist/token-APYSY3BW-POD4OUWN.cjs.map +1 -0
  18. package/dist/{token-6GSAFR2W-ABXTQD64.js → token-APYSY3BW-YTVQELJT.js} +11 -11
  19. package/dist/token-APYSY3BW-YTVQELJT.js.map +1 -0
  20. package/dist/token-util-RMHT2CPJ-77HHGIQN.cjs +10 -0
  21. package/dist/token-util-RMHT2CPJ-77HHGIQN.cjs.map +1 -0
  22. package/dist/token-util-RMHT2CPJ-WJZ2SYAR.js +8 -0
  23. package/dist/token-util-RMHT2CPJ-WJZ2SYAR.js.map +1 -0
  24. package/package.json +8 -8
  25. package/dist/chunk-HJYHDIOC.js +0 -250
  26. package/dist/chunk-HJYHDIOC.js.map +0 -1
  27. package/dist/chunk-LIBOSOHM.cjs +0 -252
  28. package/dist/chunk-LIBOSOHM.cjs.map +0 -1
  29. package/dist/token-6GSAFR2W-ABXTQD64.js.map +0 -1
  30. package/dist/token-6GSAFR2W-TW2P7HCS.cjs.map +0 -1
  31. package/dist/token-util-NEHG7TUY-GYFEVMWP.cjs +0 -10
  32. package/dist/token-util-NEHG7TUY-GYFEVMWP.cjs.map +0 -1
  33. package/dist/token-util-NEHG7TUY-XQP3QSPX.js +0 -8
  34. package/dist/token-util-NEHG7TUY-XQP3QSPX.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { __commonJS, require_token_error, __toESM } from './chunk-BSDWQEU3.js';
1
+ import { __commonJS, require_token_error, __toESM } from './chunk-SVPZMV27.js';
2
2
  import { __commonJS as __commonJS$1, require_token_error as require_token_error$1, __toESM as __toESM$1 } from './chunk-RC6RZVYE.js';
3
3
  import { ZodFirstPartyTypeKind } from 'zod/v3';
4
4
  import { z } from 'zod';
@@ -156,13 +156,13 @@ var _AISDKError = class _AISDKError2 extends Error {
156
156
  * @param {unknown} [params.cause] - The underlying cause of the error.
157
157
  */
158
158
  constructor({
159
- name: name145,
159
+ name: name146,
160
160
  message,
161
161
  cause
162
162
  }) {
163
163
  super(message);
164
164
  this[_a] = true;
165
- this.name = name145;
165
+ this.name = name146;
166
166
  this.cause = cause;
167
167
  }
168
168
  /**
@@ -173,8 +173,8 @@ var _AISDKError = class _AISDKError2 extends Error {
173
173
  static isInstance(error) {
174
174
  return _AISDKError2.hasMarker(error, marker);
175
175
  }
176
- static hasMarker(error, marker155) {
177
- const markerSymbol = Symbol.for(marker155);
176
+ static hasMarker(error, marker156) {
177
+ const markerSymbol = Symbol.for(marker156);
178
178
  return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
179
179
  }
180
180
  };
@@ -2356,12 +2356,12 @@ function registerGlobal(type, instance, diag, allowOverride) {
2356
2356
  return true;
2357
2357
  }
2358
2358
  function getGlobal(type) {
2359
- var _a173, _b17;
2359
+ var _a173, _b19;
2360
2360
  var globalVersion = (_a173 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a173 === void 0 ? void 0 : _a173.version;
2361
2361
  if (!globalVersion || !isCompatible(globalVersion)) {
2362
2362
  return;
2363
2363
  }
2364
- return (_b17 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b17 === void 0 ? void 0 : _b17[type];
2364
+ return (_b19 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b19 === void 0 ? void 0 : _b19[type];
2365
2365
  }
2366
2366
  function unregisterGlobal(type, diag) {
2367
2367
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
@@ -2526,7 +2526,7 @@ var DiagAPI = (
2526
2526
  }
2527
2527
  var self = this;
2528
2528
  var setLogger = function(logger, optionsOrLogLevel) {
2529
- var _a173, _b17, _c;
2529
+ var _a173, _b19, _c;
2530
2530
  if (optionsOrLogLevel === void 0) {
2531
2531
  optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
2532
2532
  }
@@ -2541,7 +2541,7 @@ var DiagAPI = (
2541
2541
  };
2542
2542
  }
2543
2543
  var oldLogger = getGlobal("diag");
2544
- var newLogger = createLogLevelDiagLogger((_b17 = optionsOrLogLevel.logLevel) !== null && _b17 !== void 0 ? _b17 : DiagLogLevel.INFO, logger);
2544
+ var newLogger = createLogLevelDiagLogger((_b19 = optionsOrLogLevel.logLevel) !== null && _b19 !== void 0 ? _b19 : DiagLogLevel.INFO, logger);
2545
2545
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
2546
2546
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
2547
2547
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -3502,8 +3502,8 @@ var dataContentSchema = z.union([
3502
3502
  z.custom(
3503
3503
  // Buffer might not be available in some environments such as CloudFlare:
3504
3504
  (value) => {
3505
- var _a173, _b17;
3506
- return (_b17 = (_a173 = globalThis.Buffer) == null ? void 0 : _a173.isBuffer(value)) != null ? _b17 : false;
3505
+ var _a173, _b19;
3506
+ return (_b19 = (_a173 = globalThis.Buffer) == null ? void 0 : _a173.isBuffer(value)) != null ? _b19 : false;
3507
3507
  },
3508
3508
  { message: "Must be a Buffer" }
3509
3509
  )
@@ -4115,7 +4115,8 @@ function trimStartOfStream() {
4115
4115
  var marker17 = "vercel.ai.error";
4116
4116
  var symbol17 = Symbol.for(marker17);
4117
4117
  var _a17;
4118
- var _AISDKError3 = class _AISDKError22 extends Error {
4118
+ var _b;
4119
+ var AISDKError2 = class _AISDKError3 extends (_b = Error, _a17 = symbol17, _b) {
4119
4120
  /**
4120
4121
  * Creates an AI SDK Error.
4121
4122
  *
@@ -4125,13 +4126,13 @@ var _AISDKError3 = class _AISDKError22 extends Error {
4125
4126
  * @param {unknown} [params.cause] - The underlying cause of the error.
4126
4127
  */
4127
4128
  constructor({
4128
- name: name145,
4129
+ name: name1422,
4129
4130
  message,
4130
4131
  cause
4131
4132
  }) {
4132
4133
  super(message);
4133
4134
  this[_a17] = true;
4134
- this.name = name145;
4135
+ this.name = name1422;
4135
4136
  this.cause = cause;
4136
4137
  }
4137
4138
  /**
@@ -4140,20 +4141,19 @@ var _AISDKError3 = class _AISDKError22 extends Error {
4140
4141
  * @returns {boolean} True if the error is an AI SDK Error, false otherwise.
4141
4142
  */
4142
4143
  static isInstance(error) {
4143
- return _AISDKError22.hasMarker(error, marker17);
4144
+ return _AISDKError3.hasMarker(error, marker17);
4144
4145
  }
4145
- static hasMarker(error, marker155) {
4146
- const markerSymbol = Symbol.for(marker155);
4146
+ static hasMarker(error, marker1522) {
4147
+ const markerSymbol = Symbol.for(marker1522);
4147
4148
  return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
4148
4149
  }
4149
4150
  };
4150
- _a17 = symbol17;
4151
- var AISDKError2 = _AISDKError3;
4152
4151
  var name17 = "AI_APICallError";
4153
4152
  var marker23 = `vercel.ai.error.${name17}`;
4154
4153
  var symbol23 = Symbol.for(marker23);
4155
4154
  var _a23;
4156
- var APICallError2 = class extends AISDKError2 {
4155
+ var _b2;
4156
+ var APICallError2 = class extends (_b2 = AISDKError2, _a23 = symbol23, _b2) {
4157
4157
  constructor({
4158
4158
  message,
4159
4159
  url,
@@ -4183,12 +4183,12 @@ var APICallError2 = class extends AISDKError2 {
4183
4183
  return AISDKError2.hasMarker(error, marker23);
4184
4184
  }
4185
4185
  };
4186
- _a23 = symbol23;
4187
4186
  var name23 = "AI_EmptyResponseBodyError";
4188
4187
  var marker33 = `vercel.ai.error.${name23}`;
4189
4188
  var symbol33 = Symbol.for(marker33);
4190
4189
  var _a33;
4191
- var EmptyResponseBodyError = class extends AISDKError2 {
4190
+ var _b3;
4191
+ var EmptyResponseBodyError = class extends (_b3 = AISDKError2, _a33 = symbol33, _b3) {
4192
4192
  // used in isInstance
4193
4193
  constructor({ message = "Empty response body" } = {}) {
4194
4194
  super({ name: name23, message });
@@ -4198,7 +4198,6 @@ var EmptyResponseBodyError = class extends AISDKError2 {
4198
4198
  return AISDKError2.hasMarker(error, marker33);
4199
4199
  }
4200
4200
  };
4201
- _a33 = symbol33;
4202
4201
  function getErrorMessage3(error) {
4203
4202
  if (error == null) {
4204
4203
  return "unknown error";
@@ -4215,7 +4214,8 @@ var name33 = "AI_InvalidArgumentError";
4215
4214
  var marker43 = `vercel.ai.error.${name33}`;
4216
4215
  var symbol43 = Symbol.for(marker43);
4217
4216
  var _a43;
4218
- var InvalidArgumentError3 = class extends AISDKError2 {
4217
+ var _b4;
4218
+ var InvalidArgumentError3 = class extends (_b4 = AISDKError2, _a43 = symbol43, _b4) {
4219
4219
  constructor({
4220
4220
  message,
4221
4221
  cause,
@@ -4229,12 +4229,12 @@ var InvalidArgumentError3 = class extends AISDKError2 {
4229
4229
  return AISDKError2.hasMarker(error, marker43);
4230
4230
  }
4231
4231
  };
4232
- _a43 = symbol43;
4233
4232
  var name63 = "AI_JSONParseError";
4234
4233
  var marker73 = `vercel.ai.error.${name63}`;
4235
4234
  var symbol73 = Symbol.for(marker73);
4236
4235
  var _a73;
4237
- var JSONParseError2 = class extends AISDKError2 {
4236
+ var _b7;
4237
+ var JSONParseError2 = class extends (_b7 = AISDKError2, _a73 = symbol73, _b7) {
4238
4238
  constructor({ text: text4, cause }) {
4239
4239
  super({
4240
4240
  name: name63,
@@ -4249,12 +4249,12 @@ Error message: ${getErrorMessage3(cause)}`,
4249
4249
  return AISDKError2.hasMarker(error, marker73);
4250
4250
  }
4251
4251
  };
4252
- _a73 = symbol73;
4253
4252
  var name123 = "AI_TypeValidationError";
4254
4253
  var marker133 = `vercel.ai.error.${name123}`;
4255
4254
  var symbol133 = Symbol.for(marker133);
4256
4255
  var _a133;
4257
- var _TypeValidationError3 = class _TypeValidationError22 extends AISDKError2 {
4256
+ var _b13;
4257
+ var TypeValidationError2 = class _TypeValidationError3 extends (_b13 = AISDKError2, _a133 = symbol133, _b13) {
4258
4258
  constructor({ value, cause }) {
4259
4259
  super({
4260
4260
  name: name123,
@@ -4282,11 +4282,9 @@ Error message: ${getErrorMessage3(cause)}`,
4282
4282
  value,
4283
4283
  cause
4284
4284
  }) {
4285
- return _TypeValidationError22.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError22({ value, cause });
4285
+ return _TypeValidationError3.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError3({ value, cause });
4286
4286
  }
4287
4287
  };
4288
- _a133 = symbol133;
4289
- var TypeValidationError2 = _TypeValidationError3;
4290
4288
  var ParseError = class extends Error {
4291
4289
  constructor(message, options) {
4292
4290
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
@@ -4517,14 +4515,14 @@ function handleFetchError({
4517
4515
  return error;
4518
4516
  }
4519
4517
  function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
4520
- var _a155, _b17, _c;
4518
+ var _a224, _b222, _c;
4521
4519
  if (globalThisAny.window) {
4522
4520
  return `runtime/browser`;
4523
4521
  }
4524
- if ((_a155 = globalThisAny.navigator) == null ? void 0 : _a155.userAgent) {
4522
+ if ((_a224 = globalThisAny.navigator) == null ? void 0 : _a224.userAgent) {
4525
4523
  return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
4526
4524
  }
4527
- if ((_c = (_b17 = globalThisAny.process) == null ? void 0 : _b17.versions) == null ? void 0 : _c.node) {
4525
+ if ((_c = (_b222 = globalThisAny.process) == null ? void 0 : _b222.versions) == null ? void 0 : _c.node) {
4528
4526
  return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
4529
4527
  }
4530
4528
  if (globalThisAny.EdgeRuntime) {
@@ -4562,7 +4560,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
4562
4560
  );
4563
4561
  return Object.fromEntries(normalizedHeaders.entries());
4564
4562
  }
4565
- var VERSION2 = "3.0.17";
4563
+ var VERSION2 = "3.0.22";
4566
4564
  var getOriginalFetch = () => globalThis.fetch;
4567
4565
  var getFromApi = async ({
4568
4566
  url,
@@ -4647,8 +4645,8 @@ function loadOptionalSetting({
4647
4645
  }
4648
4646
  return settingValue;
4649
4647
  }
4650
- var suspectProtoRx = /"__proto__"\s*:/;
4651
- var suspectConstructorRx = /"constructor"\s*:/;
4648
+ var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
4649
+ var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
4652
4650
  function _parse(text4) {
4653
4651
  const obj = JSON.parse(text4);
4654
4652
  if (obj === null || typeof obj !== "object") {
@@ -4668,7 +4666,7 @@ function filter(obj) {
4668
4666
  if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
4669
4667
  throw new SyntaxError("Object contains forbidden prototype property");
4670
4668
  }
4671
- if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
4669
+ if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
4672
4670
  throw new SyntaxError("Object contains forbidden prototype property");
4673
4671
  }
4674
4672
  for (const key in node) {
@@ -4904,6 +4902,36 @@ var postToApi = async ({
4904
4902
  throw handleFetchError({ error, url, requestBodyValues: body.values });
4905
4903
  }
4906
4904
  };
4905
+ function tool(tool22) {
4906
+ return tool22;
4907
+ }
4908
+ function createProviderDefinedToolFactoryWithOutputSchema({
4909
+ id,
4910
+ name: name224,
4911
+ inputSchema,
4912
+ outputSchema: outputSchema3
4913
+ }) {
4914
+ return ({
4915
+ execute,
4916
+ toModelOutput,
4917
+ onInputStart,
4918
+ onInputDelta,
4919
+ onInputAvailable,
4920
+ ...args
4921
+ }) => tool({
4922
+ type: "provider-defined",
4923
+ id,
4924
+ name: name224,
4925
+ args,
4926
+ inputSchema,
4927
+ outputSchema: outputSchema3,
4928
+ execute,
4929
+ toModelOutput,
4930
+ onInputStart,
4931
+ onInputDelta,
4932
+ onInputAvailable
4933
+ });
4934
+ }
4907
4935
  async function resolve(value) {
4908
4936
  if (typeof value === "function") {
4909
4937
  value = value();
@@ -5001,6 +5029,31 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
5001
5029
  rawValue: parsedResult.rawValue
5002
5030
  };
5003
5031
  };
5032
+ function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
5033
+ if (jsonSchema22.type === "object") {
5034
+ jsonSchema22.additionalProperties = false;
5035
+ const properties = jsonSchema22.properties;
5036
+ if (properties != null) {
5037
+ for (const property in properties) {
5038
+ properties[property] = addAdditionalPropertiesToJsonSchema(
5039
+ properties[property]
5040
+ );
5041
+ }
5042
+ }
5043
+ }
5044
+ if (jsonSchema22.type === "array" && jsonSchema22.items != null) {
5045
+ if (Array.isArray(jsonSchema22.items)) {
5046
+ jsonSchema22.items = jsonSchema22.items.map(
5047
+ (item) => addAdditionalPropertiesToJsonSchema(item)
5048
+ );
5049
+ } else {
5050
+ jsonSchema22.items = addAdditionalPropertiesToJsonSchema(
5051
+ jsonSchema22.items
5052
+ );
5053
+ }
5054
+ }
5055
+ return jsonSchema22;
5056
+ }
5004
5057
  var getRelativePath2 = (pathA, pathB) => {
5005
5058
  let i = 0;
5006
5059
  for (; i < pathA.length && i < pathB.length; i++) {
@@ -5043,11 +5096,11 @@ function parseAnyDef2() {
5043
5096
  return {};
5044
5097
  }
5045
5098
  function parseArrayDef2(def, refs) {
5046
- var _a155, _b17, _c;
5099
+ var _a224, _b222, _c;
5047
5100
  const res = {
5048
5101
  type: "array"
5049
5102
  };
5050
- if (((_a155 = def.type) == null ? void 0 : _a155._def) && ((_c = (_b17 = def.type) == null ? void 0 : _b17._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
5103
+ if (((_a224 = def.type) == null ? void 0 : _a224._def) && ((_c = (_b222 = def.type) == null ? void 0 : _b222._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
5051
5104
  res.items = parseDef2(def.type._def, {
5052
5105
  ...refs,
5053
5106
  currentPath: [...refs.currentPath, "items"]
@@ -5406,8 +5459,8 @@ function escapeNonAlphaNumeric2(source) {
5406
5459
  return result;
5407
5460
  }
5408
5461
  function addFormat2(schema, value, message, refs) {
5409
- var _a155;
5410
- if (schema.format || ((_a155 = schema.anyOf) == null ? void 0 : _a155.some((x) => x.format))) {
5462
+ var _a224;
5463
+ if (schema.format || ((_a224 = schema.anyOf) == null ? void 0 : _a224.some((x) => x.format))) {
5411
5464
  if (!schema.anyOf) {
5412
5465
  schema.anyOf = [];
5413
5466
  }
@@ -5426,8 +5479,8 @@ function addFormat2(schema, value, message, refs) {
5426
5479
  }
5427
5480
  }
5428
5481
  function addPattern2(schema, regex, message, refs) {
5429
- var _a155;
5430
- if (schema.pattern || ((_a155 = schema.allOf) == null ? void 0 : _a155.some((x) => x.pattern))) {
5482
+ var _a224;
5483
+ if (schema.pattern || ((_a224 = schema.allOf) == null ? void 0 : _a224.some((x) => x.pattern))) {
5431
5484
  if (!schema.allOf) {
5432
5485
  schema.allOf = [];
5433
5486
  }
@@ -5446,7 +5499,7 @@ function addPattern2(schema, regex, message, refs) {
5446
5499
  }
5447
5500
  }
5448
5501
  function stringifyRegExpWithFlags2(regex, refs) {
5449
- var _a155;
5502
+ var _a224;
5450
5503
  if (!refs.applyRegexFlags || !regex.flags) {
5451
5504
  return regex.source;
5452
5505
  }
@@ -5476,7 +5529,7 @@ function stringifyRegExpWithFlags2(regex, refs) {
5476
5529
  pattern += source[i];
5477
5530
  pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
5478
5531
  inCharRange = false;
5479
- } else if (source[i + 1] === "-" && ((_a155 = source[i + 2]) == null ? void 0 : _a155.match(/[a-z]/))) {
5532
+ } else if (source[i + 1] === "-" && ((_a224 = source[i + 2]) == null ? void 0 : _a224.match(/[a-z]/))) {
5480
5533
  pattern += source[i];
5481
5534
  inCharRange = true;
5482
5535
  } else {
@@ -5518,15 +5571,15 @@ function stringifyRegExpWithFlags2(regex, refs) {
5518
5571
  return pattern;
5519
5572
  }
5520
5573
  function parseRecordDef2(def, refs) {
5521
- var _a155, _b17, _c, _d, _e, _f;
5574
+ var _a224, _b222, _c, _d, _e, _f;
5522
5575
  const schema = {
5523
5576
  type: "object",
5524
- additionalProperties: (_a155 = parseDef2(def.valueType._def, {
5577
+ additionalProperties: (_a224 = parseDef2(def.valueType._def, {
5525
5578
  ...refs,
5526
5579
  currentPath: [...refs.currentPath, "additionalProperties"]
5527
- })) != null ? _a155 : refs.allowedAdditionalProperties
5580
+ })) != null ? _a224 : refs.allowedAdditionalProperties
5528
5581
  };
5529
- if (((_b17 = def.keyType) == null ? void 0 : _b17._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
5582
+ if (((_b222 = def.keyType) == null ? void 0 : _b222._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
5530
5583
  const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
5531
5584
  return {
5532
5585
  ...schema,
@@ -5781,8 +5834,8 @@ function safeIsOptional2(schema) {
5781
5834
  }
5782
5835
  }
5783
5836
  var parseOptionalDef2 = (def, refs) => {
5784
- var _a155;
5785
- if (refs.currentPath.toString() === ((_a155 = refs.propertyPath) == null ? void 0 : _a155.toString())) {
5837
+ var _a224;
5838
+ if (refs.currentPath.toString() === ((_a224 = refs.propertyPath) == null ? void 0 : _a224.toString())) {
5786
5839
  return parseDef2(def.innerType._def, refs);
5787
5840
  }
5788
5841
  const innerSchema = parseDef2(def.innerType._def, {
@@ -5952,10 +6005,10 @@ var selectParser2 = (def, typeName, refs) => {
5952
6005
  }
5953
6006
  };
5954
6007
  function parseDef2(def, refs, forceResolution = false) {
5955
- var _a155;
6008
+ var _a224;
5956
6009
  const seenItem = refs.seen.get(def);
5957
6010
  if (refs.override) {
5958
- const overrideResult = (_a155 = refs.override) == null ? void 0 : _a155.call(
6011
+ const overrideResult = (_a224 = refs.override) == null ? void 0 : _a224.call(
5959
6012
  refs,
5960
6013
  def,
5961
6014
  refs,
@@ -6021,11 +6074,11 @@ var getRefs2 = (options) => {
6021
6074
  currentPath,
6022
6075
  propertyPath: void 0,
6023
6076
  seen: new Map(
6024
- Object.entries(_options.definitions).map(([name145, def]) => [
6077
+ Object.entries(_options.definitions).map(([name224, def]) => [
6025
6078
  def._def,
6026
6079
  {
6027
6080
  def: def._def,
6028
- path: [..._options.basePath, _options.definitionPath, name145],
6081
+ path: [..._options.basePath, _options.definitionPath, name224],
6029
6082
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
6030
6083
  jsonSchema: void 0
6031
6084
  }
@@ -6034,50 +6087,50 @@ var getRefs2 = (options) => {
6034
6087
  };
6035
6088
  };
6036
6089
  var zodToJsonSchema2 = (schema, options) => {
6037
- var _a155;
6090
+ var _a224;
6038
6091
  const refs = getRefs2(options);
6039
6092
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
6040
- (acc, [name224, schema2]) => {
6041
- var _a224;
6093
+ (acc, [name324, schema2]) => {
6094
+ var _a324;
6042
6095
  return {
6043
6096
  ...acc,
6044
- [name224]: (_a224 = parseDef2(
6097
+ [name324]: (_a324 = parseDef2(
6045
6098
  schema2._def,
6046
6099
  {
6047
6100
  ...refs,
6048
- currentPath: [...refs.basePath, refs.definitionPath, name224]
6101
+ currentPath: [...refs.basePath, refs.definitionPath, name324]
6049
6102
  },
6050
6103
  true
6051
- )) != null ? _a224 : parseAnyDef2()
6104
+ )) != null ? _a324 : parseAnyDef2()
6052
6105
  };
6053
6106
  },
6054
6107
  {}
6055
6108
  ) : void 0;
6056
- const name145 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
6057
- const main = (_a155 = parseDef2(
6109
+ const name224 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
6110
+ const main = (_a224 = parseDef2(
6058
6111
  schema._def,
6059
- name145 === void 0 ? refs : {
6112
+ name224 === void 0 ? refs : {
6060
6113
  ...refs,
6061
- currentPath: [...refs.basePath, refs.definitionPath, name145]
6114
+ currentPath: [...refs.basePath, refs.definitionPath, name224]
6062
6115
  },
6063
6116
  false
6064
- )) != null ? _a155 : parseAnyDef2();
6117
+ )) != null ? _a224 : parseAnyDef2();
6065
6118
  const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
6066
6119
  if (title !== void 0) {
6067
6120
  main.title = title;
6068
6121
  }
6069
- const combined = name145 === void 0 ? definitions ? {
6122
+ const combined = name224 === void 0 ? definitions ? {
6070
6123
  ...main,
6071
6124
  [refs.definitionPath]: definitions
6072
6125
  } : main : {
6073
6126
  $ref: [
6074
6127
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
6075
6128
  refs.definitionPath,
6076
- name145
6129
+ name224
6077
6130
  ].join("/"),
6078
6131
  [refs.definitionPath]: {
6079
6132
  ...definitions,
6080
- [name145]: main
6133
+ [name224]: main
6081
6134
  }
6082
6135
  };
6083
6136
  combined.$schema = "http://json-schema.org/draft-07/schema#";
@@ -6085,8 +6138,8 @@ var zodToJsonSchema2 = (schema, options) => {
6085
6138
  };
6086
6139
  var zod_to_json_schema_default = zodToJsonSchema2;
6087
6140
  function zod3Schema(zodSchema22, options) {
6088
- var _a155;
6089
- const useReferences = (_a155 = void 0 ) != null ? _a155 : false;
6141
+ var _a224;
6142
+ const useReferences = (_a224 = void 0 ) != null ? _a224 : false;
6090
6143
  return jsonSchema2(
6091
6144
  // defer json schema creation to avoid unnecessary computation when only validation is needed
6092
6145
  () => zod_to_json_schema_default(zodSchema22, {
@@ -6101,15 +6154,17 @@ function zod3Schema(zodSchema22, options) {
6101
6154
  );
6102
6155
  }
6103
6156
  function zod4Schema(zodSchema22, options) {
6104
- var _a155;
6105
- const useReferences = (_a155 = void 0 ) != null ? _a155 : false;
6157
+ var _a224;
6158
+ const useReferences = (_a224 = void 0 ) != null ? _a224 : false;
6106
6159
  return jsonSchema2(
6107
6160
  // defer json schema creation to avoid unnecessary computation when only validation is needed
6108
- () => z4.toJSONSchema(zodSchema22, {
6109
- target: "draft-7",
6110
- io: "output",
6111
- reused: useReferences ? "ref" : "inline"
6112
- }),
6161
+ () => addAdditionalPropertiesToJsonSchema(
6162
+ z4.toJSONSchema(zodSchema22, {
6163
+ target: "draft-7",
6164
+ io: "input",
6165
+ reused: useReferences ? "ref" : "inline"
6166
+ })
6167
+ ),
6113
6168
  {
6114
6169
  validate: async (value) => {
6115
6170
  const result = await z4.safeParseAsync(zodSchema22, value);
@@ -6129,6 +6184,15 @@ function zodSchema2(zodSchema22, options) {
6129
6184
  }
6130
6185
  }
6131
6186
  var schemaSymbol2 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
6187
+ function lazySchema(createSchema) {
6188
+ let schema;
6189
+ return () => {
6190
+ if (schema == null) {
6191
+ schema = createSchema();
6192
+ }
6193
+ return schema;
6194
+ };
6195
+ }
6132
6196
  function jsonSchema2(jsonSchema22, {
6133
6197
  validate
6134
6198
  } = {}) {
@@ -6159,7 +6223,7 @@ function withoutTrailingSlash(url) {
6159
6223
  return url == null ? void 0 : url.replace(/\/$/, "");
6160
6224
  }
6161
6225
  var require_get_context = __commonJS({
6162
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
6226
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
6163
6227
  var __defProp22 = Object.defineProperty;
6164
6228
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6165
6229
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -6191,7 +6255,7 @@ var require_get_context = __commonJS({
6191
6255
  }
6192
6256
  });
6193
6257
  var require_get_vercel_oidc_token = __commonJS({
6194
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
6258
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
6195
6259
  var __defProp22 = Object.defineProperty;
6196
6260
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6197
6261
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -6227,19 +6291,23 @@ var require_get_vercel_oidc_token = __commonJS({
6227
6291
  }
6228
6292
  try {
6229
6293
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
6230
- await import('./token-util-NEHG7TUY-XQP3QSPX.js'),
6231
- await import('./token-6GSAFR2W-ABXTQD64.js')
6294
+ await import('./token-util-RMHT2CPJ-WJZ2SYAR.js'),
6295
+ await import('./token-APYSY3BW-YTVQELJT.js')
6232
6296
  ]);
6233
6297
  if (!token || isExpired(getTokenPayload(token))) {
6234
6298
  await refreshToken();
6235
6299
  token = getVercelOidcTokenSync2();
6236
6300
  }
6237
6301
  } catch (error) {
6238
- if (err?.message && error instanceof Error) {
6239
- error.message = `${err.message}
6302
+ let message = err instanceof Error ? err.message : "";
6303
+ if (error instanceof Error) {
6304
+ message = `${message}
6240
6305
  ${error.message}`;
6241
6306
  }
6242
- throw new import_token_error.VercelOidcTokenError(`Failed to refresh OIDC token`, error);
6307
+ if (message) {
6308
+ throw new import_token_error.VercelOidcTokenError(message);
6309
+ }
6310
+ throw error;
6243
6311
  }
6244
6312
  return token;
6245
6313
  }
@@ -6255,7 +6323,7 @@ ${error.message}`;
6255
6323
  }
6256
6324
  });
6257
6325
  var require_dist = __commonJS({
6258
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
6326
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
6259
6327
  var __defProp22 = Object.defineProperty;
6260
6328
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6261
6329
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -6289,8 +6357,8 @@ var import_oidc2 = __toESM(require_dist(), 1);
6289
6357
  var marker18 = "vercel.ai.gateway.error";
6290
6358
  var symbol18 = Symbol.for(marker18);
6291
6359
  var _a18;
6292
- var _b;
6293
- var GatewayError = class _GatewayError extends (_b = Error, _a18 = symbol18, _b) {
6360
+ var _b16;
6361
+ var GatewayError = class _GatewayError extends (_b16 = Error, _a18 = symbol18, _b16) {
6294
6362
  constructor({
6295
6363
  message,
6296
6364
  statusCode = 500,
@@ -6317,8 +6385,8 @@ var name18 = "GatewayAuthenticationError";
6317
6385
  var marker24 = `vercel.ai.gateway.error.${name18}`;
6318
6386
  var symbol24 = Symbol.for(marker24);
6319
6387
  var _a24;
6320
- var _b2;
6321
- var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2 = GatewayError, _a24 = symbol24, _b2) {
6388
+ var _b22;
6389
+ var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b22 = GatewayError, _a24 = symbol24, _b22) {
6322
6390
  constructor({
6323
6391
  message = "Authentication failed",
6324
6392
  statusCode = 401,
@@ -6376,8 +6444,8 @@ var name24 = "GatewayInvalidRequestError";
6376
6444
  var marker34 = `vercel.ai.gateway.error.${name24}`;
6377
6445
  var symbol34 = Symbol.for(marker34);
6378
6446
  var _a34;
6379
- var _b3;
6380
- var GatewayInvalidRequestError = class extends (_b3 = GatewayError, _a34 = symbol34, _b3) {
6447
+ var _b32;
6448
+ var GatewayInvalidRequestError = class extends (_b32 = GatewayError, _a34 = symbol34, _b32) {
6381
6449
  constructor({
6382
6450
  message = "Invalid request",
6383
6451
  statusCode = 400,
@@ -6396,8 +6464,8 @@ var name34 = "GatewayRateLimitError";
6396
6464
  var marker44 = `vercel.ai.gateway.error.${name34}`;
6397
6465
  var symbol44 = Symbol.for(marker44);
6398
6466
  var _a44;
6399
- var _b4;
6400
- var GatewayRateLimitError = class extends (_b4 = GatewayError, _a44 = symbol44, _b4) {
6467
+ var _b42;
6468
+ var GatewayRateLimitError = class extends (_b42 = GatewayError, _a44 = symbol44, _b42) {
6401
6469
  constructor({
6402
6470
  message = "Rate limit exceeded",
6403
6471
  statusCode = 429,
@@ -6423,8 +6491,8 @@ var modelNotFoundParamSchema = lazyValidator(
6423
6491
  )
6424
6492
  );
6425
6493
  var _a54;
6426
- var _b5;
6427
- var GatewayModelNotFoundError = class extends (_b5 = GatewayError, _a54 = symbol54, _b5) {
6494
+ var _b52;
6495
+ var GatewayModelNotFoundError = class extends (_b52 = GatewayError, _a54 = symbol54, _b52) {
6428
6496
  constructor({
6429
6497
  message = "Model not found",
6430
6498
  statusCode = 404,
@@ -6445,8 +6513,8 @@ var name54 = "GatewayInternalServerError";
6445
6513
  var marker64 = `vercel.ai.gateway.error.${name54}`;
6446
6514
  var symbol64 = Symbol.for(marker64);
6447
6515
  var _a64;
6448
- var _b6;
6449
- var GatewayInternalServerError = class extends (_b6 = GatewayError, _a64 = symbol64, _b6) {
6516
+ var _b62;
6517
+ var GatewayInternalServerError = class extends (_b62 = GatewayError, _a64 = symbol64, _b62) {
6450
6518
  constructor({
6451
6519
  message = "Internal server error",
6452
6520
  statusCode = 500,
@@ -6465,8 +6533,8 @@ var name64 = "GatewayResponseError";
6465
6533
  var marker74 = `vercel.ai.gateway.error.${name64}`;
6466
6534
  var symbol74 = Symbol.for(marker74);
6467
6535
  var _a74;
6468
- var _b7;
6469
- var GatewayResponseError = class extends (_b7 = GatewayError, _a74 = symbol74, _b7) {
6536
+ var _b72;
6537
+ var GatewayResponseError = class extends (_b72 = GatewayError, _a74 = symbol74, _b72) {
6470
6538
  constructor({
6471
6539
  message = "Invalid response from Gateway",
6472
6540
  statusCode = 502,
@@ -6550,21 +6618,85 @@ var gatewayErrorResponseSchema = lazyValidator(
6550
6618
  })
6551
6619
  )
6552
6620
  );
6553
- function asGatewayError(error, authMethod) {
6554
- var _a832;
6621
+ var name74 = "GatewayTimeoutError";
6622
+ var marker84 = `vercel.ai.gateway.error.${name74}`;
6623
+ var symbol84 = Symbol.for(marker84);
6624
+ var _a84;
6625
+ var _b82;
6626
+ var GatewayTimeoutError = class _GatewayTimeoutError extends (_b82 = GatewayError, _a84 = symbol84, _b82) {
6627
+ constructor({
6628
+ message = "Request timed out",
6629
+ statusCode = 408,
6630
+ cause
6631
+ } = {}) {
6632
+ super({ message, statusCode, cause });
6633
+ this[_a84] = true;
6634
+ this.name = name74;
6635
+ this.type = "timeout_error";
6636
+ }
6637
+ static isInstance(error) {
6638
+ return GatewayError.hasMarker(error) && symbol84 in error;
6639
+ }
6640
+ /**
6641
+ * Creates a helpful timeout error message with troubleshooting guidance
6642
+ */
6643
+ static createTimeoutError({
6644
+ originalMessage,
6645
+ statusCode = 408,
6646
+ cause
6647
+ }) {
6648
+ const message = `Gateway request timed out: ${originalMessage}
6649
+
6650
+ This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`;
6651
+ return new _GatewayTimeoutError({
6652
+ message,
6653
+ statusCode,
6654
+ cause
6655
+ });
6656
+ }
6657
+ };
6658
+ function isTimeoutError(error) {
6659
+ if (!(error instanceof Error)) {
6660
+ return false;
6661
+ }
6662
+ const errorCode = error.code;
6663
+ if (typeof errorCode === "string") {
6664
+ const undiciTimeoutCodes = [
6665
+ "UND_ERR_HEADERS_TIMEOUT",
6666
+ "UND_ERR_BODY_TIMEOUT",
6667
+ "UND_ERR_CONNECT_TIMEOUT"
6668
+ ];
6669
+ return undiciTimeoutCodes.includes(errorCode);
6670
+ }
6671
+ return false;
6672
+ }
6673
+ async function asGatewayError(error, authMethod) {
6674
+ var _a932;
6555
6675
  if (GatewayError.isInstance(error)) {
6556
6676
  return error;
6557
6677
  }
6678
+ if (isTimeoutError(error)) {
6679
+ return GatewayTimeoutError.createTimeoutError({
6680
+ originalMessage: error instanceof Error ? error.message : "Unknown error",
6681
+ cause: error
6682
+ });
6683
+ }
6558
6684
  if (APICallError2.isInstance(error)) {
6559
- return createGatewayErrorFromResponse({
6685
+ if (error.cause && isTimeoutError(error.cause)) {
6686
+ return GatewayTimeoutError.createTimeoutError({
6687
+ originalMessage: error.message,
6688
+ cause: error
6689
+ });
6690
+ }
6691
+ return await createGatewayErrorFromResponse({
6560
6692
  response: extractApiCallResponse(error),
6561
- statusCode: (_a832 = error.statusCode) != null ? _a832 : 500,
6693
+ statusCode: (_a932 = error.statusCode) != null ? _a932 : 500,
6562
6694
  defaultMessage: "Gateway request failed",
6563
6695
  cause: error,
6564
6696
  authMethod
6565
6697
  });
6566
6698
  }
6567
- return createGatewayErrorFromResponse({
6699
+ return await createGatewayErrorFromResponse({
6568
6700
  response: {},
6569
6701
  statusCode: 500,
6570
6702
  defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
@@ -6845,7 +6977,7 @@ var GatewayEmbeddingModel = class {
6845
6977
  abortSignal,
6846
6978
  providerOptions
6847
6979
  }) {
6848
- var _a832;
6980
+ var _a932;
6849
6981
  const resolvedHeaders = await resolve(this.config.headers());
6850
6982
  try {
6851
6983
  const {
@@ -6876,7 +7008,7 @@ var GatewayEmbeddingModel = class {
6876
7008
  });
6877
7009
  return {
6878
7010
  embeddings: responseBody.embeddings,
6879
- usage: (_a832 = responseBody.usage) != null ? _a832 : void 0,
7011
+ usage: (_a932 = responseBody.usage) != null ? _a932 : void 0,
6880
7012
  providerMetadata: responseBody.providerMetadata,
6881
7013
  response: { headers: responseHeaders, body: rawValue }
6882
7014
  };
@@ -6923,7 +7055,7 @@ var GatewayImageModel = class {
6923
7055
  headers,
6924
7056
  abortSignal
6925
7057
  }) {
6926
- var _a832;
7058
+ var _a932, _b93, _c, _d;
6927
7059
  const resolvedHeaders = await resolve(this.config.headers());
6928
7060
  try {
6929
7061
  const {
@@ -6958,16 +7090,23 @@ var GatewayImageModel = class {
6958
7090
  return {
6959
7091
  images: responseBody.images,
6960
7092
  // Always base64 strings from server
6961
- warnings: (_a832 = responseBody.warnings) != null ? _a832 : [],
7093
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
6962
7094
  providerMetadata: responseBody.providerMetadata,
6963
7095
  response: {
6964
7096
  timestamp: /* @__PURE__ */ new Date(),
6965
7097
  modelId: this.modelId,
6966
7098
  headers: responseHeaders
7099
+ },
7100
+ ...responseBody.usage != null && {
7101
+ usage: {
7102
+ inputTokens: (_b93 = responseBody.usage.inputTokens) != null ? _b93 : void 0,
7103
+ outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
7104
+ totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
7105
+ }
6967
7106
  }
6968
7107
  };
6969
7108
  } catch (error) {
6970
- throw asGatewayError(error, await parseAuthMethod(resolvedHeaders));
7109
+ throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders));
6971
7110
  }
6972
7111
  }
6973
7112
  getUrl() {
@@ -6983,6 +7122,11 @@ var GatewayImageModel = class {
6983
7122
  var providerMetadataEntrySchema = z$1.object({
6984
7123
  images: z$1.array(z$1.unknown()).optional()
6985
7124
  }).catchall(z$1.unknown());
7125
+ var gatewayImageUsageSchema = z$1.object({
7126
+ inputTokens: z$1.number().nullish(),
7127
+ outputTokens: z$1.number().nullish(),
7128
+ totalTokens: z$1.number().nullish()
7129
+ });
6986
7130
  var gatewayImageResponseSchema = z$1.object({
6987
7131
  images: z$1.array(z$1.string()),
6988
7132
  // Always base64 strings over the wire
@@ -6992,21 +7136,196 @@ var gatewayImageResponseSchema = z$1.object({
6992
7136
  message: z$1.string()
6993
7137
  })
6994
7138
  ).optional(),
6995
- providerMetadata: z$1.record(z$1.string(), providerMetadataEntrySchema).optional()
7139
+ providerMetadata: z$1.record(z$1.string(), providerMetadataEntrySchema).optional(),
7140
+ usage: gatewayImageUsageSchema.optional()
7141
+ });
7142
+ var parallelSearchInputSchema = lazySchema(
7143
+ () => zodSchema2(
7144
+ z.object({
7145
+ objective: z.string().describe(
7146
+ "Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
7147
+ ),
7148
+ search_queries: z.array(z.string()).optional().describe(
7149
+ "Optional search queries to supplement the objective. Maximum 200 characters per query."
7150
+ ),
7151
+ mode: z.enum(["one-shot", "agentic"]).optional().describe(
7152
+ 'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
7153
+ ),
7154
+ max_results: z.number().optional().describe(
7155
+ "Maximum number of results to return (1-20). Defaults to 10 if not specified."
7156
+ ),
7157
+ source_policy: z.object({
7158
+ include_domains: z.array(z.string()).optional().describe("List of domains to include in search results."),
7159
+ exclude_domains: z.array(z.string()).optional().describe("List of domains to exclude from search results."),
7160
+ after_date: z.string().optional().describe(
7161
+ "Only include results published after this date (ISO 8601 format)."
7162
+ )
7163
+ }).optional().describe(
7164
+ "Source policy for controlling which domains to include/exclude and freshness."
7165
+ ),
7166
+ excerpts: z.object({
7167
+ max_chars_per_result: z.number().optional().describe("Maximum characters per result."),
7168
+ max_chars_total: z.number().optional().describe("Maximum total characters across all results.")
7169
+ }).optional().describe("Excerpt configuration for controlling result length."),
7170
+ fetch_policy: z.object({
7171
+ max_age_seconds: z.number().optional().describe(
7172
+ "Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
7173
+ )
7174
+ }).optional().describe("Fetch policy for controlling content freshness.")
7175
+ })
7176
+ )
7177
+ );
7178
+ var parallelSearchOutputSchema = lazySchema(
7179
+ () => zodSchema2(
7180
+ z.union([
7181
+ // Success response
7182
+ z.object({
7183
+ searchId: z.string(),
7184
+ results: z.array(
7185
+ z.object({
7186
+ url: z.string(),
7187
+ title: z.string(),
7188
+ excerpt: z.string(),
7189
+ publishDate: z.string().nullable().optional(),
7190
+ relevanceScore: z.number().optional()
7191
+ })
7192
+ )
7193
+ }),
7194
+ // Error response
7195
+ z.object({
7196
+ error: z.enum([
7197
+ "api_error",
7198
+ "rate_limit",
7199
+ "timeout",
7200
+ "invalid_input",
7201
+ "configuration_error",
7202
+ "unknown"
7203
+ ]),
7204
+ statusCode: z.number().optional(),
7205
+ message: z.string()
7206
+ })
7207
+ ])
7208
+ )
7209
+ );
7210
+ var parallelSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
7211
+ id: "gateway.parallel_search",
7212
+ name: "parallel_search",
7213
+ inputSchema: parallelSearchInputSchema,
7214
+ outputSchema: parallelSearchOutputSchema
7215
+ });
7216
+ var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
7217
+ var perplexitySearchInputSchema = lazySchema(
7218
+ () => zodSchema2(
7219
+ z.object({
7220
+ query: z.union([z.string(), z.array(z.string())]).describe(
7221
+ "Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
7222
+ ),
7223
+ max_results: z.number().optional().describe(
7224
+ "Maximum number of search results to return (1-20, default: 10)"
7225
+ ),
7226
+ max_tokens_per_page: z.number().optional().describe(
7227
+ "Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
7228
+ ),
7229
+ max_tokens: z.number().optional().describe(
7230
+ "Maximum total tokens across all search results (default: 25000, max: 1000000)"
7231
+ ),
7232
+ country: z.string().optional().describe(
7233
+ "Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
7234
+ ),
7235
+ search_domain_filter: z.array(z.string()).optional().describe(
7236
+ "List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
7237
+ ),
7238
+ search_language_filter: z.array(z.string()).optional().describe(
7239
+ "List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
7240
+ ),
7241
+ search_after_date: z.string().optional().describe(
7242
+ "Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
7243
+ ),
7244
+ search_before_date: z.string().optional().describe(
7245
+ "Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
7246
+ ),
7247
+ last_updated_after_filter: z.string().optional().describe(
7248
+ "Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
7249
+ ),
7250
+ last_updated_before_filter: z.string().optional().describe(
7251
+ "Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
7252
+ ),
7253
+ search_recency_filter: z.enum(["day", "week", "month", "year"]).optional().describe(
7254
+ "Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
7255
+ )
7256
+ })
7257
+ )
7258
+ );
7259
+ var perplexitySearchOutputSchema = lazySchema(
7260
+ () => zodSchema2(
7261
+ z.union([
7262
+ // Success response
7263
+ z.object({
7264
+ results: z.array(
7265
+ z.object({
7266
+ title: z.string(),
7267
+ url: z.string(),
7268
+ snippet: z.string(),
7269
+ date: z.string().optional(),
7270
+ lastUpdated: z.string().optional()
7271
+ })
7272
+ ),
7273
+ id: z.string()
7274
+ }),
7275
+ // Error response
7276
+ z.object({
7277
+ error: z.enum([
7278
+ "api_error",
7279
+ "rate_limit",
7280
+ "timeout",
7281
+ "invalid_input",
7282
+ "unknown"
7283
+ ]),
7284
+ statusCode: z.number().optional(),
7285
+ message: z.string()
7286
+ })
7287
+ ])
7288
+ )
7289
+ );
7290
+ var perplexitySearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
7291
+ id: "gateway.perplexity_search",
7292
+ name: "perplexity_search",
7293
+ inputSchema: perplexitySearchInputSchema,
7294
+ outputSchema: perplexitySearchOutputSchema
6996
7295
  });
7296
+ var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
7297
+ var gatewayTools = {
7298
+ /**
7299
+ * Search the web using Parallel AI's Search API for LLM-optimized excerpts.
7300
+ *
7301
+ * Takes a natural language objective and returns relevant excerpts,
7302
+ * replacing multiple keyword searches with a single call for broad
7303
+ * or complex queries. Supports different search types for depth vs
7304
+ * breadth tradeoffs.
7305
+ */
7306
+ parallelSearch,
7307
+ /**
7308
+ * Search the web using Perplexity's Search API for real-time information,
7309
+ * news, research papers, and articles.
7310
+ *
7311
+ * Provides ranked search results with advanced filtering options including
7312
+ * domain, language, date range, and recency filters.
7313
+ */
7314
+ perplexitySearch
7315
+ };
6997
7316
  async function getVercelRequestId() {
6998
- var _a832;
6999
- return (_a832 = (0, import_oidc.getContext)().headers) == null ? void 0 : _a832["x-vercel-id"];
7317
+ var _a932;
7318
+ return (_a932 = (0, import_oidc.getContext)().headers) == null ? void 0 : _a932["x-vercel-id"];
7000
7319
  }
7001
- var VERSION3 = "2.0.15";
7320
+ var VERSION3 = "2.0.58";
7002
7321
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
7003
7322
  function createGatewayProvider(options = {}) {
7004
- var _a832, _b83;
7323
+ var _a932, _b93;
7005
7324
  let pendingMetadata = null;
7006
7325
  let metadataCache = null;
7007
- const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
7326
+ const cacheRefreshMillis = (_a932 = options.metadataCacheRefreshMillis) != null ? _a932 : 1e3 * 60 * 5;
7008
7327
  let lastFetchTime = 0;
7009
- const baseURL = (_b83 = withoutTrailingSlash(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v1/ai";
7328
+ const baseURL = (_b93 = withoutTrailingSlash(options.baseURL)) != null ? _b93 : "https://ai-gateway.vercel.sh/v1/ai";
7010
7329
  const getHeaders = async () => {
7011
7330
  const auth = await getGatewayAuthToken(options);
7012
7331
  if (auth) {
@@ -7039,13 +7358,18 @@ function createGatewayProvider(options = {}) {
7039
7358
  settingValue: void 0,
7040
7359
  environmentVariableName: "VERCEL_REGION"
7041
7360
  });
7361
+ const projectId = loadOptionalSetting({
7362
+ settingValue: void 0,
7363
+ environmentVariableName: "VERCEL_PROJECT_ID"
7364
+ });
7042
7365
  return async () => {
7043
7366
  const requestId = await getVercelRequestId();
7044
7367
  return {
7045
7368
  ...deploymentId && { "ai-o11y-deployment-id": deploymentId },
7046
7369
  ...environment && { "ai-o11y-environment": environment },
7047
7370
  ...region && { "ai-o11y-region": region },
7048
- ...requestId && { "ai-o11y-request-id": requestId }
7371
+ ...requestId && { "ai-o11y-request-id": requestId },
7372
+ ...projectId && { "ai-o11y-project-id": projectId }
7049
7373
  };
7050
7374
  };
7051
7375
  };
@@ -7059,8 +7383,8 @@ function createGatewayProvider(options = {}) {
7059
7383
  });
7060
7384
  };
7061
7385
  const getAvailableModels = async () => {
7062
- var _a922, _b92, _c;
7063
- const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
7386
+ var _a1022, _b103, _c;
7387
+ const now2 = (_c = (_b103 = (_a1022 = options._internal) == null ? void 0 : _a1022.currentDate) == null ? void 0 : _b103.call(_a1022).getTime()) != null ? _c : Date.now();
7064
7388
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
7065
7389
  lastFetchTime = now2;
7066
7390
  pendingMetadata = new GatewayFetchMetadata({
@@ -7120,6 +7444,7 @@ function createGatewayProvider(options = {}) {
7120
7444
  o11yHeaders: createO11yHeaders()
7121
7445
  });
7122
7446
  };
7447
+ provider.tools = gatewayTools;
7123
7448
  return provider;
7124
7449
  }
7125
7450
  var gateway = createGatewayProvider();
@@ -7237,12 +7562,12 @@ function registerGlobal2(type, instance, diag, allowOverride) {
7237
7562
  return true;
7238
7563
  }
7239
7564
  function getGlobal2(type) {
7240
- var _a163, _b83;
7565
+ var _a163, _b93;
7241
7566
  var globalVersion = (_a163 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a163 === void 0 ? void 0 : _a163.version;
7242
7567
  if (!globalVersion || !isCompatible2(globalVersion)) {
7243
7568
  return;
7244
7569
  }
7245
- return (_b83 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _b83 === void 0 ? void 0 : _b83[type];
7570
+ return (_b93 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _b93 === void 0 ? void 0 : _b93[type];
7246
7571
  }
7247
7572
  function unregisterGlobal2(type, diag) {
7248
7573
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION22 + ".");
@@ -7407,7 +7732,7 @@ var DiagAPI2 = (
7407
7732
  }
7408
7733
  var self = this;
7409
7734
  var setLogger = function(logger, optionsOrLogLevel) {
7410
- var _a163, _b83, _c;
7735
+ var _a163, _b93, _c;
7411
7736
  if (optionsOrLogLevel === void 0) {
7412
7737
  optionsOrLogLevel = { logLevel: DiagLogLevel2.INFO };
7413
7738
  }
@@ -7422,7 +7747,7 @@ var DiagAPI2 = (
7422
7747
  };
7423
7748
  }
7424
7749
  var oldLogger = getGlobal2("diag");
7425
- var newLogger = createLogLevelDiagLogger2((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel2.INFO, logger);
7750
+ var newLogger = createLogLevelDiagLogger2((_b93 = optionsOrLogLevel.logLevel) !== null && _b93 !== void 0 ? _b93 : DiagLogLevel2.INFO, logger);
7426
7751
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
7427
7752
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
7428
7753
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -7913,8 +8238,8 @@ var UnsupportedModelVersionError2 = class extends AISDKError2 {
7913
8238
  this.modelId = options.modelId;
7914
8239
  }
7915
8240
  };
7916
- var name142 = "AI_RetryError";
7917
- var marker144 = `vercel.ai.error.${name142}`;
8241
+ var name143 = "AI_RetryError";
8242
+ var marker144 = `vercel.ai.error.${name143}`;
7918
8243
  var symbol144 = Symbol.for(marker144);
7919
8244
  var _a144;
7920
8245
  var RetryError2 = class extends AISDKError2 {
@@ -7923,7 +8248,7 @@ var RetryError2 = class extends AISDKError2 {
7923
8248
  reason,
7924
8249
  errors
7925
8250
  }) {
7926
- super({ name: name142, message });
8251
+ super({ name: name143, message });
7927
8252
  this[_a144] = true;
7928
8253
  this.reason = reason;
7929
8254
  this.errors = errors;
@@ -7953,7 +8278,7 @@ function getGlobalProvider() {
7953
8278
  var _a163;
7954
8279
  return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
7955
8280
  }
7956
- var VERSION32 = "5.0.101";
8281
+ var VERSION32 = "5.0.154";
7957
8282
  var dataContentSchema2 = z$1.union([
7958
8283
  z$1.string(),
7959
8284
  z$1.instanceof(Uint8Array),
@@ -7961,8 +8286,8 @@ var dataContentSchema2 = z$1.union([
7961
8286
  z$1.custom(
7962
8287
  // Buffer might not be available in some environments such as CloudFlare:
7963
8288
  (value) => {
7964
- var _a163, _b83;
7965
- return (_b83 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b83 : false;
8289
+ var _a163, _b93;
8290
+ return (_b93 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b93 : false;
7966
8291
  },
7967
8292
  { message: "Must be a Buffer" }
7968
8293
  )
@@ -9056,8 +9381,8 @@ var object2 = ({
9056
9381
  var marker19 = "vercel.ai.error";
9057
9382
  var symbol19 = Symbol.for(marker19);
9058
9383
  var _a19;
9059
- var _b8;
9060
- var AISDKError3 = class _AISDKError4 extends (_b8 = Error, _a19 = symbol19, _b8) {
9384
+ var _b17;
9385
+ var AISDKError3 = class _AISDKError4 extends (_b17 = Error, _a19 = symbol19, _b17) {
9061
9386
  /**
9062
9387
  * Creates an AI SDK Error.
9063
9388
  *
@@ -9093,8 +9418,8 @@ var name19 = "AI_APICallError";
9093
9418
  var marker25 = `vercel.ai.error.${name19}`;
9094
9419
  var symbol25 = Symbol.for(marker25);
9095
9420
  var _a25;
9096
- var _b22;
9097
- var APICallError3 = class extends (_b22 = AISDKError3, _a25 = symbol25, _b22) {
9421
+ var _b23;
9422
+ var APICallError3 = class extends (_b23 = AISDKError3, _a25 = symbol25, _b23) {
9098
9423
  constructor({
9099
9424
  message,
9100
9425
  url,
@@ -9128,8 +9453,8 @@ var name25 = "AI_EmptyResponseBodyError";
9128
9453
  var marker35 = `vercel.ai.error.${name25}`;
9129
9454
  var symbol35 = Symbol.for(marker35);
9130
9455
  var _a35;
9131
- var _b32;
9132
- var EmptyResponseBodyError2 = class extends (_b32 = AISDKError3, _a35 = symbol35, _b32) {
9456
+ var _b33;
9457
+ var EmptyResponseBodyError2 = class extends (_b33 = AISDKError3, _a35 = symbol35, _b33) {
9133
9458
  // used in isInstance
9134
9459
  constructor({ message = "Empty response body" } = {}) {
9135
9460
  super({ name: name25, message });
@@ -9155,8 +9480,8 @@ var name35 = "AI_InvalidArgumentError";
9155
9480
  var marker45 = `vercel.ai.error.${name35}`;
9156
9481
  var symbol45 = Symbol.for(marker45);
9157
9482
  var _a45;
9158
- var _b42;
9159
- var InvalidArgumentError4 = class extends (_b42 = AISDKError3, _a45 = symbol45, _b42) {
9483
+ var _b43;
9484
+ var InvalidArgumentError4 = class extends (_b43 = AISDKError3, _a45 = symbol45, _b43) {
9160
9485
  constructor({
9161
9486
  message,
9162
9487
  cause,
@@ -9174,8 +9499,8 @@ var name65 = "AI_JSONParseError";
9174
9499
  var marker75 = `vercel.ai.error.${name65}`;
9175
9500
  var symbol75 = Symbol.for(marker75);
9176
9501
  var _a75;
9177
- var _b72;
9178
- var JSONParseError3 = class extends (_b72 = AISDKError3, _a75 = symbol75, _b72) {
9502
+ var _b73;
9503
+ var JSONParseError3 = class extends (_b73 = AISDKError3, _a75 = symbol75, _b73) {
9179
9504
  constructor({ text: text4, cause }) {
9180
9505
  super({
9181
9506
  name: name65,
@@ -9194,8 +9519,8 @@ var name125 = "AI_TypeValidationError";
9194
9519
  var marker135 = `vercel.ai.error.${name125}`;
9195
9520
  var symbol135 = Symbol.for(marker135);
9196
9521
  var _a135;
9197
- var _b13;
9198
- var TypeValidationError3 = class _TypeValidationError4 extends (_b13 = AISDKError3, _a135 = symbol135, _b13) {
9522
+ var _b132;
9523
+ var TypeValidationError3 = class _TypeValidationError4 extends (_b132 = AISDKError3, _a135 = symbol135, _b132) {
9199
9524
  constructor({
9200
9525
  value,
9201
9526
  cause,
@@ -9246,8 +9571,8 @@ Error message: ${getErrorMessage4(cause)}`,
9246
9571
  cause,
9247
9572
  context: context2
9248
9573
  }) {
9249
- var _a1522, _b152, _c;
9250
- if (_TypeValidationError4.isInstance(cause) && cause.value === value && ((_a1522 = cause.context) == null ? void 0 : _a1522.field) === (context2 == null ? void 0 : context2.field) && ((_b152 = cause.context) == null ? void 0 : _b152.entityName) === (context2 == null ? void 0 : context2.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context2 == null ? void 0 : context2.entityId)) {
9574
+ var _a1522, _b1522, _c;
9575
+ if (_TypeValidationError4.isInstance(cause) && cause.value === value && ((_a1522 = cause.context) == null ? void 0 : _a1522.field) === (context2 == null ? void 0 : context2.field) && ((_b1522 = cause.context) == null ? void 0 : _b1522.entityName) === (context2 == null ? void 0 : context2.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context2 == null ? void 0 : context2.entityId)) {
9251
9576
  return cause;
9252
9577
  }
9253
9578
  return new _TypeValidationError4({ value, cause, context: context2 });
@@ -9564,7 +9889,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
9564
9889
  );
9565
9890
  return Object.fromEntries(normalizedHeaders.entries());
9566
9891
  }
9567
- var VERSION4 = "4.0.13";
9892
+ var VERSION4 = "4.0.19";
9568
9893
  var getOriginalFetch3 = () => globalThis.fetch;
9569
9894
  var getFromApi2 = async ({
9570
9895
  url,
@@ -9649,8 +9974,8 @@ function loadOptionalSetting2({
9649
9974
  }
9650
9975
  return settingValue;
9651
9976
  }
9652
- var suspectProtoRx2 = /"__proto__"\s*:/;
9653
- var suspectConstructorRx2 = /"constructor"\s*:/;
9977
+ var suspectProtoRx2 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
9978
+ var suspectConstructorRx2 = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
9654
9979
  function _parse2(text4) {
9655
9980
  const obj = JSON.parse(text4);
9656
9981
  if (obj === null || typeof obj !== "object") {
@@ -9670,7 +9995,7 @@ function filter2(obj) {
9670
9995
  if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
9671
9996
  throw new SyntaxError("Object contains forbidden prototype property");
9672
9997
  }
9673
- if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
9998
+ if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
9674
9999
  throw new SyntaxError("Object contains forbidden prototype property");
9675
10000
  }
9676
10001
  for (const key in node) {
@@ -9696,7 +10021,7 @@ function secureJsonParse2(text4) {
9696
10021
  Error.stackTraceLimit = stackTraceLimit;
9697
10022
  }
9698
10023
  }
9699
- function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
10024
+ function addAdditionalPropertiesToJsonSchema2(jsonSchema22) {
9700
10025
  if (jsonSchema22.type === "object" || Array.isArray(jsonSchema22.type) && jsonSchema22.type.includes("object")) {
9701
10026
  jsonSchema22.additionalProperties = false;
9702
10027
  const { properties } = jsonSchema22;
@@ -9728,7 +10053,7 @@ function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
9728
10053
  }
9729
10054
  function visit(def) {
9730
10055
  if (typeof def === "boolean") return def;
9731
- return addAdditionalPropertiesToJsonSchema(def);
10056
+ return addAdditionalPropertiesToJsonSchema2(def);
9732
10057
  }
9733
10058
  var ignoreOverride3 = /* @__PURE__ */ Symbol(
9734
10059
  "Let zodToJsonSchema decide on which parser to use"
@@ -10813,7 +11138,7 @@ var zod3ToJsonSchema = (schema, options) => {
10813
11138
  return combined;
10814
11139
  };
10815
11140
  var schemaSymbol3 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
10816
- function lazySchema(createSchema) {
11141
+ function lazySchema2(createSchema) {
10817
11142
  let schema;
10818
11143
  return () => {
10819
11144
  if (schema == null) {
@@ -10846,7 +11171,7 @@ function asSchema3(schema) {
10846
11171
  }
10847
11172
  function standardSchema(standardSchema2) {
10848
11173
  return jsonSchema3(
10849
- () => addAdditionalPropertiesToJsonSchema(
11174
+ () => addAdditionalPropertiesToJsonSchema2(
10850
11175
  standardSchema2["~standard"].jsonSchema.input({
10851
11176
  target: "draft-07"
10852
11177
  })
@@ -10886,7 +11211,7 @@ function zod4Schema2(zodSchema22, options) {
10886
11211
  const useReferences = (_a224 = void 0 ) != null ? _a224 : false;
10887
11212
  return jsonSchema3(
10888
11213
  // defer json schema creation to avoid unnecessary computation when only validation is needed
10889
- () => addAdditionalPropertiesToJsonSchema(
11214
+ () => addAdditionalPropertiesToJsonSchema2(
10890
11215
  z4.toJSONSchema(zodSchema22, {
10891
11216
  target: "draft-7",
10892
11217
  io: "input",
@@ -11092,8 +11417,8 @@ var postToApi2 = async ({
11092
11417
  throw handleFetchError2({ error, url, requestBodyValues: body.values });
11093
11418
  }
11094
11419
  };
11095
- function tool(tool2) {
11096
- return tool2;
11420
+ function tool2(tool22) {
11421
+ return tool22;
11097
11422
  }
11098
11423
  function createProviderToolFactoryWithOutputSchema({
11099
11424
  id,
@@ -11109,7 +11434,7 @@ function createProviderToolFactoryWithOutputSchema({
11109
11434
  onInputDelta,
11110
11435
  onInputAvailable,
11111
11436
  ...args
11112
- }) => tool({
11437
+ }) => tool2({
11113
11438
  type: "provider",
11114
11439
  id,
11115
11440
  args,
@@ -11359,8 +11684,8 @@ var import_oidc22 = __toESM$1(require_dist2(), 1);
11359
11684
  var marker20 = "vercel.ai.gateway.error";
11360
11685
  var symbol20 = Symbol.for(marker20);
11361
11686
  var _a20;
11362
- var _b16;
11363
- var GatewayError2 = class _GatewayError2 extends (_b16 = Error, _a20 = symbol20, _b16) {
11687
+ var _b18;
11688
+ var GatewayError2 = class _GatewayError2 extends (_b18 = Error, _a20 = symbol20, _b18) {
11364
11689
  constructor({
11365
11690
  message,
11366
11691
  statusCode = 500,
@@ -11389,8 +11714,8 @@ var name20 = "GatewayAuthenticationError";
11389
11714
  var marker26 = `vercel.ai.gateway.error.${name20}`;
11390
11715
  var symbol26 = Symbol.for(marker26);
11391
11716
  var _a26;
11392
- var _b23;
11393
- var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b23 = GatewayError2, _a26 = symbol26, _b23) {
11717
+ var _b24;
11718
+ var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b24 = GatewayError2, _a26 = symbol26, _b24) {
11394
11719
  constructor({
11395
11720
  message = "Authentication failed",
11396
11721
  statusCode = 401,
@@ -11451,8 +11776,8 @@ var name26 = "GatewayInvalidRequestError";
11451
11776
  var marker36 = `vercel.ai.gateway.error.${name26}`;
11452
11777
  var symbol36 = Symbol.for(marker36);
11453
11778
  var _a36;
11454
- var _b33;
11455
- var GatewayInvalidRequestError2 = class extends (_b33 = GatewayError2, _a36 = symbol36, _b33) {
11779
+ var _b34;
11780
+ var GatewayInvalidRequestError2 = class extends (_b34 = GatewayError2, _a36 = symbol36, _b34) {
11456
11781
  constructor({
11457
11782
  message = "Invalid request",
11458
11783
  statusCode = 400,
@@ -11472,8 +11797,8 @@ var name36 = "GatewayRateLimitError";
11472
11797
  var marker46 = `vercel.ai.gateway.error.${name36}`;
11473
11798
  var symbol46 = Symbol.for(marker46);
11474
11799
  var _a46;
11475
- var _b43;
11476
- var GatewayRateLimitError2 = class extends (_b43 = GatewayError2, _a46 = symbol46, _b43) {
11800
+ var _b44;
11801
+ var GatewayRateLimitError2 = class extends (_b44 = GatewayError2, _a46 = symbol46, _b44) {
11477
11802
  constructor({
11478
11803
  message = "Rate limit exceeded",
11479
11804
  statusCode = 429,
@@ -11492,7 +11817,7 @@ var GatewayRateLimitError2 = class extends (_b43 = GatewayError2, _a46 = symbol4
11492
11817
  var name46 = "GatewayModelNotFoundError";
11493
11818
  var marker56 = `vercel.ai.gateway.error.${name46}`;
11494
11819
  var symbol56 = Symbol.for(marker56);
11495
- var modelNotFoundParamSchema2 = lazySchema(
11820
+ var modelNotFoundParamSchema2 = lazySchema2(
11496
11821
  () => zodSchema3(
11497
11822
  z$1.object({
11498
11823
  modelId: z$1.string()
@@ -11500,8 +11825,8 @@ var modelNotFoundParamSchema2 = lazySchema(
11500
11825
  )
11501
11826
  );
11502
11827
  var _a56;
11503
- var _b53;
11504
- var GatewayModelNotFoundError2 = class extends (_b53 = GatewayError2, _a56 = symbol56, _b53) {
11828
+ var _b54;
11829
+ var GatewayModelNotFoundError2 = class extends (_b54 = GatewayError2, _a56 = symbol56, _b54) {
11505
11830
  constructor({
11506
11831
  message = "Model not found",
11507
11832
  statusCode = 404,
@@ -11523,8 +11848,8 @@ var name56 = "GatewayInternalServerError";
11523
11848
  var marker66 = `vercel.ai.gateway.error.${name56}`;
11524
11849
  var symbol66 = Symbol.for(marker66);
11525
11850
  var _a66;
11526
- var _b63;
11527
- var GatewayInternalServerError2 = class extends (_b63 = GatewayError2, _a66 = symbol66, _b63) {
11851
+ var _b64;
11852
+ var GatewayInternalServerError2 = class extends (_b64 = GatewayError2, _a66 = symbol66, _b64) {
11528
11853
  constructor({
11529
11854
  message = "Internal server error",
11530
11855
  statusCode = 500,
@@ -11544,8 +11869,8 @@ var name66 = "GatewayResponseError";
11544
11869
  var marker76 = `vercel.ai.gateway.error.${name66}`;
11545
11870
  var symbol76 = Symbol.for(marker76);
11546
11871
  var _a76;
11547
- var _b73;
11548
- var GatewayResponseError2 = class extends (_b73 = GatewayError2, _a76 = symbol76, _b73) {
11872
+ var _b74;
11873
+ var GatewayResponseError2 = class extends (_b74 = GatewayError2, _a76 = symbol76, _b74) {
11549
11874
  constructor({
11550
11875
  message = "Invalid response from Gateway",
11551
11876
  statusCode = 502,
@@ -11572,7 +11897,7 @@ async function createGatewayErrorFromResponse2({
11572
11897
  cause,
11573
11898
  authMethod
11574
11899
  }) {
11575
- var _a832;
11900
+ var _a932;
11576
11901
  const parseResult = await safeValidateTypes3({
11577
11902
  value: response,
11578
11903
  schema: gatewayErrorResponseSchema2
@@ -11591,7 +11916,7 @@ async function createGatewayErrorFromResponse2({
11591
11916
  const validatedResponse = parseResult.value;
11592
11917
  const errorType = validatedResponse.error.type;
11593
11918
  const message = validatedResponse.error.message;
11594
- const generationId = (_a832 = validatedResponse.generationId) != null ? _a832 : void 0;
11919
+ const generationId = (_a932 = validatedResponse.generationId) != null ? _a932 : void 0;
11595
11920
  switch (errorType) {
11596
11921
  case "authentication_error":
11597
11922
  return GatewayAuthenticationError2.createContextualError({
@@ -11644,7 +11969,7 @@ async function createGatewayErrorFromResponse2({
11644
11969
  });
11645
11970
  }
11646
11971
  }
11647
- var gatewayErrorResponseSchema2 = lazySchema(
11972
+ var gatewayErrorResponseSchema2 = lazySchema2(
11648
11973
  () => zodSchema3(
11649
11974
  z$1.object({
11650
11975
  error: z$1.object({
@@ -11657,21 +11982,88 @@ var gatewayErrorResponseSchema2 = lazySchema(
11657
11982
  })
11658
11983
  )
11659
11984
  );
11660
- function asGatewayError2(error, authMethod) {
11661
- var _a832;
11985
+ var name76 = "GatewayTimeoutError";
11986
+ var marker86 = `vercel.ai.gateway.error.${name76}`;
11987
+ var symbol86 = Symbol.for(marker86);
11988
+ var _a86;
11989
+ var _b84;
11990
+ var GatewayTimeoutError2 = class _GatewayTimeoutError2 extends (_b84 = GatewayError2, _a86 = symbol86, _b84) {
11991
+ constructor({
11992
+ message = "Request timed out",
11993
+ statusCode = 408,
11994
+ cause,
11995
+ generationId
11996
+ } = {}) {
11997
+ super({ message, statusCode, cause, generationId });
11998
+ this[_a86] = true;
11999
+ this.name = name76;
12000
+ this.type = "timeout_error";
12001
+ }
12002
+ static isInstance(error) {
12003
+ return GatewayError2.hasMarker(error) && symbol86 in error;
12004
+ }
12005
+ /**
12006
+ * Creates a helpful timeout error message with troubleshooting guidance
12007
+ */
12008
+ static createTimeoutError({
12009
+ originalMessage,
12010
+ statusCode = 408,
12011
+ cause,
12012
+ generationId
12013
+ }) {
12014
+ const message = `Gateway request timed out: ${originalMessage}
12015
+
12016
+ This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`;
12017
+ return new _GatewayTimeoutError2({
12018
+ message,
12019
+ statusCode,
12020
+ cause,
12021
+ generationId
12022
+ });
12023
+ }
12024
+ };
12025
+ function isTimeoutError2(error) {
12026
+ if (!(error instanceof Error)) {
12027
+ return false;
12028
+ }
12029
+ const errorCode = error.code;
12030
+ if (typeof errorCode === "string") {
12031
+ const undiciTimeoutCodes = [
12032
+ "UND_ERR_HEADERS_TIMEOUT",
12033
+ "UND_ERR_BODY_TIMEOUT",
12034
+ "UND_ERR_CONNECT_TIMEOUT"
12035
+ ];
12036
+ return undiciTimeoutCodes.includes(errorCode);
12037
+ }
12038
+ return false;
12039
+ }
12040
+ async function asGatewayError2(error, authMethod) {
12041
+ var _a932;
11662
12042
  if (GatewayError2.isInstance(error)) {
11663
12043
  return error;
11664
12044
  }
12045
+ if (isTimeoutError2(error)) {
12046
+ return GatewayTimeoutError2.createTimeoutError({
12047
+ originalMessage: error instanceof Error ? error.message : "Unknown error",
12048
+ cause: error
12049
+ });
12050
+ }
11665
12051
  if (APICallError3.isInstance(error)) {
11666
- return createGatewayErrorFromResponse2({
12052
+ if (error.cause && isTimeoutError2(error.cause)) {
12053
+ return GatewayTimeoutError2.createTimeoutError({
12054
+ originalMessage: error.message,
12055
+ cause: error
12056
+ });
12057
+ }
12058
+ return await createGatewayErrorFromResponse2({
11667
12059
  response: extractApiCallResponse2(error),
11668
- statusCode: (_a832 = error.statusCode) != null ? _a832 : 500,
12060
+ statusCode: (_a932 = error.statusCode) != null ? _a932 : 500,
11669
12061
  defaultMessage: "Gateway request failed",
11670
12062
  cause: error,
11671
12063
  authMethod
11672
12064
  });
11673
12065
  }
11674
- return createGatewayErrorFromResponse2({
12066
+ return await createGatewayErrorFromResponse2({
11675
12067
  response: {},
11676
12068
  statusCode: 500,
11677
12069
  defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
@@ -11700,7 +12092,7 @@ async function parseAuthMethod2(headers) {
11700
12092
  });
11701
12093
  return result.success ? result.value : void 0;
11702
12094
  }
11703
- var gatewayAuthMethodSchema2 = lazySchema(
12095
+ var gatewayAuthMethodSchema2 = lazySchema2(
11704
12096
  () => zodSchema3(z$1.union([z$1.literal("api-key"), z$1.literal("oidc")]))
11705
12097
  );
11706
12098
  var GatewayFetchMetadata2 = class {
@@ -11747,7 +12139,7 @@ var GatewayFetchMetadata2 = class {
11747
12139
  }
11748
12140
  }
11749
12141
  };
11750
- var gatewayAvailableModelsResponseSchema2 = lazySchema(
12142
+ var gatewayAvailableModelsResponseSchema2 = lazySchema2(
11751
12143
  () => zodSchema3(
11752
12144
  z$1.object({
11753
12145
  models: z$1.array(
@@ -11773,13 +12165,13 @@ var gatewayAvailableModelsResponseSchema2 = lazySchema(
11773
12165
  provider: z$1.string(),
11774
12166
  modelId: z$1.string()
11775
12167
  }),
11776
- modelType: z$1.enum(["language", "embedding", "image"]).nullish()
12168
+ modelType: z$1.enum(["embedding", "image", "language", "video"]).nullish()
11777
12169
  })
11778
12170
  )
11779
12171
  })
11780
12172
  )
11781
12173
  );
11782
- var gatewayCreditsResponseSchema2 = lazySchema(
12174
+ var gatewayCreditsResponseSchema2 = lazySchema2(
11783
12175
  () => zodSchema3(
11784
12176
  z$1.object({
11785
12177
  balance: z$1.string(),
@@ -11952,7 +12344,7 @@ var GatewayEmbeddingModel2 = class {
11952
12344
  abortSignal,
11953
12345
  providerOptions
11954
12346
  }) {
11955
- var _a832;
12347
+ var _a932;
11956
12348
  const resolvedHeaders = await resolve2(this.config.headers());
11957
12349
  try {
11958
12350
  const {
@@ -11983,7 +12375,7 @@ var GatewayEmbeddingModel2 = class {
11983
12375
  });
11984
12376
  return {
11985
12377
  embeddings: responseBody.embeddings,
11986
- usage: (_a832 = responseBody.usage) != null ? _a832 : void 0,
12378
+ usage: (_a932 = responseBody.usage) != null ? _a932 : void 0,
11987
12379
  providerMetadata: responseBody.providerMetadata,
11988
12380
  response: { headers: responseHeaders, body: rawValue },
11989
12381
  warnings: []
@@ -12002,7 +12394,7 @@ var GatewayEmbeddingModel2 = class {
12002
12394
  };
12003
12395
  }
12004
12396
  };
12005
- var gatewayEmbeddingResponseSchema2 = lazySchema(
12397
+ var gatewayEmbeddingResponseSchema2 = lazySchema2(
12006
12398
  () => zodSchema3(
12007
12399
  z$1.object({
12008
12400
  embeddings: z$1.array(z$1.array(z$1.number())),
@@ -12033,7 +12425,7 @@ var GatewayImageModel2 = class {
12033
12425
  headers,
12034
12426
  abortSignal
12035
12427
  }) {
12036
- var _a832;
12428
+ var _a932, _b93, _c, _d;
12037
12429
  const resolvedHeaders = await resolve2(this.config.headers());
12038
12430
  try {
12039
12431
  const {
@@ -12072,16 +12464,23 @@ var GatewayImageModel2 = class {
12072
12464
  return {
12073
12465
  images: responseBody.images,
12074
12466
  // Always base64 strings from server
12075
- warnings: (_a832 = responseBody.warnings) != null ? _a832 : [],
12467
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
12076
12468
  providerMetadata: responseBody.providerMetadata,
12077
12469
  response: {
12078
12470
  timestamp: /* @__PURE__ */ new Date(),
12079
12471
  modelId: this.modelId,
12080
12472
  headers: responseHeaders
12473
+ },
12474
+ ...responseBody.usage != null && {
12475
+ usage: {
12476
+ inputTokens: (_b93 = responseBody.usage.inputTokens) != null ? _b93 : void 0,
12477
+ outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
12478
+ totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
12479
+ }
12081
12480
  }
12082
12481
  };
12083
12482
  } catch (error) {
12084
- throw asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
12483
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
12085
12484
  }
12086
12485
  }
12087
12486
  getUrl() {
@@ -12106,18 +12505,231 @@ function maybeEncodeImageFile(file) {
12106
12505
  var providerMetadataEntrySchema2 = z$1.object({
12107
12506
  images: z$1.array(z$1.unknown()).optional()
12108
12507
  }).catchall(z$1.unknown());
12508
+ var gatewayImageWarningSchema = z$1.discriminatedUnion("type", [
12509
+ z$1.object({
12510
+ type: z$1.literal("unsupported"),
12511
+ feature: z$1.string(),
12512
+ details: z$1.string().optional()
12513
+ }),
12514
+ z$1.object({
12515
+ type: z$1.literal("compatibility"),
12516
+ feature: z$1.string(),
12517
+ details: z$1.string().optional()
12518
+ }),
12519
+ z$1.object({
12520
+ type: z$1.literal("other"),
12521
+ message: z$1.string()
12522
+ })
12523
+ ]);
12524
+ var gatewayImageUsageSchema2 = z$1.object({
12525
+ inputTokens: z$1.number().nullish(),
12526
+ outputTokens: z$1.number().nullish(),
12527
+ totalTokens: z$1.number().nullish()
12528
+ });
12109
12529
  var gatewayImageResponseSchema2 = z$1.object({
12110
12530
  images: z$1.array(z$1.string()),
12111
12531
  // Always base64 strings over the wire
12112
- warnings: z$1.array(
12113
- z$1.object({
12114
- type: z$1.literal("other"),
12115
- message: z$1.string()
12116
- })
12117
- ).optional(),
12118
- providerMetadata: z$1.record(z$1.string(), providerMetadataEntrySchema2).optional()
12532
+ warnings: z$1.array(gatewayImageWarningSchema).optional(),
12533
+ providerMetadata: z$1.record(z$1.string(), providerMetadataEntrySchema2).optional(),
12534
+ usage: gatewayImageUsageSchema2.optional()
12119
12535
  });
12120
- var parallelSearchInputSchema = lazySchema(
12536
+ var GatewayVideoModel = class {
12537
+ constructor(modelId, config) {
12538
+ this.modelId = modelId;
12539
+ this.config = config;
12540
+ this.specificationVersion = "v3";
12541
+ this.maxVideosPerCall = Number.MAX_SAFE_INTEGER;
12542
+ }
12543
+ get provider() {
12544
+ return this.config.provider;
12545
+ }
12546
+ async doGenerate({
12547
+ prompt,
12548
+ n,
12549
+ aspectRatio,
12550
+ resolution,
12551
+ duration,
12552
+ fps,
12553
+ seed,
12554
+ image,
12555
+ providerOptions,
12556
+ headers,
12557
+ abortSignal
12558
+ }) {
12559
+ var _a932;
12560
+ const resolvedHeaders = await resolve2(this.config.headers());
12561
+ try {
12562
+ const { responseHeaders, value: responseBody } = await postJsonToApi2({
12563
+ url: this.getUrl(),
12564
+ headers: combineHeaders2(
12565
+ resolvedHeaders,
12566
+ headers != null ? headers : {},
12567
+ this.getModelConfigHeaders(),
12568
+ await resolve2(this.config.o11yHeaders),
12569
+ { accept: "text/event-stream" }
12570
+ ),
12571
+ body: {
12572
+ prompt,
12573
+ n,
12574
+ ...aspectRatio && { aspectRatio },
12575
+ ...resolution && { resolution },
12576
+ ...duration && { duration },
12577
+ ...fps && { fps },
12578
+ ...seed && { seed },
12579
+ ...providerOptions && { providerOptions },
12580
+ ...image && { image: maybeEncodeVideoFile(image) }
12581
+ },
12582
+ successfulResponseHandler: async ({
12583
+ response,
12584
+ url,
12585
+ requestBodyValues
12586
+ }) => {
12587
+ if (response.body == null) {
12588
+ throw new APICallError3({
12589
+ message: "SSE response body is empty",
12590
+ url,
12591
+ requestBodyValues,
12592
+ statusCode: response.status
12593
+ });
12594
+ }
12595
+ const eventStream = parseJsonEventStream2({
12596
+ stream: response.body,
12597
+ schema: gatewayVideoEventSchema
12598
+ });
12599
+ const reader = eventStream.getReader();
12600
+ const { done, value: parseResult } = await reader.read();
12601
+ reader.releaseLock();
12602
+ if (done || !parseResult) {
12603
+ throw new APICallError3({
12604
+ message: "SSE stream ended without a data event",
12605
+ url,
12606
+ requestBodyValues,
12607
+ statusCode: response.status
12608
+ });
12609
+ }
12610
+ if (!parseResult.success) {
12611
+ throw new APICallError3({
12612
+ message: "Failed to parse video SSE event",
12613
+ cause: parseResult.error,
12614
+ url,
12615
+ requestBodyValues,
12616
+ statusCode: response.status
12617
+ });
12618
+ }
12619
+ const event = parseResult.value;
12620
+ if (event.type === "error") {
12621
+ throw new APICallError3({
12622
+ message: event.message,
12623
+ statusCode: event.statusCode,
12624
+ url,
12625
+ requestBodyValues,
12626
+ responseHeaders: Object.fromEntries([...response.headers]),
12627
+ responseBody: JSON.stringify(event),
12628
+ data: {
12629
+ error: {
12630
+ message: event.message,
12631
+ type: event.errorType,
12632
+ param: event.param
12633
+ }
12634
+ }
12635
+ });
12636
+ }
12637
+ return {
12638
+ value: {
12639
+ videos: event.videos,
12640
+ warnings: event.warnings,
12641
+ providerMetadata: event.providerMetadata
12642
+ },
12643
+ responseHeaders: Object.fromEntries([...response.headers])
12644
+ };
12645
+ },
12646
+ failedResponseHandler: createJsonErrorResponseHandler2({
12647
+ errorSchema: z$1.any(),
12648
+ errorToMessage: (data) => data
12649
+ }),
12650
+ ...abortSignal && { abortSignal },
12651
+ fetch: this.config.fetch
12652
+ });
12653
+ return {
12654
+ videos: responseBody.videos,
12655
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
12656
+ providerMetadata: responseBody.providerMetadata,
12657
+ response: {
12658
+ timestamp: /* @__PURE__ */ new Date(),
12659
+ modelId: this.modelId,
12660
+ headers: responseHeaders
12661
+ }
12662
+ };
12663
+ } catch (error) {
12664
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
12665
+ }
12666
+ }
12667
+ getUrl() {
12668
+ return `${this.config.baseURL}/video-model`;
12669
+ }
12670
+ getModelConfigHeaders() {
12671
+ return {
12672
+ "ai-video-model-specification-version": "3",
12673
+ "ai-model-id": this.modelId
12674
+ };
12675
+ }
12676
+ };
12677
+ function maybeEncodeVideoFile(file) {
12678
+ if (file.type === "file" && file.data instanceof Uint8Array) {
12679
+ return {
12680
+ ...file,
12681
+ data: convertUint8ArrayToBase643(file.data)
12682
+ };
12683
+ }
12684
+ return file;
12685
+ }
12686
+ var providerMetadataEntrySchema22 = z$1.object({
12687
+ videos: z$1.array(z$1.unknown()).optional()
12688
+ }).catchall(z$1.unknown());
12689
+ var gatewayVideoDataSchema = z$1.union([
12690
+ z$1.object({
12691
+ type: z$1.literal("url"),
12692
+ url: z$1.string(),
12693
+ mediaType: z$1.string()
12694
+ }),
12695
+ z$1.object({
12696
+ type: z$1.literal("base64"),
12697
+ data: z$1.string(),
12698
+ mediaType: z$1.string()
12699
+ })
12700
+ ]);
12701
+ var gatewayVideoWarningSchema = z$1.discriminatedUnion("type", [
12702
+ z$1.object({
12703
+ type: z$1.literal("unsupported"),
12704
+ feature: z$1.string(),
12705
+ details: z$1.string().optional()
12706
+ }),
12707
+ z$1.object({
12708
+ type: z$1.literal("compatibility"),
12709
+ feature: z$1.string(),
12710
+ details: z$1.string().optional()
12711
+ }),
12712
+ z$1.object({
12713
+ type: z$1.literal("other"),
12714
+ message: z$1.string()
12715
+ })
12716
+ ]);
12717
+ var gatewayVideoEventSchema = z$1.discriminatedUnion("type", [
12718
+ z$1.object({
12719
+ type: z$1.literal("result"),
12720
+ videos: z$1.array(gatewayVideoDataSchema),
12721
+ warnings: z$1.array(gatewayVideoWarningSchema).optional(),
12722
+ providerMetadata: z$1.record(z$1.string(), providerMetadataEntrySchema22).optional()
12723
+ }),
12724
+ z$1.object({
12725
+ type: z$1.literal("error"),
12726
+ message: z$1.string(),
12727
+ errorType: z$1.string(),
12728
+ statusCode: z$1.number(),
12729
+ param: z$1.unknown().nullable()
12730
+ })
12731
+ ]);
12732
+ var parallelSearchInputSchema2 = lazySchema2(
12121
12733
  () => zodSchema3(
12122
12734
  z.object({
12123
12735
  objective: z.string().describe(
@@ -12153,7 +12765,7 @@ var parallelSearchInputSchema = lazySchema(
12153
12765
  })
12154
12766
  )
12155
12767
  );
12156
- var parallelSearchOutputSchema = lazySchema(
12768
+ var parallelSearchOutputSchema2 = lazySchema2(
12157
12769
  () => zodSchema3(
12158
12770
  z.union([
12159
12771
  // Success response
@@ -12185,13 +12797,13 @@ var parallelSearchOutputSchema = lazySchema(
12185
12797
  ])
12186
12798
  )
12187
12799
  );
12188
- var parallelSearchToolFactory = createProviderToolFactoryWithOutputSchema({
12800
+ var parallelSearchToolFactory2 = createProviderToolFactoryWithOutputSchema({
12189
12801
  id: "gateway.parallel_search",
12190
- inputSchema: parallelSearchInputSchema,
12191
- outputSchema: parallelSearchOutputSchema
12802
+ inputSchema: parallelSearchInputSchema2,
12803
+ outputSchema: parallelSearchOutputSchema2
12192
12804
  });
12193
- var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
12194
- var perplexitySearchInputSchema = lazySchema(
12805
+ var parallelSearch2 = (config = {}) => parallelSearchToolFactory2(config);
12806
+ var perplexitySearchInputSchema2 = lazySchema2(
12195
12807
  () => zodSchema3(
12196
12808
  z.object({
12197
12809
  query: z.union([z.string(), z.array(z.string())]).describe(
@@ -12233,7 +12845,7 @@ var perplexitySearchInputSchema = lazySchema(
12233
12845
  })
12234
12846
  )
12235
12847
  );
12236
- var perplexitySearchOutputSchema = lazySchema(
12848
+ var perplexitySearchOutputSchema2 = lazySchema2(
12237
12849
  () => zodSchema3(
12238
12850
  z.union([
12239
12851
  // Success response
@@ -12264,13 +12876,13 @@ var perplexitySearchOutputSchema = lazySchema(
12264
12876
  ])
12265
12877
  )
12266
12878
  );
12267
- var perplexitySearchToolFactory = createProviderToolFactoryWithOutputSchema({
12879
+ var perplexitySearchToolFactory2 = createProviderToolFactoryWithOutputSchema({
12268
12880
  id: "gateway.perplexity_search",
12269
- inputSchema: perplexitySearchInputSchema,
12270
- outputSchema: perplexitySearchOutputSchema
12881
+ inputSchema: perplexitySearchInputSchema2,
12882
+ outputSchema: perplexitySearchOutputSchema2
12271
12883
  });
12272
- var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
12273
- var gatewayTools = {
12884
+ var perplexitySearch2 = (config = {}) => perplexitySearchToolFactory2(config);
12885
+ var gatewayTools2 = {
12274
12886
  /**
12275
12887
  * Search the web using Parallel AI's Search API for LLM-optimized excerpts.
12276
12888
  *
@@ -12279,7 +12891,7 @@ var gatewayTools = {
12279
12891
  * or complex queries. Supports different search types for depth vs
12280
12892
  * breadth tradeoffs.
12281
12893
  */
12282
- parallelSearch,
12894
+ parallelSearch: parallelSearch2,
12283
12895
  /**
12284
12896
  * Search the web using Perplexity's Search API for real-time information,
12285
12897
  * news, research papers, and articles.
@@ -12287,21 +12899,21 @@ var gatewayTools = {
12287
12899
  * Provides ranked search results with advanced filtering options including
12288
12900
  * domain, language, date range, and recency filters.
12289
12901
  */
12290
- perplexitySearch
12902
+ perplexitySearch: perplexitySearch2
12291
12903
  };
12292
12904
  async function getVercelRequestId2() {
12293
- var _a832;
12294
- return (_a832 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a832["x-vercel-id"];
12905
+ var _a932;
12906
+ return (_a932 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a932["x-vercel-id"];
12295
12907
  }
12296
- var VERSION5 = "3.0.32";
12908
+ var VERSION5 = "3.0.66";
12297
12909
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
12298
12910
  function createGatewayProvider2(options = {}) {
12299
- var _a832, _b83;
12911
+ var _a932, _b93;
12300
12912
  let pendingMetadata = null;
12301
12913
  let metadataCache = null;
12302
- const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
12914
+ const cacheRefreshMillis = (_a932 = options.metadataCacheRefreshMillis) != null ? _a932 : 1e3 * 60 * 5;
12303
12915
  let lastFetchTime = 0;
12304
- const baseURL = (_b83 = withoutTrailingSlash2(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v3/ai";
12916
+ const baseURL = (_b93 = withoutTrailingSlash2(options.baseURL)) != null ? _b93 : "https://ai-gateway.vercel.sh/v3/ai";
12305
12917
  const getHeaders = async () => {
12306
12918
  try {
12307
12919
  const auth = await getGatewayAuthToken2(options);
@@ -12336,13 +12948,18 @@ function createGatewayProvider2(options = {}) {
12336
12948
  settingValue: void 0,
12337
12949
  environmentVariableName: "VERCEL_REGION"
12338
12950
  });
12951
+ const projectId = loadOptionalSetting2({
12952
+ settingValue: void 0,
12953
+ environmentVariableName: "VERCEL_PROJECT_ID"
12954
+ });
12339
12955
  return async () => {
12340
12956
  const requestId = await getVercelRequestId2();
12341
12957
  return {
12342
12958
  ...deploymentId && { "ai-o11y-deployment-id": deploymentId },
12343
12959
  ...environment && { "ai-o11y-environment": environment },
12344
12960
  ...region && { "ai-o11y-region": region },
12345
- ...requestId && { "ai-o11y-request-id": requestId }
12961
+ ...requestId && { "ai-o11y-request-id": requestId },
12962
+ ...projectId && { "ai-o11y-project-id": projectId }
12346
12963
  };
12347
12964
  };
12348
12965
  };
@@ -12356,8 +12973,8 @@ function createGatewayProvider2(options = {}) {
12356
12973
  });
12357
12974
  };
12358
12975
  const getAvailableModels = async () => {
12359
- var _a922, _b92, _c;
12360
- const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
12976
+ var _a1022, _b103, _c;
12977
+ const now2 = (_c = (_b103 = (_a1022 = options._internal) == null ? void 0 : _a1022.currentDate) == null ? void 0 : _b103.call(_a1022).getTime()) != null ? _c : Date.now();
12361
12978
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
12362
12979
  lastFetchTime = now2;
12363
12980
  pendingMetadata = new GatewayFetchMetadata2({
@@ -12420,7 +13037,20 @@ function createGatewayProvider2(options = {}) {
12420
13037
  };
12421
13038
  provider.embeddingModel = createEmbeddingModel;
12422
13039
  provider.textEmbeddingModel = createEmbeddingModel;
12423
- provider.tools = gatewayTools;
13040
+ provider.videoModel = (modelId) => {
13041
+ return new GatewayVideoModel(modelId, {
13042
+ provider: "gateway",
13043
+ baseURL,
13044
+ headers: getHeaders,
13045
+ fetch: options.fetch,
13046
+ o11yHeaders: createO11yHeaders()
13047
+ });
13048
+ };
13049
+ provider.chat = provider.languageModel;
13050
+ provider.embedding = provider.embeddingModel;
13051
+ provider.image = provider.imageModel;
13052
+ provider.video = provider.videoModel;
13053
+ provider.tools = gatewayTools2;
12424
13054
  return provider;
12425
13055
  }
12426
13056
  var gateway2 = createGatewayProvider2();
@@ -12534,12 +13164,12 @@ function registerGlobal3(type, instance, diag, allowOverride) {
12534
13164
  return true;
12535
13165
  }
12536
13166
  function getGlobal3(type) {
12537
- var _a21, _b83;
13167
+ var _a21, _b93;
12538
13168
  var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
12539
13169
  if (!globalVersion || !isCompatible3(globalVersion)) {
12540
13170
  return;
12541
13171
  }
12542
- return (_b83 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b83 === void 0 ? void 0 : _b83[type];
13172
+ return (_b93 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b93 === void 0 ? void 0 : _b93[type];
12543
13173
  }
12544
13174
  function unregisterGlobal3(type, diag) {
12545
13175
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION23 + ".");
@@ -12704,7 +13334,7 @@ var DiagAPI3 = (
12704
13334
  }
12705
13335
  var self = this;
12706
13336
  var setLogger = function(logger, optionsOrLogLevel) {
12707
- var _a21, _b83, _c;
13337
+ var _a21, _b93, _c;
12708
13338
  if (optionsOrLogLevel === void 0) {
12709
13339
  optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
12710
13340
  }
@@ -12719,7 +13349,7 @@ var DiagAPI3 = (
12719
13349
  };
12720
13350
  }
12721
13351
  var oldLogger = getGlobal3("diag");
12722
- var newLogger = createLogLevelDiagLogger3((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel3.INFO, logger);
13352
+ var newLogger = createLogLevelDiagLogger3((_b93 = optionsOrLogLevel.logLevel) !== null && _b93 !== void 0 ? _b93 : DiagLogLevel3.INFO, logger);
12723
13353
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
12724
13354
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
12725
13355
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -13152,10 +13782,10 @@ var __export3 = (target, all) => {
13152
13782
  for (var name21 in all)
13153
13783
  __defProp4(target, name21, { get: all[name21], enumerable: true });
13154
13784
  };
13155
- var name76 = "AI_InvalidArgumentError";
13156
- var marker86 = `vercel.ai.error.${name76}`;
13157
- var symbol86 = Symbol.for(marker86);
13158
- var _a86;
13785
+ var name86 = "AI_InvalidArgumentError";
13786
+ var marker96 = `vercel.ai.error.${name86}`;
13787
+ var symbol96 = Symbol.for(marker96);
13788
+ var _a96;
13159
13789
  var InvalidArgumentError23 = class extends AISDKError3 {
13160
13790
  constructor({
13161
13791
  parameter,
@@ -13163,20 +13793,20 @@ var InvalidArgumentError23 = class extends AISDKError3 {
13163
13793
  message
13164
13794
  }) {
13165
13795
  super({
13166
- name: name76,
13796
+ name: name86,
13167
13797
  message: `Invalid argument for parameter ${parameter}: ${message}`
13168
13798
  });
13169
- this[_a86] = true;
13799
+ this[_a96] = true;
13170
13800
  this.parameter = parameter;
13171
13801
  this.value = value;
13172
13802
  }
13173
13803
  static isInstance(error) {
13174
- return AISDKError3.hasMarker(error, marker86);
13804
+ return AISDKError3.hasMarker(error, marker96);
13175
13805
  }
13176
13806
  };
13177
- _a86 = symbol86;
13178
- var name86 = "AI_NoObjectGeneratedError";
13179
- var marker823 = `vercel.ai.error.${name86}`;
13807
+ _a96 = symbol96;
13808
+ var name823 = "AI_NoObjectGeneratedError";
13809
+ var marker823 = `vercel.ai.error.${name823}`;
13180
13810
  var symbol823 = Symbol.for(marker823);
13181
13811
  var _a823;
13182
13812
  var NoObjectGeneratedError3 = class extends AISDKError3 {
@@ -13188,7 +13818,7 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
13188
13818
  usage,
13189
13819
  finishReason
13190
13820
  }) {
13191
- super({ name: name86, message, cause });
13821
+ super({ name: name823, message, cause });
13192
13822
  this[_a823] = true;
13193
13823
  this.text = text22;
13194
13824
  this.response = response;
@@ -13348,7 +13978,7 @@ function getTotalTimeoutMs(timeout) {
13348
13978
  }
13349
13979
  return timeout.totalMs;
13350
13980
  }
13351
- var VERSION33 = "6.0.69";
13981
+ var VERSION33 = "6.0.116";
13352
13982
  var dataContentSchema3 = z$1.union([
13353
13983
  z$1.string(),
13354
13984
  z$1.instanceof(Uint8Array),
@@ -13356,8 +13986,8 @@ var dataContentSchema3 = z$1.union([
13356
13986
  z$1.custom(
13357
13987
  // Buffer might not be available in some environments such as CloudFlare:
13358
13988
  (value) => {
13359
- var _a21, _b83;
13360
- return (_b83 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b83 : false;
13989
+ var _a21, _b93;
13990
+ return (_b93 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b93 : false;
13361
13991
  },
13362
13992
  { message: "Must be a Buffer" }
13363
13993
  )