@mastra/libsql 1.18.0-alpha.1 → 1.19.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 +47 -0
- 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 +1 -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 +11 -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 +4 -4
- 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 +24 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -6
- 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/package.json +5 -5
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Storage grows without bound by default. Retention is an opt-in, age-based cleanup system: you declare per-table `maxAge` policies in the `retention` config, then call `storage.prune()` to delete rows older than their configured age. Anything you don't configure is kept forever, so there is no behavior change until you opt in.
|
|
6
6
|
|
|
7
|
-
`prune()` deletes rows. It caps growth and is safe to run against large tables (batched, bounded, resumable, cancellable). It never reclaims disk
|
|
7
|
+
`prune()` deletes rows. It caps growth and is safe to run against large tables (batched, bounded, resumable, cancellable). It never reclaims disk: on SQLite/libSQL the freed pages are reused by future writes so the file stops growing, but handing disk back to the OS (for example a `VACUUM`) is left to the underlying database and the operator to manage.
|
|
8
8
|
|
|
9
|
-
Retention covers **growth tables** only
|
|
9
|
+
Retention covers **growth tables** only: tables that accumulate rows unbounded as a side effect of normal operation (conversation history, telemetry, job and run records, schedule fire history, event feeds). User-authored artifacts and config (agents, skills, workspaces, prompt blocks, datasets, schedule definitions, channel installations, and so on) grow with user intent and are edited or deleted explicitly, so they're not valid retention keys.
|
|
10
10
|
|
|
11
11
|
The reference implementations are [libSQL](https://mastra.ai/reference/storage/libsql), [PostgreSQL](https://mastra.ai/reference/storage/postgresql), and [MongoDB](https://mastra.ai/reference/storage/mongodb). Other adapters keep rows forever until they implement retention.
|
|
12
12
|
|
|
@@ -31,7 +31,7 @@ const storage = new LibSQLStore({
|
|
|
31
31
|
},
|
|
32
32
|
})
|
|
33
33
|
|
|
34
|
-
// Wire this to your own cron/scheduler
|
|
34
|
+
// Wire this to your own cron/scheduler: Mastra never runs it for you.
|
|
35
35
|
const results = await storage.prune()
|
|
36
36
|
```
|
|
37
37
|
|
|
@@ -65,35 +65,35 @@ Set the `retention` field on the store config.
|
|
|
65
65
|
|
|
66
66
|
### Retention-eligible tables
|
|
67
67
|
|
|
68
|
-
Each domain declares which of its tables can be age-pruned and which timestamp column anchors the comparison. The anchor is chosen so `maxAge` means what you'd expect for that data
|
|
69
|
-
|
|
70
|
-
| Domain | Table key | Anchor column | `maxAge` measures
|
|
71
|
-
| ----------------- | ------------------ | ---------------- |
|
|
72
|
-
| `memory` | `threads` | `createdAt` | Thread age
|
|
73
|
-
| `memory` | `messages` | `createdAt` | Message age
|
|
74
|
-
| `memory` | `resources` | `createdAt` | Resource age
|
|
75
|
-
| `threadState` | `threadState` | `updatedAt` | Inactivity
|
|
76
|
-
| `observability` | `spans` | `startedAt` | Span age
|
|
77
|
-
| `observability` | `metrics` | `timestamp` | Metric event age (v-next only)
|
|
78
|
-
| `observability` | `logs` | `timestamp` | Log event age (v-next only)
|
|
79
|
-
| `observability` | `scores` | `timestamp` | Score event age (v-next only)
|
|
80
|
-
| `observability` | `feedback` | `timestamp` | Feedback event age (v-next only)
|
|
81
|
-
| `scores` | `scorers` | `createdAt` | Score record age
|
|
82
|
-
| `workflows` | `workflowSnapshot` | `updatedAt` | Inactivity
|
|
83
|
-
| `backgroundTasks` | `backgroundTasks` | `completedAt` | Time since completion
|
|
84
|
-
| `experiments` | `experiments` | `completedAt` | Time since completion
|
|
85
|
-
| `notifications` | `notifications` | `createdAt` | Notification age
|
|
86
|
-
| `harness` | `sessions` | `createdAt` | Session record age
|
|
87
|
-
| `schedules` | `triggers` | `actual_fire_at` | Fire-history age (epoch-ms column)
|
|
68
|
+
Each domain declares which of its tables can be age-pruned and which timestamp column anchors the comparison. The anchor is chosen so `maxAge` means what you'd expect for that data. Append-only logs use creation time, and live state uses last activity. Jobs and runs use completion time, so in-flight work is never pruned.
|
|
69
|
+
|
|
70
|
+
| Domain | Table key | Anchor column | `maxAge` measures |
|
|
71
|
+
| ----------------- | ------------------ | ---------------- | ---------------------------------------------------------------- |
|
|
72
|
+
| `memory` | `threads` | `createdAt` | Thread age |
|
|
73
|
+
| `memory` | `messages` | `createdAt` | Message age |
|
|
74
|
+
| `memory` | `resources` | `createdAt` | Resource age |
|
|
75
|
+
| `threadState` | `threadState` | `updatedAt` | Inactivity: state for still-active threads survives |
|
|
76
|
+
| `observability` | `spans` | `startedAt` | Span age |
|
|
77
|
+
| `observability` | `metrics` | `timestamp` | Metric event age (v-next only) |
|
|
78
|
+
| `observability` | `logs` | `timestamp` | Log event age (v-next only) |
|
|
79
|
+
| `observability` | `scores` | `timestamp` | Score event age (v-next only) |
|
|
80
|
+
| `observability` | `feedback` | `timestamp` | Feedback event age (v-next only) |
|
|
81
|
+
| `scores` | `scorers` | `createdAt` | Score record age |
|
|
82
|
+
| `workflows` | `workflowSnapshot` | `updatedAt` | Inactivity, suspended or long-running workflows survive |
|
|
83
|
+
| `backgroundTasks` | `backgroundTasks` | `completedAt` | Time since completion, in-flight tasks (`NULL`) are never pruned |
|
|
84
|
+
| `experiments` | `experiments` | `completedAt` | Time since completion, running experiments are never pruned |
|
|
85
|
+
| `notifications` | `notifications` | `createdAt` | Notification age |
|
|
86
|
+
| `harness` | `sessions` | `createdAt` | Session record age |
|
|
87
|
+
| `schedules` | `triggers` | `actual_fire_at` | Fire-history age (epoch-ms column) |
|
|
88
88
|
|
|
89
89
|
> **Note:**
|
|
90
90
|
>
|
|
91
91
|
> - The memory `observational_memory` table has no timestamp anchor, so it can't be age-pruned and isn't a valid retention key.
|
|
92
92
|
> - Experiments prune as whole units: an aged experiment's result rows are deleted together with it (results cascade with their parent), so a run is never left partially deleted. Retention doesn't have a separate `results` key.
|
|
93
|
-
> - For `schedules`, the growth table is the fire history (`schedule_triggers`, one row per fire)
|
|
93
|
+
> - For `schedules`, the growth table is the fire history (`schedule_triggers`, one row per fire): schedule definitions are config and aren't pruned.
|
|
94
94
|
> - On PostgreSQL, timestamp anchors use the timezone-aware mirror columns (for example `createdAtZ`, `completedAtZ`).
|
|
95
95
|
> - LibSQL supports all domains above; PostgreSQL and MongoDB support all except `threadState` and `harness`, which they don't implement.
|
|
96
|
-
> - The v-next PostgreSQL observability domain stores signal events in day-partitioned tables (`spans`, `metrics`, `logs`, `scores`, `feedback`). For it, `prune()` drops whole day partitions (or TimescaleDB chunks) that are entirely older than the cutoff instead of deleting rows
|
|
96
|
+
> - The v-next PostgreSQL observability domain stores signal events in day-partitioned tables (`spans`, `metrics`, `logs`, `scores`, `feedback`). For it, `prune()` drops whole day partitions (or TimescaleDB chunks) that are entirely older than the cutoff instead of deleting rows: effective level of detail is one day, and a partition is only dropped once its entire day is past `maxAge`. `PruneResult.deleted` reports the number of rows in the dropped partitions.
|
|
97
97
|
|
|
98
98
|
## Methods
|
|
99
99
|
|
|
@@ -103,11 +103,11 @@ Each domain declares which of its tables can be age-pruned and which timestamp c
|
|
|
103
103
|
|
|
104
104
|
Deletes rows older than their configured `maxAge` across every domain that has a policy in `retention`. Returns one `PruneResult` per table touched. With no `retention` configured it's a no-op returning `[]`.
|
|
105
105
|
|
|
106
|
-
`prune()` is designed to be safe on tables with millions of rows. It deletes in bounded, batched chunks
|
|
106
|
+
`prune()` is designed to be safe on tables with millions of rows. It deletes in bounded, batched chunks (each batch is its own transaction) so it never takes a long lock or bloats the transaction log. It never runs a `VACUUM`.
|
|
107
107
|
|
|
108
|
-
Pass `options.retention` to replace the configured policies for that call only
|
|
108
|
+
Pass `options.retention` to replace the configured policies for that call only: for example to skip a domain (keep chat history) or prune more aggressively than the standing config. The store's configured `retention` is unchanged.
|
|
109
109
|
|
|
110
|
-
Anchor-column indexes are created lazily on the first `prune()` call for each table with a policy
|
|
110
|
+
Anchor-column indexes are created lazily on the first `prune()` call for each table with a policy (never at `init()`) so deployments that don't configure retention pay no extra index write or disk overhead. The first prune of an existing large table pays a one-time index build. Subsequent prunes reuse the index.
|
|
111
111
|
|
|
112
112
|
```typescript
|
|
113
113
|
const results = await storage.prune({
|
|
@@ -156,7 +156,7 @@ interface PruneResult {
|
|
|
156
156
|
|
|
157
157
|
## Running prune on a schedule
|
|
158
158
|
|
|
159
|
-
`prune()` has no built-in scheduler
|
|
159
|
+
`prune()` has no built-in scheduler: you decide when it runs. Because it's bounded, a single call may not delete everything. When any result has `done: false`, eligible rows remain and you call again on the next tick. This keeps each invocation short and lets a large backlog drain over several runs.
|
|
160
160
|
|
|
161
161
|
```typescript
|
|
162
162
|
// Runs on your own cron (node-cron, a workflow schedule, an external job, etc.).
|
|
@@ -173,7 +173,7 @@ async function retentionTick() {
|
|
|
173
173
|
}
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
-
You can also cancel a long-running prune with an `AbortSignal
|
|
176
|
+
You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false`, so the next run resumes cleanly.
|
|
177
177
|
|
|
178
178
|
## MongoDB TTL indexes (alternative to prune)
|
|
179
179
|
|
|
@@ -192,7 +192,7 @@ MongoDB offers native [TTL (Time-To-Live) indexes](https://www.mongodb.com/docs/
|
|
|
192
192
|
> - You need resumable, cancellable cleanup operations
|
|
193
193
|
> - You're using composite storage with multiple databases
|
|
194
194
|
>
|
|
195
|
-
> Both approaches are valid. TTL is simpler
|
|
195
|
+
> Both approaches are valid. TTL is simpler. `prune()` gives more control.
|
|
196
196
|
|
|
197
197
|
### Setting up TTL indexes on MongoDB
|
|
198
198
|
|
|
@@ -232,9 +232,9 @@ const storage = new MongoDBStore({
|
|
|
232
232
|
|
|
233
233
|
## Reclaiming disk
|
|
234
234
|
|
|
235
|
-
`prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist and are reused by future writes, so the file stops growing
|
|
235
|
+
`prune()` deletes rows but doesn't shrink the database file. On SQLite/libSQL the freed pages go on a freelist and are reused by future writes, so the file stops growing: for most users this alone solves the unbounded-growth problem.
|
|
236
236
|
|
|
237
|
-
Handing that free space back to the OS is a separate concern that Mastra doesn't manage. If you specifically need to shrink the file, run the underlying database's compaction (for example `VACUUM` on self-hosted libSQL) yourself
|
|
237
|
+
Handing that free space back to the OS is a separate concern that Mastra doesn't manage. If you specifically need to shrink the file, run the underlying database's compaction (for example `VACUUM` on self-hosted libSQL) yourself in a maintenance window. A full `VACUUM` locks the file and needs roughly twice the file size in free disk. On PostgreSQL, autovacuum reclaims dead tuples for reuse automatically; a manual `VACUUM FULL` is only needed if you must return disk to the OS.
|
|
238
238
|
|
|
239
239
|
For MongoDB, deleted documents are reused by future insertions. To reclaim disk space, run [`db.runCommand({ compact: "collection_name" })`](https://www.mongodb.com/docs/manual/reference/command/compact/) during a maintenance window.
|
|
240
240
|
|
|
@@ -85,7 +85,7 @@ const results = await store.query({
|
|
|
85
85
|
|
|
86
86
|
### `createIndex()`
|
|
87
87
|
|
|
88
|
-
Creates a new vector collection. The index name must start with a letter or underscore and can only contain letters, numbers, and
|
|
88
|
+
Creates a new vector collection. The index name must start with a letter or underscore and can only contain letters, numbers, and underscore characters. The dimension must be a positive integer.
|
|
89
89
|
|
|
90
90
|
**indexName** (`string`): Name of the index to create
|
|
91
91
|
|
|
@@ -279,7 +279,7 @@ export const libsqlAgent = new Agent({
|
|
|
279
279
|
name: 'libSQL Agent',
|
|
280
280
|
instructions:
|
|
281
281
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
282
|
-
model: 'openai/gpt-5.
|
|
282
|
+
model: 'openai/gpt-5.6-sol',
|
|
283
283
|
memory: new Memory({
|
|
284
284
|
storage: new LibSQLStore({
|
|
285
285
|
id: 'libsql-agent-storage',
|
package/dist/index.cjs
CHANGED
|
@@ -3468,6 +3468,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
3468
3468
|
await this.#addColumnIfNotExists(_mastra_core_storage.TABLE_DATASET_ITEMS, "organizationId", "TEXT");
|
|
3469
3469
|
await this.#addColumnIfNotExists(_mastra_core_storage.TABLE_DATASET_ITEMS, "projectId", "TEXT");
|
|
3470
3470
|
await this.#addColumnIfNotExists(_mastra_core_storage.TABLE_DATASET_ITEMS, "toolMocks", "TEXT");
|
|
3471
|
+
await this.#addColumnIfNotExists(_mastra_core_storage.TABLE_DATASET_ITEMS, "unmockedToolPolicy", "TEXT");
|
|
3471
3472
|
await this.#addColumnIfNotExists(_mastra_core_storage.TABLE_DATASET_ITEMS, "externalId", "TEXT");
|
|
3472
3473
|
await this.#client.batch([
|
|
3473
3474
|
{
|
|
@@ -3564,6 +3565,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
3564
3565
|
groundTruth: row.groundTruth ? (0, _mastra_core_storage.safelyParseJSON)(row.groundTruth) : void 0,
|
|
3565
3566
|
expectedTrajectory: row.expectedTrajectory ? (0, _mastra_core_storage.safelyParseJSON)(row.expectedTrajectory) : void 0,
|
|
3566
3567
|
toolMocks: row.toolMocks ? (0, _mastra_core_storage.safelyParseJSON)(row.toolMocks) : void 0,
|
|
3568
|
+
unmockedToolPolicy: row.unmockedToolPolicy ?? void 0,
|
|
3567
3569
|
requestContext: row.requestContext ? (0, _mastra_core_storage.safelyParseJSON)(row.requestContext) : void 0,
|
|
3568
3570
|
metadata: row.metadata ? (0, _mastra_core_storage.safelyParseJSON)(row.metadata) : void 0,
|
|
3569
3571
|
source: row.source ? (0, _mastra_core_storage.safelyParseJSON)(row.source) : void 0,
|
|
@@ -3585,6 +3587,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
3585
3587
|
groundTruth: row.groundTruth ? (0, _mastra_core_storage.safelyParseJSON)(row.groundTruth) : void 0,
|
|
3586
3588
|
expectedTrajectory: row.expectedTrajectory ? (0, _mastra_core_storage.safelyParseJSON)(row.expectedTrajectory) : void 0,
|
|
3587
3589
|
toolMocks: row.toolMocks ? (0, _mastra_core_storage.safelyParseJSON)(row.toolMocks) : void 0,
|
|
3590
|
+
unmockedToolPolicy: row.unmockedToolPolicy ?? void 0,
|
|
3588
3591
|
requestContext: row.requestContext ? (0, _mastra_core_storage.safelyParseJSON)(row.requestContext) : void 0,
|
|
3589
3592
|
metadata: row.metadata ? (0, _mastra_core_storage.safelyParseJSON)(row.metadata) : void 0,
|
|
3590
3593
|
source: row.source ? (0, _mastra_core_storage.safelyParseJSON)(row.source) : void 0,
|
|
@@ -3898,7 +3901,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
3898
3901
|
args: [args.datasetId]
|
|
3899
3902
|
},
|
|
3900
3903
|
{
|
|
3901
|
-
sql: `INSERT INTO ${_mastra_core_storage.TABLE_DATASET_ITEMS} (id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, input, groundTruth, expectedTrajectory, toolMocks, requestContext, metadata, source, createdAt, updatedAt) VALUES (?, ?, (SELECT version FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), ?, (SELECT organizationId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), (SELECT projectId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), NULL, 0, jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), ?, ?)`,
|
|
3904
|
+
sql: `INSERT INTO ${_mastra_core_storage.TABLE_DATASET_ITEMS} (id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, input, groundTruth, expectedTrajectory, toolMocks, unmockedToolPolicy, requestContext, metadata, source, createdAt, updatedAt) VALUES (?, ?, (SELECT version FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), ?, (SELECT organizationId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), (SELECT projectId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), NULL, 0, jsonb(?), jsonb(?), jsonb(?), jsonb(?), ?, jsonb(?), jsonb(?), jsonb(?), ?, ?)`,
|
|
3902
3905
|
args: [
|
|
3903
3906
|
id,
|
|
3904
3907
|
args.datasetId,
|
|
@@ -3910,6 +3913,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
3910
3913
|
jsonbArg(args.groundTruth),
|
|
3911
3914
|
jsonbArg(args.expectedTrajectory),
|
|
3912
3915
|
jsonbArg(args.toolMocks),
|
|
3916
|
+
args.unmockedToolPolicy ?? null,
|
|
3913
3917
|
jsonbArg(args.requestContext),
|
|
3914
3918
|
jsonbArg(args.metadata),
|
|
3915
3919
|
jsonbArg(args.source),
|
|
@@ -3939,6 +3943,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
3939
3943
|
groundTruth: args.groundTruth,
|
|
3940
3944
|
expectedTrajectory: args.expectedTrajectory,
|
|
3941
3945
|
toolMocks: args.toolMocks,
|
|
3946
|
+
unmockedToolPolicy: args.unmockedToolPolicy,
|
|
3942
3947
|
requestContext: args.requestContext,
|
|
3943
3948
|
metadata: args.metadata,
|
|
3944
3949
|
source: args.source,
|
|
@@ -3981,6 +3986,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
3981
3986
|
const mergedGroundTruth = args.groundTruth !== void 0 ? args.groundTruth : existing.groundTruth;
|
|
3982
3987
|
const mergedExpectedTrajectory = args.expectedTrajectory !== void 0 ? args.expectedTrajectory : existing.expectedTrajectory;
|
|
3983
3988
|
const mergedToolMocks = args.toolMocks !== void 0 ? args.toolMocks : existing.toolMocks;
|
|
3989
|
+
const mergedUnmockedToolPolicy = args.unmockedToolPolicy !== void 0 ? args.unmockedToolPolicy : existing.unmockedToolPolicy;
|
|
3984
3990
|
const mergedRequestContext = args.requestContext !== void 0 ? args.requestContext : existing.requestContext;
|
|
3985
3991
|
const mergedMetadata = args.metadata !== void 0 ? args.metadata : existing.metadata;
|
|
3986
3992
|
const mergedSource = args.source !== void 0 ? args.source : existing.source;
|
|
@@ -3994,7 +4000,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
3994
4000
|
args: [args.datasetId, args.id]
|
|
3995
4001
|
},
|
|
3996
4002
|
{
|
|
3997
|
-
sql: `INSERT INTO ${_mastra_core_storage.TABLE_DATASET_ITEMS} (id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, input, groundTruth, expectedTrajectory, toolMocks, requestContext, metadata, source, createdAt, updatedAt) VALUES (?, ?, (SELECT version FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), ?, (SELECT organizationId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), (SELECT projectId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), NULL, 0, jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), ?, ?)`,
|
|
4003
|
+
sql: `INSERT INTO ${_mastra_core_storage.TABLE_DATASET_ITEMS} (id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, input, groundTruth, expectedTrajectory, toolMocks, unmockedToolPolicy, requestContext, metadata, source, createdAt, updatedAt) VALUES (?, ?, (SELECT version FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), ?, (SELECT organizationId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), (SELECT projectId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), NULL, 0, jsonb(?), jsonb(?), jsonb(?), jsonb(?), ?, jsonb(?), jsonb(?), jsonb(?), ?, ?)`,
|
|
3998
4004
|
args: [
|
|
3999
4005
|
args.id,
|
|
4000
4006
|
args.datasetId,
|
|
@@ -4006,6 +4012,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4006
4012
|
jsonbArg(mergedGroundTruth),
|
|
4007
4013
|
jsonbArg(mergedExpectedTrajectory),
|
|
4008
4014
|
jsonbArg(mergedToolMocks),
|
|
4015
|
+
mergedUnmockedToolPolicy ?? null,
|
|
4009
4016
|
jsonbArg(mergedRequestContext),
|
|
4010
4017
|
jsonbArg(mergedMetadata),
|
|
4011
4018
|
jsonbArg(mergedSource),
|
|
@@ -4033,6 +4040,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4033
4040
|
groundTruth: mergedGroundTruth,
|
|
4034
4041
|
expectedTrajectory: mergedExpectedTrajectory,
|
|
4035
4042
|
toolMocks: mergedToolMocks,
|
|
4043
|
+
unmockedToolPolicy: mergedUnmockedToolPolicy,
|
|
4036
4044
|
requestContext: mergedRequestContext,
|
|
4037
4045
|
metadata: mergedMetadata,
|
|
4038
4046
|
source: mergedSource,
|
|
@@ -4073,7 +4081,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4073
4081
|
args: [datasetId, id]
|
|
4074
4082
|
},
|
|
4075
4083
|
{
|
|
4076
|
-
sql: `INSERT INTO ${_mastra_core_storage.TABLE_DATASET_ITEMS} (id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, input, groundTruth, expectedTrajectory, toolMocks, requestContext, metadata, source, createdAt, updatedAt) VALUES (?, ?, (SELECT version FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), ?, (SELECT organizationId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), (SELECT projectId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), NULL, 1, jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), ?, ?)`,
|
|
4084
|
+
sql: `INSERT INTO ${_mastra_core_storage.TABLE_DATASET_ITEMS} (id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, input, groundTruth, expectedTrajectory, toolMocks, unmockedToolPolicy, requestContext, metadata, source, createdAt, updatedAt) VALUES (?, ?, (SELECT version FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), ?, (SELECT organizationId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), (SELECT projectId FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), NULL, 1, jsonb(?), jsonb(?), jsonb(?), jsonb(?), ?, jsonb(?), jsonb(?), jsonb(?), ?, ?)`,
|
|
4077
4085
|
args: [
|
|
4078
4086
|
id,
|
|
4079
4087
|
datasetId,
|
|
@@ -4085,6 +4093,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4085
4093
|
jsonbArg(existing.groundTruth),
|
|
4086
4094
|
jsonbArg(existing.expectedTrajectory),
|
|
4087
4095
|
jsonbArg(existing.toolMocks),
|
|
4096
|
+
existing.unmockedToolPolicy ?? null,
|
|
4088
4097
|
jsonbArg(existing.requestContext),
|
|
4089
4098
|
jsonbArg(existing.metadata),
|
|
4090
4099
|
jsonbArg(existing.source),
|
|
@@ -4380,7 +4389,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4380
4389
|
});
|
|
4381
4390
|
const externalIds = [...new Set(input.items.flatMap((item) => item.externalId ? [item.externalId] : []))];
|
|
4382
4391
|
const historyResult = externalIds.length ? await tx.execute({
|
|
4383
|
-
sql: `SELECT id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, json(input) AS input, json(groundTruth) AS groundTruth, json(expectedTrajectory) AS expectedTrajectory, json(toolMocks) AS toolMocks, json(requestContext) AS requestContext, json(metadata) AS metadata, json(source) AS source, createdAt, updatedAt FROM ${_mastra_core_storage.TABLE_DATASET_ITEMS} WHERE datasetId = ? AND externalId IN (${externalIds.map(() => "?").join(",")}) ORDER BY datasetVersion`,
|
|
4392
|
+
sql: `SELECT id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, json(input) AS input, json(groundTruth) AS groundTruth, json(expectedTrajectory) AS expectedTrajectory, json(toolMocks) AS toolMocks, unmockedToolPolicy, json(requestContext) AS requestContext, json(metadata) AS metadata, json(source) AS source, createdAt, updatedAt FROM ${_mastra_core_storage.TABLE_DATASET_ITEMS} WHERE datasetId = ? AND externalId IN (${externalIds.map(() => "?").join(",")}) ORDER BY datasetVersion`,
|
|
4384
4393
|
args: [input.datasetId, ...externalIds]
|
|
4385
4394
|
}) : { rows: [] };
|
|
4386
4395
|
const plan = this.planDatasetItemBatch(input.items, historyResult.rows.map((row) => this.transformItemRowFull(row)), () => crypto.randomUUID());
|
|
@@ -4395,7 +4404,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4395
4404
|
});
|
|
4396
4405
|
for (const { id, item } of plan.inserts) {
|
|
4397
4406
|
await tx.execute({
|
|
4398
|
-
sql: `INSERT INTO ${_mastra_core_storage.TABLE_DATASET_ITEMS} (id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, input, groundTruth, expectedTrajectory, toolMocks, requestContext, metadata, source, createdAt, updatedAt) VALUES (?, ?, ?, ?, ?, ?, NULL, 0, jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), ?, ?)`,
|
|
4407
|
+
sql: `INSERT INTO ${_mastra_core_storage.TABLE_DATASET_ITEMS} (id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, input, groundTruth, expectedTrajectory, toolMocks, unmockedToolPolicy, requestContext, metadata, source, createdAt, updatedAt) VALUES (?, ?, ?, ?, ?, ?, NULL, 0, jsonb(?), jsonb(?), jsonb(?), jsonb(?), ?, jsonb(?), jsonb(?), jsonb(?), ?, ?)`,
|
|
4399
4408
|
args: [
|
|
4400
4409
|
id,
|
|
4401
4410
|
input.datasetId,
|
|
@@ -4407,6 +4416,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4407
4416
|
jsonbArg(item.groundTruth),
|
|
4408
4417
|
jsonbArg(item.expectedTrajectory),
|
|
4409
4418
|
jsonbArg(item.toolMocks),
|
|
4419
|
+
item.unmockedToolPolicy ?? null,
|
|
4410
4420
|
jsonbArg(item.requestContext),
|
|
4411
4421
|
jsonbArg(item.metadata),
|
|
4412
4422
|
jsonbArg(item.source),
|
|
@@ -4425,6 +4435,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4425
4435
|
groundTruth: item.groundTruth,
|
|
4426
4436
|
expectedTrajectory: item.expectedTrajectory,
|
|
4427
4437
|
toolMocks: item.toolMocks,
|
|
4438
|
+
unmockedToolPolicy: item.unmockedToolPolicy,
|
|
4428
4439
|
requestContext: item.requestContext,
|
|
4429
4440
|
metadata: item.metadata,
|
|
4430
4441
|
source: item.source,
|
|
@@ -4485,7 +4496,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4485
4496
|
args: [input.datasetId, item.id]
|
|
4486
4497
|
});
|
|
4487
4498
|
statements.push({
|
|
4488
|
-
sql: `INSERT INTO ${_mastra_core_storage.TABLE_DATASET_ITEMS} (id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, input, groundTruth, expectedTrajectory, toolMocks, requestContext, metadata, source, createdAt, updatedAt) VALUES (?, ?, (SELECT version FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), ?, ?, ?, NULL, 1, jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), jsonb(?), ?, ?)`,
|
|
4499
|
+
sql: `INSERT INTO ${_mastra_core_storage.TABLE_DATASET_ITEMS} (id, datasetId, datasetVersion, externalId, organizationId, projectId, validTo, isDeleted, input, groundTruth, expectedTrajectory, toolMocks, unmockedToolPolicy, requestContext, metadata, source, createdAt, updatedAt) VALUES (?, ?, (SELECT version FROM ${_mastra_core_storage.TABLE_DATASETS} WHERE id = ?), ?, ?, ?, NULL, 1, jsonb(?), jsonb(?), jsonb(?), jsonb(?), ?, jsonb(?), jsonb(?), jsonb(?), ?, ?)`,
|
|
4489
4500
|
args: [
|
|
4490
4501
|
item.id,
|
|
4491
4502
|
input.datasetId,
|
|
@@ -4497,6 +4508,7 @@ var DatasetsLibSQL = class extends _mastra_core_storage.DatasetsStorage {
|
|
|
4497
4508
|
jsonbArg(item.groundTruth),
|
|
4498
4509
|
jsonbArg(item.expectedTrajectory),
|
|
4499
4510
|
jsonbArg(item.toolMocks),
|
|
4511
|
+
item.unmockedToolPolicy ?? null,
|
|
4500
4512
|
jsonbArg(item.requestContext),
|
|
4501
4513
|
jsonbArg(item.metadata),
|
|
4502
4514
|
jsonbArg(item.source),
|
|
@@ -4577,6 +4589,7 @@ var ExperimentsLibSQL = class extends _mastra_core_storage.ExperimentsStorage {
|
|
|
4577
4589
|
ifNotExists: [
|
|
4578
4590
|
"status",
|
|
4579
4591
|
"tags",
|
|
4592
|
+
"comment",
|
|
4580
4593
|
"toolMockReport",
|
|
4581
4594
|
"organizationId",
|
|
4582
4595
|
"projectId"
|
|
@@ -4715,6 +4728,7 @@ var ExperimentsLibSQL = class extends _mastra_core_storage.ExperimentsStorage {
|
|
|
4715
4728
|
traceId: row.traceId ?? null,
|
|
4716
4729
|
status: row.status ?? null,
|
|
4717
4730
|
tags: row.tags ? (0, _mastra_core_storage.safelyParseJSON)(row.tags) : null,
|
|
4731
|
+
comment: row.comment ?? null,
|
|
4718
4732
|
toolMockReport: row.toolMockReport ? (0, _mastra_core_storage.safelyParseJSON)(row.toolMockReport) : null,
|
|
4719
4733
|
createdAt: (0, _mastra_core_storage.ensureDate)(row.createdAt)
|
|
4720
4734
|
};
|
|
@@ -5029,6 +5043,10 @@ var ExperimentsLibSQL = class extends _mastra_core_storage.ExperimentsStorage {
|
|
|
5029
5043
|
setClauses.push(`"tags" = ?`);
|
|
5030
5044
|
values.push(JSON.stringify(input.tags));
|
|
5031
5045
|
}
|
|
5046
|
+
if (input.comment !== void 0) {
|
|
5047
|
+
setClauses.push(`"comment" = ?`);
|
|
5048
|
+
values.push(input.comment);
|
|
5049
|
+
}
|
|
5032
5050
|
if (setClauses.length === 0) {
|
|
5033
5051
|
const existing = await this.getExperimentResultById({ id: input.id });
|
|
5034
5052
|
if (!existing) throw new _mastra_core_error.MastraError({
|