@mastra/memory 1.8.2 → 1.8.3-alpha.1

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 (78) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/chunk-3PUO6DLX.js +439 -0
  3. package/dist/chunk-3PUO6DLX.js.map +1 -0
  4. package/dist/{chunk-SUU4IAZJ.js → chunk-4KPXPQX3.js} +212 -75
  5. package/dist/chunk-4KPXPQX3.js.map +1 -0
  6. package/dist/{chunk-23EXJLET.cjs → chunk-CK4U3AYR.cjs} +4 -4
  7. package/dist/{chunk-23EXJLET.cjs.map → chunk-CK4U3AYR.cjs.map} +1 -1
  8. package/dist/chunk-DAJJSFVA.cjs +441 -0
  9. package/dist/chunk-DAJJSFVA.cjs.map +1 -0
  10. package/dist/{chunk-YPFNHFT6.cjs → chunk-LGCREJMO.cjs} +212 -74
  11. package/dist/chunk-LGCREJMO.cjs.map +1 -0
  12. package/dist/{chunk-BSDWQEU3.js → chunk-SVPZMV27.js} +4 -4
  13. package/dist/{chunk-BSDWQEU3.js.map → chunk-SVPZMV27.js.map} +1 -1
  14. package/dist/docs/SKILL.md +1 -1
  15. package/dist/docs/assets/SOURCE_MAP.json +30 -25
  16. package/dist/docs/references/docs-agents-agent-approval.md +4 -4
  17. package/dist/docs/references/docs-agents-network-approval.md +1 -1
  18. package/dist/docs/references/docs-agents-networks.md +1 -1
  19. package/dist/docs/references/docs-agents-supervisor-agents.md +3 -3
  20. package/dist/docs/references/docs-memory-memory-processors.md +6 -6
  21. package/dist/docs/references/docs-memory-semantic-recall.md +1 -1
  22. package/dist/docs/references/docs-memory-storage.md +1 -1
  23. package/dist/docs/references/docs-memory-working-memory.md +1 -1
  24. package/dist/docs/references/reference-memory-memory-class.md +3 -3
  25. package/dist/docs/references/reference-memory-observational-memory.md +5 -5
  26. package/dist/docs/references/reference-processors-token-limiter-processor.md +3 -3
  27. package/dist/docs/references/reference-storage-mongodb.md +1 -1
  28. package/dist/docs/references/reference-storage-postgresql.md +1 -1
  29. package/dist/docs/references/reference-storage-upstash.md +1 -1
  30. package/dist/docs/references/reference-vectors-libsql.md +1 -1
  31. package/dist/docs/references/reference-vectors-mongodb.md +1 -1
  32. package/dist/docs/references/reference-vectors-pg.md +1 -1
  33. package/dist/docs/references/reference-vectors-upstash.md +1 -1
  34. package/dist/index.cjs +891 -255
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +881 -249
  39. package/dist/index.js.map +1 -1
  40. package/dist/{observational-memory-3HFM7PY2.cjs → observational-memory-4TV5KKFV.cjs} +21 -17
  41. package/dist/{observational-memory-3HFM7PY2.cjs.map → observational-memory-4TV5KKFV.cjs.map} +1 -1
  42. package/dist/observational-memory-UEDVTWS2.js +3 -0
  43. package/dist/{observational-memory-XXD6E2SO.js.map → observational-memory-UEDVTWS2.js.map} +1 -1
  44. package/dist/processors/index.cjs +19 -15
  45. package/dist/processors/index.js +1 -1
  46. package/dist/processors/observational-memory/index.d.ts +1 -0
  47. package/dist/processors/observational-memory/index.d.ts.map +1 -1
  48. package/dist/processors/observational-memory/observation-utils.d.ts +16 -0
  49. package/dist/processors/observational-memory/observation-utils.d.ts.map +1 -0
  50. package/dist/processors/observational-memory/observational-memory.d.ts +13 -4
  51. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
  52. package/dist/processors/observational-memory/observer-agent.d.ts +9 -7
  53. package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
  54. package/dist/processors/observational-memory/token-counter.d.ts.map +1 -1
  55. package/dist/processors/observational-memory/tool-result-helpers.d.ts +12 -0
  56. package/dist/processors/observational-memory/tool-result-helpers.d.ts.map +1 -0
  57. package/dist/{token-6GSAFR2W-TW2P7HCS.cjs → token-APYSY3BW-POD4OUWN.cjs} +14 -14
  58. package/dist/token-APYSY3BW-POD4OUWN.cjs.map +1 -0
  59. package/dist/{token-6GSAFR2W-ABXTQD64.js → token-APYSY3BW-YTVQELJT.js} +11 -11
  60. package/dist/token-APYSY3BW-YTVQELJT.js.map +1 -0
  61. package/dist/token-util-RMHT2CPJ-77HHGIQN.cjs +10 -0
  62. package/dist/token-util-RMHT2CPJ-77HHGIQN.cjs.map +1 -0
  63. package/dist/token-util-RMHT2CPJ-WJZ2SYAR.js +8 -0
  64. package/dist/token-util-RMHT2CPJ-WJZ2SYAR.js.map +1 -0
  65. package/package.json +8 -8
  66. package/dist/chunk-HJYHDIOC.js +0 -250
  67. package/dist/chunk-HJYHDIOC.js.map +0 -1
  68. package/dist/chunk-LIBOSOHM.cjs +0 -252
  69. package/dist/chunk-LIBOSOHM.cjs.map +0 -1
  70. package/dist/chunk-SUU4IAZJ.js.map +0 -1
  71. package/dist/chunk-YPFNHFT6.cjs.map +0 -1
  72. package/dist/observational-memory-XXD6E2SO.js +0 -3
  73. package/dist/token-6GSAFR2W-ABXTQD64.js.map +0 -1
  74. package/dist/token-6GSAFR2W-TW2P7HCS.cjs.map +0 -1
  75. package/dist/token-util-NEHG7TUY-GYFEVMWP.cjs +0 -10
  76. package/dist/token-util-NEHG7TUY-GYFEVMWP.cjs.map +0 -1
  77. package/dist/token-util-NEHG7TUY-XQP3QSPX.js +0 -8
  78. package/dist/token-util-NEHG7TUY-XQP3QSPX.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk23EXJLET_cjs = require('./chunk-23EXJLET.cjs');
3
+ var chunkCK4U3AYR_cjs = require('./chunk-CK4U3AYR.cjs');
4
4
  var chunkIDRQZVB4_cjs = require('./chunk-IDRQZVB4.cjs');
5
+ var chunkLGCREJMO_cjs = require('./chunk-LGCREJMO.cjs');
5
6
  var v3 = require('zod/v3');
6
7
  var zod = require('zod');
7
8
  var z4 = require('zod/v4');
