@mastra/memory 1.23.0 → 1.23.1-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 (29) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{chunk-42LZUXJ3.cjs → chunk-YNTQFC3L.cjs} +57 -26
  3. package/dist/chunk-YNTQFC3L.cjs.map +1 -0
  4. package/dist/{chunk-6ACCFKAN.js → chunk-YXN553WT.js} +57 -26
  5. package/dist/chunk-YXN553WT.js.map +1 -0
  6. package/dist/docs/SKILL.md +1 -1
  7. package/dist/docs/assets/SOURCE_MAP.json +47 -47
  8. package/dist/docs/references/docs-long-running-agents-background-tasks.md +2 -2
  9. package/dist/docs/references/docs-memory-multi-user-threads.md +4 -4
  10. package/dist/docs/references/docs-memory-observational-memory.md +78 -3
  11. package/dist/docs/references/docs-memory-overview.md +4 -0
  12. package/dist/docs/references/docs-memory-working-memory.md +1 -1
  13. package/dist/docs/references/reference-memory-observational-memory.md +21 -0
  14. package/dist/docs/references/reference-processors-token-limiter-processor.md +1 -3
  15. package/dist/docs/references/reference-vectors-mongodb.md +2 -0
  16. package/dist/index.cjs +15 -15
  17. package/dist/index.js +1 -1
  18. package/dist/{observational-memory-2F4GJOP2.cjs → observational-memory-OD3W7JXC.cjs} +29 -29
  19. package/dist/{observational-memory-2F4GJOP2.cjs.map → observational-memory-OD3W7JXC.cjs.map} +1 -1
  20. package/dist/{observational-memory-OJN26RQ4.js → observational-memory-ZYY4KPCN.js} +3 -3
  21. package/dist/{observational-memory-OJN26RQ4.js.map → observational-memory-ZYY4KPCN.js.map} +1 -1
  22. package/dist/processors/index.cjs +27 -27
  23. package/dist/processors/index.js +1 -1
  24. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
  25. package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
  26. package/dist/processors/observational-memory/retry.d.ts.map +1 -1
  27. package/package.json +7 -7
  28. package/dist/chunk-42LZUXJ3.cjs.map +0 -1
  29. package/dist/chunk-6ACCFKAN.js.map +0 -1
@@ -4774,12 +4774,14 @@ function hasTransientMessage(value) {
4774
4774
  if (typeof value.code === "string" && value.code.toUpperCase().startsWith("UND_ERR_")) return true;
4775
4775
  return false;
4776
4776
  }
4777
+ function isRetryableHttpStatus(status) {
4778
+ if (status === 408 || status === 425 || status === 429) return true;
4779
+ return status >= 500 && status <= 599;
4780
+ }
4777
4781
  function hasRetryableHttpStatus(value) {
4778
4782
  if (!isRecord2(value)) return false;
4779
- const status = typeof value.statusCode === "number" ? value.statusCode : void 0;
4780
- if (status === void 0) return false;
4781
- if (status === 408 || status === 425 || status === 429) return true;
4782
- if (status >= 500 && status <= 599) return true;
4783
+ if (typeof value.statusCode === "number" && isRetryableHttpStatus(value.statusCode)) return true;
4784
+ if (typeof value.code === "number" && isRetryableHttpStatus(value.code)) return true;
4783
4785
  return false;
4784
4786
  }
4785
4787
  function hasIsRetryableFlag(value) {
@@ -9550,7 +9552,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
9550
9552
  );
9551
9553
  return Object.fromEntries(normalizedHeaders.entries());
9552
9554
  }
9553
- var VERSION2 = "3.0.28";
9555
+ var VERSION2 = "3.0.29";
9554
9556
  var getOriginalFetch = () => globalThis.fetch;
