@mastra/libsql 0.0.0-fix-thread-subscription-multi-instance-redis-streams-20260720232722 → 0.0.0-fix-thread-subscription-multi-instance-redis-streams-20260730204150
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/CHANGELOG.md +249 -9
- package/dist/docs/SKILL.md +4 -3
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agent-builder-deploying.md +2 -2
- package/dist/docs/references/docs-agent-builder-overview.md +3 -1
- package/dist/docs/references/docs-agents-agent-approval.md +85 -11
- package/dist/docs/references/docs-agents-networks.md +2 -2
- package/dist/docs/references/docs-deployment-workers.md +137 -0
- package/dist/docs/references/docs-memory-memory-processors.md +10 -10
- package/dist/docs/references/docs-memory-message-history.md +29 -5
- package/dist/docs/references/docs-memory-multi-user-threads.md +6 -6
- package/dist/docs/references/docs-memory-overview.md +10 -10
- package/dist/docs/references/docs-memory-semantic-recall.md +3 -3
- package/dist/docs/references/docs-memory-working-memory.md +8 -8
- package/dist/docs/references/docs-rag-retrieval.md +18 -18
- package/dist/docs/references/docs-storage-overview.md +2 -2
- package/dist/docs/references/docs-workflows-snapshots.md +3 -3
- package/dist/docs/references/reference-core-mastra-class.md +48 -1
- package/dist/docs/references/reference-file-based-agents-storage.md +1 -1
- package/dist/docs/references/reference-memory-memory-class.md +5 -5
- package/dist/docs/references/reference-storage-dynamodb.md +7 -7
- package/dist/docs/references/reference-storage-retention.md +33 -33
- package/dist/docs/references/reference-vectors-libsql.md +2 -2
- package/dist/index.cjs +12742 -13175
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12708 -13141
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/datasets/index.d.ts.map +1 -1
- package/dist/storage/domains/experiments/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/factory-storage.d.ts +28 -0
- package/dist/storage/factory-storage.d.ts.map +1 -0
- package/dist/storage/index.d.ts +2 -9
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts +1 -7
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +13 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,257 @@
|
|
|
1
1
|
# @mastra/libsql
|
|
2
2
|
|
|
3
|
-
## 0.0.0-fix-thread-subscription-multi-instance-redis-streams-
|
|
3
|
+
## 0.0.0-fix-thread-subscription-multi-instance-redis-streams-20260730204150
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added persistence for dataset item undeclared tool policies. ([#19643](https://github.com/mastra-ai/mastra/pull/19643))
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
await dataset.addItem({
|
|
11
|
+
input: 'What is the weather?',
|
|
12
|
+
unmockedToolPolicy: 'deny',
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Added a comment column to experiment results so review comments persist. The column is added automatically and non-destructively on startup for existing databases (https://github.com/mastra-ai/mastra/issues/19857). ([#19865](https://github.com/mastra-ai/mastra/pull/19865))
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`c5e56ff`](https://github.com/mastra-ai/mastra/commit/c5e56ff3bcabdf062708f2d48744fec304df6792), [`7f4e26d`](https://github.com/mastra-ai/mastra/commit/7f4e26dd57bd9b23c278ea21235ab823a3810a6c), [`322daa6`](https://github.com/mastra-ai/mastra/commit/322daa6d90552909204044790d850958f6745fed), [`cadaa13`](https://github.com/mastra-ai/mastra/commit/cadaa1372e1077c8e85eb64c5499ba8803caa323), [`b582f7f`](https://github.com/mastra-ai/mastra/commit/b582f7fa2f9c1f87d19efc63d344fbe5dda2608c), [`06000d7`](https://github.com/mastra-ai/mastra/commit/06000d73712911572e913b8a83339270296d0a22), [`cf24430`](https://github.com/mastra-ai/mastra/commit/cf24430226a6ecb104bc1d54d6e401defd7cb53f), [`4e35a56`](https://github.com/mastra-ai/mastra/commit/4e35a56cdf8d74a5ff6d5eda01f2c1deaf6cc7be), [`3de0188`](https://github.com/mastra-ai/mastra/commit/3de0188bfaf9a9c09c95fe322b53838cf52c70b6), [`b582f7f`](https://github.com/mastra-ai/mastra/commit/b582f7fa2f9c1f87d19efc63d344fbe5dda2608c)]:
|
|
21
|
+
- @mastra/core@0.0.0-fix-thread-subscription-multi-instance-redis-streams-20260730204150
|
|
22
|
+
|
|
23
|
+
## 1.19.0-alpha.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- Added persistence for dataset item undeclared tool policies. ([#19643](https://github.com/mastra-ai/mastra/pull/19643))
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
await dataset.addItem({
|
|
31
|
+
input: 'What is the weather?',
|
|
32
|
+
unmockedToolPolicy: 'deny',
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Added a comment column to experiment results so review comments persist. The column is added automatically and non-destructively on startup for existing databases (https://github.com/mastra-ai/mastra/issues/19857). ([#19865](https://github.com/mastra-ai/mastra/pull/19865))
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`c5e56ff`](https://github.com/mastra-ai/mastra/commit/c5e56ff3bcabdf062708f2d48744fec304df6792), [`4e35a56`](https://github.com/mastra-ai/mastra/commit/4e35a56cdf8d74a5ff6d5eda01f2c1deaf6cc7be)]:
|
|
41
|
+
- @mastra/core@1.56.0-alpha.1
|
|
42
|
+
|
|
43
|
+
## 1.18.0
|
|
44
|
+
|
|
45
|
+
### Minor Changes
|
|
46
|
+
|
|
47
|
+
- Added exact metadata filtering to message history queries across Memory APIs and supported storage providers. ([#19991](https://github.com/mastra-ai/mastra/pull/19991))
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const messages = await memory.recall({
|
|
51
|
+
threadId: 'thread-1',
|
|
52
|
+
filter: {
|
|
53
|
+
metadata: {
|
|
54
|
+
status: 'done',
|
|
55
|
+
priority: 'high',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Multiple fields use AND semantics. Supported values are strings, finite numbers, booleans, and `null`.
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- Fixed Factory database lock errors by serializing writes that share a LibSQL connection. ([#20278](https://github.com/mastra-ai/mastra/pull/20278))
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [[`ce93a3c`](https://github.com/mastra-ai/mastra/commit/ce93a3c114ea1cbfbd576f3db41d7c26c9844f5b), [`5718a22`](https://github.com/mastra-ai/mastra/commit/5718a229281dcfd36bcd1f42a242e3717e510a33), [`a211d09`](https://github.com/mastra-ai/mastra/commit/a211d09185dc65a746534914cf38b67f21ee9bac), [`0dca9d0`](https://github.com/mastra-ai/mastra/commit/0dca9d0b1356024a53b72ea6f040db528b126caa), [`6218217`](https://github.com/mastra-ai/mastra/commit/62182171b6cfca0b099f1c6a77a2e65e7639ab86), [`5807d3a`](https://github.com/mastra-ai/mastra/commit/5807d3ae1d259b8b7d6df7e5bf2b485c694af9c8), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`05db566`](https://github.com/mastra-ai/mastra/commit/05db566fcbdcbf33d0bffca0c72ec30129e2e3ca), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`5718a22`](https://github.com/mastra-ai/mastra/commit/5718a229281dcfd36bcd1f42a242e3717e510a33), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`d1b7e3a`](https://github.com/mastra-ai/mastra/commit/d1b7e3a978a309a5653eeaa490d2d6c7c53bd093), [`29c584a`](https://github.com/mastra-ai/mastra/commit/29c584a13a88831e5ed1fdeb0ff8e82eae180433), [`c093146`](https://github.com/mastra-ai/mastra/commit/c0931466404d3c521308ea119cb165bb7e695155), [`8124754`](https://github.com/mastra-ai/mastra/commit/8124754ae89fbc69f8136d1df4a91904d0f84c4e), [`d12b2e4`](https://github.com/mastra-ai/mastra/commit/d12b2e4023fd9e3d3e93a9169f5088bcee2a849c)]:
|
|
68
|
+
- @mastra/core@1.54.0
|
|
69
|
+
|
|
70
|
+
## 1.18.0-alpha.1
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Fixed Factory database lock errors by serializing writes that share a LibSQL connection. ([#20278](https://github.com/mastra-ai/mastra/pull/20278))
|
|
75
|
+
|
|
76
|
+
- Updated dependencies [[`a211d09`](https://github.com/mastra-ai/mastra/commit/a211d09185dc65a746534914cf38b67f21ee9bac), [`05db566`](https://github.com/mastra-ai/mastra/commit/05db566fcbdcbf33d0bffca0c72ec30129e2e3ca), [`8124754`](https://github.com/mastra-ai/mastra/commit/8124754ae89fbc69f8136d1df4a91904d0f84c4e)]:
|
|
77
|
+
- @mastra/core@1.54.0-alpha.2
|
|
78
|
+
|
|
79
|
+
## 1.18.0-alpha.0
|
|
80
|
+
|
|
81
|
+
### Minor Changes
|
|
82
|
+
|
|
83
|
+
- Added exact metadata filtering to message history queries across Memory APIs and supported storage providers. ([#19991](https://github.com/mastra-ai/mastra/pull/19991))
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const messages = await memory.recall({
|
|
87
|
+
threadId: 'thread-1',
|
|
88
|
+
filter: {
|
|
89
|
+
metadata: {
|
|
90
|
+
status: 'done',
|
|
91
|
+
priority: 'high',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Multiple fields use AND semantics. Supported values are strings, finite numbers, booleans, and `null`.
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- Updated dependencies [[`0dca9d0`](https://github.com/mastra-ai/mastra/commit/0dca9d0b1356024a53b72ea6f040db528b126caa)]:
|
|
102
|
+
- @mastra/core@1.54.0-alpha.0
|
|
103
|
+
|
|
104
|
+
## 1.17.1
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- Fixed data loss and corruption in observational memory when it is written to concurrently on a local SQLite database. Buffered observations could previously be dropped or leave the memory record in an inconsistent state under load; memory updates are now serialized so concurrent writes are preserved. ([#20110](https://github.com/mastra-ai/mastra/pull/20110))
|
|
109
|
+
|
|
110
|
+
- Fixed local LibSQL stores changing shared database journal state when they close. ([#20227](https://github.com/mastra-ai/mastra/pull/20227))
|
|
111
|
+
|
|
112
|
+
- Updated dependencies [[`c8d8a01`](https://github.com/mastra-ai/mastra/commit/c8d8a010ee2efe2b7bf4d07707382c34c87b14e4), [`df6a9ce`](https://github.com/mastra-ai/mastra/commit/df6a9ce87214f7aadb2edfe62f67605fe998a0a4), [`73839cb`](https://github.com/mastra-ai/mastra/commit/73839cb58322679c170627d1015669ede5f619aa), [`371cf60`](https://github.com/mastra-ai/mastra/commit/371cf6075cef88ac6919a08d59a82e485397364a), [`8e4dc79`](https://github.com/mastra-ai/mastra/commit/8e4dc793dcf035ea506f9ce79f56d2d501a4be14), [`2db93cc`](https://github.com/mastra-ai/mastra/commit/2db93ccd0b872e4de7853a93383efe0647901df8), [`094ab61`](https://github.com/mastra-ai/mastra/commit/094ab6129a1a3ecf6eeb86decac17d5faea4e02a), [`fe80944`](https://github.com/mastra-ai/mastra/commit/fe80944f3ef6681fea6eae8200fce387b7bb3c2f), [`263d2ca`](https://github.com/mastra-ai/mastra/commit/263d2cac80ba3b03b9c0f008db6f1f1b9eb0278c), [`75f843d`](https://github.com/mastra-ai/mastra/commit/75f843d09f758223e6eeb321321bdcc5c7e779d0), [`e51e166`](https://github.com/mastra-ai/mastra/commit/e51e166c52e220abc9b64554ce37359dca8544b1)]:
|
|
113
|
+
- @mastra/core@1.53.0
|
|
114
|
+
|
|
115
|
+
## 1.17.1-alpha.1
|
|
116
|
+
|
|
117
|
+
### Patch Changes
|
|
118
|
+
|
|
119
|
+
- Fixed local LibSQL stores changing shared database journal state when they close. ([#20227](https://github.com/mastra-ai/mastra/pull/20227))
|
|
120
|
+
|
|
121
|
+
- Updated dependencies [[`73839cb`](https://github.com/mastra-ai/mastra/commit/73839cb58322679c170627d1015669ede5f619aa), [`8e4dc79`](https://github.com/mastra-ai/mastra/commit/8e4dc793dcf035ea506f9ce79f56d2d501a4be14), [`2db93cc`](https://github.com/mastra-ai/mastra/commit/2db93ccd0b872e4de7853a93383efe0647901df8), [`094ab61`](https://github.com/mastra-ai/mastra/commit/094ab6129a1a3ecf6eeb86decac17d5faea4e02a), [`fe80944`](https://github.com/mastra-ai/mastra/commit/fe80944f3ef6681fea6eae8200fce387b7bb3c2f), [`e51e166`](https://github.com/mastra-ai/mastra/commit/e51e166c52e220abc9b64554ce37359dca8544b1)]:
|
|
122
|
+
- @mastra/core@1.53.0-alpha.4
|
|
123
|
+
|
|
124
|
+
## 1.17.1-alpha.0
|
|
125
|
+
|
|
126
|
+
### Patch Changes
|
|
127
|
+
|
|
128
|
+
- Fixed data loss and corruption in observational memory when it is written to concurrently on a local SQLite database. Buffered observations could previously be dropped or leave the memory record in an inconsistent state under load; memory updates are now serialized so concurrent writes are preserved. ([#20110](https://github.com/mastra-ai/mastra/pull/20110))
|
|
129
|
+
|
|
130
|
+
- Updated dependencies [[`df6a9ce`](https://github.com/mastra-ai/mastra/commit/df6a9ce87214f7aadb2edfe62f67605fe998a0a4)]:
|
|
131
|
+
- @mastra/core@1.52.2-alpha.0
|
|
132
|
+
|
|
133
|
+
## 1.17.0
|
|
134
|
+
|
|
135
|
+
### Minor Changes
|
|
136
|
+
|
|
137
|
+
- Added LibSQLFactoryStorage for persisting Mastra agent state and lifecycle-managed application domains through one LibSQL connection. ([#19681](https://github.com/mastra-ai/mastra/pull/19681))
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
import { LibSQLFactoryStorage } from '@mastra/libsql';
|
|
141
|
+
|
|
142
|
+
const storage = new LibSQLFactoryStorage({ url: 'file:mastra.db' });
|
|
143
|
+
await storage.init();
|
|
144
|
+
```
|
|
4
145
|
|
|
5
146
|
### Patch Changes
|
|
6
147
|
|
|
148
|
+
- Replaced GitHub-specific Mastra Code session state with Factory project and linked-repository identities. This lets SDK consumers represent sessions independently of a source-control provider and select a repository explicitly when sandbox execution is required. ([#19849](https://github.com/mastra-ai/mastra/pull/19849))
|
|
149
|
+
|
|
150
|
+
Updated Mastra Code onboarding to be Factory-first: create a Factory by name, then link repositories from your connected source-control installations in a separate step. A Factory is valid with zero linked repositories, and the Board, Metrics, and Audit pages stay available for any server-backed Factory. Factory pages keep project-scoped data separate from repository-scoped intake and provide a repository selector when a Factory has multiple linked repositories. Creating a Factory from a local folder remains available as a secondary option.
|
|
151
|
+
|
|
152
|
+
**Before**
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
const state = { githubProjectId: 'project-1', sandboxId, sandboxWorkdir };
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**After**
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
const state = {
|
|
162
|
+
factoryProjectId: 'factory-project-1',
|
|
163
|
+
projectRepositoryId: 'project-repository-1',
|
|
164
|
+
sandboxId,
|
|
165
|
+
sandboxWorkdir,
|
|
166
|
+
};
|
|
167
|
+
```
|
|
168
|
+
|
|
7
169
|
- Fixed an uncaught `RangeError: Maximum call stack size exceeded` when writing deeply-nested values (such as a long chained `Error.cause`) to LibSQL storage. `safeStringify` now caps its recursion depth and substitutes a `"[Max depth exceeded]"` sentinel instead of overflowing the stack. ([#19610](https://github.com/mastra-ai/mastra/pull/19610))
|
|
8
170
|
|
|
9
|
-
-
|
|
10
|
-
|
|
171
|
+
- Fix factory storage error classification and schema drift handling. ([#20002](https://github.com/mastra-ai/mastra/pull/20002))
|
|
172
|
+
|
|
173
|
+
- `isUniqueViolation` in the LibSQL factory storage now only matches real unique-index violations (`SQLITE_CONSTRAINT_UNIQUE` / `SQLITE_CONSTRAINT_PRIMARYKEY`). Previously any `SQLITE_CONSTRAINT` failure — including NOT NULL violations — was reported as a "Unique constraint violation", which masked the real error (seen as `Unique constraint violation on collection 'factory_rule_evaluations'` when polled ingestion inserted nullable columns into a stale table).
|
|
174
|
+
- `ensureCollections` in both the LibSQL and Postgres factory storage adapters now relaxes stale NOT NULL constraints when a column becomes nullable in the schema. Postgres uses `ALTER COLUMN ... DROP NOT NULL`; LibSQL rebuilds the table in place since SQLite cannot drop NOT NULL directly. Existing rows and unique indexes are preserved.
|
|
175
|
+
|
|
176
|
+
- Updated dependencies [[`ec857fc`](https://github.com/mastra-ai/mastra/commit/ec857fc79c264b53b38e16478c789b7177f2ad59), [`d7385ad`](https://github.com/mastra-ai/mastra/commit/d7385ad9e88f9e4f33d15c0ec0bfebedde0cbc2e), [`41a5392`](https://github.com/mastra-ai/mastra/commit/41a5392d9f6c5e18d6b227f0fc0ddf49c50774e9), [`3d6e539`](https://github.com/mastra-ai/mastra/commit/3d6e539272eb2ea0407034605ee1906b3be06b39), [`1426af2`](https://github.com/mastra-ai/mastra/commit/1426af24975879c000d13ac75673f630fcc970c1), [`a40adeb`](https://github.com/mastra-ai/mastra/commit/a40adeb222b961a56a58af56a106106525721b74), [`8a0d145`](https://github.com/mastra-ai/mastra/commit/8a0d145aadbdf7278665aceaaec364b35dd9bd94), [`bd2f1d2`](https://github.com/mastra-ai/mastra/commit/bd2f1d274d05e60e2366f005ea0d94d5cea0d5ff), [`e1f2fae`](https://github.com/mastra-ai/mastra/commit/e1f2faebaf048c3d4c2e2c01d293767c195d5794), [`63aa799`](https://github.com/mastra-ai/mastra/commit/63aa799c6b44eacc7806cda6846b7c5bbee06b37), [`b7e79c3`](https://github.com/mastra-ai/mastra/commit/b7e79c3c02ac5cd415db34ba0975ceafc1464333), [`675fbff`](https://github.com/mastra-ai/mastra/commit/675fbff84d3274391b33e852f76083c38a5514e5), [`da009e1`](https://github.com/mastra-ai/mastra/commit/da009e1aacd89ed94b8d1b2af09c9d4fe7c4db49), [`3b77e77`](https://github.com/mastra-ai/mastra/commit/3b77e7704936522e4769d29de1b5ea6901f302bd), [`c7d30cd`](https://github.com/mastra-ai/mastra/commit/c7d30cd86009c407df91105591f03cd6e3d2854d), [`21a0eb8`](https://github.com/mastra-ai/mastra/commit/21a0eb86746ba0b703acea360d4f84c6a5a493f2), [`8b20926`](https://github.com/mastra-ai/mastra/commit/8b20926cd59e2ba3d66458e062fa0e6e2ada3e68), [`975295d`](https://github.com/mastra-ai/mastra/commit/975295d418552f0d46a59edfef4c3ee555f9930a), [`73db8db`](https://github.com/mastra-ai/mastra/commit/73db8db90d69ab6153c7942749f624db0d96952d), [`6b1bf3b`](https://github.com/mastra-ai/mastra/commit/6b1bf3b9494bd51aa8f654c68c9355d6046fa2a1), [`35c2181`](https://github.com/mastra-ai/mastra/commit/35c2181e6a50e47c90ba36260db7c9723d54696f), [`0a2c22c`](https://github.com/mastra-ai/mastra/commit/0a2c22c902604439ec490319e14c17f331e0c84c), [`4cfdd64`](https://github.com/mastra-ai/mastra/commit/4cfdd645794feaea0c4ea711e70ecdfbef0c5b8e), [`b75d749`](https://github.com/mastra-ai/mastra/commit/b75d749621ff5d17e86bcb4ee809d301fb4f7cf3), [`821648b`](https://github.com/mastra-ai/mastra/commit/821648bf2871ef840100c7bacbecf676010bd12a), [`de86fd7`](https://github.com/mastra-ai/mastra/commit/de86fd7119f0438381d1a642e3d258143c0b9c29), [`2745031`](https://github.com/mastra-ai/mastra/commit/2745031d1d4a4978f037092da371428c32e2842a), [`b4b7ea8`](https://github.com/mastra-ai/mastra/commit/b4b7ea8733f033fc441ea47ed03f6afb17ec2248), [`3a8024c`](https://github.com/mastra-ai/mastra/commit/3a8024ce615f8aa89479c0d71fe61d10bb0040be), [`35865a5`](https://github.com/mastra-ai/mastra/commit/35865a53e194aa9634d6a70a97010e7a6b9d58b1), [`74faf8b`](https://github.com/mastra-ai/mastra/commit/74faf8bd9c1018f2492653c06b1e25fc8300e9e6), [`ef03fbc`](https://github.com/mastra-ai/mastra/commit/ef03fbcc556bcbc04c9b3d06fab88771ecaa043c), [`675fbff`](https://github.com/mastra-ai/mastra/commit/675fbff84d3274391b33e852f76083c38a5514e5), [`70687f7`](https://github.com/mastra-ai/mastra/commit/70687f7e495a322a02070b4a67cb0c77a5ca91ec), [`1fadac4`](https://github.com/mastra-ai/mastra/commit/1fadac44537caeefe81f9f775ae2f2f3d94e9069), [`73db8db`](https://github.com/mastra-ai/mastra/commit/73db8db90d69ab6153c7942749f624db0d96952d), [`76b7181`](https://github.com/mastra-ai/mastra/commit/76b71810366e6d90b9d3973149d1c7ba3659ffb9), [`792ec9a`](https://github.com/mastra-ai/mastra/commit/792ec9a0869bab8274cf5e0ed2840738737a1607), [`712b864`](https://github.com/mastra-ai/mastra/commit/712b864aa1ed12b14c54390ec17b69de163c37f7), [`85e4fb5`](https://github.com/mastra-ai/mastra/commit/85e4fb50087a81c74df3a762f53b56373db0b912), [`0c0e8d7`](https://github.com/mastra-ai/mastra/commit/0c0e8d7becd4d1445c656b78d5d845f606c1ff9d), [`a7bbe77`](https://github.com/mastra-ai/mastra/commit/a7bbe773577f60bc4761b534ef7ec6b476332dad), [`72e437c`](https://github.com/mastra-ai/mastra/commit/72e437c515942c80b9def5b026e0bdee61b469d9), [`8f7a5de`](https://github.com/mastra-ai/mastra/commit/8f7a5dedc246cdc938bb65516703cf9b27b03756), [`a7bbe77`](https://github.com/mastra-ai/mastra/commit/a7bbe773577f60bc4761b534ef7ec6b476332dad), [`11f6cd9`](https://github.com/mastra-ai/mastra/commit/11f6cd96fe42582403416608beb212cc1a2cc79e), [`ef03c0c`](https://github.com/mastra-ai/mastra/commit/ef03c0cfc62367a458e4cc56462e2148b35681c5), [`4fb4d88`](https://github.com/mastra-ai/mastra/commit/4fb4d881bc107acee13890ad4d78661016c510ed), [`4e68363`](https://github.com/mastra-ai/mastra/commit/4e683634f94ebd062d26a3bb6093a8dfc7263d37), [`c328769`](https://github.com/mastra-ai/mastra/commit/c3287698ff8ef98dba86d415faa566fa3e5f4d56), [`9f7c67a`](https://github.com/mastra-ai/mastra/commit/9f7c67abeeb52c41c51a9b5edee60b62afe7cd8d), [`3b65e68`](https://github.com/mastra-ai/mastra/commit/3b65e68d7f1c771c7a70eea42d83fefdd28cad88), [`4eba27a`](https://github.com/mastra-ai/mastra/commit/4eba27adcf60f991df0e62f94b3e75b4e67f3b4b), [`c701be3`](https://github.com/mastra-ai/mastra/commit/c701be32d7d9aa94a66da8c6cc38dcac6856f464), [`db650ce`](https://github.com/mastra-ai/mastra/commit/db650ce490348914e85b93651d83acdf8f2a4c31), [`232fcbc`](https://github.com/mastra-ai/mastra/commit/232fcbc14fce625dd672ba043329c0b732c62be2), [`6354eeb`](https://github.com/mastra-ai/mastra/commit/6354eeb32efa9f5f68f51dda394e90e2ee76f1fb), [`a8799bb`](https://github.com/mastra-ai/mastra/commit/a8799bb8e44f4a60d01e4e2acd3448ff80bf14f8), [`3d6e539`](https://github.com/mastra-ai/mastra/commit/3d6e539272eb2ea0407034605ee1906b3be06b39), [`e3868e2`](https://github.com/mastra-ai/mastra/commit/e3868e22babfffd0133771669ca724501c2dd58e), [`9251370`](https://github.com/mastra-ai/mastra/commit/9251370ad413af464aa22d7566338bec5613e8de), [`3491666`](https://github.com/mastra-ai/mastra/commit/34916663c4fdd43b48c21f4ab2d5fb6dcccc94f9), [`c0bec73`](https://github.com/mastra-ai/mastra/commit/c0bec732c93d1a22ae5e51ed66cf8cacca8bd6a6)]:
|
|
177
|
+
- @mastra/core@1.52.0
|
|
178
|
+
|
|
179
|
+
## 1.17.0-alpha.4
|
|
180
|
+
|
|
181
|
+
### Patch Changes
|
|
182
|
+
|
|
183
|
+
- Fix factory storage error classification and schema drift handling. ([#20002](https://github.com/mastra-ai/mastra/pull/20002))
|
|
184
|
+
|
|
185
|
+
- `isUniqueViolation` in the LibSQL factory storage now only matches real unique-index violations (`SQLITE_CONSTRAINT_UNIQUE` / `SQLITE_CONSTRAINT_PRIMARYKEY`). Previously any `SQLITE_CONSTRAINT` failure — including NOT NULL violations — was reported as a "Unique constraint violation", which masked the real error (seen as `Unique constraint violation on collection 'factory_rule_evaluations'` when polled ingestion inserted nullable columns into a stale table).
|
|
186
|
+
- `ensureCollections` in both the LibSQL and Postgres factory storage adapters now relaxes stale NOT NULL constraints when a column becomes nullable in the schema. Postgres uses `ALTER COLUMN ... DROP NOT NULL`; LibSQL rebuilds the table in place since SQLite cannot drop NOT NULL directly. Existing rows and unique indexes are preserved.
|
|
187
|
+
|
|
188
|
+
- Updated dependencies:
|
|
189
|
+
- @mastra/core@1.52.0-alpha.13
|
|
190
|
+
|
|
191
|
+
## 1.17.0-alpha.3
|
|
192
|
+
|
|
193
|
+
### Minor Changes
|
|
194
|
+
|
|
195
|
+
- Added configurable local journal modes while preserving WAL as the default. ([#19901](https://github.com/mastra-ai/mastra/pull/19901))
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
const storage = new LibSQLStore({
|
|
199
|
+
id: 'local-storage',
|
|
200
|
+
url: 'file:./mastra.db',
|
|
201
|
+
journalMode: 'delete',
|
|
202
|
+
});
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Patch Changes
|
|
206
|
+
|
|
207
|
+
- Updated dependencies [[`c7d30cd`](https://github.com/mastra-ai/mastra/commit/c7d30cd86009c407df91105591f03cd6e3d2854d), [`ef03fbc`](https://github.com/mastra-ai/mastra/commit/ef03fbcc556bcbc04c9b3d06fab88771ecaa043c), [`a7bbe77`](https://github.com/mastra-ai/mastra/commit/a7bbe773577f60bc4761b534ef7ec6b476332dad), [`a7bbe77`](https://github.com/mastra-ai/mastra/commit/a7bbe773577f60bc4761b534ef7ec6b476332dad), [`4e68363`](https://github.com/mastra-ai/mastra/commit/4e683634f94ebd062d26a3bb6093a8dfc7263d37), [`9251370`](https://github.com/mastra-ai/mastra/commit/9251370ad413af464aa22d7566338bec5613e8de)]:
|
|
208
|
+
- @mastra/core@1.52.0-alpha.11
|
|
209
|
+
|
|
210
|
+
## 1.17.0-alpha.2
|
|
211
|
+
|
|
212
|
+
### Patch Changes
|
|
213
|
+
|
|
214
|
+
- Replaced GitHub-specific Mastra Code session state with Factory project and linked-repository identities. This lets SDK consumers represent sessions independently of a source-control provider and select a repository explicitly when sandbox execution is required. ([#19849](https://github.com/mastra-ai/mastra/pull/19849))
|
|
215
|
+
|
|
216
|
+
Updated Mastra Code onboarding to be Factory-first: create a Factory by name, then link repositories from your connected source-control installations in a separate step. A Factory is valid with zero linked repositories, and the Board, Metrics, and Audit pages stay available for any server-backed Factory. Factory pages keep project-scoped data separate from repository-scoped intake and provide a repository selector when a Factory has multiple linked repositories. Creating a Factory from a local folder remains available as a secondary option.
|
|
217
|
+
|
|
218
|
+
**Before**
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
const state = { githubProjectId: 'project-1', sandboxId, sandboxWorkdir };
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**After**
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
const state = {
|
|
228
|
+
factoryProjectId: 'factory-project-1',
|
|
229
|
+
projectRepositoryId: 'project-repository-1',
|
|
230
|
+
sandboxId,
|
|
231
|
+
sandboxWorkdir,
|
|
232
|
+
};
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
- Updated dependencies [[`41a5392`](https://github.com/mastra-ai/mastra/commit/41a5392d9f6c5e18d6b227f0fc0ddf49c50774e9), [`675fbff`](https://github.com/mastra-ai/mastra/commit/675fbff84d3274391b33e852f76083c38a5514e5), [`da009e1`](https://github.com/mastra-ai/mastra/commit/da009e1aacd89ed94b8d1b2af09c9d4fe7c4db49), [`35c2181`](https://github.com/mastra-ai/mastra/commit/35c2181e6a50e47c90ba36260db7c9723d54696f), [`b4b7ea8`](https://github.com/mastra-ai/mastra/commit/b4b7ea8733f033fc441ea47ed03f6afb17ec2248), [`675fbff`](https://github.com/mastra-ai/mastra/commit/675fbff84d3274391b33e852f76083c38a5514e5), [`c328769`](https://github.com/mastra-ai/mastra/commit/c3287698ff8ef98dba86d415faa566fa3e5f4d56), [`232fcbc`](https://github.com/mastra-ai/mastra/commit/232fcbc14fce625dd672ba043329c0b732c62be2), [`3491666`](https://github.com/mastra-ai/mastra/commit/34916663c4fdd43b48c21f4ab2d5fb6dcccc94f9)]:
|
|
236
|
+
- @mastra/core@1.52.0-alpha.10
|
|
237
|
+
|
|
238
|
+
## 1.17.0-alpha.1
|
|
239
|
+
|
|
240
|
+
### Minor Changes
|
|
241
|
+
|
|
242
|
+
- Added LibSQLFactoryStorage for persisting Mastra agent state and lifecycle-managed application domains through one LibSQL connection. ([#19681](https://github.com/mastra-ai/mastra/pull/19681))
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
import { LibSQLFactoryStorage } from '@mastra/libsql';
|
|
246
|
+
|
|
247
|
+
const storage = new LibSQLFactoryStorage({ url: 'file:mastra.db' });
|
|
248
|
+
await storage.init();
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Patch Changes
|
|
252
|
+
|
|
253
|
+
- Updated dependencies [[`3b77e77`](https://github.com/mastra-ai/mastra/commit/3b77e7704936522e4769d29de1b5ea6901f302bd), [`6b1bf3b`](https://github.com/mastra-ai/mastra/commit/6b1bf3b9494bd51aa8f654c68c9355d6046fa2a1), [`72e437c`](https://github.com/mastra-ai/mastra/commit/72e437c515942c80b9def5b026e0bdee61b469d9)]:
|
|
254
|
+
- @mastra/core@1.52.0-alpha.8
|
|
11
255
|
|
|
12
256
|
## 1.16.1-alpha.0
|
|
13
257
|
|
|
@@ -935,9 +1179,7 @@
|
|
|
935
1179
|
**Example**
|
|
936
1180
|
|
|
937
1181
|
```ts
|
|
938
|
-
const storage = new LibSQLStore({
|
|
939
|
-
/* config */
|
|
940
|
-
});
|
|
1182
|
+
const storage = new LibSQLStore({/* config */});
|
|
941
1183
|
const favorites = await storage.getStore('favorites');
|
|
942
1184
|
|
|
943
1185
|
await favorites?.favorite({
|
|
@@ -965,9 +1207,7 @@
|
|
|
965
1207
|
**Example**
|
|
966
1208
|
|
|
967
1209
|
```ts
|
|
968
|
-
const storage = new LibSQLStore({
|
|
969
|
-
/* config */
|
|
970
|
-
});
|
|
1210
|
+
const storage = new LibSQLStore({/* config */});
|
|
971
1211
|
const favorites = await storage.getStore('favorites');
|
|
972
1212
|
|
|
973
1213
|
await favorites?.favorite({
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-libsql
|
|
|
3
3
|
description: Documentation for @mastra/libsql. Use when working with @mastra/libsql APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/libsql"
|
|
6
|
-
version: "0.0.0-fix-thread-subscription-multi-instance-redis-streams-
|
|
6
|
+
version: "0.0.0-fix-thread-subscription-multi-instance-redis-streams-20260730204150"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -18,8 +18,9 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
18
18
|
|
|
19
19
|
- [Deploying](references/docs-agent-builder-deploying.md) - Swap local Agent Builder primitives for cloud-backed storage, filesystems, sandboxes, an EE license, auth, and a public channel URL for production.
|
|
20
20
|
- [Agent Builder overview](references/docs-agent-builder-overview.md) - Let teammates create, configure, and operate Mastra agents from a browser, with admin-pinned defaults, RBAC, and channel integrations.
|
|
21
|
-
- [Agent approval](references/docs-agents-agent-approval.md) - Learn how to require approvals
|
|
21
|
+
- [Agent approval](references/docs-agents-agent-approval.md) - Learn how to require approvals and suspend tool execution, plus automatically resume suspended tools while keeping humans in control of agent workflows.
|
|
22
22
|
- [Agent networks](references/docs-agents-networks.md) - Coordinate multiple agents, workflows, and tools using agent networks for complex, non-deterministic task execution.
|
|
23
|
+
- [Workers](references/docs-deployment-workers.md) - Separate background processing from the API layer by running workflow execution, cron schedules, and background tasks in dedicated worker processes.
|
|
23
24
|
- [Memory processors](references/docs-memory-memory-processors.md) - Learn how to use memory processors in Mastra to filter, trim, and transform messages before they're sent to the language model to manage context window limits.
|
|
24
25
|
- [Message history](references/docs-memory-message-history.md) - Learn how to configure message history in Mastra to store recent messages from the current conversation.
|
|
25
26
|
- [Multi-user threads](references/docs-memory-multi-user-threads.md) - Share one Mastra thread between multiple users by carrying speaker identity in the message body.
|
|
@@ -41,7 +42,7 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
41
42
|
- [Reference: Mastra class](references/reference-core-mastra-class.md) - Documentation for the `Mastra` class in Mastra, the core entry point for managing agents, workflows, MCP servers, and server endpoints.
|
|
42
43
|
- [Memory](references/reference-file-based-agents-memory.md) - Give a file-based agent persistent memory with a memory.ts module.
|
|
43
44
|
- [Storage](references/reference-file-based-agents-storage.md) - Set the default Mastra store by file convention with storage.ts.
|
|
44
|
-
- [Reference: Memory class](references/reference-memory-memory-class.md) - Documentation for the `Memory` class in Mastra, which provides a
|
|
45
|
+
- [Reference: Memory class](references/reference-memory-memory-class.md) - Documentation for the `Memory` class in Mastra, which provides a reliable system for managing conversation history and thread-based message storage.
|
|
45
46
|
- [Reference: Composite storage](references/reference-storage-composite.md) - Documentation for combining multiple storage backends in Mastra.
|
|
46
47
|
- [Reference: DynamoDB storage](references/reference-storage-dynamodb.md) - Documentation for the DynamoDB storage implementation in Mastra, using a single-table design with ElectroDB.
|
|
47
48
|
- [Reference: libSQL storage](references/reference-storage-libsql.md) - Documentation for the libSQL storage implementation in Mastra.
|
|
@@ -10,8 +10,8 @@ Production deployments swap the local primitives in the Quickstart for cloud-bac
|
|
|
10
10
|
|
|
11
11
|
1. **EE license**: A valid `MASTRA_EE_LICENSE` so the server will start with the Builder enabled.
|
|
12
12
|
2. **Hosted storage**: A shared store for agents, skills, runs, and memory.
|
|
13
|
-
3. **Shared workspace filesystem**: Survives across instances
|
|
14
|
-
4. **Cloud sandbox**: Runs agent commands safely
|
|
13
|
+
3. **Shared workspace filesystem**: Survives across instances. `local` is single-node only.
|
|
14
|
+
4. **Cloud sandbox**: Runs agent commands safely. `local` is unsafe in shared environments.
|
|
15
15
|
5. **Auth and RBAC**: Gates the Builder UI and `/agent-builder/*` routes.
|
|
16
16
|
6. **Public base URL for channels**: Slack and other channel providers need a reachable URL.
|
|
17
17
|
|
|
@@ -58,7 +58,7 @@ yarn add @mastra/editor @mastra/libsql
|
|
|
58
58
|
bun add @mastra/editor @mastra/libsql
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
The example below defines a storage adapter
|
|
61
|
+
The example below defines a storage adapter and registers a builder agent, plus enables the editor as explained in the prerequisites:
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
64
|
import { Mastra } from '@mastra/core/mastra'
|
|
@@ -88,6 +88,8 @@ Start Mastra's development server:
|
|
|
88
88
|
npx mastra dev
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
+
For Agent Builder development, you can also use `mastra factory dev`, which uses the same dev runtime and flags as `mastra dev` and writes to the same `.mastra/output` directory. Both commands share a dev lock and can't run simultaneously in the same project. See the [CLI reference](https://mastra.ai/reference/cli/mastra) for details.
|
|
92
|
+
|
|
91
93
|
The Agent Builder is mounted at `http://localhost:4111/agent-builder`.
|
|
92
94
|
|
|
93
95
|
## Disabling the Builder
|
|
@@ -6,7 +6,7 @@ Agents sometimes require the same [human-in-the-loop](https://mastra.ai/docs/wor
|
|
|
6
6
|
|
|
7
7
|
## When to use agent approval
|
|
8
8
|
|
|
9
|
-
- **Destructive or irreversible actions** such as deleting records
|
|
9
|
+
- **Destructive or irreversible actions** such as deleting records or sending emails, or alternatively processing payments.
|
|
10
10
|
- **Cost-heavy operations** like calling expensive third-party APIs where you want to verify arguments first.
|
|
11
11
|
- **Conditional confirmation** where a tool starts executing and then discovers it needs the user to confirm or supply extra data before finishing.
|
|
12
12
|
|
|
@@ -60,7 +60,7 @@ Mastra offers two distinct mechanisms for pausing tool calls: **pre-execution ap
|
|
|
60
60
|
|
|
61
61
|
Pre-execution approval pauses a tool call _before_ its `execute` function runs. The LLM still decides which tool to call and provides arguments, but `execute` doesn't run until you explicitly approve.
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
The flags control this, combined with OR logic. If _either_ is `true`, the call pauses:
|
|
64
64
|
|
|
65
65
|
| Flag | Where to set it | Scope |
|
|
66
66
|
| --------------------------- | --------------------------------- | ------------------------------------------- |
|
|
@@ -92,7 +92,7 @@ for await (const chunk of stream.fullStream) {
|
|
|
92
92
|
|
|
93
93
|
#### Conditional approval with a function
|
|
94
94
|
|
|
95
|
-
Instead of a boolean, `requireToolApproval` accepts a function that decides per tool call. It receives the `toolName`, the `args` the model passed, the `requestContext`, and the `workspace`. Return `true` to require approval for that call, or `false` to allow it. This lets you gate approval
|
|
95
|
+
Instead of a boolean, `requireToolApproval` accepts a function that decides per tool call. It receives the `toolName`, the `args` the model passed, the `requestContext`, and the `workspace`. Return `true` to require approval for that call, or `false` to allow it. This lets you gate approval at runtime, for example, only for tools whose name matches a pattern:
|
|
96
96
|
|
|
97
97
|
```typescript
|
|
98
98
|
const stream = await agent.stream('Clean up old records', {
|
|
@@ -100,10 +100,82 @@ const stream = await agent.stream('Clean up old records', {
|
|
|
100
100
|
})
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
-
A tool's own `requireApproval` setting
|
|
103
|
+
A tool's own `requireApproval` setting takes precedence over the function above. Its rule decides whether that tool needs approval. If the function throws, the call requires approval as a fail-safe.
|
|
104
104
|
|
|
105
105
|
> **Note:** Function-based `requireToolApproval` is only available on regular `stream()` / `generate()` calls. Durable agents and stored agents persist their options, and a function can't be serialized, so they accept only a boolean. If you pass a function in those contexts it falls back to requiring approval for every tool call.
|
|
106
106
|
|
|
107
|
+
#### Bind approval to the exact tool arguments
|
|
108
|
+
|
|
109
|
+
For sensitive tools, bind the approval to the exact tool name and arguments that were shown to the reviewer. If those arguments drift before execution, the tool shouldn't run under the old approval.
|
|
110
|
+
|
|
111
|
+
The `tool-call-approval` chunk already includes `toolName`, `toolCallId`, and `args`. You can fingerprint those fields when the approval request is shown. The example below uses a simple JSON string as the fingerprint, but in production you should use a stable hash of the tool name and arguments:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { Agent } from '@mastra/core/agent'
|
|
115
|
+
|
|
116
|
+
// For your production usecase, build a stable hash of the tool name and args
|
|
117
|
+
function actionFingerprint(toolName: string, args: unknown) {
|
|
118
|
+
const payload = JSON.stringify({ toolName, args })
|
|
119
|
+
return `fingerprint-${payload}`
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const sensitiveTools = new Set(['issue_refund', 'delete_record'])
|
|
123
|
+
const approvedFingerprints = new Set<string>()
|
|
124
|
+
|
|
125
|
+
export const approvalBoundAgent = new Agent({
|
|
126
|
+
id: 'approval-bound-agent',
|
|
127
|
+
name: 'Approval Bound Agent',
|
|
128
|
+
model: 'openai/gpt-5.6-sol',
|
|
129
|
+
tools: { issueRefundTool, deleteRecordTool },
|
|
130
|
+
hooks: {
|
|
131
|
+
beforeToolCall: ({ toolName, input }) => {
|
|
132
|
+
if (!sensitiveTools.has(toolName)) return
|
|
133
|
+
|
|
134
|
+
const fingerprint = actionFingerprint(toolName, input)
|
|
135
|
+
if (!approvedFingerprints.delete(fingerprint)) {
|
|
136
|
+
return {
|
|
137
|
+
proceed: false,
|
|
138
|
+
output: `Tool call blocked: approval did not match ${toolName} arguments.`,
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
})
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const stream = await approvalBoundAgent.stream('Refund order ord-1042', {
|
|
148
|
+
requireToolApproval: ({ toolName }) => sensitiveTools.has(toolName),
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
async function consumeApprovalStream(currentStream: typeof stream) {
|
|
152
|
+
for await (const chunk of currentStream.fullStream) {
|
|
153
|
+
if (chunk.type === 'tool-call-approval') {
|
|
154
|
+
const { toolName, toolCallId, args } = chunk.payload
|
|
155
|
+
const fingerprint = actionFingerprint(toolName, args)
|
|
156
|
+
|
|
157
|
+
// Present toolName, args, and fingerprint to your approval UI.
|
|
158
|
+
const approved = await showApprovalDialog({ toolName, args, fingerprint })
|
|
159
|
+
|
|
160
|
+
const nextStream = approved
|
|
161
|
+
? await approveReviewedToolCall(currentStream.runId, toolCallId, fingerprint)
|
|
162
|
+
: await approvalBoundAgent.declineToolCall({ runId: currentStream.runId, toolCallId })
|
|
163
|
+
|
|
164
|
+
await consumeApprovalStream(nextStream)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async function approveReviewedToolCall(runId: string, toolCallId: string, fingerprint: string) {
|
|
170
|
+
approvedFingerprints.add(fingerprint)
|
|
171
|
+
return approvalBoundAgent.approveToolCall({ runId, toolCallId })
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
await consumeApprovalStream(stream)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
In production, store the approved fingerprint in durable storage scoped to the user, run, tool call, and policy version. The `Set` above is intentionally small so the boundary is easy to see: the approval is consumed once, and only for the same canonical tool arguments that were reviewed.
|
|
178
|
+
|
|
107
179
|
### Runtime suspension with `suspend()`
|
|
108
180
|
|
|
109
181
|
A tool can also pause _during_ its `execute` function by calling `suspend()`. This is useful when the tool starts running and then discovers it needs additional user input or confirmation before it can finish.
|
|
@@ -133,7 +205,7 @@ const weatherTool = createTool({
|
|
|
133
205
|
})
|
|
134
206
|
```
|
|
135
207
|
|
|
136
|
-
> **Note:** `suspend()` doesn't throw
|
|
208
|
+
> **Note:** `suspend()` doesn't throw, return immediately after calling it (e.g. `return await suspend({ ... })`). Code after `await suspend(...)` still runs before the tool pauses.
|
|
137
209
|
|
|
138
210
|
## Tool approval with `generate()`
|
|
139
211
|
|
|
@@ -172,11 +244,11 @@ if (output.finishReason === 'suspended') {
|
|
|
172
244
|
| Decline method | `declineToolCall({ runId })` | `declineToolCallGenerate({ runId, toolCallId })` |
|
|
173
245
|
| Result | Stream to iterate | Full output object |
|
|
174
246
|
|
|
175
|
-
> **Note:** `toolCallId` is optional on all four methods. Pass it when multiple tool calls may be pending
|
|
247
|
+
> **Note:** `toolCallId` is optional on all four methods. Pass it when multiple tool calls may be pending (common in supervisor agents). When omitted, the agent resumes the most recent suspended tool call.
|
|
176
248
|
|
|
177
249
|
## Tool-level approval
|
|
178
250
|
|
|
179
|
-
Instead of pausing every tool call at the agent level, you can mark individual tools as requiring approval.
|
|
251
|
+
Instead of pausing every tool call at the agent level, you can mark individual tools as requiring approval. You get fine-grained control: only specific tools pause, while others execute immediately.
|
|
180
252
|
|
|
181
253
|
### Approval using `requireApproval`
|
|
182
254
|
|
|
@@ -303,7 +375,9 @@ const agent = new Agent({
|
|
|
303
375
|
})
|
|
304
376
|
```
|
|
305
377
|
|
|
306
|
-
When enabled, the agent detects suspended tools from message history on the next user message
|
|
378
|
+
When enabled, the agent detects suspended tools from message history on the next user message. It extracts `resumeData` based on the tool's `resumeSchema`, then automatically resumes the tool.
|
|
379
|
+
|
|
380
|
+
The following example shows a complete conversational flow:
|
|
307
381
|
|
|
308
382
|
```typescript
|
|
309
383
|
import { createTool } from '@mastra/core/tools'
|
|
@@ -386,7 +460,7 @@ Both approaches work with the same tool definitions. Automatic resumption trigge
|
|
|
386
460
|
|
|
387
461
|
## Resuming after a restart
|
|
388
462
|
|
|
389
|
-
The examples above hold on to `stream.runId` between suspension and approval. That works while the process stays alive, but in production the approval often arrives later
|
|
463
|
+
The examples above hold on to `stream.runId` between suspension and approval. That works while the process stays alive, but in production the approval often arrives later, after a page refresh, a server restart, or on a different server instance behind a load balancer.
|
|
390
464
|
|
|
391
465
|
Use [`listSuspendedRuns()`](https://mastra.ai/reference/agents/listSuspendedRuns) to rediscover the pending run for a conversation from storage:
|
|
392
466
|
|
|
@@ -414,7 +488,7 @@ if (run && toolCall) {
|
|
|
414
488
|
}
|
|
415
489
|
```
|
|
416
490
|
|
|
417
|
-
Each returned run includes the suspended tool calls (`toolCallId`, `toolName`, `args`, and `requiresApproval`). Approval suspensions (`requiresApproval: true`) are answered with `approveToolCall()` / `declineToolCall()`, while `suspend()`-based suspensions carry their `suspendPayload` and expect `resumeStream()` with resume data
|
|
491
|
+
Each returned run includes the suspended tool calls (`toolCallId`, `toolName`, `args`, and `requiresApproval`). Approval suspensions (`requiresApproval: true`) are answered with `approveToolCall()` / `declineToolCall()`, while `suspend()`-based suspensions carry their `suspendPayload` and expect `resumeStream()` with resume data, so you can rebuild the right UI for either flow without keeping any state in memory.
|
|
418
492
|
|
|
419
493
|
`sendToolApproval()` uses the same storage-backed discovery automatically: when no active run is found in memory for the thread, it looks up the suspended run in storage before failing. If several suspended runs match the thread, pass a `toolCallId` to disambiguate.
|
|
420
494
|
|
|
@@ -477,7 +551,7 @@ const supervisorAgent = new Agent({
|
|
|
477
551
|
name: 'Supervisor Agent',
|
|
478
552
|
instructions: `You coordinate data retrieval tasks.
|
|
479
553
|
Delegate to data-agent for user lookups.`,
|
|
480
|
-
model: 'openai/gpt-5.
|
|
554
|
+
model: 'openai/gpt-5.6-sol',
|
|
481
555
|
agents: { dataAgent },
|
|
482
556
|
memory: new Memory(),
|
|
483
557
|
})
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Agent networks
|
|
4
4
|
|
|
5
|
-
> **Deprecated
|
|
5
|
+
> **Deprecated:** Agent networks are deprecated and will be removed in a future major release. [Supervisor agents](https://mastra.ai/docs/agents/supervisor-agents) using `agent.stream()` or `agent.generate()` are now the recommended approach. It provides the same multi-agent coordination with better control, a simpler API, and easier debugging.
|
|
6
6
|
>
|
|
7
7
|
> See the [migration guide](https://mastra.ai/guides/migrations/network-to-supervisor) to upgrade.
|
|
8
8
|
|
|
@@ -29,7 +29,7 @@ export const routingAgent = new Agent({
|
|
|
29
29
|
name: 'Routing Agent',
|
|
30
30
|
instructions: `
|
|
31
31
|
You are a network of writers and researchers. The user will ask you to research a topic. Always respond with a complete report—no bullet points. Write in full paragraphs, like a blog post. Do not answer with incomplete or uncertain information.`,
|
|
32
|
-
model: 'openai/gpt-5.
|
|
32
|
+
model: 'openai/gpt-5.6-sol',
|
|
33
33
|
agents: {
|
|
34
34
|
researchAgent,
|
|
35
35
|
writingAgent,
|