@@ -39,7 +40,7 @@ function _interopNamespace(e) {
39
40
  var z4__namespace = /*#__PURE__*/_interopNamespace(z4);
40
41
  var xxhash__default = /*#__PURE__*/_interopDefault(xxhash);
41
42
 
42
- // ../_vendored/ai_v4/dist/chunk-GBOGIFXJ.js
43
+ // ../_vendored/ai_v4/dist/chunk-OPIPXJLE.js
43
44
  var __create = Object.create;
44
45
  var __defProp = Object.defineProperty;
45
46
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -179,13 +180,13 @@ var _AISDKError = class _AISDKError2 extends Error {
179
180
  * @param {unknown} [params.cause] - The underlying cause of the error.
180
181
  */
181
182
  constructor({
182
- name: name145,
183
+ name: name146,
183
184
  message,
184
185
  cause
185
186
  }) {
186
187
  super(message);
187
188
  this[_a] = true;
188
- this.name = name145;
189
+ this.name = name146;
189
190
  this.cause = cause;
190
191
  }
191
192
  /**
@@ -196,8 +197,8 @@ var _AISDKError = class _AISDKError2 extends Error {
196
197
  static isInstance(error) {
197
198
  return _AISDKError2.hasMarker(error, marker);
198
199
  }
199
- static hasMarker(error, marker155) {
200
- const markerSymbol = Symbol.for(marker155);
200
+ static hasMarker(error, marker156) {
201
+ const markerSymbol = Symbol.for(marker156);
201
202
  return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
202
203
  }
203
204
  };
@@ -2379,12 +2380,12 @@ function registerGlobal(type, instance, diag, allowOverride) {
2379
2380
  return true;
2380
2381
  }
2381
2382
  function getGlobal(type) {
2382
- var _a173, _b17;
2383
+ var _a173, _b19;
2383
2384
  var globalVersion = (_a173 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a173 === void 0 ? void 0 : _a173.version;
2384
2385
  if (!globalVersion || !isCompatible(globalVersion)) {
2385
2386
  return;
2386
2387
  }
2387
- return (_b17 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b17 === void 0 ? void 0 : _b17[type];
2388
+ return (_b19 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b19 === void 0 ? void 0 : _b19[type];
2388
2389
  }
2389
2390
  function unregisterGlobal(type, diag) {
2390
2391
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
@@ -2549,7 +2550,7 @@ var DiagAPI = (
2549
2550
  }
2550
2551
  var self = this;
2551
2552
  var setLogger = function(logger, optionsOrLogLevel) {
2552
- var _a173, _b17, _c;
2553
+ var _a173, _b19, _c;
2553
2554
  if (optionsOrLogLevel === void 0) {
2554
2555
  optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
2555
2556
  }
@@ -2564,7 +2565,7 @@ var DiagAPI = (
2564
2565
  };
2565
2566
  }
2566
2567
  var oldLogger = getGlobal("diag");
2567
- var newLogger = createLogLevelDiagLogger((_b17 = optionsOrLogLevel.logLevel) !== null && _b17 !== void 0 ? _b17 : DiagLogLevel.INFO, logger);
2568
+ var newLogger = createLogLevelDiagLogger((_b19 = optionsOrLogLevel.logLevel) !== null && _b19 !== void 0 ? _b19 : DiagLogLevel.INFO, logger);
2568
2569
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
2569
2570
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
2570
2571
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -3525,8 +3526,8 @@ var dataContentSchema = zod.z.union([
3525
3526
  zod.z.custom(
3526
3527
  // Buffer might not be available in some environments such as CloudFlare:
3527
3528
  (value) => {
3528
- var _a173, _b17;
3529
- return (_b17 = (_a173 = globalThis.Buffer) == null ? void 0 : _a173.isBuffer(value)) != null ? _b17 : false;
3529
+ var _a173, _b19;
3530
+ return (_b19 = (_a173 = globalThis.Buffer) == null ? void 0 : _a173.isBuffer(value)) != null ? _b19 : false;
3530
3531
  },
3531
3532
  { message: "Must be a Buffer" }
3532
3533
  )
@@ -4138,7 +4139,8 @@ function trimStartOfStream() {
4138
4139
  var marker17 = "vercel.ai.error";
4139
4140
  var symbol17 = Symbol.for(marker17);
4140
4141
  var _a17;
4141
- var _AISDKError3 = class _AISDKError22 extends Error {
4142
+ var _b;
4143
+ var AISDKError2 = class _AISDKError3 extends (_b = Error, _a17 = symbol17, _b) {
4142
4144
  /**
4143
4145
  * Creates an AI SDK Error.
4144
4146
  *
@@ -4148,13 +4150,13 @@ var _AISDKError3 = class _AISDKError22 extends Error {
4148
4150
  * @param {unknown} [params.cause] - The underlying cause of the error.
4149
4151
  */
4150
4152
  constructor({
4151
- name: name145,
4153
+ name: name1422,
4152
4154
  message,
4153
4155
  cause
4154
4156
  }) {
4155
4157
  super(message);
4156
4158
  this[_a17] = true;
4157
- this.name = name145;
4159
+ this.name = name1422;
4158
4160
  this.cause = cause;
4159
4161
  }
4160
4162
  /**
@@ -4163,20 +4165,19 @@ var _AISDKError3 = class _AISDKError22 extends Error {
4163
4165
  * @returns {boolean} True if the error is an AI SDK Error, false otherwise.
4164
4166
  */
4165
4167
  static isInstance(error) {
4166
- return _AISDKError22.hasMarker(error, marker17);
4168
+ return _AISDKError3.hasMarker(error, marker17);
4167
4169
  }
4168
- static hasMarker(error, marker155) {
4169
- const markerSymbol = Symbol.for(marker155);
4170
+ static hasMarker(error, marker1522) {
4171
+ const markerSymbol = Symbol.for(marker1522);
4170
4172
  return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
4171
4173
  }
4172
4174
  };
4173
- _a17 = symbol17;
4174
- var AISDKError2 = _AISDKError3;
4175
4175
  var name17 = "AI_APICallError";
4176
4176
  var marker23 = `vercel.ai.error.${name17}`;
4177
4177
  var symbol23 = Symbol.for(marker23);
4178
4178
  var _a23;
4179
- var APICallError2 = class extends AISDKError2 {
4179
+ var _b2;
4180
+ var APICallError2 = class extends (_b2 = AISDKError2, _a23 = symbol23, _b2) {
4180
4181
  constructor({
4181
4182
  message,
4182
4183
  url,
@@ -4206,12 +4207,12 @@ var APICallError2 = class extends AISDKError2 {
4206
4207
  return AISDKError2.hasMarker(error, marker23);
4207
4208
  }
4208
4209
  };
4209
- _a23 = symbol23;
4210
4210
  var name23 = "AI_EmptyResponseBodyError";
4211
4211
  var marker33 = `vercel.ai.error.${name23}`;
4212
4212
  var symbol33 = Symbol.for(marker33);
4213
4213
  var _a33;
4214
- var EmptyResponseBodyError = class extends AISDKError2 {
4214
+ var _b3;
4215
+ var EmptyResponseBodyError = class extends (_b3 = AISDKError2, _a33 = symbol33, _b3) {
4215
4216
  // used in isInstance
4216
4217
  constructor({ message = "Empty response body" } = {}) {
4217
4218
  super({ name: name23, message });
@@ -4221,7 +4222,6 @@ var EmptyResponseBodyError = class extends AISDKError2 {
4221
4222
  return AISDKError2.hasMarker(error, marker33);
4222
4223
  }
4223
4224
  };
4224
- _a33 = symbol33;
4225
4225
  function getErrorMessage3(error) {
4226
4226
  if (error == null) {
4227
4227
  return "unknown error";
@@ -4238,7 +4238,8 @@ var name33 = "AI_InvalidArgumentError";
4238
4238
  var marker43 = `vercel.ai.error.${name33}`;
4239
4239
  var symbol43 = Symbol.for(marker43);
4240
4240
  var _a43;
4241
- var InvalidArgumentError3 = class extends AISDKError2 {
4241
+ var _b4;
4242
+ var InvalidArgumentError3 = class extends (_b4 = AISDKError2, _a43 = symbol43, _b4) {
4242
4243
  constructor({
4243
4244
  message,
4244
4245
  cause,
@@ -4252,12 +4253,12 @@ var InvalidArgumentError3 = class extends AISDKError2 {
4252
4253
  return AISDKError2.hasMarker(error, marker43);
4253
4254
  }
4254
4255
  };
4255
- _a43 = symbol43;
4256
4256
  var name63 = "AI_JSONParseError";
4257
4257
  var marker73 = `vercel.ai.error.${name63}`;
4258
4258
  var symbol73 = Symbol.for(marker73);
4259
4259
  var _a73;
4260
- var JSONParseError2 = class extends AISDKError2 {
4260
+ var _b7;
4261
+ var JSONParseError2 = class extends (_b7 = AISDKError2, _a73 = symbol73, _b7) {
4261
4262
  constructor({ text: text4, cause }) {
4262
4263
  super({
4263
4264
  name: name63,
@@ -4272,12 +4273,12 @@ Error message: ${getErrorMessage3(cause)}`,
4272
4273
  return AISDKError2.hasMarker(error, marker73);
4273
4274
  }
4274
4275
  };
4275
- _a73 = symbol73;
4276
4276
  var name123 = "AI_TypeValidationError";
4277
4277
  var marker133 = `vercel.ai.error.${name123}`;
4278
4278
  var symbol133 = Symbol.for(marker133);
4279
4279
  var _a133;
4280
- var _TypeValidationError3 = class _TypeValidationError22 extends AISDKError2 {
4280
+ var _b13;
4281
+ var TypeValidationError2 = class _TypeValidationError3 extends (_b13 = AISDKError2, _a133 = symbol133, _b13) {
4281
4282
  constructor({ value, cause }) {
4282
4283
  super({
4283
4284
  name: name123,
@@ -4305,11 +4306,9 @@ Error message: ${getErrorMessage3(cause)}`,
4305
4306
  value,
4306
4307
  cause
4307
4308
  }) {
4308
- return _TypeValidationError22.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError22({ value, cause });
4309
+ return _TypeValidationError3.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError3({ value, cause });
4309
4310
  }
4310
4311
  };
4311
- _a133 = symbol133;
4312
- var TypeValidationError2 = _TypeValidationError3;
4313
4312
  var ParseError = class extends Error {
4314
4313
  constructor(message, options) {
4315
4314
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
@@ -4540,14 +4539,14 @@ function handleFetchError({
4540
4539
  return error;
4541
4540
  }
4542
4541
  function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
4543
- var _a155, _b17, _c;
4542
+ var _a224, _b222, _c;
4544
4543
  if (globalThisAny.window) {
4545
4544
  return `runtime/browser`;
4546
4545
  }
4547
- if ((_a155 = globalThisAny.navigator) == null ? void 0 : _a155.userAgent) {
4546
+ if ((_a224 = globalThisAny.navigator) == null ? void 0 : _a224.userAgent) {
4548
4547
  return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
4549
4548
  }
4550
- if ((_c = (_b17 = globalThisAny.process) == null ? void 0 : _b17.versions) == null ? void 0 : _c.node) {
4549
+ if ((_c = (_b222 = globalThisAny.process) == null ? void 0 : _b222.versions) == null ? void 0 : _c.node) {
4551
4550
  return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
4552
4551
  }
4553
4552
  if (globalThisAny.EdgeRuntime) {
@@ -4585,7 +4584,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
4585
4584
  );
4586
4585
  return Object.fromEntries(normalizedHeaders.entries());
4587
4586
  }
4588
- var VERSION2 = "3.0.17";
4587
+ var VERSION2 = "3.0.22";
4589
4588
  var getOriginalFetch = () => globalThis.fetch;
4590
4589
  var getFromApi = async ({
4591
4590
  url,
@@ -4670,8 +4669,8 @@ function loadOptionalSetting({
4670
4669
  }
4671
4670
  return settingValue;
4672
4671
  }
4673
- var suspectProtoRx = /"__proto__"\s*:/;
4674
- var suspectConstructorRx = /"constructor"\s*:/;
4672
+ var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
4673
+ 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*:/;
4675
4674
  function _parse(text4) {
4676
4675
  const obj = JSON.parse(text4);
4677
4676
  if (obj === null || typeof obj !== "object") {
@@ -4691,7 +4690,7 @@ function filter(obj) {
4691
4690
  if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
4692
4691
  throw new SyntaxError("Object contains forbidden prototype property");
4693
4692
  }
4694
- if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
4693
+ if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
4695
4694
  throw new SyntaxError("Object contains forbidden prototype property");
4696
4695
  }
4697
4696
  for (const key in node) {
@@ -4927,6 +4926,36 @@ var postToApi = async ({
4927
4926
  throw handleFetchError({ error, url, requestBodyValues: body.values });
4928
4927
  }
4929
4928
  };
4929
+ function tool(tool22) {
4930
+ return tool22;
4931
+ }
4932
+ function createProviderDefinedToolFactoryWithOutputSchema({
4933
+ id,
4934
+ name: name224,
4935
+ inputSchema,
4936
+ outputSchema: outputSchema3
4937
+ }) {
4938
+ return ({
4939
+ execute,
4940
+ toModelOutput,
4941
+ onInputStart,
4942
+ onInputDelta,
4943
+ onInputAvailable,
4944
+ ...args
4945
+ }) => tool({
4946
+ type: "provider-defined",
4947
+ id,
4948
+ name: name224,
4949
+ args,
4950
+ inputSchema,
4951
+ outputSchema: outputSchema3,
4952
+ execute,
4953
+ toModelOutput,
4954
+ onInputStart,
4955
+ onInputDelta,
4956
+ onInputAvailable
4957
+ });
4958
+ }
4930
4959
  async function resolve(value) {
4931
4960
  if (typeof value === "function") {
4932
4961
  value = value();
@@ -5024,6 +5053,31 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
5024
5053
  rawValue: parsedResult.rawValue
5025
5054
  };
5026
5055
  };
5056
+ function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
5057
+ if (jsonSchema22.type === "object") {
5058
+ jsonSchema22.additionalProperties = false;
5059
+ const properties = jsonSchema22.properties;
5060
+ if (properties != null) {
5061
+ for (const property in properties) {
5062
+ properties[property] = addAdditionalPropertiesToJsonSchema(
5063
+ properties[property]
5064
+ );
5065
+ }
5066
+ }
5067
+ }
5068
+ if (jsonSchema22.type === "array" && jsonSchema22.items != null) {
5069
+ if (Array.isArray(jsonSchema22.items)) {
5070
+ jsonSchema22.items = jsonSchema22.items.map(
5071
+ (item) => addAdditionalPropertiesToJsonSchema(item)
5072
+ );
5073
+ } else {
5074
+ jsonSchema22.items = addAdditionalPropertiesToJsonSchema(
5075
+ jsonSchema22.items
5076
+ );
5077
+ }
5078
+ }
5079
+ return jsonSchema22;
5080
+ }
5027
5081
  var getRelativePath2 = (pathA, pathB) => {
5028
5082
  let i = 0;
5029
5083
  for (; i < pathA.length && i < pathB.length; i++) {
@@ -5066,11 +5120,11 @@ function parseAnyDef2() {
5066
5120
  return {};
5067
5121
  }
5068
5122
  function parseArrayDef2(def, refs) {
5069
- var _a155, _b17, _c;
5123
+ var _a224, _b222, _c;
5070
5124
  const res = {
5071
5125
  type: "array"
5072
5126
  };
5073
- if (((_a155 = def.type) == null ? void 0 : _a155._def) && ((_c = (_b17 = def.type) == null ? void 0 : _b17._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
5127
+ if (((_a224 = def.type) == null ? void 0 : _a224._def) && ((_c = (_b222 = def.type) == null ? void 0 : _b222._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
5074
5128
  res.items = parseDef2(def.type._def, {
5075
5129
  ...refs,
5076
5130
  currentPath: [...refs.currentPath, "items"]
@@ -5429,8 +5483,8 @@ function escapeNonAlphaNumeric2(source) {
5429
5483
  return result;
5430
5484
  }
5431
5485
  function addFormat2(schema, value, message, refs) {
5432
- var _a155;
5433
- if (schema.format || ((_a155 = schema.anyOf) == null ? void 0 : _a155.some((x) => x.format))) {
5486
+ var _a224;
5487
+ if (schema.format || ((_a224 = schema.anyOf) == null ? void 0 : _a224.some((x) => x.format))) {
5434
5488
  if (!schema.anyOf) {
5435
5489
  schema.anyOf = [];
5436
5490
  }
@@ -5449,8 +5503,8 @@ function addFormat2(schema, value, message, refs) {
5449
5503
  }
5450
5504
  }
5451
5505
  function addPattern2(schema, regex, message, refs) {
5452
- var _a155;
5453
- if (schema.pattern || ((_a155 = schema.allOf) == null ? void 0 : _a155.some((x) => x.pattern))) {
5506
+ var _a224;
5507
+ if (schema.pattern || ((_a224 = schema.allOf) == null ? void 0 : _a224.some((x) => x.pattern))) {
5454
5508
  if (!schema.allOf) {
5455
5509
  schema.allOf = [];
5456
5510
  }
@@ -5469,7 +5523,7 @@ function addPattern2(schema, regex, message, refs) {
5469
5523
  }
5470
5524
  }
5471
5525
  function stringifyRegExpWithFlags2(regex, refs) {
5472
- var _a155;
5526
+ var _a224;
5473
5527
  if (!refs.applyRegexFlags || !regex.flags) {
5474
5528
  return regex.source;
5475
5529
  }
@@ -5499,7 +5553,7 @@ function stringifyRegExpWithFlags2(regex, refs) {
5499
5553
  pattern += source[i];
5500
5554
  pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
5501
5555
  inCharRange = false;
5502
- } else if (source[i + 1] === "-" && ((_a155 = source[i + 2]) == null ? void 0 : _a155.match(/[a-z]/))) {
5556
+ } else if (source[i + 1] === "-" && ((_a224 = source[i + 2]) == null ? void 0 : _a224.match(/[a-z]/))) {
5503
5557
  pattern += source[i];
5504
5558
  inCharRange = true;
5505
5559
  } else {
@@ -5541,15 +5595,15 @@ function stringifyRegExpWithFlags2(regex, refs) {
5541
5595
  return pattern;
5542
5596
  }
5543
5597
  function parseRecordDef2(def, refs) {
5544
- var _a155, _b17, _c, _d, _e, _f;
5598
+ var _a224, _b222, _c, _d, _e, _f;
5545
5599
  const schema = {
5546
5600
  type: "object",
5547
- additionalProperties: (_a155 = parseDef2(def.valueType._def, {
5601
+ additionalProperties: (_a224 = parseDef2(def.valueType._def, {
5548
5602
  ...refs,
5549
5603
  currentPath: [...refs.currentPath, "additionalProperties"]
5550
- })) != null ? _a155 : refs.allowedAdditionalProperties
5604
+ })) != null ? _a224 : refs.allowedAdditionalProperties
5551
5605
  };
5552
- if (((_b17 = def.keyType) == null ? void 0 : _b17._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
5606
+ if (((_b222 = def.keyType) == null ? void 0 : _b222._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
5553
5607
  const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
5554
5608
  return {
5555
5609
  ...schema,
@@ -5804,8 +5858,8 @@ function safeIsOptional2(schema) {
5804
5858
  }
5805
5859
  }
5806
5860
  var parseOptionalDef2 = (def, refs) => {
5807
- var _a155;
5808
- if (refs.currentPath.toString() === ((_a155 = refs.propertyPath) == null ? void 0 : _a155.toString())) {
5861
+ var _a224;
5862
+ if (refs.currentPath.toString() === ((_a224 = refs.propertyPath) == null ? void 0 : _a224.toString())) {
5809
5863
  return parseDef2(def.innerType._def, refs);
5810
5864
  }
5811
5865
  const innerSchema = parseDef2(def.innerType._def, {
@@ -5975,10 +6029,10 @@ var selectParser2 = (def, typeName, refs) => {
5975
6029
  }
5976
6030
  };
5977
6031
  function parseDef2(def, refs, forceResolution = false) {
5978
- var _a155;
6032
+ var _a224;
5979
6033
  const seenItem = refs.seen.get(def);
5980
6034
  if (refs.override) {
5981
- const overrideResult = (_a155 = refs.override) == null ? void 0 : _a155.call(
6035
+ const overrideResult = (_a224 = refs.override) == null ? void 0 : _a224.call(
5982
6036
  refs,
5983
6037
  def,
5984
6038
  refs,
@@ -6044,11 +6098,11 @@ var getRefs2 = (options) => {
6044
6098
  currentPath,
6045
6099
  propertyPath: void 0,
6046
6100
  seen: new Map(
6047
- Object.entries(_options.definitions).map(([name145, def]) => [
6101
+ Object.entries(_options.definitions).map(([name224, def]) => [
6048
6102
  def._def,
6049
6103
  {
6050
6104
  def: def._def,
6051
- path: [..._options.basePath, _options.definitionPath, name145],
6105
+ path: [..._options.basePath, _options.definitionPath, name224],
6052
6106
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
6053
6107
  jsonSchema: void 0
6054
6108
  }
@@ -6057,50 +6111,50 @@ var getRefs2 = (options) => {
6057
6111
  };
6058
6112
  };
6059
6113
  var zodToJsonSchema2 = (schema, options) => {
6060
- var _a155;
6114
+ var _a224;
6061
6115
  const refs = getRefs2(options);
6062
6116
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
6063
- (acc, [name224, schema2]) => {
6064
- var _a224;
6117
+ (acc, [name324, schema2]) => {
6118
+ var _a324;
6065
6119
  return {
6066
6120
  ...acc,
6067
- [name224]: (_a224 = parseDef2(
6121
+ [name324]: (_a324 = parseDef2(
6068
6122
  schema2._def,
6069
6123
  {
6070
6124
  ...refs,
6071
- currentPath: [...refs.basePath, refs.definitionPath, name224]
6125
+ currentPath: [...refs.basePath, refs.definitionPath, name324]
6072
6126
  },
6073
6127
  true
6074
- )) != null ? _a224 : parseAnyDef2()
6128
+ )) != null ? _a324 : parseAnyDef2()
6075
6129
  };
6076
6130
  },
6077
6131
  {}
6078
6132
  ) : void 0;
6079
- const name145 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
6080
- const main = (_a155 = parseDef2(
6133
+ const name224 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
6134
+ const main = (_a224 = parseDef2(
6081
6135
  schema._def,
6082
- name145 === void 0 ? refs : {
6136
+ name224 === void 0 ? refs : {
6083
6137
  ...refs,
6084
- currentPath: [...refs.basePath, refs.definitionPath, name145]
6138
+ currentPath: [...refs.basePath, refs.definitionPath, name224]
6085
6139
  },
6086
6140
  false
6087
- )) != null ? _a155 : parseAnyDef2();
6141
+ )) != null ? _a224 : parseAnyDef2();
6088
6142
  const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
6089
6143
  if (title !== void 0) {
6090
6144
  main.title = title;
6091
6145
  }
6092
- const combined = name145 === void 0 ? definitions ? {
6146
+ const combined = name224 === void 0 ? definitions ? {
6093
6147
  ...main,
6094
6148
  [refs.definitionPath]: definitions
6095
6149
  } : main : {
6096
6150
  $ref: [
6097
6151
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
6098
6152
  refs.definitionPath,
6099
- name145
6153
+ name224
6100
6154
  ].join("/"),
6101
6155
  [refs.definitionPath]: {
6102
6156
  ...definitions,
6103
- [name145]: main
6157
+ [name224]: main
6104
6158
  }
6105
6159
  };
6106
6160
  combined.$schema = "http://json-schema.org/draft-07/schema#";
@@ -6108,8 +6162,8 @@ var zodToJsonSchema2 = (schema, options) => {
6108
6162
  };
6109
6163
  var zod_to_json_schema_default = zodToJsonSchema2;
6110
6164
  function zod3Schema(zodSchema22, options) {
6111
- var _a155;
6112
- const useReferences = (_a155 = void 0 ) != null ? _a155 : false;
6165
+ var _a224;
6166
+ const useReferences = (_a224 = void 0 ) != null ? _a224 : false;
6113
6167
  return jsonSchema2(
6114
6168
  // defer json schema creation to avoid unnecessary computation when only validation is needed
6115
6169
  () => zod_to_json_schema_default(zodSchema22, {
@@ -6124,15 +6178,17 @@ function zod3Schema(zodSchema22, options) {
6124
6178
  );
6125
6179
  }
6126
6180
  function zod4Schema(zodSchema22, options) {
6127
- var _a155;
6128
- const useReferences = (_a155 = void 0 ) != null ? _a155 : false;
6181
+ var _a224;
6182
+ const useReferences = (_a224 = void 0 ) != null ? _a224 : false;
6129
6183
  return jsonSchema2(
6130
6184
  // defer json schema creation to avoid unnecessary computation when only validation is needed
6131
- () => z4__namespace.toJSONSchema(zodSchema22, {
6132
- target: "draft-7",
6133
- io: "output",
6134
- reused: useReferences ? "ref" : "inline"
6135
- }),
6185
+ () => addAdditionalPropertiesToJsonSchema(
6186
+ z4__namespace.toJSONSchema(zodSchema22, {
6187
+ target: "draft-7",
6188
+ io: "input",
6189
+ reused: useReferences ? "ref" : "inline"
6190
+ })
6191
+ ),
6136
6192
  {
6137
6193
  validate: async (value) => {
6138
6194
  const result = await z4__namespace.safeParseAsync(zodSchema22, value);
@@ -6152,6 +6208,15 @@ function zodSchema2(zodSchema22, options) {
6152
6208
  }
6153
6209
  }
6154
6210
  var schemaSymbol2 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
6211
+ function lazySchema(createSchema) {
6212
+ let schema;
6213
+ return () => {
6214
+ if (schema == null) {
6215
+ schema = createSchema();
6216
+ }
6217
+ return schema;
6218
+ };
6219
+ }
6155
6220
  function jsonSchema2(jsonSchema22, {
6156
6221
  validate
6157
6222
  } = {}) {
@@ -6181,8 +6246,8 @@ function asSchema2(schema) {
6181
6246
  function withoutTrailingSlash(url) {
6182
6247
  return url == null ? void 0 : url.replace(/\/$/, "");
6183
6248
  }
6184
- var require_get_context = chunk23EXJLET_cjs.__commonJS({
6185
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
6249
+ var require_get_context = chunkCK4U3AYR_cjs.__commonJS({
6250
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
6186
6251
  var __defProp22 = Object.defineProperty;
6187
6252
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6188
6253
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -6213,8 +6278,8 @@ var require_get_context = chunk23EXJLET_cjs.__commonJS({
6213
6278
  }
6214
6279
  }
6215
6280
  });
6216
- var require_get_vercel_oidc_token = chunk23EXJLET_cjs.__commonJS({
6217
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
6281
+ var require_get_vercel_oidc_token = chunkCK4U3AYR_cjs.__commonJS({
6282
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
6218
6283
  var __defProp22 = Object.defineProperty;
6219
6284
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6220
6285
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -6239,7 +6304,7 @@ var require_get_vercel_oidc_token = chunk23EXJLET_cjs.__commonJS({
6239
6304
  });
6240
6305
  module.exports = __toCommonJS(get_vercel_oidc_token_exports);
6241
6306
  var import_get_context = require_get_context();
6242
- var import_token_error = chunk23EXJLET_cjs.require_token_error();
6307
+ var import_token_error = chunkCK4U3AYR_cjs.require_token_error();
6243
6308
  async function getVercelOidcToken3() {
6244
6309
  let token = "";
6245
6310
  let err;
@@ -6250,19 +6315,23 @@ var require_get_vercel_oidc_token = chunk23EXJLET_cjs.__commonJS({
6250
6315
  }
6251
6316
  try {
6252
6317
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
6253
- await import('./token-util-NEHG7TUY-GYFEVMWP.cjs'),
6254
- await import('./token-6GSAFR2W-TW2P7HCS.cjs')
6318
+ await import('./token-util-RMHT2CPJ-77HHGIQN.cjs'),
6319
+ await import('./token-APYSY3BW-POD4OUWN.cjs')
6255
6320
  ]);
6256
6321
  if (!token || isExpired(getTokenPayload(token))) {
6257
6322
  await refreshToken();
6258
6323
  token = getVercelOidcTokenSync2();
6259
6324
  }
6260
6325
  } catch (error) {
6261
- if (err?.message && error instanceof Error) {
6262
- error.message = `${err.message}
6326
+ let message = err instanceof Error ? err.message : "";
6327
+ if (error instanceof Error) {
6328
+ message = `${message}
6263
6329
  ${error.message}`;
6264
6330
  }
6265
- throw new import_token_error.VercelOidcTokenError(`Failed to refresh OIDC token`, error);
6331
+ if (message) {
6332
+ throw new import_token_error.VercelOidcTokenError(message);
6333
+ }
6334
+ throw error;
6266
6335
  }
6267
6336
  return token;
6268
6337
  }
@@ -6277,8 +6346,8 @@ ${error.message}`;
6277
6346
  }
6278
6347
  }
6279
6348
  });
6280
- var require_dist = chunk23EXJLET_cjs.__commonJS({
6281
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
6349
+ var require_dist = chunkCK4U3AYR_cjs.__commonJS({
6350
+ "../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
6282
6351
  var __defProp22 = Object.defineProperty;
6283
6352
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6284
6353
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -6307,13 +6376,13 @@ var require_dist = chunk23EXJLET_cjs.__commonJS({
6307
6376
  var import_get_context = require_get_context();
6308
6377
  }
6309
6378
  });
6310
- var import_oidc = chunk23EXJLET_cjs.__toESM(require_dist(), 1);
6311
- var import_oidc2 = chunk23EXJLET_cjs.__toESM(require_dist(), 1);
6379
+ var import_oidc = chunkCK4U3AYR_cjs.__toESM(require_dist(), 1);
6380
+ var import_oidc2 = chunkCK4U3AYR_cjs.__toESM(require_dist(), 1);
6312
6381
  var marker18 = "vercel.ai.gateway.error";
6313
6382
  var symbol18 = Symbol.for(marker18);
6314
6383
  var _a18;
6315
- var _b;
6316
- var GatewayError = class _GatewayError extends (_b = Error, _a18 = symbol18, _b) {
6384
+ var _b16;
6385
+ var GatewayError = class _GatewayError extends (_b16 = Error, _a18 = symbol18, _b16) {
6317
6386
  constructor({
6318
6387
  message,
6319
6388
  statusCode = 500,
@@ -6340,8 +6409,8 @@ var name18 = "GatewayAuthenticationError";
6340
6409
  var marker24 = `vercel.ai.gateway.error.${name18}`;
6341
6410
  var symbol24 = Symbol.for(marker24);
6342
6411
  var _a24;
6343
- var _b2;
6344
- var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2 = GatewayError, _a24 = symbol24, _b2) {
6412
+ var _b22;
6413
+ var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b22 = GatewayError, _a24 = symbol24, _b22) {
6345
6414
  constructor({
6346
6415
  message = "Authentication failed",
6347
6416
  statusCode = 401,
@@ -6399,8 +6468,8 @@ var name24 = "GatewayInvalidRequestError";
6399
6468
  var marker34 = `vercel.ai.gateway.error.${name24}`;
6400
6469
  var symbol34 = Symbol.for(marker34);
6401
6470
  var _a34;
6402
- var _b3;
6403
- var GatewayInvalidRequestError = class extends (_b3 = GatewayError, _a34 = symbol34, _b3) {
6471
+ var _b32;
6472
+ var GatewayInvalidRequestError = class extends (_b32 = GatewayError, _a34 = symbol34, _b32) {
6404
6473
  constructor({
6405
6474
  message = "Invalid request",
6406
6475
  statusCode = 400,
@@ -6419,8 +6488,8 @@ var name34 = "GatewayRateLimitError";
6419
6488
  var marker44 = `vercel.ai.gateway.error.${name34}`;
6420
6489
  var symbol44 = Symbol.for(marker44);
6421
6490
  var _a44;
6422
- var _b4;
6423
- var GatewayRateLimitError = class extends (_b4 = GatewayError, _a44 = symbol44, _b4) {
6491
+ var _b42;
6492
+ var GatewayRateLimitError = class extends (_b42 = GatewayError, _a44 = symbol44, _b42) {
6424
6493
  constructor({
6425
6494
  message = "Rate limit exceeded",
6426
6495
  statusCode = 429,
@@ -6446,8 +6515,8 @@ var modelNotFoundParamSchema = lazyValidator(
6446
6515
  )
6447
6516
  );
6448
6517
  var _a54;
6449
- var _b5;
6450
- var GatewayModelNotFoundError = class extends (_b5 = GatewayError, _a54 = symbol54, _b5) {
6518
+ var _b52;
6519
+ var GatewayModelNotFoundError = class extends (_b52 = GatewayError, _a54 = symbol54, _b52) {
6451
6520
  constructor({
6452
6521
  message = "Model not found",
6453
6522
  statusCode = 404,
@@ -6468,8 +6537,8 @@ var name54 = "GatewayInternalServerError";
6468
6537
  var marker64 = `vercel.ai.gateway.error.${name54}`;
6469
6538
  var symbol64 = Symbol.for(marker64);
6470
6539
  var _a64;
6471
- var _b6;
6472
- var GatewayInternalServerError = class extends (_b6 = GatewayError, _a64 = symbol64, _b6) {
6540
+ var _b62;
6541
+ var GatewayInternalServerError = class extends (_b62 = GatewayError, _a64 = symbol64, _b62) {
6473
6542
  constructor({
6474
6543
  message = "Internal server error",
6475
6544
  statusCode = 500,
@@ -6488,8 +6557,8 @@ var name64 = "GatewayResponseError";
6488
6557
  var marker74 = `vercel.ai.gateway.error.${name64}`;
6489
6558
  var symbol74 = Symbol.for(marker74);
6490
6559
  var _a74;
6491
- var _b7;
6492
- var GatewayResponseError = class extends (_b7 = GatewayError, _a74 = symbol74, _b7) {
6560
+ var _b72;
6561
+ var GatewayResponseError = class extends (_b72 = GatewayError, _a74 = symbol74, _b72) {
6493
6562
  constructor({
6494
6563
  message = "Invalid response from Gateway",
6495
6564
  statusCode = 502,
@@ -6573,21 +6642,85 @@ var gatewayErrorResponseSchema = lazyValidator(
6573
6642
  })
6574
6643
  )
6575
6644
  );
6576
- function asGatewayError(error, authMethod) {
6577
- var _a832;
6645
+ var name74 = "GatewayTimeoutError";
6646
+ var marker84 = `vercel.ai.gateway.error.${name74}`;
6647
+ var symbol84 = Symbol.for(marker84);
6648
+ var _a84;
6649
+ var _b82;
6650
+ var GatewayTimeoutError = class _GatewayTimeoutError extends (_b82 = GatewayError, _a84 = symbol84, _b82) {
6651
+ constructor({
6652
+ message = "Request timed out",
6653
+ statusCode = 408,
6654
+ cause
6655
+ } = {}) {
6656
+ super({ message, statusCode, cause });
6657
+ this[_a84] = true;
6658
+ this.name = name74;
6659
+ this.type = "timeout_error";
6660
+ }
6661
+ static isInstance(error) {
6662
+ return GatewayError.hasMarker(error) && symbol84 in error;
6663
+ }
6664
+ /**
6665
+ * Creates a helpful timeout error message with troubleshooting guidance
6666
+ */
6667
+ static createTimeoutError({
6668
+ originalMessage,
6669
+ statusCode = 408,
6670
+ cause
6671
+ }) {
6672
+ const message = `Gateway request timed out: ${originalMessage}
6673
+
6674
+ 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`;
6675
+ return new _GatewayTimeoutError({
6676
+ message,
6677
+ statusCode,
6678
+ cause
6679
+ });
6680
+ }
6681
+ };
6682
+ function isTimeoutError(error) {
6683
+ if (!(error instanceof Error)) {
6684
+ return false;
6685
+ }
6686
+ const errorCode = error.code;
6687
+ if (typeof errorCode === "string") {
6688
+ const undiciTimeoutCodes = [
6689
+ "UND_ERR_HEADERS_TIMEOUT",
6690
+ "UND_ERR_BODY_TIMEOUT",
6691
+ "UND_ERR_CONNECT_TIMEOUT"
6692
+ ];
6693
+ return undiciTimeoutCodes.includes(errorCode);
6694
+ }
6695
+ return false;
6696
+ }
6697
+ async function asGatewayError(error, authMethod) {
6698
+ var _a932;
6578
6699
  if (GatewayError.isInstance(error)) {
6579
6700
  return error;
6580
6701
  }
6702
+ if (isTimeoutError(error)) {
6703
+ return GatewayTimeoutError.createTimeoutError({
6704
+ originalMessage: error instanceof Error ? error.message : "Unknown error",
6705
+ cause: error
6706
+ });
6707
+ }
6581
6708
  if (APICallError2.isInstance(error)) {
6582
- return createGatewayErrorFromResponse({
6709
+ if (error.cause && isTimeoutError(error.cause)) {
6710
+ return GatewayTimeoutError.createTimeoutError({
6711
+ originalMessage: error.message,
6712
+ cause: error
6713
+ });
6714
+ }
6715
+ return await createGatewayErrorFromResponse({
6583
6716
  response: extractApiCallResponse(error),
6584
- statusCode: (_a832 = error.statusCode) != null ? _a832 : 500,
6717
+ statusCode: (_a932 = error.statusCode) != null ? _a932 : 500,
6585
6718
  defaultMessage: "Gateway request failed",
6586
6719
  cause: error,
6587
6720
  authMethod
6588
6721
  });
6589
6722
  }
6590
- return createGatewayErrorFromResponse({
6723
+ return await createGatewayErrorFromResponse({
6591
6724
  response: {},
6592
6725
  statusCode: 500,
6593
6726
  defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
@@ -6868,7 +7001,7 @@ var GatewayEmbeddingModel = class {
6868
7001
  abortSignal,
6869
7002
  providerOptions
6870
7003
  }) {
6871
- var _a832;
7004
+ var _a932;
6872
7005
  const resolvedHeaders = await resolve(this.config.headers());
6873
7006
  try {
6874
7007
  const {
@@ -6899,7 +7032,7 @@ var GatewayEmbeddingModel = class {
6899
7032
  });
6900
7033
  return {
6901
7034
  embeddings: responseBody.embeddings,
6902
- usage: (_a832 = responseBody.usage) != null ? _a832 : void 0,
7035
+ usage: (_a932 = responseBody.usage) != null ? _a932 : void 0,
6903
7036
  providerMetadata: responseBody.providerMetadata,
6904
7037
  response: { headers: responseHeaders, body: rawValue }
6905
7038
  };
@@ -6946,7 +7079,7 @@ var GatewayImageModel = class {
6946
7079
  headers,
6947
7080
  abortSignal
6948
7081
  }) {
6949
- var _a832;
7082
+ var _a932, _b93, _c, _d;
6950
7083
  const resolvedHeaders = await resolve(this.config.headers());
6951
7084
  try {
6952
7085
  const {
@@ -6981,16 +7114,23 @@ var GatewayImageModel = class {
6981
7114
  return {
6982
7115
  images: responseBody.images,
6983
7116
  // Always base64 strings from server
6984
- warnings: (_a832 = responseBody.warnings) != null ? _a832 : [],
7117
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
6985
7118
  providerMetadata: responseBody.providerMetadata,
6986
7119
  response: {
6987
7120
  timestamp: /* @__PURE__ */ new Date(),
6988
7121
  modelId: this.modelId,
6989
7122
  headers: responseHeaders
7123
+ },
7124
+ ...responseBody.usage != null && {
7125
+ usage: {
7126
+ inputTokens: (_b93 = responseBody.usage.inputTokens) != null ? _b93 : void 0,
7127
+ outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
7128
+ totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
7129
+ }
6990
7130
  }
6991
7131
  };
6992
7132
  } catch (error) {
6993
- throw asGatewayError(error, await parseAuthMethod(resolvedHeaders));
7133
+ throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders));
6994
7134
  }
6995
7135
  }
6996
7136
  getUrl() {
@@ -7006,6 +7146,11 @@ var GatewayImageModel = class {
7006
7146
  var providerMetadataEntrySchema = z4.z.object({
7007
7147
  images: z4.z.array(z4.z.unknown()).optional()
7008
7148
  }).catchall(z4.z.unknown());
7149
+ var gatewayImageUsageSchema = z4.z.object({
7150
+ inputTokens: z4.z.number().nullish(),
7151
+ outputTokens: z4.z.number().nullish(),
7152
+ totalTokens: z4.z.number().nullish()
7153
+ });
7009
7154
  var gatewayImageResponseSchema = z4.z.object({
7010
7155
  images: z4.z.array(z4.z.string()),
7011
7156
  // Always base64 strings over the wire
@@ -7015,21 +7160,196 @@ var gatewayImageResponseSchema = z4.z.object({
7015
7160
  message: z4.z.string()
7016
7161
  })
7017
7162
  ).optional(),
7018
- providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema).optional()
7163
+ providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema).optional(),
7164
+ usage: gatewayImageUsageSchema.optional()
7165
+ });
7166
+ var parallelSearchInputSchema = lazySchema(
7167
+ () => zodSchema2(
7168
+ zod.z.object({
7169
+ objective: zod.z.string().describe(
7170
+ "Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
7171
+ ),
7172
+ search_queries: zod.z.array(zod.z.string()).optional().describe(
7173
+ "Optional search queries to supplement the objective. Maximum 200 characters per query."
7174
+ ),
7175
+ mode: zod.z.enum(["one-shot", "agentic"]).optional().describe(
7176
+ 'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
7177
+ ),
7178
+ max_results: zod.z.number().optional().describe(
7179
+ "Maximum number of results to return (1-20). Defaults to 10 if not specified."
7180
+ ),
7181
+ source_policy: zod.z.object({
7182
+ include_domains: zod.z.array(zod.z.string()).optional().describe("List of domains to include in search results."),
7183
+ exclude_domains: zod.z.array(zod.z.string()).optional().describe("List of domains to exclude from search results."),
7184
+ after_date: zod.z.string().optional().describe(
7185
+ "Only include results published after this date (ISO 8601 format)."
7186
+ )
7187
+ }).optional().describe(
7188
+ "Source policy for controlling which domains to include/exclude and freshness."
7189
+ ),
7190
+ excerpts: zod.z.object({
7191
+ max_chars_per_result: zod.z.number().optional().describe("Maximum characters per result."),
7192
+ max_chars_total: zod.z.number().optional().describe("Maximum total characters across all results.")
7193
+ }).optional().describe("Excerpt configuration for controlling result length."),
7194
+ fetch_policy: zod.z.object({
7195
+ max_age_seconds: zod.z.number().optional().describe(
7196
+ "Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
7197
+ )
7198
+ }).optional().describe("Fetch policy for controlling content freshness.")
7199
+ })
7200
+ )
7201
+ );
7202
+ var parallelSearchOutputSchema = lazySchema(
7203
+ () => zodSchema2(
7204
+ zod.z.union([
7205
+ // Success response
7206
+ zod.z.object({
7207
+ searchId: zod.z.string(),
7208
+ results: zod.z.array(
7209
+ zod.z.object({
7210
+ url: zod.z.string(),
7211
+ title: zod.z.string(),
7212
+ excerpt: zod.z.string(),
7213
+ publishDate: zod.z.string().nullable().optional(),
7214
+ relevanceScore: zod.z.number().optional()
7215
+ })
7216
+ )
7217
+ }),
7218
+ // Error response
7219
+ zod.z.object({
7220
+ error: zod.z.enum([
7221
+ "api_error",
7222
+ "rate_limit",
7223
+ "timeout",
7224
+ "invalid_input",
7225
+ "configuration_error",
7226
+ "unknown"
7227
+ ]),
7228
+ statusCode: zod.z.number().optional(),
7229
+ message: zod.z.string()
7230
+ })
7231
+ ])
7232
+ )
7233
+ );
7234
+ var parallelSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
7235
+ id: "gateway.parallel_search",
7236
+ name: "parallel_search",
7237
+ inputSchema: parallelSearchInputSchema,
7238
+ outputSchema: parallelSearchOutputSchema
7239
+ });
7240
+ var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
7241
+ var perplexitySearchInputSchema = lazySchema(
7242
+ () => zodSchema2(
7243
+ zod.z.object({
7244
+ query: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).describe(
7245
+ "Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
7246
+ ),
7247
+ max_results: zod.z.number().optional().describe(
7248
+ "Maximum number of search results to return (1-20, default: 10)"
7249
+ ),
7250
+ max_tokens_per_page: zod.z.number().optional().describe(
7251
+ "Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
7252
+ ),
7253
+ max_tokens: zod.z.number().optional().describe(
7254
+ "Maximum total tokens across all search results (default: 25000, max: 1000000)"
7255
+ ),
7256
+ country: zod.z.string().optional().describe(
7257
+ "Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
7258
+ ),
7259
+ search_domain_filter: zod.z.array(zod.z.string()).optional().describe(
7260
+ "List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
7261
+ ),
7262
+ search_language_filter: zod.z.array(zod.z.string()).optional().describe(
7263
+ "List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
7264
+ ),
7265
+ search_after_date: zod.z.string().optional().describe(
7266
+ "Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
7267
+ ),
7268
+ search_before_date: zod.z.string().optional().describe(
7269
+ "Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
7270
+ ),
7271
+ last_updated_after_filter: zod.z.string().optional().describe(
7272
+ "Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
7273
+ ),
7274
+ last_updated_before_filter: zod.z.string().optional().describe(
7275
+ "Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
7276
+ ),
7277
+ search_recency_filter: zod.z.enum(["day", "week", "month", "year"]).optional().describe(
7278
+ "Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
7279
+ )
7280
+ })
7281
+ )
7282
+ );
7283
+ var perplexitySearchOutputSchema = lazySchema(
7284
+ () => zodSchema2(
7285
+ zod.z.union([
7286
+ // Success response
7287
+ zod.z.object({
7288
+ results: zod.z.array(
7289
+ zod.z.object({
7290
+ title: zod.z.string(),
7291
+ url: zod.z.string(),
7292
+ snippet: zod.z.string(),
7293
+ date: zod.z.string().optional(),
7294
+ lastUpdated: zod.z.string().optional()
7295
+ })
7296
+ ),
7297
+ id: zod.z.string()
7298
+ }),
7299
+ // Error response
7300
+ zod.z.object({
7301
+ error: zod.z.enum([
7302
+ "api_error",
7303
+ "rate_limit",
7304
+ "timeout",
7305
+ "invalid_input",
7306
+ "unknown"
7307
+ ]),
7308
+ statusCode: zod.z.number().optional(),
7309
+ message: zod.z.string()
7310
+ })
7311
+ ])
7312
+ )
7313
+ );
7314
+ var perplexitySearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
7315
+ id: "gateway.perplexity_search",
7316
+ name: "perplexity_search",
7317
+ inputSchema: perplexitySearchInputSchema,
7318
+ outputSchema: perplexitySearchOutputSchema
7019
7319
  });
7320
+ var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
7321
+ var gatewayTools = {
7322
+ /**
7323
+ * Search the web using Parallel AI's Search API for LLM-optimized excerpts.
7324
+ *
7325
+ * Takes a natural language objective and returns relevant excerpts,
7326
+ * replacing multiple keyword searches with a single call for broad
7327
+ * or complex queries. Supports different search types for depth vs
7328
+ * breadth tradeoffs.
7329
+ */
7330
+ parallelSearch,
7331
+ /**
7332
+ * Search the web using Perplexity's Search API for real-time information,
7333
+ * news, research papers, and articles.
7334
+ *
7335
+ * Provides ranked search results with advanced filtering options including
7336
+ * domain, language, date range, and recency filters.
7337
+ */
7338
+ perplexitySearch
7339
+ };
7020
7340
  async function getVercelRequestId() {
7021
- var _a832;
7022
- return (_a832 = (0, import_oidc.getContext)().headers) == null ? void 0 : _a832["x-vercel-id"];
7341
+ var _a932;
7342
+ return (_a932 = (0, import_oidc.getContext)().headers) == null ? void 0 : _a932["x-vercel-id"];
7023
7343
  }
7024
- var VERSION3 = "2.0.15";
7344
+ var VERSION3 = "2.0.58";
7025
7345
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
7026
7346
  function createGatewayProvider(options = {}) {
7027
- var _a832, _b83;
7347
+ var _a932, _b93;
7028
7348
  let pendingMetadata = null;
7029
7349
  let metadataCache = null;
7030
- const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
7350
+ const cacheRefreshMillis = (_a932 = options.metadataCacheRefreshMillis) != null ? _a932 : 1e3 * 60 * 5;
7031
7351
  let lastFetchTime = 0;
7032
- const baseURL = (_b83 = withoutTrailingSlash(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v1/ai";
7352
+ const baseURL = (_b93 = withoutTrailingSlash(options.baseURL)) != null ? _b93 : "https://ai-gateway.vercel.sh/v1/ai";
7033
7353
  const getHeaders = async () => {
7034
7354
  const auth = await getGatewayAuthToken(options);
7035
7355
  if (auth) {
@@ -7062,13 +7382,18 @@ function createGatewayProvider(options = {}) {
7062
7382
  settingValue: void 0,
7063
7383
  environmentVariableName: "VERCEL_REGION"
7064
7384
  });
7385
+ const projectId = loadOptionalSetting({
7386
+ settingValue: void 0,
7387
+ environmentVariableName: "VERCEL_PROJECT_ID"
7388
+ });
7065
7389
  return async () => {
7066
7390
  const requestId = await getVercelRequestId();
7067
7391
  return {
7068
7392
  ...deploymentId && { "ai-o11y-deployment-id": deploymentId },
7069
7393
  ...environment && { "ai-o11y-environment": environment },
7070
7394
  ...region && { "ai-o11y-region": region },
7071
- ...requestId && { "ai-o11y-request-id": requestId }
7395
+ ...requestId && { "ai-o11y-request-id": requestId },
7396
+ ...projectId && { "ai-o11y-project-id": projectId }
7072
7397
  };
7073
7398
  };
7074
7399
  };
@@ -7082,8 +7407,8 @@ function createGatewayProvider(options = {}) {
7082
7407
  });
7083
7408
  };
7084
7409
  const getAvailableModels = async () => {
7085
- var _a922, _b92, _c;
7086
- const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
7410
+ var _a1022, _b103, _c;
7411
+ const now2 = (_c = (_b103 = (_a1022 = options._internal) == null ? void 0 : _a1022.currentDate) == null ? void 0 : _b103.call(_a1022).getTime()) != null ? _c : Date.now();
7087
7412
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
7088
7413
  lastFetchTime = now2;
7089
7414
  pendingMetadata = new GatewayFetchMetadata({
@@ -7143,6 +7468,7 @@ function createGatewayProvider(options = {}) {
7143
7468
  o11yHeaders: createO11yHeaders()
7144
7469
  });
7145
7470
  };
7471
+ provider.tools = gatewayTools;
7146
7472
  return provider;
7147
7473
  }
7148
7474
  var gateway = createGatewayProvider();
@@ -7260,12 +7586,12 @@ function registerGlobal2(type, instance, diag, allowOverride) {
7260
7586
  return true;
7261
7587
  }
7262
7588
  function getGlobal2(type) {
7263
- var _a163, _b83;
7589
+ var _a163, _b93;
7264
7590
  var globalVersion = (_a163 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a163 === void 0 ? void 0 : _a163.version;
7265
7591
  if (!globalVersion || !isCompatible2(globalVersion)) {
7266
7592
  return;
7267
7593
  }
7268
- return (_b83 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _b83 === void 0 ? void 0 : _b83[type];
7594
+ return (_b93 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _b93 === void 0 ? void 0 : _b93[type];
7269
7595
  }
7270
7596
  function unregisterGlobal2(type, diag) {
7271
7597
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION22 + ".");
@@ -7430,7 +7756,7 @@ var DiagAPI2 = (
7430
7756
  }
7431
7757
  var self = this;
7432
7758
  var setLogger = function(logger, optionsOrLogLevel) {
7433
- var _a163, _b83, _c;
7759
+ var _a163, _b93, _c;
7434
7760
  if (optionsOrLogLevel === void 0) {
7435
7761
  optionsOrLogLevel = { logLevel: DiagLogLevel2.INFO };
7436
7762
  }
@@ -7445,7 +7771,7 @@ var DiagAPI2 = (
7445
7771
  };
7446
7772
  }
7447
7773
  var oldLogger = getGlobal2("diag");
7448
- var newLogger = createLogLevelDiagLogger2((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel2.INFO, logger);
7774
+ var newLogger = createLogLevelDiagLogger2((_b93 = optionsOrLogLevel.logLevel) !== null && _b93 !== void 0 ? _b93 : DiagLogLevel2.INFO, logger);
7449
7775
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
7450
7776
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
7451
7777
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -7936,8 +8262,8 @@ var UnsupportedModelVersionError2 = class extends AISDKError2 {
7936
8262
  this.modelId = options.modelId;
7937
8263
  }
7938
8264
  };
7939
- var name142 = "AI_RetryError";
7940
- var marker144 = `vercel.ai.error.${name142}`;
8265
+ var name143 = "AI_RetryError";
8266
+ var marker144 = `vercel.ai.error.${name143}`;
7941
8267
  var symbol144 = Symbol.for(marker144);
7942
8268
  var _a144;
7943
8269
  var RetryError2 = class extends AISDKError2 {
@@ -7946,7 +8272,7 @@ var RetryError2 = class extends AISDKError2 {
7946
8272
  reason,
7947
8273
  errors
7948
8274
  }) {
7949
- super({ name: name142, message });
8275
+ super({ name: name143, message });
7950
8276
  this[_a144] = true;
7951
8277
  this.reason = reason;
7952
8278
  this.errors = errors;
@@ -7976,7 +8302,7 @@ function getGlobalProvider() {
7976
8302
  var _a163;
7977
8303
  return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
7978
8304
  }
7979
- var VERSION32 = "5.0.101";
8305
+ var VERSION32 = "5.0.154";
7980
8306
  var dataContentSchema2 = z4.z.union([
7981
8307
  z4.z.string(),
7982
8308
  z4.z.instanceof(Uint8Array),
@@ -7984,8 +8310,8 @@ var dataContentSchema2 = z4.z.union([
7984
8310
  z4.z.custom(
7985
8311
  // Buffer might not be available in some environments such as CloudFlare:
7986
8312
  (value) => {
7987
- var _a163, _b83;
7988
- return (_b83 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b83 : false;
8313
+ var _a163, _b93;
8314
+ return (_b93 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b93 : false;
7989
8315
  },
7990
8316
  { message: "Must be a Buffer" }
7991
8317
  )
@@ -9079,8 +9405,8 @@ var object2 = ({
9079
9405
  var marker19 = "vercel.ai.error";
9080
9406
  var symbol19 = Symbol.for(marker19);
9081
9407
  var _a19;
9082
- var _b8;
9083
- var AISDKError3 = class _AISDKError4 extends (_b8 = Error, _a19 = symbol19, _b8) {
9408
+ var _b17;
9409
+ var AISDKError3 = class _AISDKError4 extends (_b17 = Error, _a19 = symbol19, _b17) {
9084
9410
  /**
9085
9411
  * Creates an AI SDK Error.
9086
9412
  *
@@ -9116,8 +9442,8 @@ var name19 = "AI_APICallError";
9116
9442
  var marker25 = `vercel.ai.error.${name19}`;
9117
9443
  var symbol25 = Symbol.for(marker25);
9118
9444
  var _a25;
9119
- var _b22;
9120
- var APICallError3 = class extends (_b22 = AISDKError3, _a25 = symbol25, _b22) {
9445
+ var _b23;
9446
+ var APICallError3 = class extends (_b23 = AISDKError3, _a25 = symbol25, _b23) {
9121
9447
  constructor({
9122
9448
  message,
9123
9449
  url,
@@ -9151,8 +9477,8 @@ var name25 = "AI_EmptyResponseBodyError";
9151
9477
  var marker35 = `vercel.ai.error.${name25}`;
9152
9478
  var symbol35 = Symbol.for(marker35);
9153
9479
  var _a35;
9154
- var _b32;
9155
- var EmptyResponseBodyError2 = class extends (_b32 = AISDKError3, _a35 = symbol35, _b32) {
9480
+ var _b33;
9481
+ var EmptyResponseBodyError2 = class extends (_b33 = AISDKError3, _a35 = symbol35, _b33) {
9156
9482
  // used in isInstance
9157
9483
  constructor({ message = "Empty response body" } = {}) {
9158
9484
  super({ name: name25, message });
@@ -9178,8 +9504,8 @@ var name35 = "AI_InvalidArgumentError";
9178
9504
  var marker45 = `vercel.ai.error.${name35}`;
9179
9505
  var symbol45 = Symbol.for(marker45);
9180
9506
  var _a45;
9181
- var _b42;
9182
- var InvalidArgumentError4 = class extends (_b42 = AISDKError3, _a45 = symbol45, _b42) {
9507
+ var _b43;
9508
+ var InvalidArgumentError4 = class extends (_b43 = AISDKError3, _a45 = symbol45, _b43) {
9183
9509
  constructor({
9184
9510
  message,
9185
9511
  cause,
@@ -9197,8 +9523,8 @@ var name65 = "AI_JSONParseError";
9197
9523
  var marker75 = `vercel.ai.error.${name65}`;
9198
9524
  var symbol75 = Symbol.for(marker75);
9199
9525
  var _a75;
9200
- var _b72;
9201
- var JSONParseError3 = class extends (_b72 = AISDKError3, _a75 = symbol75, _b72) {
9526
+ var _b73;
9527
+ var JSONParseError3 = class extends (_b73 = AISDKError3, _a75 = symbol75, _b73) {
9202
9528
  constructor({ text: text4, cause }) {
9203
9529
  super({
9204
9530
  name: name65,
@@ -9217,8 +9543,8 @@ var name125 = "AI_TypeValidationError";
9217
9543
  var marker135 = `vercel.ai.error.${name125}`;
9218
9544
  var symbol135 = Symbol.for(marker135);
9219
9545
  var _a135;
9220
- var _b13;
9221
- var TypeValidationError3 = class _TypeValidationError4 extends (_b13 = AISDKError3, _a135 = symbol135, _b13) {
9546
+ var _b132;
9547
+ var TypeValidationError3 = class _TypeValidationError4 extends (_b132 = AISDKError3, _a135 = symbol135, _b132) {
9222
9548
  constructor({
9223
9549
  value,
9224
9550
  cause,
@@ -9269,8 +9595,8 @@ Error message: ${getErrorMessage4(cause)}`,
9269
9595
  cause,
9270
9596
  context: context2
9271
9597
  }) {
9272
- var _a1522, _b152, _c;
9273
- 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)) {
9598
+ var _a1522, _b1522, _c;
9599
+ 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)) {
9274
9600
  return cause;
9275
9601
  }
9276
9602
  return new _TypeValidationError4({ value, cause, context: context2 });
@@ -9587,7 +9913,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
9587
9913
  );
9588
9914
  return Object.fromEntries(normalizedHeaders.entries());
9589
9915
  }
9590
- var VERSION4 = "4.0.13";
9916
+ var VERSION4 = "4.0.19";
9591
9917
  var getOriginalFetch3 = () => globalThis.fetch;
9592
9918
  var getFromApi2 = async ({
9593
9919
  url,
@@ -9672,8 +9998,8 @@ function loadOptionalSetting2({
9672
9998
  }
9673
9999
  return settingValue;
9674
10000
  }
9675
- var suspectProtoRx2 = /"__proto__"\s*:/;
9676
- var suspectConstructorRx2 = /"constructor"\s*:/;
10001
+ var suspectProtoRx2 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
10002
+ 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*:/;
9677
10003
  function _parse2(text4) {
9678
10004
  const obj = JSON.parse(text4);
9679
10005
  if (obj === null || typeof obj !== "object") {
@@ -9693,7 +10019,7 @@ function filter2(obj) {
9693
10019
  if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
9694
10020
  throw new SyntaxError("Object contains forbidden prototype property");
9695
10021
  }
9696
- if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
10022
+ if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
9697
10023
  throw new SyntaxError("Object contains forbidden prototype property");
9698
10024
  }
9699
10025
  for (const key in node) {
@@ -9719,7 +10045,7 @@ function secureJsonParse2(text4) {
9719
10045
  Error.stackTraceLimit = stackTraceLimit;
9720
10046
  }
9721
10047
  }
9722
- function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
10048
+ function addAdditionalPropertiesToJsonSchema2(jsonSchema22) {
9723
10049
  if (jsonSchema22.type === "object" || Array.isArray(jsonSchema22.type) && jsonSchema22.type.includes("object")) {
9724
10050
  jsonSchema22.additionalProperties = false;
9725
10051
  const { properties } = jsonSchema22;
@@ -9751,7 +10077,7 @@ function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
9751
10077
  }
9752
10078
  function visit(def) {
9753
10079
  if (typeof def === "boolean") return def;
9754
- return addAdditionalPropertiesToJsonSchema(def);
10080
+ return addAdditionalPropertiesToJsonSchema2(def);
9755
10081
  }
9756
10082
  var ignoreOverride3 = /* @__PURE__ */ Symbol(
9757
10083
  "Let zodToJsonSchema decide on which parser to use"
@@ -10836,7 +11162,7 @@ var zod3ToJsonSchema = (schema, options) => {
10836
11162
  return combined;
10837
11163
  };
10838
11164
  var schemaSymbol3 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
10839
- function lazySchema(createSchema) {
11165
+ function lazySchema2(createSchema) {
10840
11166
  let schema;
10841
11167
  return () => {
10842
11168
  if (schema == null) {
@@ -10869,7 +11195,7 @@ function asSchema3(schema) {
10869
11195
  }
10870
11196
  function standardSchema(standardSchema2) {
10871
11197
  return jsonSchema3(
10872
- () => addAdditionalPropertiesToJsonSchema(
11198
+ () => addAdditionalPropertiesToJsonSchema2(
10873
11199
  standardSchema2["~standard"].jsonSchema.input({
10874
11200
  target: "draft-07"
10875
11201
  })
@@ -10909,7 +11235,7 @@ function zod4Schema2(zodSchema22, options) {
10909
11235
  const useReferences = (_a224 = void 0 ) != null ? _a224 : false;
10910
11236
  return jsonSchema3(
10911
11237
  // defer json schema creation to avoid unnecessary computation when only validation is needed
10912
- () => addAdditionalPropertiesToJsonSchema(
11238
+ () => addAdditionalPropertiesToJsonSchema2(
10913
11239
  z4__namespace.toJSONSchema(zodSchema22, {
10914
11240
  target: "draft-7",
10915
11241
  io: "input",
@@ -11115,8 +11441,8 @@ var postToApi2 = async ({
11115
11441
  throw handleFetchError2({ error, url, requestBodyValues: body.values });
11116
11442
  }
11117
11443
  };
11118
- function tool(tool2) {
11119
- return tool2;
11444
+ function tool2(tool22) {
11445
+ return tool22;
11120
11446
  }
11121
11447
  function createProviderToolFactoryWithOutputSchema({
11122
11448
  id,
@@ -11132,7 +11458,7 @@ function createProviderToolFactoryWithOutputSchema({
11132
11458
  onInputDelta,
11133
11459
  onInputAvailable,
11134
11460
  ...args
11135
- }) => tool({
11461
+ }) => tool2({
11136
11462
  type: "provider",
11137
11463
  id,
11138
11464
  args,
@@ -11382,8 +11708,8 @@ var import_oidc22 = chunkIDRQZVB4_cjs.__toESM(require_dist2(), 1);
11382
11708
  var marker20 = "vercel.ai.gateway.error";
11383
11709
  var symbol20 = Symbol.for(marker20);
11384
11710
  var _a20;
11385
- var _b16;
11386
- var GatewayError2 = class _GatewayError2 extends (_b16 = Error, _a20 = symbol20, _b16) {
11711
+ var _b18;
11712
+ var GatewayError2 = class _GatewayError2 extends (_b18 = Error, _a20 = symbol20, _b18) {
11387
11713
  constructor({
11388
11714
  message,
11389
11715
  statusCode = 500,
@@ -11412,8 +11738,8 @@ var name20 = "GatewayAuthenticationError";
11412
11738
  var marker26 = `vercel.ai.gateway.error.${name20}`;
11413
11739
  var symbol26 = Symbol.for(marker26);
11414
11740
  var _a26;
11415
- var _b23;
11416
- var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b23 = GatewayError2, _a26 = symbol26, _b23) {
11741
+ var _b24;
11742
+ var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b24 = GatewayError2, _a26 = symbol26, _b24) {
11417
11743
  constructor({
11418
11744
  message = "Authentication failed",
11419
11745
  statusCode = 401,
@@ -11474,8 +11800,8 @@ var name26 = "GatewayInvalidRequestError";
11474
11800
  var marker36 = `vercel.ai.gateway.error.${name26}`;
11475
11801
  var symbol36 = Symbol.for(marker36);
11476
11802
  var _a36;
11477
- var _b33;
11478
- var GatewayInvalidRequestError2 = class extends (_b33 = GatewayError2, _a36 = symbol36, _b33) {
11803
+ var _b34;
11804
+ var GatewayInvalidRequestError2 = class extends (_b34 = GatewayError2, _a36 = symbol36, _b34) {
11479
11805
  constructor({
11480
11806
  message = "Invalid request",
11481
11807
  statusCode = 400,
@@ -11495,8 +11821,8 @@ var name36 = "GatewayRateLimitError";
11495
11821
  var marker46 = `vercel.ai.gateway.error.${name36}`;
11496
11822
  var symbol46 = Symbol.for(marker46);
11497
11823
  var _a46;
11498
- var _b43;
11499
- var GatewayRateLimitError2 = class extends (_b43 = GatewayError2, _a46 = symbol46, _b43) {
11824
+ var _b44;
11825
+ var GatewayRateLimitError2 = class extends (_b44 = GatewayError2, _a46 = symbol46, _b44) {
11500
11826
  constructor({
11501
11827
  message = "Rate limit exceeded",
11502
11828
  statusCode = 429,
@@ -11515,7 +11841,7 @@ var GatewayRateLimitError2 = class extends (_b43 = GatewayError2, _a46 = symbol4
11515
11841
  var name46 = "GatewayModelNotFoundError";
11516
11842
  var marker56 = `vercel.ai.gateway.error.${name46}`;
11517
11843
  var symbol56 = Symbol.for(marker56);
11518
- var modelNotFoundParamSchema2 = lazySchema(
11844
+ var modelNotFoundParamSchema2 = lazySchema2(
11519
11845
  () => zodSchema3(
11520
11846
  z4.z.object({
11521
11847
  modelId: z4.z.string()
@@ -11523,8 +11849,8 @@ var modelNotFoundParamSchema2 = lazySchema(
11523
11849
  )
11524
11850
  );
11525
11851
  var _a56;
11526
- var _b53;
11527
- var GatewayModelNotFoundError2 = class extends (_b53 = GatewayError2, _a56 = symbol56, _b53) {
11852
+ var _b54;
11853
+ var GatewayModelNotFoundError2 = class extends (_b54 = GatewayError2, _a56 = symbol56, _b54) {
11528
11854
  constructor({
11529
11855
  message = "Model not found",
11530
11856
  statusCode = 404,
@@ -11546,8 +11872,8 @@ var name56 = "GatewayInternalServerError";
11546
11872
  var marker66 = `vercel.ai.gateway.error.${name56}`;
11547
11873
  var symbol66 = Symbol.for(marker66);
11548
11874
  var _a66;
11549
- var _b63;
11550
- var GatewayInternalServerError2 = class extends (_b63 = GatewayError2, _a66 = symbol66, _b63) {
11875
+ var _b64;
11876
+ var GatewayInternalServerError2 = class extends (_b64 = GatewayError2, _a66 = symbol66, _b64) {
11551
11877
  constructor({
11552
11878
  message = "Internal server error",
11553
11879
  statusCode = 500,
@@ -11567,8 +11893,8 @@ var name66 = "GatewayResponseError";
11567
11893
  var marker76 = `vercel.ai.gateway.error.${name66}`;
11568
11894
  var symbol76 = Symbol.for(marker76);
11569
11895
  var _a76;
11570
- var _b73;
11571
- var GatewayResponseError2 = class extends (_b73 = GatewayError2, _a76 = symbol76, _b73) {
11896
+ var _b74;
11897
+ var GatewayResponseError2 = class extends (_b74 = GatewayError2, _a76 = symbol76, _b74) {
11572
11898
  constructor({
11573
11899
  message = "Invalid response from Gateway",
11574
11900
  statusCode = 502,
@@ -11595,7 +11921,7 @@ async function createGatewayErrorFromResponse2({
11595
11921
  cause,
11596
11922
  authMethod
11597
11923
  }) {
11598
- var _a832;
11924
+ var _a932;
11599
11925
  const parseResult = await safeValidateTypes3({
11600
11926
  value: response,
11601
11927
  schema: gatewayErrorResponseSchema2
@@ -11614,7 +11940,7 @@ async function createGatewayErrorFromResponse2({
11614
11940
  const validatedResponse = parseResult.value;
11615
11941
  const errorType = validatedResponse.error.type;
11616
11942
  const message = validatedResponse.error.message;
11617
- const generationId = (_a832 = validatedResponse.generationId) != null ? _a832 : void 0;
11943
+ const generationId = (_a932 = validatedResponse.generationId) != null ? _a932 : void 0;
11618
11944
  switch (errorType) {
11619
11945
  case "authentication_error":
11620
11946
  return GatewayAuthenticationError2.createContextualError({
@@ -11667,7 +11993,7 @@ async function createGatewayErrorFromResponse2({
11667
11993
  });
11668
11994
  }
11669
11995
  }
11670
- var gatewayErrorResponseSchema2 = lazySchema(
11996
+ var gatewayErrorResponseSchema2 = lazySchema2(
11671
11997
  () => zodSchema3(
11672
11998
  z4.z.object({
11673
11999
  error: z4.z.object({
@@ -11680,21 +12006,88 @@ var gatewayErrorResponseSchema2 = lazySchema(
11680
12006
  })
11681
12007
  )
11682
12008
  );
11683
- function asGatewayError2(error, authMethod) {
11684
- var _a832;
12009
+ var name76 = "GatewayTimeoutError";
12010
+ var marker86 = `vercel.ai.gateway.error.${name76}`;
12011
+ var symbol86 = Symbol.for(marker86);
12012
+ var _a86;
12013
+ var _b84;
12014
+ var GatewayTimeoutError2 = class _GatewayTimeoutError2 extends (_b84 = GatewayError2, _a86 = symbol86, _b84) {
12015
+ constructor({
12016
+ message = "Request timed out",
12017
+ statusCode = 408,
12018
+ cause,
12019
+ generationId
12020
+ } = {}) {
12021
+ super({ message, statusCode, cause, generationId });
12022
+ this[_a86] = true;
12023
+ this.name = name76;
12024
+ this.type = "timeout_error";
12025
+ }
12026
+ static isInstance(error) {
12027
+ return GatewayError2.hasMarker(error) && symbol86 in error;
12028
+ }
12029
+ /**
12030
+ * Creates a helpful timeout error message with troubleshooting guidance
12031
+ */
12032
+ static createTimeoutError({
12033
+ originalMessage,
12034
+ statusCode = 408,
12035
+ cause,
12036
+ generationId
12037
+ }) {
12038
+ const message = `Gateway request timed out: ${originalMessage}
12039
+
12040
+ 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`;
12041
+ return new _GatewayTimeoutError2({
12042
+ message,
12043
+ statusCode,
12044
+ cause,
12045
+ generationId
12046
+ });
12047
+ }
12048
+ };
12049
+ function isTimeoutError2(error) {
12050
+ if (!(error instanceof Error)) {
12051
+ return false;
12052
+ }
12053
+ const errorCode = error.code;
12054
+ if (typeof errorCode === "string") {
12055
+ const undiciTimeoutCodes = [
12056
+ "UND_ERR_HEADERS_TIMEOUT",
12057
+ "UND_ERR_BODY_TIMEOUT",
12058
+ "UND_ERR_CONNECT_TIMEOUT"
12059
+ ];
12060
+ return undiciTimeoutCodes.includes(errorCode);
12061
+ }
12062
+ return false;
12063
+ }
12064
+ async function asGatewayError2(error, authMethod) {
12065
+ var _a932;
11685
12066
  if (GatewayError2.isInstance(error)) {
11686
12067
  return error;
11687
12068
  }
12069
+ if (isTimeoutError2(error)) {
12070
+ return GatewayTimeoutError2.createTimeoutError({
12071
+ originalMessage: error instanceof Error ? error.message : "Unknown error",
12072
+ cause: error
12073
+ });
12074
+ }
11688
12075
  if (APICallError3.isInstance(error)) {
11689
- return createGatewayErrorFromResponse2({
12076
+ if (error.cause && isTimeoutError2(error.cause)) {
12077
+ return GatewayTimeoutError2.createTimeoutError({
12078
+ originalMessage: error.message,
12079
+ cause: error
12080
+ });
12081
+ }
12082
+ return await createGatewayErrorFromResponse2({
11690
12083
  response: extractApiCallResponse2(error),
11691
- statusCode: (_a832 = error.statusCode) != null ? _a832 : 500,
12084
+ statusCode: (_a932 = error.statusCode) != null ? _a932 : 500,
11692
12085
  defaultMessage: "Gateway request failed",
11693
12086
  cause: error,
11694
12087
  authMethod
11695
12088
  });
11696
12089
  }
11697
- return createGatewayErrorFromResponse2({
12090
+ return await createGatewayErrorFromResponse2({
11698
12091
  response: {},
11699
12092
  statusCode: 500,
11700
12093
  defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
@@ -11723,7 +12116,7 @@ async function parseAuthMethod2(headers) {
11723
12116
  });
11724
12117
  return result.success ? result.value : void 0;
11725
12118
  }
11726
- var gatewayAuthMethodSchema2 = lazySchema(
12119
+ var gatewayAuthMethodSchema2 = lazySchema2(
11727
12120
  () => zodSchema3(z4.z.union([z4.z.literal("api-key"), z4.z.literal("oidc")]))
11728
12121
  );
11729
12122
  var GatewayFetchMetadata2 = class {
@@ -11770,7 +12163,7 @@ var GatewayFetchMetadata2 = class {
11770
12163
  }
11771
12164
  }
11772
12165
  };
11773
- var gatewayAvailableModelsResponseSchema2 = lazySchema(
12166
+ var gatewayAvailableModelsResponseSchema2 = lazySchema2(
11774
12167
  () => zodSchema3(
11775
12168
  z4.z.object({
11776
12169
  models: z4.z.array(
@@ -11796,13 +12189,13 @@ var gatewayAvailableModelsResponseSchema2 = lazySchema(
11796
12189
  provider: z4.z.string(),
11797
12190
  modelId: z4.z.string()
11798
12191
  }),
11799
- modelType: z4.z.enum(["language", "embedding", "image"]).nullish()
12192
+ modelType: z4.z.enum(["embedding", "image", "language", "video"]).nullish()
11800
12193
  })
11801
12194
  )
11802
12195
  })
11803
12196
  )
11804
12197
  );
11805
- var gatewayCreditsResponseSchema2 = lazySchema(
12198
+ var gatewayCreditsResponseSchema2 = lazySchema2(
11806
12199
  () => zodSchema3(
11807
12200
  z4.z.object({
11808
12201
  balance: z4.z.string(),
@@ -11975,7 +12368,7 @@ var GatewayEmbeddingModel2 = class {
11975
12368
  abortSignal,
11976
12369
  providerOptions
11977
12370
  }) {
11978
- var _a832;
12371
+ var _a932;
11979
12372
  const resolvedHeaders = await resolve2(this.config.headers());
11980
12373
  try {
11981
12374
  const {
@@ -12006,7 +12399,7 @@ var GatewayEmbeddingModel2 = class {
12006
12399
  });
12007
12400
  return {
12008
12401
  embeddings: responseBody.embeddings,
12009
- usage: (_a832 = responseBody.usage) != null ? _a832 : void 0,
12402
+ usage: (_a932 = responseBody.usage) != null ? _a932 : void 0,
12010
12403
  providerMetadata: responseBody.providerMetadata,
12011
12404
  response: { headers: responseHeaders, body: rawValue },
12012
12405
  warnings: []
@@ -12025,7 +12418,7 @@ var GatewayEmbeddingModel2 = class {
12025
12418
  };
12026
12419
  }
12027
12420
  };
12028
- var gatewayEmbeddingResponseSchema2 = lazySchema(
12421
+ var gatewayEmbeddingResponseSchema2 = lazySchema2(
12029
12422
  () => zodSchema3(
12030
12423
  z4.z.object({
12031
12424
  embeddings: z4.z.array(z4.z.array(z4.z.number())),
@@ -12056,7 +12449,7 @@ var GatewayImageModel2 = class {
12056
12449
  headers,
12057
12450
  abortSignal
12058
12451
  }) {
12059
- var _a832;
12452
+ var _a932, _b93, _c, _d;
12060
12453
  const resolvedHeaders = await resolve2(this.config.headers());
12061
12454
  try {
12062
12455
  const {
@@ -12095,16 +12488,23 @@ var GatewayImageModel2 = class {
12095
12488
  return {
12096
12489
  images: responseBody.images,
12097
12490
  // Always base64 strings from server
12098
- warnings: (_a832 = responseBody.warnings) != null ? _a832 : [],
12491
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
12099
12492
  providerMetadata: responseBody.providerMetadata,
12100
12493
  response: {
12101
12494
  timestamp: /* @__PURE__ */ new Date(),
12102
12495
  modelId: this.modelId,
12103
12496
  headers: responseHeaders
12497
+ },
12498
+ ...responseBody.usage != null && {
12499
+ usage: {
12500
+ inputTokens: (_b93 = responseBody.usage.inputTokens) != null ? _b93 : void 0,
12501
+ outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
12502
+ totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
12503
+ }
12104
12504
  }
12105
12505
  };
12106
12506
  } catch (error) {
12107
- throw asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
12507
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
12108
12508
  }
12109
12509
  }
12110
12510
  getUrl() {
@@ -12129,18 +12529,231 @@ function maybeEncodeImageFile(file) {
12129
12529
  var providerMetadataEntrySchema2 = z4.z.object({
12130
12530
  images: z4.z.array(z4.z.unknown()).optional()
12131
12531
  }).catchall(z4.z.unknown());
12532
+ var gatewayImageWarningSchema = z4.z.discriminatedUnion("type", [
12533
+ z4.z.object({
12534
+ type: z4.z.literal("unsupported"),
12535
+ feature: z4.z.string(),
12536
+ details: z4.z.string().optional()
12537
+ }),
12538
+ z4.z.object({
12539
+ type: z4.z.literal("compatibility"),
12540
+ feature: z4.z.string(),
12541
+ details: z4.z.string().optional()
12542
+ }),
12543
+ z4.z.object({
12544
+ type: z4.z.literal("other"),
12545
+ message: z4.z.string()
12546
+ })
12547
+ ]);
12548
+ var gatewayImageUsageSchema2 = z4.z.object({
12549
+ inputTokens: z4.z.number().nullish(),
12550
+ outputTokens: z4.z.number().nullish(),
12551
+ totalTokens: z4.z.number().nullish()
12552
+ });
12132
12553
  var gatewayImageResponseSchema2 = z4.z.object({
12133
12554
  images: z4.z.array(z4.z.string()),
12134
12555
  // Always base64 strings over the wire
12135
- warnings: z4.z.array(
12136
- z4.z.object({
12137
- type: z4.z.literal("other"),
12138
- message: z4.z.string()
12139
- })
12140
- ).optional(),
12141
- providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema2).optional()
12556
+ warnings: z4.z.array(gatewayImageWarningSchema).optional(),
12557
+ providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema2).optional(),
12558
+ usage: gatewayImageUsageSchema2.optional()
12142
12559
  });
12143
- var parallelSearchInputSchema = lazySchema(
12560
+ var GatewayVideoModel = class {
12561
+ constructor(modelId, config) {
12562
+ this.modelId = modelId;
12563
+ this.config = config;
12564
+ this.specificationVersion = "v3";
12565
+ this.maxVideosPerCall = Number.MAX_SAFE_INTEGER;
12566
+ }
12567
+ get provider() {
12568
+ return this.config.provider;
12569
+ }
12570
+ async doGenerate({
12571
+ prompt,
12572
+ n,
12573
+ aspectRatio,
12574
+ resolution,
12575
+ duration,
12576
+ fps,
12577
+ seed,
12578
+ image,
12579
+ providerOptions,
12580
+ headers,
12581
+ abortSignal
12582
+ }) {
12583
+ var _a932;
12584
+ const resolvedHeaders = await resolve2(this.config.headers());
12585
+ try {
12586
+ const { responseHeaders, value: responseBody } = await postJsonToApi2({
12587
+ url: this.getUrl(),
12588
+ headers: combineHeaders2(
12589
+ resolvedHeaders,
12590
+ headers != null ? headers : {},
12591
+ this.getModelConfigHeaders(),
12592
+ await resolve2(this.config.o11yHeaders),
12593
+ { accept: "text/event-stream" }
12594
+ ),
12595
+ body: {
12596
+ prompt,
12597
+ n,
12598
+ ...aspectRatio && { aspectRatio },
12599
+ ...resolution && { resolution },
12600
+ ...duration && { duration },
12601
+ ...fps && { fps },
12602
+ ...seed && { seed },
12603
+ ...providerOptions && { providerOptions },
12604
+ ...image && { image: maybeEncodeVideoFile(image) }
12605
+ },
12606
+ successfulResponseHandler: async ({
12607
+ response,
12608
+ url,
12609
+ requestBodyValues
12610
+ }) => {
12611
+ if (response.body == null) {
12612
+ throw new APICallError3({
12613
+ message: "SSE response body is empty",
12614
+ url,
12615
+ requestBodyValues,
12616
+ statusCode: response.status
12617
+ });
12618
+ }
12619
+ const eventStream = parseJsonEventStream2({
12620
+ stream: response.body,
12621
+ schema: gatewayVideoEventSchema
12622
+ });
12623
+ const reader = eventStream.getReader();
12624
+ const { done, value: parseResult } = await reader.read();
12625
+ reader.releaseLock();
12626
+ if (done || !parseResult) {
12627
+ throw new APICallError3({
12628
+ message: "SSE stream ended without a data event",
12629
+ url,
12630
+ requestBodyValues,
12631
+ statusCode: response.status
12632
+ });
12633
+ }
12634
+ if (!parseResult.success) {
12635
+ throw new APICallError3({
12636
+ message: "Failed to parse video SSE event",
12637
+ cause: parseResult.error,
12638
+ url,
12639
+ requestBodyValues,
12640
+ statusCode: response.status
12641
+ });
12642
+ }
12643
+ const event = parseResult.value;
12644
+ if (event.type === "error") {
12645
+ throw new APICallError3({
12646
+ message: event.message,
12647
+ statusCode: event.statusCode,
12648
+ url,
12649
+ requestBodyValues,
12650
+ responseHeaders: Object.fromEntries([...response.headers]),
12651
+ responseBody: JSON.stringify(event),
12652
+ data: {
12653
+ error: {
12654
+ message: event.message,
12655
+ type: event.errorType,
12656
+ param: event.param
12657
+ }
12658
+ }
12659
+ });
12660
+ }
12661
+ return {
12662
+ value: {
12663
+ videos: event.videos,
12664
+ warnings: event.warnings,
12665
+ providerMetadata: event.providerMetadata
12666
+ },
12667
+ responseHeaders: Object.fromEntries([...response.headers])
12668
+ };
12669
+ },
12670
+ failedResponseHandler: createJsonErrorResponseHandler2({
12671
+ errorSchema: z4.z.any(),
12672
+ errorToMessage: (data) => data
12673
+ }),
12674
+ ...abortSignal && { abortSignal },
12675
+ fetch: this.config.fetch
12676
+ });
12677
+ return {
12678
+ videos: responseBody.videos,
12679
+ warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
12680
+ providerMetadata: responseBody.providerMetadata,
12681
+ response: {
12682
+ timestamp: /* @__PURE__ */ new Date(),
12683
+ modelId: this.modelId,
12684
+ headers: responseHeaders
12685
+ }
12686
+ };
12687
+ } catch (error) {
12688
+ throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
12689
+ }
12690
+ }
12691
+ getUrl() {
12692
+ return `${this.config.baseURL}/video-model`;
12693
+ }
12694
+ getModelConfigHeaders() {
12695
+ return {
12696
+ "ai-video-model-specification-version": "3",
12697
+ "ai-model-id": this.modelId
12698
+ };
12699
+ }
12700
+ };
12701
+ function maybeEncodeVideoFile(file) {
12702
+ if (file.type === "file" && file.data instanceof Uint8Array) {
12703
+ return {
12704
+ ...file,
12705
+ data: convertUint8ArrayToBase643(file.data)
12706
+ };
12707
+ }
12708
+ return file;
12709
+ }
12710
+ var providerMetadataEntrySchema22 = z4.z.object({
12711
+ videos: z4.z.array(z4.z.unknown()).optional()
12712
+ }).catchall(z4.z.unknown());
12713
+ var gatewayVideoDataSchema = z4.z.union([
12714
+ z4.z.object({
12715
+ type: z4.z.literal("url"),
12716
+ url: z4.z.string(),
12717
+ mediaType: z4.z.string()
12718
+ }),
12719
+ z4.z.object({
12720
+ type: z4.z.literal("base64"),
12721
+ data: z4.z.string(),
12722
+ mediaType: z4.z.string()
12723
+ })
12724
+ ]);
12725
+ var gatewayVideoWarningSchema = z4.z.discriminatedUnion("type", [
12726
+ z4.z.object({
12727
+ type: z4.z.literal("unsupported"),
12728
+ feature: z4.z.string(),
12729
+ details: z4.z.string().optional()
12730
+ }),
12731
+ z4.z.object({
12732
+ type: z4.z.literal("compatibility"),
12733
+ feature: z4.z.string(),
12734
+ details: z4.z.string().optional()
12735
+ }),
12736
+ z4.z.object({
12737
+ type: z4.z.literal("other"),
12738
+ message: z4.z.string()
12739
+ })
12740
+ ]);
12741
+ var gatewayVideoEventSchema = z4.z.discriminatedUnion("type", [
12742
+ z4.z.object({
12743
+ type: z4.z.literal("result"),
12744
+ videos: z4.z.array(gatewayVideoDataSchema),
12745
+ warnings: z4.z.array(gatewayVideoWarningSchema).optional(),
12746
+ providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema22).optional()
12747
+ }),
12748
+ z4.z.object({
12749
+ type: z4.z.literal("error"),
12750
+ message: z4.z.string(),
12751
+ errorType: z4.z.string(),
12752
+ statusCode: z4.z.number(),
12753
+ param: z4.z.unknown().nullable()
12754
+ })
12755
+ ]);
12756
+ var parallelSearchInputSchema2 = lazySchema2(
12144
12757
  () => zodSchema3(
12145
12758
  zod.z.object({
12146
12759
  objective: zod.z.string().describe(
@@ -12176,7 +12789,7 @@ var parallelSearchInputSchema = lazySchema(
12176
12789
  })
12177
12790
  )
12178
12791
  );
12179
- var parallelSearchOutputSchema = lazySchema(
12792
+ var parallelSearchOutputSchema2 = lazySchema2(
12180
12793
  () => zodSchema3(
12181
12794
  zod.z.union([
12182
12795
  // Success response
@@ -12208,13 +12821,13 @@ var parallelSearchOutputSchema = lazySchema(
12208
12821
  ])
12209
12822
  )
12210
12823
  );
12211
- var parallelSearchToolFactory = createProviderToolFactoryWithOutputSchema({
12824
+ var parallelSearchToolFactory2 = createProviderToolFactoryWithOutputSchema({
12212
12825
  id: "gateway.parallel_search",
12213
- inputSchema: parallelSearchInputSchema,
12214
- outputSchema: parallelSearchOutputSchema
12826
+ inputSchema: parallelSearchInputSchema2,
12827
+ outputSchema: parallelSearchOutputSchema2
12215
12828
  });
12216
- var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
12217
- var perplexitySearchInputSchema = lazySchema(
12829
+ var parallelSearch2 = (config = {}) => parallelSearchToolFactory2(config);
12830
+ var perplexitySearchInputSchema2 = lazySchema2(
12218
12831
  () => zodSchema3(
12219
12832
  zod.z.object({
12220
12833
  query: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).describe(
@@ -12256,7 +12869,7 @@ var perplexitySearchInputSchema = lazySchema(
12256
12869
  })
12257
12870
  )
12258
12871
  );
12259
- var perplexitySearchOutputSchema = lazySchema(
12872
+ var perplexitySearchOutputSchema2 = lazySchema2(
12260
12873
  () => zodSchema3(
12261
12874
  zod.z.union([
12262
12875
  // Success response
@@ -12287,13 +12900,13 @@ var perplexitySearchOutputSchema = lazySchema(
12287
12900
  ])
12288
12901
  )
12289
12902
  );
12290
- var perplexitySearchToolFactory = createProviderToolFactoryWithOutputSchema({
12903
+ var perplexitySearchToolFactory2 = createProviderToolFactoryWithOutputSchema({
12291
12904
  id: "gateway.perplexity_search",
12292
- inputSchema: perplexitySearchInputSchema,
12293
- outputSchema: perplexitySearchOutputSchema
12905
+ inputSchema: perplexitySearchInputSchema2,
12906
+ outputSchema: perplexitySearchOutputSchema2
12294
12907
  });
12295
- var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
12296
- var gatewayTools = {
12908
+ var perplexitySearch2 = (config = {}) => perplexitySearchToolFactory2(config);
12909
+ var gatewayTools2 = {
12297
12910
  /**
12298
12911
  * Search the web using Parallel AI's Search API for LLM-optimized excerpts.
12299
12912
  *
@@ -12302,7 +12915,7 @@ var gatewayTools = {
12302
12915
  * or complex queries. Supports different search types for depth vs
12303
12916
  * breadth tradeoffs.
12304
12917
  */
12305
- parallelSearch,
12918
+ parallelSearch: parallelSearch2,
12306
12919
  /**
12307
12920
  * Search the web using Perplexity's Search API for real-time information,
12308
12921
  * news, research papers, and articles.
@@ -12310,21 +12923,21 @@ var gatewayTools = {
12310
12923
  * Provides ranked search results with advanced filtering options including
12311
12924
  * domain, language, date range, and recency filters.
12312
12925
  */
12313
- perplexitySearch
12926
+ perplexitySearch: perplexitySearch2
12314
12927
  };
12315
12928
  async function getVercelRequestId2() {
12316
- var _a832;
12317
- return (_a832 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a832["x-vercel-id"];
12929
+ var _a932;
12930
+ return (_a932 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a932["x-vercel-id"];
12318
12931
  }
12319
- var VERSION5 = "3.0.32";
12932
+ var VERSION5 = "3.0.66";
12320
12933
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
12321
12934
  function createGatewayProvider2(options = {}) {
12322
- var _a832, _b83;
12935
+ var _a932, _b93;
12323
12936
  let pendingMetadata = null;
12324
12937
  let metadataCache = null;
12325
- const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
12938
+ const cacheRefreshMillis = (_a932 = options.metadataCacheRefreshMillis) != null ? _a932 : 1e3 * 60 * 5;
12326
12939
  let lastFetchTime = 0;
12327
- const baseURL = (_b83 = withoutTrailingSlash2(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v3/ai";
12940
+ const baseURL = (_b93 = withoutTrailingSlash2(options.baseURL)) != null ? _b93 : "https://ai-gateway.vercel.sh/v3/ai";
12328
12941
  const getHeaders = async () => {
12329
12942
  try {
12330
12943
  const auth = await getGatewayAuthToken2(options);
@@ -12359,13 +12972,18 @@ function createGatewayProvider2(options = {}) {
12359
12972
  settingValue: void 0,
12360
12973
  environmentVariableName: "VERCEL_REGION"
12361
12974
  });
12975
+ const projectId = loadOptionalSetting2({
12976
+ settingValue: void 0,
12977
+ environmentVariableName: "VERCEL_PROJECT_ID"
12978
+ });
12362
12979
  return async () => {
12363
12980
  const requestId = await getVercelRequestId2();
12364
12981
  return {
12365
12982
  ...deploymentId && { "ai-o11y-deployment-id": deploymentId },
12366
12983
  ...environment && { "ai-o11y-environment": environment },
12367
12984
  ...region && { "ai-o11y-region": region },
12368
- ...requestId && { "ai-o11y-request-id": requestId }
12985
+ ...requestId && { "ai-o11y-request-id": requestId },
12986
+ ...projectId && { "ai-o11y-project-id": projectId }
12369
12987
  };
12370
12988
  };
12371
12989
  };
@@ -12379,8 +12997,8 @@ function createGatewayProvider2(options = {}) {
12379
12997
  });
12380
12998
  };
12381
12999
  const getAvailableModels = async () => {
12382
- var _a922, _b92, _c;
12383
- const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
13000
+ var _a1022, _b103, _c;
13001
+ const now2 = (_c = (_b103 = (_a1022 = options._internal) == null ? void 0 : _a1022.currentDate) == null ? void 0 : _b103.call(_a1022).getTime()) != null ? _c : Date.now();
12384
13002
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
12385
13003
  lastFetchTime = now2;
12386
13004
  pendingMetadata = new GatewayFetchMetadata2({
@@ -12443,7 +13061,20 @@ function createGatewayProvider2(options = {}) {
12443
13061
  };
12444
13062
  provider.embeddingModel = createEmbeddingModel;
12445
13063
  provider.textEmbeddingModel = createEmbeddingModel;
12446
- provider.tools = gatewayTools;
13064
+ provider.videoModel = (modelId) => {
13065
+ return new GatewayVideoModel(modelId, {
13066
+ provider: "gateway",
13067
+ baseURL,
13068
+ headers: getHeaders,
13069
+ fetch: options.fetch,
13070
+ o11yHeaders: createO11yHeaders()
13071
+ });
13072
+ };
13073
+ provider.chat = provider.languageModel;
13074
+ provider.embedding = provider.embeddingModel;
13075
+ provider.image = provider.imageModel;
13076
+ provider.video = provider.videoModel;
13077
+ provider.tools = gatewayTools2;
12447
13078
  return provider;
12448
13079
  }
12449
13080
  var gateway2 = createGatewayProvider2();
@@ -12557,12 +13188,12 @@ function registerGlobal3(type, instance, diag, allowOverride) {
12557
13188
  return true;
12558
13189
  }
12559
13190
  function getGlobal3(type) {
12560
- var _a21, _b83;
13191
+ var _a21, _b93;
12561
13192
  var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
12562
13193
  if (!globalVersion || !isCompatible3(globalVersion)) {
12563
13194
  return;
12564
13195
  }
12565
- return (_b83 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b83 === void 0 ? void 0 : _b83[type];
13196
+ return (_b93 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b93 === void 0 ? void 0 : _b93[type];
12566
13197
  }
12567
13198
  function unregisterGlobal3(type, diag) {
12568
13199
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION23 + ".");
@@ -12727,7 +13358,7 @@ var DiagAPI3 = (
12727
13358
  }
12728
13359
  var self = this;
12729
13360
  var setLogger = function(logger, optionsOrLogLevel) {
12730
- var _a21, _b83, _c;
13361
+ var _a21, _b93, _c;
12731
13362
  if (optionsOrLogLevel === void 0) {
12732
13363
  optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
12733
13364
  }
@@ -12742,7 +13373,7 @@ var DiagAPI3 = (
12742
13373
  };
12743
13374
  }
12744
13375
  var oldLogger = getGlobal3("diag");
12745
- var newLogger = createLogLevelDiagLogger3((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel3.INFO, logger);
13376
+ var newLogger = createLogLevelDiagLogger3((_b93 = optionsOrLogLevel.logLevel) !== null && _b93 !== void 0 ? _b93 : DiagLogLevel3.INFO, logger);
12746
13377
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
12747
13378
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
12748
13379
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -13175,10 +13806,10 @@ var __export3 = (target, all) => {
13175
13806
  for (var name21 in all)
13176
13807
  __defProp4(target, name21, { get: all[name21], enumerable: true });
13177
13808
  };
13178
- var name76 = "AI_InvalidArgumentError";
13179
- var marker86 = `vercel.ai.error.${name76}`;
13180
- var symbol86 = Symbol.for(marker86);
13181
- var _a86;
13809
+ var name86 = "AI_InvalidArgumentError";
13810
+ var marker96 = `vercel.ai.error.${name86}`;
13811
+ var symbol96 = Symbol.for(marker96);
13812
+ var _a96;
13182
13813
  var InvalidArgumentError23 = class extends AISDKError3 {
13183
13814
  constructor({
13184
13815
  parameter,
@@ -13186,20 +13817,20 @@ var InvalidArgumentError23 = class extends AISDKError3 {
13186
13817
  message
13187
13818
  }) {
13188
13819
  super({
13189
- name: name76,
13820
+ name: name86,
13190
13821
  message: `Invalid argument for parameter ${parameter}: ${message}`
13191
13822
  });
13192
- this[_a86] = true;
13823
+ this[_a96] = true;
13193
13824
  this.parameter = parameter;
13194
13825
  this.value = value;
13195
13826
  }
13196
13827
  static isInstance(error) {
13197
- return AISDKError3.hasMarker(error, marker86);
13828
+ return AISDKError3.hasMarker(error, marker96);
13198
13829
  }
13199
13830
  };
13200
- _a86 = symbol86;
13201
- var name86 = "AI_NoObjectGeneratedError";
13202
- var marker823 = `vercel.ai.error.${name86}`;
13831
+ _a96 = symbol96;
13832
+ var name823 = "AI_NoObjectGeneratedError";
13833
+ var marker823 = `vercel.ai.error.${name823}`;
13203
13834
  var symbol823 = Symbol.for(marker823);
13204
13835
  var _a823;
13205
13836
  var NoObjectGeneratedError3 = class extends AISDKError3 {
@@ -13211,7 +13842,7 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
13211
13842
  usage,
13212
13843
  finishReason
13213
13844
  }) {
13214
- super({ name: name86, message, cause });
13845
+ super({ name: name823, message, cause });
13215
13846
  this[_a823] = true;
13216
13847
  this.text = text22;
13217
13848
  this.response = response;
@@ -13371,7 +14002,7 @@ function getTotalTimeoutMs(timeout) {
13371
14002
  }
13372
14003
  return timeout.totalMs;
13373
14004
  }
13374
- var VERSION33 = "6.0.69";
14005
+ var VERSION33 = "6.0.116";
13375
14006
  var dataContentSchema3 = z4.z.union([
13376
14007
  z4.z.string(),
13377
14008
  z4.z.instanceof(Uint8Array),
@@ -13379,8 +14010,8 @@ var dataContentSchema3 = z4.z.union([
13379
14010
  z4.z.custom(
13380
14011
  // Buffer might not be available in some environments such as CloudFlare:
13381
14012
  (value) => {
13382
- var _a21, _b83;
13383
- return (_b83 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b83 : false;
14013
+ var _a21, _b93;
14014
+ return (_b93 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b93 : false;
13384
14015
  },
13385
14016
  { message: "Must be a Buffer" }
13386
14017
  )
@@ -15342,14 +15973,15 @@ var Memory = class extends memory.MastraMemory {
15342
15973
  const existingWorkingMemory = await this.getWorkingMemory({ threadId, resourceId, memoryConfig }) || "";
15343
15974
  const template = await this.getWorkingMemoryTemplate({ memoryConfig });
15344
15975
  let reason = "";
15976
+ const templateContent = typeof template?.content === "string" ? template.content : null;
15345
15977
  const normalizeForComparison = (str) => str.replace(/\s+/g, " ").trim();
15346
15978
  const normalizedNewMemory = normalizeForComparison(workingMemory);
15347
- const normalizedTemplate = template?.content ? normalizeForComparison(template.content) : "";
15979
+ const normalizedTemplate = templateContent ? normalizeForComparison(templateContent) : "";
15348
15980
  if (existingWorkingMemory) {
15349
15981
  if (searchString && existingWorkingMemory?.includes(searchString)) {
15350
15982
  workingMemory = existingWorkingMemory.replace(searchString, workingMemory);
15351
15983
  reason = `found and replaced searchString with newMemory`;
15352
- } else if (existingWorkingMemory.includes(workingMemory) || template?.content?.trim() === workingMemory.trim() || // Also check normalized versions to catch template variations with different whitespace
15984
+ } else if (existingWorkingMemory.includes(workingMemory) || templateContent?.trim() === workingMemory.trim() || // Also check normalized versions to catch template variations with different whitespace
15353
15985
  normalizedNewMemory === normalizedTemplate) {
15354
15986
  return {
15355
15987
  success: false,
@@ -15370,7 +16002,7 @@ var Memory = class extends memory.MastraMemory {
15370
16002
  workingMemory = existingWorkingMemory + `
15371
16003
  ${workingMemory}`;
15372
16004
  }
15373
- } else if (workingMemory === template?.content || normalizedNewMemory === normalizedTemplate) {
16005
+ } else if (workingMemory === templateContent || normalizedNewMemory === normalizedTemplate) {
15374
16006
  return {
15375
16007
  success: false,
15376
16008
  reason: `try again when you have data to add. newMemory was equal to the working memory template`
@@ -15378,10 +16010,10 @@ ${workingMemory}`;
15378
16010
  } else {
15379
16011
  reason = `started new working memory`;
15380
16012
  }
15381
- if (template?.content) {
15382
- workingMemory = workingMemory.replaceAll(template.content, "");
15383
- const templateWithUnixLineEndings = template.content.replace(/\r\n/g, "\n");
15384
- const templateWithWindowsLineEndings = template.content.replace(/\n/g, "\r\n");
16013
+ if (templateContent) {
16014
+ workingMemory = workingMemory.replaceAll(templateContent, "");
16015
+ const templateWithUnixLineEndings = templateContent.replace(/\r\n/g, "\n");
16016
+ const templateWithWindowsLineEndings = templateContent.replace(/\n/g, "\r\n");
15385
16017
  workingMemory = workingMemory.replaceAll(templateWithUnixLineEndings, "");
15386
16018
  workingMemory = workingMemory.replaceAll(templateWithWindowsLineEndings, "");
15387
16019
  }
@@ -16383,7 +17015,7 @@ Notes:
16383
17015
  "Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
16384
17016
  );
16385
17017
  }
16386
- const { ObservationalMemory } = await import('./observational-memory-3HFM7PY2.cjs');
17018
+ const { ObservationalMemory } = await import('./observational-memory-4TV5KKFV.cjs');
16387
17019
  return new ObservationalMemory({
16388
17020
  storage: memoryStore,
16389
17021
  scope: omConfig.scope,
@@ -16414,6 +17046,10 @@ Notes:
16414
17046
  }
16415
17047
  };
16416
17048
 
17049
+ Object.defineProperty(exports, "getObservationsAsOf", {
17050
+ enumerable: true,
17051
+ get: function () { return chunkLGCREJMO_cjs.getObservationsAsOf; }
17052
+ });
16417
17053
  Object.defineProperty(exports, "extractWorkingMemoryContent", {
16418
17054
  enumerable: true,
16419
17055
  get: function () { return memory.extractWorkingMemoryContent; }