@mastra/libsql 1.8.0 → 1.8.1-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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @mastra/libsql
2
2
 
3
+ ## 1.8.1-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Added `entityVersionId`, `parentEntityVersionId`, and `rootEntityVersionId` columns to observability storage tables (spans, metrics, scores, feedback, logs) for filtering and grouping traces by entity version. Added ALTER TABLE migrations for existing databases. Added `targetType`, `targetId`, `agentVersion`, and `status` filters to `listExperiments`, and `traceId` and `status` filters to `listExperimentResults`. ([#15317](https://github.com/mastra-ai/mastra/pull/15317))
8
+
9
+ - Updated dependencies [[`cbdf3e1`](https://github.com/mastra-ai/mastra/commit/cbdf3e12b3d0c30a6e5347be658e2009648c130a), [`8fe46d3`](https://github.com/mastra-ai/mastra/commit/8fe46d354027f3f0f0846e64219772348de106dd), [`18c67db`](https://github.com/mastra-ai/mastra/commit/18c67dbb9c9ebc26f26f65f7d3ff836e5691ef46), [`8dcc77e`](https://github.com/mastra-ai/mastra/commit/8dcc77e78a5340f5848f74b9e9f1b3da3513c1f5), [`aa67fc5`](https://github.com/mastra-ai/mastra/commit/aa67fc59ee8a5eeff1f23eb05970b8d7a536c8ff), [`fa8140b`](https://github.com/mastra-ai/mastra/commit/fa8140bcd4251d2e3ac85fdc5547dfc4f372b5be), [`190f452`](https://github.com/mastra-ai/mastra/commit/190f45258b0640e2adfc8219fa3258cdc5b8f071), [`7e7bf60`](https://github.com/mastra-ai/mastra/commit/7e7bf606886bf374a6f9d4ca9b09dd83d0533372), [`184907d`](https://github.com/mastra-ai/mastra/commit/184907d775d8609c03c26e78ccaf37315f3aa287), [`0c4cd13`](https://github.com/mastra-ai/mastra/commit/0c4cd131931c04ac5405373c932a242dbe88edd6), [`b16a753`](https://github.com/mastra-ai/mastra/commit/b16a753d5748440248d7df82e29bb987a9c8386c)]:
10
+ - @mastra/core@1.25.0-alpha.3
11
+
12
+ ## 1.8.1-alpha.0
13
+
14
+ ### Patch Changes
15
+
16
+ - Fixed "column does not exist" errors when using experiment review features on databases created before the review pipeline was introduced. Startup now automatically migrates older experiment tables to the latest schema. ([#15304](https://github.com/mastra-ai/mastra/pull/15304))
17
+
3
18
  ## 1.8.0
4
19
 
5
20
  ### Minor 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.8.0"
6
+ version: "1.8.1-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.0",
2
+ "version": "1.8.1-alpha.1",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -307,8 +307,8 @@ Both scenarios are safe - guardrails prevent inappropriate content from being pe
307
307
 
308
308
  ## Related documentation
309
309
 
310
- - [Processors](https://mastra.ai/docs/agents/processors) - General processor concepts and custom processor creation
311
- - [Guardrails](https://mastra.ai/docs/agents/guardrails) - Security and validation processors
312
- - [Memory Overview](https://mastra.ai/docs/memory/overview) - Memory types and configuration
310
+ - [Processors](https://mastra.ai/docs/agents/processors): General processor concepts and custom processor creation
311
+ - [Guardrails](https://mastra.ai/docs/agents/guardrails): Security and validation processors
312
+ - [Memory Overview](https://mastra.ai/docs/memory/overview): Memory types and configuration
313
313
 
314
314
  When creating custom processors avoid mutating the input `messages` array or its objects directly.
@@ -6,6 +6,12 @@ You can also retrieve message history to display past conversations in your UI.
6
6
 
7
7
  > **Info:** Each message belongs to a thread (the conversation) and a resource (the user or entity it's associated with). See [Threads and resources](https://mastra.ai/docs/memory/storage) for more detail.
8
8
 
9
+ > **Warning:** When you use memory with a client application, send **only the new message** from the client instead of the full conversation history.
10
+ >
11
+ > Sending the full history is redundant because Mastra loads messages from storage, and it can cause message ordering bugs when client-side timestamps conflict with stored timestamps.
12
+ >
13
+ > For an AI SDK example, see [Using Mastra Memory](https://mastra.ai/guides/build-your-ui/ai-sdk-ui).
14
+
9
15
  ## Getting started
10
16
 
11
17
  Install the Mastra memory module along with a [storage adapter](https://mastra.ai/docs/memory/storage) for your database. The examples below use `@mastra/libsql`, which stores data locally in a `mastra.db` file.
@@ -100,8 +106,8 @@ await agent.stream('Hello', {
100
106
 
101
107
  You can use this history in two ways:
102
108
 
103
- - **Automatic inclusion** - Mastra automatically fetches and includes recent messages in the context window. By default, it includes the last 10 messages, keeping agents grounded in the conversation. You can adjust this number with `lastMessages`, but in most cases you don't need to think about it.
104
- - [**Manual querying**](#querying) - For more control, use the `recall()` function to query threads and messages directly. This lets you choose exactly which memories are included in the context window, or fetch messages to render conversation history in your UI.
109
+ - **Automatic inclusion**: Mastra automatically fetches and includes recent messages in the context window. By default, it includes the last 10 messages, keeping agents grounded in the conversation. You can adjust this number with `lastMessages`, but in most cases you don't need to think about it.
110
+ - [**Manual querying**](#querying): For more control, use the `recall()` function to query threads and messages directly. This lets you choose exactly which memories are included in the context window, or fetch messages to render conversation history in your UI.
105
111
 
106
112
  > **Tip:** When memory is enabled, [Studio](https://mastra.ai/docs/studio/overview) uses message history to display past conversations in the chat sidebar.
107
113
 
@@ -118,8 +118,6 @@ export const agent = new Agent({
118
118
  })
119
119
  ```
120
120
 
121
- > **Warning:** Agent-level storage isn't supported when using [Mastra Cloud Store](https://mastra.ai/docs/mastra-cloud/deployment). If you use Mastra Cloud Store, configure storage on the Mastra instance instead. This limitation doesn't apply if you bring your own database.
122
-
123
121
  ## Threads and resources
124
122
 
125
123
  Mastra organizes conversations using two identifiers:
@@ -397,4 +397,4 @@ const response = await agent.generate('What do you know about me?', {
397
397
 
398
398
  - [Working memory with template](https://github.com/mastra-ai/mastra/tree/main/examples/memory-with-template)
399
399
  - [Working memory with schema](https://github.com/mastra-ai/mastra/tree/main/examples/memory-with-schema)
400
- - [Per-resource working memory](https://github.com/mastra-ai/mastra/tree/main/examples/memory-per-resource-example) - Complete example showing resource-scoped memory persistence
400
+ - [Per-resource working memory](https://github.com/mastra-ai/mastra/tree/main/examples/memory-per-resource-example): Complete example showing resource-scoped memory persistence
@@ -134,7 +134,7 @@ const { text } = await generateText({
134
134
 
135
135
  ## Related
136
136
 
137
- - [`withMastra()`](https://mastra.ai/reference/ai-sdk/with-mastra) - API reference for `withMastra()`
138
- - [Processors](https://mastra.ai/docs/agents/processors) - Learn about input and output processors
139
- - [Memory](https://mastra.ai/docs/memory/overview) - Overview of Mastra's memory system
140
- - [AI SDK UI](https://mastra.ai/guides/build-your-ui/ai-sdk-ui) - Using AI SDK UI hooks with Mastra agents, workflows, and networks
137
+ - [`withMastra()`](https://mastra.ai/reference/ai-sdk/with-mastra): API reference for `withMastra()`
138
+ - [Processors](https://mastra.ai/docs/agents/processors): Learn about input and output processors
139
+ - [Memory](https://mastra.ai/docs/memory/overview): Overview of Mastra's memory system
140
+ - [AI SDK UI](https://mastra.ai/guides/build-your-ui/ai-sdk-ui): Using AI SDK UI hooks with Mastra agents, workflows, and networks
package/dist/index.cjs CHANGED
@@ -3904,6 +3904,16 @@ var ExperimentsLibSQL = class extends storage.ExperimentsStorage {
3904
3904
  tableName: storage.TABLE_EXPERIMENT_RESULTS,
3905
3905
  schema: storage.EXPERIMENT_RESULTS_SCHEMA
3906
3906
  });
3907
+ await this.#db.alterTable({
3908
+ tableName: storage.TABLE_EXPERIMENTS,
3909
+ schema: storage.EXPERIMENTS_SCHEMA,
3910
+ ifNotExists: ["agentVersion"]
3911
+ });
3912
+ await this.#db.alterTable({
3913
+ tableName: storage.TABLE_EXPERIMENT_RESULTS,
3914
+ schema: storage.EXPERIMENT_RESULTS_SCHEMA,
3915
+ ifNotExists: ["status", "tags"]
3916
+ });
3907
3917
  await this.#client.execute({
3908
3918
  sql: `CREATE INDEX IF NOT EXISTS idx_experiments_datasetid ON "${storage.TABLE_EXPERIMENTS}" ("datasetId")`,
3909
3919
  args: []
@@ -4124,6 +4134,22 @@ var ExperimentsLibSQL = class extends storage.ExperimentsStorage {
4124
4134
  conditions.push("datasetId = ?");
4125
4135
  queryParams.push(args.datasetId);
4126
4136
  }
4137
+ if (args.targetType) {
4138
+ conditions.push("targetType = ?");
4139
+ queryParams.push(args.targetType);
4140
+ }
4141
+ if (args.targetId) {
4142
+ conditions.push("targetId = ?");
4143
+ queryParams.push(args.targetId);
4144
+ }
4145
+ if (args.agentVersion) {
4146
+ conditions.push("agentVersion = ?");
4147
+ queryParams.push(args.agentVersion);
4148
+ }
4149
+ if (args.status) {
4150
+ conditions.push("status = ?");
4151
+ queryParams.push(args.status);
4152
+ }
4127
4153
  const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
4128
4154
  const countResult = await this.#client.execute({
4129
4155
  sql: `SELECT COUNT(*) as count FROM ${storage.TABLE_EXPERIMENTS} ${whereClause}`,
@@ -4326,6 +4352,14 @@ var ExperimentsLibSQL = class extends storage.ExperimentsStorage {
4326
4352
  const { page, perPage: perPageInput } = args.pagination;
4327
4353
  const conditions = ["experimentId = ?"];
4328
4354
  const queryParams = [args.experimentId];
4355
+ if (args.traceId) {
4356
+ conditions.push("traceId = ?");
4357
+ queryParams.push(args.traceId);
4358
+ }
4359
+ if (args.status) {
4360
+ conditions.push("status = ?");
4361
+ queryParams.push(args.status);
4362
+ }
4329
4363
  const whereClause = `WHERE ${conditions.join(" AND ")}`;
4330
4364
  const countResult = await this.#client.execute({
4331
4365
  sql: `SELECT COUNT(*) as count FROM ${storage.TABLE_EXPERIMENT_RESULTS} ${whereClause}`,