@mastra/upstash 0.1.0-alpha.10

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 ADDED
@@ -0,0 +1,102 @@
1
+ # @mastra/upstash
2
+
3
+ ## 0.1.0-alpha.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9d1796d]
8
+ - @mastra/core@0.2.0-alpha.100
9
+
10
+ ## 0.1.0-alpha.9
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [7d83b92]
15
+ - @mastra/core@0.2.0-alpha.99
16
+
17
+ ## 0.1.0-alpha.8
18
+
19
+ ### Patch Changes
20
+
21
+ - 70dabd9: Fix broken publish
22
+ - Updated dependencies [70dabd9]
23
+ - Updated dependencies [202d404]
24
+ - @mastra/core@0.2.0-alpha.98
25
+
26
+ ## 0.1.0-alpha.7
27
+
28
+ ### Patch Changes
29
+
30
+ - 07c069d: Update build script
31
+ - Updated dependencies [07c069d]
32
+ - Updated dependencies [7892533]
33
+ - Updated dependencies [e6d8055]
34
+ - Updated dependencies [5950de5]
35
+ - Updated dependencies [df843d3]
36
+ - Updated dependencies [a870123]
37
+ - @mastra/core@0.2.0-alpha.97
38
+
39
+ ## 0.1.0-alpha.6
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies [74b3078]
44
+ - @mastra/core@0.2.0-alpha.96
45
+
46
+ ## 0.1.0-alpha.5
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [9fb59d6]
51
+ - @mastra/core@0.2.0-alpha.95
52
+
53
+ ## 0.1.0-alpha.4
54
+
55
+ ### Minor Changes
56
+
57
+ - 8b416d9: Breaking changes
58
+
59
+ ### Patch Changes
60
+
61
+ - 9c10484: update all packages
62
+ - Updated dependencies [9c10484]
63
+ - Updated dependencies [8b416d9]
64
+ - @mastra/core@0.2.0-alpha.94
65
+
66
+ ## 0.1.0-alpha.3
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [5285356]
71
+ - @mastra/core@0.2.0-alpha.93
72
+
73
+ ## 0.1.0-alpha.2
74
+
75
+ ### Minor Changes
76
+
77
+ - c87eb4e: Combine Upstash packages into `@mastra/upstash`.
78
+
79
+ - Move and combine packages to `stores/upstash`
80
+ - Reorganize source files into `src/vector` and `src/store`
81
+ - Add deprecation notices to old packages
82
+ - Update documentation and examples
83
+ - No breaking changes in functionality
84
+
85
+ ## 0.1.0-alpha.1
86
+
87
+ ### Major Changes
88
+
89
+ - Combined @mastra/vector-upstash and @mastra/store-upstash into a single package
90
+ - Moved source code into src/vector and src/storage directories
91
+ - Updated package exports to include both vector and storage functionality
92
+ - Updated documentation to reflect combined package structure
93
+ - Added proper test skipping for vector tests when credentials are not available
94
+
95
+ ### Migration Guide
96
+
97
+ If you were previously using either @mastra/vector-upstash or @mastra/store-upstash, you'll need to:
98
+
99
+ 1. Update your package.json to use @mastra/upstash instead
100
+ 2. Update your imports:
101
+ - Change `import { UpstashVector } from '@mastra/vector-upstash'` to `import { UpstashVector } from '@mastra/upstash'`
102
+ - Change `import { UpstashStore } from '@mastra/store-upstash'` to `import { UpstashStore } from '@mastra/upstash'`
package/LICENSE ADDED
@@ -0,0 +1,44 @@
1
+ Elastic License 2.0 (ELv2)
2
+
3
+ **Acceptance**
4
+ By using the software, you agree to all of the terms and conditions below.
5
+
6
+ **Copyright License**
7
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
8
+
9
+ **Limitations**
10
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
11
+
12
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
13
+
14
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
15
+
16
+ **Patents**
17
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
18
+
19
+ **Notices**
20
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
21
+
22
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
23
+
24
+ **No Other Rights**
25
+ These terms do not imply any licenses other than those expressly granted in these terms.
26
+
27
+ **Termination**
28
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
29
+
30
+ **No Liability**
31
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
32
+
33
+ **Definitions**
34
+ The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
35
+
36
+ _you_ refers to the individual or entity agreeing to these terms.
37
+
38
+ _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
39
+
40
+ _your licenses_ are all the licenses granted to you for the software under these terms.
41
+
42
+ _use_ means anything you do with the software requiring one of your licenses.
43
+
44
+ _trademark_ means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @mastra/upstash
2
+
3
+ Upstash provider for Mastra that includes both vector store and database storage capabilities.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/upstash
9
+ ```
10
+
11
+ ## Vector Store Usage
12
+
13
+ ```typescript
14
+ import { UpstashVector } from '@mastra/upstash';
15
+
16
+ const vectorStore = new UpstashVector({
17
+ // configuration options
18
+ });
19
+ ```
20
+
21
+ ### Vector Store Configuration
22
+
23
+ The Upstash vector store requires the following configuration:
24
+
25
+ - `UPSTASH_VECTOR_REST_URL`: Your Upstash Vector REST URL
26
+ - `UPSTASH_VECTOR_TOKEN`: Your Upstash Vector REST token
27
+ - `UPSTASH_INDEX`: Name of the index to use
28
+
29
+ ## Database Storage Usage
30
+
31
+ ```typescript
32
+ import { UpstashStore } from '@mastra/upstash';
33
+
34
+ const store = new UpstashStore({
35
+ url: process.env.UPSTASH_REDIS_REST_URL,
36
+ token: process.env.UPSTASH_REDIS_REST_TOKEN,
37
+ });
38
+ ```
39
+
40
+ ### Database Storage Configuration
41
+
42
+ The Upstash store requires the following configuration:
43
+
44
+ - `UPSTASH_REDIS_REST_URL`: Your Upstash Redis REST URL
45
+ - `UPSTASH_REDIS_REST_TOKEN`: Your Upstash Redis REST token
46
+
47
+ ## Features
48
+
49
+ - Serverless vector database and key-value store
50
+ - Pay-per-use pricing
51
+ - Low latency global access
52
+ - REST API interface
53
+ - Built-in vector similarity search
54
+ - Durable storage for chat history and agent memory
55
+
56
+ ## Related Links
57
+
58
+ - [Upstash Vector Documentation](https://docs.upstash.com/vector)
59
+ - [Upstash Redis Documentation](https://docs.upstash.com/redis)
@@ -0,0 +1,88 @@
1
+ import { StorageThreadType, MessageType } from '@mastra/core/memory';
2
+ import { MastraStorage, TABLE_NAMES, StorageColumn, StorageGetMessagesArg } from '@mastra/core/storage';
3
+ import { WorkflowRunState } from '@mastra/core/workflows';
4
+ import { Filter } from '@mastra/core/filter';
5
+ import { MastraVector, QueryResult } from '@mastra/core/vector';
6
+
7
+ interface UpstashConfig {
8
+ url: string;
9
+ token: string;
10
+ }
11
+ declare class UpstashStore extends MastraStorage {
12
+ private redis;
13
+ constructor(config: UpstashConfig);
14
+ private getKey;
15
+ private ensureDate;
16
+ private serializeDate;
17
+ createTable({ tableName, schema, }: {
18
+ tableName: TABLE_NAMES;
19
+ schema: Record<string, StorageColumn>;
20
+ }): Promise<void>;
21
+ clearTable({ tableName }: {
22
+ tableName: TABLE_NAMES;
23
+ }): Promise<void>;
24
+ insert({ tableName, record }: {
25
+ tableName: TABLE_NAMES;
26
+ record: Record<string, any>;
27
+ }): Promise<void>;
28
+ load<R>({ tableName, keys }: {
29
+ tableName: TABLE_NAMES;
30
+ keys: Record<string, string>;
31
+ }): Promise<R | null>;
32
+ getThreadById({ threadId }: {
33
+ threadId: string;
34
+ }): Promise<StorageThreadType | null>;
35
+ getThreadsByResourceId({ resourceId }: {
36
+ resourceId: string;
37
+ }): Promise<StorageThreadType[]>;
38
+ saveThread({ thread }: {
39
+ thread: StorageThreadType;
40
+ }): Promise<StorageThreadType>;
41
+ updateThread({ id, title, metadata, }: {
42
+ id: string;
43
+ title: string;
44
+ metadata: Record<string, unknown>;
45
+ }): Promise<StorageThreadType>;
46
+ deleteThread({ threadId }: {
47
+ threadId: string;
48
+ }): Promise<void>;
49
+ private getMessageKey;
50
+ private getThreadMessagesKey;
51
+ saveMessages({ messages }: {
52
+ messages: MessageType[];
53
+ }): Promise<MessageType[]>;
54
+ getMessages<T = unknown>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
55
+ persistWorkflowSnapshot(params: {
56
+ namespace: string;
57
+ workflowName: string;
58
+ runId: string;
59
+ snapshot: WorkflowRunState;
60
+ }): Promise<void>;
61
+ loadWorkflowSnapshot(params: {
62
+ namespace: string;
63
+ workflowName: string;
64
+ runId: string;
65
+ }): Promise<WorkflowRunState | null>;
66
+ close(): Promise<void>;
67
+ }
68
+
69
+ declare class UpstashVector extends MastraVector {
70
+ private client;
71
+ constructor({ url, token }: {
72
+ url: string;
73
+ token: string;
74
+ });
75
+ upsert(indexName: string, vectors: number[][], metadata?: Record<string, any>[], ids?: string[]): Promise<string[]>;
76
+ transformFilter(filter?: Filter): string | undefined;
77
+ createIndex(_indexName: string, _dimension: number, _metric?: 'cosine' | 'euclidean' | 'dotproduct'): Promise<void>;
78
+ query(indexName: string, queryVector: number[], topK?: number, filter?: Filter, includeVector?: boolean): Promise<QueryResult[]>;
79
+ listIndexes(): Promise<string[]>;
80
+ describeIndex(indexName: string): Promise<{
81
+ dimension: number;
82
+ count: number;
83
+ metric: "cosine" | "euclidean" | "dotproduct";
84
+ }>;
85
+ deleteIndex(indexName: string): Promise<void>;
86
+ }
87
+
88
+ export { type UpstashConfig, UpstashStore, UpstashVector };