@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 1.23.1-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed observational memory aborting the agent run when OpenRouter injects a transient provider error into the response stream (e.g. "JSON error injected into SSE stream" with google/gemini-2.5-flash). These mid-stream errors carry the HTTP status on a numeric code property and are now recognized as retryable, so the observer retries with backoff instead of failing the turn. ([#19640](https://github.com/mastra-ai/mastra/pull/19640))
8
+
9
+ - Updated dependencies [[`ec857fc`](https://github.com/mastra-ai/mastra/commit/ec857fc79c264b53b38e16478c789b7177f2ad59), [`e1f2fae`](https://github.com/mastra-ai/mastra/commit/e1f2faebaf048c3d4c2e2c01d293767c195d5794), [`63aa799`](https://github.com/mastra-ai/mastra/commit/63aa799c6b44eacc7806cda6846b7c5bbee06b37), [`73db8db`](https://github.com/mastra-ai/mastra/commit/73db8db90d69ab6153c7942749f624db0d96952d), [`73db8db`](https://github.com/mastra-ai/mastra/commit/73db8db90d69ab6153c7942749f624db0d96952d), [`76b7181`](https://github.com/mastra-ai/mastra/commit/76b71810366e6d90b9d3973149d1c7ba3659ffb9), [`0c0e8d7`](https://github.com/mastra-ai/mastra/commit/0c0e8d7becd4d1445c656b78d5d845f606c1ff9d), [`9f7c67a`](https://github.com/mastra-ai/mastra/commit/9f7c67abeeb52c41c51a9b5edee60b62afe7cd8d), [`3b65e68`](https://github.com/mastra-ai/mastra/commit/3b65e68d7f1c771c7a70eea42d83fefdd28cad88), [`e3868e2`](https://github.com/mastra-ai/mastra/commit/e3868e22babfffd0133771669ca724501c2dd58e)]:
10
+ - @mastra/core@1.52.0-alpha.5
11
+
12
+ ## 1.23.1-alpha.0
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated the async-buffering compatibility error to include `@mastra/convex` in the list of storage adapters that support Observational Memory. ([#19474](https://github.com/mastra-ai/mastra/pull/19474))
17
+
18
+ - Updated dependencies [[`8a0d145`](https://github.com/mastra-ai/mastra/commit/8a0d145aadbdf7278665aceaaec364b35dd9bd94), [`bd2f1d2`](https://github.com/mastra-ai/mastra/commit/bd2f1d274d05e60e2366f005ea0d94d5cea0d5ff), [`21a0eb8`](https://github.com/mastra-ai/mastra/commit/21a0eb86746ba0b703acea360d4f84c6a5a493f2), [`de86fd7`](https://github.com/mastra-ai/mastra/commit/de86fd7119f0438381d1a642e3d258143c0b9c29), [`2745031`](https://github.com/mastra-ai/mastra/commit/2745031d1d4a4978f037092da371428c32e2842a), [`db650ce`](https://github.com/mastra-ai/mastra/commit/db650ce490348914e85b93651d83acdf8f2a4c31), [`6354eeb`](https://github.com/mastra-ai/mastra/commit/6354eeb32efa9f5f68f51dda394e90e2ee76f1fb)]:
19
+ - @mastra/core@1.51.1-alpha.0
20
+
3
21
  ## 1.23.0
4
22
 
5
23
  ### Minor Changes
@@ -4798,12 +4798,14 @@ function hasTransientMessage(value) {
4798
4798
  if (typeof value.code === "string" && value.code.toUpperCase().startsWith("UND_ERR_")) return true;
4799
4799
  return false;
4800
4800
  }
4801
+ function isRetryableHttpStatus(status) {
4802
+ if (status === 408 || status === 425 || status === 429) return true;
4803
+ return status >= 500 && status <= 599;
4804
+ }
4801
4805
  function hasRetryableHttpStatus(value) {
4802
4806
  if (!isRecord2(value)) return false;
4803
- const status = typeof value.statusCode === "number" ? value.statusCode : void 0;
4804
- if (status === void 0) return false;
4805
- if (status === 408 || status === 425 || status === 429) return true;
4806
- if (status >= 500 && status <= 599) return true;
4807
+ if (typeof value.statusCode === "number" && isRetryableHttpStatus(value.statusCode)) return true;
4808
+ if (typeof value.code === "number" && isRetryableHttpStatus(value.code)) return true;
4807
4809
  return false;
4808
4810
  }
4809
4811
  function hasIsRetryableFlag(value) {
@@ -9574,7 +9576,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
9574
9576
  );
9575
9577
  return Object.fromEntries(normalizedHeaders.entries());
9576
9578
  }
9577
- var VERSION2 = "3.0.28";
9579
+ var VERSION2 = "3.0.29";
9578
9580
  var getOriginalFetch = () => globalThis.fetch;
9579
9581
  var getFromApi = async ({
9580
9582
  url,
@@ -9723,7 +9725,7 @@ function lazyValidator(createValidator) {
9723
9725
  };
9724
9726
  }
9725
9727
  function asValidator2(value) {
9726
- return isValidator2(value) ? value : typeof value === "function" ? value() : standardSchemaValidator(value);
9728
+ return isValidator2(value) ? value : "~standard" in value ? standardSchemaValidator(value) : value();
9727
9729
  }
9728
9730
  function standardSchemaValidator(standardSchema2) {
9729
9731
  return validator2(async (value) => {
@@ -11348,18 +11350,27 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
11348
11350
  var name24 = "GatewayForbiddenError";
11349
11351
  var marker34 = `vercel.ai.gateway.error.${name24}`;
11350
11352
  var symbol34 = Symbol.for(marker34);
11353
+ var forbiddenParamSchema = lazyValidator(
11354
+ () => zodSchema2(
11355
+ z42.z.object({
11356
+ ruleId: z42.z.string()
11357
+ })
11358
+ )
11359
+ );
11351
11360
  var _a34;
11352
11361
  var _b32;
11353
11362
  var GatewayForbiddenError = class extends (_b32 = GatewayError, _a34 = symbol34, _b32) {
11354
11363
  constructor({
11355
11364
  message = "Forbidden",
11356
11365
  statusCode = 403,
11357
- cause
11366
+ cause,
11367
+ ruleId
11358
11368
  } = {}) {
11359
11369
  super({ message, statusCode, cause });
11360
11370
  this[_a34] = true;
11361
11371
  this.name = name24;
11362
11372
  this.type = "forbidden";
11373
+ this.ruleId = ruleId;
11363
11374
  }
11364
11375
  static isInstance(error) {
11365
11376
  return GatewayError.hasMarker(error) && symbol34 in error;
@@ -11527,8 +11538,18 @@ async function createGatewayErrorFromResponse({
11527
11538
  }
11528
11539
  case "internal_server_error":
11529
11540
  return new GatewayInternalServerError({ message, statusCode, cause });
11530
- case "forbidden":
11531
- return new GatewayForbiddenError({ message, statusCode, cause });
11541
+ case "forbidden": {
11542
+ const ruleResult = await safeValidateTypes2({
11543
+ value: validatedResponse.error.param,
11544
+ schema: forbiddenParamSchema
11545
+ });
11546
+ return new GatewayForbiddenError({
11547
+ message,
11548
+ statusCode,
11549
+ cause,
11550
+ ruleId: ruleResult.success ? ruleResult.value.ruleId : void 0
11551
+ });
11552
+ }
11532
11553
  default:
11533
11554
  return new GatewayInternalServerError({ message, statusCode, cause });
11534
11555
  }
@@ -12430,7 +12451,7 @@ async function getVercelRequestId() {
12430
12451
  var _a1032;
12431
12452
  return (_a1032 = getContext().headers) == null ? void 0 : _a1032["x-vercel-id"];
12432
12453
  }
12433
- var VERSION3 = "2.0.109";
12454
+ var VERSION3 = "2.0.113";
12434
12455
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
12435
12456
  function createGatewayProvider(options = {}) {
12436
12457
  var _a1032, _b104;
@@ -13417,7 +13438,7 @@ function getGlobalProvider() {
13417
13438
  var _a163;
13418
13439
  return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
13419
13440
  }
13420
- var VERSION32 = "5.0.210";
13441
+ var VERSION32 = "5.0.214";
13421
13442
  var dataContentSchema2 = z42.z.union([
13422
13443
  z42.z.string(),
13423
13444
  z42.z.instanceof(Uint8Array),
@@ -15174,7 +15195,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
15174
15195
  );
15175
15196
  return Object.fromEntries(normalizedHeaders.entries());
15176
15197
  }
15177
- var VERSION4 = "4.0.38";
15198
+ var VERSION4 = "4.0.39";
15178
15199
  var getOriginalFetch3 = () => globalThis.fetch;
15179
15200
  var getFromApi2 = async ({
15180
15201
  url,
@@ -16460,11 +16481,18 @@ function asSchema3(schema) {
16460
16481
  }
16461
16482
  function standardSchema(standardSchema2) {
16462
16483
  return jsonSchema3(
16463
- () => addAdditionalPropertiesToJsonSchema2(
16464
- standardSchema2["~standard"].jsonSchema.input({
16465
- target: "draft-07"
16466
- })
16467
- ),
16484
+ () => {
16485
+ if (!hasStandardJsonSchema(standardSchema2)) {
16486
+ throw new Error(
16487
+ `Standard schema vendor '${standardSchema2["~standard"].vendor}' does not support JSON Schema conversion.`
16488
+ );
16489
+ }
16490
+ return addAdditionalPropertiesToJsonSchema2(
16491
+ standardSchema2["~standard"].jsonSchema.input({
16492
+ target: "draft-07"
16493
+ })
16494
+ );
16495
+ },
16468
16496
  {
16469
16497
  validate: async (value) => {
16470
16498
  const result = await standardSchema2["~standard"].validate(value);
@@ -16479,6 +16507,9 @@ function standardSchema(standardSchema2) {
16479
16507
  }
16480
16508
  );
16481
16509
  }
16510
+ function hasStandardJsonSchema(schema) {
16511
+ return schema["~standard"].jsonSchema != null;
16512
+ }
16482
16513
  function zod3Schema2(zodSchema22, options) {
16483
16514
  var _a223;
16484
16515
  const useReferences = (_a223 = void 0 ) != null ? _a223 : false;
@@ -17152,7 +17183,7 @@ var GatewayFailedDependencyError = class extends (_b74 = GatewayError2, _a76 = s
17152
17183
  var name76 = "GatewayForbiddenError";
17153
17184
  var marker86 = `vercel.ai.gateway.error.${name76}`;
17154
17185
  var symbol86 = Symbol.for(marker86);
17155
- var forbiddenParamSchema = lazySchema2(
17186
+ var forbiddenParamSchema2 = lazySchema2(
17156
17187
  () => zodSchema3(
17157
17188
  z42.z.object({
17158
17189
  ruleId: z42.z.string()
@@ -17284,7 +17315,7 @@ async function createGatewayErrorFromResponse2({
17284
17315
  case "forbidden": {
17285
17316
  const ruleResult = await safeValidateTypes3({
17286
17317
  value: validatedResponse.error.param,
17287
- schema: forbiddenParamSchema
17318
+ schema: forbiddenParamSchema2
17288
17319
  });
17289
17320
  return new GatewayForbiddenError2({
17290
17321
  message,
@@ -18935,7 +18966,7 @@ async function getVercelRequestId2() {
18935
18966
  var _a117;
18936
18967
  return (_a117 = getContext2().headers) == null ? void 0 : _a117["x-vercel-id"];
18937
18968
  }
18938
- var VERSION5 = "3.0.148";
18969
+ var VERSION5 = "3.0.151";
18939
18970
  var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
18940
18971
  function createGatewayProvider2(options = {}) {
18941
18972
  var _a117, _b113;
@@ -20041,7 +20072,7 @@ function getTotalTimeoutMs(timeout) {
20041
20072
  }
20042
20073
  return timeout.totalMs;
20043
20074
  }
20044
- var VERSION23 = "6.0.224";
20075
+ var VERSION23 = "6.0.228";
20045
20076
  var dataContentSchema3 = z42.z.union([
20046
20077
  z42.z.string(),
20047
20078
  z42.z.instanceof(Uint8Array),
@@ -25409,7 +25440,7 @@ ${workingMemory}`;
25409
25440
  }
25410
25441
  if (omConfig.observation?.bufferTokens !== false && !features.coreFeatures.has("asyncBuffering")) {
25411
25442
  throw new Error(
25412
- "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."
25443
+ "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."
25413
25444
  );
25414
25445
  }
25415
25446
  if (!features.coreFeatures.has("request-response-id-rotation")) {
@@ -25417,7 +25448,7 @@ ${workingMemory}`;
25417
25448
  "Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
25418
25449
  );
25419
25450
  }
25420
- const { ObservationalMemory: OMClass } = await import('./observational-memory-2F4GJOP2.cjs');
25451
+ const { ObservationalMemory: OMClass } = await import('./observational-memory-OD3W7JXC.cjs');
25421
25452
  const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
25422
25453
  await this.indexObservation(observation);
25423
25454
  } : void 0;
@@ -26465,7 +26496,7 @@ Notes:
26465
26496
  if (!effectiveConfig) return null;
26466
26497
  const engine = await this.omEngine;
26467
26498
  if (!engine) return null;
26468
- const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-2F4GJOP2.cjs');
26499
+ const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-OD3W7JXC.cjs');
26469
26500
  return new ObservationalMemoryProcessor2(engine, this, {
26470
26501
  temporalMarkers: effectiveConfig.temporalMarkers
26471
26502
  });
@@ -31461,5 +31492,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
31461
31492
  exports.stripObservationGroups = stripObservationGroups;
31462
31493
  exports.summarizeConversation = summarizeConversation;
31463
31494
  exports.wrapInObservationGroup = wrapInObservationGroup;
31464
- //# sourceMappingURL=chunk-42LZUXJ3.cjs.map
31465
- //# sourceMappingURL=chunk-42LZUXJ3.cjs.map
31495
+ //# sourceMappingURL=chunk-YNTQFC3L.cjs.map
31496
+ //# sourceMappingURL=chunk-YNTQFC3L.cjs.map