@mastra/upstash 0.0.0-workflow-deno-20250616132510 → 0.0.0-working-memory-per-user-20250620161509

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,28 @@
1
1
  # @mastra/upstash
2
2
 
3
- ## 0.0.0-workflow-deno-20250616132510
3
+ ## 0.0.0-working-memory-per-user-20250620161509
4
+
5
+ ### Patch Changes
6
+
7
+ - d8f2d19: Add updateMessages API to storage classes (only support for PG and LibSQL for now) and to memory class. Additionally allow for metadata to be saved in the content field of a message.
8
+ - 2097952: [MASTRA-4021] Fix PG getMessages and update messageLimit for all storage adapters
9
+ - Updated dependencies [d8f2d19]
10
+ - Updated dependencies [9d52b17]
11
+ - Updated dependencies [2097952]
12
+ - Updated dependencies [8ba1b51]
13
+ - @mastra/core@0.0.0-working-memory-per-user-20250620161509
14
+
15
+ ## 0.11.1-alpha.0
16
+
17
+ ### Patch Changes
18
+
19
+ - d8f2d19: Add updateMessages API to storage classes (only support for PG and LibSQL for now) and to memory class. Additionally allow for metadata to be saved in the content field of a message.
20
+ - Updated dependencies [d8f2d19]
21
+ - Updated dependencies [9d52b17]
22
+ - Updated dependencies [8ba1b51]
23
+ - @mastra/core@0.10.7-alpha.0
24
+
25
+ ## 0.11.0
4
26
 
5
27
  ### Minor Changes
6
28
 
@@ -15,15 +37,51 @@
15
37
 
16
38
  ### Patch Changes
17
39
 
40
+ - 2fda031: Clarify upstash argument concepts.
41
+ - e8fdbdd: Fix dynamic require of crypto using upstash.
42
+ caused by a bad import was used in the monorepo
43
+
44
+ Fixes #4801
45
+
18
46
  - Updated dependencies [63f6b7d]
47
+ - Updated dependencies [12a95fc]
48
+ - Updated dependencies [4b0f8a6]
49
+ - Updated dependencies [51264a5]
50
+ - Updated dependencies [8e6f677]
51
+ - Updated dependencies [d70c420]
19
52
  - Updated dependencies [ee9af57]
20
53
  - Updated dependencies [36f1c36]
54
+ - Updated dependencies [2a16996]
21
55
  - Updated dependencies [10d352e]
22
- - Updated dependencies [b0c32de]
56
+ - Updated dependencies [9589624]
23
57
  - Updated dependencies [53d3c37]
58
+ - Updated dependencies [751c894]
59
+ - Updated dependencies [577ce3a]
60
+ - Updated dependencies [9260b3a]
61
+ - @mastra/core@0.10.6
62
+
63
+ ## 0.11.0-alpha.2
64
+
65
+ ### Patch Changes
66
+
67
+ - e8fdbdd: Fix dynamic require of crypto using upstash.
68
+ caused by a bad import was used in the monorepo
69
+
70
+ Fixes #4801
71
+
72
+ - Updated dependencies [9589624]
73
+ - @mastra/core@0.10.6-alpha.4
74
+
75
+ ## 0.11.0-alpha.1
76
+
77
+ ### Patch Changes
78
+
79
+ - 2fda031: Clarify upstash argument concepts.
80
+ - Updated dependencies [ee9af57]
81
+ - Updated dependencies [751c894]
24
82
  - Updated dependencies [577ce3a]
25
83
  - Updated dependencies [9260b3a]
26
- - @mastra/core@0.0.0-workflow-deno-20250616132510
84
+ - @mastra/core@0.10.6-alpha.1
27
85
 
28
86
  ## 0.11.0-alpha.0
29
87
 
