@superdoc/mcp 1.0.1-next.5 → 1.0.1-next.6

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 +100 -19
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31314,7 +31314,7 @@ var init_host = __esm(() => {
31314
31314
  });
31315
31315
 
31316
31316
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31317
- var SDK_VERSION = "2.13.1-next.5";
31317
+ var SDK_VERSION = "2.13.1-next.6";
31318
31318
 
31319
31319
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31320
31320
  import { chmodSync, existsSync } from "node:fs";
@@ -421919,13 +421919,21 @@ function mirrorStoryBlocksFromSession(input) {
421919
421919
  });
421920
421920
  }
421921
421921
  syncBlockPayloads(input.doc, payloads);
421922
- } else if (findBlockMap(input.doc, source.first.paraId) && findBlockMap(input.doc, source.second.paraId)) {
421923
- mergeBlocks({
421924
- doc: input.doc,
421925
- firstBlockId: source.first.paraId,
421926
- secondBlockId: source.second.paraId,
421927
- origin: STORY_SURFACE_BACKEND_ORIGIN
421928
- });
421922
+ } else {
421923
+ const physicallyMerged = input.prepared.semanticDelta.invalidatedRefs.some((ref5) => ref5.kind === "block" && ref5.storyId === input.storyId && ref5.nodeId === source.second.paraId);
421924
+ if (physicallyMerged) {
421925
+ if (findBlockMap(input.doc, source.first.paraId) && findBlockMap(input.doc, source.second.paraId)) {
421926
+ mergeBlocks({
421927
+ doc: input.doc,
421928
+ firstBlockId: source.first.paraId,
421929
+ secondBlockId: source.second.paraId,
421930
+ origin: STORY_SURFACE_BACKEND_ORIGIN
421931
+ });
421932
+ }
421933
+ syncBlocksFromSession(input.session, input.storyId, input.doc, [source.first.paraId]);
421934
+ } else {
421935
+ syncBlocksFromSession(input.session, input.storyId, input.doc, input.extension.targetBlockIds);
421936
+ }
421929
421937
  }
421930
421938
  writeParagraphMembershipTableOverlaysFromSession(input.session, input.prepared, input.storyId, input.doc, [source.first.paraId, source.second.paraId], "paragraph.merge");
421931
421939
  return;
@@ -423027,6 +423035,14 @@ var init_story_surface_session_sync = __esm(() => {
423027
423035
  });
423028
423036
 
423029
423037
  // ../../../v2/collaboration-v2/dist/backend/story-surface-execution-backend.js
