@mastra/libsql 0.12.0 → 0.13.0-alpha.1
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/.turbo/turbo-build.log +2 -21
- package/CHANGELOG.md +28 -0
- package/dist/index.cjs +7 -3
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -0
- package/dist/storage/domains/legacy-evals/index.d.ts +18 -0
- package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +87 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/operations/index.d.ts +61 -0
- package/dist/storage/domains/operations/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +45 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/traces/index.d.ts +21 -0
- package/dist/storage/domains/traces/index.d.ts.map +1 -0
- package/dist/storage/domains/utils.d.ts +16 -0
- package/dist/storage/domains/utils.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +34 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +221 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/vector/filter.d.ts +29 -0
- package/dist/vector/filter.d.ts.map +1 -0
- package/dist/vector/index.d.ts +72 -0
- package/dist/vector/index.d.ts.map +1 -0
- package/dist/vector/prompt.d.ts +6 -0
- package/dist/vector/prompt.d.ts.map +1 -0
- package/dist/vector/sql-builder.d.ts +9 -0
- package/dist/vector/sql-builder.d.ts.map +1 -0
- package/package.json +9 -8
- package/src/storage/domains/scores/index.ts +5 -3
- package/src/storage/domains/traces/index.ts +5 -5
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +1 -1
- package/tsup.config.ts +17 -0
- package/dist/_tsup-dts-rollup.d.cts +0 -642
- package/dist/_tsup-dts-rollup.d.ts +0 -642
- package/dist/index.d.cts +0 -6
|
@@ -0,0 +1,6 @@
|
|
|
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 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}";
|
|
6
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/vector/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,iyIAgGxB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InValue } from '@libsql/client';
|
|
2
|
+
import type { LibSQLVectorFilter } from './filter.js';
|
|
3
|
+
interface FilterResult {
|
|
4
|
+
sql: string;
|
|
5
|
+
values: InValue[];
|
|
6
|
+
}
|
|
7
|
+
export declare function buildFilterQuery(filter: LibSQLVectorFilter): FilterResult;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=sql-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-builder.d.ts","sourceRoot":"","sources":["../../src/vector/sql-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAS9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AA2VnD,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AAeD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAkBzE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/libsql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0-alpha.1",
|
|
4
4
|
"description": "Libsql provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"default": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"require": {
|
|
15
|
-
"types": "./dist/index.d.
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
16
|
"default": "./dist/index.cjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
@@ -29,16 +29,17 @@
|
|
|
29
29
|
"tsup": "^8.5.0",
|
|
30
30
|
"typescript": "^5.8.3",
|
|
31
31
|
"vitest": "^3.2.4",
|
|
32
|
-
"@internal/lint": "0.0.
|
|
33
|
-
"@internal/storage-test-utils": "0.0.
|
|
34
|
-
"@mastra/core": "0.
|
|
32
|
+
"@internal/lint": "0.0.26",
|
|
33
|
+
"@internal/storage-test-utils": "0.0.22",
|
|
34
|
+
"@mastra/core": "0.13.0-alpha.2",
|
|
35
|
+
"@internal/types-builder": "0.0.1"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"@mastra/core": ">=0.
|
|
38
|
+
"@mastra/core": ">=0.13.0-0 <0.14.0-0"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
|
-
"build": "tsup
|
|
41
|
-
"build:watch": "
|
|
41
|
+
"build": "tsup --silent --config tsup.config.ts",
|
|
42
|
+
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
42
43
|
"test": "vitest run",
|
|
43
44
|
"lint": "eslint ."
|
|
44
45
|
}
|
|
@@ -113,7 +113,7 @@ export class ScoresLibSQL extends ScoresStorage {
|
|
|
113
113
|
const runtimeContextValue = row.runtimeContext ? JSON.parse(row.runtimeContext) : null;
|
|
114
114
|
const metadataValue = row.metadata ? JSON.parse(row.metadata) : null;
|
|
115
115
|
const entityValue = row.entity ? JSON.parse(row.entity) : null;
|
|
116
|
-
const
|
|
116
|
+
const preprocessStepResultValue = row.preprocessStepResult ? JSON.parse(row.preprocessStepResult) : null;
|
|
117
117
|
const analyzeStepResultValue = row.analyzeStepResult ? JSON.parse(row.analyzeStepResult) : null;
|
|
118
118
|
|
|
119
119
|
return {
|
|
@@ -123,10 +123,12 @@ export class ScoresLibSQL extends ScoresStorage {
|
|
|
123
123
|
scorer: scorerValue,
|
|
124
124
|
score: row.score,
|
|
125
125
|
reason: row.reason,
|
|
126
|
-
|
|
126
|
+
preprocessStepResult: preprocessStepResultValue,
|
|
127
127
|
analyzeStepResult: analyzeStepResultValue,
|
|
128
128
|
analyzePrompt: row.analyzePrompt,
|
|
129
|
-
|
|
129
|
+
preprocessPrompt: row.preprocessPrompt,
|
|
130
|
+
generateScorePrompt: row.generateScorePrompt,
|
|
131
|
+
generateReasonPrompt: row.generateReasonPrompt,
|
|
130
132
|
metadata: metadataValue,
|
|
131
133
|
input: inputValue,
|
|
132
134
|
output: outputValue,
|
|
@@ -110,13 +110,13 @@ export class TracesLibSQL extends TracesStorage {
|
|
|
110
110
|
name: row.name,
|
|
111
111
|
scope: row.scope,
|
|
112
112
|
kind: row.kind,
|
|
113
|
-
status: safelyParseJSON(row.status
|
|
114
|
-
events: safelyParseJSON(row.events
|
|
115
|
-
links: safelyParseJSON(row.links
|
|
116
|
-
attributes: safelyParseJSON(row.attributes
|
|
113
|
+
status: safelyParseJSON(row.status),
|
|
114
|
+
events: safelyParseJSON(row.events),
|
|
115
|
+
links: safelyParseJSON(row.links),
|
|
116
|
+
attributes: safelyParseJSON(row.attributes),
|
|
117
117
|
startTime: row.startTime,
|
|
118
118
|
endTime: row.endTime,
|
|
119
|
-
other: safelyParseJSON(row.other
|
|
119
|
+
other: safelyParseJSON(row.other),
|
|
120
120
|
createdAt: row.createdAt,
|
|
121
121
|
}) as Trace,
|
|
122
122
|
) ?? [];
|
package/tsconfig.json
CHANGED
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { generateTypes } from '@internal/types-builder';
|
|
2
|
+
import { defineConfig } from 'tsup';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
entry: ['src/index.ts'],
|
|
6
|
+
format: ['esm', 'cjs'],
|
|
7
|
+
clean: true,
|
|
8
|
+
dts: false,
|
|
9
|
+
splitting: true,
|
|
10
|
+
treeshake: {
|
|
11
|
+
preset: 'smallest',
|
|
12
|
+
},
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
onSuccess: async () => {
|
|
15
|
+
await generateTypes(process.cwd());
|
|
16
|
+
},
|
|
17
|
+
});
|