@mastra/libsql 0.0.1-alpha.4 → 0.0.1-alpha.5

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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/libsql@0.0.1-alpha.4 build /home/runner/work/mastra/mastra/stores/libsql
2
+ > @mastra/libsql@0.0.1-alpha.5 build /home/runner/work/mastra/mastra/stores/libsql
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 6559ms
9
+ TSC ⚡️ Build success in 9438ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/libsql/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/libsql/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 8932ms
16
+ DTS ⚡️ Build success in 11373ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 37.37 KB
21
- CJS ⚡️ Build success in 804ms
22
- ESM dist/index.js 37.26 KB
23
- ESM ⚡️ Build success in 804ms
20
+ ESM dist/index.js 41.28 KB
21
+ ESM ⚡️ Build success in 1118ms
22
+ CJS dist/index.cjs 41.41 KB
23
+ CJS ⚡️ Build success in 1119ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @mastra/libsql
2
2
 
3
+ ## 0.0.1-alpha.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 5f826d9: Moved vector store specific prompts from @mastra/rag to be exported from the store that the prompt belongs to, ie @mastra/pg
8
+ - Updated dependencies [3e7b69d]
9
+ - @mastra/core@0.9.1-alpha.5
10
+
3
11
  ## 0.0.1-alpha.4
4
12
 
5
13
  ### Patch Changes
