@superdoc/mcp 1.3.0-next.10 → 1.3.0-next.12

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 +127 -29
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31318,7 +31318,7 @@ var init_host = __esm(() => {
31318
31318
  });
31319
31319
 
31320
31320
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31321
- var SDK_VERSION = "2.16.0-next.10";
31321
+ var SDK_VERSION = "2.16.0-next.12";
31322
31322
 
31323
31323
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31324
31324
  import { chmodSync, existsSync } from "node:fs";
@@ -221816,7 +221816,7 @@ function runCompareApplyCommit(input) {
221816
221816
  if (input.options.expectedPackageRevision && input.options.expectedPackageRevision !== state.packageRevision) {
221817
221817
  return rejected14(txId, "base-revision-drift");
221818
221818
  }
221819
- if (input.readCurrentPackageBinding() !== op.planBinding) {
221819
+ if (input.readCurrentComparePlanBinding() !== op.planBinding) {
221820
221820
  return rejected14(txId, "base-revision-drift");
221821
221821
  }
221822
221822
  const changeMode = op.changeMode;
@@ -228689,13 +228689,14 @@ function changeIlvl(input, delta) {
228689
228689
  const trackedFormatting = buildTrackedListFormattingMetadata(input, op.target.storyId);
228690
228690
  if (trackedFormatting && "reason" in trackedFormatting)
228691
228691
  return rejected15(input.txId, trackedFormatting.reason);
228692
- const { target, bytes, paraXml, plan } = prepared;
228692
+ const { target, bytes, paraXml, plan, paragraphStyleId } = prepared;
228693
228693
  return commitParagraphNumPrRewrite({
228694
228694
  input,
228695
228695
  target,
228696
228696
  bytes,
228697
228697
  paraXml,
228698
228698
  numPr: { numId: plan.numId, ilvl: plan.ilvl },
228699
+ paragraphStyleId,
228699
228700
  trackedFormatting
228700
228701
  });
228701
228702
  }
@@ -228716,10 +228717,30 @@ function prepareListLevelChange(state, op, delta, author) {
228716
228717
  });
228717
228718
  if (!structural.ok)
228718
228719
  return structural;
228719
- const plan = decideListLevelChange(resolveEffectiveListReferenceForState(state, paraXml), delta);
228720
+ const effective = resolveEffectiveListReferenceForState(state, paraXml);
228721
+ const plan = decideListLevelChange(effective, delta);
228720
228722
  if (plan.kind === "reject")
228721
228723
  return { ok: false, reason: plan.reason };
228722
- return { ok: true, target, bytes, paraXml, plan };
228724
+ const targetStyle = resolveTargetLevelParagraphStyle(state, effective, plan.ilvl);
228725
+ if (!targetStyle.ok)
228726
+ return targetStyle;
228727
+ return { ok: true, target, bytes, paraXml, plan, paragraphStyleId: targetStyle.paragraphStyleId };
228728
+ }
228729
+ function resolveTargetLevelParagraphStyle(state, effective, ilvl) {
228730
+ if (effective.definition.status !== "resolved")
228731
+ return { ok: false, reason: effectiveListRejectionReason(effective) };
228732
+ const level = resolveNumberingLevel(effective.definition, ilvl);
228733
+ if (!level)
228734
+ return { ok: false, reason: "list-numbering-level-missing" };
228735
+ const paragraphStyleId = level.level.paragraphStyleId;
228736
+ if (paragraphStyleId === null)
228737
+ return { ok: true, paragraphStyleId: null };
228738
+ const styles = getEffectiveListResolverContextForState(state);
228739
+ const record3 = styles.styleIndex.get(paragraphStyleId);
228740
+ if (styles.stylesStatus !== "available" || !record3 || !isParagraphStyleRecord(record3) || record3.listCarrierStatus === "malformed") {
228741
+ return { ok: false, reason: "list-numbering-link-invalid" };
228742
+ }
228743
+ return { ok: true, paragraphStyleId };
228723
228744
  }
228724
228745
  function validateListLevelChange(state, op, author) {
228725
228746
  const prepared = prepareListLevelChange(state, op, op.kind === "listIndent" ? 1 : -1, author);
@@ -228839,8 +228860,11 @@ function changeIlvlRange(input, delta) {
228839
228860
  });
