@mastra/libsql 1.23.3 → 1.24.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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-overview.md +2 -2
- package/dist/index.cjs +32 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +2 -4
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/docs/SKILL.md
CHANGED
|
@@ -212,7 +212,7 @@ To go beyond this default isolation, you can share memory between agents by pass
|
|
|
212
212
|
|
|
213
213
|
When you call agents directly (outside the delegation flow), memory sharing is controlled by two identifiers: `resourceId` and `threadId`. Agents that use the same values read and write to the same data. This is useful when agents collaborate on a shared context, for example, a researcher that saves notes and a writer that reads them.
|
|
214
214
|
|
|
215
|
-
**Resource-scoped sharing** is the most common pattern. [Working memory](https://mastra.ai/docs/memory/working-memory) and [semantic recall](https://mastra.ai/docs/memory/semantic-recall) default to `scope: 'resource'`. If two agents share a `resourceId`, they share
|
|
215
|
+
**Resource-scoped sharing** is the most common pattern. [Working memory](https://mastra.ai/docs/memory/working-memory) and [semantic recall](https://mastra.ai/docs/memory/semantic-recall) default to `scope: 'resource'`. If two agents share a `resourceId`, they share working memory and embeddings, even across different threads:
|
|
216
216
|
|
|
217
217
|
```typescript
|
|
218
218
|
// Both agents share the same resource-scoped memory
|
|
@@ -225,7 +225,7 @@ await writer.generate('Write a summary from the research notes.', {
|
|
|
225
225
|
})
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
-
Because both calls use `resource: 'project-42'`, the writer can access the researcher's
|
|
228
|
+
Because both calls use `resource: 'project-42'`, the writer can access the researcher's working memory. Semantic embeddings are also shared through the resource. Each agent still has its own thread, so message histories stay separate.
|
|
229
229
|
|
|
230
230
|
**Thread-scoped sharing** gives tighter coupling. [Observational Memory](https://mastra.ai/docs/memory/observational-memory) uses `scope: 'thread'` by default. If two agents use the same `resource` and `thread`, they share the full message history. Each agent sees every message the other has written. This is useful when agents need to build on each other's exact outputs.
|
|
231
231
|
|
package/dist/index.cjs
CHANGED
|
@@ -2954,7 +2954,9 @@ function rowToTask(row) {
|
|
|
2954
2954
|
createdAt: new Date(String(row.createdAt)),
|
|
2955
2955
|
startedAt: row.startedAt ? new Date(String(row.startedAt)) : void 0,
|
|
2956
2956
|
suspendedAt: row.suspendedAt ? new Date(String(row.suspendedAt)) : void 0,
|
|
2957
|
-
completedAt: row.completedAt ? new Date(String(row.completedAt)) : void 0
|
|
2957
|
+
completedAt: row.completedAt ? new Date(String(row.completedAt)) : void 0,
|
|
2958
|
+
ownerId: row.ownerId != null ? String(row.ownerId) : void 0,
|
|
2959
|
+
leaseExpiresAt: row.leaseExpiresAt ? new Date(String(row.leaseExpiresAt)) : void 0
|
|
2958
2960
|
};
|
|
2959
2961
|
}
|
|
2960
2962
|
var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_storage.BackgroundTasksStorage {
|
|
@@ -2988,7 +2990,12 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
|
|
|
2988
2990
|
await this.#db.alterTable({
|
|
2989
2991
|
tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
|
|
2990
2992
|
schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS],
|
|
2991
|
-
ifNotExists: [
|
|
2993
|
+
ifNotExists: [
|
|
2994
|
+
"suspend_payload",
|
|
2995
|
+
"suspendedAt",
|
|
2996
|
+
"ownerId",
|
|
2997
|
+
"leaseExpiresAt"
|
|
2998
|
+
]
|
|
2992
2999
|
});
|
|
2993
3000
|
}
|
|
2994
3001
|
async dangerouslyClearAll() {
|
|
@@ -3031,7 +3038,9 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
|
|
|
3031
3038
|
createdAt: task.createdAt.toISOString(),
|
|
3032
3039
|
startedAt: task.startedAt?.toISOString() ?? null,
|
|
3033
3040
|
suspendedAt: task.suspendedAt?.toISOString() ?? null,
|
|
3034
|
-
completedAt: task.completedAt?.toISOString() ?? null
|
|
3041
|
+
completedAt: task.completedAt?.toISOString() ?? null,
|
|
3042
|
+
ownerId: task.ownerId ?? null,
|
|
3043
|
+
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
|
|
3035
3044
|
}
|
|
3036
3045
|
});
|
|
3037
3046
|
}
|
|
@@ -3070,6 +3079,14 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
|
|
|
3070
3079
|
setClauses.push("completedAt = ?");
|
|
3071
3080
|
params.push(update.completedAt?.toISOString() ?? null);
|
|
3072
3081
|
}
|
|
3082
|
+
if ("ownerId" in update) {
|
|
3083
|
+
setClauses.push("ownerId = ?");
|
|
3084
|
+
params.push(update.ownerId ?? null);
|
|
3085
|
+
}
|
|
3086
|
+
if ("leaseExpiresAt" in update) {
|
|
3087
|
+
setClauses.push("leaseExpiresAt = ?");
|
|
3088
|
+
params.push(update.leaseExpiresAt?.toISOString() ?? null);
|
|
3089
|
+
}
|
|
3073
3090
|
if (setClauses.length === 0) return false;
|
|
3074
3091
|
params.push(taskId);
|
|
3075
3092
|
let where = "id = ?";
|
|
@@ -3077,6 +3094,16 @@ var BackgroundTasksLibSQL = class BackgroundTasksLibSQL extends _mastra_core_sto
|
|
|
3077
3094
|
where += " AND status = ?";
|
|
3078
3095
|
params.push(options.expectedStatus);
|
|
3079
3096
|
}
|
|
3097
|
+
if (options?.expectedOwnerId !== void 0) if (options.expectedOwnerId === null) where += " AND ownerId IS NULL";
|
|
3098
|
+
else {
|
|
3099
|
+
where += " AND ownerId = ?";
|
|
3100
|
+
params.push(options.expectedOwnerId);
|
|
3101
|
+
}
|
|
3102
|
+
if (options?.expectedLeaseExpiresAt !== void 0) if (options.expectedLeaseExpiresAt === null) where += " AND leaseExpiresAt IS NULL";
|
|
3103
|
+
else {
|
|
3104
|
+
where += " AND leaseExpiresAt = ?";
|
|
3105
|
+
params.push(options.expectedLeaseExpiresAt.toISOString());
|
|
3106
|
+
}
|
|
3080
3107
|
return (await this.#client.execute({
|
|
3081
3108
|
sql: `UPDATE ${_mastra_core_storage.TABLE_BACKGROUND_TASKS} SET ${setClauses.join(", ")} WHERE ${where}`,
|
|
3082
3109
|
args: params
|
|
@@ -13528,7 +13555,7 @@ var WorkflowsLibSQL = class WorkflowsLibSQL extends _mastra_core_storage.Workflo
|
|
|
13528
13555
|
}
|
|
13529
13556
|
}, "deleteWorkflowRunById");
|
|
13530
13557
|
}
|
|
13531
|
-
async listWorkflowRuns({ workflowName, fromDate, toDate, page, perPage, resourceId, threadId, status } = {}) {
|
|
13558
|
+
async listWorkflowRuns({ workflowName, fromDate, toDate, page, perPage, resourceId, threadId, status, summary } = {}) {
|
|
13532
13559
|
try {
|
|
13533
13560
|
const conditions = [];
|
|
13534
13561
|
const args = [];
|
|
@@ -13569,7 +13596,7 @@ var WorkflowsLibSQL = class WorkflowsLibSQL extends _mastra_core_storage.Workflo
|
|
|
13569
13596
|
const normalizedPerPage = usePagination ? (0, _mastra_core_storage.normalizePerPage)(perPage, Number.MAX_SAFE_INTEGER) : 0;
|
|
13570
13597
|
const offset = usePagination ? page * normalizedPerPage : 0;
|
|
13571
13598
|
const runs = ((await this.#client.execute({
|
|
13572
|
-
sql: `SELECT workflow_name, run_id, resourceId, json(snapshot) as snapshot, createdAt, updatedAt FROM ${_mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT} ${whereClause} ORDER BY createdAt DESC${usePagination ? ` LIMIT ? OFFSET ?` : ""}`,
|
|
13599
|
+
sql: `SELECT workflow_name, run_id, resourceId, ${summary ? `json_object('status', json_extract(snapshot, '$.status'), 'timestamp', json_extract(snapshot, '$.timestamp'))` : "json(snapshot)"} as snapshot, createdAt, updatedAt FROM ${_mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT} ${whereClause} ORDER BY createdAt DESC${usePagination ? ` LIMIT ? OFFSET ?` : ""}`,
|
|
13573
13600
|
args: usePagination ? [
|
|
13574
13601
|
...args,
|
|
13575
13602
|
normalizedPerPage,
|