@mastra/upstash 1.5.5 → 1.6.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.
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/{reference-vectors-upstash.md → integrations-vectors-upstash.md} +12 -0
- package/dist/docs/references/reference-rag-vector-databases.md +3 -3
- package/dist/index.cjs +16 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +1 -0
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-upstash
|
|
|
3
3
|
description: Documentation for @mastra/upstash. Use when working with @mastra/upstash APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/upstash"
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.6.0-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -21,12 +21,12 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
21
21
|
### Integrations
|
|
22
22
|
|
|
23
23
|
- [Upstash](references/integrations-databases-upstash.md) - Use Upstash Redis as serverless Mastra storage with REST credentials, namespaced keys, durable persistence, and deployment-friendly connections.
|
|
24
|
+
- [Upstash](references/integrations-vectors-upstash.md) - Run serverless vector and hybrid search from Mastra with Upstash Vector, including metadata filtering and automatic index creation.
|
|
24
25
|
|
|
25
26
|
### Reference
|
|
26
27
|
|
|
27
28
|
- [Retrieval, semantic search, reranking](references/reference-rag-retrieval.md) - After storing embeddings, you need to retrieve relevant chunks to answer user queries.
|
|
28
29
|
- [Storing embeddings in a vector database](references/reference-rag-vector-databases.md) - After generating embeddings, you need to store them in a database that supports vector similarity search.
|
|
29
|
-
- [Reference: Upstash vector store](references/reference-vectors-upstash.md) - Configure UpstashVector for serverless similarity and hybrid search, metadata filtering, index management, and vector operations with Upstash Vector.
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
package/dist/docs/references/{reference-vectors-upstash.md → integrations-vectors-upstash.md}
RENAMED
|
@@ -104,6 +104,18 @@ The `update` object can have the following properties:
|
|
|
104
104
|
|
|
105
105
|
Attempts to delete an item by its ID from the specified index. Logs an error message if the deletion fails.
|
|
106
106
|
|
|
107
|
+
### `deleteVectors()`
|
|
108
|
+
|
|
109
|
+
Delete multiple vectors by IDs or by metadata filter. Either `ids` or `filter` must be provided, but not both, and neither can be empty.
|
|
110
|
+
|
|
111
|
+
Filter deletion runs one approximate query with `topK: 1000` and deletes the returned IDs. `deleteVectors()` returns `Promise<void>` and does not report how many vectors it deleted, so repeating the call cannot guarantee complete deletion. Use [Upstash's filter-delete API](https://upstash.com/docs/vector/api/endpoints/delete) when complete filter deletion is required. Deleting by `ids` isn't subject to this query limit.
|
|
112
|
+
|
|
113
|
+
**indexName** (`string`): Namespace to delete from
|
|
114
|
+
|
|
115
|
+
**ids** (`string[]`): Array of vector IDs to delete (mutually exclusive with filter)
|
|
116
|
+
|
|
117
|
+
**filter** (`Record<string, any>`): Metadata filter to identify vectors to delete (mutually exclusive with ids). Only the first 1,000 matches are deleted
|
|
118
|
+
|
|
107
119
|
## Hybrid vector search
|
|
108
120
|
|
|
109
121
|
Upstash Vector supports hybrid search that combines semantic search (dense vectors) with keyword-based search (sparse vectors) for improved relevance and accuracy.
|
|
@@ -35,7 +35,7 @@ MongoDB Vector Search is a good solution for teams who want to consolidate vecto
|
|
|
35
35
|
|
|
36
36
|
### Using VoyageAI with MongoDB
|
|
37
37
|
|
|
38
|
-
MongoDB works directly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/
|
|
38
|
+
MongoDB works directly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb).
|
|
39
39
|
|
|
40
40
|
### Hybrid Search (Vector + Full-Text)
|
|
41
41
|
|
|
@@ -52,7 +52,7 @@ const results = await store.hybridQuery({
|
|
|
52
52
|
})
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
See the [MongoDB vector reference](https://mastra.ai/
|
|
55
|
+
See the [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb) for details on `createSearchIndex()`, `textQuery()`, and `hybridQuery()`.
|
|
56
56
|
|
|
57
57
|
### Automated Embedding
|
|
58
58
|
|
|
@@ -75,7 +75,7 @@ const results = await store.query({
|
|
|
75
75
|
})
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Automated Embedding is a MongoDB Preview feature and needs a deployment where it's available. See the [MongoDB vector reference](https://mastra.ai/
|
|
78
|
+
Automated Embedding is a MongoDB Preview feature and needs a deployment where it's available. See the [MongoDB vector reference](https://mastra.ai/integrations/vectors/mongodb) for the supported options and requirements.
|
|
79
79
|
|
|
80
80
|
**PgVector**:
|
|
81
81
|
|
package/dist/index.cjs
CHANGED
|
@@ -187,7 +187,9 @@ function toStorageRecord(task) {
|
|
|
187
187
|
suspendedAt: task.suspendedAt?.toISOString() ?? null,
|
|
188
188
|
completedAt: task.completedAt?.toISOString() ?? null,
|
|
189
189
|
ownerId: task.ownerId ?? null,
|
|
190
|
-
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
|
|
190
|
+
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null,
|
|
191
|
+
expiresAt: task.expiresAt?.toISOString() ?? null,
|
|
192
|
+
metadata: task.metadata ?? null
|
|
191
193
|
};
|
|
192
194
|
}
|
|
193
195
|
function fromStorageRecord(record) {
|
|
@@ -212,10 +214,13 @@ function fromStorageRecord(record) {
|
|
|
212
214
|
suspendedAt: record.suspendedAt ? new Date(record.suspendedAt) : void 0,
|
|
213
215
|
completedAt: record.completedAt ? new Date(record.completedAt) : void 0,
|
|
214
216
|
ownerId: record.ownerId ?? void 0,
|
|
215
|
-
leaseExpiresAt: record.leaseExpiresAt ? new Date(record.leaseExpiresAt) : void 0
|
|
217
|
+
leaseExpiresAt: record.leaseExpiresAt ? new Date(record.leaseExpiresAt) : void 0,
|
|
218
|
+
expiresAt: record.expiresAt ? new Date(record.expiresAt) : void 0,
|
|
219
|
+
metadata: record.metadata ?? void 0
|
|
216
220
|
};
|
|
217
221
|
}
|
|
218
222
|
var BackgroundTasksUpstash = class extends _mastra_core_storage.BackgroundTasksStorage {
|
|
223
|
+
supportsTaskExpiry = true;
|
|
219
224
|
client;
|
|
220
225
|
#db;
|
|
221
226
|
constructor(config) {
|
|
@@ -244,6 +249,8 @@ var BackgroundTasksUpstash = class extends _mastra_core_storage.BackgroundTasksS
|
|
|
244
249
|
if ("completedAt" in update) patch.completedAt = update.completedAt?.toISOString() ?? null;
|
|
245
250
|
if ("ownerId" in update) patch.ownerId = update.ownerId ?? null;
|
|
246
251
|
if ("leaseExpiresAt" in update) patch.leaseExpiresAt = update.leaseExpiresAt?.toISOString() ?? null;
|
|
252
|
+
if ("expiresAt" in update) patch.expiresAt = update.expiresAt?.toISOString() ?? null;
|
|
253
|
+
if ("metadata" in update) patch.metadata = update.metadata ?? null;
|
|
247
254
|
if (Object.keys(patch).length === 0) return false;
|
|
248
255
|
const key = getKey(_mastra_core_storage.TABLE_BACKGROUND_TASKS, { id: taskId });
|
|
249
256
|
const result = await this.client.eval(`
|
|
@@ -261,6 +268,9 @@ var BackgroundTasksUpstash = class extends _mastra_core_storage.BackgroundTasksS
|
|
|
261
268
|
if ARGV[5] == '1' then
|
|
262
269
|
if normalize(record.leaseExpiresAt) ~= normalize(cjson.decode(ARGV[6])) then return 0 end
|
|
263
270
|
end
|
|
271
|
+
if ARGV[7] == '1' then
|
|
272
|
+
if normalize(record.suspendedAt) ~= normalize(cjson.decode(ARGV[8])) then return 0 end
|
|
273
|
+
end
|
|
264
274
|
local patch = cjson.decode(ARGV[2])
|
|
265
275
|
for field, value in pairs(patch) do record[field] = value end
|
|
266
276
|
redis.call('SET', KEYS[1], cjson.encode(record))
|
|
@@ -271,7 +281,9 @@ var BackgroundTasksUpstash = class extends _mastra_core_storage.BackgroundTasksS
|
|
|
271
281
|
options?.expectedOwnerId !== void 0 ? "1" : "0",
|
|
272
282
|
JSON.stringify(options?.expectedOwnerId ?? null),
|
|
273
283
|
options?.expectedLeaseExpiresAt !== void 0 ? "1" : "0",
|
|
274
|
-
JSON.stringify(options?.expectedLeaseExpiresAt?.toISOString() ?? null)
|
|
284
|
+
JSON.stringify(options?.expectedLeaseExpiresAt?.toISOString() ?? null),
|
|
285
|
+
options?.expectedSuspendedAt !== void 0 ? "1" : "0",
|
|
286
|
+
JSON.stringify(options?.expectedSuspendedAt?.toISOString() ?? null)
|
|
275
287
|
]);
|
|
276
288
|
return Number(result) === 1;
|
|
277
289
|
}
|
|
@@ -298,6 +310,7 @@ var BackgroundTasksUpstash = class extends _mastra_core_storage.BackgroundTasksS
|
|
|
298
310
|
if (filter.threadId) tasks = tasks.filter((t) => t.threadId === filter.threadId);
|
|
299
311
|
if (filter.resourceId) tasks = tasks.filter((t) => t.resourceId === filter.resourceId);
|
|
300
312
|
if (filter.runId) tasks = tasks.filter((t) => t.runId === filter.runId);
|
|
313
|
+
if (filter.hasExpiresAt !== void 0) tasks = tasks.filter((t) => t.expiresAt != null === filter.hasExpiresAt);
|
|
301
314
|
if (filter.toolName) tasks = tasks.filter((t) => t.toolName === filter.toolName);
|
|
302
315
|
if (filter.toolCallId) tasks = tasks.filter((t) => t.toolCallId === filter.toolCallId);
|
|
303
316
|
const dateCol = filter.dateFilterBy ?? "createdAt";
|