@mastra/memory 1.20.1-alpha.0 → 1.20.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 (46) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +2 -160
  3. package/dist/{chunk-LXU26UVM.js → chunk-KMJQDCCZ.js} +128 -12
  4. package/dist/{chunk-LXU26UVM.js.map → chunk-KMJQDCCZ.js.map} +1 -1
  5. package/dist/{chunk-R2H7SJS2.cjs → chunk-P4BYW7GY.cjs} +127 -11
  6. package/dist/chunk-P4BYW7GY.cjs.map +1 -0
  7. package/dist/docs/SKILL.md +1 -1
  8. package/dist/docs/assets/SOURCE_MAP.json +28 -28
  9. package/dist/docs/references/docs-agents-agent-approval.md +15 -1
  10. package/dist/docs/references/docs-agents-background-tasks.md +2 -2
  11. package/dist/docs/references/docs-agents-networks.md +1 -1
  12. package/dist/docs/references/docs-agents-supervisor-agents.md +2 -2
  13. package/dist/docs/references/docs-memory-memory-processors.md +6 -6
  14. package/dist/docs/references/docs-memory-multi-user-threads.md +1 -1
  15. package/dist/docs/references/docs-memory-semantic-recall.md +2 -2
  16. package/dist/docs/references/docs-memory-storage.md +2 -1
  17. package/dist/docs/references/docs-memory-working-memory.md +1 -1
  18. package/dist/docs/references/reference-memory-memory-class.md +3 -3
  19. package/dist/docs/references/reference-memory-observational-memory.md +4 -4
  20. package/dist/docs/references/reference-processors-token-limiter-processor.md +3 -3
  21. package/dist/docs/references/reference-storage-dsql.md +1 -1
  22. package/dist/docs/references/reference-storage-mongodb.md +1 -1
  23. package/dist/docs/references/reference-storage-postgresql.md +1 -1
  24. package/dist/docs/references/reference-storage-redis.md +1 -1
  25. package/dist/docs/references/reference-storage-upstash.md +1 -1
  26. package/dist/docs/references/reference-vectors-libsql.md +1 -1
  27. package/dist/docs/references/reference-vectors-mongodb.md +1 -1
  28. package/dist/docs/references/reference-vectors-pg.md +3 -1
  29. package/dist/docs/references/reference-vectors-upstash.md +1 -1
  30. package/dist/index.cjs +198 -203
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +189 -194
  34. package/dist/index.js.map +1 -1
  35. package/dist/{observational-memory-L32TPJ5J.cjs → observational-memory-CDLGZL67.cjs} +26 -26
  36. package/dist/{observational-memory-L32TPJ5J.cjs.map → observational-memory-CDLGZL67.cjs.map} +1 -1
  37. package/dist/{observational-memory-GE5MP6W7.js → observational-memory-TJFOX3YN.js} +3 -3
  38. package/dist/{observational-memory-GE5MP6W7.js.map → observational-memory-TJFOX3YN.js.map} +1 -1
  39. package/dist/processors/index.cjs +24 -24
  40. package/dist/processors/index.js +1 -1
  41. package/dist/processors/observational-memory/temporal-markers.d.ts.map +1 -1
  42. package/dist/processors/observational-memory/token-counter.d.ts +1 -0
  43. package/dist/processors/observational-memory/token-counter.d.ts.map +1 -1
  44. package/dist/tools/working-memory.d.ts.map +1 -1
  45. package/package.json +8 -8
  46. package/dist/chunk-R2H7SJS2.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 1.20.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed observational memory replaying previously observed assistant responses during reprocessing, so past assistant messages no longer reappear in later turns. ([#17338](https://github.com/mastra-ai/mastra/pull/17338))
8
+
9
+ - Fixed a crash in Cloudflare Workers when using a Zod schema for working memory. Working-memory input is now validated directly by the provided schema validator, which avoids runtime restrictions in Cloudflare Workers. ([#17327](https://github.com/mastra-ai/mastra/pull/17327))
10
+
11
+ - Preserve system-reminder filtering for normalized reactive signal metadata. ([#17191](https://github.com/mastra-ai/mastra/pull/17191))
12
+
13
+ - Added `observation.bufferOnIdle` to opt idle turns into background observation buffering and carry the signal sender needed for background notifications. ([#17181](https://github.com/mastra-ai/mastra/pull/17181))
14
+
15
+ - Fixed `Memory.saveMessages` not populating `role`, `content`, and `created_at` in the vector store metadata. Calls to `GET /api/memory/search` now return matches with the full message shape regardless of whether messages were saved through `agent.generate`/`agent.stream` or written directly via `Memory.saveMessages` (for example through the `POST /api/memory/save-messages` HTTP route used by external agents). ([#16381](https://github.com/mastra-ai/mastra/pull/16381))
16
+
17
+ - Updated dependencies [[`00eca42`](https://github.com/mastra-ai/mastra/commit/00eca4252393aa114dc8c9a5e1da68df91fa06cf), [`fa63872`](https://github.com/mastra-ai/mastra/commit/fa6387280954e6b667bec5714b55ba082bc627ff), [`d779de3`](https://github.com/mastra-ai/mastra/commit/d779de3cd9d2e7ed8110547190e2f15e786a0e41), [`1750c97`](https://github.com/mastra-ai/mastra/commit/1750c975d6179fbf6db2813b15229d4f8f23fc55), [`9283971`](https://github.com/mastra-ai/mastra/commit/928397157009b4aef4d5fdf3a0a273cb371beb55), [`f07b646`](https://github.com/mastra-ai/mastra/commit/f07b64604ab7d25391179790b7fd4823df9e2dff), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`40f9297`](https://github.com/mastra-ai/mastra/commit/40f9297003b921c62373d3e8d3a4bda76c9f6de3), [`19a8658`](https://github.com/mastra-ai/mastra/commit/19a86589c788ef48bb6c1b0612cc82a201857379), [`850af77`](https://github.com/mastra-ai/mastra/commit/850af7779cb87c350804488734544a5b1843de25), [`0f0d1ba`](https://github.com/mastra-ai/mastra/commit/0f0d1ba67bfcb2204e571401662f1eceefc03357), [`a18775a`](https://github.com/mastra-ai/mastra/commit/a18775a693172546ee2378d39b67d4e32895b251), [`1baf2d1`](https://github.com/mastra-ai/mastra/commit/1baf2d152c6881338ff8f114633d5316fe13dd15), [`8c31bcd`](https://github.com/mastra-ai/mastra/commit/8c31bcdb00e597880d5939b1b7d7566fbe5dacae), [`0e32507`](https://github.com/mastra-ai/mastra/commit/0e32507962cdfa5569b7bda5bc6fb3dd34e40b03), [`95b14cd`](https://github.com/mastra-ai/mastra/commit/95b14cdd820e86d97ac05fe568424c513a252e31), [`07c3de7`](https://github.com/mastra-ai/mastra/commit/07c3de7f7bc418beccaea3b5e6b7f7cdda79d492), [`0bf2d93`](https://github.com/mastra-ai/mastra/commit/0bf2d932d20e2936f2d9abb8c0a86e24fbc97ec6), [`7b0d34c`](https://github.com/mastra-ai/mastra/commit/7b0d34cfe4a2fce22ac86ae17404685ff67a2ddb), [`a659a77`](https://github.com/mastra-ai/mastra/commit/a659a779bdebe3a52a518c56d2260592d0240fe0), [`aa36be2`](https://github.com/mastra-ai/mastra/commit/aa36be23aa513b7dc53cb8ca16b7fab8f20e43ad), [`3332be9`](https://github.com/mastra-ai/mastra/commit/3332be9701ecd77aba840959d9a1d1ce7aef02d3), [`212c635`](https://github.com/mastra-ai/mastra/commit/212c635203e61d036ab41db8ff86c3893dc795b3), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`9aa5a73`](https://github.com/mastra-ai/mastra/commit/9aa5a73e7e110f6e9365eec69364a33d5f03bb56), [`f73c789`](https://github.com/mastra-ai/mastra/commit/f73c789e8ef21561580395d2c410119cab5848c8), [`8bd16da`](https://github.com/mastra-ai/mastra/commit/8bd16da73a4cb874d739373643dbd6a6e7f88684), [`c8630f8`](https://github.com/mastra-ai/mastra/commit/c8630f80d4f40cb5d22e60ab162b618b1907167a), [`94dfef6`](https://github.com/mastra-ai/mastra/commit/94dfef6e2bf19a88467ea3940afcbce88a433f0f), [`47f71dc`](https://github.com/mastra-ai/mastra/commit/47f71dc6fbcbd12d71e21a979e676e20a02bd77d), [`50ceae2`](https://github.com/mastra-ai/mastra/commit/50ceae270878e2f8fb2b2c6c2faab09df0007c8a), [`a122f79`](https://github.com/mastra-ai/mastra/commit/a122f79427ae225ec79c7b2ed46278da48d04b17), [`8cdde58`](https://github.com/mastra-ai/mastra/commit/8cdde5875bbba6702d9df226f2b20232b8d75d6c), [`3a081c1`](https://github.com/mastra-ai/mastra/commit/3a081c1255c5ae8c99f6dad91cc612934ef6f2bd), [`49f8abc`](https://github.com/mastra-ai/mastra/commit/49f8abce8258e4f2f87bd326acfbdb641264a47c), [`847ff1e`](https://github.com/mastra-ai/mastra/commit/847ff1e0d94368d94b2e173e4e0908e115568ef3), [`0c1ed1d`](https://github.com/mastra-ai/mastra/commit/0c1ed1d00c7d87b5ac99ca95896211a2fa9189fa), [`259d409`](https://github.com/mastra-ai/mastra/commit/259d409a514174299dbde1ff5e1121209b3ba850), [`9e16c68`](https://github.com/mastra-ai/mastra/commit/9e16c6818b6485ccb43df28aba6f3a2219d28662), [`cefca33`](https://github.com/mastra-ai/mastra/commit/cefca33ae666e69810c935fedf95a929c173d1d7), [`d00e8c5`](https://github.com/mastra-ai/mastra/commit/d00e8c50daebe5bce5bf2f48bde39c86fc3d2fe4), [`36fa7e2`](https://github.com/mastra-ai/mastra/commit/36fa7e24d14e58a1eb46147097b32f583e5b8775), [`87e9774`](https://github.com/mastra-ai/mastra/commit/87e97741c1e493cd6d62f478eb810b49bda4d57c), [`65a72e7`](https://github.com/mastra-ai/mastra/commit/65a72e70c25eedea8ff985a6624b96be2850236b), [`fe9eacd`](https://github.com/mastra-ai/mastra/commit/fe9eacd9545a0a9d64aad31c9fa90294a425289e), [`4c02027`](https://github.com/mastra-ai/mastra/commit/4c020277235eaa6b1dc957c90ad0639eef213992), [`0f77241`](https://github.com/mastra-ai/mastra/commit/0f7724108806703799a8ba80ad0f09414afd5066), [`849efb9`](https://github.com/mastra-ai/mastra/commit/849efb9fca6dc976589c1f90a303fea618769109), [`92ff509`](https://github.com/mastra-ai/mastra/commit/92ff5098ef8a990438ca038077021a5f7541ec1d), [`3fce5e7`](https://github.com/mastra-ai/mastra/commit/3fce5e70d011d289043e75003ef3336ed4aa43c3), [`a763592`](https://github.com/mastra-ai/mastra/commit/a763592c3db46963ef1011cfe16fe372816e775e), [`db79c86`](https://github.com/mastra-ai/mastra/commit/db79c86c60723d57e02f9636ca2611bd4515f194), [`6855012`](https://github.com/mastra-ai/mastra/commit/685501247cc4717506f3e89beed03509d63a5370), [`80c7737`](https://github.com/mastra-ai/mastra/commit/80c7737e32d7917b5f356957d67c169d01744fd3), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`3f1cf47`](https://github.com/mastra-ai/mastra/commit/3f1cf476f74c1e4cc2df908837e05853a5347e31), [`ff9d743`](https://github.com/mastra-ai/mastra/commit/ff9d743f71d7e072927725c0d700632aca0c1fee)]:
18
+ - @mastra/schema-compat@1.2.11
19
+ - @mastra/core@1.38.0
20
+
21
+ ## 1.20.1-alpha.1
22
+
23
+ ### Patch Changes
24
+
25
+ - Fixed observational memory replaying previously observed assistant responses during reprocessing, so past assistant messages no longer reappear in later turns. ([#17338](https://github.com/mastra-ai/mastra/pull/17338))
26
+
27
+ - Fixed a crash in Cloudflare Workers when using a Zod schema for working memory. Working-memory input is now validated directly by the provided schema validator, which avoids runtime restrictions in Cloudflare Workers. ([#17327](https://github.com/mastra-ai/mastra/pull/17327))
28
+
29
+ - Preserve system-reminder filtering for normalized reactive signal metadata. ([#17191](https://github.com/mastra-ai/mastra/pull/17191))
30
+
31
+ - Fixed `Memory.saveMessages` not populating `role`, `content`, and `created_at` in the vector store metadata. Calls to `GET /api/memory/search` now return matches with the full message shape regardless of whether messages were saved through `agent.generate`/`agent.stream` or written directly via `Memory.saveMessages` (for example through the `POST /api/memory/save-messages` HTTP route used by external agents). ([#16381](https://github.com/mastra-ai/mastra/pull/16381))
32
+
33
+ - Updated dependencies [[`00eca42`](https://github.com/mastra-ai/mastra/commit/00eca4252393aa114dc8c9a5e1da68df91fa06cf), [`8ace89d`](https://github.com/mastra-ai/mastra/commit/8ace89df77f762e622d3b9f7f65ad7524350d050), [`fa63872`](https://github.com/mastra-ai/mastra/commit/fa6387280954e6b667bec5714b55ba082bc627ff), [`f07b646`](https://github.com/mastra-ai/mastra/commit/f07b64604ab7d25391179790b7fd4823df9e2dff), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`40f9297`](https://github.com/mastra-ai/mastra/commit/40f9297003b921c62373d3e8d3a4bda76c9f6de3), [`0f0d1ba`](https://github.com/mastra-ai/mastra/commit/0f0d1ba67bfcb2204e571401662f1eceefc03357), [`8c31bcd`](https://github.com/mastra-ai/mastra/commit/8c31bcdb00e597880d5939b1b7d7566fbe5dacae), [`95b14cd`](https://github.com/mastra-ai/mastra/commit/95b14cdd820e86d97ac05fe568424c513a252e31), [`aa36be2`](https://github.com/mastra-ai/mastra/commit/aa36be23aa513b7dc53cb8ca16b7fab8f20e43ad), [`212c635`](https://github.com/mastra-ai/mastra/commit/212c635203e61d036ab41db8ff86c3893dc795b3), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`9aa5a73`](https://github.com/mastra-ai/mastra/commit/9aa5a73e7e110f6e9365eec69364a33d5f03bb56), [`f73c789`](https://github.com/mastra-ai/mastra/commit/f73c789e8ef21561580395d2c410119cab5848c8), [`8bd16da`](https://github.com/mastra-ai/mastra/commit/8bd16da73a4cb874d739373643dbd6a6e7f88684), [`c8630f8`](https://github.com/mastra-ai/mastra/commit/c8630f80d4f40cb5d22e60ab162b618b1907167a), [`47f71dc`](https://github.com/mastra-ai/mastra/commit/47f71dc6fbcbd12d71e21a979e676e20a02bd77d), [`50ceae2`](https://github.com/mastra-ai/mastra/commit/50ceae270878e2f8fb2b2c6c2faab09df0007c8a), [`8cdde58`](https://github.com/mastra-ai/mastra/commit/8cdde5875bbba6702d9df226f2b20232b8d75d6c), [`847ff1e`](https://github.com/mastra-ai/mastra/commit/847ff1e0d94368d94b2e173e4e0908e115568ef3), [`259d409`](https://github.com/mastra-ai/mastra/commit/259d409a514174299dbde1ff5e1121209b3ba850), [`9e16c68`](https://github.com/mastra-ai/mastra/commit/9e16c6818b6485ccb43df28aba6f3a2219d28662), [`cefca33`](https://github.com/mastra-ai/mastra/commit/cefca33ae666e69810c935fedf95a929c173d1d7), [`d00e8c5`](https://github.com/mastra-ai/mastra/commit/d00e8c50daebe5bce5bf2f48bde39c86fc3d2fe4), [`36fa7e2`](https://github.com/mastra-ai/mastra/commit/36fa7e24d14e58a1eb46147097b32f583e5b8775), [`87e9774`](https://github.com/mastra-ai/mastra/commit/87e97741c1e493cd6d62f478eb810b49bda4d57c), [`65a72e7`](https://github.com/mastra-ai/mastra/commit/65a72e70c25eedea8ff985a6624b96be2850236b), [`0f77241`](https://github.com/mastra-ai/mastra/commit/0f7724108806703799a8ba80ad0f09414afd5066), [`92ff509`](https://github.com/mastra-ai/mastra/commit/92ff5098ef8a990438ca038077021a5f7541ec1d), [`3fce5e7`](https://github.com/mastra-ai/mastra/commit/3fce5e70d011d289043e75003ef3336ed4aa43c3), [`a763592`](https://github.com/mastra-ai/mastra/commit/a763592c3db46963ef1011cfe16fe372816e775e), [`80c7737`](https://github.com/mastra-ai/mastra/commit/80c7737e32d7917b5f356957d67c169d01744fd3), [`3f1cf47`](https://github.com/mastra-ai/mastra/commit/3f1cf476f74c1e4cc2df908837e05853a5347e31), [`ff9d743`](https://github.com/mastra-ai/mastra/commit/ff9d743f71d7e072927725c0d700632aca0c1fee)]:
34
+ - @mastra/schema-compat@1.2.11-alpha.0
35
+ - @mastra/core@1.38.0-alpha.3
36
+
3
37
  ## 1.20.1-alpha.0
4
38
 
5
39
  ### Patch Changes
@@ -1,3 +1,4 @@
1
+ import { JSONSchema7 } from 'json-schema';
1
2
  import { ServerResponse } from 'http';
2
3
  import { ServerResponse as ServerResponse_2 } from 'node:http';
3
4
  import { z } from 'zod';
@@ -3324,165 +3325,6 @@ export declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, {
3324
3325
  };
3325
3326
  }): Schema<OBJECT>;
3326
3327
 
3327
- declare interface JSONSchema7 {
3328
- $id?: string | undefined;
3329
- $ref?: string | undefined;
3330
- $schema?: JSONSchema7Version | undefined;
3331
- $comment?: string | undefined;
3332
-
3333
- /**
3334
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
3335
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
3336
- */
3337
- $defs?: {
3338
- [key: string]: JSONSchema7Definition;
3339
- } | undefined;
3340
-
3341
- /**
3342
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
3343
- */
3344
- type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
3345
- enum?: JSONSchema7Type[] | undefined;
3346
- const?: JSONSchema7Type | undefined;
3347
-
3348
- /**
3349
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
3350
- */
3351
- multipleOf?: number | undefined;
3352
- maximum?: number | undefined;
3353
- exclusiveMaximum?: number | undefined;
3354
- minimum?: number | undefined;
3355
- exclusiveMinimum?: number | undefined;
3356
-
3357
- /**
3358
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
3359
- */
3360
- maxLength?: number | undefined;
3361
- minLength?: number | undefined;
3362
- pattern?: string | undefined;
3363
-
3364
- /**
3365
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
3366
- */
3367
- items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
3368
- additionalItems?: JSONSchema7Definition | undefined;
3369
- maxItems?: number | undefined;
3370
- minItems?: number | undefined;
3371
- uniqueItems?: boolean | undefined;
3372
- contains?: JSONSchema7Definition | undefined;
3373
-
3374
- /**
3375
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
3376
- */
3377
- maxProperties?: number | undefined;
3378
- minProperties?: number | undefined;
3379
- required?: string[] | undefined;
3380
- properties?: {
3381
- [key: string]: JSONSchema7Definition;
3382
- } | undefined;
3383
- patternProperties?: {
3384
- [key: string]: JSONSchema7Definition;
3385
- } | undefined;
3386
- additionalProperties?: JSONSchema7Definition | undefined;
3387
- dependencies?: {
3388
- [key: string]: JSONSchema7Definition | string[];
3389
- } | undefined;
3390
- propertyNames?: JSONSchema7Definition | undefined;
3391
-
3392
- /**
3393
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
3394
- */
3395
- if?: JSONSchema7Definition | undefined;
3396
- then?: JSONSchema7Definition | undefined;
3397
- else?: JSONSchema7Definition | undefined;
3398
-
3399
- /**
3400
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
3401
- */
3402
- allOf?: JSONSchema7Definition[] | undefined;
3403
- anyOf?: JSONSchema7Definition[] | undefined;
3404
- oneOf?: JSONSchema7Definition[] | undefined;
3405
- not?: JSONSchema7Definition | undefined;
3406
-
3407
- /**
3408
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
3409
- */
3410
- format?: string | undefined;
3411
-
3412
- /**
3413
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
3414
- */
3415
- contentMediaType?: string | undefined;
3416
- contentEncoding?: string | undefined;
3417
-
3418
- /**
3419
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
3420
- */
3421
- definitions?: {
3422
- [key: string]: JSONSchema7Definition;
3423
- } | undefined;
3424
-
3425
- /**
3426
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
3427
- */
3428
- title?: string | undefined;
3429
- description?: string | undefined;
3430
- default?: JSONSchema7Type | undefined;
3431
- readOnly?: boolean | undefined;
3432
- writeOnly?: boolean | undefined;
3433
- examples?: JSONSchema7Type | undefined;
3434
- }
3435
-
3436
- declare interface JSONSchema7Array extends Array<JSONSchema7Type> {}
3437
-
3438
- /**
3439
- * JSON Schema v7
3440
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
3441
- */
3442
- declare type JSONSchema7Definition = JSONSchema7 | boolean;
3443
-
3444
- declare interface JSONSchema7Object {
3445
- [key: string]: JSONSchema7Type;
3446
- }
3447
-
3448
- /**
3449
- * Primitive type
3450
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
3451
- */
3452
- declare type JSONSchema7Type =
3453
- | string //
3454
- | number
3455
- | boolean
3456
- | JSONSchema7Object
3457
- | JSONSchema7Array
3458
- | null;
3459
-
3460
- /**
3461
- * Primitive type
3462
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
3463
- */
3464
- declare type JSONSchema7TypeName =
3465
- | "string" //
3466
- | "number"
3467
- | "integer"
3468
- | "boolean"
3469
- | "object"
3470
- | "array"
3471
- | "null";
3472
-
3473
- /**
3474
- * Meta schema
3475
- *
3476
- * Recommended values:
3477
- * - 'http://json-schema.org/schema#'
3478
- * - 'http://json-schema.org/hyper-schema#'
3479
- * - 'http://json-schema.org/draft-07/schema#'
3480
- * - 'http://json-schema.org/draft-07/hyper-schema#'
3481
- *
3482
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
3483
- */
3484
- declare type JSONSchema7Version = string;
3485
-
3486
3328
  /**
3487
3329
  A JSON value can be a string, number, boolean, object, array, or null.
3488
3330
  JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods.
@@ -7605,4 +7447,4 @@ export declare function zodSchema<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeD
7605
7447
  }): Schema<OBJECT>;
7606
7448
 
7607
7449
  export { }
7608
- export { LanguageModelV1Message as LanguageModelV1Message, LanguageModelV1CallSettings as LanguageModelV1CallSettings, LanguageModelV1FunctionTool as LanguageModelV1FunctionTool, LanguageModelV1ProviderDefinedTool as LanguageModelV1ProviderDefinedTool, LanguageModelV1ToolChoice as LanguageModelV1ToolChoice, LanguageModelV1ObjectGenerationMode as LanguageModelV1ObjectGenerationMode, LanguageModelV1FunctionToolCall as LanguageModelV1FunctionToolCall, LanguageModelV1Source as LanguageModelV1Source, LanguageModelV1LogProbs as LanguageModelV1LogProbs, FetchFunction as FetchFunction, TextUIPart as TextUIPart, ReasoningUIPart as ReasoningUIPart, ToolInvocationUIPart as ToolInvocationUIPart, SourceUIPart as SourceUIPart, FileUIPart as FileUIPart, StepStartUIPart as StepStartUIPart, AssistantStreamPartType as AssistantStreamPartType, AssistantStreamPartValueType as AssistantStreamPartValueType, AssistantStreamString as AssistantStreamString, DataStreamPartType as DataStreamPartType, DataStreamPartValueType as DataStreamPartValueType, DeepPartialInternal as DeepPartialInternal, Validator as Validator, JSONSchema7 as JSONSchema7, LanguageModelV1FinishReason as LanguageModelV1FinishReason, LanguageModelV1CallWarning as LanguageModelV1CallWarning, JSONValue_2 as JSONValue_2, Source as Source, DataStreamString as DataStreamString, AttributeValue as AttributeValue, Tracer as Tracer, EmbeddingModelV1 as EmbeddingModelV1, EmbeddingModelV1Embedding as EmbeddingModelV1Embedding, ImageModelV1CallWarning as ImageModelV1CallWarning, TranscriptionModelV1CallWarning as TranscriptionModelV1CallWarning, SpeechModelV1CallWarning as SpeechModelV1CallWarning, ProviderOptions as ProviderOptions, ReasoningPart as ReasoningPart, RedactedReasoningPart as RedactedReasoningPart, ToolResultContent as ToolResultContent, inferParameters as inferParameters, ToolParameters as ToolParameters, JSONRPCRequestSchema as JSONRPCRequestSchema, JSONRPCResponseSchema as JSONRPCResponseSchema, JSONRPCErrorSchema as JSONRPCErrorSchema, JSONRPCNotificationSchema as JSONRPCNotificationSchema, JSONRPCMessageSchema as JSONRPCMessageSchema, MCPClientConfig as MCPClientConfig, MCPClient as MCPClient, ValueOf as ValueOf, ToToolResultObject as ToToolResultObject, ToToolsWithDefinedExecute as ToToolsWithDefinedExecute, ToToolsWithExecute as ToToolsWithExecute, ReasoningDetail as ReasoningDetail, ToolCallArray as ToolCallArray, ToolResultArray as ToolResultArray, ResponseMessage as ResponseMessage, Output_2 as Output_2, ConsumeStreamOptions as ConsumeStreamOptions, ImageModelV1 as ImageModelV1, CallSettings as CallSettings, Prompt as Prompt, StreamObjectOnErrorCallback as StreamObjectOnErrorCallback, AsyncIterableStream as AsyncIterableStream, SpeechModelV1 as SpeechModelV1, TranscriptionModelV1 as TranscriptionModelV1, LanguageModelV1ProviderMetadata as LanguageModelV1ProviderMetadata, ExtractModelId as ExtractModelId, ExtractLiteralUnion as ExtractLiteralUnion, ProviderV1 as ProviderV1, SingleRequestTextStreamPart as SingleRequestTextStreamPart, RetryErrorReason as RetryErrorReason, AssistantResponseSettings as AssistantResponseSettings, AssistantResponseCallback as AssistantResponseCallback };
7450
+ export { LanguageModelV1Message as LanguageModelV1Message, LanguageModelV1CallSettings as LanguageModelV1CallSettings, LanguageModelV1FunctionTool as LanguageModelV1FunctionTool, LanguageModelV1ProviderDefinedTool as LanguageModelV1ProviderDefinedTool, LanguageModelV1ToolChoice as LanguageModelV1ToolChoice, LanguageModelV1ObjectGenerationMode as LanguageModelV1ObjectGenerationMode, LanguageModelV1FunctionToolCall as LanguageModelV1FunctionToolCall, LanguageModelV1Source as LanguageModelV1Source, LanguageModelV1LogProbs as LanguageModelV1LogProbs, FetchFunction as FetchFunction, TextUIPart as TextUIPart, ReasoningUIPart as ReasoningUIPart, ToolInvocationUIPart as ToolInvocationUIPart, SourceUIPart as SourceUIPart, FileUIPart as FileUIPart, StepStartUIPart as StepStartUIPart, AssistantStreamPartType as AssistantStreamPartType, AssistantStreamPartValueType as AssistantStreamPartValueType, AssistantStreamString as AssistantStreamString, DataStreamPartType as DataStreamPartType, DataStreamPartValueType as DataStreamPartValueType, DeepPartialInternal as DeepPartialInternal, Validator as Validator, LanguageModelV1FinishReason as LanguageModelV1FinishReason, LanguageModelV1CallWarning as LanguageModelV1CallWarning, JSONValue_2 as JSONValue_2, Source as Source, DataStreamString as DataStreamString, AttributeValue as AttributeValue, Tracer as Tracer, EmbeddingModelV1 as EmbeddingModelV1, EmbeddingModelV1Embedding as EmbeddingModelV1Embedding, ImageModelV1CallWarning as ImageModelV1CallWarning, TranscriptionModelV1CallWarning as TranscriptionModelV1CallWarning, SpeechModelV1CallWarning as SpeechModelV1CallWarning, ProviderOptions as ProviderOptions, ReasoningPart as ReasoningPart, RedactedReasoningPart as RedactedReasoningPart, ToolResultContent as ToolResultContent, inferParameters as inferParameters, ToolParameters as ToolParameters, JSONRPCRequestSchema as JSONRPCRequestSchema, JSONRPCResponseSchema as JSONRPCResponseSchema, JSONRPCErrorSchema as JSONRPCErrorSchema, JSONRPCNotificationSchema as JSONRPCNotificationSchema, JSONRPCMessageSchema as JSONRPCMessageSchema, MCPClientConfig as MCPClientConfig, MCPClient as MCPClient, ValueOf as ValueOf, ToToolResultObject as ToToolResultObject, ToToolsWithDefinedExecute as ToToolsWithDefinedExecute, ToToolsWithExecute as ToToolsWithExecute, ReasoningDetail as ReasoningDetail, ToolCallArray as ToolCallArray, ToolResultArray as ToolResultArray, ResponseMessage as ResponseMessage, Output_2 as Output_2, ConsumeStreamOptions as ConsumeStreamOptions, ImageModelV1 as ImageModelV1, CallSettings as CallSettings, Prompt as Prompt, StreamObjectOnErrorCallback as StreamObjectOnErrorCallback, AsyncIterableStream as AsyncIterableStream, SpeechModelV1 as SpeechModelV1, TranscriptionModelV1 as TranscriptionModelV1, LanguageModelV1ProviderMetadata as LanguageModelV1ProviderMetadata, ExtractModelId as ExtractModelId, ExtractLiteralUnion as ExtractLiteralUnion, ProviderV1 as ProviderV1, SingleRequestTextStreamPart as SingleRequestTextStreamPart, RetryErrorReason as RetryErrorReason, AssistantResponseSettings as AssistantResponseSettings, AssistantResponseCallback as AssistantResponseCallback };
@@ -6,7 +6,7 @@ import { MessageHistory } from '@mastra/core/processors';
6
6
  import xxhash from 'xxhash-wasm';
7
7
  import { appendFileSync, writeFileSync, mkdirSync } from 'fs';
8
8
  import { join } from 'path';
9
- import { randomBytes, createHash, randomUUID } from 'crypto';
9
+ import { createHash, randomBytes, randomUUID } from 'crypto';
10
10
  import { estimateTokenCount } from 'tokenx';
11
11
  import { Agent } from '@mastra/core/agent';
12
12
  import { getOrCreateSpan, EntityType, SpanType, createObservabilityContext } from '@mastra/core/observability';
@@ -5755,7 +5755,7 @@ function ensureMessageMastraMetadata(message) {
5755
5755
  return typedMessage.metadata.mastra;
5756
5756
  }
5757
5757
  function buildEstimateKey(kind, text) {
5758
- const payloadHash = createHash("sha1").update(text).digest("hex");
5758
+ const payloadHash = createHash("sha256").update(text).digest("hex");
5759
5759
  return `${kind}:${payloadHash}`;
5760
5760
  }
5761
5761
  function resolveEstimatorId() {
@@ -6298,7 +6298,7 @@ function getAttachmentFingerprint(asset) {
6298
6298
  }
6299
6299
  const base64 = encodeAttachmentBase64(asset);
6300
6300
  if (base64) {
6301
- return { contentHash: createHash("sha1").update(base64).digest("hex") };
6301
+ return { contentHash: createHash("sha256").update(base64).digest("hex") };
6302
6302
  }
6303
6303
  return {};
6304
6304
  }
@@ -6577,6 +6577,116 @@ var TokenCounter = class _TokenCounter {
6577
6577
  resolveToolResultForTokenCounting(part, invocationResult) {
6578
6578
  return resolveToolResultValue(part, invocationResult);
6579
6579
  }
6580
+ countMultimodalToolResultContent(part, toolResult) {
6581
+ if (!toolResult || typeof toolResult !== "object") {
6582
+ return void 0;
6583
+ }
6584
+ const output = toolResult;
6585
+ const content = output.type === "content" && Array.isArray(output.value) ? output.value : output.content;
6586
+ if (!Array.isArray(content)) {
6587
+ return void 0;
6588
+ }
6589
+ let hasAttachment = false;
6590
+ let tokens = 0;
6591
+ const cacheParts = [];
6592
+ const countJsonContentPart = (contentPart) => {
6593
+ const formatted = formatToolResultForObserver(contentPart);
6594
+ tokens += this.countString(formatted);
6595
+ cacheParts.push({ type: "json", valueHash: createHash("sha256").update(formatted).digest("hex") });
6596
+ };
6597
+ for (const item of content) {
6598
+ if (!item || typeof item !== "object") {
6599
+ continue;
6600
+ }
6601
+ const contentPart = item;
6602
+ const partType = contentPart.type;
6603
+ if (partType === "text") {
6604
+ const text = typeof contentPart.text === "string" ? contentPart.text : String(contentPart.value ?? "");
6605
+ tokens += this.countString(text);
6606
+ cacheParts.push({ type: "text", textHash: createHash("sha256").update(text).digest("hex") });
6607
+ continue;
6608
+ }
6609
+ if (partType === "image" || partType === "image-data" || partType === "media" && String(contentPart.mediaType ?? "").startsWith("image/")) {
6610
+ if (typeof contentPart.data !== "string") {
6611
+ countJsonContentPart(contentPart);
6612
+ continue;
6613
+ }
6614
+ hasAttachment = true;
6615
+ const imagePart = {
6616
+ type: "image",
6617
+ image: contentPart.data,
6618
+ mimeType: contentPart.mediaType ?? contentPart.mimeType,
6619
+ providerOptions: contentPart.providerOptions,
6620
+ providerMetadata: contentPart.providerMetadata
6621
+ };
6622
+ const clientEstimate = getClientPartTokenEstimate(imagePart);
6623
+ if (clientEstimate) {
6624
+ tokens += clientEstimate.tokens;
6625
+ cacheParts.push({
6626
+ type: "image-data-client-estimate",
6627
+ key: clientEstimate.key,
6628
+ tokens: clientEstimate.tokens
6629
+ });
6630
+ continue;
6631
+ }
6632
+ const estimate = this.estimateImageTokens(imagePart);
6633
+ tokens += estimate.tokens;
6634
+ cacheParts.push({ type: "image-data", estimate: JSON.parse(estimate.cachePayload) });
6635
+ continue;
6636
+ }
6637
+ if (partType === "audio" || partType === "file-data" || partType === "media") {
6638
+ if (typeof contentPart.data !== "string") {
6639
+ countJsonContentPart(contentPart);
6640
+ continue;
6641
+ }
6642
+ hasAttachment = true;
6643
+ const filePart = {
6644
+ type: "file",
6645
+ data: contentPart.data,
6646
+ mimeType: contentPart.mediaType ?? contentPart.mimeType,
6647
+ filename: contentPart.filename,
6648
+ providerOptions: contentPart.providerOptions,
6649
+ providerMetadata: contentPart.providerMetadata
6650
+ };
6651
+ const clientEstimate = getClientPartTokenEstimate(filePart);
6652
+ if (clientEstimate) {
6653
+ tokens += clientEstimate.tokens;
6654
+ cacheParts.push({
6655
+ type: "file-data-client-estimate",
6656
+ key: clientEstimate.key,
6657
+ tokens: clientEstimate.tokens
6658
+ });
6659
+ continue;
6660
+ }
6661
+ if (isImageLikeFilePart(filePart)) {
6662
+ const estimate = this.estimateImageLikeFileTokens(filePart);
6663
+ tokens += estimate.tokens;
6664
+ cacheParts.push({ type: "image-like-file-data", estimate: JSON.parse(estimate.cachePayload) });
6665
+ continue;
6666
+ }
6667
+ const byteEstimate = estimateNonImageFileTokens(this.getModelContext(), filePart);
6668
+ if (byteEstimate) {
6669
+ tokens += byteEstimate.tokens;
6670
+ cacheParts.push({ type: "file-data", estimate: JSON.parse(byteEstimate.cachePayload) });
6671
+ continue;
6672
+ }
6673
+ const descriptor = serializeNonImageFilePartForTokenCounting(filePart);
6674
+ tokens += this.countString(descriptor);
6675
+ cacheParts.push({ type: "file-data-descriptor", descriptor });
6676
+ continue;
6677
+ }
6678
+ countJsonContentPart(contentPart);
6679
+ }
6680
+ if (!hasAttachment) {
6681
+ return void 0;
6682
+ }
6683
+ return this.readOrPersistFixedPartEstimate(
6684
+ part,
6685
+ "tool-result-multimodal-content",
6686
+ JSON.stringify({ type: "content", value: cacheParts }),
6687
+ tokens
6688
+ );
6689
+ }
6580
6690
  estimateImageAssetTokens(part, asset, kind) {
6581
6691
  const modelContext = this.getModelContext();
6582
6692
  const provider = resolveProviderId(modelContext);
@@ -6835,12 +6945,17 @@ var TokenCounter = class _TokenCounter {
6835
6945
  invocation.result
6836
6946
  );
6837
6947
  if (resultForCounting !== void 0) {
6838
- const formattedResult = formatToolResultForObserver(resultForCounting);
6839
- tokens += this.readOrPersistPartEstimate(
6840
- part,
6841
- usingStoredModelOutput ? "tool-result-model-output-json" : "tool-result-json",
6842
- formattedResult
6843
- );
6948
+ const contentTokens = this.countMultimodalToolResultContent(part, resultForCounting);
6949
+ if (contentTokens !== void 0) {
6950
+ tokens += contentTokens;
6951
+ } else {
6952
+ const formattedResult = formatToolResultForObserver(resultForCounting);
6953
+ tokens += this.readOrPersistPartEstimate(
6954
+ part,
6955
+ usingStoredModelOutput ? "tool-result-model-output-json" : "tool-result-json",
6956
+ formattedResult
6957
+ );
6958
+ }
6844
6959
  if (typeof resultForCounting !== "string") {
6845
6960
  overheadDelta -= 12;
6846
6961
  }
@@ -9576,7 +9691,8 @@ async function insertTemporalGapMarkers({
9576
9691
  }
9577
9692
  await sendSignal?.({
9578
9693
  id: `__temporal_gap_${crypto.randomUUID()}`,
9579
- type: "system-reminder",
9694
+ type: "reactive",
9695
+ tagName: "system-reminder",
9580
9696
  contents: getTemporalGapReminderText(gapText, timestamp),
9581
9697
  createdAt: new Date(timestamp - 1),
9582
9698
  acceptedAt: new Date(timestamp),
@@ -9864,5 +9980,5 @@ function getObservationsAsOf(activeObservations, asOf) {
9864
9980
  }
9865
9981
 
9866
9982
  export { ModelByInputTokens, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deriveObservationGroupProvenance, extractCurrentTask, formatMessagesForObserver, formatToolResultForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, resolveToolResultValue, stripEphemeralAnchorIds, stripObservationGroups, truncateStringByTokens, wrapInObservationGroup };
9867
- //# sourceMappingURL=chunk-LXU26UVM.js.map
9868
- //# sourceMappingURL=chunk-LXU26UVM.js.map
9983
+ //# sourceMappingURL=chunk-KMJQDCCZ.js.map
9984
+ //# sourceMappingURL=chunk-KMJQDCCZ.js.map