@mastra/libsql 1.22.3-alpha.2 → 1.22.3-alpha.3

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/README.md CHANGED
@@ -16,27 +16,30 @@ npm install @mastra/libsql
16
16
  import { LibSQLVector } from '@mastra/libsql';
17
17
 
18
18
  const vectorStore = new LibSQLVector({
19
- url: 'file:./my-db.db'
19
+ url: 'file:./my-db.db',
20
20
  });
21
21
 
22
22
  // Create a new table with vector support
23
23
  await vectorStore.createIndex({
24
24
  indexName: 'my_vectors',
25
- dimension: 1536,
25
+ dimension: 3,
26
26
  metric: 'cosine',
27
27
  });
28
28
 
29
29
  // Add vectors
30
30
  const ids = await vectorStore.upsert({
31
31
  indexName: 'my_vectors',
32
- vectors: [[0.1, 0.2, ...], [0.3, 0.4, ...]],
32
+ vectors: [
33
+ [0.1, 0.2, 0.3],
34
+ [0.3, 0.4, 0.5],
35
+ ],
33
36
  metadata: [{ text: 'doc1' }, { text: 'doc2' }],
34
37
  });
35
38
 
36
39
  // Query vectors
37
40
  const results = await vectorStore.query({
38
41
  indexName: 'my_vectors',
39
- queryVector: [0.1, 0.2, ...],
42
+ queryVector: [0.1, 0.2, 0.3],
40
43
  topK: 10, // topK
41
44
  filter: { text: 'doc1' }, // filter
42
45
  includeVector: false, // includeVector
@@ -44,111 +47,14 @@ const results = await vectorStore.query({
44
47
  });
45
48
  ```
46
49
 
47
- ### Storage
48
-
49
- ```typescript
50
- import { LibSQLStore } from '@mastra/libsql';
51
-
52
- const store = new LibSQLStore({
53
- id: 'libsql-storage',
54
- url: 'file:./my-db.db',
55
- });
56
-
57
- // Create a thread
58
- await store.saveThread({
59
- thread: {
60
- id: 'thread-123',
61
- resourceId: 'resource-456',
62
- title: 'My Thread',
63
- metadata: { key: 'value' },
64
- createdAt: new Date(),
65
- },
66
- });
67
-
68
- // Add messages to thread
69
- await store.saveMessages({
70
- messages: [
71
- {
72
- id: 'msg-789',
73
- threadId: 'thread-123',
74
- role: 'user',
75
- content: { content: 'Hello' },
76
- resourceId: 'resource-456',
77
- createdAt: new Date(),
78
- },
79
- ],
80
- });
81
-
82
- // Query threads and messages
83
- const savedThread = await store.getThreadById({ threadId: 'thread-123' });
84
- const messages = await store.listMessages({ threadId: 'thread-123' });
85
- ```
86
-
87
- ## Configuration
88
-
89
- The LibSQLStore store can be initialized with:
90
-
91
- - Configuration object with url and auth. Auth is only necessary when using a provider like [Turso](https://turso.tech/)
92
-
93
- ## Features
94
-
95
- ### Vector Store Features
96
-
97
- - Vector similarity search with cosine, euclidean, and dot product metrics
98
- - Advanced metadata filtering with MongoDB-like query syntax
99
- - Minimum score threshold for queries
100
- - Automatic UUID generation for vectors
101
- - Table management (create, list, describe, delete, truncate)
102
-
103
- ### Storage Features
104
-
105
- - Thread and message storage with JSON support
106
- - Atomic transactions for data consistency
107
- - Efficient batch operations
108
- - Rich metadata support
109
- - Timestamp tracking
110
- - Cascading deletes
111
-
112
- ## Supported Filter Operators
113
-
114
- The following filter operators are supported for metadata queries:
115
-
116
- - Comparison: `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`
117
- - Logical: `$and`, `$or`
118
- - Array: `$in`, `$nin`
119
- - Text: `$regex`, `$like`
120
-
121
- Example filter:
122
-
123
- ```typescript
124
- {
125
- $and: [{ age: { $gt: 25 } }, { tags: { $in: ['tag1', 'tag2'] } }];
126
- }
127
- ```
128
-
129
- ## Vector Store Methods
50
+ ## Documentation
130
51
 
131
- - `createIndex({indexName, dimension, metric?, indexConfig?, defineIndex?})`: Create a new table with vector support
132
- - `upsert({indexName, vectors, metadata?, ids?})`: Add or update vectors
133
- - `query({indexName, queryVector, topK?, filter?, includeVector?, minScore?})`: Search for similar vectors
134
- - `updateVector({ indexName, id?, filter?, update })`: Update a single vector by ID or metadata filter
135
- - `deleteVector({ indexName, id })`: Delete a single vector by ID
136
- - `deleteVectors({ indexName, ids?, filter? })`: Delete multiple vectors by IDs or metadata filter
137
- - `defineIndex({indexName, metric?, indexConfig?})`: Define an index
138
- - `listIndexes()`: List all vector-enabled tables
139
- - `describeIndex(indexName)`: Get table statistics
140
- - `deleteIndex(indexName)`: Delete a table
141
- - `truncateIndex(indexName)`: Remove all data from a table
52
+ - [@mastra/libsql documentation](https://mastra.ai/reference/vectors/libsql)
142
53
 
143
- ## Storage Methods
54
+ ## Changelog
144
55
 
145
- - `saveThread({ thread })`: Create or update a thread
146
- - `getThreadById({ threadId })`: Get a thread by ID
147
- - `deleteThread({ threadId })`: Delete a thread and its messages
148
- - `saveMessages({ messages })`: Save multiple messages in a transaction
149
- - `listMessages({ threadId, perPage?, page? })`: Get messages for a thread with pagination
150
- - `deleteMessages(messageIds)`: Delete specific messages
56
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/stores/libsql/CHANGELOG.md) for version history and release notes.
151
57
 
152
- ## Related Links
58
+ ## Support
153
59
 
154
- - [LibSQL Documentation](https://docs.turso.tech/sdk/introductionh)
60
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
@@ -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.22.3-alpha.2"
6
+ version: "1.22.3-alpha.3"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.22.3-alpha.2",
2
+ "version": "1.22.3-alpha.3",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -316,7 +316,7 @@ See the [Editor versioning reference](https://mastra.ai/reference/editor/version
316
316
 
317
317
  ## Programmatic access
318
318
 
319
- Everything available in Studio is also available programmatically through [`mastra.getEditor()`](https://mastra.ai/reference/core/getEditor), the REST API, or the Client SDK. Use it to script bulk updates or seed stored configurations from code. It can also power automation that tunes agents based on [evaluation results](https://mastra.ai/docs/datasets/running-experiments).
319
+ Everything available in Studio is also available programmatically through [`mastra.getEditor()`](https://mastra.ai/reference/core/getEditor), the REST API, or the Client SDK. Use it to script bulk updates or seed stored configurations from code. It can also power automation that tunes agents based on [evaluation results](https://mastra.ai/docs/evals/experiments).
320
320
 
321
321
  Call `mastra.getEditor()` when application code has access to the Mastra instance:
322
322
 
package/dist/index.cjs CHANGED
@@ -239,13 +239,13 @@ const FILTER_OPERATORS = {
239
239
  sql: `NOT (${key})`,
240
240
  needsValue: false
241
241
  }),
242
- $size: (key, paramIndex) => {
242
+ $size: (key, value) => {
243
243
  const jsonPath = getJsonPath(key);
244
244
  return {
245
245
  sql: `(
246
246
  CASE
247
- WHEN json_type(json_extract(metadata, ${jsonPath})) = 'array' THEN
248
- json_array_length(json_extract(metadata, ${jsonPath})) = $${paramIndex}
247
+ WHEN json_type(json_extract(metadata, ${jsonPath})) = 'array' THEN
248
+ json_array_length(json_extract(metadata, ${jsonPath})) = ?
249
249
  ELSE FALSE
250
250
  END
251
251
  )`,