@mastra/upstash 0.13.0 → 0.14.0-alpha.0

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 (40) hide show
  1. package/.turbo/turbo-build.log +2 -21
  2. package/CHANGELOG.md +14 -0
  3. package/dist/index.cjs +5 -1
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.ts +4 -4
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +5 -1
  8. package/dist/index.js.map +1 -0
  9. package/dist/storage/domains/legacy-evals/index.d.ts +28 -0
  10. package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
  11. package/dist/storage/domains/memory/index.d.ts +86 -0
  12. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  13. package/dist/storage/domains/operations/index.d.ts +40 -0
  14. package/dist/storage/domains/operations/index.d.ts.map +1 -0
  15. package/dist/storage/domains/scores/index.d.ts +65 -0
  16. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  17. package/dist/storage/domains/traces/index.d.ts +28 -0
  18. package/dist/storage/domains/traces/index.d.ts.map +1 -0
  19. package/dist/storage/domains/utils.d.ts +12 -0
  20. package/dist/storage/domains/utils.d.ts.map +1 -0
  21. package/dist/storage/domains/workflows/index.d.ts +36 -0
  22. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  23. package/dist/storage/index.d.ts +208 -0
  24. package/dist/storage/index.d.ts.map +1 -0
  25. package/dist/vector/filter.d.ts +21 -0
  26. package/dist/vector/filter.d.ts.map +1 -0
  27. package/dist/vector/index.d.ts +79 -0
  28. package/dist/vector/index.d.ts.map +1 -0
  29. package/dist/vector/prompt.d.ts +6 -0
  30. package/dist/vector/prompt.d.ts.map +1 -0
  31. package/dist/vector/types.d.ts +23 -0
  32. package/dist/vector/types.d.ts.map +1 -0
  33. package/package.json +6 -6
  34. package/src/storage/domains/scores/index.ts +3 -1
  35. package/tsconfig.build.json +9 -0
  36. package/tsconfig.json +1 -1
  37. package/tsup.config.ts +22 -0
  38. package/dist/_tsup-dts-rollup.d.cts +0 -655
  39. package/dist/_tsup-dts-rollup.d.ts +0 -655
  40. package/dist/index.d.cts +0 -4
