@mastra/libsql 1.9.0-alpha.2 → 1.9.1-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,31 @@
1
1
  # @mastra/libsql
2
2
 
3
+ ## 1.9.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Added platform channels framework with ChannelProvider interface, ChannelsStorage domain, and ChannelConnectResult discriminated union supporting OAuth, deep link, and immediate connection flows. Channels can be registered on the Mastra instance and expose connect/disconnect/list APIs for platform integrations. ([#15876](https://github.com/mastra-ai/mastra/pull/15876))
8
+
9
+ - Updated dependencies [[`b2deb29`](https://github.com/mastra-ai/mastra/commit/b2deb29412b300c868655b5840463614fbb7962d), [`66644be`](https://github.com/mastra-ai/mastra/commit/66644beac1aa560f0e417956ff007c89341dc382), [`310b953`](https://github.com/mastra-ai/mastra/commit/310b95345f302dcd5ba3ed862bdc96f059d44122), [`43f0e1d`](https://github.com/mastra-ai/mastra/commit/43f0e1d5d5a74ba6fc746f2ad89ebe0c64777a7d), [`da0b9e2`](https://github.com/mastra-ai/mastra/commit/da0b9e2ba7ecc560213b426d6c097fe63946086e)]:
10
+ - @mastra/core@1.31.0-alpha.3
11
+
12
+ ## 1.9.0
13
+
14
+ ### Minor Changes
15
+
16
+ - Use DiskANN vector_top_k() index for faster vector queries when available ([#14913](https://github.com/mastra-ai/mastra/pull/14913))
17
+
18
+ LibSQLVector.query() now automatically uses the existing DiskANN index for approximate nearest neighbor search instead of brute-force full table scans, providing 10-25x query speedups on larger datasets. Falls back to brute-force when no index exists.
19
+
20
+ ### Patch Changes
21
+
22
+ - Add `BackgroundTasksStorage` domain implementation so `@mastra/core` background task execution works with any storage adapter. ([#15307](https://github.com/mastra-ai/mastra/pull/15307))
23
+
24
+ - Added `getTraceLight` method to the observability storage, returning only lightweight span fields needed for timeline rendering. This avoids transferring heavy fields like `input`, `output`, `attributes`, and `metadata` when they are not needed. ([#15574](https://github.com/mastra-ai/mastra/pull/15574))
25
+
26
+ - Updated dependencies [[`20f59b8`](https://github.com/mastra-ai/mastra/commit/20f59b876cf91199efbc49a0e36b391240708f08), [`aba393e`](https://github.com/mastra-ai/mastra/commit/aba393e2da7390c69b80e516a4f153cda6f09376), [`3d83d06`](https://github.com/mastra-ai/mastra/commit/3d83d06f776f00fb5f4163dddd32a030c5c20844), [`e2687a7`](https://github.com/mastra-ai/mastra/commit/e2687a7408790c384563816a9a28ed06735684c9), [`fdd54cf`](https://github.com/mastra-ai/mastra/commit/fdd54cf612a9af876e9fdd85e534454f6e7dd518), [`6315317`](https://github.com/mastra-ai/mastra/commit/63153175fe9a7b224e5be7c209bbebc01dd9b0d5), [`a371ac5`](https://github.com/mastra-ai/mastra/commit/a371ac534aa1bb368a1acf9d8b313378dfdc787e), [`0474c2b`](https://github.com/mastra-ai/mastra/commit/0474c2b2e7c7e1ad8691dca031284841391ff1ef), [`0a5fa1d`](https://github.com/mastra-ai/mastra/commit/0a5fa1d3cb0583889d06687155f26fd7d2edc76c), [`7e0e63e`](https://github.com/mastra-ai/mastra/commit/7e0e63e2e485e84442351f4c7a79a424c83539dc), [`ea43e64`](https://github.com/mastra-ai/mastra/commit/ea43e646dd95d507694b6112b0bf1df22ad552b2), [`f607106`](https://github.com/mastra-ai/mastra/commit/f607106854c6416c4a07d4082604b9f66d047221), [`30456b6`](https://github.com/mastra-ai/mastra/commit/30456b6b08c8fd17e109dd093b73d93b65e83bc5), [`9d11a8c`](https://github.com/mastra-ai/mastra/commit/9d11a8c1c8924eb975a245a5884d40ca1b7e0491), [`9d3b24b`](https://github.com/mastra-ai/mastra/commit/9d3b24b19407ae9c09586cf7766d38dc4dff4a69), [`00d1b16`](https://github.com/mastra-ai/mastra/commit/00d1b16b401199cb294fa23f43336547db4dca9b), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`62919a6`](https://github.com/mastra-ai/mastra/commit/62919a6ee0fbf3779ad21a97b1ec6696515d5104), [`d246696`](https://github.com/mastra-ai/mastra/commit/d246696139a3144a5b21b042d41c532688e957e1), [`354f9ce`](https://github.com/mastra-ai/mastra/commit/354f9ce1ca6af2074b6a196a23f8ec30012dccca), [`16e34ca`](https://github.com/mastra-ai/mastra/commit/16e34caa98b9a114b17a6125e4e3fd87f169d0d0), [`7020c06`](https://github.com/mastra-ai/mastra/commit/7020c0690b199d9da337f0e805f16948e557922e), [`8786a61`](https://github.com/mastra-ai/mastra/commit/8786a61fa54ba265f85eeff9985ca39863d18bb6), [`9467ea8`](https://github.com/mastra-ai/mastra/commit/9467ea87695749a53dfc041576410ebf9ee7bb67), [`7338d94`](https://github.com/mastra-ai/mastra/commit/7338d949380cf68b095342e8e42610dc51d557c1), [`c80dc16`](https://github.com/mastra-ai/mastra/commit/c80dc16e113e6cc159f510ffde501ad4711b2189), [`af8a57e`](https://github.com/mastra-ai/mastra/commit/af8a57ed9ba9685ad8601d5b71ae3706da6222f9), [`d63ffdb`](https://github.com/mastra-ai/mastra/commit/d63ffdbb2c11e76fe5ea45faab44bc15460f010c), [`47cee3e`](https://github.com/mastra-ai/mastra/commit/47cee3e137fe39109cf7fffd2a8cf47b76dc702e), [`1bd5104`](https://github.com/mastra-ai/mastra/commit/1bd51048b6da93507276d6623e3fd96a9e1a8944), [`e9837b5`](https://github.com/mastra-ai/mastra/commit/e9837b53699e18711b09e0ca010a4106376f2653), [`8f1b280`](https://github.com/mastra-ai/mastra/commit/8f1b280b7fe6999ec654f160cb69c1a8719e7a57), [`92dcf02`](https://github.com/mastra-ai/mastra/commit/92dcf029294210ac91b090900c1a0555a425c57a), [`0fd90a2`](https://github.com/mastra-ai/mastra/commit/0fd90a215caf5fca8099c15a67ca03e4427747a3), [`8fb2405`](https://github.com/mastra-ai/mastra/commit/8fb2405138f2d208b7962ad03f121ca25bcc28c5), [`12df98c`](https://github.com/mastra-ai/mastra/commit/12df98c4904643d9481f5c78f3bed443725b4c96)]:
27
+ - @mastra/core@1.26.0
28
+
3
29
  ## 1.9.0-alpha.2
4
30
 
5
31
  ### 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.9.0-alpha.2"
6
+ version: "1.9.1-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.9.0-alpha.2",
2
+ "version": "1.9.1-alpha.0",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -34,6 +34,7 @@ Each provider page includes installation instructions, configuration parameters,
34
34
  - [PostgreSQL](https://mastra.ai/reference/storage/postgresql)
35
35
  - [MongoDB](https://mastra.ai/reference/storage/mongodb)
36
36
  - [Upstash](https://mastra.ai/reference/storage/upstash)
37
+ - [Redis](https://mastra.ai/reference/storage/redis)
37
38
  - [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1)
38
39
  - [Cloudflare KV & Durable Objects](https://mastra.ai/reference/storage/cloudflare)
39
40
  - [Convex](https://mastra.ai/reference/storage/convex)
@@ -208,7 +208,7 @@ const paragraphMemory = new Memory({
208
208
 
209
209
  ## Structured working memory
210
210
 
211
- Working memory can also be defined using a structured schema instead of a Markdown template. This allows you to specify the exact fields and types that should be tracked, using a [Zod](https://zod.dev/) schema. When using a schema, the agent will see and update working memory as a JSON object matching your schema.
211
+ Working memory can also be defined using a structured schema instead of a Markdown template. This allows you to specify the exact fields and types that should be tracked, using a [Standard JSON Schema](https://standardschema.dev/json-schema) ([Zod](https://zod.dev/), [Valibot](https://valibot.dev/), [ArkType](https://arktype.io/), etc.). When using a schema, the agent will see and update working memory as a JSON object matching your schema.
212
212
 
213
213
  **Important:** You must specify either `template` or `schema`, but not both.
214
214
 
@@ -49,6 +49,8 @@ Visit the [Configuration reference](https://mastra.ai/reference/configuration) f
49
49
 
50
50
  **observability** (`ObservabilityEntrypoint`): Observability configuration for tracing and monitoring
51
51
 
52
+ **environment** (`string`): Deployment environment name (e.g. \`production\`, \`staging\`, \`development\`). When set, automatically attached to all observability signals so they can be filtered by environment without passing \`tracingOptions.metadata.environment\` on each call. Falls back to \`process.env.NODE\_ENV\` when unset; left undefined if neither is set. Per-call \`tracingOptions.metadata.environment\` always takes precedence.
53
+
52
54
  **deployer** (`MastraDeployer`): An instance of a MastraDeployer for managing deployments.
53
55
 
54
56
  **server** (`ServerConfig`): Server configuration including port, host, timeout, API routes, middleware, CORS settings, and build options for Swagger UI, API request logging, and OpenAPI docs.
@@ -218,12 +218,12 @@ const storage = new MastraCompositeStore({
218
218
 
219
219
  Observability data can quickly overwhelm general-purpose databases in production. A single agent interaction can generate hundreds of spans, and high-traffic applications can produce thousands of traces per day.
220
220
 
221
- **ClickHouse** is recommended for production observability because it's optimized for high-volume, write-heavy analytics workloads. Use composite storage to route observability to ClickHouse while keeping other data in your primary database:
221
+ **[ClickHouse](https://mastra.ai/reference/storage/clickhouse)** is recommended for production observability because it's optimized for high-volume, write-heavy analytics workloads. Use composite storage to route observability to ClickHouse while keeping other data in your primary database:
222
222
 
223
223
  ```typescript
224
224
  import { MastraCompositeStore } from '@mastra/core/storage'
225
225
  import { MemoryPG, WorkflowsPG, ScoresPG } from '@mastra/pg'
226
- import { ObservabilityStorageClickhouse } from '@mastra/clickhouse'
226
+ import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
227
227
 
228
228
  const storage = new MastraCompositeStore({
229
229
  id: 'composite',
@@ -231,7 +231,7 @@ const storage = new MastraCompositeStore({
231
231
  memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
232
232
  workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
233
233
  scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
234
- observability: new ObservabilityStorageClickhouse({
234
+ observability: new ObservabilityStorageClickhouseVNext({
235
235
  url: process.env.CLICKHOUSE_URL,
236
236
  username: process.env.CLICKHOUSE_USERNAME,
237
237
  password: process.env.CLICKHOUSE_PASSWORD,
@@ -240,4 +240,6 @@ 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.
244
+
243
245
  > **Info:** This approach is also required when using storage providers that don't support observability (like Convex, DynamoDB, or Cloudflare). See the [DefaultExporter documentation](https://mastra.ai/docs/observability/tracing/exporters/default) for the full list of supported providers.
package/dist/index.cjs CHANGED
@@ -3280,6 +3280,149 @@ var BlobsLibSQL = class extends storage.BlobStore {
3280
3280
  };
3281
3281
  }
3282
3282
  };
3283
+ var ChannelsLibSQL = class extends storage.ChannelsStorage {
3284
+ #db;
3285
+ #client;
3286
+ static MANAGED_TABLES = [storage.TABLE_CHANNEL_INSTALLATIONS, storage.TABLE_CHANNEL_CONFIG];
3287
+ constructor(config) {
3288
+ super();
3289
+ const client = resolveClient(config);
3290
+ this.#client = client;
3291
+ this.#db = new LibSQLDB({ client, maxRetries: config.maxRetries, initialBackoffMs: config.initialBackoffMs });
3292
+ }
3293
+ async init() {
3294
+ await this.#db.createTable({
3295
+ tableName: storage.TABLE_CHANNEL_INSTALLATIONS,
3296
+ schema: storage.TABLE_SCHEMAS[storage.TABLE_CHANNEL_INSTALLATIONS]
3297
+ });
3298
+ await this.#db.createTable({
3299
+ tableName: storage.TABLE_CHANNEL_CONFIG,
3300
+ schema: storage.TABLE_SCHEMAS[storage.TABLE_CHANNEL_CONFIG]
3301
+ });
3302
+ await this.#client.execute(
3303
+ `CREATE UNIQUE INDEX IF NOT EXISTS idx_channel_installations_webhook ON "${storage.TABLE_CHANNEL_INSTALLATIONS}" ("webhookId")`
3304
+ );
3305
+ await this.#client.execute(
3306
+ `CREATE INDEX IF NOT EXISTS idx_channel_installations_platform_agent ON "${storage.TABLE_CHANNEL_INSTALLATIONS}" ("platform", "agentId")`
3307
+ );
3308
+ }
3309
+ async dangerouslyClearAll() {
3310
+ await this.#db.deleteData({ tableName: storage.TABLE_CHANNEL_INSTALLATIONS });
3311
+ await this.#db.deleteData({ tableName: storage.TABLE_CHANNEL_CONFIG });
3312
+ }
3313
+ async saveInstallation(installation) {
3314
+ const now = (/* @__PURE__ */ new Date()).toISOString();
3315
+ await this.#client.execute({
3316
+ sql: `
3317
+ INSERT INTO "${storage.TABLE_CHANNEL_INSTALLATIONS}" (id, platform, agentId, status, webhookId, data, configHash, error, createdAt, updatedAt)
3318
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
3319
+ ON CONFLICT(id) DO UPDATE SET
3320
+ platform = excluded.platform,
3321
+ agentId = excluded.agentId,
3322
+ status = excluded.status,
3323
+ webhookId = excluded.webhookId,
3324
+ data = excluded.data,
3325
+ configHash = excluded.configHash,
3326
+ error = excluded.error,
3327
+ updatedAt = excluded.updatedAt
3328
+ `,
3329
+ args: [
3330
+ installation.id,
3331
+ installation.platform,
3332
+ installation.agentId,
3333
+ installation.status,
3334
+ installation.webhookId ?? null,
3335
+ JSON.stringify(installation.data),
3336
+ installation.configHash ?? null,
3337
+ installation.error ?? null,
3338
+ installation.createdAt?.toISOString() ?? now,
3339
+ now
3340
+ ]
3341
+ });
3342
+ }
3343
+ async getInstallation(id) {
3344
+ const result = await this.#client.execute({
3345
+ sql: `SELECT * FROM "${storage.TABLE_CHANNEL_INSTALLATIONS}" WHERE id = ?`,
3346
+ args: [id]
3347
+ });
3348
+ const row = result.rows?.[0];
3349
+ return row ? this.#parseInstallationRow(row) : null;
3350
+ }
3351
+ async getInstallationByAgent(platform, agentId) {
3352
+ const result = await this.#client.execute({
3353
+ sql: `SELECT * FROM "${storage.TABLE_CHANNEL_INSTALLATIONS}" WHERE platform = ? AND agentId = ? ORDER BY CASE status WHEN 'active' THEN 0 WHEN 'pending' THEN 1 ELSE 2 END, updatedAt DESC LIMIT 1`,
3354
+ args: [platform, agentId]
3355
+ });
3356
+ const row = result.rows?.[0];
3357
+ return row ? this.#parseInstallationRow(row) : null;
3358
+ }
3359
+ async getInstallationByWebhookId(webhookId) {
3360
+ const result = await this.#client.execute({
3361
+ sql: `SELECT * FROM "${storage.TABLE_CHANNEL_INSTALLATIONS}" WHERE webhookId = ?`,
3362
+ args: [webhookId]
3363
+ });
3364
+ const row = result.rows?.[0];
3365
+ return row ? this.#parseInstallationRow(row) : null;
3366
+ }
3367
+ async listInstallations(platform) {
3368
+ const result = await this.#client.execute({
3369
+ sql: `SELECT * FROM "${storage.TABLE_CHANNEL_INSTALLATIONS}" WHERE platform = ? ORDER BY createdAt DESC`,
3370
+ args: [platform]
3371
+ });
3372
+ return result.rows.map((row) => this.#parseInstallationRow(row));
3373
+ }
3374
+ async deleteInstallation(id) {
3375
+ await this.#client.execute({
3376
+ sql: `DELETE FROM "${storage.TABLE_CHANNEL_INSTALLATIONS}" WHERE id = ?`,
3377
+ args: [id]
3378
+ });
3379
+ }
3380
+ async saveConfig(config) {
3381
+ await this.#client.execute({
3382
+ sql: `
3383
+ INSERT INTO "${storage.TABLE_CHANNEL_CONFIG}" (platform, data, updatedAt)
3384
+ VALUES (?, ?, ?)
3385
+ ON CONFLICT(platform) DO UPDATE SET
3386
+ data = excluded.data,
3387
+ updatedAt = excluded.updatedAt
3388
+ `,
3389
+ args: [config.platform, JSON.stringify(config.data), config.updatedAt.toISOString()]
3390
+ });
3391
+ }
3392
+ async getConfig(platform) {
3393
+ const result = await this.#client.execute({
3394
+ sql: `SELECT * FROM "${storage.TABLE_CHANNEL_CONFIG}" WHERE platform = ?`,
3395
+ args: [platform]
3396
+ });
3397
+ const row = result.rows?.[0];
3398
+ if (!row) return null;
3399
+ return {
3400
+ platform: row.platform,
3401
+ data: JSON.parse(row.data || "{}"),
3402
+ updatedAt: new Date(row.updatedAt)
3403
+ };
3404
+ }
3405
+ async deleteConfig(platform) {
3406
+ await this.#client.execute({
3407
+ sql: `DELETE FROM "${storage.TABLE_CHANNEL_CONFIG}" WHERE platform = ?`,
3408
+ args: [platform]
3409
+ });
3410
+ }
3411
+ #parseInstallationRow(row) {
3412
+ return {
3413
+ id: row.id,
3414
+ platform: row.platform,
3415
+ agentId: row.agentId,
3416
+ status: row.status,
3417
+ webhookId: row.webhookId || void 0,
3418
+ data: JSON.parse(row.data || "{}"),
3419
+ configHash: row.configHash || void 0,
3420
+ error: row.error || void 0,
3421
+ createdAt: new Date(row.createdAt),
3422
+ updatedAt: new Date(row.updatedAt)
3423
+ };
3424
+ }
3425
+ };
3283
3426
  function jsonbArg(value) {
3284
3427
  return value === void 0 || value === null ? null : JSON.stringify(value);
3285
3428
  }
@@ -10973,6 +11116,7 @@ var LibSQLStore = class extends storage.MastraCompositeStore {
10973
11116
  const memory = new MemoryLibSQL(domainConfig);
10974
11117
  const observability = new ObservabilityLibSQL(domainConfig);
10975
11118
  const agents = new AgentsLibSQL(domainConfig);
11119
+ const channels = new ChannelsLibSQL(domainConfig);
10976
11120
  const datasets = new DatasetsLibSQL(domainConfig);
10977
11121
  const experiments = new ExperimentsLibSQL(domainConfig);
10978
11122
  const promptBlocks = new PromptBlocksLibSQL(domainConfig);
@@ -10989,6 +11133,7 @@ var LibSQLStore = class extends storage.MastraCompositeStore {
10989
11133
  memory,
10990
11134
  observability,
10991
11135
  agents,
11136
+ channels,
10992
11137
  datasets,
10993
11138
  experiments,
10994
11139
  promptBlocks,
@@ -11105,6 +11250,7 @@ Example Complex Query:
11105
11250
  exports.AgentsLibSQL = AgentsLibSQL;
11106
11251
  exports.BackgroundTasksLibSQL = BackgroundTasksLibSQL;
11107
11252
  exports.BlobsLibSQL = BlobsLibSQL;
11253
+ exports.ChannelsLibSQL = ChannelsLibSQL;
11108
11254
  exports.DatasetsLibSQL = DatasetsLibSQL;
11109
11255
  exports.DefaultStorage = LibSQLStore;
11110
11256
  exports.ExperimentsLibSQL = ExperimentsLibSQL;