@@ -43,6 +43,14 @@ export declare interface FilterResult {
43
43
 
44
44
  export declare const handleKey: (key: string) => string;
45
45
 
46
+ /**
47
+ * Vector store specific prompt that details supported operators and examples.
48
+ * This prompt helps users construct valid filters for LibSQL Vector.
49
+ */
50
+ declare const LIBSQL_PROMPT = "When querying LibSQL Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $contains: Check if array contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nRestrictions:\n- Regex patterns are not supported\n- Direct RegExp patterns will throw an error\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Array operations work on array fields only\n- Basic operators handle array values as JSON strings\n- Empty arrays in conditions are handled gracefully\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$contains\": \"value\" }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n- $elemMatch requires an object with conditions\n Valid: { \"array\": { \"$elemMatch\": { \"field\": \"value\" } } }\n Invalid: { \"array\": { \"$elemMatch\": \"value\" } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 50 }, \"inStock\": true } } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
51
+ export { LIBSQL_PROMPT }
52
+ export { LIBSQL_PROMPT as LIBSQL_PROMPT_alias_1 }
53
+
46
54
  declare interface LibSQLConfig {
47
55
  url: string;
48
56
  authToken?: string;
@@ -43,6 +43,14 @@ export declare interface FilterResult {
43
43
 
44
44
  export declare const handleKey: (key: string) => string;
45
45
 
46
+ /**
47
+ * Vector store specific prompt that details supported operators and examples.
48
+ * This prompt helps users construct valid filters for LibSQL Vector.
49
+ */
50
+ declare const LIBSQL_PROMPT = "When querying LibSQL Vector, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n- $all: Match all values in array\n Example: { \"tags\": { \"$all\": [\"premium\", \"sale\"] } }\n- $elemMatch: Match array elements that meet all specified conditions\n Example: { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 100 } } } }\n- $contains: Check if array contains value\n Example: { \"tags\": { \"$contains\": \"premium\" } }\n\nLogical Operators:\n- $and: Logical AND (implicit when using multiple conditions)\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n- $not: Logical NOT\n Example: { \"$not\": { \"category\": \"electronics\" } }\n- $nor: Logical NOR\n Example: { \"$nor\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nElement Operators:\n- $exists: Check if field exists\n Example: { \"rating\": { \"$exists\": true } }\n\nSpecial Operators:\n- $size: Array length check\n Example: { \"tags\": { \"$size\": 2 } }\n\nRestrictions:\n- Regex patterns are not supported\n- Direct RegExp patterns will throw an error\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Array operations work on array fields only\n- Basic operators handle array values as JSON strings\n- Empty arrays in conditions are handled gracefully\n- Only logical operators ($and, $or, $not, $nor) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$contains\": \"value\" }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- $not operator:\n - Must be an object\n - Cannot be empty\n - Can be used at field level or top level\n - Valid: { \"$not\": { \"field\": \"value\" } }\n - Valid: { \"field\": { \"$not\": { \"$eq\": \"value\" } } }\n- Other logical operators ($and, $or, $nor):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n- $elemMatch requires an object with conditions\n Valid: { \"array\": { \"$elemMatch\": { \"field\": \"value\" } } }\n Invalid: { \"array\": { \"$elemMatch\": \"value\" } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"tags\": { \"$all\": [\"premium\", \"sale\"] } },\n { \"items\": { \"$elemMatch\": { \"price\": { \"$gt\": 50 }, \"inStock\": true } } },\n { \"$or\": [\n { \"stock\": { \"$gt\": 0 } },\n { \"preorder\": true }\n ]}\n ]\n}";
51
+ export { LIBSQL_PROMPT }
52
+ export { LIBSQL_PROMPT as LIBSQL_PROMPT_alias_1 }
53
+
46
54
  declare interface LibSQLConfig {
47
55
  url: string;
48
56
  authToken?: string;
package/dist/index.cjs CHANGED
@@ -1185,6 +1185,106 @@ var LibSQLStore = class extends storage.MastraStorage {
1185
1185
  }
1186
1186
  };
1187
1187
 
1188
+ // src/vector/prompt.ts
1189
+ var LIBSQL_PROMPT = `When querying LibSQL Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
1190
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
1191
+ If a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.
1192
+
1193
+ Basic Comparison Operators:
1194
+ - $eq: Exact match (default when using field: value)
1195
+ Example: { "category": "electronics" }
1196
+ - $ne: Not equal
1197
+ Example: { "category": { "$ne": "electronics" } }
1198
+ - $gt: Greater than
1199
+ Example: { "price": { "$gt": 100 } }
1200
+ - $gte: Greater than or equal
1201
+ Example: { "price": { "$gte": 100 } }
1202
+ - $lt: Less than
1203
+ Example: { "price": { "$lt": 100 } }
1204
+ - $lte: Less than or equal
1205
+ Example: { "price": { "$lte": 100 } }
1206
+
1207
+ Array Operators:
1208
+ - $in: Match any value in array
1209
+ Example: { "category": { "$in": ["electronics", "books"] } }
1210
+ - $nin: Does not match any value in array
1211
+ Example: { "category": { "$nin": ["electronics", "books"] } }
1212
+ - $all: Match all values in array
1213
+ Example: { "tags": { "$all": ["premium", "sale"] } }
1214
+ - $elemMatch: Match array elements that meet all specified conditions
1215
+ Example: { "items": { "$elemMatch": { "price": { "$gt": 100 } } } }
1216
+ - $contains: Check if array contains value
1217
+ Example: { "tags": { "$contains": "premium" } }
1218
+
1219
+ Logical Operators:
1220
+ - $and: Logical AND (implicit when using multiple conditions)
1221
+ Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
1222
+ - $or: Logical OR
1223
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
1224
+ - $not: Logical NOT
1225
+ Example: { "$not": { "category": "electronics" } }
1226
+ - $nor: Logical NOR
1227
+ Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
1228
+
1229
+ Element Operators:
1230
+ - $exists: Check if field exists
1231
+ Example: { "rating": { "$exists": true } }
1232
+
1233
+ Special Operators:
1234
+ - $size: Array length check
1235
+ Example: { "tags": { "$size": 2 } }
1236
+
1237
+ Restrictions:
1238
+ - Regex patterns are not supported
1239
+ - Direct RegExp patterns will throw an error
1240
+ - Nested fields are supported using dot notation
1241
+ - Multiple conditions on the same field are supported with both implicit and explicit $and
1242
+ - Array operations work on array fields only
1243
+ - Basic operators handle array values as JSON strings
1244
+ - Empty arrays in conditions are handled gracefully
1245
+ - Only logical operators ($and, $or, $not, $nor) can be used at the top level
1246
+ - All other operators must be used within a field condition
1247
+ Valid: { "field": { "$gt": 100 } }
1248
+ Valid: { "$and": [...] }
1249
+ Invalid: { "$gt": 100 }
1250
+ Invalid: { "$contains": "value" }
1251
+ - Logical operators must contain field conditions, not direct operators
1252
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
1253
+ Invalid: { "$and": [{ "$gt": 100 }] }
1254
+ - $not operator:
1255
+ - Must be an object
1256
+ - Cannot be empty
1257
+ - Can be used at field level or top level
1258
+ - Valid: { "$not": { "field": "value" } }
1259
+ - Valid: { "field": { "$not": { "$eq": "value" } } }
1260
+ - Other logical operators ($and, $or, $nor):
1261
+ - Can only be used at top level or nested within other logical operators
1262
+ - Can not be used on a field level, or be nested inside a field
1263
+ - Can not be used inside an operator
1264
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
1265
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
1266
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
1267
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
1268
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
1269
+ - $elemMatch requires an object with conditions
1270
+ Valid: { "array": { "$elemMatch": { "field": "value" } } }
1271
+ Invalid: { "array": { "$elemMatch": "value" } }
1272
+
1273
+ Example Complex Query:
1274
+ {
1275
+ "$and": [
1276
+ { "category": { "$in": ["electronics", "computers"] } },
1277
+ { "price": { "$gte": 100, "$lte": 1000 } },
1278
+ { "tags": { "$all": ["premium", "sale"] } },
1279
+ { "items": { "$elemMatch": { "price": { "$gt": 50 }, "inStock": true } } },
1280
+ { "$or": [
1281
+ { "stock": { "$gt": 0 } },
1282
+ { "preorder": true }
1283
+ ]}
1284
+ ]
1285
+ }`;
1286
+
1188
1287
  exports.DefaultStorage = LibSQLStore;
1288
+ exports.LIBSQL_PROMPT = LIBSQL_PROMPT;
1189
1289
  exports.LibSQLStore = LibSQLStore;
1190
1290
  exports.LibSQLVector = LibSQLVector;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ export { LIBSQL_PROMPT } from './_tsup-dts-rollup.cjs';
1
2
  export { LibSQLVector } from './_tsup-dts-rollup.cjs';
2
3
  export { LibSQLConfig } from './_tsup-dts-rollup.cjs';
3
4
  export { LibSQLStore } from './_tsup-dts-rollup.cjs';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { LIBSQL_PROMPT } from './_tsup-dts-rollup.js';
1
2
  export { LibSQLVector } from './_tsup-dts-rollup.js';
2
3
  export { LibSQLConfig } from './_tsup-dts-rollup.js';
3
4
  export { LibSQLStore } from './_tsup-dts-rollup.js';
package/dist/index.js CHANGED
@@ -1183,4 +1183,103 @@ var LibSQLStore = class extends MastraStorage {
1183
1183
  }
1184
1184
  };
1185
1185
 
1186
- export { LibSQLStore as DefaultStorage, LibSQLStore, LibSQLVector };
1186
+ // src/vector/prompt.ts
1187
+ var LIBSQL_PROMPT = `When querying LibSQL Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
1188
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
1189
+ If a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.
1190
+
1191
+ Basic Comparison Operators:
1192
+ - $eq: Exact match (default when using field: value)
1193
+ Example: { "category": "electronics" }
1194
+ - $ne: Not equal
1195
+ Example: { "category": { "$ne": "electronics" } }
1196
+ - $gt: Greater than
1197
+ Example: { "price": { "$gt": 100 } }
1198
+ - $gte: Greater than or equal
1199
+ Example: { "price": { "$gte": 100 } }
1200
+ - $lt: Less than
1201
+ Example: { "price": { "$lt": 100 } }
1202
+ - $lte: Less than or equal
1203
+ Example: { "price": { "$lte": 100 } }
1204
+
1205
+ Array Operators:
1206
+ - $in: Match any value in array
1207
+ Example: { "category": { "$in": ["electronics", "books"] } }
1208
+ - $nin: Does not match any value in array
1209
+ Example: { "category": { "$nin": ["electronics", "books"] } }
1210
+ - $all: Match all values in array
1211
+ Example: { "tags": { "$all": ["premium", "sale"] } }
1212
+ - $elemMatch: Match array elements that meet all specified conditions
1213
+ Example: { "items": { "$elemMatch": { "price": { "$gt": 100 } } } }
1214
+ - $contains: Check if array contains value
1215
+ Example: { "tags": { "$contains": "premium" } }
1216
+
1217
+ Logical Operators:
1218
+ - $and: Logical AND (implicit when using multiple conditions)
1219
+ Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
1220
+ - $or: Logical OR
1221
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
1222
+ - $not: Logical NOT
1223
+ Example: { "$not": { "category": "electronics" } }
1224
+ - $nor: Logical NOR
1225
+ Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
1226
+
1227
+ Element Operators:
1228
+ - $exists: Check if field exists
1229
+ Example: { "rating": { "$exists": true } }
1230
+
1231
+ Special Operators:
1232
+ - $size: Array length check
1233
+ Example: { "tags": { "$size": 2 } }
1234
+
1235
+ Restrictions:
1236
+ - Regex patterns are not supported
1237
+ - Direct RegExp patterns will throw an error
1238
+ - Nested fields are supported using dot notation
1239
+ - Multiple conditions on the same field are supported with both implicit and explicit $and
1240
+ - Array operations work on array fields only
1241
+ - Basic operators handle array values as JSON strings
1242
+ - Empty arrays in conditions are handled gracefully
1243
+ - Only logical operators ($and, $or, $not, $nor) can be used at the top level
1244
+ - All other operators must be used within a field condition
1245
+ Valid: { "field": { "$gt": 100 } }
1246
+ Valid: { "$and": [...] }
1247
+ Invalid: { "$gt": 100 }
1248
+ Invalid: { "$contains": "value" }
1249
+ - Logical operators must contain field conditions, not direct operators
1250
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
1251
+ Invalid: { "$and": [{ "$gt": 100 }] }
1252
+ - $not operator:
1253
+ - Must be an object
1254
+ - Cannot be empty
1255
+ - Can be used at field level or top level
1256
+ - Valid: { "$not": { "field": "value" } }
1257
+ - Valid: { "field": { "$not": { "$eq": "value" } } }
1258
+ - Other logical operators ($and, $or, $nor):
1259
+ - Can only be used at top level or nested within other logical operators
1260
+ - Can not be used on a field level, or be nested inside a field
1261
+ - Can not be used inside an operator
1262
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
1263
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
1264
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
1265
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
1266
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
1267
+ - $elemMatch requires an object with conditions
1268
+ Valid: { "array": { "$elemMatch": { "field": "value" } } }
1269
+ Invalid: { "array": { "$elemMatch": "value" } }
1270
+
1271
+ Example Complex Query:
1272
+ {
1273
+ "$and": [
1274
+ { "category": { "$in": ["electronics", "computers"] } },
1275
+ { "price": { "$gte": 100, "$lte": 1000 } },
1276
+ { "tags": { "$all": ["premium", "sale"] } },
1277
+ { "items": { "$elemMatch": { "price": { "$gt": 50 }, "inStock": true } } },
1278
+ { "$or": [
1279
+ { "stock": { "$gt": 0 } },
1280
+ { "preorder": true }
1281
+ ]}
1282
+ ]
1283
+ }`;
1284
+
1285
+ export { LibSQLStore as DefaultStorage, LIBSQL_PROMPT, LibSQLStore, LibSQLVector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/libsql",
3
- "version": "0.0.1-alpha.4",
3
+ "version": "0.0.1-alpha.5",
4
4
  "description": "Libsql provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@libsql/client": "^0.15.4",
24
- "@mastra/core": "^0.9.1-alpha.4"
24
+ "@mastra/core": "^0.9.1-alpha.5"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@microsoft/api-extractor": "^7.52.5",
@@ -30,8 +30,8 @@
30
30
  "tsup": "^8.4.0",
31
31
  "typescript": "^5.8.3",
32
32
  "vitest": "^3.1.2",
33
- "@internal/lint": "0.0.2",
34
- "@internal/storage-test-utils": "0.0.1-alpha.3"
33
+ "@internal/storage-test-utils": "0.0.1-alpha.4",
34
+ "@internal/lint": "0.0.2"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './vector';
2
2
  export * from './storage';
3
+ export { LIBSQL_PROMPT } from './vector/prompt';
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Vector store specific prompt that details supported operators and examples.
3
+ * This prompt helps users construct valid filters for LibSQL Vector.
4
+ */
5
+ export const LIBSQL_PROMPT = `When querying LibSQL Vector, you can ONLY use the operators listed below. Any other operators will be rejected.
6
+ Important: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.
7
+ If a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.
8
+
9
+ Basic Comparison Operators:
10
+ - $eq: Exact match (default when using field: value)
11
+ Example: { "category": "electronics" }
12
+ - $ne: Not equal
13
+ Example: { "category": { "$ne": "electronics" } }
14
+ - $gt: Greater than
15
+ Example: { "price": { "$gt": 100 } }
16
+ - $gte: Greater than or equal
17
+ Example: { "price": { "$gte": 100 } }
18
+ - $lt: Less than
19
+ Example: { "price": { "$lt": 100 } }
20
+ - $lte: Less than or equal
21
+ Example: { "price": { "$lte": 100 } }
22
+
23
+ Array Operators:
24
+ - $in: Match any value in array
25
+ Example: { "category": { "$in": ["electronics", "books"] } }
26
+ - $nin: Does not match any value in array
27
+ Example: { "category": { "$nin": ["electronics", "books"] } }
28
+ - $all: Match all values in array
29
+ Example: { "tags": { "$all": ["premium", "sale"] } }
30
+ - $elemMatch: Match array elements that meet all specified conditions
31
+ Example: { "items": { "$elemMatch": { "price": { "$gt": 100 } } } }
32
+ - $contains: Check if array contains value
33
+ Example: { "tags": { "$contains": "premium" } }
34
+
35
+ Logical Operators:
36
+ - $and: Logical AND (implicit when using multiple conditions)
37
+ Example: { "$and": [{ "price": { "$gt": 100 } }, { "category": "electronics" }] }
38
+ - $or: Logical OR
39
+ Example: { "$or": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
40
+ - $not: Logical NOT
41
+ Example: { "$not": { "category": "electronics" } }
42
+ - $nor: Logical NOR
43
+ Example: { "$nor": [{ "price": { "$lt": 50 } }, { "category": "books" }] }
44
+
45
+ Element Operators:
46
+ - $exists: Check if field exists
47
+ Example: { "rating": { "$exists": true } }
48
+
49
+ Special Operators:
50
+ - $size: Array length check
51
+ Example: { "tags": { "$size": 2 } }
52
+
53
+ Restrictions:
54
+ - Regex patterns are not supported
55
+ - Direct RegExp patterns will throw an error
56
+ - Nested fields are supported using dot notation
57
+ - Multiple conditions on the same field are supported with both implicit and explicit $and
58
+ - Array operations work on array fields only
59
+ - Basic operators handle array values as JSON strings
60
+ - Empty arrays in conditions are handled gracefully
61
+ - Only logical operators ($and, $or, $not, $nor) can be used at the top level
62
+ - All other operators must be used within a field condition
63
+ Valid: { "field": { "$gt": 100 } }
64
+ Valid: { "$and": [...] }
65
+ Invalid: { "$gt": 100 }
66
+ Invalid: { "$contains": "value" }
67
+ - Logical operators must contain field conditions, not direct operators
68
+ Valid: { "$and": [{ "field": { "$gt": 100 } }] }
69
+ Invalid: { "$and": [{ "$gt": 100 }] }
70
+ - $not operator:
71
+ - Must be an object
72
+ - Cannot be empty
73
+ - Can be used at field level or top level
74
+ - Valid: { "$not": { "field": "value" } }
75
+ - Valid: { "field": { "$not": { "$eq": "value" } } }
76
+ - Other logical operators ($and, $or, $nor):
77
+ - Can only be used at top level or nested within other logical operators
78
+ - Can not be used on a field level, or be nested inside a field
79
+ - Can not be used inside an operator
80
+ - Valid: { "$and": [{ "field": { "$gt": 100 } }] }
81
+ - Valid: { "$or": [{ "$and": [{ "field": { "$gt": 100 } }] }] }
82
+ - Invalid: { "field": { "$and": [{ "$gt": 100 }] } }
83
+ - Invalid: { "field": { "$or": [{ "$gt": 100 }] } }
84
+ - Invalid: { "field": { "$gt": { "$and": [{...}] } } }
85
+ - $elemMatch requires an object with conditions
86
+ Valid: { "array": { "$elemMatch": { "field": "value" } } }
87
+ Invalid: { "array": { "$elemMatch": "value" } }
88
+
89
+ Example Complex Query:
90
+ {
91
+ "$and": [
92
+ { "category": { "$in": ["electronics", "computers"] } },
93
+ { "price": { "$gte": 100, "$lte": 1000 } },
94
+ { "tags": { "$all": ["premium", "sale"] } },
95
+ { "items": { "$elemMatch": { "price": { "$gt": 50 }, "inStock": true } } },
96
+ { "$or": [
97
+ { "stock": { "$gt": 0 } },
98
+ { "preorder": true }
99
+ ]}
100
+ ]
101
+ }`;