@mastra/memory 1.0.0 → 1.0.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 (76) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/{chunk-SG3GRV3O.cjs → chunk-23EXJLET.cjs} +3 -3
  3. package/dist/chunk-23EXJLET.cjs.map +1 -0
  4. package/dist/{chunk-KMQS2YEC.js → chunk-BSDWQEU3.js} +3 -3
  5. package/dist/chunk-BSDWQEU3.js.map +1 -0
  6. package/dist/{chunk-WC4XBMZT.js → chunk-HJYHDIOC.js} +5 -5
  7. package/dist/chunk-HJYHDIOC.js.map +1 -0
  8. package/dist/{chunk-YMNW6DEN.cjs → chunk-LIBOSOHM.cjs} +14 -14
  9. package/dist/chunk-LIBOSOHM.cjs.map +1 -0
  10. package/dist/{chunk-ZUQPUTTO.cjs → chunk-O3CS4UGX.cjs} +3 -3
  11. package/dist/chunk-O3CS4UGX.cjs.map +1 -0
  12. package/dist/{chunk-QY6BZOPJ.js → chunk-WM6IIUQW.js} +5 -5
  13. package/dist/chunk-WM6IIUQW.js.map +1 -0
  14. package/dist/{chunk-MMUHFOCG.js → chunk-YF4R74L2.js} +3 -3
  15. package/dist/chunk-YF4R74L2.js.map +1 -0
  16. package/dist/{chunk-W72AYUIF.cjs → chunk-ZSBBXHNM.cjs} +14 -14
  17. package/dist/chunk-ZSBBXHNM.cjs.map +1 -0
  18. package/dist/docs/README.md +2 -2
  19. package/dist/docs/SKILL.md +2 -2
  20. package/dist/docs/SOURCE_MAP.json +1 -1
  21. package/dist/docs/agents/01-agent-memory.md +8 -8
  22. package/dist/docs/agents/02-networks.md +1 -1
  23. package/dist/docs/agents/03-agent-approval.md +2 -2
  24. package/dist/docs/agents/04-network-approval.md +2 -2
  25. package/dist/docs/core/01-reference.md +6 -6
  26. package/dist/docs/memory/01-overview.md +22 -53
  27. package/dist/docs/memory/02-storage.md +115 -87
  28. package/dist/docs/memory/03-message-history.md +249 -0
  29. package/dist/docs/memory/{03-working-memory.md → 04-working-memory.md} +22 -1
  30. package/dist/docs/memory/{04-semantic-recall.md → 05-semantic-recall.md} +45 -22
  31. package/dist/docs/memory/{05-memory-processors.md → 06-memory-processors.md} +4 -4
  32. package/dist/docs/memory/{06-reference.md → 07-reference.md} +33 -33
  33. package/dist/docs/processors/01-reference.md +1 -1
  34. package/dist/docs/storage/01-reference.md +114 -35
  35. package/dist/docs/vectors/01-reference.md +12 -12
  36. package/dist/index.cjs +56 -28
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.ts +9 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +44 -16
  41. package/dist/index.js.map +1 -1
  42. package/dist/{token-6GSAFR2W-JV3TZR4M.cjs → token-6GSAFR2W-2B4WM6AQ.cjs} +8 -8
  43. package/dist/token-6GSAFR2W-2B4WM6AQ.cjs.map +1 -0
  44. package/dist/{token-6GSAFR2W-VLY2XUPA.js → token-6GSAFR2W-ABXTQD64.js} +5 -5
  45. package/dist/token-6GSAFR2W-ABXTQD64.js.map +1 -0
  46. package/dist/{token-6GSAFR2W-YCB5SK2Z.cjs → token-6GSAFR2W-TW2P7HCS.cjs} +8 -8
  47. package/dist/token-6GSAFR2W-TW2P7HCS.cjs.map +1 -0
  48. package/dist/{token-6GSAFR2W-K2BTU23I.js → token-6GSAFR2W-WGTMOPEU.js} +5 -5
  49. package/dist/token-6GSAFR2W-WGTMOPEU.js.map +1 -0
  50. package/dist/token-util-NEHG7TUY-GYFEVMWP.cjs +10 -0
  51. package/dist/{token-util-NEHG7TUY-7IL6JUVY.cjs.map → token-util-NEHG7TUY-GYFEVMWP.cjs.map} +1 -1
  52. package/dist/token-util-NEHG7TUY-TV2H7N56.js +8 -0
  53. package/dist/{token-util-NEHG7TUY-KSXDO2NO.js.map → token-util-NEHG7TUY-TV2H7N56.js.map} +1 -1
  54. package/dist/token-util-NEHG7TUY-WJZIPNNX.cjs +10 -0
  55. package/dist/{token-util-NEHG7TUY-HF7KBP2H.cjs.map → token-util-NEHG7TUY-WJZIPNNX.cjs.map} +1 -1
  56. package/dist/token-util-NEHG7TUY-XQP3QSPX.js +8 -0
  57. package/dist/{token-util-NEHG7TUY-TIJ3LMSH.js.map → token-util-NEHG7TUY-XQP3QSPX.js.map} +1 -1
  58. package/dist/tools/working-memory.d.ts +2 -2
  59. package/dist/tools/working-memory.d.ts.map +1 -1
  60. package/package.json +9 -9
  61. package/dist/chunk-KMQS2YEC.js.map +0 -1
  62. package/dist/chunk-MMUHFOCG.js.map +0 -1
  63. package/dist/chunk-QY6BZOPJ.js.map +0 -1
  64. package/dist/chunk-SG3GRV3O.cjs.map +0 -1
  65. package/dist/chunk-W72AYUIF.cjs.map +0 -1
  66. package/dist/chunk-WC4XBMZT.js.map +0 -1
  67. package/dist/chunk-YMNW6DEN.cjs.map +0 -1
  68. package/dist/chunk-ZUQPUTTO.cjs.map +0 -1
  69. package/dist/token-6GSAFR2W-JV3TZR4M.cjs.map +0 -1
  70. package/dist/token-6GSAFR2W-K2BTU23I.js.map +0 -1
  71. package/dist/token-6GSAFR2W-VLY2XUPA.js.map +0 -1
  72. package/dist/token-6GSAFR2W-YCB5SK2Z.cjs.map +0 -1
  73. package/dist/token-util-NEHG7TUY-7IL6JUVY.cjs +0 -10
  74. package/dist/token-util-NEHG7TUY-HF7KBP2H.cjs +0 -10
  75. package/dist/token-util-NEHG7TUY-KSXDO2NO.js +0 -8
  76. package/dist/token-util-NEHG7TUY-TIJ3LMSH.js +0 -8
