@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/_types/{@internal_core → @internal_core@0.1.4}/dist/knowledge-compat/index.d.ts
RENAMED
|
@@ -326,10 +326,20 @@ export interface KnowledgePagesCore {
|
|
|
326
326
|
/** Loads core's page-store runtime once, after checking core advertises `knowledge-pages`. */
|
|
327
327
|
export declare function createKnowledgePagesCoreLoader(features: ReadonlySet<string>, loadStorageModule: () => Promise<unknown>): () => Promise<KnowledgePagesCore>;
|
|
328
328
|
/**
|
|
329
|
-
* Keyword-search words: the query split on whitespace, lowercased, deduplicated.
|
|
330
|
-
*
|
|
329
|
+
* Keyword-search words: the query split on whitespace, lowercased, deduplicated. A hit needs at
|
|
330
|
+
* least one of them (as a case-insensitive substring); an empty list means the search returns nothing.
|
|
331
331
|
*/
|
|
332
332
|
export declare function knowledgeSearchWords(query: string): string[];
|
|
333
|
+
/**
|
|
334
|
+
* Points one matched search word earns on a page, by the best field it appears in: name, then
|
|
335
|
+
* description, then body. Pages rank by how many query words they match first; these points only
|
|
336
|
+
* break ties between pages that match the same number of words.
|
|
337
|
+
*/
|
|
338
|
+
export declare const KNOWLEDGE_SEARCH_WEIGHTS: {
|
|
339
|
+
readonly name: 3;
|
|
340
|
+
readonly description: 2;
|
|
341
|
+
readonly body: 1;
|
|
342
|
+
};
|
|
333
343
|
/**
|
|
334
344
|
* Why `key` can't be a Knowledge page key, or undefined when it can. Keys are one path segment:
|
|
335
345
|
* non-empty, with no `/` (path separator), `#` (scope/path separator) or `%` (escape character).
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -169,7 +169,7 @@ See the [Editor tools reference](https://mastra.ai/reference/editor/tools) for M
|
|
|
169
169
|
|
|
170
170
|
## Decide what collaborators can edit
|
|
171
171
|
|
|
172
|
-
The `editor` field decides which fields Studio owns. When omitted, collaborators can change an agent's instructions and manage its tools, including their descriptions, starting from the values in code. The agent's `id`, `name`, and
|
|
172
|
+
The `editor` field decides which fields Studio owns. When omitted, collaborators can change an agent's instructions and manage its tools, including their descriptions, starting from the values in code. The agent's `id`, `name`, and model configuration come from code unless you explicitly enable model editing.
|
|
173
173
|
|
|
174
174
|
```typescript
|
|
175
175
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -206,15 +206,18 @@ export const supportAgent = new Agent({
|
|
|
206
206
|
|
|
207
207
|
Here Studio owns the instructions, while tool membership stays in code: collaborators can only improve the descriptions of `searchOrders`.
|
|
208
208
|
|
|
209
|
-
| `editor` value | What collaborators can change | What code must provide
|
|
210
|
-
| ---------------------------------- | ------------------------------------------- |
|
|
211
|
-
| Omitted | Instructions, tools, and tool descriptions | `instructions`; tools are optional
|
|
212
|
-
| `false` | Nothing | `instructions`
|
|
213
|
-
| `{ instructions: true }` | Instructions | No `instructions`; tools are optional
|
|
214
|
-
| `{ tools: true }` | Tools and tool descriptions | `instructions`; no `tools`
|
|
215
|
-
| `{ tools: { description: true } }` | Descriptions of tools already added in code | `instructions`; the tools to describe
|
|
209
|
+
| `editor` value | What collaborators can change | What code must provide |
|
|
210
|
+
| ---------------------------------- | ------------------------------------------- | ------------------------------------------------ |
|
|
211
|
+
| Omitted | Instructions, tools, and tool descriptions | `instructions`; tools are optional |
|
|
212
|
+
| `false` | Nothing | `instructions` |
|
|
213
|
+
| `{ instructions: true }` | Instructions | No `instructions`; tools are optional |
|
|
214
|
+
| `{ tools: true }` | Tools and tool descriptions | `instructions`; no `tools` |
|
|
215
|
+
| `{ tools: { description: true } }` | Descriptions of tools already added in code | `instructions`; the tools to describe |
|
|
216
|
+
| `{ model: true }` | A static model fallback list | A static fallback array with immutable entry IDs |
|
|
216
217
|
|
|
217
|
-
Studio
|
|
218
|
+
To edit models in Studio, set `editor: { model: true }` and define `model` as a static array in code. Give every entry a stable `id` so Editor can match saved values to the corresponding code-defined model settings. Studio can reorder entries, change their provider and model, and enable or disable them.
|
|
219
|
+
|
|
220
|
+
Function-valued model configuration remains code-owned and can't be edited in Studio. See [editor overrides](https://mastra.ai/reference/agents/agent) for the complete configuration.
|
|
218
221
|
|
|
219
222
|
## Choose where changes are stored
|
|
220
223
|
|
package/dist/index.cjs
CHANGED
|
@@ -2644,7 +2644,8 @@ var AgentsLibSQL = class extends _mastra_core_storage.AgentsStorage {
|
|
|
2644
2644
|
"skillsFormat",
|
|
2645
2645
|
"durable",
|
|
2646
2646
|
"browser",
|
|
2647
|
-
"toolProviders"
|
|
2647
|
+
"toolProviders",
|
|
2648
|
+
"modelList"
|
|
2648
2649
|
]
|
|
2649
2650
|
});
|
|
2650
2651
|
await this.#migrateToolsToJsonbFormat();
|
|
@@ -3061,8 +3062,9 @@ var AgentsLibSQL = class extends _mastra_core_storage.AgentsStorage {
|
|
|
3061
3062
|
versionNumber: input.versionNumber,
|
|
3062
3063
|
name: input.name ?? null,
|
|
3063
3064
|
description: input.description ?? null,
|
|
3064
|
-
instructions: this.serializeInstructions(input.instructions),
|
|
3065
|
-
model: input.model,
|
|
3065
|
+
instructions: this.serializeInstructions(input.instructions ?? ""),
|
|
3066
|
+
model: input.model ?? {},
|
|
3067
|
+
modelList: input.modelList ?? null,
|
|
3066
3068
|
tools: input.tools ?? null,
|
|
3067
3069
|
defaultOptions: input.defaultOptions ?? null,
|
|
3068
3070
|
workflows: input.workflows ?? null,
|
|
@@ -3319,6 +3321,7 @@ var AgentsLibSQL = class extends _mastra_core_storage.AgentsStorage {
|
|
|
3319
3321
|
description: row.description,
|
|
3320
3322
|
instructions: this.deserializeInstructions(row.instructions),
|
|
3321
3323
|
model: this.parseJson(row.model, "model"),
|
|
3324
|
+
modelList: this.parseJson(row.modelList, "modelList"),
|
|
3322
3325
|
tools: this.parseJson(row.tools, "tools"),
|
|
3323
3326
|
defaultOptions: this.parseJson(row.defaultOptions, "defaultOptions"),
|
|
3324
3327
|
workflows: this.parseJson(row.workflows, "workflows"),
|
|
@@ -6668,13 +6671,23 @@ function createKnowledgePagesCoreLoader(features, loadStorageModule) {
|
|
|
6668
6671
|
};
|
|
6669
6672
|
}
|
|
6670
6673
|
/**
|
|
6671
|
-
* Keyword-search words: the query split on whitespace, lowercased, deduplicated.
|
|
6672
|
-
*
|
|
6674
|
+
* Keyword-search words: the query split on whitespace, lowercased, deduplicated. A hit needs at
|
|
6675
|
+
* least one of them (as a case-insensitive substring); an empty list means the search returns nothing.
|
|
6673
6676
|
*/
|
|
6674
6677
|
function knowledgeSearchWords(query) {
|
|
6675
6678
|
return [...new Set(query.toLowerCase().split(/\s+/).filter(Boolean))];
|
|
6676
6679
|
}
|
|
6677
6680
|
/**
|
|
6681
|
+
* Points one matched search word earns on a page, by the best field it appears in: name, then
|
|
6682
|
+
* description, then body. Pages rank by how many query words they match first; these points only
|
|
6683
|
+
* break ties between pages that match the same number of words.
|
|
6684
|
+
*/
|
|
6685
|
+
const KNOWLEDGE_SEARCH_WEIGHTS = {
|
|
6686
|
+
name: 3,
|
|
6687
|
+
description: 2,
|
|
6688
|
+
body: 1
|
|
6689
|
+
};
|
|
6690
|
+
/**
|
|
6678
6691
|
* Why `key` can't be a Knowledge page key, or undefined when it can. Keys are one path segment:
|
|
6679
6692
|
* non-empty, with no `/` (path separator), `#` (scope/path separator) or `%` (escape character).
|
|
6680
6693
|
*/
|
|
@@ -7544,6 +7557,15 @@ var LibSQLKnowledgePages = class {
|
|
|
7544
7557
|
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);
|
|
7545
7558
|
return this.#noteOutput(rows, limit);
|
|
7546
7559
|
}
|
|
7560
|
+
async countChildPages(input) {
|
|
7561
|
+
const ids = [...new Set(input.parentIds)];
|
|
7562
|
+
const counts = Object.fromEntries(ids.map((id) => [id, 0]));
|
|
7563
|
+
if (ids.length === 0) return counts;
|
|
7564
|
+
const readable = pageReadable("p", input.read);
|
|
7565
|
+
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]);
|
|
7566
|
+
for (const row of rows) counts[String(row.parentId)] = Number(row.total);
|
|
7567
|
+
return counts;
|
|
7568
|
+
}
|
|
7547
7569
|
async countNotes(input) {
|
|
7548
7570
|
const ids = [...new Set(input.pageIds)];
|
|
7549
7571
|
const counts = Object.fromEntries(ids.map((id) => [id, 0]));
|
|
@@ -7715,18 +7737,22 @@ var LibSQLKnowledgePages = class {
|
|
|
7715
7737
|
const readable = pageReadable("p", input.read);
|
|
7716
7738
|
const scopeFilter = input.scopeIds ? ` AND p.scopeId IN (SELECT value FROM json_each(?))` : "";
|
|
7717
7739
|
const scopeArgs = input.scopeIds ? [jsonList(input.scopeIds)] : [];
|
|
7718
|
-
const
|
|
7719
|
-
const
|
|
7720
|
-
const
|
|
7740
|
+
const field = (column) => `lower(COALESCE(${column}, '')) LIKE ? ESCAPE '='`;
|
|
7741
|
+
const pageMatch = words.map(() => `(${field("p.name")} OR ${field("p.description")} OR ${field("p.body")})`).join(" OR ");
|
|
7742
|
+
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(" + ");
|
|
7743
|
+
const pageCount = words.map(() => `(CASE WHEN ${field("p.name")} OR ${field("p.description")} OR ${field("p.body")} THEN 1 ELSE 0 END)`).join(" + ");
|
|
7744
|
+
const triple = likes.flatMap((like) => [
|
|
7745
|
+
like,
|
|
7746
|
+
like,
|
|
7747
|
+
like
|
|
7748
|
+
]);
|
|
7749
|
+
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 ?`, [
|
|
7721
7750
|
...readable.args,
|
|
7722
7751
|
...scopeArgs,
|
|
7723
|
-
...
|
|
7724
|
-
like,
|
|
7725
|
-
like,
|
|
7726
|
-
like
|
|
7727
|
-
]),
|
|
7752
|
+
...triple,
|
|
7728
7753
|
phrase,
|
|
7729
|
-
...
|
|
7754
|
+
...triple,
|
|
7755
|
+
...triple,
|
|
7730
7756
|
limit
|
|
7731
7757
|
])).map((row) => ({
|
|
7732
7758
|
type: "page",
|
|
@@ -7734,11 +7760,12 @@ var LibSQLKnowledgePages = class {
|
|
|
7734
7760
|
}));
|
|
7735
7761
|
if (hits.length >= limit) return hits;
|
|
7736
7762
|
const noteVisible = noteReadable("n", input.read);
|
|
7737
|
-
const
|
|
7738
|
-
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 ${
|
|
7763
|
+
const noteHas = words.map(() => `lower(n.text) LIKE ? ESCAPE '='`);
|
|
7764
|
+
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 ?`, [
|
|
7739
7765
|
...scopeArgs,
|
|
7740
7766
|
...likes,
|
|
7741
7767
|
...noteVisible.args,
|
|
7768
|
+
...likes,
|
|
7742
7769
|
limit - hits.length
|
|
7743
7770
|
]);
|
|
7744
7771
|
const notes = await this.#hydrateNotes(this.#read, noteRows);
|
|
@@ -8068,6 +8095,9 @@ var KnowledgeLibSQL = class extends _mastra_core_storage.KnowledgeStorage {
|
|
|
8068
8095
|
listNotes(input) {
|
|
8069
8096
|
return this.#pages.listNotes(input);
|
|
8070
8097
|
}
|
|
8098
|
+
countChildPages(input) {
|
|
8099
|
+
return this.#pages.countChildPages(input);
|
|
8100
|
+
}
|
|
8071
8101
|
countNotes(input) {
|
|
8072
8102
|
return this.#pages.countNotes(input);
|
|
8073
8103
|
}
|