@mastra/libsql 1.12.1 → 1.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @mastra/libsql
2
2
 
3
+ ## 1.13.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added LibSQL storage support for durable harness sessions. ([#17712](https://github.com/mastra-ai/mastra/pull/17712))
8
+
9
+ ```ts
10
+ const storage = new LibSQLStore({ id: 'mastra-storage', url: 'file:./mastra.db' });
11
+
12
+ const harness = new Harness({
13
+ ownerId: 'my-app',
14
+ agent,
15
+ memory,
16
+ storage,
17
+ modes: [{ id: 'default', defaultModelId: '__GATEWAY_OPENAI_MODEL__' }],
18
+ defaultModeId: 'default',
19
+ });
20
+ ```
21
+
22
+ - Add `ThreadStateLibSQL`, the LibSQL implementation of the new `ThreadStateStorage` domain. It persists per-thread, per-type state (e.g. the agent task list under `type: "task"`) in the `mastra_thread_state` table, keyed by `(threadId, type)`. Composing a LibSQL store wires this domain automatically, so an agent's task list now survives a process restart. ([#17820](https://github.com/mastra-ai/mastra/pull/17820))
23
+
24
+ ### Patch Changes
25
+
26
+ - dependencies updates: ([#17148](https://github.com/mastra-ai/mastra/pull/17148))
27
+ - Updated dependency [`@libsql/client@^0.17.3` ↗︎](https://www.npmjs.com/package/@libsql/client/v/0.17.3) (from `^0.15.15`, in `dependencies`)
28
+
29
+ - Fixed concurrent writes silently disappearing when using LibSQL with a local (`file:`) database. ([#16796](https://github.com/mastra-ai/mastra/pull/16796))
30
+
31
+ LibSQL backs a local database with a single connection. When one operation held an interactive write transaction (for example, persisting workflow snapshots) and another operation wrote at the same time (for example, creating a dataset experiment), the second write could be swept into the open transaction and rolled back — so it appeared to succeed but never persisted. This surfaced as concurrent agent/workflow runs losing unrelated records.
32
+
33
+ Writes on a LibSQL client are now serialized, so a write issued during an in-flight transaction no longer interleaves with it.
34
+
35
+ - Updated dependencies [[`575f815`](https://github.com/mastra-ai/mastra/commit/575f815c5c3567b71c0b83cbb7fa98c8253a9d9c), [`306909a`](https://github.com/mastra-ai/mastra/commit/306909a693de77d709b38706e2673c9547d24a28), [`5191af8`](https://github.com/mastra-ai/mastra/commit/5191af80c799eea25357c545fc05d91b3883531d), [`43bd3d4`](https://github.com/mastra-ai/mastra/commit/43bd3d421987463fdf35386a45199c49499ed069), [`e6fa79e`](https://github.com/mastra-ai/mastra/commit/e6fa79ec72a2ddffdd25e85270398951e9d552a4), [`904bcdf`](https://github.com/mastra-ai/mastra/commit/904bcdf7b8004aa7be823f9f70ca63580e47e470), [`7f5ee1d`](https://github.com/mastra-ai/mastra/commit/7f5ee1dca46daee8d2817f2ebe49e6335da81956), [`1e9aab5`](https://github.com/mastra-ai/mastra/commit/1e9aab50ff11e6e88fde4d7cbf512c44a9fe8d61), [`bf8eb6d`](https://github.com/mastra-ai/mastra/commit/bf8eb6d0ec213a403eb9265a594ad283c44ab3dc), [`493a328`](https://github.com/mastra-ai/mastra/commit/493a328f4346a1deeb9f1e2e44c8f2a3a4d7591b), [`029a414`](https://github.com/mastra-ai/mastra/commit/029a4141719793bd3e898a39eb5a0466a55f5f3a), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`d371ac1`](https://github.com/mastra-ai/mastra/commit/d371ac1d9820afaaf7cfdbc380a475946a994d8f), [`cf182b7`](https://github.com/mastra-ai/mastra/commit/cf182b7fb495767946d9840ef29f19cfa906f31f), [`a049c2a`](https://github.com/mastra-ai/mastra/commit/a049c2a9dfb41d0ee2e7a28874a88cd64fd5669f), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`2a96528`](https://github.com/mastra-ai/mastra/commit/2a9652848dfa3c5a2426f952e9d93554c26fd90f), [`2656d9c`](https://github.com/mastra-ai/mastra/commit/2656d9c2976d4f3354253bfbbbf9b88a1b2bbf34), [`63e3fe1`](https://github.com/mastra-ai/mastra/commit/63e3fe13cc1ea96f91d7c68aea92f400faf9e4da), [`1d4ce8d`](https://github.com/mastra-ai/mastra/commit/1d4ce8daaa54511f325c1b609d31b8e54009d677), [`8c68372`](https://github.com/mastra-ai/mastra/commit/8c68372e85fe0b066ec12c58bd29ffb93e54c552)]:
36
+ - @mastra/core@1.42.0-alpha.4
37
+
3
38
  ## 1.12.1
4
39
 
5
40
  ### Patch Changes
@@ -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: "1.12.1"
6
+ version: "1.13.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.12.1",
2
+ "version": "1.13.0-alpha.0",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -9,6 +9,7 @@ The Agent Builder lets you build, configure, and operate Mastra agents all withi
9
9
  - [**Memory**](https://mastra.ai/docs/agent-builder/memory): Configure the default memory shape for every Builder-created agent.
10
10
  - [**Access control**](https://mastra.ai/docs/agent-builder/access-control): Gate the Builder behind Mastra RBAC roles and permissions.
11
11
  - [**Channels**](https://mastra.ai/docs/agent-builder/channels): Connect Builder-created agents to Slack and other channels.
12
+ - [**Tool providers**](https://mastra.ai/docs/agent-builder/integrations): Connect Builder-created agents to third-party apps through OAuth-backed tool providers.
12
13
  - [**Skill registries**](https://mastra.ai/docs/agent-builder/skill-registries): Browse and install community skills from opt-in registries.
13
14
  - [**Deploying**](https://mastra.ai/docs/agent-builder/deploying): Swap local primitives for cloud-backed storage, filesystems, and sandboxes.
14
15
 
@@ -96,7 +96,7 @@ const stream = await agent.stream('Clean up old records', {
96
96
  })
97
97
  ```
98
98
 
99
- A tool's own `requireApproval` setting still takes precedence: if a tool defines its own approval rule, that rule decides for that tool and the function above does not override it. If the function throws, the call requires approval (fail-safe).
99
+ A tool's own `requireApproval` setting still takes precedence: if a tool defines its own approval rule, that rule decides for that tool and the function above doesn't override it. If the function throws, the call requires approval (fail-safe).
100
100
 
101
101
  > **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.
102
102
 
@@ -106,7 +106,7 @@ A tool can also pause _during_ its `execute` function by calling `suspend()`. Th
106
106
 
107
107
  The stream emits a `tool-call-suspended` chunk with a custom payload defined by the tool's `suspendSchema`. You resume by calling `resumeStream()` with data matching the tool's `resumeSchema`.
108
108
 
109
- > **Note:** `suspend()` does not throw — return immediately after calling it (e.g. `return await suspend({ ... })`). Code after `await suspend(...)` still runs before the tool pauses.
109
+ > **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.
110
110
 
111
111
  ## Tool approval with `generate()`
112
112
 
@@ -413,12 +413,12 @@ const memory = new Memory({
413
413
  What changes:
414
414
 
415
415
  - **Storage is identical.** The same resource/thread `workingMemory` field is read and written.
416
- - **The tool is the same shape, exposed under a new name.** Writes still flow through the same underlying tool; on this path it is registered as `setWorkingMemory` (instead of `updateWorkingMemory`). The rename keeps legacy strip filters from removing tool-call parts so they persist as a normal audit trail and the next model step picks the new value up automatically.
416
+ - **The tool is the same shape, exposed under a new name.** Writes still flow through the same underlying tool; on this path it's registered as `setWorkingMemory` (instead of `updateWorkingMemory`). The rename keeps legacy strip filters from removing tool-call parts so they persist as a normal audit trail and the next model step picks the new value up automatically.
417
417
  - **Delivery only.** Instead of folding into the system prompt, `Memory` auto-attaches a `WorkingMemoryStateProcessor` that emits the current working memory as a `state` signal with `stateId: 'working-memory'`.
418
418
 
419
419
  You inherit the standard state-signal benefits: thread-scoped tracking metadata, `cacheKey` dedup so identical snapshots are only emitted once, and `contextWindow.hasSnapshot` re-injection when an older snapshot rolls out of the window.
420
420
 
421
- The default (`useStateSignals: false`) keeps the existing system-message behavior unchanged. `useStateSignals` is not supported with template working memory `version: 'vnext'`.
421
+ The default (`useStateSignals: false`) keeps the existing system-message behavior unchanged. `useStateSignals` isn't supported with template working memory `version: 'vnext'`.
422
422
 
423
423
  ## Examples
424
424
 
@@ -27,6 +27,24 @@ export const mastra = new Mastra({
27
27
  })
28
28
  ```
29
29
 
30
+ Enable scheduled notification dispatch when deferred notification records and notification summaries should be delivered automatically through the workflow scheduler:
31
+
32
+ ```typescript
33
+ export const mastra = new Mastra({
34
+ agents: { supportAgent },
35
+ storage,
36
+ notifications: {
37
+ dispatch: {
38
+ enabled: true,
39
+ cron: '*/1 * * * *',
40
+ batchSize: 100,
41
+ },
42
+ },
43
+ })
44
+ ```
45
+
46
+ `notifications.dispatch.enabled` registers an internal workflow with the default cron `*/1 * * * *`. The dispatcher reads due notification records from storage, groups summaries by `agentId`, `resourceId`, and `threadId`, and emits signals through the agent thread runtime. It isn't a user-facing entrypoint.
47
+
30
48
  ## Constructor parameters
31
49
 
32
50
  Visit the [Configuration reference](https://mastra.ai/reference/configuration) for detailed documentation on all available configuration options.
@@ -67,6 +85,16 @@ Visit the [Configuration reference](https://mastra.ai/reference/configuration) f
67
85
 
68
86
  **memory** (`Record<string, MastraMemory>`): Memory instances to register. These can be referenced by stored agents and resolved at runtime. Structured as a key-value pair, with keys being the registry key and values being memory instances. (Default: `{}`)
69
87
 
88
+ **notifications** (`object`): Runtime configuration for notification signal dispatch.
89
+
90
+ **notifications.dispatch** (`NotificationDispatchConfig`): Scheduled dispatch configuration for deferred notifications and notification summaries. Dispatch is enabled by default.
91
+
92
+ **notifications.dispatch.enabled** (`boolean`): Set to \`false\` to opt out of automatic scheduled notification dispatch.
93
+
94
+ **notifications.dispatch.cron** (`string`): Cron schedule used by the internal notification dispatcher workflow.
95
+
96
+ **notifications.dispatch.batchSize** (`number`): Maximum number of due notification records to process per dispatch run.
97
+
70
98
  **versions** (`VersionOverrides`): Global version overrides for sub-agent delegation. When a supervisor agent delegates to a sub-agent, these overrides determine which stored version of that sub-agent to use instead of the code-defined default. Requires the editor package to be configured. See \[Sub-agent versioning]\(/docs/editor/overview#sub-agent-versioning) for details.
71
99
 
72
100
  **versions.agents** (`Record<string, VersionSelector>`): A map of agent IDs to their version selectors. Each selector can target a specific version by ID or by publication status.
@@ -240,6 +240,38 @@ const storage = new MastraCompositeStore({
240
240
  })
241
241
  ```
242
242
 
243
- > **Note:** `ObservabilityStorageClickhouseVNext` is the current observability domain implementation. The legacy `ObservabilityStorageClickhouse` class is also exported and remains supported for projects that have not migrated. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for details.
243
+ > **Note:** `ObservabilityStorageClickhouseVNext` is the current observability domain implementation. The legacy `ObservabilityStorageClickhouse` class is also exported and remains supported for projects that haven't migrated. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for details.
244
244
 
245
- > **Info:** This approach is also required when using storage providers that don't support observability (like Convex, DynamoDB, or Cloudflare). See the [MastraStorageExporter documentation](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage) for the full list of supported providers.
245
+ ### Replicated ClickHouse for multi-replica clusters
246
+
247
+ For self-managed ClickHouse clusters with multiple replicas, set `replication` so Mastra emits `ReplicatedMergeTree` engines and applies `ON CLUSTER` to its DDL:
248
+
249
+ ```typescript
250
+ import { MastraCompositeStore } from '@mastra/core/storage'
251
+ import { MemoryPG, WorkflowsPG, ScoresPG } from '@mastra/pg'
252
+ import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
253
+
254
+ const storage = new MastraCompositeStore({
255
+ id: 'composite',
256
+ domains: {
257
+ memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
258
+ workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
259
+ scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
260
+ observability: new ObservabilityStorageClickhouseVNext({
261
+ url: process.env.CLICKHOUSE_URL,
262
+ username: process.env.CLICKHOUSE_USERNAME,
263
+ password: process.env.CLICKHOUSE_PASSWORD,
264
+ replication: {
265
+ cluster: 'production_cluster',
266
+ // Optional (defaults shown):
267
+ // zookeeperPath: '/clickhouse/tables/{shard}/{database}/{table}',
268
+ // replicaName: '{replica}',
269
+ },
270
+ }),
271
+ },
272
+ })
273
+ ```
274
+
275
+ Do not set `replication` on ClickHouse Cloud. Cloud rewrites `MergeTree` to `SharedMergeTree` server-side. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for the full config shape and operator notes.
276
+
277
+ > **Info:** This approach is also required when using storage providers that don't support observability (like Convex, DynamoDB, or Cloudflare). See the [MastraStorageExporter documentation](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage) for the full list of supported providers.
@@ -136,6 +136,6 @@ const thread = await memoryStore?.getThreadById({ threadId: '...' })
136
136
 
137
137
  ## Observability
138
138
 
139
- libSQL supports observability and is ideal for local development. Use the `realtime` [tracing strategy](https://mastra.ai/docs/observability/tracing/exporters/mastra-storage) for immediate visibility while debugging.
139
+ libSQL supports observability and is ideal for local development. Use the `realtime` [tracing strategy](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage) for immediate visibility while debugging.
140
140
 
141
141
  For production environments with higher trace volumes, consider using [PostgreSQL](https://mastra.ai/reference/storage/postgresql) or [ClickHouse via composite storage](https://mastra.ai/reference/storage/composite).