@@ -11,24 +11,26 @@
11
11
 
12
12
  The DynamoDB storage implementation provides a scalable and performant NoSQL database solution for Mastra, leveraging a single-table design pattern with [ElectroDB](https://electrodb.dev/).
13
13
 
14
+ > **Observability Not Supported**
15
+ DynamoDB storage **does not support the observability domain**. Traces from the `DefaultExporter` cannot be persisted to DynamoDB, and Mastra Studio's observability features won't work with DynamoDB as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite#specialized-storage-for-observability) to route observability data to a supported provider like ClickHouse or PostgreSQL.
16
+
17
+ > **Item Size Limit**
18
+ DynamoDB enforces a **400 KB maximum item size**. This limit can be exceeded when storing messages with base64-encoded attachments such as images. See [Handling large attachments](https://mastra.ai/docs/memory/storage#handling-large-attachments) for workarounds including uploading attachments to external storage.
19
+
14
20
  ## Features
15
21
 
16
22
  - Efficient single-table design for all Mastra storage needs
17
23
  - Based on ElectroDB for type-safe DynamoDB access
18
24
  - Support for AWS credentials, regions, and endpoints
19
25
  - Compatible with AWS DynamoDB Local for development
20
- - Stores Thread, Message, Trace, Eval, and Workflow data
26
+ - Stores Thread, Message, Eval, and Workflow data
21
27
  - Optimized for serverless environments
22
28
  - Configurable TTL (Time To Live) for automatic data expiration per entity type
23
29
 
24
30
  ## Installation
25
31
 
26
- ```bash
27
- npm install @mastra/dynamodb@beta
28
- # or
29
- pnpm add @mastra/dynamodb@beta
30
- # or
31
- yarn add @mastra/dynamodb@beta
32
+ ```bash npm2yarn
33
+ npm install @mastra/dynamodb@latest
32
34
  ```
33
35
 
34
36
  ## Prerequisites
@@ -260,14 +262,14 @@ This implementation uses a single-table design pattern with ElectroDB, which off
260
262
 
261
263
  [libSQL](https://docs.turso.tech/libsql) is an open-source, SQLite-compatible database that supports both local and remote deployments. It can be used to store message history, workflow snapshots, traces, and eval scores.
262
264
 
263
- For vectors like semantic recall or traditional RAG, use [libSQL Vector](https://mastra.ai/reference/v1/vectors/libsql) which covers embeddings and vector search.
265
+ For vectors like semantic recall or traditional RAG, use [libSQL Vector](https://mastra.ai/reference/vectors/libsql) which covers embeddings and vector search.
264
266
 
265
267
  ## Installation
266
268
 
267
269
  Storage providers must be installed as separate packages:
268
270
 
269
- ```bash
270
- npm install @mastra/libsql@beta
271
+ ```bash npm2yarn
272
+ npm install @mastra/libsql@latest
271
273
  ```
272
274
 
273
275
  ## Usage
@@ -330,7 +332,7 @@ In-memory storage resets when the process changes. Only suitable for development
330
332
 
331
333
  ## Initialization
332
334
 
333
- When you pass storage to the Mastra class, `init()` is called automatically to create the [core schema](https://mastra.ai/reference/v1/storage/overview#core-schema):
335
+ When you pass storage to the Mastra class, `init()` is called automatically to create the [core schema](https://mastra.ai/reference/storage/overview#core-schema):
334
336
 
335
337
  ```typescript
336
338
  import { Mastra } from "@mastra/core";
@@ -363,6 +365,12 @@ const memoryStore = await storage.getStore('memory');
363
365
  const thread = await memoryStore?.getThreadById({ threadId: "..." });
364
366
  ```
365
367
 
368
+ ## Observability
369
+
370
+ libSQL supports observability and is ideal for local development. Use the `realtime` [tracing strategy](https://mastra.ai/docs/observability/tracing/exporters/default#tracing-strategies) for immediate visibility while debugging.
371
+
372
+ For production environments with higher trace volumes, consider using [PostgreSQL](https://mastra.ai/reference/storage/postgresql) or [ClickHouse via composite storage](https://mastra.ai/reference/storage/composite#specialized-storage-for-observability).
373
+
366
374
  ---
367
375
 
368
376
  ## Reference: MongoDB Storage
@@ -373,8 +381,8 @@ The MongoDB storage implementation provides a scalable storage solution using Mo
373
381
 
374
382
  ## Installation
375
383
 
376
- ```bash
377
- npm install @mastra/mongodb@beta
384
+ ```bash npm2yarn
385
+ npm install @mastra/mongodb@latest
378
386
  ```
379
387
 
380
388
  ## Usage
@@ -612,8 +620,8 @@ The PostgreSQL storage implementation provides a production-ready storage soluti
612
620
 
613
621
  ## Installation
614
622
 
615
- ```bash
616
- npm install @mastra/pg@beta
623
+ ```bash npm2yarn
624
+ npm install @mastra/pg@latest
617
625
  ```
618
626
 
619
627
  ## Usage
@@ -635,22 +643,26 @@ You can instantiate `PostgresStore` in the following ways:
635
643
 
636
644
  ```ts
637
645
  import { PostgresStore } from "@mastra/pg";
646
+ import { Pool } from "pg";
638
647
 
639
- // Using a connection string only
648
+ // Using a connection string
640
649
  const store1 = new PostgresStore({
641
650
  id: 'pg-storage-1',
642
651
  connectionString: "postgresql://user:password@localhost:5432/mydb",
643
652
  });
644
653
 
645
- // Using a connection string with a custom schema name
654
+ // Using a connection string with pool options
646
655
  const store2 = new PostgresStore({
647
656
  id: 'pg-storage-2',
648
657
  connectionString: "postgresql://user:password@localhost:5432/mydb",
649
- schemaName: "custom_schema", // optional
658
+ schemaName: "custom_schema",
659
+ max: 30, // Max pool connections
660
+ idleTimeoutMillis: 60000, // Idle timeout
661
+ ssl: { rejectUnauthorized: false },
650
662
  });
651
663
 
652
664
  // Using individual connection parameters
653
- const store4 = new PostgresStore({
665
+ const store3 = new PostgresStore({
654
666
  id: 'pg-storage-3',
655
667
  host: "localhost",
656
668
  port: 5432,
@@ -659,14 +671,16 @@ const store4 = new PostgresStore({
659
671
  password: "password",
660
672
  });
661
673
 
662
- // Individual parameters with schemaName
663
- const store5 = new PostgresStore({
674
+ // Using a pre-configured pg.Pool (recommended for pool reuse)
675
+ const existingPool = new Pool({
676
+ connectionString: "postgresql://user:password@localhost:5432/mydb",
677
+ max: 20,
678
+ // ... your custom pool configuration
679
+ });
680
+
681
+ const store4 = new PostgresStore({
664
682
  id: 'pg-storage-4',
665
- host: "localhost",
666
- port: 5432,
667
- database: "mydb",
668
- user: "user",
669
- password: "password",
683
+ pool: existingPool,
670
684
  schemaName: "custom_schema", // optional
671
685
  });
672
686
  ```
@@ -685,6 +699,14 @@ The storage implementation handles schema creation and updates automatically. It
685
699
  - `mastra_scorers`: Stores scoring and evaluation data
686
700
  - `mastra_resources`: Stores resource working memory data
687
701
 
702
+ ### Observability
703
+
704
+ PostgreSQL supports observability and can handle low trace volumes. Throughput capacity depends on deployment factors such as hardware, schema design, indexing, and retention policies, and should be validated for your specific environment. For high-volume production environments, consider:
705
+
706
+ - Using the `insert-only` [tracing strategy](https://mastra.ai/docs/observability/tracing/exporters/default#tracing-strategies) to reduce database write operations
707
+ - Setting up table partitioning for efficient data retention
708
+ - Migrating observability to [ClickHouse via composite storage](https://mastra.ai/reference/storage/composite#specialized-storage-for-observability) if you need to scale further
709
+
688
710
  ### Initialization
689
711
 
690
712
  When you pass storage to the Mastra class, `init()` is called automatically before any storage operation:
@@ -724,19 +746,74 @@ const thread = await memoryStore?.getThreadById({ threadId: "..." });
724
746
  > **Note:**
725
747
  If `init()` is not called, tables won't be created and storage operations will fail silently or throw errors.
726
748
 
749
+ ### Using an Existing Pool
750
+
751
+ If you already have a `pg.Pool` in your application (e.g., shared with an ORM or for Row Level Security), you can pass it directly to `PostgresStore`:
752
+
753
+ ```typescript
754
+ import { Pool } from "pg";
755
+ import { PostgresStore } from "@mastra/pg";
756
+
757
+ // Your existing pool (shared across your application)
758
+ const pool = new Pool({
759
+ connectionString: process.env.DATABASE_URL,
760
+ max: 20,
761
+ });
762
+
763
+ const storage = new PostgresStore({
764
+ id: "shared-storage",
765
+ pool: pool,
766
+ });
767
+ ```
768
+
769
+ **Pool lifecycle behavior:**
770
+
771
+ - When you **provide a pool**: Mastra uses your pool but does **not** close it when `store.close()` is called. You manage the pool lifecycle.
772
+ - When Mastra **creates a pool**: Mastra owns the pool and will close it when `store.close()` is called.
773
+
727
774
  ### Direct Database and Pool Access
728
775
 
729
- `PostgresStore` exposes both the underlying database object and the pg-promise instance as public fields:
776
+ `PostgresStore` exposes the underlying database client and pool for advanced use cases:
730
777
 
731
778
  ```typescript
732
- store.db; // pg-promise database instance
733
- store.pgp; // pg-promise main instance
779
+ store.db; // DbClient - query interface with helpers (any, one, tx, etc.)
780
+ store.pool; // pg.Pool - the underlying connection pool
734
781
  ```
735
782
 
736
- This enables direct queries and custom transaction management. When using these fields:
783
+ **Using `store.db` for queries:**
784
+
785
+ ```typescript
786
+ // Execute queries with helper methods
787
+ const users = await store.db.any("SELECT * FROM users WHERE active = $1", [true]);
788
+ const user = await store.db.one("SELECT * FROM users WHERE id = $1", [userId]);
789
+ const maybeUser = await store.db.oneOrNone("SELECT * FROM users WHERE email = $1", [email]);
790
+
791
+ // Use transactions
792
+ const result = await store.db.tx(async (t) => {
793
+ await t.none("INSERT INTO logs (message) VALUES ($1)", ["Started"]);
794
+ const data = await t.any("SELECT * FROM items");
795
+ return data;
796
+ });
797
+ ```
798
+
799
+ **Using `store.pool` directly:**
800
+
801
+ ```typescript
802
+ // Get a client for manual connection management
803
+ const client = await store.pool.connect();
804
+ try {
805
+ await client.query("SET LOCAL app.user_id = $1", [userId]);
806
+ const result = await client.query("SELECT * FROM protected_table");
807
+ return result.rows;
808
+ } finally {
809
+ client.release();
810
+ }
811
+ ```
812
+
813
+ When using these fields:
737
814
 
738
815
  - You are responsible for proper connection and transaction handling.
739
- - Closing the store (`store.close()`) will destroy the associated connection pool.
816
+ - Closing the store (`store.close()`) will destroy the pool only if Mastra created it.
740
817
  - Direct access bypasses any additional logic or validation provided by PostgresStore methods.
741
818
 
742
819
  This approach is intended for advanced scenarios where low-level access is required.
@@ -1007,14 +1084,16 @@ PostgreSQL offers different index types optimized for specific scenarios:
1007
1084
 
1008
1085
  The Upstash storage implementation provides a serverless-friendly storage solution using Upstash's Redis-compatible key-value store.
1009
1086
 
1010
- > **Note:**
1087
+ > **Pricing**
1088
+ When using Mastra with Upstash, the pay-as-you-go model can result in unexpectedly high costs due to the high volume of Redis commands generated during agent conversations. We strongly recommend using a **fixed pricing plan** for predictable costs. See [Upstash pricing](https://upstash.com/pricing/redis) for details and [GitHub issue #5850](https://github.com/mastra-ai/mastra/issues/5850) for context.
1011
1089
 
1012
- **Important:** When using Mastra with Upstash, the pay-as-you-go model can result in unexpectedly high costs due to the high volume of Redis commands generated during agent conversations. We strongly recommend using a **fixed pricing plan** for predictable costs. See [Upstash pricing](https://upstash.com/pricing/redis) for details and [GitHub issue #5850](https://github.com/mastra-ai/mastra/issues/5850) for context.
1090
+ > **Observability Not Supported**
1091
+ Upstash storage **does not support the observability domain**. Traces from the `DefaultExporter` cannot be persisted to Upstash, and Mastra Studio's observability features won't work with Upstash as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite#specialized-storage-for-observability) to route observability data to a supported provider like ClickHouse or PostgreSQL.
1013
1092
 
1014
1093
  ## Installation
1015
1094
 
1016
- ```bash
1017
- npm install @mastra/upstash@beta
1095
+ ```bash npm2yarn
1096
+ npm install @mastra/upstash@latest
1018
1097
  ```
1019
1098
 
1020
1099
  ## Usage
@@ -14,8 +14,8 @@ It's part of the `@mastra/libsql` package and offers efficient vector similarity
14
14
 
15
15
  ## Installation
16
16
 
17
- ```bash
18
- npm install @mastra/libsql@beta
17
+ ```bash npm2yarn
18
+ npm install @mastra/libsql@latest
19
19
  ```
20
20
 
21
21
  ## Usage
@@ -168,8 +168,8 @@ Embeddings are numeric vectors used by memory's `semanticRecall` to retrieve rel
168
168
 
169
169
  Install `fastembed` to get started:
170
170
 
171
- ```bash
172
- npm install @mastra/fastembed@beta
171
+ ```bash npm2yarn
172
+ npm install @mastra/fastembed@latest
173
173
  ```
174
174
 
175
175
  Add the following to your agent:
@@ -222,8 +222,8 @@ The `MongoDBVector` class provides vector search using [MongoDB Atlas Vector Sea
222
222
 
223
223
  ## Installation
224
224
 
225
- ```bash
226
- npm install @mastra/mongodb@beta
225
+ ```bash npm2yarn
226
+ npm install @mastra/mongodb@latest
227
227
  ```
228
228
 
229
229
  ## Usage Example
@@ -363,8 +363,8 @@ Embeddings are numeric vectors used by memory's `semanticRecall` to retrieve rel
363
363
  This setup uses FastEmbed, a local embedding model, to generate vector embeddings.
364
364
  To use this, install `@mastra/fastembed`:
365
365
 
366
- ```bash
367
- npm install @mastra/fastembed@beta
366
+ ```bash npm2yarn
367
+ npm install @mastra/fastembed@latest
368
368
  ```
369
369
 
370
370
  Add the following to your agent:
@@ -669,8 +669,8 @@ Embeddings are numeric vectors used by memory's `semanticRecall` to retrieve rel
669
669
 
670
670
  Install `fastembed` to get started:
671
671
 
672
- ```bash
673
- npm install @mastra/fastembed@beta
672
+ ```bash npm2yarn
673
+ npm install @mastra/fastembed@latest
674
674
  ```
675
675
 
676
676
  Add the following to your agent:
@@ -896,8 +896,8 @@ Embeddings are numeric vectors used by memory's `semanticRecall` to retrieve rel
896
896
 
897
897
  Install `fastembed` to get started:
898
898
 
899
- ```bash
900
- npm install @mastra/fastembed@beta
899
+ ```bash npm2yarn
900
+ npm install @mastra/fastembed@latest
901
901
  ```
902
902
 
903
903
  Add the following to your agent:
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkSG3GRV3O_cjs = require('./chunk-SG3GRV3O.cjs');
4
- var chunkZUQPUTTO_cjs = require('./chunk-ZUQPUTTO.cjs');
3
+ var chunk23EXJLET_cjs = require('./chunk-23EXJLET.cjs');
4
+ var chunkO3CS4UGX_cjs = require('./chunk-O3CS4UGX.cjs');
5
5
  var zod = require('zod');
6
6
  var z4 = require('zod/v4');
7
7
  var v3 = require('zod/v3');
@@ -65,7 +65,7 @@ var __toESM3 = (mod, isNodeMode, target) => (target = mod != null ? __create(__g
65
65
  mod
66
66
  ));
67
67
  var require_secure_json_parse = __commonJS3({
68
- "../../../node_modules/.pnpm/secure-json-parse@2.7.0/node_modules/secure-json-parse/index.js"(exports, module) {
68
+ "../../../node_modules/.pnpm/secure-json-parse@2.7.0/node_modules/secure-json-parse/index.js"(exports$1, module) {
69
69
  var hasBuffer = typeof Buffer !== "undefined";
70
70
  var suspectProtoRx3 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
71
71
  var suspectConstructorRx3 = /"(?: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*:/;
@@ -6180,8 +6180,8 @@ function asSchema2(schema) {
6180
6180
  function withoutTrailingSlash(url) {
6181
6181
  return url == null ? void 0 : url.replace(/\/$/, "");
6182
6182
  }
6183
- var require_get_context = chunkSG3GRV3O_cjs.__commonJS({
6184
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports, module) {
6183
+ var require_get_context = chunk23EXJLET_cjs.__commonJS({
6184
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
6185
6185
  var __defProp22 = Object.defineProperty;
6186
6186
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6187
6187
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -6212,8 +6212,8 @@ var require_get_context = chunkSG3GRV3O_cjs.__commonJS({
6212
6212
  }
6213
6213
  }
6214
6214
  });
6215
- var require_get_vercel_oidc_token = chunkSG3GRV3O_cjs.__commonJS({
6216
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports, module) {
6215
+ var require_get_vercel_oidc_token = chunk23EXJLET_cjs.__commonJS({
6216
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
6217
6217
  var __defProp22 = Object.defineProperty;
6218
6218
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6219
6219
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -6238,7 +6238,7 @@ var require_get_vercel_oidc_token = chunkSG3GRV3O_cjs.__commonJS({
6238
6238
  });
6239
6239
  module.exports = __toCommonJS(get_vercel_oidc_token_exports);
6240
6240
  var import_get_context = require_get_context();
6241
- var import_token_error = chunkSG3GRV3O_cjs.require_token_error();
6241
+ var import_token_error = chunk23EXJLET_cjs.require_token_error();
6242
6242
  async function getVercelOidcToken3() {
6243
6243
  let token = "";
6244
6244
  let err;
@@ -6249,8 +6249,8 @@ var require_get_vercel_oidc_token = chunkSG3GRV3O_cjs.__commonJS({
6249
6249
  }
6250
6250
  try {
6251
6251
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
6252
- await import('./token-util-NEHG7TUY-7IL6JUVY.cjs'),
6253
- await import('./token-6GSAFR2W-YCB5SK2Z.cjs')
6252
+ await import('./token-util-NEHG7TUY-GYFEVMWP.cjs'),
6253
+ await import('./token-6GSAFR2W-TW2P7HCS.cjs')
6254
6254
  ]);
6255
6255
  if (!token || isExpired(getTokenPayload(token))) {
6256
6256
  await refreshToken();
@@ -6276,8 +6276,8 @@ ${error.message}`;
6276
6276
  }
6277
6277
  }
6278
6278
  });
6279
- var require_dist = chunkSG3GRV3O_cjs.__commonJS({
6280
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports, module) {
6279
+ var require_dist = chunk23EXJLET_cjs.__commonJS({
6280
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
6281
6281
  var __defProp22 = Object.defineProperty;
6282
6282
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
6283
6283
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -6306,8 +6306,8 @@ var require_dist = chunkSG3GRV3O_cjs.__commonJS({
6306
6306
  var import_get_context = require_get_context();
6307
6307
  }
6308
6308
  });
6309
- var import_oidc = chunkSG3GRV3O_cjs.__toESM(require_dist(), 1);
6310
- var import_oidc2 = chunkSG3GRV3O_cjs.__toESM(require_dist(), 1);
6309
+ var import_oidc = chunk23EXJLET_cjs.__toESM(require_dist(), 1);
6310
+ var import_oidc2 = chunk23EXJLET_cjs.__toESM(require_dist(), 1);
6311
6311
  var marker18 = "vercel.ai.gateway.error";
6312
6312
  var symbol18 = Symbol.for(marker18);
6313
6313
  var _a18;
@@ -11138,8 +11138,8 @@ var createJsonResponseHandler2 = (responseSchema) => async ({ response, url, req
11138
11138
  function withoutTrailingSlash2(url) {
11139
11139
  return url == null ? void 0 : url.replace(/\/$/, "");
11140
11140
  }
11141
- var require_get_context2 = chunkZUQPUTTO_cjs.__commonJS({
11142
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports, module) {
11141
+ var require_get_context2 = chunkO3CS4UGX_cjs.__commonJS({
11142
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
11143
11143
  var __defProp22 = Object.defineProperty;
11144
11144
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
11145
11145
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -11170,8 +11170,8 @@ var require_get_context2 = chunkZUQPUTTO_cjs.__commonJS({
11170
11170
  }
11171
11171
  }
11172
11172
  });
11173
- var require_get_vercel_oidc_token2 = chunkZUQPUTTO_cjs.__commonJS({
11174
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports, module) {
11173
+ var require_get_vercel_oidc_token2 = chunkO3CS4UGX_cjs.__commonJS({
11174
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
11175
11175
  var __defProp22 = Object.defineProperty;
11176
11176
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
11177
11177
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -11196,7 +11196,7 @@ var require_get_vercel_oidc_token2 = chunkZUQPUTTO_cjs.__commonJS({
11196
11196
  });
11197
11197
  module.exports = __toCommonJS(get_vercel_oidc_token_exports);
11198
11198
  var import_get_context = require_get_context2();
11199
- var import_token_error = chunkZUQPUTTO_cjs.require_token_error();
11199
+ var import_token_error = chunkO3CS4UGX_cjs.require_token_error();
11200
11200
  async function getVercelOidcToken3() {
11201
11201
  let token = "";
11202
11202
  let err;
@@ -11207,8 +11207,8 @@ var require_get_vercel_oidc_token2 = chunkZUQPUTTO_cjs.__commonJS({
11207
11207
  }
11208
11208
  try {
11209
11209
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
11210
- await import('./token-util-NEHG7TUY-HF7KBP2H.cjs'),
11211
- await import('./token-6GSAFR2W-JV3TZR4M.cjs')
11210
+ await import('./token-util-NEHG7TUY-WJZIPNNX.cjs'),
11211
+ await import('./token-6GSAFR2W-2B4WM6AQ.cjs')
11212
11212
  ]);
11213
11213
  if (!token || isExpired(getTokenPayload(token))) {
11214
11214
  await refreshToken();
@@ -11234,8 +11234,8 @@ ${error.message}`;
11234
11234
  }
11235
11235
  }
11236
11236
  });
11237
- var require_dist2 = chunkZUQPUTTO_cjs.__commonJS({
11238
- "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports, module) {
11237
+ var require_dist2 = chunkO3CS4UGX_cjs.__commonJS({
11238
+ "../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
11239
11239
  var __defProp22 = Object.defineProperty;
11240
11240
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
11241
11241
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
@@ -11264,8 +11264,8 @@ var require_dist2 = chunkZUQPUTTO_cjs.__commonJS({
11264
11264
  var import_get_context = require_get_context2();
11265
11265
  }
11266
11266
  });
11267
- var import_oidc3 = chunkZUQPUTTO_cjs.__toESM(require_dist2(), 1);
11268
- var import_oidc22 = chunkZUQPUTTO_cjs.__toESM(require_dist2(), 1);
11267
+ var import_oidc3 = chunkO3CS4UGX_cjs.__toESM(require_dist2(), 1);
11268
+ var import_oidc22 = chunkO3CS4UGX_cjs.__toESM(require_dist2(), 1);
11269
11269
  var marker20 = "vercel.ai.gateway.error";
11270
11270
  var symbol20 = Symbol.for(marker20);
11271
11271
  var _a20;
@@ -14958,7 +14958,7 @@ ${workingMemory}`;
14958
14958
  const promise = embedFn({
14959
14959
  values: chunks,
14960
14960
  maxRetries: 3,
14961
- // @ts-ignore
14961
+ // @ts-expect-error - embedder type mismatch
14962
14962
  model: this.embedder,
14963
14963
  ...this.embedderOptions || {}
14964
14964
  });
@@ -15142,6 +15142,12 @@ ${workingMemory}`;
15142
15142
  if (!workingMemoryTemplate) {
15143
15143
  return null;
15144
15144
  }
15145
+ if (config?.readOnly) {
15146
+ return this.getReadOnlyWorkingMemoryInstruction({
15147
+ template: workingMemoryTemplate,
15148
+ data: workingMemoryData
15149
+ });
15150
+ }
15145
15151
  return this.isVNextWorkingMemoryConfig(memoryConfig) ? this.__experimental_getWorkingMemoryToolInstructionVNext({
15146
15152
  template: workingMemoryTemplate,
15147
15153
  data: workingMemoryData
@@ -15229,10 +15235,32 @@ Notes:
15229
15235
  ${template.content !== this.defaultWorkingMemoryTemplate ? `- Only store information if it's in the working memory template, do not store other information unless the user asks you to remember it, as that non-template information may be irrelevant` : `- If you're unsure whether to store something, store it (eg if the user tells you information about themselves, call updateWorkingMemory immediately to update it)
15230
15236
  `}
15231
15237
  - This system is here so that you can maintain the conversation when your context window is very short. Update your working memory because you may need it to maintain the conversation without the full conversation history
15232
- - REMEMBER: the way you update your working memory is by calling the updateWorkingMemory tool with the ${template.format === "json" ? "JSON" : "Markdown"} content. The system will store it for you. The user will not see it.
15238
+ - REMEMBER: the way you update your working memory is by calling the updateWorkingMemory tool with the ${template.format === "json" ? "JSON" : "Markdown"} content. The system will store it for you. The user will not see it.
15233
15239
  - IMPORTANT: You MUST call updateWorkingMemory in every response to a prompt where you received relevant information if that information is not already stored.
15234
15240
  - IMPORTANT: Preserve the ${template.format === "json" ? "JSON" : "Markdown"} formatting structure above while updating the content.
15235
15241
  `;
15242
+ }
15243
+ /**
15244
+ * Generate read-only working memory instructions.
15245
+ * This provides the working memory context without any tool update instructions.
15246
+ * Used when memory is in readOnly mode.
15247
+ */
15248
+ getReadOnlyWorkingMemoryInstruction({ data }) {
15249
+ return `WORKING_MEMORY_SYSTEM_INSTRUCTION (READ-ONLY):
15250
+ The following is your working memory - persistent information about the user and conversation collected over previous interactions. This data is provided for context to help you maintain continuity.
15251
+
15252
+ <working_memory_data>
15253
+ ${data || "No working memory data available."}
15254
+ </working_memory_data>
15255
+
15256
+ Guidelines:
15257
+ 1. Use this information to provide personalized and contextually relevant responses
15258
+ 2. Act naturally - don't mention this system to users. This information should inform your responses without being explicitly referenced
15259
+ 3. This memory is read-only in the current session - you cannot update it
15260
+
15261
+ Notes:
15262
+ - This system is here so that you can maintain the conversation when your context window is very short
15263
+ - The user will not see the working memory data directly`;
15236
15264
  }
15237
15265
  isVNextWorkingMemoryConfig(config) {
15238
15266
  if (!config?.workingMemory) return false;
@@ -15241,7 +15269,7 @@ ${template.content !== this.defaultWorkingMemoryTemplate ? `- Only store informa
15241
15269
  }
15242
15270
  listTools(config) {
15243
15271
  const mergedConfig = this.getMergedThreadConfig(config);
15244
- if (mergedConfig.workingMemory?.enabled) {
15272
+ if (mergedConfig.workingMemory?.enabled && !mergedConfig.readOnly) {
15245
15273
  return {
15246
15274
  updateWorkingMemory: this.isVNextWorkingMemoryConfig(mergedConfig) ? (
15247
15275
  // use the new experimental tool