@mastra/libsql 0.0.0-knowledge-studio-20261029065150 → 0.0.0-knowledge-alpha-studio-20261030162625

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.
Files changed (34) hide show
  1. package/dist/_types/@internal_core/dist/knowledge-compat/index.d.ts +306 -183
  2. package/dist/_types/@internal_core/dist/memory/index.d.ts +0 -2
  3. package/dist/docs/SKILL.md +1 -1
  4. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  5. package/dist/docs/references/docs-agents-human-in-the-loop.md +10 -1
  6. package/dist/docs/references/docs-memory-memory-processors.md +49 -3
  7. package/dist/docs/references/docs-memory-message-history.md +3 -0
  8. package/dist/docs/references/docs-memory-overview.md +6 -0
  9. package/dist/docs/references/docs-memory-semantic-recall.md +9 -3
  10. package/dist/docs/references/integrations-databases-dynamodb.md +4 -4
  11. package/dist/docs/references/reference-core-mastra-class.md +7 -3
  12. package/dist/docs/references/reference-memory-memory-class.md +87 -8
  13. package/dist/docs/references/reference-rag-retrieval.md +11 -0
  14. package/dist/index.cjs +1521 -3071
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.js +1522 -3072
  17. package/dist/index.js.map +1 -1
  18. package/dist/storage/db/index.d.ts +12 -0
  19. package/dist/storage/db/index.d.ts.map +1 -1
  20. package/dist/storage/domains/background-tasks/index.d.ts +1 -0
  21. package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
  22. package/dist/storage/domains/knowledge/index.d.ts +33 -193
  23. package/dist/storage/domains/knowledge/index.d.ts.map +1 -1
  24. package/dist/storage/domains/knowledge/pages.d.ts +148 -0
  25. package/dist/storage/domains/knowledge/pages.d.ts.map +1 -0
  26. package/dist/storage/domains/memory/index.d.ts.map +1 -1
  27. package/dist/storage/domains/observability/index.d.ts +2 -1
  28. package/dist/storage/domains/observability/index.d.ts.map +1 -1
  29. package/dist/storage/domains/workflows/index.d.ts +9 -3
  30. package/dist/storage/domains/workflows/index.d.ts.map +1 -1
  31. package/dist/vector/sql-builder.d.ts.map +1 -1
  32. package/package.json +11 -11
  33. package/dist/storage/domains/knowledge/fixtures/generate-snapshot-dbs.d.mts +0 -2
  34. package/dist/storage/domains/knowledge/fixtures/generate-snapshot-dbs.d.mts.map +0 -1
@@ -1,19 +1,5 @@
1
- //#region src/knowledge-compat/index.d.ts
2
- /**
3
- * Knowledge values that storage adapters bundle instead of importing from `@mastra/core`, so adapters keep
4
- * the same `@mastra/core` peer range as releases without Knowledge. Adapter tests assert these copies equal
5
- * the current core exports. Runtime behavior that must come from the
6
- * installed core (errors, sanitizers) is loaded lazily through {@link createKnowledgeCoreLoader} once core
7
- * advertises a matching Knowledge storage contract.
8
- */
9
- export declare const KNOWLEDGE_CORE_FEATURE = "knowledge-v2";
10
- export declare const KNOWLEDGE_STORAGE_CONTRACT_VERSION: 3;
11
- export declare const KNOWLEDGE_STORAGE_SCHEMA_VERSION: 3;
12
- /**
13
- * Marker version pre-release snapshots wrote for the same canonical layout before the version moved past
14
- * the released v2 contract; adapters rewrite it to {@link KNOWLEDGE_STORAGE_SCHEMA_VERSION} and keep the rows.
15
- */
16
- export declare const PRE_RELEASE_KNOWLEDGE_SCHEMA_VERSION: 1;
1
+ export declare const KNOWLEDGE_STORAGE_CONTRACT_VERSION: 4;
2
+ export declare const KNOWLEDGE_STORAGE_SCHEMA_VERSION: 4;
17
3
  export declare const TABLE_KNOWLEDGE_NODE_SCOPES = "mastra_knowledge_node_scopes";
18
4
  export declare const TABLE_KNOWLEDGE_RECORD_SCOPES = "mastra_knowledge_record_scopes";
19
5
  export declare const TABLE_KNOWLEDGE_SCOPE_GRANTS = "mastra_knowledge_scope_grants";
@@ -23,181 +9,318 @@ export declare const TABLE_KNOWLEDGE_NODE_ADDRESSES = "mastra_knowledge_node_add
23
9
  export declare const TABLE_KNOWLEDGE_IMPORT_STATE = "mastra_knowledge_import_state";
24
10
  export declare const TABLE_KNOWLEDGE_IMPORT_RUNS = "mastra_knowledge_import_runs";