@@ -0,0 +1,65 @@
1
+ import type { ScoreRowData } from '@mastra/core/scores';
2
+ import { ScoresStorage } from '@mastra/core/storage';
3
+ import type { Redis } from '@upstash/redis';
4
+ import type { StoreOperationsUpstash } from '../operations';
5
+ export declare class ScoresUpstash extends ScoresStorage {
6
+ private client;
7
+ private operations;
8
+ constructor({ client, operations }: {
9
+ client: Redis;
10
+ operations: StoreOperationsUpstash;
11
+ });
12
+ getScoreById({ id }: {
13
+ id: string;
14
+ }): Promise<ScoreRowData | null>;
15
+ getScoresByScorerId({ scorerId, pagination, }: {
16
+ scorerId: string;
17
+ pagination?: {
18
+ page: number;
19
+ perPage: number;
20
+ };
21
+ }): Promise<{
22
+ scores: ScoreRowData[];
23
+ pagination: {
24
+ total: number;
25
+ page: number;
26
+ perPage: number;
27
+ hasMore: boolean;
28
+ };
29
+ }>;
30
+ saveScore(score: ScoreRowData): Promise<{
31
+ score: ScoreRowData;
32
+ }>;
33
+ getScoresByRunId({ runId, pagination, }: {
34
+ runId: string;
35
+ pagination?: {
36
+ page: number;
37
+ perPage: number;
38
+ };
39
+ }): Promise<{
40
+ scores: ScoreRowData[];
41
+ pagination: {
42
+ total: number;
43
+ page: number;
44
+ perPage: number;
45
+ hasMore: boolean;
46
+ };
47
+ }>;
48
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
49
+ entityId: string;
50
+ entityType?: string;
51
+ pagination?: {
52
+ page: number;
53
+ perPage: number;
54
+ };
55
+ }): Promise<{
56
+ scores: ScoreRowData[];
57
+ pagination: {
58
+ total: number;
59
+ page: number;
60
+ perPage: number;
61
+ hasMore: boolean;
62
+ };
63
+ }>;
64
+ }
65
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains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OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;KAChD,GAAG,OAAO,CAAC;QACV,MAAM,EAAE,YAAY,EAAE,CAAC;QACvB,UAAU,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,OAAO,CAAA;SAAE,CAAC;KAChF,CAAC;IAiCI,mBAAmB,CAAC,EACxB,QAAQ,EACR,UAAU,EACV,UAAqC,GACtC,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC;KAChD,GAAG,OAAO,CAAC;QACV,MAAM,EAAE,YAAY,EAAE,CAAC;QACvB,UAAU,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,OAAO,CAAA;SAAE,CAAC;KAChF,CAAC;CAqCH"}
@@ -0,0 +1,28 @@
1
+ import type { StorageGetTracesArg, PaginationInfo, PaginationArgs } from '@mastra/core/storage';
2
+ import { TracesStorage } from '@mastra/core/storage';
3
+ import type { Redis } from '@upstash/redis';
4
+ import type { StoreOperationsUpstash } from '../operations';
5
+ export declare class TracesUpstash extends TracesStorage {
6
+ private client;
7
+ private operations;
8
+ constructor({ client, operations }: {
9
+ client: Redis;
10
+ operations: StoreOperationsUpstash;
11
+ });
12
+ /**
13
+ * @deprecated use getTracesPaginated instead
14
+ */
15
+ getTraces(args: StorageGetTracesArg): Promise<any[]>;
16
+ getTracesPaginated(args: {
17
+ name?: string;
18
+ scope?: string;
19
+ attributes?: Record<string, string>;
20
+ filters?: Record<string, any>;
21
+ } & PaginationArgs): Promise<PaginationInfo & {
22
+ traces: any[];
23
+ }>;
24
+ batchTraceInsert(args: {
25
+ records: Record<string, any>[];
26
+ }): Promise<void>;
27
+ }
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/traces/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,aAAa,EAAgB,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAG5D,qBAAa,aAAc,SAAQ,aAAa;IAC9C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,UAAU,CAAyB;gBAE/B,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,sBAAsB,CAAA;KAAE;IAMzF;;OAEG;IACU,SAAS,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAsBpD,kBAAkB,CAC7B,IAAI,EAAE;QACJ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC/B,GAAG,cAAc,GACjB,OAAO,CAAC,cAAc,GAAG;QAAE,MAAM,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC;IAoHxC,gBAAgB,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAMhF"}
@@ -0,0 +1,12 @@
1
+ import type { TABLE_NAMES } from '@mastra/core/storage';
2
+ export declare function ensureDate(value: any): Date | null;
3
+ export declare function parseJSON(value: any): any;
4
+ export declare function getKey(tableName: TABLE_NAMES, keys: Record<string, any>): string;
5
+ export declare function processRecord(tableName: TABLE_NAMES, record: Record<string, any>): {
6
+ key: string;
7
+ processedRecord: {
8
+ createdAt: string | undefined;
9
+ updatedAt: string | undefined;
10
+ };
11
+ };
12
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/storage/domains/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,wBAAgB,UAAU,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,CAMlD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CASzC;AAED,wBAAgB,MAAM,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAKhF;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;;;;;EA2BhF"}
@@ -0,0 +1,36 @@
1
+ import type { WorkflowRun, WorkflowRuns, WorkflowRunState } from '@mastra/core';
2
+ import { WorkflowsStorage } from '@mastra/core/storage';
3
+ import type { Redis } from '@upstash/redis';
4
+ import type { StoreOperationsUpstash } from '../operations';
5
+ export declare class WorkflowsUpstash extends WorkflowsStorage {
6
+ private client;
7
+ private operations;
8
+ constructor({ client, operations }: {
9
+ client: Redis;
10
+ operations: StoreOperationsUpstash;
11
+ });
12
+ persistWorkflowSnapshot(params: {
13
+ namespace: string;
14
+ workflowName: string;
15
+ runId: string;
16
+ snapshot: WorkflowRunState;
17
+ }): Promise<void>;
18
+ loadWorkflowSnapshot(params: {
19
+ namespace: string;
20
+ workflowName: string;
21
+ runId: string;
22
+ }): Promise<WorkflowRunState | null>;
23
+ getWorkflowRunById({ runId, workflowName, }: {
24
+ runId: string;
25
+ workflowName?: string;
26
+ }): Promise<WorkflowRun | null>;
27
+ getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }: {
28
+ workflowName?: string;
29
+ fromDate?: Date;
30
+ toDate?: Date;
31
+ limit?: number;
32
+ offset?: number;
33
+ resourceId?: string;
34
+ }): Promise<WorkflowRuns>;
35
+ }
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,EAA2B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAuB5D,qBAAa,gBAAiB,SAAQ,gBAAgB;IACpD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,UAAU,CAAyB;gBAE/B,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,sBAAsB,CAAA;KAAE;IAMnF,uBAAuB,CAAC,MAAM,EAAE;QACpC,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BX,oBAAoB,CAAC,MAAM,EAAE;QACjC,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAiC9B,kBAAkB,CAAC,EACvB,KAAK,EACL,YAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAsCzB,eAAe,CAAC,EACpB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,UAAU,GACX,EAAE;QACD,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,MAAM,CAAC,EAAE,IAAI,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,YAAY,CAAC;CA0E1B"}
@@ -0,0 +1,208 @@
1
+ import type { MastraMessageContentV2, MastraMessageV2 } from '@mastra/core/agent';
2
+ import type { StorageThreadType, MastraMessageV1 } from '@mastra/core/memory';
3
+ import type { ScoreRowData } from '@mastra/core/scores';
4
+ import { MastraStorage } from '@mastra/core/storage';
5
+ import type { TABLE_NAMES, StorageColumn, StorageGetMessagesArg, StorageResourceType, EvalRow, WorkflowRuns, WorkflowRun, PaginationInfo, PaginationArgs, StorageGetTracesArg, StoragePagination, StorageDomains } from '@mastra/core/storage';
6
+ import type { WorkflowRunState } from '@mastra/core/workflows';
7
+ export interface UpstashConfig {
8
+ url: string;
9
+ token: string;
10
+ }
11
+ export declare class UpstashStore extends MastraStorage {
12
+ private redis;
13
+ stores: StorageDomains;
14
+ constructor(config: UpstashConfig);
15
+ get supports(): {
16
+ selectByIncludeResourceScope: boolean;
17
+ resourceWorkingMemory: boolean;
18
+ hasColumn: boolean;
19
+ createTable: boolean;
20
+ deleteMessages: boolean;
21
+ };
22
+ /**
23
+ * @deprecated Use getEvals instead
24
+ */
25
+ getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
26
+ /**
27
+ * Get all evaluations with pagination and total count
28
+ * @param options Pagination and filtering options
29
+ * @returns Object with evals array and total count
30
+ */
31
+ getEvals(options: {
32
+ agentName?: string;
33
+ type?: 'test' | 'live';
34
+ } & PaginationArgs): Promise<PaginationInfo & {
35
+ evals: EvalRow[];
36
+ }>;
37
+ /**
38
+ * @deprecated use getTracesPaginated instead
39
+ */
40
+ getTraces(args: StorageGetTracesArg): Promise<any[]>;
41
+ getTracesPaginated(args: {
42
+ name?: string;
43
+ scope?: string;
44
+ attributes?: Record<string, string>;
45
+ filters?: Record<string, any>;
46
+ } & PaginationArgs): Promise<PaginationInfo & {
47
+ traces: any[];
48
+ }>;
49
+ batchTraceInsert(args: {
50
+ records: Record<string, any>[];
51
+ }): Promise<void>;
52
+ createTable({ tableName, schema, }: {
53
+ tableName: TABLE_NAMES;
54
+ schema: Record<string, StorageColumn>;
55
+ }): Promise<void>;
56
+ /**
57
+ * No-op: This backend is schemaless and does not require schema changes.
58
+ * @param tableName Name of the table
59
+ * @param schema Schema of the table
60
+ * @param ifNotExists Array of column names to add if they don't exist
61
+ */
62
+ alterTable(args: {
63
+ tableName: TABLE_NAMES;
64
+ schema: Record<string, StorageColumn>;
65
+ ifNotExists: string[];
66
+ }): Promise<void>;
67
+ clearTable({ tableName }: {
68
+ tableName: TABLE_NAMES;
69
+ }): Promise<void>;
70
+ dropTable({ tableName }: {
71
+ tableName: TABLE_NAMES;
72
+ }): Promise<void>;
73
+ insert({ tableName, record }: {
74
+ tableName: TABLE_NAMES;
75
+ record: Record<string, any>;
76
+ }): Promise<void>;
77
+ batchInsert(input: {
78
+ tableName: TABLE_NAMES;
79
+ records: Record<string, any>[];
80
+ }): Promise<void>;
81
+ load<R>({ tableName, keys }: {
82
+ tableName: TABLE_NAMES;
83
+ keys: Record<string, string>;
84
+ }): Promise<R | null>;
85
+ getThreadById({ threadId }: {
86
+ threadId: string;
87
+ }): Promise<StorageThreadType | null>;
88
+ /**
89
+ * @deprecated use getThreadsByResourceIdPaginated instead
90
+ */
91
+ getThreadsByResourceId({ resourceId }: {
92
+ resourceId: string;
93
+ }): Promise<StorageThreadType[]>;
94
+ getThreadsByResourceIdPaginated(args: {
95
+ resourceId: string;
96
+ page: number;
97
+ perPage: number;
98
+ }): Promise<PaginationInfo & {
99
+ threads: StorageThreadType[];
100
+ }>;
101
+ saveThread({ thread }: {
102
+ thread: StorageThreadType;
103
+ }): Promise<StorageThreadType>;
104
+ updateThread({ id, title, metadata, }: {
105
+ id: string;
106
+ title: string;
107
+ metadata: Record<string, unknown>;
108
+ }): Promise<StorageThreadType>;
109
+ deleteThread({ threadId }: {
110
+ threadId: string;
111
+ }): Promise<void>;
112
+ saveMessages(args: {
113
+ messages: MastraMessageV1[];
114
+ format?: undefined | 'v1';
115
+ }): Promise<MastraMessageV1[]>;
116
+ saveMessages(args: {
117
+ messages: MastraMessageV2[];
118
+ format: 'v2';
119
+ }): Promise<MastraMessageV2[]>;
120
+ /**
121
+ * @deprecated use getMessagesPaginated instead
122
+ */
123
+ getMessages(args: StorageGetMessagesArg & {
124
+ format?: 'v1';
125
+ }): Promise<MastraMessageV1[]>;
126
+ getMessages(args: StorageGetMessagesArg & {
127
+ format: 'v2';
128
+ }): Promise<MastraMessageV2[]>;
129
+ getMessagesPaginated(args: StorageGetMessagesArg & {
130
+ format?: 'v1' | 'v2';
131
+ }): Promise<PaginationInfo & {
132
+ messages: MastraMessageV1[] | MastraMessageV2[];
133
+ }>;
134
+ persistWorkflowSnapshot(params: {
135
+ namespace: string;
136
+ workflowName: string;
137
+ runId: string;
138
+ snapshot: WorkflowRunState;
139
+ }): Promise<void>;
140
+ loadWorkflowSnapshot(params: {
141
+ namespace: string;
142
+ workflowName: string;
143
+ runId: string;
144
+ }): Promise<WorkflowRunState | null>;
145
+ getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
146
+ workflowName?: string;
147
+ fromDate?: Date;
148
+ toDate?: Date;
149
+ limit?: number;
150
+ offset?: number;
151
+ resourceId?: string;
152
+ }): Promise<WorkflowRuns>;
153
+ getWorkflowRunById({ runId, workflowName, }: {
154
+ runId: string;
155
+ workflowName?: string;
156
+ }): Promise<WorkflowRun | null>;
157
+ close(): Promise<void>;
158
+ updateMessages(args: {
159
+ messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
160
+ id: string;
161
+ content?: {
162
+ metadata?: MastraMessageContentV2['metadata'];
163
+ content?: MastraMessageContentV2['content'];
164
+ };
165
+ })[];
166
+ }): Promise<MastraMessageV2[]>;
167
+ deleteMessages(messageIds: string[]): Promise<void>;
168
+ getResourceById({ resourceId }: {
169
+ resourceId: string;
170
+ }): Promise<StorageResourceType | null>;
171
+ saveResource({ resource }: {
172
+ resource: StorageResourceType;
173
+ }): Promise<StorageResourceType>;
174
+ updateResource({ resourceId, workingMemory, metadata, }: {
175
+ resourceId: string;
176
+ workingMemory?: string;
177
+ metadata?: Record<string, unknown>;
178
+ }): Promise<StorageResourceType>;
179
+ getScoreById({ id: _id }: {
180
+ id: string;
181
+ }): Promise<ScoreRowData | null>;
182
+ saveScore(score: ScoreRowData): Promise<{
183
+ score: ScoreRowData;
184
+ }>;
185
+ getScoresByRunId({ runId, pagination, }: {
186
+ runId: string;
187
+ pagination: StoragePagination;
188
+ }): Promise<{
189
+ pagination: PaginationInfo;
190
+ scores: ScoreRowData[];
191
+ }>;
192
+ getScoresByEntityId({ entityId, entityType, pagination, }: {
193
+ pagination: StoragePagination;
194
+ entityId: string;
195
+ entityType: string;
196
+ }): Promise<{
197
+ pagination: PaginationInfo;
198
+ scores: ScoreRowData[];
199
+ }>;
200
+ getScoresByScorerId({ scorerId, pagination, }: {
201
+ scorerId: string;
202
+ pagination: StoragePagination;
203
+ }): Promise<{
204
+ pagination: PaginationInfo;
205
+ scores: ScoreRowData[];
206
+ }>;
207
+ }
208
+ //# sourceMappingURL=index.d.ts.map
@@ -0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core/vector/filter';
2
+ import type { OperatorSupport, VectorFilter, OperatorValueMap } from '@mastra/core/vector/filter';
3
+ type UpstashOperatorValueMap = Omit<OperatorValueMap, '$options' | '$elemMatch'> & {
4
+ $contains: string;
5
+ };
6
+ export type UpstashVectorFilter = VectorFilter<keyof UpstashOperatorValueMap, UpstashOperatorValueMap>;
7
+ export declare class UpstashFilterTranslator extends BaseFilterTranslator<UpstashVectorFilter, string | undefined> {
8
+ protected getSupportedOperators(): OperatorSupport;
9
+ translate(filter?: UpstashVectorFilter): string | undefined;
10
+ private translateNode;
11
+ private readonly COMPARISON_OPS;
12
+ private translateOperator;
13
+ private readonly NEGATED_OPERATORS;
14
+ private formatNot;
15
+ private formatValue;
16
+ private formatArray;
17
+ private formatComparison;
18
+ private joinConditions;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/vector/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAElG,KAAK,uBAAuB,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,YAAY,CAAC,GAAG;IACjF,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,YAAY,CAAC,MAAM,uBAAuB,EAAE,uBAAuB,CAAC,CAAC;AAEvG,qBAAa,uBAAwB,SAAQ,oBAAoB,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;cACrF,qBAAqB,IAAI,eAAe;IAS3D,SAAS,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS;IAM3D,OAAO,CAAC,aAAa;IA4CrB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAOpB;IAEX,OAAO,CAAC,iBAAiB;IAmDzB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAUhC;IAEF,OAAO,CAAC,SAAS;IA6DjB,OAAO,CAAC,WAAW;IAkCnB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,cAAc;CAQvB"}
@@ -0,0 +1,79 @@
1
+ import { MastraVector } from '@mastra/core/vector';
2
+ import type { CreateIndexParams, DeleteIndexParams, DeleteVectorParams, DescribeIndexParams, IndexStats, QueryResult } from '@mastra/core/vector';
3
+ import type { UpstashVectorFilter } from './filter';
4
+ import type { UpstashUpsertVectorParams, UpstashQueryVectorParams, UpstashUpdateVectorParams } from './types';
5
+ export declare class UpstashVector extends MastraVector<UpstashVectorFilter> {
6
+ private client;
7
+ /**
8
+ * Creates a new UpstashVector instance.
9
+ * @param {object} params - The parameters for the UpstashVector.
10
+ * @param {string} params.url - The URL of the Upstash vector index.
11
+ * @param {string} params.token - The token for the Upstash vector index.
12
+ */
13
+ constructor({ url, token }: {
14
+ url: string;
15
+ token: string;
16
+ });
17
+ /**
18
+ * Upserts vectors into the index.
19
+ * @param {UpsertVectorParams} params - The parameters for the upsert operation.
20
+ * @returns {Promise<string[]>} A promise that resolves to the IDs of the upserted vectors.
21
+ */
22
+ upsert({ indexName: namespace, vectors, metadata, ids, sparseVectors, }: UpstashUpsertVectorParams): Promise<string[]>;
23
+ /**
24
+ * Transforms a Mastra vector filter into an Upstash-compatible filter string.
25
+ * @param {UpstashVectorFilter} [filter] - The filter to transform.
26
+ * @returns {string | undefined} The transformed filter string, or undefined if no filter is provided.
27
+ */
28
+ transformFilter(filter?: UpstashVectorFilter): string | undefined;
29
+ /**
30
+ * Creates a new index. For Upstash, this is a no-op as indexes (known as namespaces in Upstash) are created on-the-fly.
31
+ * @param {CreateIndexParams} _params - The parameters for creating the index (ignored).
32
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
33
+ */
34
+ createIndex(_params: CreateIndexParams): Promise<void>;
35
+ /**
36
+ * Queries the vector index.
37
+ * @param {QueryVectorParams} params - The parameters for the query operation. indexName is the namespace in Upstash.
38
+ * @returns {Promise<QueryResult[]>} A promise that resolves to the query results.
39
+ */
40
+ query({ indexName: namespace, queryVector, topK, filter, includeVector, sparseVector, fusionAlgorithm, queryMode, }: UpstashQueryVectorParams): Promise<QueryResult[]>;
41
+ /**
42
+ * Lists all namespaces in the Upstash vector index, which correspond to indexes.
43
+ * @returns {Promise<string[]>} A promise that resolves to a list of index names.
44
+ */
45
+ listIndexes(): Promise<string[]>;
46
+ /**
47
+ * Retrieves statistics about a vector index.
48
+ *
49
+ * @param {string} indexName - The name of the namespace to describe
50
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
51
+ */
52
+ describeIndex({ indexName: namespace }: DescribeIndexParams): Promise<IndexStats>;
53
+ /**
54
+ * Deletes an index (namespace).
55
+ * @param {DeleteIndexParams} params - The parameters for the delete operation.
56
+ * @returns {Promise<void>} A promise that resolves when the deletion is complete.
57
+ */
58
+ deleteIndex({ indexName: namespace }: DeleteIndexParams): Promise<void>;
59
+ /**
60
+ * Updates a vector by its ID with the provided vector and/or metadata.
61
+ * @param indexName - The name of the namespace containing the vector.
62
+ * @param id - The ID of the vector to update.
63
+ * @param update - An object containing the vector and/or metadata to update.
64
+ * @param update.vector - An optional array of numbers representing the new vector.
65
+ * @param update.metadata - An optional record containing the new metadata.
66
+ * @returns A promise that resolves when the update is complete.
67
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
68
+ */
69
+ updateVector({ indexName: namespace, id, update }: UpstashUpdateVectorParams): Promise<void>;
70
+ /**
71
+ * Deletes a vector by its ID.
72
+ * @param indexName - The name of the namespace containing the vector.
73
+ * @param id - The ID of the vector to delete.
74
+ * @returns A promise that resolves when the deletion is complete.
75
+ * @throws Will throw an error if the deletion operation fails.
76
+ */
77
+ deleteVector({ indexName: namespace, id }: DeleteVectorParams): Promise<void>;
78
+ }
79
+ //# sourceMappingURL=index.d.ts.map
@@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EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAsBvF;;;;OAIG;IACG,WAAW,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB7E;;;;;;;;;OASG;IACG,YAAY,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4ClG;;;;;;OAMG;IACG,YAAY,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAkBpF"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Vector store specific prompt that details supported operators and examples.
3
+ * This prompt helps users construct valid filters for Upstash Vector.
4
+ */
5
+ export declare const UPSTASH_PROMPT = "When querying Upstash Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND (can be implicit or explicit)\n Implicit Example: { \"price\": { \"$gt\": 100 }, \"category\": \"electronics\" }\n Explicit Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nRestrictions:\n- Regex patterns are not supported\n- Only $and and $or logical operators are supported at the top level\n- Empty arrays in $in/$nin will return no results\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- At least one key-value pair is required in filter object\n- Empty objects and undefined values are treated as no filter\n- Invalid types in comparison operators will throw errors\n- All non-logical operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"rating\": { \"$exists\": true, \"$gt\": 4 } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
6
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/vector/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,cAAc,uvGAwEzB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { UpsertVectorParams, QueryVectorParams, UpdateVectorParams } from '@mastra/core/vector';
2
+ import type { FusionAlgorithm, QueryMode } from '@upstash/vector';
3
+ import type { UpstashVectorFilter } from './filter';
4
+ export interface UpstashSparseVector {
5
+ indices: number[];
6
+ values: number[];
7
+ }
8
+ export interface UpstashUpsertVectorParams extends UpsertVectorParams {
9
+ sparseVectors?: UpstashSparseVector[];
10
+ }
11
+ export interface UpstashQueryVectorParams extends QueryVectorParams<UpstashVectorFilter> {
12
+ sparseVector?: UpstashSparseVector;
13
+ fusionAlgorithm?: FusionAlgorithm;
14
+ queryMode?: QueryMode;
15
+ }
16
+ export interface UpstashUpdateVectorParams extends UpdateVectorParams {
17
+ update: {
18
+ vector?: number[];
19
+ metadata?: Record<string, any>;
20
+ sparseVector?: UpstashSparseVector;
21
+ };
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vector/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,aAAa,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACvC;AAED,MAAM,WAAW,wBAAyB,SAAQ,iBAAiB,CAAC,mBAAmB,CAAC;IACtF,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,MAAM,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC/B,YAAY,CAAC,EAAE,mBAAmB,CAAC;KACpC,CAAC;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/upstash",
3
- "version": "0.13.0",
3
+ "version": "0.14.0-alpha.0",
4
4
  "description": "Upstash provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,9 +31,9 @@
31
31
  "tsup": "^8.5.0",
32
32
  "typescript": "^5.8.3",
33
33
  "vitest": "^3.2.4",
34
- "@internal/storage-test-utils": "0.0.20",
35
- "@internal/lint": "0.0.24",
36
- "@mastra/core": "0.12.0"
34
+ "@internal/storage-test-utils": "0.0.22",
35
+ "@internal/lint": "0.0.26",
36
+ "@mastra/core": "0.13.0-alpha.1"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@mastra/core": ">=0.12.0-0 <0.13.0-0"
@@ -43,7 +43,7 @@
43
43
  "test": "vitest run",
44
44
  "posttest": "docker compose down",
45
45
  "lint": "eslint .",
46
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
47
- "build:watch": "pnpm build --watch"
46
+ "build": "tsup --silent --config tsup.config.ts",
47
+ "build:watch": "tsup --watch --silent --config tsup.config.ts"
48
48
  }
49
49
  }