228840
228861
  continue;
228841
228862
  }
228863
+ const targetStyle = resolveTargetLevelParagraphStyle(input.state, ref3, nextIlvl);
228864
+ if (!targetStyle.ok)
228865
+ return rejected15(input.txId, targetStyle.reason);
228842
228866
  const trackedFormatting = trackedAllocator && !("reason" in trackedAllocator) ? trackedAllocator.mint() : undefined;
228843
- const rewrite = trackedFormatting ? rewriteParagraphNumPrTracked(paraXml, { numId: ref3.authoredNumId, ilvl: nextIlvl }, trackedFormatting) : rewriteParagraphNumPr(paraXml, { numId: ref3.authoredNumId, ilvl: nextIlvl });
228867
+ const rewrite = trackedFormatting ? rewriteParagraphNumPrTracked(paraXml, { numId: ref3.authoredNumId, ilvl: nextIlvl }, trackedFormatting, targetStyle.paragraphStyleId) : rewriteParagraphNumPr(paraXml, { numId: ref3.authoredNumId, ilvl: nextIlvl }, targetStyle.paragraphStyleId);
228844
228868
  if (!rewrite.ok)
228845
228869
  return rejected15(input.txId, rewrite.reason);
228846
228870
  items.push({
@@ -229097,13 +229121,13 @@ function decodeByteRange2(bytes, startByte, endByte) {
229097
229121
  return "";
229098
229122
  return TD60.decode(bytes.subarray(startByte, endByte));
229099
229123
  }
229100
- function rewriteParagraphNumPr(paraXml, numPr) {
229124
+ function rewriteParagraphNumPr(paraXml, numPr, paragraphStyleId) {
229101
229125
  const selfClosingParaMatch = paraXml.match(/^<((?:[\w.-]+:)?p)\b([^>]*)\/>$/);
229102
229126
  if (selfClosingParaMatch) {
229103
229127
  const paragraphQName = selfClosingParaMatch[1];
229104
229128
  const attrs = selfClosingParaMatch[2] ?? "";
229105
229129
  const names2 = wordNamesForQName(paragraphQName);
229106
- const listParagraphStyleXml = renderParagraphStyle(names2, "ListParagraph");
229130
+ const listParagraphStyleXml = renderParagraphStyle(names2, paragraphStyleId ?? "ListParagraph");
229107
229131
  const numPrXml2 = renderParagraphNumPr(names2, numPr);
229108
229132
  return {
229109
229133
  ok: true,
@@ -229121,7 +229145,7 @@ function rewriteParagraphNumPr(paraXml, numPr) {
229121
229145
  const pPrName = names2.element("pPr");
229122
229146
  return {
229123
229147
  ok: true,
229124
- xml: `${openTag}<${pPrName}>${renderParagraphStyle(names2, "ListParagraph")}` + `${renderParagraphNumPr(names2, numPr)}</${pPrName}>${inner}`
229148
+ xml: `${openTag}<${pPrName}>${renderParagraphStyle(names2, paragraphStyleId ?? "ListParagraph")}` + `${renderParagraphNumPr(names2, numPr)}</${pPrName}>${inner}`
229125
229149
  };
229126
229150
  }
229127
229151
  const pPrQName = /^<((?:[\w.-]+:)?pPr)\b/.exec(split.pPr)?.[1];
@@ -229131,7 +229155,7 @@ function rewriteParagraphNumPr(paraXml, numPr) {
229131
229155
  const children = readLivePPrChildren(split.pPr);
229132
229156
  if (!children)
229133
229157
  return { ok: false, reason: "list-target-not-found" };
229134
- const withStyle = children.some((child) => child.localName === "pStyle") ? split.pPr : rewriteLivePPrChild(split.pPr, "pStyle", renderParagraphStyle(names, "ListParagraph"), { ordered: true });
229158
+ const withStyle = paragraphStyleId === null || paragraphStyleId === undefined ? children.some((child) => child.localName === "pStyle") ? split.pPr : rewriteLivePPrChild(split.pPr, "pStyle", renderParagraphStyle(names, "ListParagraph"), { ordered: true }) : rewriteLivePPrChild(split.pPr, "pStyle", renderParagraphStyle(names, paragraphStyleId), { ordered: true });
229135
229159
  if (withStyle === null)
229136
229160
  return { ok: false, reason: "list-target-not-found" };
229137
229161
  const numPrXml = renderParagraphNumPr(names, numPr);
@@ -229229,7 +229253,7 @@ function readLivePPrChildren(pPrXml) {
229229
229253
  return children;
229230
229254
  }
229231
229255
  function commitParagraphNumPrRewrite(args) {
229232
- const rewrite = args.trackedFormatting ? rewriteParagraphNumPrTracked(args.paraXml, args.numPr, args.trackedFormatting) : rewriteParagraphNumPr(args.paraXml, args.numPr);
229256
+ const rewrite = args.trackedFormatting ? rewriteParagraphNumPrTracked(args.paraXml, args.numPr, args.trackedFormatting, args.paragraphStyleId) : rewriteParagraphNumPr(args.paraXml, args.numPr, args.paragraphStyleId);
229233
229257
  if (!rewrite.ok)
229234
229258
  return rejected15(args.input.txId, rewrite.reason);
229235
229259
  return commitParagraphRewrite({
@@ -229330,8 +229354,8 @@ function buildTrackedListFormattingAllocator(input, storyId) {
229330
229354
  }
229331
229355
  };
229332
229356
  }
229333
- function rewriteParagraphNumPrTracked(paraXml, numPr, tracked) {
229334
- const direct = rewriteParagraphNumPr(paraXml, numPr);
229357
+ function rewriteParagraphNumPrTracked(paraXml, numPr, tracked, paragraphStyleId) {
229358
+ const direct = rewriteParagraphNumPr(paraXml, numPr, paragraphStyleId);
229335
229359
  if (!direct.ok)
229336
229360
  return direct;
229337
229361
  return wrapParagraphTrackedChange(direct.xml, paraXml, tracked);
@@ -239497,13 +239521,13 @@ function allocateTransactionId() {
239497
239521
  return `tx-${time3}-${nextTx.toString(36)}-${random}`;
239498
239522
  }
239499
239523
  function createSDTransactionContext(input) {
239500
- return new TxContext(input.state, input.author, input.readCurrentPackageBinding, input.options, input.onCommitted);
239524
+ return new TxContext(input.state, input.author, input.readCurrentComparePlanBinding, input.options, input.onCommitted);
239501
239525
  }
239502
239526
 
239503
239527
  class TxContext {
239504
- constructor(state, author, readCurrentPackageBinding, options = {}, onCommitted) {
239528
+ constructor(state, author, readCurrentComparePlanBinding, options = {}, onCommitted) {
239505
239529
  this.state = state;
239506
- this.readCurrentPackageBinding = readCurrentPackageBinding;
239530
+ this.readCurrentComparePlanBinding = readCurrentComparePlanBinding;
239507
239531
  this.options = options;
239508
239532
  this.onCommitted = onCommitted;
239509
239533
  this.txId = allocateTransactionId();
@@ -240102,7 +240126,7 @@ class TxContext {
240102
240126
  author: this.author,
240103
240127
  authorOverride: this.authorOverride,
240104
240128
  txTimestamp: this.txTimestamp,
240105
- readCurrentPackageBinding: this.readCurrentPackageBinding,
240129
+ readCurrentComparePlanBinding: this.readCurrentComparePlanBinding,
240106
240130
  options: this.options,
240107
240131
  op,
240108
240132
  pushHistory: (entry) => this.pushHistoryEntry(entry),
@@ -247981,7 +248005,12 @@ var init_comment_export_normalization = __esm(() => {
247981
248005
 
247982
248006
  // ../../../v2/editor-core/dist/document/transactions/note-export-hygiene.js
247983
248007
  function planNoteExportHygiene(state) {
247984
- const noteFree = isNoteFreePackage(state);
248008
+ return buildNoteExportHygienePlan(state, isNoteFreePackage(state));
248009
+ }
248010
+ function planNoteExportHygieneForFingerprint(state) {
248011
+ return buildNoteExportHygienePlan(state, isNoteFreePackageForFingerprint(state));
248012
+ }
248013
+ function buildNoteExportHygienePlan(state, noteFree) {
247985
248014
  const removals = new Set;
247986
248015
  if (noteFree) {
247987
248016
  for (const partUri of [FOOTNOTES_PART_URI2, ENDNOTES_PART_URI2]) {
@@ -248011,6 +248040,12 @@ function transformXmlBytes(bytes, transform2) {
248011
248040
  return next === xml ? bytes : TE41.encode(next);
248012
248041
  }
248013
248042
  function isNoteFreePackage(state) {
248043
+ return isNoteFreePackageCore(state, { pruneUnconfiguredOrphanSidecar: state.renderCommitSequence !== 0 });
248044
+ }
248045
+ function isNoteFreePackageForFingerprint(state) {
248046
+ return isNoteFreePackageCore(state, { pruneUnconfiguredOrphanSidecar: true });
248047
+ }
248048
+ function isNoteFreePackageCore(state, options) {
248014
248049
  for (const partUri of listStoryPartUris2(state)) {
248015
248050
  const bytes = state.packageBytes.get(partUri);
248016
248051
  if (!bytes)
@@ -248032,7 +248067,7 @@ function isNoteFreePackage(state) {
248032
248067
  if (hasConfiguredNoteSettings(settingsXml))
248033
248068
  return false;
248034
248069
  const hasNoteSidecar = state.packageBytes.has(FOOTNOTES_PART_URI2) || state.packageBytes.has(ENDNOTES_PART_URI2);
248035
- if (state.renderCommitSequence === 0 && hasNoteSidecar && !/<w:(?:footnotePr|endnotePr)\b/.test(settingsXml))
248070
+ if (!options.pruneUnconfiguredOrphanSidecar && hasNoteSidecar && !/<w:(?:footnotePr|endnotePr)\b/.test(settingsXml))
248036
248071
  return false;
248037
248072
  return true;
248038
248073
  }
@@ -249150,6 +249185,45 @@ function computeSDDocumentSessionInternalPackageBinding(session) {
249150
249185
  const payload = PACKAGE_BINDING_TEXT_ENCODER.encode(JSON.stringify({ version: "sd-package-binding/v1", parts }));
249151
249186
  return `sha256:${sha256HexSync(payload)}`;
249152
249187
  }
249188
+ function computeSDDocumentSessionInternalSemanticPackageBinding(session) {
249189
+ const internal = INTERNALS.get(session);
249190
+ if (!internal)
249191
+ throw new Error("internal: unknown SDDocumentSession instance");
249192
+ const noteHygienePlan = planNoteExportHygieneForFingerprint(internal.state);
249193
+ const partUris = new Set([
249194
+ ...internal.state.parts.keys(),
249195
+ ...internal.state.packageBytes.keys()
249196
+ ]);
249197
+ const parts = [...partUris].filter((partUri) => !noteHygienePlan.removals.has(partUri)).map((partUri) => {
249198
+ const descriptor = internal.state.parts.get(partUri)?.descriptor ?? null;
249199
+ const sourcePartSize = internal.openResult.packageOpen.pkg.parts.get(partUri)?.uncompressedSize;
249200
+ const unchangedFromSource = descriptor?.revision === internal.state.sourcePartRevisions.get(partUri);
249201
+ const oversizedUnchangedSource = unchangedFromSource && sourcePartSize !== undefined && sourcePartSize > 64 * 1024 * 1024;
249202
+ const rawBytes = oversizedUnchangedSource ? null : descriptor ? getSDDocumentSessionInternalCapturePartBytes(session, partUri, unchangedFromSource ? 64 * 1024 * 1024 : Number.MAX_SAFE_INTEGER) : internal.state.packageBytes.get(partUri) ?? null;
249203
+ const bytes = rawBytes ? canonicalizePartBytesForSemanticBinding(partUri, rawBytes, noteHygienePlan) : null;
249204
+ return {
249205
+ partUri,
249206
+ contentType: descriptor?.contentType ?? null,
249207
+ kind: descriptor?.kind ?? null,
249208
+ byteLength: bytes?.length ?? null,
249209
+ bytesSha256: bytes ? sha256HexSync(bytes) : null
249210
+ };
249211
+ }).sort((a, b) => a.partUri.localeCompare(b.partUri));
249212
+ const payload = PACKAGE_BINDING_TEXT_ENCODER.encode(JSON.stringify({ version: "sd-package-binding-semantic/v1", parts }));
249213
+ return `sha256-semantic:${sha256HexSync(payload)}`;
249214
+ }
249215
+ function canonicalizePartBytesForSemanticBinding(partUri, bytes, noteHygienePlan) {
249216
+ const noteProjected = noteHygienePlan.transformPartBytes(partUri, bytes);
249217
+ const wordXmlNormalized = normalizeWordXmlForSave(partUri, noteProjected);
249218
+ if (!WORD_XML_PART_RE.test(partUri))
249219
+ return wordXmlNormalized;
249220
+ const xml = SAVE_XML_DECODER.decode(wordXmlNormalized);
249221
+ const stripped = stripSessionIssuedTrackedChangeIdsForFingerprint(xml);
249222
+ return stripped === xml ? wordXmlNormalized : SAVE_XML_ENCODER.encode(stripped);
249223
+ }
249224
+ function stripSessionIssuedTrackedChangeIdsForFingerprint(xml) {
249225
+ return xml.replace(RSID_ATTR_FOR_FINGERPRINT_RE, "").replace(SIMPLE_TRACKED_CHANGE_WRAPPER_OPEN_RE, (tag) => tag.replace(WRAPPER_ID_ATTR_FOR_FINGERPRINT_RE, ""));
249226
+ }
249153
249227
  function markSDDocumentSessionInternalExactPackageSave(session, binding) {
249154
249228
  var _a3;
249155
249229
  const internal = INTERNALS.get(session);
@@ -250169,7 +250243,7 @@ function beginSDDocumentSessionInternalTransaction(session, options) {
250169
250243
  return createSDTransactionContext({
250170
250244
  state: internal.state,
250171
250245
  author: internal.author,
250172
- readCurrentPackageBinding: () => computeSDDocumentSessionInternalPackageBinding(session),
250246
+ readCurrentComparePlanBinding: () => computeSDDocumentSessionInternalSemanticPackageBinding(session),
250173
250247
  options: mergedOptions,
250174
250248
  onCommitted: internal.onMutationCommitted
250175
250249
  });
@@ -252948,7 +253022,7 @@ async function waitForQueuedPreScan(controller, cancel) {
252948
253022
  }
252949
253023
  return outcome.value;
252950
253024
  }
252951
- var SAVE_XML_DECODER, SAVE_XML_ENCODER, PACKAGE_BINDING_TEXT_ENCODER, WORD_XML_PART_RE, REVIEW_SOURCE_COPY_CHUNK_BYTES, INTERNALS, LIVE_MAIN_STORY_SCAN_MEMO, RELS_DECODER, DEFAULT_SAVE_COMPRESSION_LEVEL = 6, SAVE_ZIP_ENTRY_MTIME, EMPTY_PART_URI_SET, ALREADY_COMPRESSED_PART_RE, RAW_FONT_PART_RE, SDSourceBackedSaveUnsupportedError, REMOTE_PROJECTION_GENERATIONS, COLLABORATION_ATTACHMENTS, FIELD_STABLE_ID_ALLOCATORS;
253025
+ var SAVE_XML_DECODER, SAVE_XML_ENCODER, PACKAGE_BINDING_TEXT_ENCODER, WORD_XML_PART_RE, REVIEW_SOURCE_COPY_CHUNK_BYTES, INTERNALS, LIVE_MAIN_STORY_SCAN_MEMO, RELS_DECODER, DEFAULT_SAVE_COMPRESSION_LEVEL = 6, SAVE_ZIP_ENTRY_MTIME, EMPTY_PART_URI_SET, ALREADY_COMPRESSED_PART_RE, RAW_FONT_PART_RE, RSID_ATTR_FOR_FINGERPRINT_RE, SIMPLE_TRACKED_CHANGE_WRAPPER_OPEN_RE, WRAPPER_ID_ATTR_FOR_FINGERPRINT_RE, SDSourceBackedSaveUnsupportedError, REMOTE_PROJECTION_GENERATIONS, COLLABORATION_ATTACHMENTS, FIELD_STABLE_ID_ALLOCATORS;
252952
253026
  var init_sd_document_session = __esm(() => {
252953
253027
  init_textbox_atom_replacement();
252954
253028
  init_paragraph_signal_index();
@@ -253025,6 +253099,9 @@ var init_sd_document_session = __esm(() => {
253025
253099
  EMPTY_PART_URI_SET = new Set;
253026
253100
  ALREADY_COMPRESSED_PART_RE = /\.(png|jpe?g|gif|webp|bmp|ico|tiff?|emf|wmf|mp3|mp4|m4a|mov|avi|wmv|ogg|zip|gz|woff2?|eot)$/i;
253027
253101
  RAW_FONT_PART_RE = /\.(ttf|otf|odttf)$/i;
253102
+ RSID_ATTR_FOR_FINGERPRINT_RE = /\s+w:rsid\w*="[^"]*"/g;
253103
+ SIMPLE_TRACKED_CHANGE_WRAPPER_OPEN_RE = /<w:(?:ins|del|rPrChange|pPrChange)\b[^>]*>/g;
253104
+ WRAPPER_ID_ATTR_FOR_FINGERPRINT_RE = /\s+w:id="[^"]*"/g;
253028
253105
  SDSourceBackedSaveUnsupportedError = class SDSourceBackedSaveUnsupportedError extends Error {
253029
253106
  constructor(code, partUri, message) {
253030
253107
  super(message);
@@ -357887,6 +357964,16 @@ function collectCellScopes(tableCatalog) {
357887
357964
  function computeComparePackageFingerprint(context) {
357888
357965
  return computeSDDocumentSessionInternalPackageBinding(context.session);
357889
357966
  }
357967
+ function computeCompareSemanticPackageFingerprint(context) {
357968
+ return computeSDDocumentSessionInternalSemanticPackageBinding(context.session);
357969
+ }
357970
+ function resolveComparePlanBindingMatch(context, expectedBinding) {
357971
+ const liveSemanticBinding = computeCompareSemanticPackageFingerprint(context);
357972
+ if (liveSemanticBinding === expectedBinding)
357973
+ return { matched: true, liveSemanticBinding };
357974
+ const liveLegacyBinding = computeComparePackageFingerprint(context);
357975
+ return { matched: liveLegacyBinding === expectedBinding, liveSemanticBinding };
357976
+ }
357890
357977
  var init_fingerprint = __esm(() => {
357891
357978
  init_sd_document_session_internal();
357892
357979
  });
@@ -359771,7 +359858,7 @@ function projectCompareSnapshot(context, posture, options) {
359771
359858
  return {
359772
359859
  version: "sd-compare-snapshot/v1",
359773
359860
  identity: {
359774
- fingerprint: computeComparePackageFingerprint(context),
359861
+ fingerprint: computeCompareSemanticPackageFingerprint(context),
359775
359862
  ...options.label !== undefined ? { label: options.label } : {}
359776
359863
  },
359777
359864
  sourcePosture: posture,
@@ -359837,10 +359924,11 @@ function compareOperationId(storyId, ordinal) {
359837
359924
  function applyComparePlan(context, plan, options = {}) {
359838
359925
  const reviewMarkup = options.reviewMarkup !== false;
359839
359926
  const changeMode = reviewMarkup ? "tracked" : "direct";
359840
- const liveBinding = computeComparePackageFingerprint(context);
359841
- if (liveBinding !== plan.planBinding) {
359842
- throw new SDCompareError("PRECONDITION_FAILED", `compare plan is stale: live document binding ${liveBinding} does not match plan binding ${plan.planBinding}.`);
359927
+ const bindingResolution = resolveComparePlanBindingMatch(context, plan.planBinding);
359928
+ if (!bindingResolution.matched) {
359929
+ throw new SDCompareError("PRECONDITION_FAILED", `compare plan is stale: live document binding ${bindingResolution.liveSemanticBinding} ` + `does not match plan binding ${plan.planBinding}.`);
359843
359930
  }
359931
+ const effectivePlanBinding = bindingResolution.liveSemanticBinding;
359844
359932
  let operationOrdinal = plan.bodyOperations.length;
359845
359933
  const storyGroups = (plan.storyOperations ?? []).filter((group) => group.operations.length > 0).map((group) => ({
359846
359934
  storyId: group.storyId,
@@ -359914,7 +360002,7 @@ function applyComparePlan(context, plan, options = {}) {
359914
360002
  tx.compareApply({
359915
360003
  operationId: "v2-compare-apply",
359916
360004
  storyId: mainStoryId,
359917
- planBinding: plan.planBinding,
360005
+ planBinding: effectivePlanBinding,
359918
360006
  changeMode,
359919
360007
  bodySteps,
359920
360008
  ...storyGroups.length > 0 ? {
@@ -368176,7 +368264,12 @@ class V2DiffAdapter {
368176
368264
  }
368177
368265
  const liveFingerprint = liveSnapshot.identity.fingerprint;
368178
368266
  const expectedBinding = payload.applyPlan.planBinding;
368179
- if (liveFingerprint !== payload.base.identity.fingerprint || liveFingerprint !== expectedBinding) {
368267
+ let bindingsMatch = liveFingerprint === payload.base.identity.fingerprint && liveFingerprint === expectedBinding;
368268
+ if (!bindingsMatch) {
368269
+ const liveLegacyFingerprint = computeComparePackageFingerprint(this.context);
368270
+ bindingsMatch = liveLegacyFingerprint === payload.base.identity.fingerprint && liveLegacyFingerprint === expectedBinding;
368271
+ }
368272
+ if (!bindingsMatch) {
368180
368273
  throw diffValidationError("PRECONDITION_FAILED", `diff.apply: package binding mismatch — current=${liveFingerprint} ` + `expectedBase=${payload.base.identity.fingerprint} planBinding=${expectedBinding}.`, { current: liveFingerprint, expectedBase: payload.base.identity.fingerprint, planBinding: expectedBinding });
368181
368274
  }
368182
368275
  const physicalSourceProblems = [
@@ -370140,6 +370233,7 @@ var init_adapter24 = __esm(() => {
370140
370233
  init_compare();
370141
370234
  init_sd_document_session_internal();
370142
370235
  init_part_fingerprint();
370236
+ init_fingerprint();
370143
370237
  init_section_xml();
370144
370238
  init_adapter23();
370145
370239
  init_header_footer_lifecycle();
@@ -432314,16 +432408,20 @@ function mirrorStoryBlocksFromSession(input) {
432314
432408
  if (!tailBlockId) {
432315
432409
  throw new Error("storyBlocks mirror could not resolve tail paragraph id for paragraphSplit");
432316
432410
  }
432411
+ const context = loadStorySyncContext(input.session, input.storyId);
432412
+ const headPayload = readSessionBlockPayload(context, source.target.paraId);
432413
+ const tailPayload = readSessionBlockPayload(context, tailBlockId);
432317
432414
  if (!findBlockMap(input.doc, tailBlockId)) {
432415
+ const offset = source.coordinateSpace === "tracked" ? parseParagraphXml(headPayload.xml, headPayload.namespaceBindings, trackedWrapperIdentityStateForPayload(headPayload)).visibleText.length : source.offset;
432318
432416
  splitBlock({
432319
432417
  doc: input.doc,
432320
432418
  blockId: source.target.paraId,
432321
- offset: source.offset,
432419
+ offset,
432322
432420
  tailBlockId,
432323
432421
  origin: STORY_SURFACE_BACKEND_ORIGIN
432324
432422
  });
432325
432423
  }
432326
- syncBlocksFromSession(input.session, input.storyId, input.doc, [source.target.paraId, tailBlockId]);
432424
+ syncBlockPayloads(input.doc, [headPayload, tailPayload]);
432327
432425
  writeParagraphMembershipTableOverlaysFromSession(input.session, input.prepared, input.storyId, input.doc, [source.target.paraId, tailBlockId], "paragraph.split");
432328
432426
  return;
432329
432427
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.3.0-next.10",
3
+ "version": "1.3.0-next.12",
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.16.0-next.10",
27
+ "@superdoc/sdk": "2.16.0-next.12",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.19.0-next.9",
33
- "@superdoc/docx-engine": "0.18.0-next.9",
32
+ "superdoc": "2.19.0-next.11",
33
+ "@superdoc/docx-engine": "0.18.0-next.11",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",