@mastra/upstash 0.11.0-alpha.0 → 0.11.0-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.
- package/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +11 -0
- package/README.md +4 -0
- package/dist/_tsup-dts-rollup.d.cts +44 -9
- package/dist/_tsup-dts-rollup.d.ts +44 -9
- package/dist/index.cjs +83 -42
- package/dist/index.js +83 -42
- package/package.json +2 -2
- package/src/vector/index.ts +54 -19
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/upstash@0.11.0-alpha.
|
|
2
|
+
> @mastra/upstash@0.11.0-alpha.1 build /home/runner/work/mastra/mastra/stores/upstash
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 10304ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/upstash/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/upstash/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 12195ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
20
|
dist/index.cjs (1729:18): Use of eval in "dist/index.cjs" is strongly discouraged as it poses security risks and may cause issues with minification.
|
|
21
21
|
dist/index.js (1729:18): Use of eval in "dist/index.js" is strongly discouraged as it poses security risks and may cause issues with minification.
|
|
22
22
|
[32mCJS[39m [1mdist/getMachineId-darwin-3PL23DL6.cjs [22m[32m1.19 KB[39m
|
|
23
|
+
[32mCJS[39m [1mdist/getMachineId-linux-KYLPK3HC.cjs [22m[32m813.00 B[39m
|
|
23
24
|
[32mCJS[39m [1mdist/getMachineId-bsd-HDZ73WR7.cjs [22m[32m1015.00 B[39m
|
|
24
25
|
[32mCJS[39m [1mdist/getMachineId-win-ZTI2LRDJ.cjs [22m[32m1.66 KB[39m
|
|
25
|
-
[32mCJS[39m [1mdist/getMachineId-linux-KYLPK3HC.cjs [22m[32m813.00 B[39m
|
|
26
|
-
[32mCJS[39m [1mdist/getMachineId-unsupported-DEDJN4ZS.cjs [22m[32m777.00 B[39m
|
|
27
26
|
[32mCJS[39m [1mdist/chunk-N2CPQVE3.cjs [22m[32m1.09 KB[39m
|
|
27
|
+
[32mCJS[39m [1mdist/getMachineId-unsupported-DEDJN4ZS.cjs [22m[32m777.00 B[39m
|
|
28
28
|
[32mCJS[39m [1mdist/chunk-U74OJRHU.cjs [22m[32m62.08 KB[39m
|
|
29
29
|
[32mCJS[39m [1mdist/index.cjs [22m[32m1.67 MB[39m
|
|
30
|
-
[32mCJS[39m ⚡️ Build success in
|
|
31
|
-
[32mESM[39m [1mdist/getMachineId-darwin-UTKBTJ2U.js [22m[32m1.08 KB[39m
|
|
30
|
+
[32mCJS[39m ⚡️ Build success in 22539ms
|
|
32
31
|
[32mESM[39m [1mdist/getMachineId-linux-K3QXQYAB.js [22m[32m740.00 B[39m
|
|
33
|
-
[32mESM[39m [1mdist/getMachineId-
|
|
32
|
+
[32mESM[39m [1mdist/getMachineId-darwin-UTKBTJ2U.js [22m[32m1.08 KB[39m
|
|
34
33
|
[32mESM[39m [1mdist/getMachineId-win-L2EYIM5A.js [22m[32m1.04 KB[39m
|
|
34
|
+
[32mESM[39m [1mdist/getMachineId-bsd-KKIDU47O.js [22m[32m896.00 B[39m
|
|
35
35
|
[32mESM[39m [1mdist/chunk-IGKEDEDE.js [22m[32m452.00 B[39m
|
|
36
|
-
[32mESM[39m [1mdist/getMachineId-unsupported-VPWBQCK7.js [22m[32m700.00 B[39m
|
|
37
36
|
[32mESM[39m [1mdist/chunk-HSTZWXH7.js [22m[32m61.52 KB[39m
|
|
38
|
-
[32mESM[39m [1mdist/
|
|
39
|
-
[32mESM[39m
|
|
37
|
+
[32mESM[39m [1mdist/getMachineId-unsupported-VPWBQCK7.js [22m[32m700.00 B[39m
|
|
38
|
+
[32mESM[39m [1mdist/index.js [22m[32m1.67 MB[39m
|
|
39
|
+
[32mESM[39m ⚡️ Build success in 22541ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 0.11.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2fda031: Clarify upstash argument concepts.
|
|
8
|
+
- Updated dependencies [ee9af57]
|
|
9
|
+
- Updated dependencies [751c894]
|
|
10
|
+
- Updated dependencies [577ce3a]
|
|
11
|
+
- Updated dependencies [9260b3a]
|
|
12
|
+
- @mastra/core@0.10.6-alpha.1
|
|
13
|
+
|
|
3
14
|
## 0.11.0-alpha.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
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',
|
|
@@ -217,26 +217,61 @@ export { UpstashStore as UpstashStore_alias_1 }
|
|
|
217
217
|
|
|
218
218
|
declare class UpstashVector extends MastraVector {
|
|
219
219
|
private client;
|
|
220
|
+
/**
|
|
221
|
+
* Creates a new UpstashVector instance.
|
|
222
|
+
* @param {object} params - The parameters for the UpstashVector.
|
|
223
|
+
* @param {string} params.url - The URL of the Upstash vector index.
|
|
224
|
+
* @param {string} params.token - The token for the Upstash vector index.
|
|
225
|
+
*/
|
|
220
226
|
constructor({ url, token }: {
|
|
221
227
|
url: string;
|
|
222
228
|
token: string;
|
|
223
229
|
});
|
|
224
|
-
|
|
230
|
+
/**
|
|
231
|
+
* Upserts vectors into the index.
|
|
232
|
+
* @param {UpsertVectorParams} params - The parameters for the upsert operation.
|
|
233
|
+
* @returns {Promise<string[]>} A promise that resolves to the IDs of the upserted vectors.
|
|
234
|
+
*/
|
|
235
|
+
upsert({ indexName: namespace, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
236
|
+
/**
|
|
237
|
+
* Transforms a Mastra vector filter into an Upstash-compatible filter string.
|
|
238
|
+
* @param {VectorFilter} [filter] - The filter to transform.
|
|
239
|
+
* @returns {string | undefined} The transformed filter string, or undefined if no filter is provided.
|
|
240
|
+
*/
|
|
225
241
|
transformFilter(filter?: VectorFilter): string | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* Creates a new index. For Upstash, this is a no-op as indexes (known as namespaces in Upstash) are created on-the-fly.
|
|
244
|
+
* @param {CreateIndexParams} _params - The parameters for creating the index (ignored).
|
|
245
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
246
|
+
*/
|
|
226
247
|
createIndex(_params: CreateIndexParams): Promise<void>;
|
|
227
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Queries the vector index.
|
|
250
|
+
* @param {QueryVectorParams} params - The parameters for the query operation. indexName is the namespace in Upstash.
|
|
251
|
+
* @returns {Promise<QueryResult[]>} A promise that resolves to the query results.
|
|
252
|
+
*/
|
|
253
|
+
query({ indexName: namespace, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
|
|
254
|
+
/**
|
|
255
|
+
* Lists all namespaces in the Upstash vector index, which correspond to indexes.
|
|
256
|
+
* @returns {Promise<string[]>} A promise that resolves to a list of index names.
|
|
257
|
+
*/
|
|
228
258
|
listIndexes(): Promise<string[]>;
|
|
229
259
|
/**
|
|
230
260
|
* Retrieves statistics about a vector index.
|
|
231
261
|
*
|
|
232
|
-
* @param {string} indexName - The name of the
|
|
262
|
+
* @param {string} indexName - The name of the namespace to describe
|
|
233
263
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
234
264
|
*/
|
|
235
|
-
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
236
|
-
|
|
265
|
+
describeIndex({ indexName: namespace }: DescribeIndexParams): Promise<IndexStats>;
|
|
266
|
+
/**
|
|
267
|
+
* Deletes an index (namespace).
|
|
268
|
+
* @param {DeleteIndexParams} params - The parameters for the delete operation.
|
|
269
|
+
* @returns {Promise<void>} A promise that resolves when the deletion is complete.
|
|
270
|
+
*/
|
|
271
|
+
deleteIndex({ indexName: namespace }: DeleteIndexParams): Promise<void>;
|
|
237
272
|
/**
|
|
238
273
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
239
|
-
* @param indexName - The name of the
|
|
274
|
+
* @param indexName - The name of the namespace containing the vector.
|
|
240
275
|
* @param id - The ID of the vector to update.
|
|
241
276
|
* @param update - An object containing the vector and/or metadata to update.
|
|
242
277
|
* @param update.vector - An optional array of numbers representing the new vector.
|
|
@@ -244,15 +279,15 @@ declare class UpstashVector extends MastraVector {
|
|
|
244
279
|
* @returns A promise that resolves when the update is complete.
|
|
245
280
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
246
281
|
*/
|
|
247
|
-
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
282
|
+
updateVector({ indexName: namespace, id, update }: UpdateVectorParams): Promise<void>;
|
|
248
283
|
/**
|
|
249
284
|
* Deletes a vector by its ID.
|
|
250
|
-
* @param indexName - The name of the
|
|
285
|
+
* @param indexName - The name of the namespace containing the vector.
|
|
251
286
|
* @param id - The ID of the vector to delete.
|
|
252
287
|
* @returns A promise that resolves when the deletion is complete.
|
|
253
288
|
* @throws Will throw an error if the deletion operation fails.
|
|
254
289
|
*/
|
|
255
|
-
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
290
|
+
deleteVector({ indexName: namespace, id }: DeleteVectorParams): Promise<void>;
|
|
256
291
|
}
|
|
257
292
|
export { UpstashVector }
|
|
258
293
|
export { UpstashVector as UpstashVector_alias_1 }
|
|
@@ -217,26 +217,61 @@ export { UpstashStore as UpstashStore_alias_1 }
|
|
|
217
217
|
|
|
218
218
|
declare class UpstashVector extends MastraVector {
|
|
219
219
|
private client;
|
|
220
|
+
/**
|
|
221
|
+
* Creates a new UpstashVector instance.
|
|
222
|
+
* @param {object} params - The parameters for the UpstashVector.
|
|
223
|
+
* @param {string} params.url - The URL of the Upstash vector index.
|
|
224
|
+
* @param {string} params.token - The token for the Upstash vector index.
|
|
225
|
+
*/
|
|
220
226
|
constructor({ url, token }: {
|
|
221
227
|
url: string;
|
|
222
228
|
token: string;
|
|
223
229
|
});
|
|
224
|
-
|
|
230
|
+
/**
|
|
231
|
+
* Upserts vectors into the index.
|
|
232
|
+
* @param {UpsertVectorParams} params - The parameters for the upsert operation.
|
|
233
|
+
* @returns {Promise<string[]>} A promise that resolves to the IDs of the upserted vectors.
|
|
234
|
+
*/
|
|
235
|
+
upsert({ indexName: namespace, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
236
|
+
/**
|
|
237
|
+
* Transforms a Mastra vector filter into an Upstash-compatible filter string.
|
|
238
|
+
* @param {VectorFilter} [filter] - The filter to transform.
|
|
239
|
+
* @returns {string | undefined} The transformed filter string, or undefined if no filter is provided.
|
|
240
|
+
*/
|
|
225
241
|
transformFilter(filter?: VectorFilter): string | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* Creates a new index. For Upstash, this is a no-op as indexes (known as namespaces in Upstash) are created on-the-fly.
|
|
244
|
+
* @param {CreateIndexParams} _params - The parameters for creating the index (ignored).
|
|
245
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
246
|
+
*/
|
|
226
247
|
createIndex(_params: CreateIndexParams): Promise<void>;
|
|
227
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Queries the vector index.
|
|
250
|
+
* @param {QueryVectorParams} params - The parameters for the query operation. indexName is the namespace in Upstash.
|
|
251
|
+
* @returns {Promise<QueryResult[]>} A promise that resolves to the query results.
|
|
252
|
+
*/
|
|
253
|
+
query({ indexName: namespace, queryVector, topK, filter, includeVector, }: QueryVectorParams): Promise<QueryResult[]>;
|
|
254
|
+
/**
|
|
255
|
+
* Lists all namespaces in the Upstash vector index, which correspond to indexes.
|
|
256
|
+
* @returns {Promise<string[]>} A promise that resolves to a list of index names.
|
|
257
|
+
*/
|
|
228
258
|
listIndexes(): Promise<string[]>;
|
|
229
259
|
/**
|
|
230
260
|
* Retrieves statistics about a vector index.
|
|
231
261
|
*
|
|
232
|
-
* @param {string} indexName - The name of the
|
|
262
|
+
* @param {string} indexName - The name of the namespace to describe
|
|
233
263
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
234
264
|
*/
|
|
235
|
-
describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
|
|
236
|
-
|
|
265
|
+
describeIndex({ indexName: namespace }: DescribeIndexParams): Promise<IndexStats>;
|
|
266
|
+
/**
|
|
267
|
+
* Deletes an index (namespace).
|
|
268
|
+
* @param {DeleteIndexParams} params - The parameters for the delete operation.
|
|
269
|
+
* @returns {Promise<void>} A promise that resolves when the deletion is complete.
|
|
270
|
+
*/
|
|
271
|
+
deleteIndex({ indexName: namespace }: DeleteIndexParams): Promise<void>;
|
|
237
272
|
/**
|
|
238
273
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
239
|
-
* @param indexName - The name of the
|
|
274
|
+
* @param indexName - The name of the namespace containing the vector.
|
|
240
275
|
* @param id - The ID of the vector to update.
|
|
241
276
|
* @param update - An object containing the vector and/or metadata to update.
|
|
242
277
|
* @param update.vector - An optional array of numbers representing the new vector.
|
|
@@ -244,15 +279,15 @@ declare class UpstashVector extends MastraVector {
|
|
|
244
279
|
* @returns A promise that resolves when the update is complete.
|
|
245
280
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
246
281
|
*/
|
|
247
|
-
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
282
|
+
updateVector({ indexName: namespace, id, update }: UpdateVectorParams): Promise<void>;
|
|
248
283
|
/**
|
|
249
284
|
* Deletes a vector by its ID.
|
|
250
|
-
* @param indexName - The name of the
|
|
285
|
+
* @param indexName - The name of the namespace containing the vector.
|
|
251
286
|
* @param id - The ID of the vector to delete.
|
|
252
287
|
* @returns A promise that resolves when the deletion is complete.
|
|
253
288
|
* @throws Will throw an error if the deletion operation fails.
|
|
254
289
|
*/
|
|
255
|
-
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
290
|
+
deleteVector({ indexName: namespace, id }: DeleteVectorParams): Promise<void>;
|
|
256
291
|
}
|
|
257
292
|
export { UpstashVector }
|
|
258
293
|
export { UpstashVector as UpstashVector_alias_1 }
|
package/dist/index.cjs
CHANGED
|
@@ -11014,9 +11014,9 @@ var init_esm5 = chunkU74OJRHU_cjs.__esm({
|
|
|
11014
11014
|
}
|
|
11015
11015
|
});
|
|
11016
11016
|
|
|
11017
|
-
// ../../packages/core/dist/chunk-
|
|
11018
|
-
var
|
|
11019
|
-
"../../packages/core/dist/chunk-
|
|
11017
|
+
// ../../packages/core/dist/chunk-JDOKE3OQ.cjs
|
|
11018
|
+
var require_chunk_JDOKE3OQ = chunkU74OJRHU_cjs.__commonJS({
|
|
11019
|
+
"../../packages/core/dist/chunk-JDOKE3OQ.cjs"(exports2) {
|
|
11020
11020
|
var chunkOLSQRA2V_cjs = require_chunk_OLSQRA2V();
|
|
11021
11021
|
var api = (chunkU74OJRHU_cjs.init_esm(), chunkU74OJRHU_cjs.__toCommonJS(chunkU74OJRHU_cjs.esm_exports));
|
|
11022
11022
|
var core = (init_esm3(), chunkU74OJRHU_cjs.__toCommonJS(esm_exports2));
|
|
@@ -11385,10 +11385,10 @@ var require_chunk_QQ3KHYKE = chunkU74OJRHU_cjs.__commonJS({
|
|
|
11385
11385
|
*/
|
|
11386
11386
|
static init(config = {}) {
|
|
11387
11387
|
try {
|
|
11388
|
-
if (!
|
|
11389
|
-
|
|
11388
|
+
if (!globalThis.__TELEMETRY__) {
|
|
11389
|
+
globalThis.__TELEMETRY__ = new _Telemetry(config);
|
|
11390
11390
|
}
|
|
11391
|
-
return
|
|
11391
|
+
return globalThis.__TELEMETRY__;
|
|
11392
11392
|
} catch (error) {
|
|
11393
11393
|
const wrappedError = new chunkOLSQRA2V_cjs.MastraError(
|
|
11394
11394
|
{
|
|
@@ -11413,7 +11413,7 @@ var require_chunk_QQ3KHYKE = chunkU74OJRHU_cjs.__commonJS({
|
|
|
11413
11413
|
* @returns {Telemetry} The global telemetry instance
|
|
11414
11414
|
*/
|
|
11415
11415
|
static get() {
|
|
11416
|
-
if (!
|
|
11416
|
+
if (!globalThis.__TELEMETRY__) {
|
|
11417
11417
|
throw new chunkOLSQRA2V_cjs.MastraError({
|
|
11418
11418
|
id: "TELEMETRY_GETTER_FAILED_GLOBAL_TELEMETRY_NOT_INITIALIZED",
|
|
11419
11419
|
text: "Telemetry not initialized",
|
|
@@ -11422,7 +11422,7 @@ var require_chunk_QQ3KHYKE = chunkU74OJRHU_cjs.__commonJS({
|
|
|
11422
11422
|
/* USER */
|
|
11423
11423
|
});
|
|
11424
11424
|
}
|
|
11425
|
-
return
|
|
11425
|
+
return globalThis.__TELEMETRY__;
|
|
11426
11426
|
}
|
|
11427
11427
|
/**
|
|
11428
11428
|
* Wraps a class instance with telemetry tracing
|
|
@@ -11873,17 +11873,17 @@ var require_chunk_RWTSGWWL = chunkU74OJRHU_cjs.__commonJS({
|
|
|
11873
11873
|
}
|
|
11874
11874
|
});
|
|
11875
11875
|
|
|
11876
|
-
// ../../packages/core/dist/chunk-
|
|
11877
|
-
var
|
|
11878
|
-
"../../packages/core/dist/chunk-
|
|
11879
|
-
var
|
|
11876
|
+
// ../../packages/core/dist/chunk-6U377XOJ.cjs
|
|
11877
|
+
var require_chunk_6U377XOJ = chunkU74OJRHU_cjs.__commonJS({
|
|
11878
|
+
"../../packages/core/dist/chunk-6U377XOJ.cjs"(exports2) {
|
|
11879
|
+
var chunkJDOKE3OQ_cjs = require_chunk_JDOKE3OQ();
|
|
11880
11880
|
var chunkOLSQRA2V_cjs = require_chunk_OLSQRA2V();
|
|
11881
11881
|
var chunkP3Q73CAW_cjs = require_chunk_P3Q73CAW();
|
|
11882
11882
|
var chunkRWTSGWWL_cjs = require_chunk_RWTSGWWL();
|
|
11883
11883
|
var _MastraVoice_decorators;
|
|
11884
11884
|
var _init;
|
|
11885
11885
|
var _a;
|
|
11886
|
-
_MastraVoice_decorators = [
|
|
11886
|
+
_MastraVoice_decorators = [chunkJDOKE3OQ_cjs.InstrumentClass({
|
|
11887
11887
|
prefix: "voice",
|
|
11888
11888
|
excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
|
|
11889
11889
|
})];
|
|
@@ -38789,14 +38789,14 @@ ${err.message}`);
|
|
|
38789
38789
|
}
|
|
38790
38790
|
});
|
|
38791
38791
|
|
|
38792
|
-
// ../../packages/core/dist/chunk-
|
|
38793
|
-
var
|
|
38794
|
-
"../../packages/core/dist/chunk-
|
|
38795
|
-
var
|
|
38792
|
+
// ../../packages/core/dist/chunk-DHQAWCO4.cjs
|
|
38793
|
+
var require_chunk_DHQAWCO4 = chunkU74OJRHU_cjs.__commonJS({
|
|
38794
|
+
"../../packages/core/dist/chunk-DHQAWCO4.cjs"(exports2) {
|
|
38795
|
+
var chunk6U377XOJ_cjs = require_chunk_6U377XOJ();
|
|
38796
38796
|
var chunkTGK6JO2D_cjs = require_chunk_TGK6JO2D();
|
|
38797
38797
|
var chunkST5RMVLG_cjs = require_chunk_ST5RMVLG();
|
|
38798
38798
|
var chunkHVI3SKIH_cjs = require_chunk_HVI3SKIH();
|
|
38799
|
-
var
|
|
38799
|
+
var chunkJDOKE3OQ_cjs = require_chunk_JDOKE3OQ();
|
|
38800
38800
|
var chunkJ7MLMW6O_cjs = require_chunk_J7MLMW6O();
|
|
38801
38801
|
var chunkOLSQRA2V_cjs = require_chunk_OLSQRA2V();
|
|
38802
38802
|
var chunkP3Q73CAW_cjs = require_chunk_P3Q73CAW();
|
|
@@ -38858,7 +38858,7 @@ var require_chunk_QQT4XTOG = chunkU74OJRHU_cjs.__commonJS({
|
|
|
38858
38858
|
var _Agent_decorators;
|
|
38859
38859
|
var _init;
|
|
38860
38860
|
var _a;
|
|
38861
|
-
_Agent_decorators = [
|
|
38861
|
+
_Agent_decorators = [chunkJDOKE3OQ_cjs.InstrumentClass({
|
|
38862
38862
|
prefix: "agent",
|
|
38863
38863
|
excludeMethods: ["hasOwnMemory", "getMemory", "__primitive", "__registerMastra", "__registerPrimitives", "__setTools", "__setLogger", "__setTelemetry", "log", "getModel", "getInstructions", "getTools", "getLLM", "getWorkflows", "getDefaultGenerateOptions", "getDefaultStreamOptions", "getDescription"]
|
|
38864
38864
|
})];
|
|
@@ -38936,7 +38936,7 @@ var require_chunk_QQT4XTOG = chunkU74OJRHU_cjs.__commonJS({
|
|
|
38936
38936
|
this.#voice?.addInstructions(config.instructions);
|
|
38937
38937
|
}
|
|
38938
38938
|
} else {
|
|
38939
|
-
this.#voice = new
|
|
38939
|
+
this.#voice = new chunk6U377XOJ_cjs.DefaultVoice();
|
|
38940
38940
|
}
|
|
38941
38941
|
}
|
|
38942
38942
|
hasOwnMemory() {
|
|
@@ -39000,7 +39000,7 @@ var require_chunk_QQT4XTOG = chunkU74OJRHU_cjs.__commonJS({
|
|
|
39000
39000
|
}));
|
|
39001
39001
|
return voice;
|
|
39002
39002
|
} else {
|
|
39003
|
-
return new
|
|
39003
|
+
return new chunk6U377XOJ_cjs.DefaultVoice();
|
|
39004
39004
|
}
|
|
39005
39005
|
}
|
|
39006
39006
|
get instructions() {
|
|
@@ -40122,6 +40122,8 @@ ${JSON.stringify(
|
|
|
40122
40122
|
telemetry,
|
|
40123
40123
|
memory: this.getMemory(),
|
|
40124
40124
|
runtimeContext,
|
|
40125
|
+
threadId,
|
|
40126
|
+
resourceId,
|
|
40125
40127
|
...args
|
|
40126
40128
|
});
|
|
40127
40129
|
const newStreamResult = streamResult;
|
|
@@ -40164,6 +40166,8 @@ ${JSON.stringify(
|
|
|
40164
40166
|
telemetry,
|
|
40165
40167
|
memory: this.getMemory(),
|
|
40166
40168
|
runtimeContext,
|
|
40169
|
+
threadId,
|
|
40170
|
+
resourceId,
|
|
40167
40171
|
...args
|
|
40168
40172
|
});
|
|
40169
40173
|
}
|
|
@@ -40203,6 +40207,8 @@ ${JSON.stringify(
|
|
|
40203
40207
|
telemetry,
|
|
40204
40208
|
memory: this.getMemory(),
|
|
40205
40209
|
runtimeContext,
|
|
40210
|
+
threadId,
|
|
40211
|
+
resourceId,
|
|
40206
40212
|
...args
|
|
40207
40213
|
});
|
|
40208
40214
|
}
|
|
@@ -43329,12 +43335,12 @@ ${JSON.stringify(
|
|
|
43329
43335
|
// ../../packages/core/dist/agent/index.cjs
|
|
43330
43336
|
var require_agent = chunkU74OJRHU_cjs.__commonJS({
|
|
43331
43337
|
"../../packages/core/dist/agent/index.cjs"(exports2) {
|
|
43332
|
-
var
|
|
43338
|
+
var chunkDHQAWCO4_cjs = require_chunk_DHQAWCO4();
|
|
43333
43339
|
var chunkTGK6JO2D_cjs = require_chunk_TGK6JO2D();
|
|
43334
43340
|
Object.defineProperty(exports2, "Agent", {
|
|
43335
43341
|
enumerable: true,
|
|
43336
43342
|
get: function() {
|
|
43337
|
-
return
|
|
43343
|
+
return chunkDHQAWCO4_cjs.Agent;
|
|
43338
43344
|
}
|
|
43339
43345
|
});
|
|
43340
43346
|
Object.defineProperty(exports2, "MessageList", {
|
|
@@ -44394,6 +44400,12 @@ var UpstashFilterTranslator = class extends filter.BaseFilterTranslator {
|
|
|
44394
44400
|
// src/vector/index.ts
|
|
44395
44401
|
var UpstashVector = class extends vector.MastraVector {
|
|
44396
44402
|
client;
|
|
44403
|
+
/**
|
|
44404
|
+
* Creates a new UpstashVector instance.
|
|
44405
|
+
* @param {object} params - The parameters for the UpstashVector.
|
|
44406
|
+
* @param {string} params.url - The URL of the Upstash vector index.
|
|
44407
|
+
* @param {string} params.token - The token for the Upstash vector index.
|
|
44408
|
+
*/
|
|
44397
44409
|
constructor({ url, token }) {
|
|
44398
44410
|
super();
|
|
44399
44411
|
this.client = new vector$1.Index({
|
|
@@ -44401,7 +44413,12 @@ var UpstashVector = class extends vector.MastraVector {
|
|
|
44401
44413
|
token
|
|
44402
44414
|
});
|
|
44403
44415
|
}
|
|
44404
|
-
|
|
44416
|
+
/**
|
|
44417
|
+
* Upserts vectors into the index.
|
|
44418
|
+
* @param {UpsertVectorParams} params - The parameters for the upsert operation.
|
|
44419
|
+
* @returns {Promise<string[]>} A promise that resolves to the IDs of the upserted vectors.
|
|
44420
|
+
*/
|
|
44421
|
+
async upsert({ indexName: namespace, vectors, metadata, ids }) {
|
|
44405
44422
|
const generatedIds = ids || vectors.map(() => crypto.randomUUID());
|
|
44406
44423
|
const points = vectors.map((vector, index) => ({
|
|
44407
44424
|
id: generatedIds[index],
|
|
@@ -44409,25 +44426,40 @@ var UpstashVector = class extends vector.MastraVector {
|
|
|
44409
44426
|
metadata: metadata?.[index]
|
|
44410
44427
|
}));
|
|
44411
44428
|
await this.client.upsert(points, {
|
|
44412
|
-
namespace
|
|
44429
|
+
namespace
|
|
44413
44430
|
});
|
|
44414
44431
|
return generatedIds;
|
|
44415
44432
|
}
|
|
44433
|
+
/**
|
|
44434
|
+
* Transforms a Mastra vector filter into an Upstash-compatible filter string.
|
|
44435
|
+
* @param {VectorFilter} [filter] - The filter to transform.
|
|
44436
|
+
* @returns {string | undefined} The transformed filter string, or undefined if no filter is provided.
|
|
44437
|
+
*/
|
|
44416
44438
|
transformFilter(filter) {
|
|
44417
44439
|
const translator = new UpstashFilterTranslator();
|
|
44418
44440
|
return translator.translate(filter);
|
|
44419
44441
|
}
|
|
44442
|
+
/**
|
|
44443
|
+
* Creates a new index. For Upstash, this is a no-op as indexes (known as namespaces in Upstash) are created on-the-fly.
|
|
44444
|
+
* @param {CreateIndexParams} _params - The parameters for creating the index (ignored).
|
|
44445
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
44446
|
+
*/
|
|
44420
44447
|
async createIndex(_params) {
|
|
44421
|
-
|
|
44448
|
+
this.logger.debug("No need to call createIndex for Upstash");
|
|
44422
44449
|
}
|
|
44450
|
+
/**
|
|
44451
|
+
* Queries the vector index.
|
|
44452
|
+
* @param {QueryVectorParams} params - The parameters for the query operation. indexName is the namespace in Upstash.
|
|
44453
|
+
* @returns {Promise<QueryResult[]>} A promise that resolves to the query results.
|
|
44454
|
+
*/
|
|
44423
44455
|
async query({
|
|
44424
|
-
indexName,
|
|
44456
|
+
indexName: namespace,
|
|
44425
44457
|
queryVector,
|
|
44426
44458
|
topK = 10,
|
|
44427
44459
|
filter,
|
|
44428
44460
|
includeVector = false
|
|
44429
44461
|
}) {
|
|
44430
|
-
const ns = this.client.namespace(
|
|
44462
|
+
const ns = this.client.namespace(namespace);
|
|
44431
44463
|
const filterString = this.transformFilter(filter);
|
|
44432
44464
|
const results = await ns.query({
|
|
44433
44465
|
topK,
|
|
@@ -44443,6 +44475,10 @@ var UpstashVector = class extends vector.MastraVector {
|
|
|
44443
44475
|
...includeVector && { vector: result.vector || [] }
|
|
44444
44476
|
}));
|
|
44445
44477
|
}
|
|
44478
|
+
/**
|
|
44479
|
+
* Lists all namespaces in the Upstash vector index, which correspond to indexes.
|
|
44480
|
+
* @returns {Promise<string[]>} A promise that resolves to a list of index names.
|
|
44481
|
+
*/
|
|
44446
44482
|
async listIndexes() {
|
|
44447
44483
|
const indexes = await this.client.listNamespaces();
|
|
44448
44484
|
return indexes.filter(Boolean);
|
|
@@ -44450,27 +44486,32 @@ var UpstashVector = class extends vector.MastraVector {
|
|
|
44450
44486
|
/**
|
|
44451
44487
|
* Retrieves statistics about a vector index.
|
|
44452
44488
|
*
|
|
44453
|
-
* @param {string} indexName - The name of the
|
|
44489
|
+
* @param {string} indexName - The name of the namespace to describe
|
|
44454
44490
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
44455
44491
|
*/
|
|
44456
|
-
async describeIndex({ indexName }) {
|
|
44492
|
+
async describeIndex({ indexName: namespace }) {
|
|
44457
44493
|
const info = await this.client.info();
|
|
44458
44494
|
return {
|
|
44459
44495
|
dimension: info.dimension,
|
|
44460
|
-
count: info.namespaces?.[
|
|
44496
|
+
count: info.namespaces?.[namespace]?.vectorCount || 0,
|
|
44461
44497
|
metric: info?.similarityFunction?.toLowerCase()
|
|
44462
44498
|
};
|
|
44463
44499
|
}
|
|
44464
|
-
|
|
44500
|
+
/**
|
|
44501
|
+
* Deletes an index (namespace).
|
|
44502
|
+
* @param {DeleteIndexParams} params - The parameters for the delete operation.
|
|
44503
|
+
* @returns {Promise<void>} A promise that resolves when the deletion is complete.
|
|
44504
|
+
*/
|
|
44505
|
+
async deleteIndex({ indexName: namespace }) {
|
|
44465
44506
|
try {
|
|
44466
|
-
await this.client.deleteNamespace(
|
|
44507
|
+
await this.client.deleteNamespace(namespace);
|
|
44467
44508
|
} catch (error) {
|
|
44468
|
-
|
|
44509
|
+
this.logger.error("Failed to delete namespace:", error);
|
|
44469
44510
|
}
|
|
44470
44511
|
}
|
|
44471
44512
|
/**
|
|
44472
44513
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
44473
|
-
* @param indexName - The name of the
|
|
44514
|
+
* @param indexName - The name of the namespace containing the vector.
|
|
44474
44515
|
* @param id - The ID of the vector to update.
|
|
44475
44516
|
* @param update - An object containing the vector and/or metadata to update.
|
|
44476
44517
|
* @param update.vector - An optional array of numbers representing the new vector.
|
|
@@ -44478,7 +44519,7 @@ var UpstashVector = class extends vector.MastraVector {
|
|
|
44478
44519
|
* @returns A promise that resolves when the update is complete.
|
|
44479
44520
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
44480
44521
|
*/
|
|
44481
|
-
async updateVector({ indexName, id, update }) {
|
|
44522
|
+
async updateVector({ indexName: namespace, id, update }) {
|
|
44482
44523
|
try {
|
|
44483
44524
|
if (!update.vector && !update.metadata) {
|
|
44484
44525
|
throw new Error("No update data provided");
|
|
@@ -44499,26 +44540,26 @@ var UpstashVector = class extends vector.MastraVector {
|
|
|
44499
44540
|
metadata: updatePayload.metadata
|
|
44500
44541
|
};
|
|
44501
44542
|
await this.client.upsert(points, {
|
|
44502
|
-
namespace
|
|
44543
|
+
namespace
|
|
44503
44544
|
});
|
|
44504
44545
|
} catch (error) {
|
|
44505
|
-
throw new Error(`Failed to update vector by id: ${id} for index name: ${
|
|
44546
|
+
throw new Error(`Failed to update vector by id: ${id} for index name: ${namespace}: ${error.message}`);
|
|
44506
44547
|
}
|
|
44507
44548
|
}
|
|
44508
44549
|
/**
|
|
44509
44550
|
* Deletes a vector by its ID.
|
|
44510
|
-
* @param indexName - The name of the
|
|
44551
|
+
* @param indexName - The name of the namespace containing the vector.
|
|
44511
44552
|
* @param id - The ID of the vector to delete.
|
|
44512
44553
|
* @returns A promise that resolves when the deletion is complete.
|
|
44513
44554
|
* @throws Will throw an error if the deletion operation fails.
|
|
44514
44555
|
*/
|
|
44515
|
-
async deleteVector({ indexName, id }) {
|
|
44556
|
+
async deleteVector({ indexName: namespace, id }) {
|
|
44516
44557
|
try {
|
|
44517
44558
|
await this.client.delete(id, {
|
|
44518
|
-
namespace
|
|
44559
|
+
namespace
|
|
44519
44560
|
});
|
|
44520
44561
|
} catch (error) {
|
|
44521
|
-
|
|
44562
|
+
this.logger.error(`Failed to delete vector by id: ${id} for namespace: ${namespace}:`, error);
|
|
44522
44563
|
}
|
|
44523
44564
|
}
|
|
44524
44565
|
};
|
package/dist/index.js
CHANGED
|
@@ -11012,9 +11012,9 @@ var init_esm5 = __esm({
|
|
|
11012
11012
|
}
|
|
11013
11013
|
});
|
|
11014
11014
|
|
|
11015
|
-
// ../../packages/core/dist/chunk-
|
|
11016
|
-
var
|
|
11017
|
-
"../../packages/core/dist/chunk-
|
|
11015
|
+
// ../../packages/core/dist/chunk-JDOKE3OQ.cjs
|
|
11016
|
+
var require_chunk_JDOKE3OQ = __commonJS({
|
|
11017
|
+
"../../packages/core/dist/chunk-JDOKE3OQ.cjs"(exports2) {
|
|
11018
11018
|
var chunkOLSQRA2V_cjs = require_chunk_OLSQRA2V();
|
|
11019
11019
|
var api = (init_esm(), __toCommonJS(esm_exports));
|
|
11020
11020
|
var core = (init_esm3(), __toCommonJS(esm_exports2));
|
|
@@ -11383,10 +11383,10 @@ var require_chunk_QQ3KHYKE = __commonJS({
|
|
|
11383
11383
|
*/
|
|
11384
11384
|
static init(config = {}) {
|
|
11385
11385
|
try {
|
|
11386
|
-
if (!
|
|
11387
|
-
|
|
11386
|
+
if (!globalThis.__TELEMETRY__) {
|
|
11387
|
+
globalThis.__TELEMETRY__ = new _Telemetry(config);
|
|
11388
11388
|
}
|
|
11389
|
-
return
|
|
11389
|
+
return globalThis.__TELEMETRY__;
|
|
11390
11390
|
} catch (error) {
|
|
11391
11391
|
const wrappedError = new chunkOLSQRA2V_cjs.MastraError(
|
|
11392
11392
|
{
|
|
@@ -11411,7 +11411,7 @@ var require_chunk_QQ3KHYKE = __commonJS({
|
|
|
11411
11411
|
* @returns {Telemetry} The global telemetry instance
|
|
11412
11412
|
*/
|
|
11413
11413
|
static get() {
|
|
11414
|
-
if (!
|
|
11414
|
+
if (!globalThis.__TELEMETRY__) {
|
|
11415
11415
|
throw new chunkOLSQRA2V_cjs.MastraError({
|
|
11416
11416
|
id: "TELEMETRY_GETTER_FAILED_GLOBAL_TELEMETRY_NOT_INITIALIZED",
|
|
11417
11417
|
text: "Telemetry not initialized",
|
|
@@ -11420,7 +11420,7 @@ var require_chunk_QQ3KHYKE = __commonJS({
|
|
|
11420
11420
|
/* USER */
|
|
11421
11421
|
});
|
|
11422
11422
|
}
|
|
11423
|
-
return
|
|
11423
|
+
return globalThis.__TELEMETRY__;
|
|
11424
11424
|
}
|
|
11425
11425
|
/**
|
|
11426
11426
|
* Wraps a class instance with telemetry tracing
|
|
@@ -11871,17 +11871,17 @@ var require_chunk_RWTSGWWL = __commonJS({
|
|
|
11871
11871
|
}
|
|
11872
11872
|
});
|
|
11873
11873
|
|
|
11874
|
-
// ../../packages/core/dist/chunk-
|
|
11875
|
-
var
|
|
11876
|
-
"../../packages/core/dist/chunk-
|
|
11877
|
-
var
|
|
11874
|
+
// ../../packages/core/dist/chunk-6U377XOJ.cjs
|
|
11875
|
+
var require_chunk_6U377XOJ = __commonJS({
|
|
11876
|
+
"../../packages/core/dist/chunk-6U377XOJ.cjs"(exports2) {
|
|
11877
|
+
var chunkJDOKE3OQ_cjs = require_chunk_JDOKE3OQ();
|
|
11878
11878
|
var chunkOLSQRA2V_cjs = require_chunk_OLSQRA2V();
|
|
11879
11879
|
var chunkP3Q73CAW_cjs = require_chunk_P3Q73CAW();
|
|
11880
11880
|
var chunkRWTSGWWL_cjs = require_chunk_RWTSGWWL();
|
|
11881
11881
|
var _MastraVoice_decorators;
|
|
11882
11882
|
var _init;
|
|
11883
11883
|
var _a;
|
|
11884
|
-
_MastraVoice_decorators = [
|
|
11884
|
+
_MastraVoice_decorators = [chunkJDOKE3OQ_cjs.InstrumentClass({
|
|
11885
11885
|
prefix: "voice",
|
|
11886
11886
|
excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
|
|
11887
11887
|
})];
|
|
@@ -38787,14 +38787,14 @@ ${err.message}`);
|
|
|
38787
38787
|
}
|
|
38788
38788
|
});
|
|
38789
38789
|
|
|
38790
|
-
// ../../packages/core/dist/chunk-
|
|
38791
|
-
var
|
|
38792
|
-
"../../packages/core/dist/chunk-
|
|
38793
|
-
var
|
|
38790
|
+
// ../../packages/core/dist/chunk-DHQAWCO4.cjs
|
|
38791
|
+
var require_chunk_DHQAWCO4 = __commonJS({
|
|
38792
|
+
"../../packages/core/dist/chunk-DHQAWCO4.cjs"(exports2) {
|
|
38793
|
+
var chunk6U377XOJ_cjs = require_chunk_6U377XOJ();
|
|
38794
38794
|
var chunkTGK6JO2D_cjs = require_chunk_TGK6JO2D();
|
|
38795
38795
|
var chunkST5RMVLG_cjs = require_chunk_ST5RMVLG();
|
|
38796
38796
|
var chunkHVI3SKIH_cjs = require_chunk_HVI3SKIH();
|
|
38797
|
-
var
|
|
38797
|
+
var chunkJDOKE3OQ_cjs = require_chunk_JDOKE3OQ();
|
|
38798
38798
|
var chunkJ7MLMW6O_cjs = require_chunk_J7MLMW6O();
|
|
38799
38799
|
var chunkOLSQRA2V_cjs = require_chunk_OLSQRA2V();
|
|
38800
38800
|
var chunkP3Q73CAW_cjs = require_chunk_P3Q73CAW();
|
|
@@ -38856,7 +38856,7 @@ var require_chunk_QQT4XTOG = __commonJS({
|
|
|
38856
38856
|
var _Agent_decorators;
|
|
38857
38857
|
var _init;
|
|
38858
38858
|
var _a;
|
|
38859
|
-
_Agent_decorators = [
|
|
38859
|
+
_Agent_decorators = [chunkJDOKE3OQ_cjs.InstrumentClass({
|
|
38860
38860
|
prefix: "agent",
|
|
38861
38861
|
excludeMethods: ["hasOwnMemory", "getMemory", "__primitive", "__registerMastra", "__registerPrimitives", "__setTools", "__setLogger", "__setTelemetry", "log", "getModel", "getInstructions", "getTools", "getLLM", "getWorkflows", "getDefaultGenerateOptions", "getDefaultStreamOptions", "getDescription"]
|
|
38862
38862
|
})];
|
|
@@ -38934,7 +38934,7 @@ var require_chunk_QQT4XTOG = __commonJS({
|
|
|
38934
38934
|
this.#voice?.addInstructions(config.instructions);
|
|
38935
38935
|
}
|
|
38936
38936
|
} else {
|
|
38937
|
-
this.#voice = new
|
|
38937
|
+
this.#voice = new chunk6U377XOJ_cjs.DefaultVoice();
|
|
38938
38938
|
}
|
|
38939
38939
|
}
|
|
38940
38940
|
hasOwnMemory() {
|
|
@@ -38998,7 +38998,7 @@ var require_chunk_QQT4XTOG = __commonJS({
|
|
|
38998
38998
|
}));
|
|
38999
38999
|
return voice;
|
|
39000
39000
|
} else {
|
|
39001
|
-
return new
|
|
39001
|
+
return new chunk6U377XOJ_cjs.DefaultVoice();
|
|
39002
39002
|
}
|
|
39003
39003
|
}
|
|
39004
39004
|
get instructions() {
|
|
@@ -40120,6 +40120,8 @@ ${JSON.stringify(
|
|
|
40120
40120
|
telemetry,
|
|
40121
40121
|
memory: this.getMemory(),
|
|
40122
40122
|
runtimeContext,
|
|
40123
|
+
threadId,
|
|
40124
|
+
resourceId,
|
|
40123
40125
|
...args
|
|
40124
40126
|
});
|
|
40125
40127
|
const newStreamResult = streamResult;
|
|
@@ -40162,6 +40164,8 @@ ${JSON.stringify(
|
|
|
40162
40164
|
telemetry,
|
|
40163
40165
|
memory: this.getMemory(),
|
|
40164
40166
|
runtimeContext,
|
|
40167
|
+
threadId,
|
|
40168
|
+
resourceId,
|
|
40165
40169
|
...args
|
|
40166
40170
|
});
|
|
40167
40171
|
}
|
|
@@ -40201,6 +40205,8 @@ ${JSON.stringify(
|
|
|
40201
40205
|
telemetry,
|
|
40202
40206
|
memory: this.getMemory(),
|
|
40203
40207
|
runtimeContext,
|
|
40208
|
+
threadId,
|
|
40209
|
+
resourceId,
|
|
40204
40210
|
...args
|
|
40205
40211
|
});
|
|
40206
40212
|
}
|
|
@@ -43327,12 +43333,12 @@ ${JSON.stringify(
|
|
|
43327
43333
|
// ../../packages/core/dist/agent/index.cjs
|
|
43328
43334
|
var require_agent = __commonJS({
|
|
43329
43335
|
"../../packages/core/dist/agent/index.cjs"(exports2) {
|
|
43330
|
-
var
|
|
43336
|
+
var chunkDHQAWCO4_cjs = require_chunk_DHQAWCO4();
|
|
43331
43337
|
var chunkTGK6JO2D_cjs = require_chunk_TGK6JO2D();
|
|
43332
43338
|
Object.defineProperty(exports2, "Agent", {
|
|
43333
43339
|
enumerable: true,
|
|
43334
43340
|
get: function() {
|
|
43335
|
-
return
|
|
43341
|
+
return chunkDHQAWCO4_cjs.Agent;
|
|
43336
43342
|
}
|
|
43337
43343
|
});
|
|
43338
43344
|
Object.defineProperty(exports2, "MessageList", {
|
|
@@ -44392,6 +44398,12 @@ var UpstashFilterTranslator = class extends BaseFilterTranslator {
|
|
|
44392
44398
|
// src/vector/index.ts
|
|
44393
44399
|
var UpstashVector = class extends MastraVector {
|
|
44394
44400
|
client;
|
|
44401
|
+
/**
|
|
44402
|
+
* Creates a new UpstashVector instance.
|
|
44403
|
+
* @param {object} params - The parameters for the UpstashVector.
|
|
44404
|
+
* @param {string} params.url - The URL of the Upstash vector index.
|
|
44405
|
+
* @param {string} params.token - The token for the Upstash vector index.
|
|
44406
|
+
*/
|
|
44395
44407
|
constructor({ url, token }) {
|
|
44396
44408
|
super();
|
|
44397
44409
|
this.client = new Index({
|
|
@@ -44399,7 +44411,12 @@ var UpstashVector = class extends MastraVector {
|
|
|
44399
44411
|
token
|
|
44400
44412
|
});
|
|
44401
44413
|
}
|
|
44402
|
-
|
|
44414
|
+
/**
|
|
44415
|
+
* Upserts vectors into the index.
|
|
44416
|
+
* @param {UpsertVectorParams} params - The parameters for the upsert operation.
|
|
44417
|
+
* @returns {Promise<string[]>} A promise that resolves to the IDs of the upserted vectors.
|
|
44418
|
+
*/
|
|
44419
|
+
async upsert({ indexName: namespace, vectors, metadata, ids }) {
|
|
44403
44420
|
const generatedIds = ids || vectors.map(() => crypto.randomUUID());
|
|
44404
44421
|
const points = vectors.map((vector, index) => ({
|
|
44405
44422
|
id: generatedIds[index],
|
|
@@ -44407,25 +44424,40 @@ var UpstashVector = class extends MastraVector {
|
|
|
44407
44424
|
metadata: metadata?.[index]
|
|
44408
44425
|
}));
|
|
44409
44426
|
await this.client.upsert(points, {
|
|
44410
|
-
namespace
|
|
44427
|
+
namespace
|
|
44411
44428
|
});
|
|
44412
44429
|
return generatedIds;
|
|
44413
44430
|
}
|
|
44431
|
+
/**
|
|
44432
|
+
* Transforms a Mastra vector filter into an Upstash-compatible filter string.
|
|
44433
|
+
* @param {VectorFilter} [filter] - The filter to transform.
|
|
44434
|
+
* @returns {string | undefined} The transformed filter string, or undefined if no filter is provided.
|
|
44435
|
+
*/
|
|
44414
44436
|
transformFilter(filter) {
|
|
44415
44437
|
const translator = new UpstashFilterTranslator();
|
|
44416
44438
|
return translator.translate(filter);
|
|
44417
44439
|
}
|
|
44440
|
+
/**
|
|
44441
|
+
* Creates a new index. For Upstash, this is a no-op as indexes (known as namespaces in Upstash) are created on-the-fly.
|
|
44442
|
+
* @param {CreateIndexParams} _params - The parameters for creating the index (ignored).
|
|
44443
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
44444
|
+
*/
|
|
44418
44445
|
async createIndex(_params) {
|
|
44419
|
-
|
|
44446
|
+
this.logger.debug("No need to call createIndex for Upstash");
|
|
44420
44447
|
}
|
|
44448
|
+
/**
|
|
44449
|
+
* Queries the vector index.
|
|
44450
|
+
* @param {QueryVectorParams} params - The parameters for the query operation. indexName is the namespace in Upstash.
|
|
44451
|
+
* @returns {Promise<QueryResult[]>} A promise that resolves to the query results.
|
|
44452
|
+
*/
|
|
44421
44453
|
async query({
|
|
44422
|
-
indexName,
|
|
44454
|
+
indexName: namespace,
|
|
44423
44455
|
queryVector,
|
|
44424
44456
|
topK = 10,
|
|
44425
44457
|
filter,
|
|
44426
44458
|
includeVector = false
|
|
44427
44459
|
}) {
|
|
44428
|
-
const ns = this.client.namespace(
|
|
44460
|
+
const ns = this.client.namespace(namespace);
|
|
44429
44461
|
const filterString = this.transformFilter(filter);
|
|
44430
44462
|
const results = await ns.query({
|
|
44431
44463
|
topK,
|
|
@@ -44441,6 +44473,10 @@ var UpstashVector = class extends MastraVector {
|
|
|
44441
44473
|
...includeVector && { vector: result.vector || [] }
|
|
44442
44474
|
}));
|
|
44443
44475
|
}
|
|
44476
|
+
/**
|
|
44477
|
+
* Lists all namespaces in the Upstash vector index, which correspond to indexes.
|
|
44478
|
+
* @returns {Promise<string[]>} A promise that resolves to a list of index names.
|
|
44479
|
+
*/
|
|
44444
44480
|
async listIndexes() {
|
|
44445
44481
|
const indexes = await this.client.listNamespaces();
|
|
44446
44482
|
return indexes.filter(Boolean);
|
|
@@ -44448,27 +44484,32 @@ var UpstashVector = class extends MastraVector {
|
|
|
44448
44484
|
/**
|
|
44449
44485
|
* Retrieves statistics about a vector index.
|
|
44450
44486
|
*
|
|
44451
|
-
* @param {string} indexName - The name of the
|
|
44487
|
+
* @param {string} indexName - The name of the namespace to describe
|
|
44452
44488
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
44453
44489
|
*/
|
|
44454
|
-
async describeIndex({ indexName }) {
|
|
44490
|
+
async describeIndex({ indexName: namespace }) {
|
|
44455
44491
|
const info = await this.client.info();
|
|
44456
44492
|
return {
|
|
44457
44493
|
dimension: info.dimension,
|
|
44458
|
-
count: info.namespaces?.[
|
|
44494
|
+
count: info.namespaces?.[namespace]?.vectorCount || 0,
|
|
44459
44495
|
metric: info?.similarityFunction?.toLowerCase()
|
|
44460
44496
|
};
|
|
44461
44497
|
}
|
|
44462
|
-
|
|
44498
|
+
/**
|
|
44499
|
+
* Deletes an index (namespace).
|
|
44500
|
+
* @param {DeleteIndexParams} params - The parameters for the delete operation.
|
|
44501
|
+
* @returns {Promise<void>} A promise that resolves when the deletion is complete.
|
|
44502
|
+
*/
|
|
44503
|
+
async deleteIndex({ indexName: namespace }) {
|
|
44463
44504
|
try {
|
|
44464
|
-
await this.client.deleteNamespace(
|
|
44505
|
+
await this.client.deleteNamespace(namespace);
|
|
44465
44506
|
} catch (error) {
|
|
44466
|
-
|
|
44507
|
+
this.logger.error("Failed to delete namespace:", error);
|
|
44467
44508
|
}
|
|
44468
44509
|
}
|
|
44469
44510
|
/**
|
|
44470
44511
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
44471
|
-
* @param indexName - The name of the
|
|
44512
|
+
* @param indexName - The name of the namespace containing the vector.
|
|
44472
44513
|
* @param id - The ID of the vector to update.
|
|
44473
44514
|
* @param update - An object containing the vector and/or metadata to update.
|
|
44474
44515
|
* @param update.vector - An optional array of numbers representing the new vector.
|
|
@@ -44476,7 +44517,7 @@ var UpstashVector = class extends MastraVector {
|
|
|
44476
44517
|
* @returns A promise that resolves when the update is complete.
|
|
44477
44518
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
44478
44519
|
*/
|
|
44479
|
-
async updateVector({ indexName, id, update }) {
|
|
44520
|
+
async updateVector({ indexName: namespace, id, update }) {
|
|
44480
44521
|
try {
|
|
44481
44522
|
if (!update.vector && !update.metadata) {
|
|
44482
44523
|
throw new Error("No update data provided");
|
|
@@ -44497,26 +44538,26 @@ var UpstashVector = class extends MastraVector {
|
|
|
44497
44538
|
metadata: updatePayload.metadata
|
|
44498
44539
|
};
|
|
44499
44540
|
await this.client.upsert(points, {
|
|
44500
|
-
namespace
|
|
44541
|
+
namespace
|
|
44501
44542
|
});
|
|
44502
44543
|
} catch (error) {
|
|
44503
|
-
throw new Error(`Failed to update vector by id: ${id} for index name: ${
|
|
44544
|
+
throw new Error(`Failed to update vector by id: ${id} for index name: ${namespace}: ${error.message}`);
|
|
44504
44545
|
}
|
|
44505
44546
|
}
|
|
44506
44547
|
/**
|
|
44507
44548
|
* Deletes a vector by its ID.
|
|
44508
|
-
* @param indexName - The name of the
|
|
44549
|
+
* @param indexName - The name of the namespace containing the vector.
|
|
44509
44550
|
* @param id - The ID of the vector to delete.
|
|
44510
44551
|
* @returns A promise that resolves when the deletion is complete.
|
|
44511
44552
|
* @throws Will throw an error if the deletion operation fails.
|
|
44512
44553
|
*/
|
|
44513
|
-
async deleteVector({ indexName, id }) {
|
|
44554
|
+
async deleteVector({ indexName: namespace, id }) {
|
|
44514
44555
|
try {
|
|
44515
44556
|
await this.client.delete(id, {
|
|
44516
|
-
namespace
|
|
44557
|
+
namespace
|
|
44517
44558
|
});
|
|
44518
44559
|
} catch (error) {
|
|
44519
|
-
|
|
44560
|
+
this.logger.error(`Failed to delete vector by id: ${id} for namespace: ${namespace}:`, error);
|
|
44520
44561
|
}
|
|
44521
44562
|
}
|
|
44522
44563
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/upstash",
|
|
3
|
-
"version": "0.11.0-alpha.
|
|
3
|
+
"version": "0.11.0-alpha.1",
|
|
4
4
|
"description": "Upstash provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"vitest": "^3.2.3",
|
|
34
34
|
"@internal/storage-test-utils": "0.0.8",
|
|
35
35
|
"@internal/lint": "0.0.12",
|
|
36
|
-
"@mastra/core": "0.10.6-alpha.
|
|
36
|
+
"@mastra/core": "0.10.6-alpha.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@mastra/core": ">=0.10.4-0 <0.11.0"
|
package/src/vector/index.ts
CHANGED
|
@@ -18,6 +18,12 @@ import { UpstashFilterTranslator } from './filter';
|
|
|
18
18
|
export class UpstashVector extends MastraVector {
|
|
19
19
|
private client: Index;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new UpstashVector instance.
|
|
23
|
+
* @param {object} params - The parameters for the UpstashVector.
|
|
24
|
+
* @param {string} params.url - The URL of the Upstash vector index.
|
|
25
|
+
* @param {string} params.token - The token for the Upstash vector index.
|
|
26
|
+
*/
|
|
21
27
|
constructor({ url, token }: { url: string; token: string }) {
|
|
22
28
|
super();
|
|
23
29
|
this.client = new Index({
|
|
@@ -26,7 +32,12 @@ export class UpstashVector extends MastraVector {
|
|
|
26
32
|
});
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Upserts vectors into the index.
|
|
37
|
+
* @param {UpsertVectorParams} params - The parameters for the upsert operation.
|
|
38
|
+
* @returns {Promise<string[]>} A promise that resolves to the IDs of the upserted vectors.
|
|
39
|
+
*/
|
|
40
|
+
async upsert({ indexName: namespace, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]> {
|
|
30
41
|
const generatedIds = ids || vectors.map(() => crypto.randomUUID());
|
|
31
42
|
|
|
32
43
|
const points = vectors.map((vector, index) => ({
|
|
@@ -36,28 +47,43 @@ export class UpstashVector extends MastraVector {
|
|
|
36
47
|
}));
|
|
37
48
|
|
|
38
49
|
await this.client.upsert(points, {
|
|
39
|
-
namespace
|
|
50
|
+
namespace,
|
|
40
51
|
});
|
|
41
52
|
return generatedIds;
|
|
42
53
|
}
|
|
43
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Transforms a Mastra vector filter into an Upstash-compatible filter string.
|
|
57
|
+
* @param {VectorFilter} [filter] - The filter to transform.
|
|
58
|
+
* @returns {string | undefined} The transformed filter string, or undefined if no filter is provided.
|
|
59
|
+
*/
|
|
44
60
|
transformFilter(filter?: VectorFilter) {
|
|
45
61
|
const translator = new UpstashFilterTranslator();
|
|
46
62
|
return translator.translate(filter);
|
|
47
63
|
}
|
|
48
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new index. For Upstash, this is a no-op as indexes (known as namespaces in Upstash) are created on-the-fly.
|
|
67
|
+
* @param {CreateIndexParams} _params - The parameters for creating the index (ignored).
|
|
68
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
69
|
+
*/
|
|
49
70
|
async createIndex(_params: CreateIndexParams): Promise<void> {
|
|
50
|
-
|
|
71
|
+
this.logger.debug('No need to call createIndex for Upstash');
|
|
51
72
|
}
|
|
52
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Queries the vector index.
|
|
76
|
+
* @param {QueryVectorParams} params - The parameters for the query operation. indexName is the namespace in Upstash.
|
|
77
|
+
* @returns {Promise<QueryResult[]>} A promise that resolves to the query results.
|
|
78
|
+
*/
|
|
53
79
|
async query({
|
|
54
|
-
indexName,
|
|
80
|
+
indexName: namespace,
|
|
55
81
|
queryVector,
|
|
56
82
|
topK = 10,
|
|
57
83
|
filter,
|
|
58
84
|
includeVector = false,
|
|
59
85
|
}: QueryVectorParams): Promise<QueryResult[]> {
|
|
60
|
-
const ns = this.client.namespace(
|
|
86
|
+
const ns = this.client.namespace(namespace);
|
|
61
87
|
|
|
62
88
|
const filterString = this.transformFilter(filter);
|
|
63
89
|
const results = await ns.query({
|
|
@@ -77,6 +103,10 @@ export class UpstashVector extends MastraVector {
|
|
|
77
103
|
}));
|
|
78
104
|
}
|
|
79
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Lists all namespaces in the Upstash vector index, which correspond to indexes.
|
|
108
|
+
* @returns {Promise<string[]>} A promise that resolves to a list of index names.
|
|
109
|
+
*/
|
|
80
110
|
async listIndexes(): Promise<string[]> {
|
|
81
111
|
const indexes = await this.client.listNamespaces();
|
|
82
112
|
return indexes.filter(Boolean);
|
|
@@ -85,30 +115,35 @@ export class UpstashVector extends MastraVector {
|
|
|
85
115
|
/**
|
|
86
116
|
* Retrieves statistics about a vector index.
|
|
87
117
|
*
|
|
88
|
-
* @param {string} indexName - The name of the
|
|
118
|
+
* @param {string} indexName - The name of the namespace to describe
|
|
89
119
|
* @returns A promise that resolves to the index statistics including dimension, count and metric
|
|
90
120
|
*/
|
|
91
|
-
async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {
|
|
121
|
+
async describeIndex({ indexName: namespace }: DescribeIndexParams): Promise<IndexStats> {
|
|
92
122
|
const info = await this.client.info();
|
|
93
123
|
|
|
94
124
|
return {
|
|
95
125
|
dimension: info.dimension,
|
|
96
|
-
count: info.namespaces?.[
|
|
126
|
+
count: info.namespaces?.[namespace]?.vectorCount || 0,
|
|
97
127
|
metric: info?.similarityFunction?.toLowerCase() as 'cosine' | 'euclidean' | 'dotproduct',
|
|
98
128
|
};
|
|
99
129
|
}
|
|
100
130
|
|
|
101
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Deletes an index (namespace).
|
|
133
|
+
* @param {DeleteIndexParams} params - The parameters for the delete operation.
|
|
134
|
+
* @returns {Promise<void>} A promise that resolves when the deletion is complete.
|
|
135
|
+
*/
|
|
136
|
+
async deleteIndex({ indexName: namespace }: DeleteIndexParams): Promise<void> {
|
|
102
137
|
try {
|
|
103
|
-
await this.client.deleteNamespace(
|
|
138
|
+
await this.client.deleteNamespace(namespace);
|
|
104
139
|
} catch (error) {
|
|
105
|
-
|
|
140
|
+
this.logger.error('Failed to delete namespace:', error);
|
|
106
141
|
}
|
|
107
142
|
}
|
|
108
143
|
|
|
109
144
|
/**
|
|
110
145
|
* Updates a vector by its ID with the provided vector and/or metadata.
|
|
111
|
-
* @param indexName - The name of the
|
|
146
|
+
* @param indexName - The name of the namespace containing the vector.
|
|
112
147
|
* @param id - The ID of the vector to update.
|
|
113
148
|
* @param update - An object containing the vector and/or metadata to update.
|
|
114
149
|
* @param update.vector - An optional array of numbers representing the new vector.
|
|
@@ -116,7 +151,7 @@ export class UpstashVector extends MastraVector {
|
|
|
116
151
|
* @returns A promise that resolves when the update is complete.
|
|
117
152
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
118
153
|
*/
|
|
119
|
-
async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {
|
|
154
|
+
async updateVector({ indexName: namespace, id, update }: UpdateVectorParams): Promise<void> {
|
|
120
155
|
try {
|
|
121
156
|
if (!update.vector && !update.metadata) {
|
|
122
157
|
throw new Error('No update data provided');
|
|
@@ -143,27 +178,27 @@ export class UpstashVector extends MastraVector {
|
|
|
143
178
|
};
|
|
144
179
|
|
|
145
180
|
await this.client.upsert(points, {
|
|
146
|
-
namespace
|
|
181
|
+
namespace,
|
|
147
182
|
});
|
|
148
183
|
} catch (error: any) {
|
|
149
|
-
throw new Error(`Failed to update vector by id: ${id} for index name: ${
|
|
184
|
+
throw new Error(`Failed to update vector by id: ${id} for index name: ${namespace}: ${error.message}`);
|
|
150
185
|
}
|
|
151
186
|
}
|
|
152
187
|
|
|
153
188
|
/**
|
|
154
189
|
* Deletes a vector by its ID.
|
|
155
|
-
* @param indexName - The name of the
|
|
190
|
+
* @param indexName - The name of the namespace containing the vector.
|
|
156
191
|
* @param id - The ID of the vector to delete.
|
|
157
192
|
* @returns A promise that resolves when the deletion is complete.
|
|
158
193
|
* @throws Will throw an error if the deletion operation fails.
|
|
159
194
|
*/
|
|
160
|
-
async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {
|
|
195
|
+
async deleteVector({ indexName: namespace, id }: DeleteVectorParams): Promise<void> {
|
|
161
196
|
try {
|
|
162
197
|
await this.client.delete(id, {
|
|
163
|
-
namespace
|
|
198
|
+
namespace,
|
|
164
199
|
});
|
|
165
200
|
} catch (error) {
|
|
166
|
-
|
|
201
|
+
this.logger.error(`Failed to delete vector by id: ${id} for namespace: ${namespace}:`, error);
|
|
167
202
|
}
|
|
168
203
|
}
|
|
169
204
|
}
|