@@ -19,7 +19,9 @@ function transformScoreRow(row: Record<string, any>): ScoreRowData {
19
19
  return {
20
20
  ...row,
21
21
  scorer: parseField(row.scorer),
22
- extractStepResult: parseField(row.extractStepResult),
22
+ preprocessStepResult: parseField(row.preprocessStepResult),
23
+ generateScorePrompt: row.generateScorePrompt,
24
+ generateReasonPrompt: row.generateReasonPrompt,
23
25
  analyzeStepResult: parseField(row.analyzeStepResult),
24
26
  metadata: parseField(row.metadata),
25
27
  input: parseField(row.input),
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "**/*.test.ts", "src/**/*.mock.ts"]
9
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
3
+ "include": ["src/**/*", "tsup.config.ts"],
4
4
  "exclude": ["node_modules", "**/*.test.ts"]
5
5
  }
package/tsup.config.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { spawn } from 'child_process';
2
+ import { promisify } from 'util';
3
+ import { defineConfig } from 'tsup';
4
+
5
+ const exec = promisify(spawn);
6
+
7
+ export default defineConfig({
8
+ entry: ['src/index.ts'],
9
+ format: ['esm', 'cjs'],
10
+ clean: true,
11
+ dts: false,
12
+ splitting: true,
13
+ treeshake: {
14
+ preset: 'smallest',
15
+ },
16
+ sourcemap: true,
17
+ onSuccess: async () => {
18
+ await exec('pnpm', ['tsc', '-p', 'tsconfig.build.json'], {
19
+ stdio: 'inherit',
20
+ });
21
+ },
22
+ });