25
11
  export declare const TABLE_KNOWLEDGE_PROPOSALS = "mastra_knowledge_proposals";
26
- export declare const TABLE_KNOWLEDGE_SCHEMA = "mastra_knowledge_schema";
27
- /** Every table managed by canonical Knowledge storage, in creation order. */
28
- export declare const KNOWLEDGE_TABLE_NAMES: readonly ["mastra_knowledge_nodes", "mastra_knowledge_records", "mastra_knowledge_mentions", "mastra_knowledge_activity", "mastra_knowledge_semantic_outbox", "mastra_knowledge_node_scopes", "mastra_knowledge_record_scopes", "mastra_knowledge_scope_grants", "mastra_knowledge_access_state", "mastra_knowledge_scope_addresses", "mastra_knowledge_node_addresses", "mastra_knowledge_import_state", "mastra_knowledge_import_runs", "mastra_knowledge_proposals", "mastra_knowledge_schema"];
29
- /** Knowledge v1 tables with no canonical equivalent; an explicit schema reset drops them. */
12
+ export declare const KNOWLEDGE_TABLE_NAMES: readonly ["mastra_knowledge_nodes", "mastra_knowledge_records", "mastra_knowledge_mentions", "mastra_knowledge_activity", "mastra_knowledge_semantic_outbox", "mastra_knowledge_node_scopes", "mastra_knowledge_record_scopes", "mastra_knowledge_scope_grants", "mastra_knowledge_access_state", "mastra_knowledge_scope_addresses", "mastra_knowledge_node_addresses", "mastra_knowledge_import_state", "mastra_knowledge_import_runs", "mastra_knowledge_proposals"];
13
+ /** Knowledge v1 tables with no v2 equivalent; an explicit schema reset drops them. */
30
14
  export declare const RETIRED_KNOWLEDGE_TABLE_NAMES: readonly ['mastra_knowledge_cursors'];
