@mastra/upstash 1.5.4-alpha.0 → 1.5.5-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 +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +3 -3
- package/dist/docs/references/integrations-databases-upstash.md +1 -1
- package/dist/docs/references/reference-rag-retrieval.md +13 -13
- package/dist/docs/references/reference-vectors-upstash.md +1 -1
- package/dist/index.cjs +24 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -20
- package/dist/index.js.map +1 -1
- package/package.json +13 -14
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.5.
|
|
6
|
+
version: "1.5.5-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -34,7 +34,7 @@ const agent = new Agent({
|
|
|
34
34
|
id: 'personal-assistant',
|
|
35
35
|
name: 'PersonalAssistant',
|
|
36
36
|
instructions: 'You are a helpful personal assistant.',
|
|
37
|
-
model: 'openai/gpt-
|
|
37
|
+
model: 'openai/gpt-6.1-sol',
|
|
38
38
|
memory: new Memory({
|
|
39
39
|
options: {
|
|
40
40
|
workingMemory: {
|
|
@@ -217,7 +217,7 @@ const paragraphMemory = new Memory({
|
|
|
217
217
|
|
|
218
218
|
Working memory can also be defined using a structured schema instead of a Markdown template. A [Standard JSON Schema](https://standardschema.dev/json-schema) ([Zod](https://zod.dev/), [Valibot](https://valibot.dev/), [ArkType](https://arktype.io/), etc.). When using a schema, the agent will see and update working memory as a JSON object matching your schema.
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
You can specify either `template` or `schema`, but not both. If you omit both, Mastra uses the default working memory template.
|
|
221
221
|
|
|
222
222
|
### Example: Schema-Based Working Memory
|
|
223
223
|
|
|
@@ -418,7 +418,7 @@ const response = await agent.generate('What do you know about me?', {
|
|
|
418
418
|
|
|
419
419
|
## Opt in to state signals (experimental)
|
|
420
420
|
|
|
421
|
-
By default, working memory reaches the model as part of the system message. You can opt into delivering it as a [state signal](https://mastra.ai/docs/
|
|
421
|
+
By default, working memory reaches the model as part of the system message. You can opt into delivering it as a [state signal](https://mastra.ai/docs/signals/state-signals) instead by setting `useStateSignals: true`:
|
|
422
422
|
|
|
423
423
|
```typescript
|
|
424
424
|
const memory = new Memory({
|
|
@@ -107,7 +107,7 @@ export const upstashAgent = new Agent({
|
|
|
107
107
|
name: 'Upstash Agent',
|
|
108
108
|
instructions:
|
|
109
109
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
110
|
-
model: 'openai/gpt-
|
|
110
|
+
model: 'openai/gpt-6.1-sol',
|
|
111
111
|
memory: new Memory({
|
|
112
112
|
storage: new UpstashStore({
|
|
113
113
|
id: 'upstash-agent-storage',
|
|
@@ -386,7 +386,7 @@ import { MONGODB_PROMPT } from '@mastra/mongodb'
|
|
|
386
386
|
export const ragAgent = new Agent({
|
|
387
387
|
id: 'rag-agent',
|
|
388
388
|
name: 'RAG Agent',
|
|
389
|
-
model: 'openai/gpt-
|
|
389
|
+
model: 'openai/gpt-6.1-sol',
|
|
390
390
|
instructions: `
|
|
391
391
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
392
392
|
${MONGODB_PROMPT}
|
|
@@ -403,7 +403,7 @@ import { PGVECTOR_PROMPT } from '@mastra/pg'
|
|
|
403
403
|
export const ragAgent = new Agent({
|
|
404
404
|
id: 'rag-agent',
|
|
405
405
|
name: 'RAG Agent',
|
|
406
|
-
model: 'openai/gpt-
|
|
406
|
+
model: 'openai/gpt-6.1-sol',
|
|
407
407
|
instructions: `
|
|
408
408
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
409
409
|
${PGVECTOR_PROMPT}
|
|
@@ -420,7 +420,7 @@ import { PINECONE_PROMPT } from '@mastra/pinecone'
|
|
|
420
420
|
export const ragAgent = new Agent({
|
|
421
421
|
id: 'rag-agent',
|
|
422
422
|
name: 'RAG Agent',
|
|
423
|
-
model: 'openai/gpt-
|
|
423
|
+
model: 'openai/gpt-6.1-sol',
|
|
424
424
|
instructions: `
|
|
425
425
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
426
426
|
${PINECONE_PROMPT}
|
|
@@ -437,7 +437,7 @@ import { QDRANT_PROMPT } from '@mastra/qdrant'
|
|
|
437
437
|
export const ragAgent = new Agent({
|
|
438
438
|
id: 'rag-agent',
|
|
439
439
|
name: 'RAG Agent',
|
|
440
|
-
model: 'openai/gpt-
|
|
440
|
+
model: 'openai/gpt-6.1-sol',
|
|
441
441
|
instructions: `
|
|
442
442
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
443
443
|
${QDRANT_PROMPT}
|
|
@@ -454,7 +454,7 @@ import { CHROMA_PROMPT } from '@mastra/chroma'
|
|
|
454
454
|
export const ragAgent = new Agent({
|
|
455
455
|
id: 'rag-agent',
|
|
456
456
|
name: 'RAG Agent',
|
|
457
|
-
model: 'openai/gpt-
|
|
457
|
+
model: 'openai/gpt-6.1-sol',
|
|
458
458
|
instructions: `
|
|
459
459
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
460
460
|
${CHROMA_PROMPT}
|
|
@@ -471,7 +471,7 @@ import { ASTRA_PROMPT } from '@mastra/astra'
|
|
|
471
471
|
export const ragAgent = new Agent({
|
|
472
472
|
id: 'rag-agent',
|
|
473
473
|
name: 'RAG Agent',
|
|
474
|
-
model: 'openai/gpt-
|
|
474
|
+
model: 'openai/gpt-6.1-sol',
|
|
475
475
|
instructions: `
|
|
476
476
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
477
477
|
${ASTRA_PROMPT}
|
|
@@ -488,7 +488,7 @@ import { LIBSQL_PROMPT } from '@mastra/libsql'
|
|
|
488
488
|
export const ragAgent = new Agent({
|
|
489
489
|
id: 'rag-agent',
|
|
490
490
|
name: 'RAG Agent',
|
|
491
|
-
model: 'openai/gpt-
|
|
491
|
+
model: 'openai/gpt-6.1-sol',
|
|
492
492
|
instructions: `
|
|
493
493
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
494
494
|
${LIBSQL_PROMPT}
|
|
@@ -505,7 +505,7 @@ import { UPSTASH_PROMPT } from '@mastra/upstash'
|
|
|
505
505
|
export const ragAgent = new Agent({
|
|
506
506
|
id: 'rag-agent',
|
|
507
507
|
name: 'RAG Agent',
|
|
508
|
-
model: 'openai/gpt-
|
|
508
|
+
model: 'openai/gpt-6.1-sol',
|
|
509
509
|
instructions: `
|
|
510
510
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
511
511
|
${UPSTASH_PROMPT}
|
|
@@ -522,7 +522,7 @@ import { VECTORIZE_PROMPT } from '@mastra/vectorize'
|
|
|
522
522
|
export const ragAgent = new Agent({
|
|
523
523
|
id: 'rag-agent',
|
|
524
524
|
name: 'RAG Agent',
|
|
525
|
-
model: 'openai/gpt-
|
|
525
|
+
model: 'openai/gpt-6.1-sol',
|
|
526
526
|
instructions: `
|
|
527
527
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
528
528
|
${VECTORIZE_PROMPT}
|
|
@@ -539,7 +539,7 @@ import { OPENSEARCH_PROMPT } from '@mastra/opensearch'
|
|
|
539
539
|
export const ragAgent = new Agent({
|
|
540
540
|
id: 'rag-agent',
|
|
541
541
|
name: 'RAG Agent',
|
|
542
|
-
model: 'openai/gpt-
|
|
542
|
+
model: 'openai/gpt-6.1-sol',
|
|
543
543
|
instructions: `
|
|
544
544
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
545
545
|
${OPENSEARCH_PROMPT}
|
|
@@ -556,7 +556,7 @@ import { ORACLEDB_PROMPT } from '@mastra/oracledb'
|
|
|
556
556
|
export const ragAgent = new Agent({
|
|
557
557
|
id: 'rag-agent',
|
|
558
558
|
name: 'RAG Agent',
|
|
559
|
-
model: 'openai/gpt-
|
|
559
|
+
model: 'openai/gpt-6.1-sol',
|
|
560
560
|
instructions: `
|
|
561
561
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
562
562
|
${ORACLEDB_PROMPT}
|
|
@@ -573,7 +573,7 @@ import { S3VECTORS_PROMPT } from '@mastra/s3vectors'
|
|
|
573
573
|
export const ragAgent = new Agent({
|
|
574
574
|
id: 'rag-agent',
|
|
575
575
|
name: 'RAG Agent',
|
|
576
|
-
model: 'openai/gpt-
|
|
576
|
+
model: 'openai/gpt-6.1-sol',
|
|
577
577
|
instructions: `
|
|
578
578
|
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
579
579
|
${S3VECTORS_PROMPT}
|
|
@@ -605,7 +605,7 @@ const initialResults = await pgVector.query({
|
|
|
605
605
|
// Create a relevance scorer
|
|
606
606
|
const relevanceProvider = new MastraAgentRelevanceScorer(
|
|
607
607
|
'relevance-scorer',
|
|
608
|
-
'openai/gpt-
|
|
608
|
+
'openai/gpt-6.1-sol',
|
|
609
609
|
)
|
|
610
610
|
|
|
611
611
|
// Re-rank the results
|
|
@@ -275,7 +275,7 @@ export const upstashAgent = new Agent({
|
|
|
275
275
|
name: 'Upstash Agent',
|
|
276
276
|
instructions:
|
|
277
277
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
278
|
-
model: 'openai/gpt-
|
|
278
|
+
model: 'openai/gpt-6.1-sol',
|
|
279
279
|
memory: new Memory({
|
|
280
280
|
storage: new UpstashStore({
|
|
281
281
|
id: 'upstash-agent-storage',
|
package/dist/index.cjs
CHANGED
|
@@ -231,7 +231,8 @@ var BackgroundTasksUpstash = class extends _mastra_core_storage.BackgroundTasksS
|
|
|
231
231
|
await this.#db.deleteData({ tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS });
|
|
232
232
|
}
|
|
233
233
|
async createTask(task) {
|
|
234
|
-
const
|
|
234
|
+
const record = toStorageRecord(task);
|
|
235
|
+
const { key, processedRecord } = processRecord(_mastra_core_storage.TABLE_BACKGROUND_TASKS, record);
|
|
235
236
|
await this.client.set(key, processedRecord);
|
|
236
237
|
}
|
|
237
238
|
async updateTask(taskId, update, options) {
|
|
@@ -356,7 +357,7 @@ function runClaimKey(claims, runId) {
|
|
|
356
357
|
return `${claims}:run_id:${runId}`;
|
|
357
358
|
}
|
|
358
359
|
const RUN_FENCE_CONFLICT = "MASTRA_RUN_FENCE_CONFLICT";
|
|
359
|
-
const RUN_CLAIM_RETENTION_MS =
|
|
360
|
+
const RUN_CLAIM_RETENTION_MS = 6048e5;
|
|
360
361
|
const FENCE_GUARD = `
|
|
361
362
|
local fenceClaim = redis.call('HMGET', KEYS[#KEYS], 'generation', 'ownerId')
|
|
362
363
|
if tonumber(fenceClaim[1]) ~= tonumber(ARGV[#ARGV - 1]) or fenceClaim[2] ~= ARGV[#ARGV] then
|
|
@@ -1368,22 +1369,24 @@ var StoreMemoryUpstash = class extends _mastra_core_storage.MemoryStorage {
|
|
|
1368
1369
|
}
|
|
1369
1370
|
for (const key in fieldsToUpdate) if (Object.prototype.hasOwnProperty.call(fieldsToUpdate, key) && key !== "content") updatedMessage[key] = fieldsToUpdate[key];
|
|
1370
1371
|
const key = messageIdToKey[id];
|
|
1371
|
-
if (key)
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1372
|
+
if (key) {
|
|
1373
|
+
if (updatePayload.threadId && updatePayload.threadId !== existingMessage.threadId) {
|
|
1374
|
+
const newThreadId = updatedMessage.threadId;
|
|
1375
|
+
const oldThreadMessagesKey = getThreadMessagesKey(existingMessage.threadId);
|
|
1376
|
+
pipeline.zrem(oldThreadMessagesKey, id);
|
|
1377
|
+
pipeline.del(key);
|
|
1378
|
+
const newKey = getMessageKey(newThreadId, id);
|
|
1379
|
+
pipeline.set(newKey, updatedMessage);
|
|
1380
|
+
pipeline.set(getMessageIndexKey(id), newThreadId);
|
|
1381
|
+
messageIdToKey[id] = newKey;
|
|
1382
|
+
const newThreadMessagesKey = getThreadMessagesKey(newThreadId);
|
|
1383
|
+
const score = updatedMessage._index !== void 0 ? updatedMessage._index : new Date(updatedMessage.createdAt).getTime();
|
|
1384
|
+
pipeline.zadd(newThreadMessagesKey, {
|
|
1385
|
+
score,
|
|
1386
|
+
member: id
|
|
1387
|
+
});
|
|
1388
|
+
} else pipeline.set(key, updatedMessage);
|
|
1389
|
+
}
|
|
1387
1390
|
}
|
|
1388
1391
|
const now = /* @__PURE__ */ new Date();
|
|
1389
1392
|
for (const threadId of threadIdsToUpdate) if (threadId) {
|
|
@@ -1715,12 +1718,13 @@ var ScoresUpstash = class extends _mastra_core_storage.ScoresStorage {
|
|
|
1715
1718
|
const id = crypto.randomUUID();
|
|
1716
1719
|
const createdAt = now;
|
|
1717
1720
|
const updatedAt = now;
|
|
1718
|
-
const
|
|
1721
|
+
const scoreWithId = {
|
|
1719
1722
|
...validatedScore,
|
|
1720
1723
|
id,
|
|
1721
1724
|
createdAt,
|
|
1722
1725
|
updatedAt
|
|
1723
|
-
}
|
|
1726
|
+
};
|
|
1727
|
+
const { key, processedRecord } = processRecord(_mastra_core_storage.TABLE_SCORERS, scoreWithId);
|
|
1724
1728
|
try {
|
|
1725
1729
|
await this.client.set(key, processedRecord);
|
|
1726
1730
|
return { score: {
|