@mastra/pg 1.34.0 → 1.35.0-alpha.0

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,92 +1,5 @@
1
- export declare const KNOWLEDGE_V2_CORE_FEATURE = "knowledge-v2";
2
- export declare const KNOWLEDGE_STORAGE_CONTRACT_VERSION: 2;
3
- export declare const KNOWLEDGE_STORAGE_SCHEMA_VERSION: 2;
4
- /** Hard cap on scope nodes returned by one `listScopeNodes` read. */
5
- export declare const MAX_KNOWLEDGE_SCOPE_NODES = 1000;
6
- export interface ListKnowledgeScopeNodesInput {
7
- /** Only the scope at this address and the scopes beneath it, following parent edges transitively. */
8
- withinAddress?: string;
9
- /** Only the scopes at these exact addresses. */
10
- addresses?: string[];
11
- /** Only the scope nodes with these UUIDs. Combines with the other filters. */
12
- ids?: string[];
13
- /** `nextCursor` from the previous page of the same query. */
14
- cursor?: string;
15
- /** Page size, from 1 to `MAX_KNOWLEDGE_SCOPE_NODES` (the default). */
16
- limit?: number;
17
- }
18
- export interface ListKnowledgeScopeNodesOutput {
19
- /** Scope nodes ordered by name, then id. */
20
- scopes: KnowledgeScopeNodeSummary[];
21
- /** Pass back as `cursor` for the next page; `null` when this is the last page. */
22
- nextCursor: string | null;
23
- }
24
- export declare function createKnowledgeScopeNodeCursor(scope: Pick<KnowledgeScopeNodeSummary, 'name' | 'id'>, input: ListKnowledgeScopeNodesInput): string;
25
- /** Validates the page size and cursor of a `listScopeNodes` query; throws on a cursor from a different query. */
26
- export declare function parseListKnowledgeScopeNodesInput(input?: ListKnowledgeScopeNodesInput): {
27
- limit: number;
28
- after: {
29
- name: string;
30
- id: string;
31
- } | null;
32
- };
33
- /** Builds a page from up to `limit + 1` name/id-ordered scope nodes. */
34
- export declare function pageKnowledgeScopeNodes(rows: KnowledgeScopeNodeSummary[], limit: number, input: ListKnowledgeScopeNodesInput): ListKnowledgeScopeNodesOutput;
35
- /** A node placed inside a structural scope. Child scopes are members too, with `scope: null`. */
36
- export interface KnowledgeScopeMember {
37
- id: string;
38
- type: 'node';
39
- name: string;
40
- kind: string;
41
- content?: string;
42
- description?: string;
43
- scope: string[] | null;
44
- version: number;
45
- mergedInto?: string;
46
- createdAt: Date;
47
- updatedAt: Date;
48
- }
49
- export interface ListKnowledgeScopeMembersInput {
50
- scopeNodeId: string;
51
- /** `nextCursor` from the previous page for the same scope. */
52
- cursor?: string;
53
- /** Members to return, 1–500 (default 500). */
54
- limit?: number;
55
- }
56
- export interface ListKnowledgeScopeMembersOutput {
57
- /** Most recently updated members first (ties by name, then ID), at most `limit`. */
58
- members: KnowledgeScopeMember[];
59
- /** True when the scope has more members than were returned. */
60
- hasMore: boolean;
61
- /** Pass as `cursor` to read the next page; `null` on the last page. */
62
- nextCursor: string | null;
63
- }
64
- export declare const MAX_KNOWLEDGE_SCOPE_MEMBERS_LIMIT = 500;
65
- /** Clamps a requested member limit to 1–{@link MAX_KNOWLEDGE_SCOPE_MEMBERS_LIMIT}. */
66
- export declare function knowledgeScopeMembersLimit(limit: number | undefined): number;
67
- /** Validates the page size and cursor of a `listScopeMembers` query; throws on a cursor from another scope. */
68
- export declare function parseListKnowledgeScopeMembersInput(input: ListKnowledgeScopeMembersInput): {
69
- limit: number;
70
- after: {
71
- updatedAt: Date;
72
- name: string;
73
- id: string;
74
- } | null;
75
- };
76
- /** Builds a page from up to `limit + 1` members in `listScopeMembers` order. */
77
- export declare function pageKnowledgeScopeMembers(rows: KnowledgeScopeMember[], limit: number, input: ListKnowledgeScopeMembersInput): ListKnowledgeScopeMembersOutput;
78
- /** A reconciled structural scope node with its containing scope nodes. */
79
- export interface KnowledgeScopeNodeSummary {
80
- /** UUID of the `isScope` node. */
81
- id: string;
82
- /** Canonical address the scope node was reconciled from (e.g. `features:memory`). */
83
- address: string;
84
- name: string;
85
- kind?: string;
86
- description?: string;
87
- /** UUIDs of the scope nodes that contain this scope (membership edges). */
88
- parentIds: string[];
89
- }
1
+ export declare const KNOWLEDGE_STORAGE_CONTRACT_VERSION: 4;
2
+ export declare const KNOWLEDGE_STORAGE_SCHEMA_VERSION: 4;
90
3
  export declare const TABLE_KNOWLEDGE_NODE_SCOPES = "mastra_knowledge_node_scopes";