15
+ export declare const KNOWLEDGE_PAGES_CORE_FEATURE = "knowledge-pages";
16
+ export declare const KNOWLEDGE_PAGES_SCHEMA_VERSION: 4;
17
+ export declare const TABLE_KNOWLEDGE_PAGES = "mastra_knowledge_pages";
18
+ export declare const TABLE_KNOWLEDGE_NOTES = "mastra_knowledge_notes";
19
+ export declare const TABLE_KNOWLEDGE_NOTE_STAMPS = "mastra_knowledge_note_stamps";
20
+ /** Same name as the schema-2 table; schema 4 re-keys it to note → page. */
21
+ export declare const TABLE_KNOWLEDGE_PAGE_MENTIONS = "mastra_knowledge_mentions";
22
+ export declare const TABLE_KNOWLEDGE_PINS = "mastra_knowledge_pins";
23
+ /** Same name as schema 2; schema 4 re-keys it to scope/page/note. */
24
+ export declare const TABLE_KNOWLEDGE_PAGE_ACTIVITY = "mastra_knowledge_activity";
25
+ /** Holds `{ id: 'knowledge', schemaVersion: 4 }`, written when the schema-4 tables are created. */
26
+ export declare const TABLE_KNOWLEDGE_PAGES_STATE = "mastra_knowledge_access_state";
27
+ export declare const KNOWLEDGE_PAGES_TABLE_NAMES: readonly ["mastra_knowledge_pages", "mastra_knowledge_notes", "mastra_knowledge_note_stamps", "mastra_knowledge_mentions", "mastra_knowledge_pins", "mastra_knowledge_activity", "mastra_knowledge_access_state"];
28
+ /** Every Knowledge table any schema version created. Reset drops these and nothing else. */
29
+ export declare const KNOWLEDGE_RESETTABLE_TABLE_NAMES: readonly string[];
30
+ /** Schema-1/2 tables whose presence means the store needs a reset before schema 4 can run. */
31
+ export declare const LEGACY_KNOWLEDGE_TABLE_NAMES: ReadonlySet<string>;
32
+ /** Pages and scope pages. `scopeId` equals `id` on scope pages; `address`/`declaration` only on scope pages. */
33
+ export declare const KNOWLEDGE_PAGES_SCHEMA: {
34
+ readonly id: {
35
+ readonly type: 'text';
36
+ readonly nullable: false;
37
+ readonly primaryKey: true;
38
+ };
39
+ readonly scopeId: {
40
+ readonly type: 'text';
41
+ readonly nullable: false;
42
+ };
43
+ readonly parentId: {
44
+ readonly type: 'text';
45
+ readonly nullable: true;
46
+ };
47
+ readonly isScope: {
48
+ readonly type: 'boolean';
49
+ readonly nullable: false;
50
+ };
51
+ readonly address: {
52
+ readonly type: 'text';
53
+ readonly nullable: true;
54
+ };
55
+ readonly declaration: {
56
+ readonly type: 'text';
57
+ readonly nullable: true;
58
+ };
59
+ readonly key: {
60
+ readonly type: 'text';
61
+ readonly nullable: true;
62
+ };
63
+ readonly position: {
64
+ readonly type: 'text';
65
+ readonly nullable: false;
66
+ };
67
+ readonly name: {
68
+ readonly type: 'text';
69
+ readonly nullable: false;
70
+ };
71
+ readonly canonicalName: {
72
+ readonly type: 'text';
73
+ readonly nullable: false;
74
+ };
75
+ readonly description: {
76
+ readonly type: 'text';
77
+ readonly nullable: true;
78
+ };
79
+ readonly body: {
80
+ readonly type: 'text';
81
+ readonly nullable: true;
82
+ };
83
+ readonly version: {
84
+ readonly type: 'integer';
85
+ readonly nullable: false;
86
+ };
87
+ readonly mergedInto: {
88
+ readonly type: 'text';
89
+ readonly nullable: true;
90
+ };
91
+ readonly createdBy: {
92
+ readonly type: 'jsonb';
93
+ readonly nullable: false;
94
+ };
95
+ readonly updatedBy: {
96
+ readonly type: 'jsonb';
97
+ readonly nullable: false;
98
+ };
99
+ readonly createdAt: {
100
+ readonly type: 'timestamp';
101
+ readonly nullable: false;
102
+ };
103
+ readonly updatedAt: {
104
+ readonly type: 'timestamp';
105
+ readonly nullable: false;
106
+ };
107
+ readonly deletedAt: {
108
+ readonly type: 'timestamp';
109
+ readonly nullable: true;
110
+ };
111
+ readonly deletedBy: {
112
+ readonly type: 'text';
113
+ readonly nullable: true;
114
+ };
115
+ };
116
+ export declare const KNOWLEDGE_NOTES_SCHEMA: {
117
+ readonly id: {
118
+ readonly type: 'text';
119
+ readonly nullable: false;
120
+ readonly primaryKey: true;
121
+ };
122
+ readonly pageId: {
123
+ readonly type: 'text';
124
+ readonly nullable: false;
125
+ readonly references: {
126
+ readonly table: "mastra_knowledge_pages";
127
+ readonly column: 'id';
128
+ };
129
+ };
130
+ readonly text: {
131
+ readonly type: 'text';
132
+ readonly nullable: false;
133
+ };
134
+ readonly when: {
135
+ readonly type: 'timestamp';
136
+ readonly nullable: true;
137
+ };
138
+ readonly provenance: {
139
+ readonly type: 'jsonb';
140
+ readonly nullable: false;
141
+ };
142
+ readonly version: {
143
+ readonly type: 'integer';
144
+ readonly nullable: false;
145
+ };
146
+ readonly createdAt: {
147
+ readonly type: 'timestamp';
148
+ readonly nullable: false;
149
+ };
150
+ readonly updatedAt: {
151
+ readonly type: 'timestamp';
152
+ readonly nullable: false;
153
+ };
154
+ readonly deletedAt: {
155
+ readonly type: 'timestamp';
156
+ readonly nullable: true;
157
+ };
158
+ readonly deletedBy: {
159
+ readonly type: 'text';
160
+ readonly nullable: true;
161
+ };
162
+ };
163
+ /** One row per (note, stamp scope). Primary key is the pair. */
164
+ export declare const KNOWLEDGE_NOTE_STAMPS_SCHEMA: {
165
+ readonly noteId: {
166
+ readonly type: 'text';
167
+ readonly nullable: false;
168
+ readonly references: {
169
+ readonly table: "mastra_knowledge_notes";
170
+ readonly column: 'id';
171
+ };
172
+ };
173
+ readonly scopeId: {
174
+ readonly type: 'text';
175
+ readonly nullable: false;
176
+ readonly references: {
177
+ readonly table: "mastra_knowledge_pages";
178
+ readonly column: 'id';
179
+ };
180
+ };
181
+ };
182
+ /** One row per (note, mentioned page). Primary key is the pair. */
183
+ export declare const KNOWLEDGE_PAGE_MENTIONS_SCHEMA: {
184
+ readonly noteId: {
185
+ readonly type: 'text';
186
+ readonly nullable: false;
187
+ readonly references: {
188
+ readonly table: "mastra_knowledge_notes";
189
+ readonly column: 'id';
190
+ };
191
+ };
192
+ readonly pageId: {
193
+ readonly type: 'text';
194
+ readonly nullable: false;
195
+ readonly references: {
196
+ readonly table: "mastra_knowledge_pages";
197
+ readonly column: 'id';
198
+ };
199
+ };
200
+ };
201
+ /** `audience` is a JSON array of scope addresses (PG may store it as `text[]`, Mongo as an array). */
202
+ export declare const KNOWLEDGE_PINS_SCHEMA: {
203
+ readonly id: {
204
+ readonly type: 'text';
205
+ readonly nullable: false;
206
+ readonly primaryKey: true;
207
+ };
208
+ readonly pageId: {
209
+ readonly type: 'text';
210
+ readonly nullable: false;
211
+ readonly references: {
212
+ readonly table: "mastra_knowledge_pages";
213
+ readonly column: 'id';
214
+ };
215
+ };
216
+ readonly audience: {
217
+ readonly type: 'jsonb';
218
+ readonly nullable: false;
219
+ };
220
+ readonly createdBy: {
221
+ readonly type: 'text';
222
+ readonly nullable: false;
223
+ };
224
+ readonly createdAt: {
225
+ readonly type: 'timestamp';
226
+ readonly nullable: false;
227
+ };
228
+ readonly updatedAt: {
229
+ readonly type: 'timestamp';
230
+ readonly nullable: false;
231
+ };
232
+ };
233
+ export declare const KNOWLEDGE_PAGE_ACTIVITY_SCHEMA: {
234
+ readonly id: {
235
+ readonly type: 'text';
236
+ readonly nullable: false;
237
+ readonly primaryKey: true;
238
+ };
239
+ readonly action: {
240
+ readonly type: 'text';
241
+ readonly nullable: false;
242
+ };
243
+ readonly scopeId: {
244
+ readonly type: 'text';
245
+ readonly nullable: false;
246
+ };
247
+ readonly pageId: {
248
+ readonly type: 'text';
249
+ readonly nullable: false;
250
+ };
251
+ readonly noteId: {
252
+ readonly type: 'text';
253
+ readonly nullable: true;
254
+ };
255
+ readonly provenance: {
256
+ readonly type: 'jsonb';
257
+ readonly nullable: false;
258
+ };
259
+ readonly createdAt: {
260
+ readonly type: 'timestamp';
261
+ readonly nullable: false;
262
+ };
263
+ };
264
+ export declare const KNOWLEDGE_PAGES_STATE_SCHEMA: {
265
+ readonly id: {
266
+ readonly type: 'text';
267
+ readonly nullable: false;
268
+ readonly primaryKey: true;
269
+ };
270
+ readonly schemaVersion: {
271
+ readonly type: 'integer';
272
+ readonly nullable: false;
273
+ };
274
+ };
275
+ export type KnowledgePagesSchemaInspection = {
276
+ status: 'compatible';
277
+ schemaVersion: typeof KNOWLEDGE_PAGES_SCHEMA_VERSION;
278
+ } | {
279
+ status: 'uninitialized';
280
+ schemaVersion: null;
281
+ } | {
282
+ status: 'incompatible-reset-required';
283
+ schemaVersion: number | null;
284
+ reason: string;
285
+ };
31
286
  /**
32
- * Columns of the tables published v1 adapters created for every app, empty unless the app used
33
- * Knowledge. Every non-retired table must be present with only these columns before an adapter treats
34
- * the layout as safely replaceable.
35
- */
36
- export declare const PUBLISHED_KNOWLEDGE_V1_COLUMNS: ReadonlyMap<string, readonly string[]>;
37
- /**
38
- * True when `columnsByTable` (every Knowledge-prefixed table and its columns) is exactly a published
39
- * v1 layout: all non-retired v1 tables present, no other tables, and each with only published columns.
40
- * PostgreSQL adapters also created a `<column>Z` timestamptz shadow beside each timestamp column; pass
41
- * `timestampShadows` to accept those.
42
- */
43
- export declare function isPublishedKnowledgeV1Layout(columnsByTable: ReadonlyMap<string, readonly string[]>, { timestampShadows }?: {
44
- timestampShadows?: boolean;
45
- }): boolean;
46
- /** Indexes published v1 adapters created on {@link PUBLISHED_KNOWLEDGE_V1_COLUMNS} tables. */
47
- export declare const PUBLISHED_KNOWLEDGE_V1_INDEX_NAMES: ReadonlySet<string>;
48
- /**
49
- * Columns of the Knowledge tables that the first canonical-model release (`@mastra/core` 1.76.0-alpha.3,
50
- * `@mastra/libsql`/`@mastra/pg` from the same commit) created. That release wrote no schema marker and
51
- * kept nullable v1 facade columns, so canonical storage cannot open it. Its data is not migrated.
52
- */
53
- export declare const INTERIM_KNOWLEDGE_COLUMNS: ReadonlyMap<string, readonly string[]>;
54
- /** Indexes the interim release created on {@link INTERIM_KNOWLEDGE_COLUMNS} tables. */
55
- export declare const INTERIM_KNOWLEDGE_INDEX_NAMES: ReadonlySet<string>;
56
- /**
57
- * Every column layout a published interim build created. Snapshots `0.0.0-knowledge-w1-20261008204450`
58
- * onward match {@link INTERIM_KNOWLEDGE_COLUMNS}. Earlier snapshots kept extra record columns, and
59
- * `0.0.0-knowledge-w1-20261006001735` also the v1 cursors table. Later builds never dropped those, so a
60
- * database first initialized by an early snapshot keeps its layout; it only gains the later indexes.
61
- */
62
- export declare const INTERIM_KNOWLEDGE_LAYOUTS: readonly ReadonlyMap<string, readonly string[]>[];
63
- /**
64
- * True when `columnsByTable` (every Knowledge-prefixed table and its columns) is exactly one of the
65
- * {@link INTERIM_KNOWLEDGE_LAYOUTS}: every table present, no other tables, and each with exactly those
66
- * columns. Pass `timestampShadows` for PostgreSQL, whose adapters add a `<column>Z` timestamptz shadow.
67
- */
68
- export declare function isInterimKnowledgeLayout(columnsByTable: ReadonlyMap<string, readonly string[]>, { timestampShadows }?: {
69
- timestampShadows?: boolean;
70
- }): boolean;
71
- /**
72
- * Index names a replaceable non-canonical layout may carry, or `null` when `columnsByTable` is neither
73
- * the published v1 layout nor the interim layout.
287
+ * Classifies what an adapter found before creating schema-4 tables. `tableNames` is every
288
+ * `mastra_knowledge_*` table present; `schemaVersion` is the state row's version, if any.
74
289
  */
