@superdoc/mcp 1.10.1-next.5 → 1.11.0-next.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.
Files changed (2) hide show
  1. package/dist/index.js +133 -122
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31630,7 +31630,7 @@ var init_host = __esm(() => {
31630
31630
  });
31631
31631
 
31632
31632
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31633
- var SDK_VERSION = "2.23.1-next.5";
31633
+ var SDK_VERSION = "2.24.0-next.1";
31634
31634
 
31635
31635
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31636
31636
  import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
@@ -429301,19 +429301,146 @@ var init_scope2 = __esm(() => {
429301
429301
  init_textbox_story();
429302
429302
  });
429303
429303
 
429304
+ // ../../../v2/document-api-v2-adapter/dist/search/within.js
429305
+ function resolveWithinWindowOrThrow(input) {
429306
+ const within = input.within;
429307
+ if (!within)
429308
+ return null;
429309
+ if (!isSupportedWithinNodeType(within.nodeType)) {
429310
+ throw withinFailure("INVALID_TARGET", `within-node-type-unsupported: ${within.nodeType} is not a supported v2 search scope.`);
429311
+ }
429312
+ const candidates = selectCandidateStories(input.context, input.candidates, within);
429313
+ const matches = candidates.map((candidate2) => resolveWithinWindowInStory(input.context, candidate2.storyId, candidate2.storyByteRange, within)).filter((candidate2) => candidate2 != null);
429314
+ if (matches.length === 0) {
429315
+ throw withinFailure("TARGET_NOT_FOUND", `within-target-not-found: ${within.nodeType} ${within.nodeId} was not found in the requested scope.`);
429316
+ }
429317
+ if (!within.story && matches.length > 1) {
429318
+ throw withinFailure("INVALID_TARGET", `within-target-ambiguous-across-stories: ${within.nodeId} matched multiple stories; specify within.story.`);
429319
+ }
429320
+ return matches[0];
429321
+ }
429322
+ function selectCandidateStories(context, candidates, within) {
429323
+ if (!within.story)
429324
+ return candidates;
429325
+ const resolved = context.resolveFullStoryLocator(within.story);
429326
+ if ("error" in resolved) {
429327
+ throw withinFailure(resolved.error === "not-found" || resolved.error === "unknown-section" ? "TARGET_NOT_FOUND" : "INVALID_TARGET", `within-story-not-found: ${resolved.error}`);
429328
+ }
429329
+ const matching = candidates.filter((candidate2) => candidate2.storyId === resolved.storyId && sameStoryByteRange2(candidate2.storyByteRange, resolved.storyByteRange));
429330
+ if (matching.length === 0) {
429331
+ throw withinFailure("INVALID_TARGET", "within-story-mismatch: within.story does not overlap the requested search scope.");
429332
+ }
429333
+ return matching;
429334
+ }
429335
+ function resolveWithinWindowInStory(context, storyId, storyByteRange, within) {
429336
+ if (PARAGRAPH_LIKE_NODE_TYPES.has(within.nodeType)) {
429337
+ const index2 = readParagraphIndexForStory2(context, storyId);
429338
+ if (!index2)
429339
+ return null;
429340
+ const candidate2 = index2.byParaId(within.nodeId);
429341
+ const entry = candidate2 && isRangeInsideStoryByteRange({ start: candidate2.byteStart, end: candidate2.byteEnd }, storyByteRange) ? candidate2 : null;
429342
+ if (!entry)
429343
+ return null;
429344
+ return {
429345
+ storyId,
429346
+ structuralByteRange: [entry.byteStart, entry.byteEnd],
429347
+ textByteRange: [entry.byteStart, entry.byteEnd],
429348
+ exactBlockId: entry.blockId
429349
+ };
429350
+ }
429351
+ const catalog = readTableCatalogForSession(context.session, storyId);
429352
+ if (!catalog)
429353
+ return null;
429354
+ if (within.nodeType === "table") {
429355
+ const table = catalog.tables.find((candidate2) => candidate2.tableNodeId === within.nodeId && isRangeInsideStoryByteRange({ start: candidate2.tableByteStart, end: candidate2.tableByteEnd }, storyByteRange));
429356
+ if (!table)
429357
+ return null;
429358
+ return {
429359
+ storyId,
429360
+ structuralByteRange: [table.tableByteStart, table.tableByteEnd],
429361
+ textByteRange: [table.tableByteStart, table.tableByteEnd]
429362
+ };
429363
+ }
429364
+ if (within.nodeType === "tableRow") {
429365
+ for (const table of catalog.tables) {
429366
+ const row = table.rows.find((candidate2) => candidate2.rowNodeId === within.nodeId && isRangeInsideStoryByteRange({ start: candidate2.rowByteStart, end: candidate2.rowByteEnd }, storyByteRange));
429367
+ if (!row)
429368
+ continue;
429369
+ return {
429370
+ storyId,
429371
+ structuralByteRange: [row.rowByteStart, row.rowByteEnd],
429372
+ textByteRange: [row.rowByteStart, row.rowByteEnd]
429373
+ };
429374
+ }
429375
+ return null;
429376
+ }
429377
+ if (within.nodeType === "tableCell") {
429378
+ for (const table of catalog.tables) {
429379
+ for (const row of table.rows) {
429380
+ const cell = row.cells.find((candidate2) => candidate2.cellNodeId === within.nodeId && isRangeInsideStoryByteRange({ start: candidate2.cellByteStart, end: candidate2.cellByteEnd }, storyByteRange));
429381
+ if (!cell)
429382
+ continue;
429383
+ return {
429384
+ storyId,
429385
+ structuralByteRange: [cell.cellByteStart, cell.cellByteEnd],
429386
+ textByteRange: [cell.bodyByteStart, cell.bodyByteEnd]
429387
+ };
429388
+ }
429389
+ }
429390
+ }
429391
+ return null;
429392
+ }
429393
+ function readParagraphIndexForStory2(context, storyId) {
429394
+ const main = getSDDocumentSessionInternalParagraphIndex(context.session);
429395
+ if (main?.entries[0]?.storyId === storyId)
429396
+ return main;
429397
+ return getSDDocumentSessionInternalStoryParagraphIndex(context.session, storyId);
429398
+ }
429399
+ function isSupportedWithinNodeType(nodeType) {
429400
+ return PARAGRAPH_LIKE_NODE_TYPES.has(nodeType) || nodeType === "table" || nodeType === "tableRow" || nodeType === "tableCell";
429401
+ }
429402
+ function sameStoryByteRange2(left, right) {
429403
+ if (!left && !right)
429404
+ return true;
429405
+ if (!left || !right)
429406
+ return false;
429407
+ return left[0] === right[0] && left[1] === right[1];
429408
+ }
429409
+ function withinFailure(code2, message) {
429410
+ const error48 = new Error(message);
429411
+ error48.code = code2;
429412
+ return error48;
429413
+ }
429414
+ var PARAGRAPH_LIKE_NODE_TYPES;
429415
+ var init_within = __esm(() => {
429416
+ init_sd_document_session_internal();
429417
+ init_note_story();
429418
+ PARAGRAPH_LIKE_NODE_TYPES = new Set(["paragraph", "heading", "listItem"]);
429419
+ });
429420
+
429304
429421
  // ../../../v2/document-api-v2-adapter/dist/search/tracked-text-search.js
