@mastra/mysql 0.16.0-alpha.2 → 0.16.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.
package/dist/index.js CHANGED
@@ -4300,7 +4300,8 @@ const KNOWLEDGE_PAGES_CORE_FUNCTIONS = [
4300
4300
  const KNOWLEDGE_PAGES_CORE_NUMBERS = [
4301
4301
  "MAX_KNOWLEDGE_MOVE_PAGES",
4302
4302
  "MAX_KNOWLEDGE_PAGE_DEPTH",
4303
- "MAX_KNOWLEDGE_PAGE_LIST_LIMIT"
4303
+ "MAX_KNOWLEDGE_PAGE_LIST_LIMIT",
4304
+ "MAX_KNOWLEDGE_PAGE_LINKS"
4304
4305
  ];
4305
4306
  function resolveKnowledgePagesCore(storageModule) {
4306
4307
  const module = typeof storageModule === "object" && storageModule !== null ? storageModule : {};
@@ -4321,16 +4322,18 @@ function createKnowledgePagesCoreLoader(features, loadStorageModule) {
4321
4322
  };
4322
4323
  }
4323
4324
  /**
4324
- * Keyword-search words: the query split on whitespace, lowercased, deduplicated. A hit needs at
4325
- * least one of them (as a case-insensitive substring); an empty list means the search returns nothing.
4325
+ * Keyword-search words: the query split on whitespace, lowercased, deduplicated, keeping the first
4326
+ * {@link KNOWLEDGE_SEARCH_MAX_WORDS}. A hit needs at least one of them (as a case-insensitive
4327
+ * substring); an empty list means the search returns nothing.
4326
4328
  */
4327
4329
  function knowledgeSearchWords(query) {
4328
- return [...new Set(query.toLowerCase().split(/\s+/).filter(Boolean))];
4330
+ return [...new Set(query.toLowerCase().split(/\s+/).filter(Boolean))].slice(0, 16);
4329
4331
  }
4330
4332
  /**
4331
4333
  * Points one matched search word earns on a page, by the best field it appears in: name, then
4332
- * description, then body. Pages rank by how many query words they match first; these points only
4333
- * break ties between pages that match the same number of words.
4334
+ * description, then body. A page whose name contains the whole query ranks first; below that, pages
4335
+ * rank by how many query words they match, and these points only break ties between pages that
4336
+ * match the same number of words.
4334
4337
  */
4335
4338
  const KNOWLEDGE_SEARCH_WEIGHTS = {
4336
4339
  name: 3,
@@ -4356,7 +4359,8 @@ const T = {
4356
4359
  mentions: "`mastra_knowledge_mentions`",
4357
4360
  pins: "`mastra_knowledge_pins`",
4358
4361
  pinAudiences: "`mastra_knowledge_pin_audiences`",
4359
- activity: "`mastra_knowledge_activity`"
4362
+ activity: "`mastra_knowledge_activity`",
4363
+ links: "`mastra_knowledge_page_links`"
4360
4364
  };
4361
4365
  const KEY = "`key`";
4362
4366
  const WHEN = "`when`";
@@ -4367,6 +4371,11 @@ const LIVE_KEY_COLUMN = `VARCHAR(768) ${BIN} AS (IF(deletedAt IS NULL AND \`key\
4367
4371
  const MISSING_PAGE_INDEX = `SELECT 1 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema = DATABASE() AND table_name = 'mastra_knowledge_pages' AND index_name = ?)`;
4368
4372
  /** Upgrades for Knowledge databases created by an earlier alpha build; `needed` returns a row when `apply` must run. */
4369
4373
  const KNOWLEDGE_PAGE_UPGRADES = [
4374
+ {
4375
+ needed: `SELECT 1 FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'mastra_knowledge_pins' AND column_name = 'kind')`,
4376
+ args: [],
4377
+ apply: ["ALTER TABLE `mastra_knowledge_pins` ADD COLUMN kind VARCHAR(16) NOT NULL DEFAULT 'page', ADD COLUMN depth INT NULL, DROP INDEX idx_kpins_page, ADD UNIQUE KEY idx_kpins_page_kind (pageId, kind)"]
4378
+ },
4370
4379
  {
4371
4380
  needed: `SELECT 1 FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'mastra_knowledge_pages' AND column_name = 'liveKey' AND generation_expression LIKE '%scopeId%'`,
4372
4381
  args: [],
@@ -4459,17 +4468,27 @@ const KNOWLEDGE_PAGE_DDL = [
4459
4468
  `CREATE TABLE IF NOT EXISTS ${T.pins} (
4460
4469
  id VARCHAR(255) ${BIN} NOT NULL PRIMARY KEY,
4461
4470
  pageId VARCHAR(255) ${BIN} NOT NULL,
4471
+ kind VARCHAR(16) NOT NULL DEFAULT 'page',
4472
+ depth INT NULL,
4462
4473
  audience JSON NOT NULL,
4463
4474
  createdBy VARCHAR(255) NOT NULL,
4464
4475
  createdAt VARCHAR(32) NOT NULL,
4465
4476
  updatedAt VARCHAR(32) NOT NULL,
4466
- UNIQUE KEY idx_kpins_page (pageId)
4477
+ UNIQUE KEY idx_kpins_page_kind (pageId, kind)
4467
4478
  )`,
4468
4479
  `CREATE TABLE IF NOT EXISTS ${T.pinAudiences} (
4469
4480
  audience VARCHAR(512) ${BIN} NOT NULL,
4470
4481
  pinId VARCHAR(255) ${BIN} NOT NULL,
4471
4482
  PRIMARY KEY (audience, pinId),
4472
4483
  KEY idx_kpin_audiences_pin (pinId)
4484
+ )`,
4485
+ `CREATE TABLE IF NOT EXISTS ${T.links} (
4486
+ fromPageId VARCHAR(255) ${BIN} NOT NULL,
4487
+ ref VARCHAR(512) ${BIN} NOT NULL,
4488
+ toPageId VARCHAR(255) ${BIN} NULL,
4489
+ linkCount INT NOT NULL,
4490
+ PRIMARY KEY (fromPageId, ref),
4491
+ KEY idx_klinks_to_ref (toPageId, ref)
4473
4492
  )`,
4474
4493
  `CREATE TABLE IF NOT EXISTS ${T.activity} (
4475
4494
  id VARCHAR(255) ${BIN} NOT NULL PRIMARY KEY,
@@ -4535,6 +4554,8 @@ function toPin(row) {
4535
4554
  return {
4536
4555
  id: String(row.id),
4537
4556
  pageId: String(row.pageId),
4557
+ kind: String(row.kind),
4558
+ ...row.depth == null ? {} : { depth: Number(row.depth) },
4538
4559
  audience: parseJsonList(row.audience),
4539
4560
  createdBy: String(row.createdBy),
4540
4561
  createdAt: new Date(String(row.createdAt)),
@@ -4706,6 +4727,7 @@ var MySQLKnowledgePages = class {
4706
4727
  T.mentions,
4707
4728
  T.stamps,
4708
4729
  T.notes,
4730
+ T.links,
4709
4731
  T.pages
4710
4732
  ]) await tx.execute({
4711
4733
  sql: `DELETE FROM ${table}`,
@@ -4888,13 +4910,19 @@ var MySQLKnowledgePages = class {
4888
4910
  const limit = limitOf(input.limit, core.MAX_KNOWLEDGE_PAGE_LIST_LIMIT);
4889
4911
  const cursor = decodeCursor(input.cursor, 2);
4890
4912
  const args = [input.parentId];
4913
+ let filter = "";
4914
+ if (input.read) {
4915
+ const readable = pageReadable("p", input.read);
4916
+ filter = ` AND ${readable.sql}`;
4917
+ args.push(...readable.args);
4918
+ }
4891
4919
  let after = "";
4892
4920
  if (cursor) {
4893
- after = ` AND (position > ? OR (position = ? AND id > ?))`;
4921
+ after = ` AND (p.position > ? OR (p.position = ? AND p.id > ?))`;
4894
4922
  args.push(cursor[0], cursor[0], cursor[1]);
4895
4923
  }
4896
4924
  args.push(limit + 1);
4897
- const rows = await this.#query(this.#read, `SELECT * FROM ${T.pages} WHERE isScope = 1 AND parentId <=> ?${after} ORDER BY position, id LIMIT ?`, args);
4925
+ const rows = await this.#query(this.#read, `SELECT p.* FROM ${T.pages} p WHERE p.isScope = 1 AND p.parentId <=> ?${filter}${after} ORDER BY p.position, p.id LIMIT ?`, args);
4898
4926
  return this.#pageOutput(rows, limit, (row) => [String(row.position), String(row.id)]);
4899
4927
  }
4900
4928
  #pageOutput(rows, limit, cursorOf) {
@@ -5184,9 +5212,8 @@ var MySQLKnowledgePages = class {
5184
5212
  args: [input.sourceId]
5185
5213
  });
5186
5214
  const pins = await this.#query(tx, `SELECT * FROM ${T.pins} WHERE pageId IN (?, ?)`, [input.sourceId, input.targetId]);
5187
- const sourcePin = pins.find((pin) => String(pin.pageId) === input.sourceId);
5188
- if (sourcePin) {
5189
- const targetPin = pins.find((pin) => String(pin.pageId) === input.targetId);
5215
+ for (const sourcePin of pins.filter((pin) => String(pin.pageId) === input.sourceId)) {
5216
+ const targetPin = pins.find((pin) => String(pin.pageId) === input.targetId && pin.kind === sourcePin.kind);
5190
5217
  const audience = parseJsonList(sourcePin.audience);
5191
5218
  if (targetPin) {
5192
5219
  const merged = [.../* @__PURE__ */ new Set([...parseJsonList(targetPin.audience), ...audience])];
@@ -5286,6 +5313,15 @@ var MySQLKnowledgePages = class {
5286
5313
  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);
5287
5314
  return this.#noteOutput(rows, limit);
5288
5315
  }
5316
+ async countChildScopes(input) {
5317
+ const ids = [...new Set(input.parentIds)];
5318
+ const counts = Object.fromEntries(ids.map((id) => [id, 0]));
5319
+ if (ids.length === 0) return counts;
5320
+ const readable = pageReadable("p", input.read);
5321
+ const rows = await this.#query(this.#read, `SELECT p.parentId AS parentId, COUNT(*) AS total FROM ${T.pages} p WHERE p.parentId IN ${JV} AND p.isScope = 1 AND ${readable.sql} GROUP BY p.parentId`, [jsonList(ids), ...readable.args]);
5322
+ for (const row of rows) counts[String(row.parentId)] = Number(row.total);
5323
+ return counts;
5324
+ }
5289
5325
  async countChildPages(input) {
5290
5326
  const ids = [...new Set(input.parentIds)];
5291
5327
  const counts = Object.fromEntries(ids.map((id) => [id, 0]));
@@ -5295,6 +5331,130 @@ var MySQLKnowledgePages = class {
5295
5331
  for (const row of rows) counts[String(row.parentId)] = Number(row.total);
5296
5332
  return counts;
5297
5333
  }
5334
+ async replacePageBodyLinks(input) {
5335
+ await this.#transaction(async (tx) => {
5336
+ await tx.execute({
5337
+ sql: `DELETE FROM ${T.links} WHERE fromPageId = ?`,
5338
+ args: [input.pageId]
5339
+ });
5340
+ if (input.links.length === 0) return;
5341
+ await tx.execute({
5342
+ sql: `INSERT INTO ${T.links} (fromPageId, ref, toPageId, linkCount) VALUES ${input.links.map(() => "(?, ?, ?, ?)").join(", ")}`,
5343
+ args: input.links.flatMap((link) => [
5344
+ input.pageId,
5345
+ link.ref,
5346
+ link.toPageId,
5347
+ link.count
5348
+ ])
5349
+ });
5350
+ });
5351
+ }
5352
+ async listPageBodyLinkSources(input) {
5353
+ const refs = [...new Set(input.refs ?? [])];
5354
+ const targets = [...new Set(input.toPageIds ?? [])];
5355
+ const parts = [];
5356
+ const args = [];
5357
+ if (refs.length) {
5358
+ parts.push(`(toPageId IS NULL AND ref IN ${JV})`);
5359
+ args.push(jsonList(refs));
5360
+ }
5361
+ if (targets.length) {
5362
+ parts.push(`toPageId IN ${JV}`);
5363
+ args.push(jsonList(targets));
5364
+ }
5365
+ if (!parts.length) return [];
5366
+ return (await this.#query(this.#read, `SELECT DISTINCT fromPageId FROM ${T.links} WHERE ${parts.join(" OR ")}`, args)).map((row) => String(row.fromPageId));
5367
+ }
5368
+ /**
5369
+ * Every resolved link touching `ids` whose both ends are live and readable, one row per
5370
+ * (from, to, kind); no self-links. Note links go through the same visible-note rule as listNotes.
5371
+ */
5372
+ #visibleLinkEdges(ids, read, direction, kinds) {
5373
+ const wanted = new Set(kinds ?? ["body", "note"]);
5374
+ const idList = jsonList(ids);
5375
+ const touch = (from, to) => direction === "out" ? {
5376
+ sql: `${from} IN ${JV}`,
5377
+ args: [idList]
5378
+ } : direction === "in" ? {
5379
+ sql: `${to} IN ${JV}`,
5380
+ args: [idList]
5381
+ } : {
5382
+ sql: `(${from} IN ${JV} OR ${to} IN ${JV})`,
5383
+ args: [idList, idList]
5384
+ };
5385
+ const branches = [];
5386
+ const args = [];
5387
+ if (wanted.has("body")) {
5388
+ const fromReadable = pageReadable("fp", read);
5389
+ const toReadable = pageReadable("tp", read);
5390
+ const t = touch("l.fromPageId", "l.toPageId");
5391
+ branches.push(`SELECT l.fromPageId AS fromPageId, l.toPageId AS toPageId, 'body' AS kind, CAST(SUM(l.linkCount) AS SIGNED) AS cnt
5392
+ FROM ${T.links} l
5393
+ JOIN ${T.pages} fp ON fp.id = l.fromPageId AND fp.deletedAt IS NULL AND ${fromReadable.sql}
5394
+ JOIN ${T.pages} tp ON tp.id = l.toPageId AND tp.deletedAt IS NULL AND ${toReadable.sql}
5395
+ WHERE l.toPageId IS NOT NULL AND l.fromPageId <> l.toPageId AND ${t.sql}
5396
+ GROUP BY l.fromPageId, l.toPageId`);
5397
+ args.push(...fromReadable.args, ...toReadable.args, ...t.args);
5398
+ }
5399
+ if (wanted.has("note")) {
5400
+ const visible = noteReadable("n", read);
5401
+ const toReadable = pageReadable("tp", read);
5402
+ const t = touch("vn.pageId", "mn.pageId");
5403
+ branches.push(`SELECT vn.pageId AS fromPageId, mn.pageId AS toPageId, 'note' AS kind, CAST(COUNT(*) AS SIGNED) AS cnt
5404
+ FROM (SELECT n.id AS id, n.pageId AS pageId FROM ${T.notes} n
5405
+ JOIN ${T.pages} np ON np.id = n.pageId AND np.deletedAt IS NULL
5406
+ WHERE n.deletedAt IS NULL AND (n.pageId IN ${JV} OR n.id IN (SELECT mm.noteId FROM ${T.mentions} mm WHERE mm.pageId IN ${JV}))
5407
+ AND ${visible.sql}) vn
5408
+ JOIN ${T.mentions} mn ON mn.noteId = vn.id
5409
+ JOIN ${T.pages} tp ON tp.id = mn.pageId AND tp.deletedAt IS NULL AND ${toReadable.sql}
5410
+ WHERE mn.pageId <> vn.pageId AND ${t.sql}
5411
+ GROUP BY vn.pageId, mn.pageId`);
5412
+ args.push(idList, idList, ...visible.args, ...toReadable.args, ...t.args);
5413
+ }
5414
+ return {
5415
+ sql: branches.length ? branches.join(" UNION ALL ") : `SELECT NULL AS fromPageId, NULL AS toPageId, NULL AS kind, NULL AS cnt FROM DUAL WHERE FALSE`,
5416
+ args
5417
+ };
5418
+ }
5419
+ async countPageLinks(input) {
5420
+ const ids = [...new Set(input.pageIds)];
5421
+ const counts = Object.fromEntries(ids.map((id) => [id, {
5422
+ in: 0,
5423
+ out: 0
5424
+ }]));
5425
+ if (ids.length === 0) return counts;
5426
+ const edges = this.#visibleLinkEdges(ids, input.read, "both", input.kinds);
5427
+ const idList = jsonList(ids);
5428
+ const rows = await this.#query(this.#read, `WITH e AS (${edges.sql})
5429
+ SELECT r.id AS id, CAST(SUM(r.o) AS SIGNED) AS outCount, CAST(SUM(r.i) AS SIGNED) AS inCount FROM (
5430
+ SELECT fromPageId AS id, COUNT(DISTINCT toPageId) AS o, 0 AS i FROM e WHERE fromPageId IN ${JV} GROUP BY fromPageId
5431
+ UNION ALL
5432
+ SELECT toPageId AS id, 0 AS o, COUNT(DISTINCT fromPageId) AS i FROM e WHERE toPageId IN ${JV} GROUP BY toPageId
5433
+ ) r GROUP BY r.id`, [
5434
+ ...edges.args,
5435
+ idList,
5436
+ idList
5437
+ ]);
5438
+ for (const row of rows) counts[String(row.id)] = {
5439
+ in: Number(row.inCount),
5440
+ out: Number(row.outCount)
5441
+ };
5442
+ return counts;
5443
+ }
5444
+ async listPageLinks(input) {
5445
+ const limit = input.limit ?? 1e3;
5446
+ if (!Number.isInteger(limit) || limit < 1) throw new RangeError("Knowledge link limit must be a positive integer");
5447
+ const core = await loadPagesCore();
5448
+ const ids = [...new Set(input.pageIds)];
5449
+ if (ids.length === 0) return [];
5450
+ const edges = this.#visibleLinkEdges(ids, input.read, input.direction ?? "both", input.kinds);
5451
+ return (await this.#query(this.#read, `SELECT * FROM (${edges.sql}) e ORDER BY fromPageId, toPageId, (kind = 'note') LIMIT ${Math.min(limit, core.MAX_KNOWLEDGE_PAGE_LINKS)}`, edges.args)).map((row) => ({
5452
+ fromPageId: String(row.fromPageId),
5453
+ toPageId: String(row.toPageId),
5454
+ kind: String(row.kind),
5455
+ count: Number(row.cnt)
5456
+ }));
5457
+ }
5298
5458
  async countNotes(input) {
5299
5459
  const ids = [...new Set(input.pageIds)];
5300
5460
  const counts = Object.fromEntries(ids.map((id) => [id, 0]));
@@ -5556,17 +5716,21 @@ var MySQLKnowledgePages = class {
5556
5716
  });
5557
5717
  }
5558
5718
  addPinAudience(input) {
5719
+ const kind = input.kind ?? "page";
5720
+ const depth = kind === "list" ? input.depth ?? 1 : null;
5559
5721
  return this.#transaction(async (tx) => {
5560
5722
  const page = await this.#livePage(tx, input.pageId);
5561
5723
  const now = (/* @__PURE__ */ new Date()).toISOString();
5562
- const existing = (await this.#query(tx, `SELECT * FROM ${T.pins} WHERE pageId = ?`, [input.pageId]))[0];
5724
+ const existing = (await this.#query(tx, `SELECT * FROM ${T.pins} WHERE pageId = ? AND kind = ?`, [input.pageId, kind]))[0];
5563
5725
  if (!existing) {
5564
5726
  const id = createKnowledgeUlid();
5565
5727
  await tx.execute({
5566
- sql: `INSERT INTO ${T.pins} (id, pageId, audience, createdBy, createdAt, updatedAt) VALUES (?, ?, ?, ?, ?, ?)`,
5728
+ sql: `INSERT INTO ${T.pins} (id, pageId, kind, depth, audience, createdBy, createdAt, updatedAt) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
5567
5729
  args: [
5568
5730
  id,
5569
5731
  input.pageId,
5732
+ kind,
5733
+ depth,
5570
5734
  JSON.stringify([...new Set(input.audience)]),
5571
5735
  input.createdBy,
5572
5736
  now,
@@ -5583,11 +5747,13 @@ var MySQLKnowledgePages = class {
5583
5747
  }
5584
5748
  const current = parseJsonList(existing.audience);
5585
5749
  const merged = [.../* @__PURE__ */ new Set([...current, ...input.audience])];
5586
- if (merged.length !== current.length) {
5750
+ const depthChanged = (existing.depth == null ? null : Number(existing.depth)) !== depth;
5751
+ if (merged.length !== current.length || depthChanged) {
5587
5752
  await tx.execute({
5588
- sql: `UPDATE ${T.pins} SET audience = ?, updatedAt = ? WHERE id = ?`,
5753
+ sql: `UPDATE ${T.pins} SET audience = ?, depth = ?, updatedAt = ? WHERE id = ?`,
5589
5754
  args: [
5590
5755
  JSON.stringify(merged),
5756
+ depth,
5591
5757
  now,
5592
5758
  String(existing.id)
5593
5759
  ]
@@ -5604,7 +5770,7 @@ var MySQLKnowledgePages = class {
5604
5770
  }
5605
5771
  removePinAudience(input) {
5606
5772
  return this.#transaction(async (tx) => {
5607
- const existing = (await this.#query(tx, `SELECT * FROM ${T.pins} WHERE pageId = ?`, [input.pageId]))[0];
5773
+ const existing = (await this.#query(tx, `SELECT * FROM ${T.pins} WHERE pageId = ? AND kind = ?`, [input.pageId, input.kind ?? "page"]))[0];
5608
5774
  if (!existing) return null;
5609
5775
  const current = parseJsonList(existing.audience);
5610
5776
  const remove = new Set(input.audience);
@@ -5648,15 +5814,19 @@ var MySQLKnowledgePages = class {
5648
5814
  filters += ` AND pin.id IN (SELECT pa.pinId FROM (SELECT jv.v FROM JSON_TABLE(?, '$[*]' COLUMNS (v VARCHAR(512) ${BIN} PATH '$')) jv) aud STRAIGHT_JOIN ${T.pinAudiences} pa ON pa.audience = aud.v)`;
5649
5815
  args.push(jsonList(input.audience));
5650
5816
  }
5817
+ if (input.kind) {
5818
+ filters += ` AND pin.kind = ?`;
5819
+ args.push(input.kind);
5820
+ }
5651
5821
  if (input.pageIds) {
5652
5822
  filters += ` AND pin.pageId IN ${JV}`;
5653
5823
  args.push(jsonList(input.pageIds));
5654
5824
  }
5655
5825
  if (input.excludePageIds?.length) {
5656
- filters += ` AND pin.pageId NOT IN ${JV}`;
5826
+ filters += ` AND (pin.kind <> 'page' OR pin.pageId NOT IN ${JV})`;
5657
5827
  args.push(jsonList(input.excludePageIds));
5658
5828
  }
5659
- if (input.withBody) filters += ` AND REGEXP_LIKE(p.body, '[^[:space:]]')`;
5829
+ if (input.withBody) filters += ` AND (pin.kind <> 'page' OR REGEXP_LIKE(p.body, '[^[:space:]]'))`;
5660
5830
  const from = `FROM ${T.pins} pin JOIN ${T.pages} p ON p.id = pin.pageId WHERE p.deletedAt IS NULL AND ${readable.sql}${filters}`;
5661
5831
  let total;
5662
5832
  if (input.count) total = Number((await this.#query(this.#read, `SELECT COUNT(*) AS n ${from}`, args))[0].n);
@@ -5717,7 +5887,8 @@ var KnowledgeMySQL = class extends KnowledgeStorage {
5717
5887
  contractVersion: 4,
5718
5888
  schemaVersion: 4,
5719
5889
  supportsSchemaInspection: true,
5720
- supportsExplicitReset: true
5890
+ supportsExplicitReset: true,
5891
+ supportsPinKinds: true
5721
5892
  };
5722
5893
  }
5723
5894
  async #inspectPages(client = this.#pool) {
@@ -5773,7 +5944,11 @@ var KnowledgeMySQL = class extends KnowledgeStorage {
5773
5944
  await this.#upgrade();
5774
5945
  }
5775
5946
  async dangerouslyReset() {
5776
- for (const table of [...KNOWLEDGE_RESETTABLE_TABLE_NAMES, "mastra_knowledge_pin_audiences"]) await this.#pool.query(`DROP TABLE IF EXISTS \`${table}\``);
5947
+ for (const table of [
5948
+ ...KNOWLEDGE_RESETTABLE_TABLE_NAMES,
5949
+ "mastra_knowledge_pin_audiences",
5950
+ "mastra_knowledge_page_links"
5951
+ ]) await this.#pool.query(`DROP TABLE IF EXISTS \`${table}\``);
5777
5952
  await this.init();
5778
5953
  }
5779
5954
  materializeScope(input) {
@@ -5791,6 +5966,9 @@ var KnowledgeMySQL = class extends KnowledgeStorage {
5791
5966
  listChildScopes(input) {
5792
5967
  return this.#pages.listChildScopes(input);
5793
5968
  }
5969
+ countChildScopes(input) {
5970
+ return this.#pages.countChildScopes(input);
5971
+ }
5794
5972
  getPage(input) {
5795
5973
  return this.#pages.getPage(input);
5796
5974
  }
@@ -5830,6 +6008,18 @@ var KnowledgeMySQL = class extends KnowledgeStorage {
5830
6008
  countChildPages(input) {
5831
6009
  return this.#pages.countChildPages(input);
5832
6010
  }
6011
+ replacePageBodyLinks(input) {
6012
+ return this.#pages.replacePageBodyLinks(input);
6013
+ }
6014
+ listPageBodyLinkSources(input) {
6015
+ return this.#pages.listPageBodyLinkSources(input);
6016
+ }
6017
+ countPageLinks(input) {
6018
+ return this.#pages.countPageLinks(input);
6019
+ }
6020
+ listPageLinks(input) {
6021
+ return this.#pages.listPageLinks(input);
6022
+ }
5833
6023
  countNotes(input) {
5834
6024
  return this.#pages.countNotes(input);
5835
6025
  }