91
4
  export declare const TABLE_KNOWLEDGE_RECORD_SCOPES = "mastra_knowledge_record_scopes";
92
5
  export declare const TABLE_KNOWLEDGE_SCOPE_GRANTS = "mastra_knowledge_scope_grants";
@@ -99,20 +12,35 @@ export declare const TABLE_KNOWLEDGE_PROPOSALS = "mastra_knowledge_proposals";
99
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"];
100
13
  /** Knowledge v1 tables with no v2 equivalent; an explicit schema reset drops them. */
101
14
  export declare const RETIRED_KNOWLEDGE_TABLE_NAMES: readonly ['mastra_knowledge_cursors'];
102
- /** Tables and indexes published v1 adapters created for every app, whether or not it used Knowledge. */
103
- export declare const PUBLISHED_KNOWLEDGE_V1_TABLE_NAMES: ReadonlySet<string>;
104
- export declare const PUBLISHED_KNOWLEDGE_V1_INDEX_NAMES: ReadonlySet<string>;
105
- export declare const KNOWLEDGE_V2_NODES_SCHEMA: {
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: {
106
34
  readonly id: {
107
35
  readonly type: 'text';
108
36
  readonly nullable: false;
109
37
  readonly primaryKey: true;
110
38
  };
111
- readonly name: {
39
+ readonly scopeId: {
112
40
  readonly type: 'text';
113
41
  readonly nullable: false;
114
42
  };
115
- readonly kind: {
43
+ readonly parentId: {
116
44
  readonly type: 'text';
117
45
  readonly nullable: true;
118
46
  };
@@ -120,86 +48,55 @@ export declare const KNOWLEDGE_V2_NODES_SCHEMA: {
120
48
  readonly type: 'boolean';
121
49
  readonly nullable: false;
122
50
  };
123
- readonly metadata: {
124
- readonly type: 'jsonb';
125
- readonly nullable: true;
126
- };
127
- readonly version: {
128
- readonly type: 'integer';
129
- readonly nullable: false;
130
- };
131
- readonly createdAt: {
132
- readonly type: 'timestamp';
133
- readonly nullable: false;
134
- };
135
- readonly updatedAt: {
136
- readonly type: 'timestamp';
137
- readonly nullable: false;
138
- };
139
- readonly deletedAt: {
140
- readonly type: 'timestamp';
141
- readonly nullable: true;
142
- };
143
- readonly deletedBy: {
51
+ readonly address: {
144
52
  readonly type: 'text';
145
53
  readonly nullable: true;
146
54
  };
147
- readonly type: {
55
+ readonly declaration: {
148
56
  readonly type: 'text';
149
57
  readonly nullable: true;
150
58
  };
151
- readonly canonicalName: {
59
+ readonly key: {
152
60
  readonly type: 'text';
153
61
  readonly nullable: true;
154
62
  };
155
- readonly content: {
63
+ readonly position: {
156
64
  readonly type: 'text';
157
- readonly nullable: true;
65
+ readonly nullable: false;
158
66
  };
159
- readonly description: {
67
+ readonly name: {
160
68
  readonly type: 'text';
161
- readonly nullable: true;
69
+ readonly nullable: false;
162
70
  };
163
- readonly scope: {
164
- readonly type: 'jsonb';
165
- readonly nullable: true;
71
+ readonly canonicalName: {
72
+ readonly type: 'text';
73
+ readonly nullable: false;
166
74
  };
167
- readonly scopeKey: {
75
+ readonly description: {
168
76
  readonly type: 'text';
169
77
  readonly nullable: true;
170
78
  };
171
- readonly mergedInto: {
79
+ readonly body: {
172
80
  readonly type: 'text';
173
81
  readonly nullable: true;
174
82
  };
175
- };
176
- export declare const KNOWLEDGE_V2_RECORDS_SCHEMA: {
177
- readonly id: {
178
- readonly type: 'text';
83
+ readonly version: {
84
+ readonly type: 'integer';
179
85
  readonly nullable: false;
180
- readonly primaryKey: true;
181
86
  };
182
- readonly node: {
87
+ readonly mergedInto: {
183
88
  readonly type: 'text';
184
- readonly nullable: false;
185
- readonly references: {
186
- readonly table: "mastra_knowledge_nodes";
187
- readonly column: 'id';
188
- };
89
+ readonly nullable: true;
189
90
  };
190
- readonly text: {
191
- readonly type: 'text';
91
+ readonly createdBy: {
92
+ readonly type: 'jsonb';
192
93
  readonly nullable: false;
193
94
  };
194
- readonly metadata: {
95
+ readonly updatedBy: {
195
96
  readonly type: 'jsonb';
196
- readonly nullable: true;
197
- };
198
- readonly version: {
199
- readonly type: 'integer';
200
97
  readonly nullable: false;
201
98
  };
202
- readonly capturedAt: {
99
+ readonly createdAt: {
203
100
  readonly type: 'timestamp';
204
101
  readonly nullable: false;
205
102
  };
@@ -215,237 +112,125 @@ export declare const KNOWLEDGE_V2_RECORDS_SCHEMA: {
215
112
  readonly type: 'text';
216
113
  readonly nullable: true;
217
114
  };
218
- readonly scope: {
219
- readonly type: 'jsonb';
220
- readonly nullable: true;
221
- };
222
- readonly scopeKey: {
223
- readonly type: 'text';
224
- readonly nullable: true;
225
- };
226
- readonly sourceThreadId: {
227
- readonly type: 'text';
228
- readonly nullable: true;
229
- };
230
- readonly when: {
231
- readonly type: 'timestamp';
232
- readonly nullable: true;
233
- };
234
115
  };
235
- export declare const KNOWLEDGE_V2_MENTIONS_SCHEMA: {
236
- readonly recordId: {
116
+ export declare const KNOWLEDGE_NOTES_SCHEMA: {
117
+ readonly id: {
237
118
  readonly type: 'text';
238
119
  readonly nullable: false;
239
- readonly references: {
240
- readonly table: "mastra_knowledge_records";
241
- readonly column: 'id';
242
- };
120
+ readonly primaryKey: true;
243
121
  };
244
- readonly targetNodeId: {
122
+ readonly pageId: {
245
123
  readonly type: 'text';
246
- readonly nullable: true;
124
+ readonly nullable: false;
247
125
  readonly references: {
248
- readonly table: "mastra_knowledge_nodes";
126
+ readonly table: "mastra_knowledge_pages";
249
127
  readonly column: 'id';
250
128
  };
251
129
  };
252
- readonly sourceType: {
130
+ readonly text: {
253
131
  readonly type: 'text';
254
- readonly nullable: true;
132
+ readonly nullable: false;
255
133
  };
256
- readonly sourceId: {
257
- readonly type: 'text';
134
+ readonly when: {
135
+ readonly type: 'timestamp';
258
136
  readonly nullable: true;
259
137
  };
260
- };
261
- export declare const KNOWLEDGE_NODE_SCOPES_SCHEMA: {
262
- readonly nodeId: {
263
- readonly type: 'text';
138
+ readonly provenance: {
139
+ readonly type: 'jsonb';
264
140
  readonly nullable: false;
265
- readonly references: {
266
- readonly table: "mastra_knowledge_nodes";
267
- readonly column: 'id';
268
- };
269
141
  };
270
- readonly scopeNodeId: {
271
- readonly type: 'text';
142
+ readonly version: {
143
+ readonly type: 'integer';
272
144
  readonly nullable: false;
273
- readonly references: {
274
- readonly table: "mastra_knowledge_nodes";
275
- readonly column: 'id';
276
- };
277
145
  };
278
- readonly addedAt: {
146
+ readonly createdAt: {
279
147
  readonly type: 'timestamp';
280
148
  readonly nullable: false;
281
149
  };
282
- };
283
- export declare const KNOWLEDGE_RECORD_SCOPES_SCHEMA: {
284
- readonly recordId: {
285
- readonly type: 'text';
286
- readonly nullable: false;
287
- readonly references: {
288
- readonly table: "mastra_knowledge_records";
289
- readonly column: 'id';
290
- };
291
- };
292
- readonly scopeNodeId: {
293
- readonly type: 'text';
150
+ readonly updatedAt: {
151
+ readonly type: 'timestamp';
294
152
  readonly nullable: false;
295
- readonly references: {
296
- readonly table: "mastra_knowledge_nodes";
297
- readonly column: 'id';
298
- };
299
153
  };
300
- readonly addedAt: {
154
+ readonly deletedAt: {
301
155
  readonly type: 'timestamp';
302
- readonly nullable: false;
156
+ readonly nullable: true;
157
+ };
158
+ readonly deletedBy: {
159
+ readonly type: 'text';
160
+ readonly nullable: true;
303
161
  };
304
162
  };
305
- export declare const KNOWLEDGE_SCOPE_GRANTS_SCHEMA: {
306
- readonly scopeNodeId: {
163
+ /** One row per (note, stamp scope). Primary key is the pair. */
164
+ export declare const KNOWLEDGE_NOTE_STAMPS_SCHEMA: {
165
+ readonly noteId: {
307
166
  readonly type: 'text';
308
167
  readonly nullable: false;
309
168
  readonly references: {
310
- readonly table: "mastra_knowledge_nodes";
169
+ readonly table: "mastra_knowledge_notes";
311
170
  readonly column: 'id';
312
171
  };
313
172
  };
314
- readonly scopeRefId: {
173
+ readonly scopeId: {
315
174
  readonly type: 'text';
316
175
  readonly nullable: false;
317
176
  readonly references: {
318
- readonly table: "mastra_knowledge_nodes";
177
+ readonly table: "mastra_knowledge_pages";
319
178
  readonly column: 'id';
320
179
  };
321
180
  };
322
- readonly role: {
323
- readonly type: 'text';
324
- readonly nullable: false;
325
- };
326
- readonly canSuggest: {
327
- readonly type: 'boolean';
328
- readonly nullable: true;
329
- };
330
- };
331
- export declare const KNOWLEDGE_ACCESS_STATE_SCHEMA: {
332
- readonly id: {
333
- readonly type: 'text';
334
- readonly nullable: false;
335
- readonly primaryKey: true;
336
- };
337
- readonly epoch: {
338
- readonly type: 'integer';
339
- readonly nullable: false;
340
- };
341
- readonly schemaVersion: {
342
- readonly type: 'integer';
343
- readonly nullable: false;
344
- };
345
181
  };
346
- export declare const KNOWLEDGE_SCOPE_ADDRESSES_SCHEMA: {
347
- readonly address: {
348
- readonly type: 'text';
349
- readonly nullable: false;
350
- readonly primaryKey: true;
351
- };
352
- readonly scopeNodeId: {
182
+ /** One row per (note, mentioned page). Primary key is the pair. */
183
+ export declare const KNOWLEDGE_PAGE_MENTIONS_SCHEMA: {
184
+ readonly noteId: {
353
185
  readonly type: 'text';
354
186
  readonly nullable: false;
355
187
  readonly references: {
356
- readonly table: "mastra_knowledge_nodes";
188
+ readonly table: "mastra_knowledge_notes";
357
189
  readonly column: 'id';
358
190
  };
359
191
  };
360
- };
361
- export declare const KNOWLEDGE_NODE_ADDRESSES_SCHEMA: {
362
- readonly source: {
363
- readonly type: 'text';
364
- readonly nullable: false;
365
- };
366
- readonly address: {
367
- readonly type: 'text';
368
- readonly nullable: false;
369
- };
370
- readonly nodeId: {
192
+ readonly pageId: {
371
193
  readonly type: 'text';
372
194
  readonly nullable: false;
373
195
  readonly references: {
374
- readonly table: "mastra_knowledge_nodes";
196
+ readonly table: "mastra_knowledge_pages";
375
197
  readonly column: 'id';
376
198
  };
377
199
  };
378
200
  };
379
- export declare const KNOWLEDGE_IMPORT_STATE_SCHEMA: {
380
- readonly importerId: {
381
- readonly type: 'text';
382
- readonly nullable: false;
383
- };
384
- readonly binding: {
385
- readonly type: 'text';
386
- readonly nullable: false;
387
- };
388
- readonly key: {
389
- readonly type: 'text';
390
- readonly nullable: false;
391
- };
392
- readonly value: {
393
- readonly type: 'text';
394
- readonly nullable: false;
395
- };
396
- };
397
- export declare const KNOWLEDGE_IMPORT_RUNS_SCHEMA: {
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: {
398
203
  readonly id: {
399
204
  readonly type: 'text';
400
205
  readonly nullable: false;
401
206
  readonly primaryKey: true;
402
207
  };
403
- readonly importerId: {
404
- readonly type: 'text';
405
- readonly nullable: false;
406
- };
407
- readonly binding: {
408
- readonly type: 'text';
409
- readonly nullable: false;
410
- };
411
- readonly importKind: {
208
+ readonly pageId: {
412
209
  readonly type: 'text';
413
210
  readonly nullable: false;
211
+ readonly references: {
212
+ readonly table: "mastra_knowledge_pages";
213
+ readonly column: 'id';
214
+ };
414
215
  };
415
- readonly triggerKind: {
416
- readonly type: 'text';
216
+ readonly audience: {
217
+ readonly type: 'jsonb';
417
218
  readonly nullable: false;
418
219
  };
419
- readonly status: {
220
+ readonly createdBy: {
420
221
  readonly type: 'text';
421
222
  readonly nullable: false;
422
223
  };
423
- readonly error: {
424
- readonly type: 'text';
425
- readonly nullable: true;
426
- };
427
- readonly transcriptThreadId: {
428
- readonly type: 'text';
429
- readonly nullable: true;
430
- };
431
- readonly traceId: {
432
- readonly type: 'text';
433
- readonly nullable: true;
434
- };
435
- readonly queuedAt: {
224
+ readonly createdAt: {
436
225
  readonly type: 'timestamp';
437
226
  readonly nullable: false;
438
227
  };
439
- readonly startedAt: {
440
- readonly type: 'timestamp';
441
- readonly nullable: true;
442
- };
443
- readonly completedAt: {
228
+ readonly updatedAt: {
444
229
  readonly type: 'timestamp';
445
- readonly nullable: true;
230
+ readonly nullable: false;
446
231
  };
447
232
  };
448
- export declare const KNOWLEDGE_V2_ACTIVITY_SCHEMA: {
233
+ export declare const KNOWLEDGE_PAGE_ACTIVITY_SCHEMA: {
449
234
  readonly id: {
450
235
  readonly type: 'text';
451
236
  readonly nullable: false;
@@ -455,113 +240,41 @@ export declare const KNOWLEDGE_V2_ACTIVITY_SCHEMA: {
455
240
  readonly type: 'text';
456
241
  readonly nullable: false;
457
242
  };
458
- readonly targetType: {
459
- readonly type: 'text';
460
- readonly nullable: true;
461
- };
462
- readonly targetId: {
243
+ readonly scopeId: {
463
244
  readonly type: 'text';
464
- readonly nullable: true;
245
+ readonly nullable: false;
465
246
  };
466
- readonly contextScopeId: {
247
+ readonly pageId: {
467
248
  readonly type: 'text';
468
- readonly nullable: true;
469
- readonly references: {
470
- readonly table: "mastra_knowledge_nodes";
471
- readonly column: 'id';
472
- };
249
+ readonly nullable: false;
473
250
  };
474
- readonly importRunId: {
251
+ readonly noteId: {
475
252
  readonly type: 'text';
476
253
  readonly nullable: true;
477
- readonly references: {
478
- readonly table: "mastra_knowledge_import_runs";
479
- readonly column: 'id';
480
- };
481
254
  };
482
- readonly details: {
255
+ readonly provenance: {
483
256
  readonly type: 'jsonb';
484
- readonly nullable: true;
257
+ readonly nullable: false;
485
258
  };
486
259
  readonly createdAt: {
487
260
  readonly type: 'timestamp';
488
261
  readonly nullable: false;
489
262
  };
490
- readonly recordType: {
491
- readonly type: 'text';
492
- readonly nullable: true;
493
- };
494
- readonly recordId: {
495
- readonly type: 'text';
496
- readonly nullable: true;
497
- };
498
- readonly scope: {
499
- readonly type: 'jsonb';
500
- readonly nullable: true;
501
- };
502
- readonly scopeKey: {
503
- readonly type: 'text';
504
- readonly nullable: true;
505
- };
506
- readonly sourceThreadId: {
507
- readonly type: 'text';
508
- readonly nullable: true;
509
- };
510
263
  };
511
- export declare const KNOWLEDGE_PROPOSALS_SCHEMA: {
264
+ export declare const KNOWLEDGE_PAGES_STATE_SCHEMA: {
512
265
  readonly id: {
513
266
  readonly type: 'text';
514
267
  readonly nullable: false;
515
268
  readonly primaryKey: true;
516
269
  };
517
- readonly targetType: {
518
- readonly type: 'text';
519
- readonly nullable: false;
520
- };
521
- readonly targetId: {
522
- readonly type: 'text';
523
- readonly nullable: false;
524
- };
525
- readonly action: {
526
- readonly type: 'text';
527
- readonly nullable: false;
528
- };
529
- readonly changes: {
530
- readonly type: 'jsonb';
531
- readonly nullable: false;
532
- };
533
- readonly reason: {
534
- readonly type: 'text';
535
- readonly nullable: true;
536
- };
537
- readonly proposerContextScopeId: {
538
- readonly type: 'text';
539
- readonly nullable: false;
540
- };
541
- readonly expectedVersion: {
270
+ readonly schemaVersion: {
542
271
  readonly type: 'integer';
543
272
  readonly nullable: false;
544
273
  };
545
- readonly status: {
546
- readonly type: 'text';
547
- readonly nullable: false;
548
- };
549
- readonly reviewerContextScopeId: {
550
- readonly type: 'text';
551
- readonly nullable: true;
552
- };
553
- readonly reviewedAt: {
554
- readonly type: 'timestamp';
555
- readonly nullable: true;
556
- };
557
- readonly createdAt: {
558
- readonly type: 'timestamp';
559
- readonly nullable: false;
560
- };
561
274
  };
562
- export type KnowledgeSchemaInspection = {
275
+ export type KnowledgePagesSchemaInspection = {
563
276
  status: 'compatible';
564
- schemaVersion: typeof KNOWLEDGE_STORAGE_SCHEMA_VERSION;
277
+ schemaVersion: typeof KNOWLEDGE_PAGES_SCHEMA_VERSION;
565
278
  } | {
566
279
  status: 'uninitialized';
567
280
  schemaVersion: null;
@@ -569,24 +282,57 @@ export type KnowledgeSchemaInspection = {
569
282
  status: 'incompatible-reset-required';
570
283
  schemaVersion: number | null;
571
284
  reason: string;
572
- } | {
573
- status: 'unavailable';
574
- schemaVersion: null;
575
- reason: string;
576
285
  };
577
- export interface KnowledgeSchemaSnapshot {
578
- available: boolean;
286
+ /**
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.
289
+ */
290
+ export declare function inspectKnowledgePagesSchema(snapshot: {
579
291
  tableNames: readonly string[];
580
292
  schemaVersion?: number;
581
- reason?: string;
582
- }
583
- interface KnowledgeV2Core {
584
- assertKnowledgeDescriptionWithinBound(description: string | undefined): void;
585
- assertKnowledgeRecordTextWithinBound(text: string): void;
586
- assertKnowledgeSchemaCompatible(inspection: KnowledgeSchemaInspection): void;
587
- inspectKnowledgeSchema(snapshot: KnowledgeSchemaSnapshot): KnowledgeSchemaInspection;
293
+ }): KnowledgePagesSchemaInspection;
294
+ /**
295
+ * The old Knowledge tables an adapter drops on init, rows included: Knowledge before schema 4 was an
296
+ * experimental store with no migration. Every schema-1/2-only table present is dropped. The table
297
+ * names schema 4 reuses (mentions, activity, the state table) are dropped too, but only when an old
298
+ * table is present and no schema-4 state row exists, so they are old-shaped. Schema-4-only tables
299
+ * are never listed. On a schema-4 store this lists only tables an older process recreated during a
300
+ * rolling deploy. Drop order is safe for adapters that enforce references.
301
+ */
302
+ export declare function legacyKnowledgeTablesToDrop(snapshot: {
303
+ tableNames: readonly string[];
304
+ schemaVersion?: number;
305
+ }): string[];
306
+ /** Message for the error an adapter throws on `incompatible-reset-required`. */
307
+ export declare function knowledgePagesResetMessage(reason: string): string;
308
+ /**
309
+ * The page-store runtime pieces adapters take from `@mastra/core/storage`. They are loaded through
310
+ * `createKnowledgePagesCoreLoader` instead of static imports so adapters keep loading on cores
311
+ * older than the `knowledge-pages` feature without raising their `@mastra/core` peer floor.
312
+ */
313
+ export interface KnowledgePagesCore {
314
+ assertKnowledgePageDescriptionWithinBound(description: string | undefined): void;
315
+ assertKnowledgeNoteTextWithinBound(text: string): void;
316
+ canonicalKnowledgeName(name: string): string;
317
+ knowledgePositionBetween(before?: string, after?: string): string;
318
+ MAX_KNOWLEDGE_MOVE_PAGES: number;
319
+ MAX_KNOWLEDGE_PAGE_DEPTH: number;
320
+ MAX_KNOWLEDGE_PAGE_LIST_LIMIT: number;
321
+ KnowledgeMoveTooLargeError: new (pageId: string, pages: number) => Error;
322
+ KnowledgePageDepthError: new (pageId: string) => Error;
323
+ KnowledgePageHasChildrenError: new (pageId: string) => Error;
324
+ KnowledgePageKeyConflictError: new (key: string, parentId: string) => Error;
588
325
  }
589
- export declare function assertKnowledgeV2CoreSupport(features: ReadonlySet<string>): void;
590
- export declare function createKnowledgeV2CoreLoader(features: ReadonlySet<string>, loadStorageModule: () => Promise<unknown>): () => Promise<KnowledgeV2Core>;
591
- export {};
326
+ /** Loads core's page-store runtime once, after checking core advertises `knowledge-pages`. */
327
+ export declare function createKnowledgePagesCoreLoader(features: ReadonlySet<string>, loadStorageModule: () => Promise<unknown>): () => Promise<KnowledgePagesCore>;
328
+ /**
329
+ * Keyword-search words: the query split on whitespace, lowercased, deduplicated. Every word must
330
+ * appear (as a case-insensitive substring) in a hit; an empty list means the search returns nothing.
331
+ */
332
+ export declare function knowledgeSearchWords(query: string): string[];
333
+ /**
334
+ * Why `key` can't be a Knowledge page key, or undefined when it can. Keys are one path segment:
335
+ * non-empty, with no `/` (path separator), `#` (scope/path separator) or `%` (escape character).
336
+ */
337
+ export declare function knowledgePageKeyProblem(key: string): string | undefined;
592
338
  //# sourceMappingURL=index.d.ts.map