package/README.md CHANGED
@@ -13,6 +13,7 @@ npm install @mastra/upstash
13
13
  ```typescript
14
14
  import { UpstashVector } from '@mastra/upstash';
15
15
 
16
+ // In upstash they refer to the store as an index
16
17
  const vectorStore = new UpstashVector({
17
18
  url: process.env.UPSTASH_VECTOR_REST_URL,
18
19
  token: process.env.UPSTASH_VECTOR_TOKEN
@@ -27,6 +28,9 @@ const ids = await vectorStore.upsert({
27
28
  metadata
28
29
  });
29
30
 
31
+ // There is no store.createIndex call here, Upstash creates indexes (known as namespaces in Upstash) automatically
32
+ // when you upsert if that namespace does not exist yet.
33
+
30
34
  // Query vectors
31
35
  const results = await vectorStore.query({
32
36
  indexName: 'my-namespace',
@@ -5,8 +5,9 @@ import type { DeleteVectorParams } from '@mastra/core/vector';
5
5
  import type { DescribeIndexParams } from '@mastra/core/vector';
6
6
  import type { EvalRow } from '@mastra/core/storage';
7
7
  import type { IndexStats } from '@mastra/core/vector';
8
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
8
9
  import type { MastraMessageV1 } from '@mastra/core/memory';
9
- import type { MastraMessageV2 } from '@mastra/core/memory';
10
+ import type { MastraMessageV2 } from '@mastra/core/agent';
10
11
  import { MastraStorage } from '@mastra/core/storage';
11
12
  import { MastraVector } from '@mastra/core/vector';
12
13
  import type { OperatorSupport } from '@mastra/core/vector/filter';
@@ -17,6 +18,7 @@ import type { QueryVectorParams } from '@mastra/core/vector';
17
18
  import type { StorageColumn } from '@mastra/core/storage';
18
19
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
19
20
  import type { StorageGetTracesArg } from '@mastra/core/storage';
21
+ import type { StorageResourceType } from '@mastra/core/storage';
20
22
  import type { StorageThreadType } from '@mastra/core/memory';
21
23
  import type { TABLE_NAMES } from '@mastra/core/storage';
22
24
  import type { UpdateVectorParams } from '@mastra/core/vector';
@@ -60,6 +62,7 @@ declare class UpstashStore extends MastraStorage {
60
62
  constructor(config: UpstashConfig);
61
63
  get supports(): {
62
64
  selectByIncludeResourceScope: boolean;
65
+ resourceWorkingMemory: boolean;
63
66
  };
64
67
  private transformEvalRecord;
65
68
  private parseJSON;
@@ -211,32 +214,87 @@ declare class UpstashStore extends MastraStorage {
211
214
  workflowName?: string;
212
215
  }): Promise<WorkflowRun | null>;
213
216
  close(): Promise<void>;
217
+ updateMessages(_args: {
218
+ messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
219
+ id: string;
220
+ content?: {
221
+ metadata?: MastraMessageContentV2['metadata'];
222
+ content?: MastraMessageContentV2['content'];
223
+ };
224
+ }[];
225
+ }): Promise<MastraMessageV2[]>;
226
+ getResourceById({ resourceId }: {
227
+ resourceId: string;
228
+ }): Promise<StorageResourceType | null>;
229
+ saveResource({ resource }: {
230
+ resource: StorageResourceType;
231
+ }): Promise<StorageResourceType>;
232
+ updateResource({ resourceId, workingMemory, metadata, }: {
233
+ resourceId: string;
234
+ workingMemory?: string;
235
+ metadata?: Record<string, unknown>;
236
+ }): Promise<StorageResourceType>;
214
237
  }
215
238
  export { UpstashStore }
216
239
  export { UpstashStore as UpstashStore_alias_1 }
217
240
 
218
241
  declare class UpstashVector extends MastraVector {
219
242
  private client;
243
+ /**
244
+ * Creates a new UpstashVector instance.
245
+ * @param {object} params - The parameters for the UpstashVector.
246
+ * @param {string} params.url - The URL of the Upstash vector index.
247
+ * @param {string} params.token - The token for the Upstash vector index.
248
+ */
220
249
  constructor({ url, token }: {
221
250
  url: string;
222
251
  token: string;
223
252
  });
224
- upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
253
+ /**
254
+ * Upserts vectors into the index.
255
+ * @param {UpsertVectorParams} params - The parameters for the upsert operation.
256
+ * @returns {Promise<string[]>} A promise that resolves to the IDs of the upserted vectors.
257
+ */
258
+ upsert({ indexName: namespace, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
259
+ /**
260
+ * Transforms a Mastra vector filter into an Upstash-compatible filter string.
261
+ * @param {VectorFilter} [filter] - The filter to transform.
262
+ * @returns {string | undefined} The transformed filter string, or undefined if no filter is provided.
263
+ */
225
264
  transformFilter(filter?: VectorFilter): string | undefined;
265
+ /**
266
+ * Creates a new index. For Upstash, this is a no-op as indexes (known as namespaces in Upstash) are created on-the-fly.
267
+ * @param {CreateIndexParams} _params - The parameters for creating the index (ignored).
268
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
269
+ */
226
270
  createIndex(_params: CreateIndexParams): Promise<void>;
227
- query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
271
+ /**
272
+ * Queries the vector index.
273
+ * @param {QueryVectorParams} params - The parameters for the query operation. indexName is the namespace in Upstash.
274
+ * @returns {Promise<QueryResult[]>} A promise that resolves to the query results.
275
+ */
276
+ query({ indexName: namespace, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
277
+ /**
278
+ * Lists all namespaces in the Upstash vector index, which correspond to indexes.
279
+ * @returns {Promise<string[]>} A promise that resolves to a list of index names.
280
+ */
228
281
  listIndexes(): Promise<string[]>;
229
282
  /**
230
283
  * Retrieves statistics about a vector index.
231
284
  *
232
- * @param {string} indexName - The name of the index to describe
285
+ * @param {string} indexName - The name of the namespace to describe
233
286
  * @returns A promise that resolves to the index statistics including dimension, count and metric
234
287
  */
235
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
236
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
288
+ describeIndex({ indexName: namespace }: DescribeIndexParams): Promise<IndexStats>;
289
+ /**
290
+ * Deletes an index (namespace).
291
+ * @param {DeleteIndexParams} params - The parameters for the delete operation.
292
+ * @returns {Promise<void>} A promise that resolves when the deletion is complete.
293
+ */
294
+ deleteIndex({ indexName: namespace }: DeleteIndexParams): Promise<void>;
237
295
  /**
238
296
  * Updates a vector by its ID with the provided vector and/or metadata.
239
- * @param indexName - The name of the index containing the vector.
297
+ * @param indexName - The name of the namespace containing the vector.
240
298
  * @param id - The ID of the vector to update.
241
299
  * @param update - An object containing the vector and/or metadata to update.
242
300
  * @param update.vector - An optional array of numbers representing the new vector.
@@ -244,15 +302,15 @@ declare class UpstashVector extends MastraVector {
244
302
  * @returns A promise that resolves when the update is complete.
245
303
  * @throws Will throw an error if no updates are provided or if the update operation fails.
246
304
  */
247
- updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
305
+ updateVector({ indexName: namespace, id, update }: UpdateVectorParams): Promise<void>;
248
306
  /**
249
307
  * Deletes a vector by its ID.
250
- * @param indexName - The name of the index containing the vector.
308
+ * @param indexName - The name of the namespace containing the vector.
251
309
  * @param id - The ID of the vector to delete.
252
310
  * @returns A promise that resolves when the deletion is complete.
253
311
  * @throws Will throw an error if the deletion operation fails.
254
312
  */
255
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
313
+ deleteVector({ indexName: namespace, id }: DeleteVectorParams): Promise<void>;
256
314
  }
257
315
  export { UpstashVector }
258
316
  export { UpstashVector as UpstashVector_alias_1 }
@@ -5,8 +5,9 @@ import type { DeleteVectorParams } from '@mastra/core/vector';
5
5
  import type { DescribeIndexParams } from '@mastra/core/vector';
6
6
  import type { EvalRow } from '@mastra/core/storage';
7
7
  import type { IndexStats } from '@mastra/core/vector';
8
+ import type { MastraMessageContentV2 } from '@mastra/core/agent';
8
9
  import type { MastraMessageV1 } from '@mastra/core/memory';
9
- import type { MastraMessageV2 } from '@mastra/core/memory';
10
+ import type { MastraMessageV2 } from '@mastra/core/agent';
10
11
  import { MastraStorage } from '@mastra/core/storage';
11
12
  import { MastraVector } from '@mastra/core/vector';
12
13
  import type { OperatorSupport } from '@mastra/core/vector/filter';
@@ -17,6 +18,7 @@ import type { QueryVectorParams } from '@mastra/core/vector';
17
18
  import type { StorageColumn } from '@mastra/core/storage';
18
19
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
19
20
  import type { StorageGetTracesArg } from '@mastra/core/storage';
21
+ import type { StorageResourceType } from '@mastra/core/storage';
20
22
  import type { StorageThreadType } from '@mastra/core/memory';
21
23
  import type { TABLE_NAMES } from '@mastra/core/storage';
22
24
  import type { UpdateVectorParams } from '@mastra/core/vector';
@@ -60,6 +62,7 @@ declare class UpstashStore extends MastraStorage {
60
62
  constructor(config: UpstashConfig);
61
63
  get supports(): {
62
64
  selectByIncludeResourceScope: boolean;
65
+ resourceWorkingMemory: boolean;
63
66
  };
64
67
  private transformEvalRecord;
65
68
  private parseJSON;
@@ -211,32 +214,87 @@ declare class UpstashStore extends MastraStorage {
211
214
  workflowName?: string;
212
215
  }): Promise<WorkflowRun | null>;
213
216
  close(): Promise<void>;
217
+ updateMessages(_args: {
218
+ messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
219
+ id: string;
220
+ content?: {
221
+ metadata?: MastraMessageContentV2['metadata'];
222
+ content?: MastraMessageContentV2['content'];
223
+ };
224
+ }[];
225
+ }): Promise<MastraMessageV2[]>;
226
+ getResourceById({ resourceId }: {
227
+ resourceId: string;
228
+ }): Promise<StorageResourceType | null>;
229
+ saveResource({ resource }: {
230
+ resource: StorageResourceType;
231
+ }): Promise<StorageResourceType>;
232
+ updateResource({ resourceId, workingMemory, metadata, }: {
233
+ resourceId: string;
234
+ workingMemory?: string;
235
+ metadata?: Record<string, unknown>;
236
+ }): Promise<StorageResourceType>;
214
237
  }
215
238
  export { UpstashStore }
216
239
  export { UpstashStore as UpstashStore_alias_1 }
217
240
 
218
241
  declare class UpstashVector extends MastraVector {
219
242
  private client;
243
+ /**
244
+ * Creates a new UpstashVector instance.
245
+ * @param {object} params - The parameters for the UpstashVector.
246
+ * @param {string} params.url - The URL of the Upstash vector index.
247
+ * @param {string} params.token - The token for the Upstash vector index.
248
+ */
220
249
  constructor({ url, token }: {
221
250
  url: string;
222
251
  token: string;
223
252
  });
224
- upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
253
+ /**
254
+ * Upserts vectors into the index.
255
+ * @param {UpsertVectorParams} params - The parameters for the upsert operation.
256
+ * @returns {Promise<string[]>} A promise that resolves to the IDs of the upserted vectors.
257
+ */
258
+ upsert({ indexName: namespace, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
259
+ /**
260
+ * Transforms a Mastra vector filter into an Upstash-compatible filter string.
261
+ * @param {VectorFilter} [filter] - The filter to transform.
262
+ * @returns {string | undefined} The transformed filter string, or undefined if no filter is provided.
263
+ */
225
264
  transformFilter(filter?: VectorFilter): string | undefined;
265
+ /**
266
+ * Creates a new index. For Upstash, this is a no-op as indexes (known as namespaces in Upstash) are created on-the-fly.
267
+ * @param {CreateIndexParams} _params - The parameters for creating the index (ignored).
268
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
269
+ */
226
270
  createIndex(_params: CreateIndexParams): Promise<void>;
227
- query({ indexName, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
271
+ /**
272
+ * Queries the vector index.
273
+ * @param {QueryVectorParams} params - The parameters for the query operation. indexName is the namespace in Upstash.
274
+ * @returns {Promise<QueryResult[]>} A promise that resolves to the query results.
275
+ */
276
+ query({ indexName: namespace, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
277
+ /**
278
+ * Lists all namespaces in the Upstash vector index, which correspond to indexes.
279
+ * @returns {Promise<string[]>} A promise that resolves to a list of index names.
280
+ */
228
281
  listIndexes(): Promise<string[]>;
229
282
  /**
230
283
  * Retrieves statistics about a vector index.
231
284
  *
232
- * @param {string} indexName - The name of the index to describe
285
+ * @param {string} indexName - The name of the namespace to describe
233
286
  * @returns A promise that resolves to the index statistics including dimension, count and metric
234
287
  */
235
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
236
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
288
+ describeIndex({ indexName: namespace }: DescribeIndexParams): Promise<IndexStats>;
289
+ /**
290
+ * Deletes an index (namespace).
291
+ * @param {DeleteIndexParams} params - The parameters for the delete operation.
292
+ * @returns {Promise<void>} A promise that resolves when the deletion is complete.
293
+ */
294
+ deleteIndex({ indexName: namespace }: DeleteIndexParams): Promise<void>;
237
295
  /**
238
296
  * Updates a vector by its ID with the provided vector and/or metadata.
239
- * @param indexName - The name of the index containing the vector.
297
+ * @param indexName - The name of the namespace containing the vector.
240
298
  * @param id - The ID of the vector to update.
241
299
  * @param update - An object containing the vector and/or metadata to update.
242
300
  * @param update.vector - An optional array of numbers representing the new vector.
@@ -244,15 +302,15 @@ declare class UpstashVector extends MastraVector {
244
302
  * @returns A promise that resolves when the update is complete.
245
303
  * @throws Will throw an error if no updates are provided or if the update operation fails.
246
304
  */
247
- updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
305
+ updateVector({ indexName: namespace, id, update }: UpdateVectorParams): Promise<void>;
248
306
  /**
249
307
  * Deletes a vector by its ID.
250
- * @param indexName - The name of the index containing the vector.
308
+ * @param indexName - The name of the namespace containing the vector.
251
309
  * @param id - The ID of the vector to delete.
252
310
  * @returns A promise that resolves when the deletion is complete.
253
311
  * @throws Will throw an error if the deletion operation fails.
254
312
  */
255
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
313
+ deleteVector({ indexName: namespace, id }: DeleteVectorParams): Promise<void>;
256
314
  }
257
315
  export { UpstashVector }
258
316
  export { UpstashVector as UpstashVector_alias_1 }