@mastra/memory 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/{chunk-M7RAJAZ6.js → chunk-SUU4IAZJ.js} +307 -39
  3. package/dist/chunk-SUU4IAZJ.js.map +1 -0
  4. package/dist/{chunk-SHID74TI.cjs → chunk-YPFNHFT6.cjs} +307 -39
  5. package/dist/chunk-YPFNHFT6.cjs.map +1 -0
  6. package/dist/docs/SKILL.md +1 -1
  7. package/dist/docs/assets/SOURCE_MAP.json +24 -24
  8. package/dist/docs/references/docs-memory-observational-memory.md +23 -0
  9. package/dist/docs/references/docs-memory-overview.md +3 -3
  10. package/dist/docs/references/reference-memory-observational-memory.md +2 -0
  11. package/dist/index.cjs +64 -368
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +64 -368
  15. package/dist/index.js.map +1 -1
  16. package/dist/{observational-memory-AU6MIH4Q.cjs → observational-memory-3HFM7PY2.cjs} +17 -17
  17. package/dist/{observational-memory-AU6MIH4Q.cjs.map → observational-memory-3HFM7PY2.cjs.map} +1 -1
  18. package/dist/{observational-memory-YRWU6CY3.js → observational-memory-XXD6E2SO.js} +3 -3
  19. package/dist/{observational-memory-YRWU6CY3.js.map → observational-memory-XXD6E2SO.js.map} +1 -1
  20. package/dist/processors/index.cjs +15 -15
  21. package/dist/processors/index.js +1 -1
  22. package/dist/processors/observational-memory/observational-memory.d.ts +21 -0
  23. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
  24. package/dist/processors/observational-memory/observer-agent.d.ts +14 -2
  25. package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
  26. package/dist/processors/observational-memory/types.d.ts +7 -0
  27. package/dist/processors/observational-memory/types.d.ts.map +1 -1
  28. package/package.json +8 -8
  29. package/dist/chunk-M7RAJAZ6.js.map +0 -1
  30. package/dist/chunk-SHID74TI.cjs.map +0 -1
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import { isStandardSchemaWithJSON as isStandardSchemaWithJSON$1, toStandardSchem
16
16
  import { createTool } from '@mastra/core/tools';
17
17
  export { MessageHistory, SemanticRecall, WorkingMemory } from '@mastra/core/processors';
18
18
 
19
- // ../_vendored/ai_v4/dist/chunk-OPIPXJLE.js
19
+ // ../_vendored/ai_v4/dist/chunk-GBOGIFXJ.js
20
20
  var __create = Object.create;
21
21
  var __defProp = Object.defineProperty;
22
22
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7001,12 +7001,12 @@ async function getVercelRequestId() {
7001
7001
  var VERSION3 = "2.0.15";
7002
7002
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
7003
7003
  function createGatewayProvider(options = {}) {
7004
- var _a832, _b84;
7004
+ var _a832, _b83;
7005
7005
  let pendingMetadata = null;
7006
7006
  let metadataCache = null;
7007
7007
  const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
7008
7008
  let lastFetchTime = 0;
7009
- const baseURL = (_b84 = withoutTrailingSlash(options.baseURL)) != null ? _b84 : "https://ai-gateway.vercel.sh/v1/ai";
7009
+ const baseURL = (_b83 = withoutTrailingSlash(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v1/ai";
7010
7010
  const getHeaders = async () => {
7011
7011
  const auth = await getGatewayAuthToken(options);
7012
7012
  if (auth) {
@@ -7059,8 +7059,8 @@ function createGatewayProvider(options = {}) {
7059
7059
  });
7060
7060
  };
7061
7061
  const getAvailableModels = async () => {
7062
- var _a923, _b92, _c;
7063
- const now2 = (_c = (_b92 = (_a923 = options._internal) == null ? void 0 : _a923.currentDate) == null ? void 0 : _b92.call(_a923).getTime()) != null ? _c : Date.now();
7062
+ var _a922, _b92, _c;
7063
+ const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
7064
7064
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
7065
7065
  lastFetchTime = now2;
7066
7066
  pendingMetadata = new GatewayFetchMetadata({
@@ -7237,12 +7237,12 @@ function registerGlobal2(type, instance, diag, allowOverride) {
7237
7237
  return true;
7238
7238
  }
7239
7239
  function getGlobal2(type) {
7240
- var _a163, _b84;
7240
+ var _a163, _b83;
7241
7241
  var globalVersion = (_a163 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a163 === void 0 ? void 0 : _a163.version;
7242
7242
  if (!globalVersion || !isCompatible2(globalVersion)) {
7243
7243
  return;
7244
7244
  }
7245
- return (_b84 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _b84 === void 0 ? void 0 : _b84[type];
7245
+ return (_b83 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _b83 === void 0 ? void 0 : _b83[type];
7246
7246
  }
7247
7247
  function unregisterGlobal2(type, diag) {
7248
7248
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION22 + ".");
@@ -7407,7 +7407,7 @@ var DiagAPI2 = (
7407
7407
  }
7408
7408
  var self = this;
7409
7409
  var setLogger = function(logger, optionsOrLogLevel) {
7410
- var _a163, _b84, _c;
7410
+ var _a163, _b83, _c;
7411
7411
  if (optionsOrLogLevel === void 0) {
7412
7412
  optionsOrLogLevel = { logLevel: DiagLogLevel2.INFO };
7413
7413
  }
@@ -7422,7 +7422,7 @@ var DiagAPI2 = (
7422
7422
  };
7423
7423
  }
7424
7424
  var oldLogger = getGlobal2("diag");
7425
- var newLogger = createLogLevelDiagLogger2((_b84 = optionsOrLogLevel.logLevel) !== null && _b84 !== void 0 ? _b84 : DiagLogLevel2.INFO, logger);
7425
+ var newLogger = createLogLevelDiagLogger2((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel2.INFO, logger);
7426
7426
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
7427
7427
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
7428
7428
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -7961,8 +7961,8 @@ var dataContentSchema2 = z$1.union([
7961
7961
  z$1.custom(
7962
7962
  // Buffer might not be available in some environments such as CloudFlare:
7963
7963
  (value) => {
7964
- var _a163, _b84;
7965
- return (_b84 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b84 : false;
7964
+ var _a163, _b83;
7965
+ return (_b83 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b83 : false;
7966
7966
  },
7967
7967
  { message: "Must be a Buffer" }
7968
7968
  )
@@ -9564,7 +9564,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
9564
9564
  );
9565
9565
  return Object.fromEntries(normalizedHeaders.entries());
9566
9566
  }
9567
- var VERSION4 = "4.0.19";
9567
+ var VERSION4 = "4.0.13";
9568
9568
  var getOriginalFetch3 = () => globalThis.fetch;
9569
9569
  var getFromApi2 = async ({
9570
9570
  url,
@@ -9649,8 +9649,8 @@ function loadOptionalSetting2({
9649
9649
  }
9650
9650
  return settingValue;
9651
9651
  }
9652
- var suspectProtoRx2 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
9653
- 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*:/;
9652
+ var suspectProtoRx2 = /"__proto__"\s*:/;
9653
+ var suspectConstructorRx2 = /"constructor"\s*:/;
9654
9654
  function _parse2(text4) {
9655
9655
  const obj = JSON.parse(text4);
9656
9656
  if (obj === null || typeof obj !== "object") {
@@ -9670,7 +9670,7 @@ function filter2(obj) {
9670
9670
  if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
9671
9671
  throw new SyntaxError("Object contains forbidden prototype property");
9672
9672
  }
9673
- if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
9673
+ if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
9674
9674
  throw new SyntaxError("Object contains forbidden prototype property");
9675
9675
  }
9676
9676
  for (const key in node) {
@@ -11572,7 +11572,7 @@ async function createGatewayErrorFromResponse2({
11572
11572
  cause,
11573
11573
  authMethod
11574
11574
  }) {
11575
- var _a932;
11575
+ var _a832;
11576
11576
  const parseResult = await safeValidateTypes3({
11577
11577
  value: response,
11578
11578
  schema: gatewayErrorResponseSchema2
@@ -11591,7 +11591,7 @@ async function createGatewayErrorFromResponse2({
11591
11591
  const validatedResponse = parseResult.value;
11592
11592
  const errorType = validatedResponse.error.type;
11593
11593
  const message = validatedResponse.error.message;
11594
- const generationId = (_a932 = validatedResponse.generationId) != null ? _a932 : void 0;
11594
+ const generationId = (_a832 = validatedResponse.generationId) != null ? _a832 : void 0;
11595
11595
  switch (errorType) {
11596
11596
  case "authentication_error":
11597
11597
  return GatewayAuthenticationError2.createContextualError({
@@ -11657,88 +11657,21 @@ var gatewayErrorResponseSchema2 = lazySchema(
11657
11657
  })
11658
11658
  )
11659
11659
  );
11660
- var name76 = "GatewayTimeoutError";
11661
- var marker86 = `vercel.ai.gateway.error.${name76}`;
11662
- var symbol86 = Symbol.for(marker86);
11663
- var _a86;
11664
- var _b83;
11665
- var GatewayTimeoutError = class _GatewayTimeoutError extends (_b83 = GatewayError2, _a86 = symbol86, _b83) {
11666
- constructor({
11667
- message = "Request timed out",
11668
- statusCode = 408,
11669
- cause,
11670
- generationId
11671
- } = {}) {
11672
- super({ message, statusCode, cause, generationId });
11673
- this[_a86] = true;
11674
- this.name = name76;
11675
- this.type = "timeout_error";
11676
- }
11677
- static isInstance(error) {
11678
- return GatewayError2.hasMarker(error) && symbol86 in error;
11679
- }
11680
- /**
11681
- * Creates a helpful timeout error message with troubleshooting guidance
11682
- */
11683
- static createTimeoutError({
11684
- originalMessage,
11685
- statusCode = 408,
11686
- cause,
11687
- generationId
11688
- }) {
11689
- const message = `Gateway request timed out: ${originalMessage}
11690
-
11691
- 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`;
11692
- return new _GatewayTimeoutError({
11693
- message,
11694
- statusCode,
11695
- cause,
11696
- generationId
11697
- });
11698
- }
11699
- };
11700
- function isTimeoutError(error) {
11701
- if (!(error instanceof Error)) {
11702
- return false;
11703
- }
11704
- const errorCode = error.code;
11705
- if (typeof errorCode === "string") {
11706
- const undiciTimeoutCodes = [
11707
- "UND_ERR_HEADERS_TIMEOUT",
11708
- "UND_ERR_BODY_TIMEOUT",
11709
- "UND_ERR_CONNECT_TIMEOUT"
11710
- ];
11711
- return undiciTimeoutCodes.includes(errorCode);
11712
- }
11713
- return false;
11714
- }
11715
- async function asGatewayError2(error, authMethod) {
11716
- var _a932;
11660
+ function asGatewayError2(error, authMethod) {
11661
+ var _a832;
11717
11662
  if (GatewayError2.isInstance(error)) {
11718
11663
  return error;
11719
11664
  }
11720
- if (isTimeoutError(error)) {
11721
- return GatewayTimeoutError.createTimeoutError({
11722
- originalMessage: error instanceof Error ? error.message : "Unknown error",
11723
- cause: error
11724
- });
11725
- }
11726
11665
  if (APICallError3.isInstance(error)) {
11727
- if (error.cause && isTimeoutError(error.cause)) {
11728
- return GatewayTimeoutError.createTimeoutError({
11729
- originalMessage: error.message,
11730
- cause: error
11731
- });
11732
- }
11733
- return await createGatewayErrorFromResponse2({
11666
+ return createGatewayErrorFromResponse2({
11734
11667
  response: extractApiCallResponse2(error),
11735
- statusCode: (_a932 = error.statusCode) != null ? _a932 : 500,
11668
+ statusCode: (_a832 = error.statusCode) != null ? _a832 : 500,
11736
11669
  defaultMessage: "Gateway request failed",
11737
11670
  cause: error,
11738
11671
  authMethod
11739
11672
  });
11740
11673
  }
11741
- return await createGatewayErrorFromResponse2({
11674
+ return createGatewayErrorFromResponse2({
11742
11675
  response: {},
11743
11676
  statusCode: 500,
11744
11677
  defaultMessage: error instanceof Error ? `Gateway request failed: ${error.message}` : "Unknown Gateway error",
@@ -11840,7 +11773,7 @@ var gatewayAvailableModelsResponseSchema2 = lazySchema(
11840
11773
  provider: z$1.string(),
11841
11774
  modelId: z$1.string()
11842
11775
  }),
11843
- modelType: z$1.enum(["embedding", "image", "language", "video"]).nullish()
11776
+ modelType: z$1.enum(["language", "embedding", "image"]).nullish()
11844
11777
  })
11845
11778
  )
11846
11779
  })
@@ -12019,7 +11952,7 @@ var GatewayEmbeddingModel2 = class {
12019
11952
  abortSignal,
12020
11953
  providerOptions
12021
11954
  }) {
12022
- var _a932;
11955
+ var _a832;
12023
11956
  const resolvedHeaders = await resolve2(this.config.headers());
12024
11957
  try {
12025
11958
  const {
@@ -12050,7 +11983,7 @@ var GatewayEmbeddingModel2 = class {
12050
11983
  });
12051
11984
  return {
12052
11985
  embeddings: responseBody.embeddings,
12053
- usage: (_a932 = responseBody.usage) != null ? _a932 : void 0,
11986
+ usage: (_a832 = responseBody.usage) != null ? _a832 : void 0,
12054
11987
  providerMetadata: responseBody.providerMetadata,
12055
11988
  response: { headers: responseHeaders, body: rawValue },
12056
11989
  warnings: []
@@ -12100,7 +12033,7 @@ var GatewayImageModel2 = class {
12100
12033
  headers,
12101
12034
  abortSignal
12102
12035
  }) {
12103
- var _a932, _b92, _c, _d;
12036
+ var _a832;
12104
12037
  const resolvedHeaders = await resolve2(this.config.headers());
12105
12038
  try {
12106
12039
  const {
@@ -12139,23 +12072,16 @@ var GatewayImageModel2 = class {
12139
12072
  return {
12140
12073
  images: responseBody.images,
12141
12074
  // Always base64 strings from server
12142
- warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
12075
+ warnings: (_a832 = responseBody.warnings) != null ? _a832 : [],
12143
12076
  providerMetadata: responseBody.providerMetadata,
12144
12077
  response: {
12145
12078
  timestamp: /* @__PURE__ */ new Date(),
12146
12079
  modelId: this.modelId,
12147
12080
  headers: responseHeaders
12148
- },
12149
- ...responseBody.usage != null && {
12150
- usage: {
12151
- inputTokens: (_b92 = responseBody.usage.inputTokens) != null ? _b92 : void 0,
12152
- outputTokens: (_c = responseBody.usage.outputTokens) != null ? _c : void 0,
12153
- totalTokens: (_d = responseBody.usage.totalTokens) != null ? _d : void 0
12154
- }
12155
12081
  }
12156
12082
  };
12157
12083
  } catch (error) {
12158
- throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
12084
+ throw asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
12159
12085
  }
12160
12086
  }
12161
12087
  getUrl() {
@@ -12180,230 +12106,17 @@ function maybeEncodeImageFile(file) {
12180
12106
  var providerMetadataEntrySchema2 = z$1.object({
12181
12107
  images: z$1.array(z$1.unknown()).optional()
12182
12108
  }).catchall(z$1.unknown());
12183
- var gatewayImageWarningSchema = z$1.discriminatedUnion("type", [
12184
- z$1.object({
12185
- type: z$1.literal("unsupported"),
12186
- feature: z$1.string(),
12187
- details: z$1.string().optional()
12188
- }),
12189
- z$1.object({
12190
- type: z$1.literal("compatibility"),
12191
- feature: z$1.string(),
12192
- details: z$1.string().optional()
12193
- }),
12194
- z$1.object({
12195
- type: z$1.literal("other"),
12196
- message: z$1.string()
12197
- })
12198
- ]);
12199
- var gatewayImageUsageSchema = z$1.object({
12200
- inputTokens: z$1.number().nullish(),
12201
- outputTokens: z$1.number().nullish(),
12202
- totalTokens: z$1.number().nullish()
12203
- });
12204
12109
  var gatewayImageResponseSchema2 = z$1.object({
12205
12110
  images: z$1.array(z$1.string()),
12206
12111
  // Always base64 strings over the wire
12207
- warnings: z$1.array(gatewayImageWarningSchema).optional(),
12208
- providerMetadata: z$1.record(z$1.string(), providerMetadataEntrySchema2).optional(),
12209
- usage: gatewayImageUsageSchema.optional()
12112
+ warnings: z$1.array(
12113
+ z$1.object({
12114
+ type: z$1.literal("other"),
12115
+ message: z$1.string()
12116
+ })
12117
+ ).optional(),
12118
+ providerMetadata: z$1.record(z$1.string(), providerMetadataEntrySchema2).optional()
12210
12119
  });
12211
- var GatewayVideoModel = class {
12212
- constructor(modelId, config) {
12213
- this.modelId = modelId;
12214
- this.config = config;
12215
- this.specificationVersion = "v3";
12216
- this.maxVideosPerCall = Number.MAX_SAFE_INTEGER;
12217
- }
12218
- get provider() {
12219
- return this.config.provider;
12220
- }
12221
- async doGenerate({
12222
- prompt,
12223
- n,
12224
- aspectRatio,
12225
- resolution,
12226
- duration,
12227
- fps,
12228
- seed,
12229
- image,
12230
- providerOptions,
12231
- headers,
12232
- abortSignal
12233
- }) {
12234
- var _a932;
12235
- const resolvedHeaders = await resolve2(this.config.headers());
12236
- try {
12237
- const { responseHeaders, value: responseBody } = await postJsonToApi2({
12238
- url: this.getUrl(),
12239
- headers: combineHeaders2(
12240
- resolvedHeaders,
12241
- headers != null ? headers : {},
12242
- this.getModelConfigHeaders(),
12243
- await resolve2(this.config.o11yHeaders),
12244
- { accept: "text/event-stream" }
12245
- ),
12246
- body: {
12247
- prompt,
12248
- n,
12249
- ...aspectRatio && { aspectRatio },
12250
- ...resolution && { resolution },
12251
- ...duration && { duration },
12252
- ...fps && { fps },
12253
- ...seed && { seed },
12254
- ...providerOptions && { providerOptions },
12255
- ...image && { image: maybeEncodeVideoFile(image) }
12256
- },
12257
- successfulResponseHandler: async ({
12258
- response,
12259
- url,
12260
- requestBodyValues
12261
- }) => {
12262
- if (response.body == null) {
12263
- throw new APICallError3({
12264
- message: "SSE response body is empty",
12265
- url,
12266
- requestBodyValues,
12267
- statusCode: response.status
12268
- });
12269
- }
12270
- const eventStream = parseJsonEventStream2({
12271
- stream: response.body,
12272
- schema: gatewayVideoEventSchema
12273
- });
12274
- const reader = eventStream.getReader();
12275
- const { done, value: parseResult } = await reader.read();
12276
- reader.releaseLock();
12277
- if (done || !parseResult) {
12278
- throw new APICallError3({
12279
- message: "SSE stream ended without a data event",
12280
- url,
12281
- requestBodyValues,
12282
- statusCode: response.status
12283
- });
12284
- }
12285
- if (!parseResult.success) {
12286
- throw new APICallError3({
12287
- message: "Failed to parse video SSE event",
12288
- cause: parseResult.error,
12289
- url,
12290
- requestBodyValues,
12291
- statusCode: response.status
12292
- });
12293
- }
12294
- const event = parseResult.value;
12295
- if (event.type === "error") {
12296
- throw new APICallError3({
12297
- message: event.message,
12298
- statusCode: event.statusCode,
12299
- url,
12300
- requestBodyValues,
12301
- responseHeaders: Object.fromEntries([...response.headers]),
12302
- responseBody: JSON.stringify(event),
12303
- data: {
12304
- error: {
12305
- message: event.message,
12306
- type: event.errorType,
12307
- param: event.param
12308
- }
12309
- }
12310
- });
12311
- }
12312
- return {
12313
- value: {
12314
- videos: event.videos,
12315
- warnings: event.warnings,
12316
- providerMetadata: event.providerMetadata
12317
- },
12318
- responseHeaders: Object.fromEntries([...response.headers])
12319
- };
12320
- },
12321
- failedResponseHandler: createJsonErrorResponseHandler2({
12322
- errorSchema: z$1.any(),
12323
- errorToMessage: (data) => data
12324
- }),
12325
- ...abortSignal && { abortSignal },
12326
- fetch: this.config.fetch
12327
- });
12328
- return {
12329
- videos: responseBody.videos,
12330
- warnings: (_a932 = responseBody.warnings) != null ? _a932 : [],
12331
- providerMetadata: responseBody.providerMetadata,
12332
- response: {
12333
- timestamp: /* @__PURE__ */ new Date(),
12334
- modelId: this.modelId,
12335
- headers: responseHeaders
12336
- }
12337
- };
12338
- } catch (error) {
12339
- throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
12340
- }
12341
- }
12342
- getUrl() {
12343
- return `${this.config.baseURL}/video-model`;
12344
- }
12345
- getModelConfigHeaders() {
12346
- return {
12347
- "ai-video-model-specification-version": "3",
12348
- "ai-model-id": this.modelId
12349
- };
12350
- }
12351
- };
12352
- function maybeEncodeVideoFile(file) {
12353
- if (file.type === "file" && file.data instanceof Uint8Array) {
12354
- return {
12355
- ...file,
12356
- data: convertUint8ArrayToBase643(file.data)
12357
- };
12358
- }
12359
- return file;
12360
- }
12361
- var providerMetadataEntrySchema22 = z$1.object({
12362
- videos: z$1.array(z$1.unknown()).optional()
12363
- }).catchall(z$1.unknown());
12364
- var gatewayVideoDataSchema = z$1.union([
12365
- z$1.object({
12366
- type: z$1.literal("url"),
12367
- url: z$1.string(),
12368
- mediaType: z$1.string()
12369
- }),
12370
- z$1.object({
12371
- type: z$1.literal("base64"),
12372
- data: z$1.string(),
12373
- mediaType: z$1.string()
12374
- })
12375
- ]);
12376
- var gatewayVideoWarningSchema = z$1.discriminatedUnion("type", [
12377
- z$1.object({
12378
- type: z$1.literal("unsupported"),
12379
- feature: z$1.string(),
12380
- details: z$1.string().optional()
12381
- }),
12382
- z$1.object({
12383
- type: z$1.literal("compatibility"),
12384
- feature: z$1.string(),
12385
- details: z$1.string().optional()
12386
- }),
12387
- z$1.object({
12388
- type: z$1.literal("other"),
12389
- message: z$1.string()
12390
- })
12391
- ]);
12392
- var gatewayVideoEventSchema = z$1.discriminatedUnion("type", [
12393
- z$1.object({
12394
- type: z$1.literal("result"),
12395
- videos: z$1.array(gatewayVideoDataSchema),
12396
- warnings: z$1.array(gatewayVideoWarningSchema).optional(),
12397
- providerMetadata: z$1.record(z$1.string(), providerMetadataEntrySchema22).optional()
12398
- }),
12399
- z$1.object({
12400
- type: z$1.literal("error"),
12401
- message: z$1.string(),
12402
- errorType: z$1.string(),
12403
- statusCode: z$1.number(),
12404
- param: z$1.unknown().nullable()
12405
- })
12406
- ]);
12407
12120
  var parallelSearchInputSchema = lazySchema(
12408
12121
  () => zodSchema3(
12409
12122
  z.object({
@@ -12577,18 +12290,18 @@ var gatewayTools = {
12577
12290
  perplexitySearch
12578
12291
  };
12579
12292
  async function getVercelRequestId2() {
12580
- var _a932;
12581
- return (_a932 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a932["x-vercel-id"];
12293
+ var _a832;
12294
+ return (_a832 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a832["x-vercel-id"];
12582
12295
  }
12583
- var VERSION5 = "3.0.66";
12296
+ var VERSION5 = "3.0.32";
12584
12297
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
12585
12298
  function createGatewayProvider2(options = {}) {
12586
- var _a932, _b92;
12299
+ var _a832, _b83;
12587
12300
  let pendingMetadata = null;
12588
12301
  let metadataCache = null;
12589
- const cacheRefreshMillis = (_a932 = options.metadataCacheRefreshMillis) != null ? _a932 : 1e3 * 60 * 5;
12302
+ const cacheRefreshMillis = (_a832 = options.metadataCacheRefreshMillis) != null ? _a832 : 1e3 * 60 * 5;
12590
12303
  let lastFetchTime = 0;
12591
- const baseURL = (_b92 = withoutTrailingSlash2(options.baseURL)) != null ? _b92 : "https://ai-gateway.vercel.sh/v3/ai";
12304
+ const baseURL = (_b83 = withoutTrailingSlash2(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v3/ai";
12592
12305
  const getHeaders = async () => {
12593
12306
  try {
12594
12307
  const auth = await getGatewayAuthToken2(options);
@@ -12623,18 +12336,13 @@ function createGatewayProvider2(options = {}) {
12623
12336
  settingValue: void 0,
12624
12337
  environmentVariableName: "VERCEL_REGION"
12625
12338
  });
12626
- const projectId = loadOptionalSetting2({
12627
- settingValue: void 0,
12628
- environmentVariableName: "VERCEL_PROJECT_ID"
12629
- });
12630
12339
  return async () => {
12631
12340
  const requestId = await getVercelRequestId2();
12632
12341
  return {
12633
12342
  ...deploymentId && { "ai-o11y-deployment-id": deploymentId },
12634
12343
  ...environment && { "ai-o11y-environment": environment },
12635
12344
  ...region && { "ai-o11y-region": region },
12636
- ...requestId && { "ai-o11y-request-id": requestId },
12637
- ...projectId && { "ai-o11y-project-id": projectId }
12345
+ ...requestId && { "ai-o11y-request-id": requestId }
12638
12346
  };
12639
12347
  };
12640
12348
  };
@@ -12648,8 +12356,8 @@ function createGatewayProvider2(options = {}) {
12648
12356
  });
12649
12357
  };
12650
12358
  const getAvailableModels = async () => {
12651
- var _a1022, _b102, _c;
12652
- const now2 = (_c = (_b102 = (_a1022 = options._internal) == null ? void 0 : _a1022.currentDate) == null ? void 0 : _b102.call(_a1022).getTime()) != null ? _c : Date.now();
12359
+ var _a922, _b92, _c;
12360
+ const now2 = (_c = (_b92 = (_a922 = options._internal) == null ? void 0 : _a922.currentDate) == null ? void 0 : _b92.call(_a922).getTime()) != null ? _c : Date.now();
12653
12361
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
12654
12362
  lastFetchTime = now2;
12655
12363
  pendingMetadata = new GatewayFetchMetadata2({
@@ -12712,19 +12420,6 @@ function createGatewayProvider2(options = {}) {
12712
12420
  };
12713
12421
  provider.embeddingModel = createEmbeddingModel;
12714
12422
  provider.textEmbeddingModel = createEmbeddingModel;
12715
- provider.videoModel = (modelId) => {
12716
- return new GatewayVideoModel(modelId, {
12717
- provider: "gateway",
12718
- baseURL,
12719
- headers: getHeaders,
12720
- fetch: options.fetch,
12721
- o11yHeaders: createO11yHeaders()
12722
- });
12723
- };
12724
- provider.chat = provider.languageModel;
12725
- provider.embedding = provider.embeddingModel;
12726
- provider.image = provider.imageModel;
12727
- provider.video = provider.videoModel;
12728
12423
  provider.tools = gatewayTools;
12729
12424
  return provider;
12730
12425
  }
@@ -12839,12 +12534,12 @@ function registerGlobal3(type, instance, diag, allowOverride) {
12839
12534
  return true;
12840
12535
  }
12841
12536
  function getGlobal3(type) {
12842
- var _a21, _b92;
12537
+ var _a21, _b83;
12843
12538
  var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
12844
12539
  if (!globalVersion || !isCompatible3(globalVersion)) {
12845
12540
  return;
12846
12541
  }
12847
- return (_b92 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b92 === void 0 ? void 0 : _b92[type];
12542
+ return (_b83 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _b83 === void 0 ? void 0 : _b83[type];
12848
12543
  }
12849
12544
  function unregisterGlobal3(type, diag) {
12850
12545
  diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION23 + ".");
@@ -13009,7 +12704,7 @@ var DiagAPI3 = (
13009
12704
  }
13010
12705
  var self = this;
13011
12706
  var setLogger = function(logger, optionsOrLogLevel) {
13012
- var _a21, _b92, _c;
12707
+ var _a21, _b83, _c;
13013
12708
  if (optionsOrLogLevel === void 0) {
13014
12709
  optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
13015
12710
  }
@@ -13024,7 +12719,7 @@ var DiagAPI3 = (
13024
12719
  };
13025
12720
  }
13026
12721
  var oldLogger = getGlobal3("diag");
13027
- var newLogger = createLogLevelDiagLogger3((_b92 = optionsOrLogLevel.logLevel) !== null && _b92 !== void 0 ? _b92 : DiagLogLevel3.INFO, logger);
12722
+ var newLogger = createLogLevelDiagLogger3((_b83 = optionsOrLogLevel.logLevel) !== null && _b83 !== void 0 ? _b83 : DiagLogLevel3.INFO, logger);
13028
12723
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
13029
12724
  var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
13030
12725
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -13457,10 +13152,10 @@ var __export3 = (target, all) => {
13457
13152
  for (var name21 in all)
13458
13153
  __defProp4(target, name21, { get: all[name21], enumerable: true });
13459
13154
  };
13460
- var name86 = "AI_InvalidArgumentError";
13461
- var marker96 = `vercel.ai.error.${name86}`;
13462
- var symbol96 = Symbol.for(marker96);
13463
- var _a96;
13155
+ var name76 = "AI_InvalidArgumentError";
13156
+ var marker86 = `vercel.ai.error.${name76}`;
13157
+ var symbol86 = Symbol.for(marker86);
13158
+ var _a86;
13464
13159
  var InvalidArgumentError23 = class extends AISDKError3 {
13465
13160
  constructor({
13466
13161
  parameter,
@@ -13468,20 +13163,20 @@ var InvalidArgumentError23 = class extends AISDKError3 {
13468
13163
  message
13469
13164
  }) {
13470
13165
  super({
13471
- name: name86,
13166
+ name: name76,
13472
13167
  message: `Invalid argument for parameter ${parameter}: ${message}`
13473
13168
  });
13474
- this[_a96] = true;
13169
+ this[_a86] = true;
13475
13170
  this.parameter = parameter;
13476
13171
  this.value = value;
13477
13172
  }
13478
13173
  static isInstance(error) {
13479
- return AISDKError3.hasMarker(error, marker96);
13174
+ return AISDKError3.hasMarker(error, marker86);
13480
13175
  }
13481
13176
  };
13482
- _a96 = symbol96;
13483
- var name822 = "AI_NoObjectGeneratedError";
13484
- var marker823 = `vercel.ai.error.${name822}`;
13177
+ _a86 = symbol86;
13178
+ var name86 = "AI_NoObjectGeneratedError";
13179
+ var marker823 = `vercel.ai.error.${name86}`;
13485
13180
  var symbol823 = Symbol.for(marker823);
13486
13181
  var _a823;
13487
13182
  var NoObjectGeneratedError3 = class extends AISDKError3 {
@@ -13493,7 +13188,7 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
13493
13188
  usage,
13494
13189
  finishReason
13495
13190
  }) {
13496
- super({ name: name822, message, cause });
13191
+ super({ name: name86, message, cause });
13497
13192
  this[_a823] = true;
13498
13193
  this.text = text22;
13499
13194
  this.response = response;
@@ -13653,7 +13348,7 @@ function getTotalTimeoutMs(timeout) {
13653
13348
  }
13654
13349
  return timeout.totalMs;
13655
13350
  }
13656
- var VERSION33 = "6.0.116";
13351
+ var VERSION33 = "6.0.69";
13657
13352
  var dataContentSchema3 = z$1.union([
13658
13353
  z$1.string(),
13659
13354
  z$1.instanceof(Uint8Array),
@@ -13661,8 +13356,8 @@ var dataContentSchema3 = z$1.union([
13661
13356
  z$1.custom(
13662
13357
  // Buffer might not be available in some environments such as CloudFlare:
13663
13358
  (value) => {
13664
- var _a21, _b92;
13665
- return (_b92 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b92 : false;
13359
+ var _a21, _b83;
13360
+ return (_b83 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b83 : false;
13666
13361
  },
13667
13362
  { message: "Must be a Buffer" }
13668
13363
  )
@@ -16665,7 +16360,7 @@ Notes:
16665
16360
  "Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
16666
16361
  );
16667
16362
  }
16668
- const { ObservationalMemory } = await import('./observational-memory-YRWU6CY3.js');
16363
+ const { ObservationalMemory } = await import('./observational-memory-XXD6E2SO.js');
16669
16364
  return new ObservationalMemory({
16670
16365
  storage: memoryStore,
16671
16366
  scope: omConfig.scope,
@@ -16680,6 +16375,7 @@ Notes:
16680
16375
  bufferTokens: omConfig.observation.bufferTokens,
16681
16376
  bufferActivation: omConfig.observation.bufferActivation,
16682
16377
  blockAfter: omConfig.observation.blockAfter,
16378
+ previousObserverTokens: omConfig.observation.previousObserverTokens,
16683
16379
  instruction: omConfig.observation.instruction
16684
16380
  } : void 0,
16685
16381
  reflection: omConfig.reflection ? {