@mastra/libsql 1.24.1 → 1.25.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.
@@ -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.24.1"
6
+ version: "1.25.1-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.24.1",
2
+ "version": "1.25.1-alpha.0",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -20,7 +20,7 @@ After getting a response from the LLM, all new messages (user, assistant, and to
20
20
 
21
21
  ## Quickstart
22
22
 
23
- Semantic recall is disabled by default. To enable it, set `semanticRecall: true` in `options` and provide a `vector` store and `embedder`:
23
+ Semantic recall is disabled by default. To enable it, set `semanticRecall: true` in `options` and provide a `vector` store and an `embedder`. A store that generates embeddings itself, such as MongoDB with Automated Embedding, works without one. See [Server-side embeddings](#server-side-embeddings).
24
24
 
25
25
  **LibSQL**:
26
26
 
@@ -242,6 +242,40 @@ const options = {
242
242
  }
243
243
  ```
244
244
 
245
+ ## Server-side embeddings
246
+
247
+ Some vector stores generate the embeddings themselves. With one of those, semantic recall runs without an `embedder`: the database embeds each message on write and the search string on arrival. The embedding provider stays out of your application entirely.
248
+
249
+ MongoDB does this through [Automated Embedding](https://mastra.ai/reference/vectors/mongodb): name a Voyage AI model on the vector store and leave the `embedder` out.
250
+
251
+ ```typescript
252
+ import { Memory } from '@mastra/memory'
253
+ import { MongoDBStore, MongoDBVector } from '@mastra/mongodb'
254
+
255
+ const memory = new Memory({
256
+ storage: new MongoDBStore({
257
+ id: 'agent-storage',
258
+ uri: process.env.MONGODB_URI,
259
+ dbName: process.env.MONGODB_DB_NAME,
260
+ }),
261
+ vector: new MongoDBVector({
262
+ id: 'agent-vector',
263
+ uri: process.env.MONGODB_URI,
264
+ dbName: process.env.MONGODB_DB_NAME,
265
+ autoEmbed: { model: 'voyage-4' },
266
+ }),
267
+ options: {
268
+ semanticRecall: { topK: 3, messageRange: 2 },
269
+ },
270
+ })
271
+ ```
272
+
273
+ Messages are stored as text and MongoDB embeds them, so the model choice and the vector size belong to the index rather than to your application. Recall works the same way through an agent and through [`recall()`](#using-the-recall-method).
274
+
275
+ MongoDB embeds newly written messages in the background. A message saved moments ago may not be recallable immediately.
276
+
277
+ Every other store expects your application to supply the vectors, and keeps requiring an `embedder`. Enabling semantic recall with neither an `embedder` nor a store that embeds server-side raises an error naming both options.
278
+
245
279
  ## Embedder configuration
246
280
 
247
281
  Semantic recall relies on an [embedding model](https://mastra.ai/reference/memory/memory-class) to convert messages into embeddings. Mastra supports embedding models through the model router using `provider/model` strings, or you can use any [embedding model](https://sdk.vercel.ai/docs/ai-sdk-core/embeddings) compatible with the AI SDK.
@@ -194,6 +194,7 @@ Each provider page includes installation instructions, configuration parameters,
194
194
 
195
195
  - [Aurora DSQL](https://mastra.ai/integrations/databases/aurora-dsql)
196
196
  - [ClickHouse](https://mastra.ai/integrations/databases/clickhouse)
197
+ - [ClickHouse Managed Postgres](https://mastra.ai/integrations/databases/clickhouse-managed-postgres)
197
198
  - [Cloudflare D1](https://mastra.ai/integrations/databases/cloudflare-d1)
198
199
  - [Cloudflare KV](https://mastra.ai/integrations/databases/cloudflare-kv)
199
200
  - [Convex](https://mastra.ai/integrations/databases/convex)
package/dist/index.cjs CHANGED
@@ -7827,6 +7827,7 @@ function addSqliteMetadataValuePredicate(conditions, params, path, value) {
7827
7827
  var MemoryLibSQL = class MemoryLibSQL extends _mastra_core_storage.MemoryStorage {
7828
7828
  supportsPartialThreadUpdate = true;
7829
7829
  supportsObservationalMemory = true;
7830
+ supportsObservationalMemoryHistorySearch = true;
7830
7831
  /**
7831
7832
  * Retention-eligible tables. `threads`, `messages`, and `resources` all anchor
7832
7833
  * on `createdAt` and are indexed for fast batched deletes. Cascade order is
@@ -8998,6 +8999,10 @@ var MemoryLibSQL = class MemoryLibSQL extends _mastra_core_storage.MemoryStorage
8998
8999
  const lookupKey = this.getOMKey(threadId, resourceId);
8999
9000
  const conditions = [`"lookupKey" = ?`];
9000
9001
  const args = [lookupKey];
9002
+ if (options?.recordId !== void 0) {
9003
+ conditions.push(`id = ?`);
9004
+ args.push(options.recordId);
9005
+ }
9001
9006
  if (options?.from) {
9002
9007
  conditions.push(`"createdAt" >= ?`);
9003
9008
  args.push(options.from.toISOString());
@@ -9006,8 +9011,25 @@ var MemoryLibSQL = class MemoryLibSQL extends _mastra_core_storage.MemoryStorage
9006
9011
  conditions.push(`"createdAt" <= ?`);
9007
9012
  args.push(options.to.toISOString());
9008
9013
  }
9014
+ if (options?.groupId !== void 0) {
9015
+ conditions.push(`(instr("activeObservations", ?) > 0 OR EXISTS (
9016
+ SELECT 1 FROM json_each("bufferedObservationChunks") AS chunk
9017
+ WHERE instr(json_extract(chunk.value, '$.observations'), ?) > 0
9018
+ ))`);
9019
+ const prefix = `<observation-group id="${options.groupId}"`;
9020
+ args.push(prefix, prefix);
9021
+ }
9022
+ if (options?.beforeGeneration !== void 0) {
9023
+ conditions.push(`"generationCount" < ?`);
9024
+ args.push(options.beforeGeneration);
9025
+ }
9026
+ if (options?.afterGeneration !== void 0) {
9027
+ conditions.push(`"generationCount" > ?`);
9028
+ args.push(options.afterGeneration);
9029
+ }
9030
+ const direction = options?.sortDirection === "ASC" ? "ASC" : "DESC";
9009
9031
  args.push(limit);
9010
- let sql = `SELECT * FROM "${OM_TABLE}" WHERE ${conditions.join(" AND ")} ORDER BY "generationCount" DESC LIMIT ?`;
9032
+ let sql = `SELECT * FROM "${OM_TABLE}" WHERE ${conditions.join(" AND ")} ORDER BY "generationCount" ${direction}, "createdAt" ASC, id ASC LIMIT ?`;
9011
9033
  if (options?.offset != null) {
9012
9034
  args.push(options.offset);
9013
9035
  sql += ` OFFSET ?`;
@@ -11433,16 +11455,17 @@ var SchedulesLibSQL = class SchedulesLibSQL extends _mastra_core_storage.Schedul
11433
11455
  if (!updated) throw new Error(`Schedule ${id} not found`);
11434
11456
  return updated;
11435
11457
  }
11436
- async updateScheduleNextFire(id, expectedNextFireAt, newNextFireAt, lastFireAt, lastRunId) {
11458
+ async updateScheduleNextFire(id, expectedNextFireAt, newNextFireAt, lastFireAt, lastRunId, newStatus) {
11437
11459
  return ((await this.#client.execute({
11438
11460
  sql: `UPDATE ${_mastra_core_storage.TABLE_SCHEDULES}
11439
- SET next_fire_at = ?, last_fire_at = ?, last_run_id = ?, updated_at = ?
11461
+ SET next_fire_at = ?, last_fire_at = ?, last_run_id = ?, updated_at = ?, status = COALESCE(?, status)
11440
11462
  WHERE id = ? AND next_fire_at = ? AND status = ?`,
11441
11463
  args: [
11442
11464
  newNextFireAt,
11443
11465
  lastFireAt,
11444
11466
  lastRunId,
11445
11467
  Date.now(),
11468
+ newStatus ?? null,
11446
11469
  id,
11447
11470
  expectedNextFireAt,
11448
11471
  "active"