423038
+ function trackedStoryTextRequiresMergedCarrierSync(validation) {
423039
+ if (!validation || validation.source.changeMode !== "tracked")
423040
+ return false;
423041
+ const authorsText = validation.trackedInsert != null || validation.trackedInsertContinuation === true || (validation.trackedRefinement?.metadata.insertedText.length ?? 0) > 0;
423042
+ if (!authorsText && validation.trackedRefinement?.usesMergedCarrier !== true)
423043
+ return false;
423044
+ return snapshotStoryShard(validation.doc).blocks.some((block) => block.blockId === validation.target.blockId && block.mergedTailBlockIds.length > 0);
423045
+ }
423030
423046
  function createStorySurfaceExecutionBackend(options) {
423031
423047
  const delegate = options.delegate;
423032
423048
  return {
@@ -423215,7 +423231,8 @@ function runFamilyMirror(prepared, extension2, options, directStoryText, tracked
423215
423231
  };
423216
423232
  }
423217
423233
  if (extension2.family === "storyText") {
423218
- if (extension2.historyReplay || extension2.resyncFromSession || extension2.sessionSync) {
423234
+ const mergedCarrierSync = trackedStoryTextRequiresMergedCarrierSync(directStoryText);
423235
+ if (extension2.historyReplay || extension2.resyncFromSession || extension2.sessionSync || mergedCarrierSync) {
423219
423236
  if (!options.session) {
423220
423237
  return {
423221
423238
  mirrored: false,
@@ -423229,7 +423246,7 @@ function runFamilyMirror(prepared, extension2, options, directStoryText, tracked
423229
423246
  const sessionSync = mirrorStorySurfaceFromSession({
423230
423247
  session: options.session,
423231
423248
  prepared,
423232
- extension: extension2,
423249
+ extension: mergedCarrierSync && !extension2.sessionSync ? { ...extension2, sessionSync: { reason: "structural-inline-edit" } } : extension2,
423233
423250
  storyIds: storyIdsRequiringShards(prepared, extension2),
423234
423251
  resolveStoryShard: options.resolveStoryShard
423235
423252
  });
@@ -424050,6 +424067,9 @@ function admitPreparedStorySurfaceMutation(prepared, options) {
424050
424067
  return validateStoryTextSessionSync(prepared, extension2, options);
424051
424068
  }
424052
424069
  const direct = validateDirectStoryText(prepared, extension2, options);
424070
+ if (direct.ok && trackedStoryTextRequiresMergedCarrierSync(direct) && !options.session) {
424071
+ return { ok: false, message: "tracked text across merged carriers requires an authoritative session" };
424072
+ }
424053
424073
  return direct.ok ? { ok: true, directStoryText: direct } : { ok: false, message: direct.failureReason };
424054
424074
  }
424055
424075
  const storyIds = [...new Set(prepared.resolvedTargets.stories.map((storyId) => String(storyId)))];
@@ -424488,9 +424508,18 @@ function validateDirectStoryText(prepared, extension2, options) {
424488
424508
  let validatedTrackedRefinement;
424489
424509
  if (trackedRefinement?.ok) {
424490
424510
  const live = validateTrackedTextRefinementTarget(hydratedBlock, trackedRefinement.metadata);
424491
- if (!live.ok)
424492
- return { ok: false, failureReason: live.failureReason };
424493
- validatedTrackedRefinement = { metadata: trackedRefinement.metadata, span: live.span };
424511
+ if (live.ok) {
424512
+ validatedTrackedRefinement = { metadata: trackedRefinement.metadata, span: live.span };
424513
+ } else {
424514
+ const merged = validateMergedCarrierTrackedTextRefinementTarget(doc2, source.on.startBlockId, trackedRefinement.metadata);
424515
+ if (!merged.ok)
424516
+ return { ok: false, failureReason: live.failureReason };
424517
+ validatedTrackedRefinement = {
424518
+ metadata: trackedRefinement.metadata,
424519
+ span: merged.span,
424520
+ usesMergedCarrier: true
424521
+ };
424522
+ }
424494
424523
  } else {
424495
424524
  const mutationStart = trackedEdit?.ok ? trackedEdit.trackedEdit.startOffset : source.on.startOffset;
424496
424525
  const mutationEnd = trackedEdit?.ok ? trackedEdit.trackedEdit.endOffset : source.on.endOffset;
@@ -424583,6 +424612,58 @@ function validateTrackedTextRefinementTarget(block, metadata2) {
424583
424612
  }
424584
424613
  return { ok: true, span };
424585
424614
  }
424615
+ function validateMergedCarrierTrackedTextRefinementTarget(doc2, blockId, metadata2) {
424616
+ const block = snapshotStoryShard(doc2).blocks.find((candidate2) => candidate2.blockId === blockId);
424617
+ if (!block || block.mergedTailBlockIds.length === 0) {
424618
+ return { ok: false, failureReason: "tracked text refinement has no merged paragraph carriers" };
424619
+ }
424620
+ const starts = block.atoms.map((atom, index2) => ({ atom, index: index2 })).filter(({ atom }) => atom.kind === INLINE_ATOM_KIND.trackedWrapper && atom.meta.wrapper === "ins" && String(atom.meta.rsid ?? "") === metadata2.insertionRsid && atom.meta.position === "start");
424621
+ const ends = block.atoms.map((atom, index2) => ({ atom, index: index2 })).filter(({ atom }) => atom.kind === INLINE_ATOM_KIND.trackedWrapper && atom.meta.wrapper === "ins" && String(atom.meta.rsid ?? "") === metadata2.insertionRsid && atom.meta.position === "end");
424622
+ const candidates = starts.flatMap((start) => {
424623
+ const end = ends.find((candidate2) => candidate2.index > start.index);
424624
+ if (!end)
424625
+ return [];
424626
+ const span2 = {
424627
+ trackedKind: "ins",
424628
+ blockId,
424629
+ startOffset: start.atom.visibleOffset,
424630
+ endOffset: end.atom.visibleOffset,
424631
+ sourceStartOffset: start.atom.visibleOffset,
424632
+ sourceEndOffset: end.atom.visibleOffset,
424633
+ startAtomIndex: start.index,
424634
+ startAtomId: start.atom.id,
424635
+ endAtomId: end.atom.id,
424636
+ preservedAtomIds: [],
424637
+ containedAtomIds: block.atoms.slice(start.index + 1, end.index).map((atom) => atom.id),
424638
+ deletedRuns: [],
424639
+ deletedSegments: []
424640
+ };
424641
+ return metadata2.liveTextRange.startOffset >= span2.startOffset && metadata2.liveTextRange.endOffset <= span2.endOffset ? [span2] : [];
424642
+ });
424643
+ if (candidates.length !== 1) {
424644
+ return {
424645
+ ok: false,
424646
+ failureReason: `tracked text refinement could not resolve insertion ${metadata2.insertionRsid}`
424647
+ };
424648
+ }
424649
+ const span = candidates[0];
424650
+ const resultLength = span.endOffset - span.startOffset - (metadata2.liveTextRange.endOffset - metadata2.liveTextRange.startOffset) + metadata2.insertedText.length;
424651
+ if (resultLength < 0 || metadata2.removesInsertion !== (resultLength === 0)) {
424652
+ return { ok: false, failureReason: "tracked text refinement removal metadata does not match live insertion" };
424653
+ }
424654
+ if (span.containedAtomIds.length > 0) {
424655
+ return {
424656
+ ok: false,
424657
+ failureReason: "tracked text refinement intersects an unsupported insertion carrier"
424658
+ };
424659
+ }
424660
+ const ownCarrierIds = new Set([span.startAtomId, span.endAtomId]);
424661
+ const unsafeCarrier = block.atoms.find((atom) => !ownCarrierIds.has(atom.id) && atom.visibleOffset > metadata2.liveTextRange.startOffset && atom.visibleOffset < metadata2.liveTextRange.endOffset);
424662
+ if (unsafeCarrier) {
424663
+ return { ok: false, failureReason: `tracked text refinement intersects ${unsafeCarrier.kind} atom` };
424664
+ }
424665
+ return { ok: true, span };
424666
+ }
424586
424667
  function validateTrackedTextInsert(source, extension2) {
424587
424668
  if (extension2.changeMode !== "tracked") {
424588
424669
  return { ok: false, failureReason: "tracked editText source requires tracked storySurface metadata" };
@@ -424681,7 +424762,7 @@ function mirrorTrackedTextInsert(input) {
424681
424762
  wrapper: "ins",
424682
424763
  position: "start",
424683
424764
  rsid: input.trackedInsert.rsid,
424684
- wId: input.trackedInsert.wId,
424765
+ wId: String(input.trackedInsert.wId),
424685
424766
  author: input.trackedInsert.author,
424686
424767
  authorEmail: author.email ?? null,
424687
424768
  date: input.trackedInsert.date
@@ -424695,7 +424776,7 @@ function mirrorTrackedTextInsert(input) {
424695
424776
  wrapper: "ins",
424696
424777
  position: "end",
424697
424778
  rsid: input.trackedInsert.rsid,
424698
- wId: input.trackedInsert.wId,
424779
+ wId: String(input.trackedInsert.wId),
424699
424780
  author: input.trackedInsert.author,
424700
424781
  authorEmail: author.email ?? null,
424701
424782
  date: input.trackedInsert.date
@@ -424878,7 +424959,7 @@ function mirrorTrackedTextEdit(input) {
424878
424959
  wrapper: "del",
424879
424960
  position: "start",
424880
424961
  rsid: input.trackedEdit.deletion.rsid,
424881
- wId: input.trackedEdit.deletion.wId,
424962
+ wId: String(input.trackedEdit.deletion.wId),
424882
424963
  author: input.trackedEdit.deletion.author,
424883
424964
  authorEmail: deletionAuthor.email ?? null,
424884
424965
  date: input.trackedEdit.deletion.date
@@ -424898,7 +424979,7 @@ function mirrorTrackedTextEdit(input) {
424898
424979
  wrapper: "del",
424899
424980
  position: "end",
424900
424981
  rsid: input.trackedEdit.deletion.rsid,
424901
- wId: input.trackedEdit.deletion.wId,
424982
+ wId: String(input.trackedEdit.deletion.wId),
424902
424983
  author: input.trackedEdit.deletion.author,
424903
424984
  authorEmail: deletionAuthor.email ?? null,
424904
424985
  date: input.trackedEdit.deletion.date
@@ -424918,7 +424999,7 @@ function mirrorTrackedTextEdit(input) {
424918
424999
  wrapper: "ins",
424919
425000
  position: "start",
424920
425001
  rsid: insertion.rsid,
424921
- wId: insertion.wId,
425002
+ wId: String(insertion.wId),
424922
425003
  author: insertion.author,
424923
425004
  authorEmail: insertionAuthor.email ?? null,
424924
425005
  date: insertion.date
@@ -424931,7 +425012,7 @@ function mirrorTrackedTextEdit(input) {
424931
425012
  wrapper: "ins",
424932
425013
  position: "end",
424933
425014
  rsid: insertion.rsid,
424934
- wId: insertion.wId,
425015
+ wId: String(insertion.wId),
424935
425016
  author: insertion.author,
424936
425017
  authorEmail: insertionAuthor.email ?? null,
424937
425018
  date: insertion.date
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.0.1-next.5",
3
+ "version": "1.0.1-next.6",
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.13.1-next.5",
27
+ "@superdoc/sdk": "2.13.1-next.6",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.16.1-next.5",
33
- "@superdoc/docx-engine": "0.15.1-next.4",
32
+ "superdoc": "2.16.1-next.6",
33
+ "@superdoc/docx-engine": "0.15.1-next.5",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",