429305
429422
  function resolveTrackedTextSelectorRef(context, where, story) {
429306
- if (where.within) {
429307
- throw new DocumentApiValidationError2("CAPABILITY_UNSUPPORTED", "v2 mutations do not yet support hidden tracked-text selection with `within`.");
429308
- }
429309
429423
  const selector = where.select;
429310
429424
  if (selector.mode === "regex") {
429311
429425
  throw new DocumentApiValidationError2("CAPABILITY_UNSUPPORTED", "regex search is not supported for v2 mutations.");
429312
429426
  }
429313
429427
  const scopes = enumerateSearchScopes(context.session, story ? { kind: "in", locator: story } : { kind: "body" });
429314
- const matches = collectTrackedTextSearchHits({ context, scopes, selector }).map(({ scope, hit, packageRevision, partRevision, storyRevision }) => encodeTrackedHitRef(scope, hit, packageRevision, partRevision, storyRevision));
429428
+ const withinWindow = resolveWithinWindowOrThrow({
429429
+ context,
429430
+ candidates: scopes.map(storySurfaceFromSearchScope),
429431
+ within: where.within
429432
+ });
429433
+ const matches = collectTrackedTextSearchHits({
429434
+ context,
429435
+ scopes: withinWindow ? scopes.filter((scope) => storySurfaceFromSearchScope(scope).storyId === withinWindow.storyId) : scopes,
429436
+ selector,
429437
+ withinByteRange: withinWindow?.textByteRange
429438
+ }).map(({ scope, hit, packageRevision, partRevision, storyRevision }) => encodeTrackedHitRef(scope, hit, packageRevision, partRevision, storyRevision));
429315
429439
  if (matches.length === 0)
429316
429440
  return null;
429441
+ if (where.within) {
429442
+ throw new DocumentApiValidationError2("CAPABILITY_UNSUPPORTED", "v2 mutations do not yet support hidden tracked-text selection with `within`.");
429443
+ }
429317
429444
  if (where.require === "exactlyOne" && matches.length !== 1) {
429318
429445
  throw new DocumentApiValidationError2("AMBIGUOUS_MATCH", "selector matched multiple tracked-text ranges.");
429319
429446
  }
@@ -429525,126 +429652,10 @@ var init_tracked_text_search = __esm(() => {
429525
429652
  init_story_identity();
429526
429653
  init_document_reader();
429527
429654
  init_scope2();
429655
+ init_within();
429528
429656
  TD117 = new TextDecoder;
429529
429657
  });
429530
429658
 
429531
- // ../../../v2/document-api-v2-adapter/dist/search/within.js
429532
- function resolveWithinWindowOrThrow(input) {
429533
- const within = input.within;
429534
- if (!within)
429535
- return null;
429536
- if (!isSupportedWithinNodeType(within.nodeType)) {
429537
- throw withinFailure("INVALID_TARGET", `within-node-type-unsupported: ${within.nodeType} is not a supported v2 search scope.`);
429538
- }
429539
- const candidates = selectCandidateStories(input.context, input.candidates, within);
429540
- const matches = candidates.map((candidate2) => resolveWithinWindowInStory(input.context, candidate2.storyId, candidate2.storyByteRange, within)).filter((candidate2) => candidate2 != null);
429541
- if (matches.length === 0) {
429542
- throw withinFailure("TARGET_NOT_FOUND", `within-target-not-found: ${within.nodeType} ${within.nodeId} was not found in the requested scope.`);
429543
- }
429544
- if (!within.story && matches.length > 1) {
429545
- throw withinFailure("INVALID_TARGET", `within-target-ambiguous-across-stories: ${within.nodeId} matched multiple stories; specify within.story.`);
429546
- }
429547
- return matches[0];
429548
- }
429549
- function selectCandidateStories(context, candidates, within) {
429550
- if (!within.story)
429551
- return candidates;
429552
- const resolved = context.resolveFullStoryLocator(within.story);
429553
- if ("error" in resolved) {
429554
- throw withinFailure(resolved.error === "not-found" || resolved.error === "unknown-section" ? "TARGET_NOT_FOUND" : "INVALID_TARGET", `within-story-not-found: ${resolved.error}`);
429555
- }
429556
- const matching = candidates.filter((candidate2) => candidate2.storyId === resolved.storyId && sameStoryByteRange2(candidate2.storyByteRange, resolved.storyByteRange));
429557
- if (matching.length === 0) {
429558
- throw withinFailure("INVALID_TARGET", "within-story-mismatch: within.story does not overlap the requested search scope.");
429559
- }
429560
- return matching;
429561
- }
429562
- function resolveWithinWindowInStory(context, storyId, storyByteRange, within) {
429563
- if (PARAGRAPH_LIKE_NODE_TYPES.has(within.nodeType)) {
429564
- const index2 = readParagraphIndexForStory2(context, storyId);
429565
- if (!index2)
429566
- return null;
429567
- const candidate2 = index2.byParaId(within.nodeId);
429568
- const entry = candidate2 && isRangeInsideStoryByteRange({ start: candidate2.byteStart, end: candidate2.byteEnd }, storyByteRange) ? candidate2 : null;
429569
- if (!entry)
429570
- return null;
429571
- return {
429572
- storyId,
429573
- structuralByteRange: [entry.byteStart, entry.byteEnd],
429574
- textByteRange: [entry.byteStart, entry.byteEnd],
429575
- exactBlockId: entry.blockId
429576
- };
429577
- }
429578
- const catalog = readTableCatalogForSession(context.session, storyId);
429579
- if (!catalog)
429580
- return null;
429581
- if (within.nodeType === "table") {
429582
- const table = catalog.tables.find((candidate2) => candidate2.tableNodeId === within.nodeId && isRangeInsideStoryByteRange({ start: candidate2.tableByteStart, end: candidate2.tableByteEnd }, storyByteRange));
429583
- if (!table)
429584
- return null;
429585
- return {
429586
- storyId,
429587
- structuralByteRange: [table.tableByteStart, table.tableByteEnd],
429588
- textByteRange: [table.tableByteStart, table.tableByteEnd]
429589
- };
429590
- }
429591
- if (within.nodeType === "tableRow") {
429592
- for (const table of catalog.tables) {
429593
- const row = table.rows.find((candidate2) => candidate2.rowNodeId === within.nodeId && isRangeInsideStoryByteRange({ start: candidate2.rowByteStart, end: candidate2.rowByteEnd }, storyByteRange));
429594
- if (!row)
429595
- continue;
429596
- return {
429597
- storyId,
429598
- structuralByteRange: [row.rowByteStart, row.rowByteEnd],
429599
- textByteRange: [row.rowByteStart, row.rowByteEnd]
429600
- };
429601
- }
429602
- return null;
429603
- }
429604
- if (within.nodeType === "tableCell") {
429605
- for (const table of catalog.tables) {
429606
- for (const row of table.rows) {
429607
- const cell = row.cells.find((candidate2) => candidate2.cellNodeId === within.nodeId && isRangeInsideStoryByteRange({ start: candidate2.cellByteStart, end: candidate2.cellByteEnd }, storyByteRange));
429608
- if (!cell)
429609
- continue;
429610
- return {
429611
- storyId,
429612
- structuralByteRange: [cell.cellByteStart, cell.cellByteEnd],
429613
- textByteRange: [cell.bodyByteStart, cell.bodyByteEnd]
429614
- };
429615
- }
429616
- }
429617
- }
429618
- return null;
429619
- }
429620
- function readParagraphIndexForStory2(context, storyId) {
429621
- const main = getSDDocumentSessionInternalParagraphIndex(context.session);
429622
- if (main?.entries[0]?.storyId === storyId)
429623
- return main;
429624
- return getSDDocumentSessionInternalStoryParagraphIndex(context.session, storyId);
429625
- }
429626
- function isSupportedWithinNodeType(nodeType) {
429627
- return PARAGRAPH_LIKE_NODE_TYPES.has(nodeType) || nodeType === "table" || nodeType === "tableRow" || nodeType === "tableCell";
429628
- }
429629
- function sameStoryByteRange2(left, right) {
429630
- if (!left && !right)
429631
- return true;
429632
- if (!left || !right)
429633
- return false;
429634
- return left[0] === right[0] && left[1] === right[1];
429635
- }
429636
- function withinFailure(code2, message) {
429637
- const error48 = new Error(message);
429638
- error48.code = code2;
429639
- return error48;
429640
- }
429641
- var PARAGRAPH_LIKE_NODE_TYPES;
429642
- var init_within = __esm(() => {
429643
- init_sd_document_session_internal();
429644
- init_note_story();
429645
- PARAGRAPH_LIKE_NODE_TYPES = new Set(["paragraph", "heading", "listItem"]);
429646
- });
429647
-
429648
429659
  // ../../../v2/document-api-v2-adapter/dist/search/collect-text-page.js
429649
429660
  function collectTextSearchPage(input) {
429650
429661
  const withinWindow = resolveWithinWindowOrThrow({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.10.1-next.5",
3
+ "version": "1.11.0-next.1",
4
4
  "description": "Model Context Protocol server for SuperDoc, giving an AI agent tools to read and edit .docx files.",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0",
@@ -24,13 +24,13 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@modelcontextprotocol/sdk": "^1.26.0",
27
- "@superdoc/sdk": "2.23.1-next.5",
27
+ "@superdoc/sdk": "2.24.0-next.1",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.26.1-next.5",
33
- "@superdoc/docx-engine": "0.25.1-next.5",
32
+ "superdoc": "2.27.0-next.1",
33
+ "@superdoc/docx-engine": "0.26.0-next.1",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",