@mastra/upstash 1.5.3 → 1.5.4
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
CHANGED
|
@@ -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
|
|
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: {
|