75
- export declare function replaceableKnowledgeLayoutIndexNames(columnsByTable: ReadonlyMap<string, readonly string[]>, options?: {
76
- timestampShadows?: boolean;
77
- }): ReadonlySet<string> | null;
290
+ export declare function inspectKnowledgePagesSchema(snapshot: {
291
+ tableNames: readonly string[];
292
+ schemaVersion?: number;
293
+ }): KnowledgePagesSchemaInspection;
294
+ /** Message for the error an adapter throws on `incompatible-reset-required`. */
295
+ export declare function knowledgePagesResetMessage(reason: string): string;
78
296
  /**
79
- * The warning to log when replacing a non-canonical layout discards rows, or `null` when it held none.
80
- * The access-state row is bookkeeping every init writes, so it alone never warrants a warning.
297
+ * The page-store runtime pieces adapters take from `@mastra/core/storage`. They are loaded through
298
+ * `createKnowledgePagesCoreLoader` instead of static imports so adapters keep loading on cores
299
+ * older than the `knowledge-pages` feature without raising their `@mastra/core` peer floor.
81
300
  */
82
- export declare function discardedKnowledgeRowsWarning(columnsByTable: ReadonlyMap<string, readonly string[]>, rowCounts: ReadonlyMap<string, number>, options?: {
83
- timestampShadows?: boolean;
84
- }): {
85
- message: string;
86
- details: {
87
- layout: 'published-v1' | 'interim';
88
- discardedRows: Record<string, number>;
89
- };
90
- } | null;
91
- /** Tables a replaceable non-canonical layout may contain. */
92
- export declare const REPLACEABLE_KNOWLEDGE_TABLE_NAMES: ReadonlySet<string>;
93
- /** Appended to schema errors so callers learn the one supported way forward. */
94
- export declare const KNOWLEDGE_RESET_GUIDANCE = "Existing Knowledge data is not migrated. To replace it, call `await storage.stores?.knowledge?.dangerouslyReset()`, which deletes every Knowledge row and nothing else.";
95
- /** Mirrors `StorageColumn` from `@mastra/core/storage`. */
96
- export interface KnowledgeStorageColumn {
97
- type: 'text' | 'timestamp' | 'uuid' | 'jsonb' | 'integer' | 'float' | 'bigint' | 'boolean';
98
- primaryKey?: boolean;
99
- nullable?: boolean;
100
- references?: {
101
- table: string;
102
- column: string;
103
- };
301
+ export interface KnowledgePagesCore {
302
+ assertKnowledgePageDescriptionWithinBound(description: string | undefined): void;
303
+ assertKnowledgeNoteTextWithinBound(text: string): void;
304
+ canonicalKnowledgeName(name: string): string;
305
+ knowledgePositionBetween(before?: string, after?: string): string;
306
+ MAX_KNOWLEDGE_MOVE_PAGES: number;
307
+ MAX_KNOWLEDGE_PAGE_DEPTH: number;
308
+ MAX_KNOWLEDGE_PAGE_LIST_LIMIT: number;
309
+ KnowledgeMoveTooLargeError: new (pageId: string, pages: number) => Error;
310
+ KnowledgePageDepthError: new (pageId: string) => Error;
311
+ KnowledgePageHasChildrenError: new (pageId: string) => Error;
312
+ KnowledgePageKeyConflictError: new (key: string, parentId: string) => Error;
104
313
  }
105
- export declare const KNOWLEDGE_NODE_SCOPES_SCHEMA: Record<string, KnowledgeStorageColumn>;
106
- export declare const KNOWLEDGE_RECORD_SCOPES_SCHEMA: Record<string, KnowledgeStorageColumn>;
107
- export declare const KNOWLEDGE_SCOPE_GRANTS_SCHEMA: Record<string, KnowledgeStorageColumn>;
108
- export declare const KNOWLEDGE_ACCESS_STATE_SCHEMA: Record<string, KnowledgeStorageColumn>;
109
- export declare const KNOWLEDGE_SCHEMA_SCHEMA: Record<string, KnowledgeStorageColumn>;
110
- export declare const KNOWLEDGE_SCOPE_ADDRESSES_SCHEMA: Record<string, KnowledgeStorageColumn>;
111
- export declare const KNOWLEDGE_NODE_ADDRESSES_SCHEMA: Record<string, KnowledgeStorageColumn>;
112
- export declare const KNOWLEDGE_IMPORT_STATE_SCHEMA: Record<string, KnowledgeStorageColumn>;
113
- export declare const KNOWLEDGE_IMPORT_RUNS_SCHEMA: Record<string, KnowledgeStorageColumn>;
114
- export declare const KNOWLEDGE_PROPOSALS_SCHEMA: Record<string, KnowledgeStorageColumn>;
115
- /** Canonicalizes a node UUID. */
116
- export declare function canonicalizeKnowledgeNodeId(id: string): string;
117
- /** Canonicalizes a set of scope-node UUIDs. */
118
- export declare function canonicalizeKnowledgeScopeIds(scopeIds: string[]): string[];
119
- export declare function knowledgeScopeIdsKey(scopeIds: string[]): string;
120
- /** Canonicalizes a stored `[source, scope]` importer binding key. */
121
- export declare function canonicalizeKnowledgeImporterBindingKey(binding: string): string;
122
- /** Scope nodes are visible through their own identity as well as their direct parent memberships. */
123
- export declare function isKnowledgeNodeVisible(node: {
124
- id: string;
125
- isScope: boolean;
126
- }, nodeScopeIds: string[], visibleScopeIds: string[]): boolean;
127
- /** Knowledge runtime values adapters take from the installed `@mastra/core`. */
128
- export interface KnowledgeCore {
129
- KnowledgeSchemaError: new (message: string) => Error;
130
- KnowledgeUnsupportedError: new (adapter?: string) => Error;
131
- sanitizeKnowledgeImportError(error: unknown): string;
132
- }
133
- export declare function assertKnowledgeCoreSupport(features: ReadonlySet<string>): void;
134
- /**
135
- * Returns a coalesced loader for core's Knowledge runtime. It rejects cores without the Knowledge feature
136
- * before importing anything, and retries after a failed import.
137
- */
138
- export declare function createKnowledgeCoreLoader(features: ReadonlySet<string>, loadStorageModule: () => Promise<unknown>): () => Promise<KnowledgeCore>;
314
+ /** Loads core's page-store runtime once, after checking core advertises `knowledge-pages`. */
315
+ export declare function createKnowledgePagesCoreLoader(features: ReadonlySet<string>, loadStorageModule: () => Promise<unknown>): () => Promise<KnowledgePagesCore>;
139
316
  /**
140
- * Importer claims (mirrors `@mastra/core/storage` so adapters run against any core with Knowledge).
141
- * A claim is one importer binding's contribution to a node's memberships or a record, stored in that
142
- * binding's import state and written in the same transaction as the change it describes.
317
+ * Keyword-search words: the query split on whitespace, lowercased, deduplicated. Every word must
318
+ * appear (as a case-insensitive substring) in a hit; an empty list means the search returns nothing.
143
319
  */
144
- export interface KnowledgeImportClaimCompat {
145
- importerId: string;
146
- binding: string;
147
- source: string;
148
- targetType: 'node' | 'record';
149
- targetId: string;
150
- scopeIds: string[];
151
- version: number;
152
- }
153
- export declare function knowledgeImportClaimKey(targetType: 'node' | 'record', targetId: string): string;
154
- export declare function parseKnowledgeImportClaim(state: {
155
- importerId: string;
156
- binding: string;
157
- key: string;
158
- value: string;
159
- }): KnowledgeImportClaimCompat | null;
160
- export declare function serializeKnowledgeImportClaim(claim: {
161
- source: string;
162
- scopeIds: string[];
163
- version: number;
164
- }): string;
165
- /** Memberships after one claimant replaces its claim, keeping what other claims (or no claim) hold. */
166
- export declare function reconcileKnowledgeClaimScopes(input: {
167
- current: string[];
168
- previous: string[];
169
- next: string[];
170
- others: string[];
171
- }): string[];
320
+ export declare function knowledgeSearchWords(query: string): string[];
172
321
  /**
173
- * Version for the scope-less claim a release leaves on a node when no claim from the same importer and source
174
- * remains, or `null` when one does. While the importer still owned the node, the marker follows the node so a moved
175
- * or re-added binding can adopt it; after an outside edit it keeps the importer's last version, so the edit is still
176
- * detected and never becomes importer-owned by being released.
322
+ * Why `key` can't be a Knowledge page key, or undefined when it can. Keys are one path segment:
323
+ * non-empty, with no `/` (path separator), `#` (scope/path separator) or `%` (escape character).
177
324
  */
178
- export declare function knowledgeReleaseMarkerVersion(released: {
179
- importerId: string;
180
- source: string;
181
- version: number;
182
- }, remaining: readonly {
183
- importerId: string;
184
- source: string;
185
- }[], versionBefore: number, versionAfter: number): number | null;
186
- export declare function isSameKnowledgeClaimant(left: {
187
- importerId: string;
188
- binding: string;
189
- }, right: {
190
- importerId: string;
191
- binding: string;
192
- }): boolean;
193
- /** Most sources one `listSourcesWithVisibleRecords` call may ask about. Mirrors the current core export. */
194
- export declare const KNOWLEDGE_SOURCE_PROBE_LIMIT = 1000;
195
- export declare function assertKnowledgeSourceProbeLimit(sources: unknown[]): void;
196
- /** Most node plus record ids one `listVisibleKnowledgeIds` call may ask about. Mirrors the current core export. */
197
- export declare const KNOWLEDGE_VISIBILITY_PROBE_LIMIT = 1000;
198
- export declare function assertKnowledgeVisibilityProbeLimit(input: {
199
- nodeIds: string[];
200
- recordIds: string[];
201
- }): void;
202
- //#endregion
325
+ export declare function knowledgePageKeyProblem(key: string): string | undefined;
203
326
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,3 @@
1
- //#region src/memory/index.d.ts
2
1
  /**
3
2
  * Shared rules for observational memory lifecycle writes. Every storage adapter applies
4
3
  * these inside its own atomic section (lock, transaction, or conditional update), so the
@@ -97,5 +96,4 @@ export declare function assertActiveObservationsApplied(result: UpdateActiveObse
97
96
  * (equal, or only appended to since).
98
97
  */
99
98
  export declare function isAppendOnlySince(storedObservations: string, snapshotObservations: string): boolean;
100
- //#endregion
101
99
  //# sourceMappingURL=index.d.ts.map
@@ -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: "0.0.0-knowledge-studio-20261029065150"
6
+ version: "0.0.0-knowledge-alpha-studio-20261030162625"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.0-knowledge-studio-20261029065150",
2
+ "version": "0.0.0-knowledge-alpha-studio-20261030162625",
3
3
  "package": "@mastra/libsql",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -116,7 +116,7 @@ const stream = await agent.stream('Clean up old records', {
116
116
  })
117
117
  ```
118
118
 
119
- The function can be asynchronous. For decisions that depend on the tool name and arguments, use a [classifier](https://mastra.ai/reference/classifier/classifier) to estimate whether the call needs human review:
119
+ The function can be asynchronous. For decisions that depend on the tool name and arguments, use a [classifier](https://mastra.ai/docs/classifier) to estimate whether the call needs human review:
120
120
 
121
121
  ```typescript
122
122
  import { Classifier } from '@mastra/core/classifier'
@@ -311,6 +311,9 @@ Instead of pausing every tool call at the agent level, you can mark individual t
311
311
  Set `requireApproval: true` on a tool definition. The tool pauses before execution regardless of whether `requireToolApproval` is set on the agent:
312
312
 
313
313
  ```typescript
314
+ import { createTool } from '@mastra/core/tools'
315
+ import { z } from 'zod'
316
+
314
317
  export const testTool = createTool({
315
318
  id: 'test-tool',
316
319
  description: 'Fetches weather for a location',
@@ -359,6 +362,9 @@ const handleApproval = async () => {
359
362
  With this approach, neither the agent nor the tool uses `requireApproval`. Instead, the tool's `execute` function calls `suspend()` to pause at a specific point and return context or confirmation prompts to the user. This is useful when approval depends on runtime conditions rather than being unconditional.
360
363
 
361
364
  ```typescript
365
+ import { createTool } from '@mastra/core/tools'
366
+ import { z } from 'zod'
367
+
362
368
  export const testToolB = createTool({
363
369
  id: 'test-tool-b',
364
370
  description: 'Fetches weather for a location',
@@ -662,6 +668,9 @@ for await (const chunk of stream.fullStream) {
662
668
  Tools can also use [`suspend()`](#approval-using-suspend) to pause execution and return context to the user. This approach works through the supervisor delegation chain the same way `requireApproval` does: the suspension surfaces at the supervisor level:
663
669
 
664
670
  ```typescript
671
+ import { createTool } from '@mastra/core/tools'
672
+ import { z } from 'zod'
673
+
665
674
  const conditionalTool = createTool({
666
675
  id: 'conditional-operation',
667
676
  description: 'Performs an operation that may require confirmation',
@@ -12,13 +12,13 @@ Memory processors are [processors](https://mastra.ai/docs/agents/processors) tha
12
12
 
13
13
  ## Built-in memory processors
14
14
 
15
- Mastra automatically adds these processors when memory is enabled:
15
+ Mastra automatically adds these processors when memory is enabled. `MemoryInputFilter` is added only when a memory store is available and stored history will be loaded:
16
16
 
17
17
  ### `MemoryInputFilter`
18
18
 
19
- Trims client-echoed history before memory loaders run. For an existing thread, it keeps only the current user turn or new tool results. For an empty thread, it keeps the full initial input and removes provider item metadata from assistant parts that could refer to items that don't exist in storage.
19
+ Trims client-echoed history before memory loaders run. For an existing thread, it keeps only the current user turn or new tool results. For an empty thread, it keeps the full initial input and removes provider item metadata from assistant parts that could refer to items that don't exist in storage. When `retainFullInput: true` is set, it skips both the trim and the metadata strip and processes the input exactly as supplied, while stored history still loads.
20
20
 
21
- This processor runs first so `MessageHistory`, `SemanticRecall`, and Observational Memory receive only the new input they need.
21
+ By default, this processor runs first so `MessageHistory`, `SemanticRecall`, and Observational Memory receive only the new input they need.
22
22
 
23
23
  ### `MessageHistory`
24
24
 
@@ -320,6 +320,52 @@ const agent = new Agent({
320
320
 
321
321
  Both scenarios are safe - guardrails prevent inappropriate content from being persisted to memory
322
322
 
323
+ ## Aborted runs and saved messages
324
+
325
+ Cancelling a run and blocking it with a processor `abort()` both stop generation, but they save different things:
326
+
327
+ | What stops the run | Memory processors | What's persisted |
328
+ | ----------------------------- | ----------------- | ------------------------------------------------------------ |
329
+ | `abortSignal` from the caller | Still run | The user message and the assistant text the user already saw |
330
+ | `abort()` inside a processor | Skipped | Nothing; the tripwire blocks the save |
331
+
332
+ A caller cancellation goes through output processors like any other run, so the built-in `MessageHistory` processor saves the thread. The partial answer is stored as an ordinary assistant message with no error part, which means the next turn starts from what the user actually read.
333
+
334
+ ```typescript
335
+ import { Agent } from '@mastra/core/agent'
336
+ import { Memory } from '@mastra/memory'
337
+
338
+ const memory = new Memory({ options: { lastMessages: 20 } })
339
+ const agent = new Agent({
340
+ id: 'writer',
341
+ name: 'writer',
342
+ instructions: 'You write step-by-step migration guides.',
343
+ model: 'openai/gpt-6.1-sol',
344
+ memory,
345
+ })
346
+
347
+ const controller = new AbortController()
348
+ const stream = await agent.stream('Write the migration guide.', {
349
+ memory: { thread: 'thread-1', resource: 'user-1' },
350
+ abortSignal: controller.signal,
351
+ onAbort: ({ steps, text }) => {
352
+ console.log(`Aborted after ${steps.length} steps with ${text?.length ?? 0} characters streamed`)
353
+ },
354
+ })
355
+
356
+ let streamed = ''
357
+ for await (const chunk of stream.fullStream) {
358
+ if (chunk.type !== 'text-delta') continue
359
+ streamed += chunk.payload.text
360
+ if (streamed.length > 200) controller.abort()
361
+ }
362
+
363
+ // The partial answer is already in the thread
364
+ const { messages } = await memory.recall({ threadId: 'thread-1', resourceId: 'user-1' })
365
+ ```
366
+
367
+ `onAbort` receives the steps that completed before the cancellation and the assistant text streamed for the in-flight step. For the abort lifecycle itself, including durable runs aborted by `runId`, see the [`stream()` reference](https://mastra.ai/reference/streaming/agents/stream).
368
+
323
369
  ## Handling large attachments
324
370
 
325
371
  Some storage providers enforce record size limits that base64-encoded file attachments can exceed:
@@ -138,6 +138,9 @@ If you assemble the request input yourself and need it processed exactly as sent
138
138
  Message count is a poor proxy for context size: a tool result can be a few tokens or thousands. Use `messageHistory` to keep recent history within a token budget instead:
139
139
 
140
140
  ```typescript
141
+ import { Agent } from '@mastra/core/agent'
142
+ import { Memory } from '@mastra/memory'
143
+
141
144
  export const agent = new Agent({
142
145
  id: 'test-agent',
143
146
  memory: new Memory({