9555
9557
  var getFromApi = async ({
9556
9558
  url,
@@ -9699,7 +9701,7 @@ function lazyValidator(createValidator) {
9699
9701
  };
9700
9702
  }
9701
9703
  function asValidator2(value) {
9702
- return isValidator2(value) ? value : typeof value === "function" ? value() : standardSchemaValidator(value);
9704
+ return isValidator2(value) ? value : "~standard" in value ? standardSchemaValidator(value) : value();
9703
9705
  }
9704
9706
  function standardSchemaValidator(standardSchema2) {
9705
9707
  return validator2(async (value) => {
@@ -11324,18 +11326,27 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
11324
11326
  var name24 = "GatewayForbiddenError";
11325
11327
  var marker34 = `vercel.ai.gateway.error.${name24}`;
11326
11328
  var symbol34 = Symbol.for(marker34);
11329
+ var forbiddenParamSchema = lazyValidator(
11330
+ () => zodSchema2(
11331
+ z$1.object({
11332
+ ruleId: z$1.string()
11333
+ })
11334
+ )
11335
+ );
11327
11336
  var _a34;
11328
11337
  var _b32;
11329
11338
  var GatewayForbiddenError = class extends (_b32 = GatewayError, _a34 = symbol34, _b32) {
11330
11339
  constructor({
11331
11340
  message = "Forbidden",
11332
11341
  statusCode = 403,
11333
- cause
11342
+ cause,
11343
+ ruleId
11334
11344
  } = {}) {
11335
11345
  super({ message, statusCode, cause });
11336
11346
  this[_a34] = true;
11337
11347
  this.name = name24;
11338
11348
  this.type = "forbidden";
11349
+ this.ruleId = ruleId;
11339
11350
  }
11340
11351
  static isInstance(error) {
11341
11352
  return GatewayError.hasMarker(error) && symbol34 in error;
@@ -11503,8 +11514,18 @@ async function createGatewayErrorFromResponse({
11503
11514
  }
11504
11515
  case "internal_server_error":
11505
11516
  return new GatewayInternalServerError({ message, statusCode, cause });
11506
- case "forbidden":
11507
- return new GatewayForbiddenError({ message, statusCode, cause });
11517
+ case "forbidden": {
11518
+ const ruleResult = await safeValidateTypes2({
11519
+ value: validatedResponse.error.param,
11520
+ schema: forbiddenParamSchema
11521
+ });
11522
+ return new GatewayForbiddenError({
11523
+ message,
11524
+ statusCode,
11525
+ cause,
11526
+ ruleId: ruleResult.success ? ruleResult.value.ruleId : void 0
11527
+ });
11528
+ }
11508
11529
  default:
11509
11530
  return new GatewayInternalServerError({ message, statusCode, cause });
11510
11531
  }
@@ -12406,7 +12427,7 @@ async function getVercelRequestId() {
12406
12427
  var _a1032;
12407
12428
  return (_a1032 = getContext().headers) == null ? void 0 : _a1032["x-vercel-id"];
12408
12429
  }
12409
- var VERSION3 = "2.0.109";
12430
+ var VERSION3 = "2.0.113";
12410
12431
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
12411
12432
  function createGatewayProvider(options = {}) {
12412
12433
  var _a1032, _b104;
@@ -13393,7 +13414,7 @@ function getGlobalProvider() {
13393
13414
  var _a163;
13394
13415
  return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
13395
13416
  }
13396
- var VERSION32 = "5.0.210";
13417
+ var VERSION32 = "5.0.214";
13397
13418
  var dataContentSchema2 = z$1.union([
13398
13419
  z$1.string(),
13399
13420
  z$1.instanceof(Uint8Array),
@@ -15150,7 +15171,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
15150
15171
  );
15151
15172
  return Object.fromEntries(normalizedHeaders.entries());
15152
15173
  }
15153
- var VERSION4 = "4.0.38";
15174
+ var VERSION4 = "4.0.39";
15154
15175
  var getOriginalFetch3 = () => globalThis.fetch;
15155
15176
  var getFromApi2 = async ({
15156
15177
  url,
@@ -16436,11 +16457,18 @@ function asSchema3(schema) {
16436
16457
  }
16437
16458
  function standardSchema(standardSchema2) {
16438
16459
  return jsonSchema3(
16439
- () => addAdditionalPropertiesToJsonSchema2(
16440
- standardSchema2["~standard"].jsonSchema.input({
16441
- target: "draft-07"
16442
- })
16443
- ),
16460
+ () => {
16461
+ if (!hasStandardJsonSchema(standardSchema2)) {
16462
+ throw new Error(
16463
+ `Standard schema vendor '${standardSchema2["~standard"].vendor}' does not support JSON Schema conversion.`
16464
+ );
16465
+ }
16466
+ return addAdditionalPropertiesToJsonSchema2(
16467
+ standardSchema2["~standard"].jsonSchema.input({
16468
+ target: "draft-07"
16469
+ })
16470
+ );
16471
+ },
16444
16472
  {
16445
16473
  validate: async (value) => {
16446
16474
  const result = await standardSchema2["~standard"].validate(value);
@@ -16455,6 +16483,9 @@ function standardSchema(standardSchema2) {
16455
16483
  }
16456
16484
  );
16457
16485
  }
16486
+ function hasStandardJsonSchema(schema) {
16487
+ return schema["~standard"].jsonSchema != null;
16488
+ }
16458
16489
  function zod3Schema2(zodSchema22, options) {
16459
16490
  var _a223;
16460
16491
  const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
@@ -17128,7 +17159,7 @@ var GatewayFailedDependencyError = class extends (_b74 = GatewayError2, _a76 = s
17128
17159
  var name76 = "GatewayForbiddenError";
17129
17160
  var marker86 = `vercel.ai.gateway.error.${name76}`;
17130
17161
  var symbol86 = Symbol.for(marker86);
17131
- var forbiddenParamSchema = lazySchema2(
17162
+ var forbiddenParamSchema2 = lazySchema2(
17132
17163
  () => zodSchema3(
17133
17164
  z$1.object({
17134
17165
  ruleId: z$1.string()
@@ -17260,7 +17291,7 @@ async function createGatewayErrorFromResponse2({
17260
17291
  case "forbidden": {
17261
17292
  const ruleResult = await safeValidateTypes3({
17262
17293
  value: validatedResponse.error.param,
17263
- schema: forbiddenParamSchema
17294
+ schema: forbiddenParamSchema2
17264
17295
  });
17265
17296
  return new GatewayForbiddenError2({
17266
17297
  message,
@@ -18911,7 +18942,7 @@ async function getVercelRequestId2() {
18911
18942
  var _a117;
18912
18943
  return (_a117 = getContext2().headers) == null ? void 0 : _a117["x-vercel-id"];
18913
18944
  }
18914
- var VERSION5 = "3.0.148";
18945
+ var VERSION5 = "3.0.151";
18915
18946
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
18916
18947
  function createGatewayProvider2(options = {}) {
18917
18948
  var _a117, _b113;
@@ -20017,7 +20048,7 @@ function getTotalTimeoutMs(timeout) {
20017
20048
  }
20018
20049
  return timeout.totalMs;
20019
20050
  }
20020
- var VERSION23 = "6.0.224";
20051
+ var VERSION23 = "6.0.228";
20021
20052
  var dataContentSchema3 = z$1.union([
20022
20053
  z$1.string(),
20023
20054
  z$1.instanceof(Uint8Array),
@@ -25385,7 +25416,7 @@ ${workingMemory}`;
25385
25416
  }
25386
25417
  if (omConfig.observation?.bufferTokens !== false && !coreFeatures.has("asyncBuffering")) {
25387
25418
  throw new Error(
25388
- "Observational memory async buffering is enabled by default but the installed version of @mastra/core does not support it. Either upgrade @mastra/core, @mastra/memory, and your storage adapter (@mastra/libsql, @mastra/pg, or @mastra/mongodb) to the latest version, or explicitly disable async buffering by setting `observation: { bufferTokens: false }` in your observationalMemory config."
25419
+ "Observational memory async buffering is enabled by default but the installed version of @mastra/core does not support it. Either upgrade @mastra/core, @mastra/memory, and your storage adapter (@mastra/libsql, @mastra/pg, @mastra/mongodb, or @mastra/convex) to the latest version, or explicitly disable async buffering by setting `observation: { bufferTokens: false }` in your observationalMemory config."
25389
25420
  );
25390
25421
  }
25391
25422
  if (!coreFeatures.has("request-response-id-rotation")) {
@@ -25393,7 +25424,7 @@ ${workingMemory}`;
25393
25424
  "Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
25394
25425
  );
25395
25426
  }
25396
- const { ObservationalMemory: OMClass } = await import('./observational-memory-OJN26RQ4.js');
25427
+ const { ObservationalMemory: OMClass } = await import('./observational-memory-ZYY4KPCN.js');
25397
25428
  const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
25398
25429
  await this.indexObservation(observation);
25399
25430
  } : void 0;
@@ -26441,7 +26472,7 @@ Notes:
26441
26472
  if (!effectiveConfig) return null;
26442
26473
  const engine = await this.omEngine;
26443
26474
  if (!engine) return null;
26444
- const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-OJN26RQ4.js');
26475
+ const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-ZYY4KPCN.js');
26445
26476
  return new ObservationalMemoryProcessor2(engine, this, {
26446
26477
  temporalMarkers: effectiveConfig.temporalMarkers
26447
26478
  });
@@ -31394,5 +31425,5 @@ function getObservationsAsOf(activeObservations, asOf) {
31394
31425
  }
31395
31426
 
31396
31427
  export { Extractor, Memory, ModelByInputTokens, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, SUMMARIZE_THREAD_DEFAULTS, TokenCounter, WorkingMemoryExtractor, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deepMergeWorkingMemory, deriveObservationGroupProvenance, extractCurrentTask, extractWorkingMemoryContent, extractWorkingMemoryTags, formatMessagesForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, removeWorkingMemoryTags, renderObservationGroupsForReflection, stripEphemeralAnchorIds, stripObservationGroups, summarizeConversation, wrapInObservationGroup };
31397
- //# sourceMappingURL=chunk-6ACCFKAN.js.map
31398
- //# sourceMappingURL=chunk-6ACCFKAN.js.map
31428
+ //# sourceMappingURL=chunk-YXN553WT.js.map
31429
+ //# sourceMappingURL=chunk-YXN553WT.js.map