@mastra/libsql 1.29.0-alpha.0 → 1.29.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/dist/_types/{@internal_core → @internal_core@0.1.4}/dist/knowledge-compat/index.d.ts +12 -2
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-studio-editor.md +12 -9
- package/dist/index.cjs +46 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -16
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/knowledge/index.d.ts +2 -1
- package/dist/storage/domains/knowledge/index.d.ts.map +1 -1
- package/dist/storage/domains/knowledge/pages.d.ts +4 -0
- package/dist/storage/domains/knowledge/pages.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +1 -1
- package/package.json +3 -3
- /package/dist/_types/{@internal_core → @internal_core@0.1.4}/dist/memory/index.d.ts +0 -0
- /package/dist/_types/{@internal_core → @internal_core@0.1.4}/package.json +0 -0
package/dist/index.js
CHANGED
|
@@ -2643,7 +2643,8 @@ var AgentsLibSQL = class extends AgentsStorage {
|
|
|
2643
2643
|
"skillsFormat",
|
|
2644
2644
|
"durable",
|
|
2645
2645
|
"browser",
|
|
2646
|
-
"toolProviders"
|
|
2646
|
+
"toolProviders",
|
|
2647
|
+
"modelList"
|
|
2647
2648
|
]
|
|
2648
2649
|
});
|
|
2649
2650
|
await this.#migrateToolsToJsonbFormat();
|
|
@@ -3060,8 +3061,9 @@ var AgentsLibSQL = class extends AgentsStorage {
|
|
|
3060
3061
|
versionNumber: input.versionNumber,
|
|
3061
3062
|
name: input.name ?? null,
|
|
3062
3063
|
description: input.description ?? null,
|
|
3063
|
-
instructions: this.serializeInstructions(input.instructions),
|
|
3064
|
-
model: input.model,
|
|
3064
|
+
instructions: this.serializeInstructions(input.instructions ?? ""),
|
|
3065
|
+
model: input.model ?? {},
|
|
3066
|
+
modelList: input.modelList ?? null,
|
|
3065
3067
|
tools: input.tools ?? null,
|
|
3066
3068
|
defaultOptions: input.defaultOptions ?? null,
|
|
3067
3069
|
workflows: input.workflows ?? null,
|
|
@@ -3318,6 +3320,7 @@ var AgentsLibSQL = class extends AgentsStorage {
|
|
|
3318
3320
|
description: row.description,
|
|
3319
3321
|
instructions: this.deserializeInstructions(row.instructions),
|
|
3320
3322
|
model: this.parseJson(row.model, "model"),
|
|
3323
|
+
modelList: this.parseJson(row.modelList, "modelList"),
|
|
3321
3324
|
tools: this.parseJson(row.tools, "tools"),
|
|
3322
3325
|
defaultOptions: this.parseJson(row.defaultOptions, "defaultOptions"),
|
|
3323
3326
|
workflows: this.parseJson(row.workflows, "workflows"),
|
|
@@ -6667,13 +6670,23 @@ function createKnowledgePagesCoreLoader(features, loadStorageModule) {
|
|
|
6667
6670
|
};
|
|
6668
6671
|
}
|
|
6669
6672
|
/**
|
|
6670
|
-
* Keyword-search words: the query split on whitespace, lowercased, deduplicated.
|
|
6671
|
-
*
|
|
6673
|
+
* Keyword-search words: the query split on whitespace, lowercased, deduplicated. A hit needs at
|
|
6674
|
+
* least one of them (as a case-insensitive substring); an empty list means the search returns nothing.
|
|
6672
6675
|
*/
|
|
6673
6676
|
function knowledgeSearchWords(query) {
|
|
6674
6677
|
return [...new Set(query.toLowerCase().split(/\s+/).filter(Boolean))];
|
|
6675
6678
|
}
|
|
6676
6679
|
/**
|
|
6680
|
+
* Points one matched search word earns on a page, by the best field it appears in: name, then
|
|
6681
|
+
* description, then body. Pages rank by how many query words they match first; these points only
|
|
6682
|
+
* break ties between pages that match the same number of words.
|
|
6683
|
+
*/
|
|
6684
|
+
const KNOWLEDGE_SEARCH_WEIGHTS = {
|
|
6685
|
+
name: 3,
|
|
6686
|
+
description: 2,
|
|
6687
|
+
body: 1
|
|
6688
|
+
};
|
|
6689
|
+
/**
|
|
6677
6690
|
* Why `key` can't be a Knowledge page key, or undefined when it can. Keys are one path segment:
|
|
6678
6691
|
* non-empty, with no `/` (path separator), `#` (scope/path separator) or `%` (escape character).
|
|
6679
6692
|
*/
|
|
@@ -7543,6 +7556,15 @@ var LibSQLKnowledgePages = class {
|
|
|
7543
7556
|
const rows = await this.#query(this.#read, `SELECT n.* FROM "${T.notes}" n WHERE n.pageId = ?${input.includeDeleted ? "" : " AND n.deletedAt IS NULL"} AND ${readable.sql}${after} ORDER BY n.createdAt, n.id LIMIT ?`, args);
|
|
7544
7557
|
return this.#noteOutput(rows, limit);
|
|
7545
7558
|
}
|
|
7559
|
+
async countChildPages(input) {
|
|
7560
|
+
const ids = [...new Set(input.parentIds)];
|
|
7561
|
+
const counts = Object.fromEntries(ids.map((id) => [id, 0]));
|
|
7562
|
+
if (ids.length === 0) return counts;
|
|
7563
|
+
const readable = pageReadable("p", input.read);
|
|
7564
|
+
const rows = await this.#query(this.#read, `SELECT p.parentId AS parentId, COUNT(*) AS total FROM "${T.pages}" p WHERE p.parentId IN (SELECT value FROM json_each(?)) AND p.isScope = 0 AND p.deletedAt IS NULL AND ${readable.sql} GROUP BY p.parentId`, [jsonList(ids), ...readable.args]);
|
|
7565
|
+
for (const row of rows) counts[String(row.parentId)] = Number(row.total);
|
|
7566
|
+
return counts;
|
|
7567
|
+
}
|
|
7546
7568
|
async countNotes(input) {
|
|
7547
7569
|
const ids = [...new Set(input.pageIds)];
|
|
7548
7570
|
const counts = Object.fromEntries(ids.map((id) => [id, 0]));
|
|
@@ -7714,18 +7736,22 @@ var LibSQLKnowledgePages = class {
|
|
|
7714
7736
|
const readable = pageReadable("p", input.read);
|
|
7715
7737
|
const scopeFilter = input.scopeIds ? ` AND p.scopeId IN (SELECT value FROM json_each(?))` : "";
|
|
7716
7738
|
const scopeArgs = input.scopeIds ? [jsonList(input.scopeIds)] : [];
|
|
7717
|
-
const
|
|
7718
|
-
const
|
|
7719
|
-
const
|
|
7739
|
+
const field = (column) => `lower(COALESCE(${column}, '')) LIKE ? ESCAPE '='`;
|
|
7740
|
+
const pageMatch = words.map(() => `(${field("p.name")} OR ${field("p.description")} OR ${field("p.body")})`).join(" OR ");
|
|
7741
|
+
const pageScore = words.map(() => `(CASE WHEN ${field("p.name")} THEN ${KNOWLEDGE_SEARCH_WEIGHTS.name} WHEN ${field("p.description")} THEN ${KNOWLEDGE_SEARCH_WEIGHTS.description} WHEN ${field("p.body")} THEN ${KNOWLEDGE_SEARCH_WEIGHTS.body} ELSE 0 END)`).join(" + ");
|
|
7742
|
+
const pageCount = words.map(() => `(CASE WHEN ${field("p.name")} OR ${field("p.description")} OR ${field("p.body")} THEN 1 ELSE 0 END)`).join(" + ");
|
|
7743
|
+
const triple = likes.flatMap((like) => [
|
|
7744
|
+
like,
|
|
7745
|
+
like,
|
|
7746
|
+
like
|
|
7747
|
+
]);
|
|
7748
|
+
const hits = (await this.#query(this.#read, `SELECT p.* FROM "${T.pages}" p WHERE p.deletedAt IS NULL AND p.isScope = 0 AND ${readable.sql}${scopeFilter} AND (${pageMatch}) ORDER BY CASE WHEN instr(p.canonicalName, ?) > 0 THEN 0 ELSE 1 END, (${pageCount}) DESC, (${pageScore}) DESC, p.updatedAt DESC, p.id ASC LIMIT ?`, [
|
|
7720
7749
|
...readable.args,
|
|
7721
7750
|
...scopeArgs,
|
|
7722
|
-
...
|
|
7723
|
-
like,
|
|
7724
|
-
like,
|
|
7725
|
-
like
|
|
7726
|
-
]),
|
|
7751
|
+
...triple,
|
|
7727
7752
|
phrase,
|
|
7728
|
-
...
|
|
7753
|
+
...triple,
|
|
7754
|
+
...triple,
|
|
7729
7755
|
limit
|
|
7730
7756
|
])).map((row) => ({
|
|
7731
7757
|
type: "page",
|
|
@@ -7733,11 +7759,12 @@ var LibSQLKnowledgePages = class {
|
|
|
7733
7759
|
}));
|
|
7734
7760
|
if (hits.length >= limit) return hits;
|
|
7735
7761
|
const noteVisible = noteReadable("n", input.read);
|
|
7736
|
-
const
|
|
7737
|
-
const noteRows = await this.#query(this.#read, `SELECT n.* FROM "${T.notes}" n JOIN "${T.pages}" p ON p.id = n.pageId WHERE n.deletedAt IS NULL AND p.deletedAt IS NULL${scopeFilter} AND ${
|
|
7762
|
+
const noteHas = words.map(() => `lower(n.text) LIKE ? ESCAPE '='`);
|
|
7763
|
+
const noteRows = await this.#query(this.#read, `SELECT n.* FROM "${T.notes}" n JOIN "${T.pages}" p ON p.id = n.pageId WHERE n.deletedAt IS NULL AND p.deletedAt IS NULL${scopeFilter} AND (${noteHas.join(" OR ")}) AND ${noteVisible.sql} ORDER BY (${noteHas.map((has) => `(CASE WHEN ${has} THEN 1 ELSE 0 END)`).join(" + ")}) DESC, n.updatedAt DESC, n.id DESC LIMIT ?`, [
|
|
7738
7764
|
...scopeArgs,
|
|
7739
7765
|
...likes,
|
|
7740
7766
|
...noteVisible.args,
|
|
7767
|
+
...likes,
|
|
7741
7768
|
limit - hits.length
|
|
7742
7769
|
]);
|
|
7743
7770
|
const notes = await this.#hydrateNotes(this.#read, noteRows);
|
|
@@ -8067,6 +8094,9 @@ var KnowledgeLibSQL = class extends KnowledgeStorage {
|
|
|
8067
8094
|
listNotes(input) {
|
|
8068
8095
|
return this.#pages.listNotes(input);
|
|
8069
8096
|
}
|
|
8097
|
+
countChildPages(input) {
|
|
8098
|
+
return this.#pages.countChildPages(input);
|
|
8099
|
+
}
|
|
8070
8100
|
countNotes(input) {
|
|
8071
8101
|
return this.#pages.countNotes(input);
|
|
8072
8102
|
}
|