@superdoc/mcp 1.7.0-next.10 → 1.7.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 +349 -59
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -31600,7 +31600,7 @@ var init_host = __esm(() => {
31600
31600
  });
31601
31601
 
31602
31602
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
31603
- var SDK_VERSION = "2.20.0-next.10";
31603
+ var SDK_VERSION = "2.20.0-next.12";
31604
31604
 
31605
31605
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31606
31606
  import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
@@ -104422,7 +104422,20 @@ function validateChangeMode(value) {
104422
104422
  value
104423
104423
  });
104424
104424
  }
104425
+ function normalizeTextMutationOptions(options) {
104426
+ const { author, ...mutationOptions } = options ?? {};
104427
+ const normalized = normalizeMutationOptions(mutationOptions);
104428
+ if (!options || !("author" in options))
104429
+ return normalized;
104430
+ if (options.changeMode !== "tracked" || !isRecord6(author) || Object.keys(author).some((key) => key !== "name") || typeof author.name !== "string" || author.name.trim().length === 0) {
104431
+ throw new DocumentApiValidationError("INVALID_INPUT", 'author requires changeMode: "tracked" and an object containing only a non-empty name.');
104432
+ }
104433
+ return { ...normalized, changeMode: "tracked", author: { name: author.name } };
104434
+ }
104425
104435
  function normalizeMutationOptions(options, supportCheckOperation) {
104436
+ if (options && typeof options === "object" && "author" in options) {
104437
+ throw new DocumentApiValidationError("INVALID_INPUT", "author is supported only for tracked plain-text doc.insert, doc.delete, and doc.replace calls.");
104438
+ }
104426
104439
  validateChangeMode(options?.changeMode);
104427
104440
  const supportCheck = options?.supportCheck;
104428
104441
  if (supportCheck !== undefined) {
@@ -104461,7 +104474,7 @@ function validateSupportCheckGuard(value, operation) {
104461
104474
  }
104462
104475
  }
104463
104476
  function executeWrite(adapter, request, options) {
104464
- return adapter.write(request, normalizeMutationOptions(options));
104477
+ return adapter.write(request, normalizeTextMutationOptions(options));
104465
104478
  }
104466
104479
  var CHANGE_MODE_VALUES;
104467
104480
  var init_write = __esm(() => {
@@ -106674,6 +106687,7 @@ function textReceiptToSDReceipt(receipt2, context = {}) {
106674
106687
  ...receipt2.failure.details != null ? { details: receipt2.failure.details } : {}
106675
106688
  };
106676
106689
  const CODE_MAP = {
106690
+ INVALID_INPUT: "INVALID_INPUT",
106677
106691
  INVALID_TARGET: "INVALID_TARGET",
106678
106692
  TARGET_NOT_FOUND: "TARGET_NOT_FOUND",
106679
106693
  MATCH_NOT_FOUND: "TARGET_NOT_FOUND",
@@ -106792,6 +106806,9 @@ function validateStructuralInsertInput(input) {
106792
106806
  function executeInsert(selectionAdapter, writeAdapter, input, options) {
106793
106807
  assertOperationCanStart(options);
106794
106808
  validateInsertInput(input);
106809
+ if (options && "author" in options && (isStructuralInsertInput(input) || input.type === "html" || input.type === "markdown")) {
106810
+ throw new DocumentApiValidationError("INVALID_INPUT", "author is supported only for tracked plain-text inserts.");
106811
+ }
106795
106812
  if (isStructuralInsertInput(input)) {
106796
106813
  return writeAdapter.insertStructured(input, normalizeMutationOptions(options));
106797
106814
  }
@@ -106803,7 +106820,7 @@ function executeInsert(selectionAdapter, writeAdapter, input, options) {
106803
106820
  const { target, ref, in: storyIn } = input;
106804
106821
  if (target || ref) {
106805
106822
  const request2 = target ? { kind: "insert", target, text: value, ...storyIn ? { in: storyIn } : {} } : { kind: "insert", ref, text: value, ...storyIn ? { in: storyIn } : {} };
106806
- const textReceipt2 = selectionAdapter.execute(request2, normalizeMutationOptions(options));
106823
+ const textReceipt2 = selectionAdapter.execute(request2, normalizeTextMutationOptions(options));
106807
106824
  return textReceiptToSDReceipt(textReceipt2);
106808
106825
  }
106809
106826
  const request = { kind: "insert", text: value, ...storyIn ? { in: storyIn } : {} };
@@ -106979,6 +106996,9 @@ function validateBodyReplaceShape(input) {
106979
106996
  }
106980
106997
  function executeReplace(selectionAdapter, writeAdapter, input, options) {
106981
106998
  validateReplaceInput(input);
106999
+ if (options && "author" in options && (isStructuralReplaceInput(input) || isRichContentReplaceInput(input) || input.target && isBodyReplaceTarget(input.target))) {
107000
+ throw new DocumentApiValidationError("INVALID_INPUT", "author is supported only for tracked plain-text replacements.");
107001
+ }
106982
107002
  if (isStructuralReplaceInput(input)) {
106983
107003
  return writeAdapter.replaceStructured(input, normalizeMutationOptions(options));
106984
107004
  }
@@ -106996,7 +107016,7 @@ function executeReplace(selectionAdapter, writeAdapter, input, options) {
106996
107016
  in: textInput.in,
106997
107017
  ...textInput.expectedText !== undefined ? { expectedText: textInput.expectedText } : {}
106998
107018
  } : { kind: "replace", ref: textInput.ref, text: textInput.text, in: textInput.in };
106999
- const textReceipt = selectionAdapter.execute(request, normalizeMutationOptions(options));
107019
+ const textReceipt = selectionAdapter.execute(request, normalizeTextMutationOptions(options));
107000
107020
  return textReceiptToSDReceipt(textReceipt);
107001
107021
  }
107002
107022
  var TEXT_REPLACE_ALLOWED_KEYS, STRUCTURAL_REPLACE_ALLOWED_KEYS, RICH_REPLACE_ALLOWED_KEYS, RICH_REPLACE_TYPES;
@@ -117062,7 +117082,7 @@ function validateDeleteInput(input) {
117062
117082
  function executeDelete(adapter, input, options) {
117063
117083
  validateDeleteInput(input);
117064
117084
  const request = input.target ? { kind: "delete", target: input.target, behavior: input.behavior ?? "selection", in: input.in } : { kind: "delete", ref: input.ref, behavior: input.behavior ?? "selection", in: input.in };
117065
- return adapter.execute(request, normalizeMutationOptions(options));
117085
+ return adapter.execute(request, normalizeTextMutationOptions(options));
117066
117086
  }
117067
117087
  var DELETE_INPUT_ALLOWED_KEYS, VALID_BEHAVIORS;
117068
117088
  var init_delete = __esm(() => {
@@ -167555,6 +167575,130 @@ function extractNamespaceClosedParagraphMarkRunPropertiesFromParagraph(paragraph
167555
167575
  return null;
167556
167576
  return namespaceClosedOpenTag + runPropertiesXml.slice(runPropertiesNode.openEnd);
167557
167577
  }
167578
+ function namespaceCloseParagraphPropertiesForRelocation(paragraphPropertiesXml, paragraphXml, inheritedNamespaceBindings, ancestorOpenTags = []) {
167579
+ const paragraph = readValidatedXmlNodeAt(paragraphXml, 0);
167580
+ if (!paragraph || paragraph.kind !== "element" || xmlLocalName(paragraph.qname) !== "p" || paragraph.selfClosing || paragraphXml.slice(paragraph.end).trim())
167581
+ return null;
167582
+ const paragraphOpenTag = paragraphXml.slice(0, paragraph.openEnd);
167583
+ const ancestorPolicySources = readAncestorPolicySources(ancestorOpenTags);
167584
+ if (ancestorPolicySources == null)
167585
+ return null;
167586
+ const { pPr } = splitLeadingParagraphPropertyBlock(paragraphXml.slice(paragraph.openEnd, paragraph.closeStart));
167587
+ const sourcePropertiesStart = pPr.search(/<(?:[\w.-]+:)?pPr\b/);
167588
+ const sourceProperties = sourcePropertiesStart >= 0 ? readValidatedXmlNodeAt(pPr, sourcePropertiesStart) : null;
167589
+ if (sourceProperties && (sourceProperties.kind !== "element" || xmlLocalName(sourceProperties.qname) !== "pPr"))
167590
+ return null;
167591
+ const sourcePropertiesOpenTag = sourceProperties ? pPr.slice(sourcePropertiesStart, sourceProperties.openEnd) : "";
167592
+ const paragraphDeclarations = readLocalNamespaceDeclarations(paragraphOpenTag);
167593
+ if (paragraphDeclarations == null)
167594
+ return null;
167595
+ const sourceBindings = { ...inheritedNamespaceBindings };
167596
+ for (const declaration of paragraphDeclarations)
167597
+ sourceBindings[declaration.prefix] = declaration.namespaceUri;
167598
+ const paragraphBindings = { ...sourceBindings };
167599
+ const sourcePropertiesDeclarations = readLocalNamespaceDeclarations(sourcePropertiesOpenTag);
167600
+ if (sourcePropertiesDeclarations == null)
167601
+ return null;
167602
+ for (const declaration of sourcePropertiesDeclarations)
167603
+ sourceBindings[declaration.prefix] = declaration.namespaceUri;
167604
+ return closePropertyFragmentWithCompatibilityPolicy(paragraphPropertiesXml, "pPr", sourceBindings, [
167605
+ ...ancestorPolicySources,
167606
+ [paragraphOpenTag, paragraphBindings],
167607
+ [sourcePropertiesOpenTag, sourceBindings]
167608
+ ]);
167609
+ }
167610
+ function namespaceCloseRunPropertiesWithAncestorPolicy(runPropertiesXml, paragraphOpenTag, inheritedNamespaceBindings, ancestorOpenTags) {
167611
+ if (!runPropertiesXml)
167612
+ return "";
167613
+ const ancestorPolicySources = readAncestorPolicySources(ancestorOpenTags);
167614
+ const declarations = readLocalNamespaceDeclarations(paragraphOpenTag);
167615
+ if (ancestorPolicySources == null || declarations == null)
167616
+ return null;
167617
+ const bindings = { ...inheritedNamespaceBindings };
167618
+ for (const declaration of declarations)
167619
+ bindings[declaration.prefix] = declaration.namespaceUri;
167620
+ return closePropertyFragmentWithCompatibilityPolicy(runPropertiesXml, "rPr", bindings, [
167621
+ ...ancestorPolicySources,
167622
+ [paragraphOpenTag, bindings]
167623
+ ]);
167624
+ }
167625
+ function readAncestorPolicySources(ancestorOpenTags) {
167626
+ const sources = [];
167627
+ const bindings = {};
167628
+ for (const openTag of ancestorOpenTags) {
167629
+ const declarations = readLocalNamespaceDeclarations(openTag);
167630
+ if (declarations == null)
167631
+ return null;
167632
+ for (const declaration of declarations)
167633
+ bindings[declaration.prefix] = declaration.namespaceUri;
167634
+ sources.push([openTag, { ...bindings }]);
167635
+ }
167636
+ return sources;
167637
+ }
167638
+ function closePropertyFragmentWithCompatibilityPolicy(propertiesXml, propertyName, inheritedNamespaceBindings, policySources) {
167639
+ const node2 = readValidatedXmlNodeAt(propertiesXml, 0);
167640
+ if (!node2 || node2.kind !== "element" || xmlLocalName(node2.qname) !== propertyName || node2.end !== propertiesXml.length)
167641
+ return null;
167642
+ let openTag = propertiesXml.slice(0, node2.openEnd);
167643
+ const localDeclarations = readLocalNamespaceDeclarations(openTag);
167644
+ if (localDeclarations == null)
167645
+ return null;
167646
+ const bindings = { ...inheritedNamespaceBindings };
167647
+ for (const declaration of localDeclarations)
167648
+ bindings[declaration.prefix] = declaration.namespaceUri;
167649
+ const prefix = parseRawXmlElementTag(openTag)?.prefix;
167650
+ if (prefix == null)
167651
+ return null;
167652
+ if (bindings[prefix] == null)
167653
+ bindings[prefix] = NS_W;
167654
+ if (bindings[prefix] !== NS_W)
167655
+ return null;
167656
+ for (const [sourceOpenTag, policyBindings] of policySources) {
167657
+ const policyPrefixes = markupCompatibilityValuePrefixes(sourceOpenTag, new Map(Object.entries(policyBindings)));
167658
+ if (policyPrefixes == null || [...policyPrefixes].some((key2) => policyBindings[key2] !== bindings[key2]))
167659
+ return null;
167660
+ for (const attribute of scanRawXmlAttributes(sourceOpenTag)) {
167661
+ if (policyBindings[attribute.prefix] !== NS_MC)
167662
+ continue;
167663
+ if (bindings[attribute.prefix] !== NS_MC)
167664
+ return null;
167665
+ const existing = [...scanRawXmlAttributes(openTag)].find((candidate) => bindings[candidate.prefix] === NS_MC && candidate.localName === attribute.localName);
167666
+ if (existing) {
167667
+ const currentValue = decodeXmlText(existing.value);
167668
+ const sourceValue = decodeXmlText(attribute.value);
167669
+ if (currentValue !== sourceValue) {
167670
+ if (!INHERITED_MC_LIST_ATTRIBUTES.has(attribute.localName))
167671
+ return null;
167672
+ const tokens = [...new Set([...currentValue.split(/\s+/), ...sourceValue.split(/\s+/)].filter(Boolean))];
167673
+ openTag = openTag.slice(0, existing.valueStart) + escapeXmlAttribute(tokens.join(" ")) + openTag.slice(existing.valueEnd);
167674
+ }
167675
+ } else {
167676
+ const sourceXml = sourceOpenTag.slice(attribute.sourceStart, attribute.sourceEnd);
167677
+ openTag = openTag.replace(/\s*(\/?)>$/, (_match, slash) => ` ${sourceXml.trim()}${slash}>`);
167678
+ }
167679
+ }
167680
+ }
167681
+ const fragment3 = openTag + propertiesXml.slice(node2.openEnd);
167682
+ const required2 = namespacePrefixesRequiredByFragment(fragment3);
167683
+ const compatibilityPrefixes = markupCompatibilityValuePrefixes(openTag, new Map(Object.entries(bindings)));
167684
+ if (required2 == null || compatibilityPrefixes == null)
167685
+ return null;
167686
+ const declarations = [];
167687
+ for (const requiredPrefix of new Set([...required2, ...compatibilityPrefixes])) {
167688
+ if (requiredPrefix === "xml")
167689
+ continue;
167690
+ const namespaceUri = bindings[requiredPrefix];
167691
+ if (!namespaceUri || namespaceUri.startsWith("urn:superdoc:unresolved-namespace-prefix:"))
167692
+ return null;
167693
+ declarations.push({
167694
+ prefix: requiredPrefix,
167695
+ namespaceUri,
167696
+ sourceXml: requiredPrefix ? ` xmlns:${requiredPrefix}="${escapeXmlAttribute(namespaceUri)}"` : ` xmlns="${escapeXmlAttribute(namespaceUri)}"`
167697
+ });
167698
+ }
167699
+ const closed = addNamespaceDeclarations(openTag, declarations);
167700
+ return closed == null ? null : closed + propertiesXml.slice(node2.openEnd);
167701
+ }
167558
167702
  function namespaceCloseRunPropertiesForRelocation(runPropertiesXml, namespaceSourceOpenTag, inheritedNamespaceBindings = {}) {
167559
167703
  const runPropertiesNode = readValidatedXmlNodeAt(runPropertiesXml, 0);
167560
167704
  if (!runPropertiesNode || runPropertiesNode.kind !== "element" || runPropertiesNode.selfClosing || xmlLocalName(runPropertiesNode.qname) !== "rPr" || runPropertiesNode.end !== runPropertiesXml.length) {
@@ -168097,11 +168241,12 @@ function addNamespaceDeclarations(openTag, sourceNamespaces, inheritedNamespaceB
168097
168241
  }
168098
168242
  return additions.length > 0 ? openTag.replace(/\s*(\/?)>$/, (_match, selfClosing) => `${additions}${selfClosing}>`) : openTag;
168099
168243
  }
168100
- var PARAGRAPH_MARK_REVISION_CHILDREN;
168244
+ var PARAGRAPH_MARK_REVISION_CHILDREN, INHERITED_MC_LIST_ATTRIBUTES;
168101
168245
  var init_paragraph_property_block = __esm(() => {
168102
168246
  init_xml_text();
168103
168247
  init_xml_sax();
168104
168248
  PARAGRAPH_MARK_REVISION_CHILDREN = new Set(["ins", "del", "moveFrom", "moveTo", "rPrChange"]);
168249
+ INHERITED_MC_LIST_ATTRIBUTES = new Set(["Ignorable", "PreserveAttributes", "PreserveElements", "ProcessContent"]);
168105
168250
  });
168106
168251
 
168107
168252
  // ../../../v2/editor-core/dist/document/transactions/collapsed-inline-insertion-site.js
@@ -187984,11 +188129,18 @@ var init_part_wml_scan_cache = __esm(() => {
187984
188129
 
187985
188130
  // ../../../v2/editor-core/dist/document/transactions/paragraph-para-id-attrs.js
187986
188131
  function namespaceBindingsAtPosition(bytes, byteOffset, localOpenTag = "") {
188132
+ return namespaceContextAtPosition(bytes, byteOffset, localOpenTag).bindings;
188133
+ }
188134
+ function namespaceContextAtPosition(bytes, byteOffset, localOpenTag = "") {
188135
+ const scopes = readNamespaceScopesBeforeByte(bytes, byteOffset);
187987
188136
  const bindings = {
187988
- ...readNamespacesBeforeByte(bytes, byteOffset),
188137
+ ...scopes.reduce((acc, frame) => ({ ...acc, ...frame.namespaces }), {}),
187989
188138
  ...readNamespaceDeclarations2(localOpenTag)
187990
188139
  };
187991
- return Object.fromEntries(Object.entries(bindings).filter((entry) => entry[1] != null));
188140
+ return {
188141
+ bindings: Object.fromEntries(Object.entries(bindings).filter((entry) => entry[1] != null)),
188142
+ ancestorOpenTags: scopes.map((frame) => frame.openTag)
188143
+ };
187992
188144
  }
187993
188145
  function matchParagraphOpenTag(paragraphXml) {
187994
188146
  return paragraphXml.match(PARAGRAPH_OPEN_TAG_RE2)?.[0] ?? null;
@@ -188016,6 +188168,9 @@ function readPartRootNamespaces(bytes) {
188016
188168
  return readNamespaceDeclarations2(rootOpenTag);
188017
188169
  }
188018
188170
  function readNamespacesBeforeByte(bytes, byteOffset) {
188171
+ return readNamespaceScopesBeforeByte(bytes, byteOffset).reduce((acc, frame) => ({ ...acc, ...frame.namespaces }), {});
188172
+ }
188173
+ function readNamespaceScopesBeforeByte(bytes, byteOffset) {
188019
188174
  ancestorNamespacePrefixScanCount += 1;
188020
188175
  const prefix = stripXmlCommentsAndCdata(TD33.decode(bytes.subarray(0, Math.max(0, byteOffset))));
188021
188176
  const stack = [];
@@ -188038,9 +188193,9 @@ function readNamespacesBeforeByte(bytes, byteOffset) {
188038
188193
  const namespaces = readNamespaceDeclarations2(match[0]);
188039
188194
  if (/\/\s*>$/.test(match[0]))
188040
188195
  continue;
188041
- stack.push({ name, namespaces });
188196
+ stack.push({ name, namespaces, openTag: match[0] });
188042
188197
  }
188043
- return stack.reduce((acc, frame) => ({ ...acc, ...frame.namespaces }), {});
188198
+ return stack;
188044
188199
  }
188045
188200
  function stripXmlCommentsAndCdata(xml) {
188046
188201
  let result = "";
@@ -219329,7 +219484,7 @@ function resolveInsertionFormattingContext(state, input) {
219329
219484
  const style = resolveInsertionStyle(state, paragraphXml, input.anchor, input.styleRef, inheritance, input.fallbackToDocumentDefaultStyle ?? false);
219330
219485
  if (!style.ok)
219331
219486
  return style;
219332
- const direct = inheritance === "anchor" && paragraphXml != null ? resolveDirectInsertionFormatting(paragraphXml, input.anchor.placement, readAnchorNamespaceBindings(state, input.anchor.entry)) : {
219487
+ const direct = inheritance === "anchor" && paragraphXml != null ? resolveDirectInsertionFormatting(paragraphXml, input.anchor.placement, readAnchorNamespaceBindings(state, input.anchor.entry), input.includeRunProperties ?? true) : {
219333
219488
  paragraphPropertiesXml: null,
219334
219489
  paragraphMarkRunPropertiesXml: null,
219335
219490
  runPropertiesXml: null,
@@ -219492,10 +219647,10 @@ function lookupNextStyle(state, styleId) {
219492
219647
  function readWordAttribute2(tag, namespaceUri, localName2) {
219493
219648
  return readXmlAttribute(tag, namespaceUri, localName2)?.value;
219494
219649
  }
219495
- function resolveDirectInsertionFormatting(paragraphXml, placement2, inheritedNamespaceBindings = {}) {
219650
+ function resolveDirectInsertionFormatting(paragraphXml, placement2, inheritedNamespaceBindings = {}, includeRunProperties = true) {
219496
219651
  const paragraphPropertiesXml = cloneDirectParagraphPropertiesForInsert(paragraphXml);
219497
219652
  const paragraphMarkRunPropertiesXml = cloneParagraphMarkRunPropertiesForInsert(paragraphXml);
219498
- const adjacentRunProperties = cloneAdjacentRunPropertiesForInsert(paragraphXml, placement2, paragraphMarkRunPropertiesXml, inheritedNamespaceBindings);
219653
+ const adjacentRunProperties = includeRunProperties ? cloneAdjacentRunPropertiesForInsert(paragraphXml, placement2, paragraphMarkRunPropertiesXml, inheritedNamespaceBindings) : { ok: true, runPropertiesXml: null };
219499
219654
  if (!adjacentRunProperties.ok)
219500
219655
  return adjacentRunProperties;
219501
219656
  const runPropertiesXml = adjacentRunProperties.runPropertiesXml;
@@ -241404,31 +241559,32 @@ var init_compile_paste_lists = __esm(() => {
241404
241559
  });
241405
241560
 
241406
241561
  // ../../../v2/editor-core/dist/document/transactions/match-destination-paste.js
241407
- function normalizeMatchDestinationBlocks(blocks) {
241408
- return blocks.map((block) => {
241409
- if (block.kind !== "paragraph")
241410
- return block;
241411
- return {
241412
- kind: "paragraph",
241413
- runs: block.runs.map((run) => ({ text: run.text, ...run.sourcePath ? { sourcePath: run.sourcePath } : {} })),
241414
- ...block.sourcePath ? { sourcePath: block.sourcePath } : {},
241415
- ...block.inlines ? {
241416
- inlines: block.inlines.map((inline) => inline.kind === "text" ? {
241417
- kind: "text",
241418
- text: inline.text,
241419
- ...inline.sourcePath ? { sourcePath: inline.sourcePath } : {}
241420
- } : inline.kind === "hyperlink" ? {
241421
- ...inline,
241422
- inlines: inline.inlines.map((child) => child.kind === "text" ? {
241423
- kind: "text",
241424
- text: child.text,
241425
- ...child.sourcePath ? { sourcePath: child.sourcePath } : {}
241426
- } : child)
241427
- } : inline)
241428
- } : {}
241429
- };
241430
- });
241562
+ function normalizeMatchDestinationBlocks(blocks, destinationTableParagraphPropertiesXml) {
241563
+ return blocks.map((block) => block.kind === "table" ? mapPasteTableParagraphs(block, (paragraph) => ({
241564
+ ...normalizeMatchDestinationParagraph(paragraph),
241565
+ ...destinationTableParagraphPropertiesXml ? { pPrXml: destinationTableParagraphPropertiesXml, complete: true } : {}
241566
+ })) : block.kind === "paragraph" ? normalizeMatchDestinationParagraph(block) : block);
241567
+ }
241568
+ function normalizeMatchDestinationParagraph(block) {
241569
+ return {
241570
+ kind: "paragraph",
241571
+ runs: block.runs.map(withoutSourceMarks),
241572
+ ...block.sourcePath ? { sourcePath: block.sourcePath } : {},
241573
+ ...block.inlines ? {
241574
+ inlines: block.inlines.map((inline) => inline.kind === "text" ? withoutSourceMarks(inline) : inline.kind === "hyperlink" ? {
241575
+ ...inline,
241576
+ inlines: inline.inlines.map((child) => child.kind === "text" ? withoutSourceMarks(child) : child)
241577
+ } : inline)
241578
+ } : {}
241579
+ };
241431
241580
  }
241581
+ function withoutSourceMarks(run) {
241582
+ const { marks: _sourceMarks, ...retained } = run;
241583
+ return retained;
241584
+ }
241585
+ var init_match_destination_paste = __esm(() => {
241586
+ init_paste_blocks();
241587
+ });
241432
241588
 
241433
241589
  // ../../../v2/editor-core/dist/document/transactions/image-catalog.js
241434
241590
  function buildImageCatalog(input) {
@@ -243912,7 +244068,32 @@ function preparePasteFragmentMutation(input) {
243912
244068
  if (!isMaterializablePasteBlocks(blocks)) {
243913
244069
  return rejected18(txId, "paste-structure-unsupported");
243914
244070
  }
243915
- const normalizedBlocks = isTextTarget2(pasteTarget) && op.formattingMode === "match-destination" ? normalizeMatchDestinationBlocks(blocks) : blocks;
244071
+ let destinationTableParagraphPropertiesXml = null;
244072
+ if (isTextTarget2(pasteTarget) && op.formattingMode === "match-destination" && blocks.some((block) => block.kind === "table")) {
244073
+ const anchor = resolveParagraph3(state, pasteTarget.storyId, pasteTarget.paraId);
244074
+ if (!anchor)
244075
+ return rejected18(txId, "paste-target-unsupported");
244076
+ const destination = resolveInsertionFormattingContext(state, {
244077
+ anchor: { entry: anchor.entry, placement: "before" },
244078
+ includeRunProperties: false
244079
+ });
244080
+ if (!destination.ok)
244081
+ return rejected18(txId, destination.reason);
244082
+ if (destination.context.paragraphPropertiesXml) {
244083
+ const bytes = state.packageBytes.get(anchor.partUri);
244084
+ if (!bytes)
244085
+ return rejected18(txId, "paste-target-unsupported");
244086
+ const paragraphXml = TD70.decode(bytes.subarray(anchor.byteStart, anchor.byteEnd));
244087
+ const openTag = matchParagraphOpenTag(paragraphXml);
244088
+ if (!openTag)
244089
+ return rejected18(txId, "paste-target-unsupported");
244090
+ const namespaceContext = namespaceContextAtPosition(bytes, anchor.byteStart, openTag);
244091
+ destinationTableParagraphPropertiesXml = namespaceCloseParagraphPropertiesForRelocation(destination.context.paragraphPropertiesXml, paragraphXml, namespaceContext.bindings, namespaceContext.ancestorOpenTags);
244092
+ if (destinationTableParagraphPropertiesXml == null)
244093
+ return rejected18(txId, "paste-structure-unsupported");
244094
+ }
244095
+ }
244096
+ const normalizedBlocks = isTextTarget2(pasteTarget) && op.formattingMode === "match-destination" ? normalizeMatchDestinationBlocks(blocks, destinationTableParagraphPropertiesXml) : blocks;
243916
244097
  const imageValidation = validateImageFragment(op.fragment);
243917
244098
  if (!imageValidation.ok)
243918
244099
  return rejected18(txId, imageValidation.reason);
@@ -244012,7 +244193,13 @@ function preparePasteFragmentMutation(input) {
244012
244193
  if (!anchor || !bytes)
244013
244194
  return rejected18(txId, "paste-target-unsupported");
244014
244195
  const anchorXml = TD70.decode(bytes.subarray(anchor.byteStart, anchor.byteEnd));
244015
- const destination = resolveCaretRunPropertiesForInsertion(anchorXml, target.start.charOffset, namespaceBindingsAtPosition(bytes, anchor.byteStart, matchParagraphOpenTag(anchorXml) ?? ""), anchor.entry.textLength);
244196
+ const destination = resolveDestinationPasteRunProperties({
244197
+ paragraphXml: anchorXml,
244198
+ charOffset: target.start.charOffset,
244199
+ partBytes: bytes,
244200
+ paragraphStartByte: anchor.byteStart,
244201
+ replaceToOffset: anchor.entry.textLength
244202
+ });
244016
244203
  if (!destination.ok)
244017
244204
  return rejected18(txId, destination.reason);
244018
244205
  imageExtras.value = {
@@ -244925,6 +245112,24 @@ function tryRunTableRowPasteCommit(input, pasteTarget, pastedBlocks, additionalP
244925
245112
  const targetTableLocation = findContainingTableCell(tableCatalog, targetParagraph);
244926
245113
  if (!targetTableLocation)
244927
245114
  return null;
245115
+ if (input.op.formattingMode === "match-destination" && storyPartBytes) {
245116
+ const paragraphXml = TD70.decode(storyPartBytes.subarray(targetParagraph.byteStart, targetParagraph.byteEnd));
245117
+ const destination = resolveDestinationPasteRunProperties({
245118
+ paragraphXml,
245119
+ charOffset: pasteTarget.charOffset,
245120
+ partBytes: storyPartBytes,
245121
+ paragraphStartByte: targetParagraph.byteStart,
245122
+ replaceToOffset: pasteTarget.replaceToOffset,
245123
+ collapsedInlineAffinity: pasteTarget.collapsedInlineAffinity,
245124
+ collapsedObjectBoundary: pasteTarget.collapsedObjectBoundary
245125
+ });
245126
+ if (!destination.ok)
245127
+ return rejected18(transactionId, destination.reason);
245128
+ pastedImageExtras = {
245129
+ ...pastedImageExtras,
245130
+ inlineSpecs: inheritDestinationInlineSpecs(pastedImageExtras.inlineSpecs, pastedBlocks, destination.runPropertiesXml ?? "")
245131
+ };
245132
+ }
244928
245133
  if (targetTableLocation.table.hasVMerge) {
244929
245134
  return rejected18(transactionId, "paste-target-unsupported");
244930
245135
  }
@@ -245424,7 +245629,15 @@ function runPasteSpliceCommit(input, target, resolvedBlocks, listExtras, imageEx
245424
245629
  const anchorXml = TD70.decode(bytes.subarray(paragraphStartByte, paragraphEndByte));
245425
245630
  let inlineSpecs = imageExtras.inlineSpecs;
245426
245631
  if (input.op.formattingMode === "match-destination") {
245427
- const destination = resolveCaretRunPropertiesForInsertion(anchorXml, target.charOffset, namespaceBindingsAtPosition(bytes, paragraphStartByte, matchParagraphOpenTag(anchorXml) ?? ""), target.replaceToOffset, target.collapsedInlineAffinity, target.collapsedObjectBoundary);
245632
+ const destination = resolveDestinationPasteRunProperties({
245633
+ paragraphXml: anchorXml,
245634
+ charOffset: target.charOffset,
245635
+ partBytes: bytes,
245636
+ paragraphStartByte,
245637
+ replaceToOffset: target.replaceToOffset,
245638
+ collapsedInlineAffinity: target.collapsedInlineAffinity,
245639
+ collapsedObjectBoundary: target.collapsedObjectBoundary
245640
+ });
245428
245641
  if (!destination.ok)
245429
245642
  return rejected18(txId, destination.reason);
245430
245643
  inlineSpecs = inheritDestinationInlineSpecs(inlineSpecs, resolvedBlocks, destination.runPropertiesXml ?? "");
@@ -245590,9 +245803,20 @@ function runPasteSpliceCommit(input, target, resolvedBlocks, listExtras, imageEx
245590
245803
  }
245591
245804
  });
245592
245805
  }
245806
+ function resolveDestinationPasteRunProperties(input) {
245807
+ const openTag = matchParagraphOpenTag(input.paragraphXml);
245808
+ if (!openTag)
245809
+ return { ok: false, reason: "unsupported-context" };
245810
+ const context = namespaceContextAtPosition(input.partBytes, input.paragraphStartByte, openTag);
245811
+ const destination = resolveCaretRunPropertiesForInsertion(input.paragraphXml, input.charOffset, context.bindings, input.replaceToOffset, input.collapsedInlineAffinity, input.collapsedObjectBoundary);
245812
+ if (!destination.ok)
245813
+ return destination;
245814
+ const runPropertiesXml = namespaceCloseRunPropertiesWithAncestorPolicy(destination.runPropertiesXml ?? "", openTag, context.bindings, context.ancestorOpenTags);
245815
+ return runPropertiesXml == null ? { ok: false, reason: "unsupported-context" } : { ok: true, runPropertiesXml };
245816
+ }
245593
245817
  function inheritDestinationInlineSpecs(inlineSpecs, blocks, runPropertiesXml) {
245594
245818
  const inherited = new Map(inlineSpecs);
245595
- for (const block of blocks) {
245819
+ for (const block of walkPasteBlocks(blocks)) {
245596
245820
  if (block.kind !== "paragraph")
245597
245821
  continue;
245598
245822
  inherited.set(block, (inlineSpecs.get(block) ?? block.runs.map(toPasteTextRunSpec)).map((run) => withDestinationRunProperties(run, runPropertiesXml)));
@@ -246849,8 +247073,10 @@ var init_compile_paste_fragment = __esm(() => {
246849
247073
  init_compile_paste_splice();
246850
247074
  init_compile_paste_lists();
246851
247075
  init_paste_blocks();
247076
+ init_match_destination_paste();
246852
247077
  init_paragraph_para_id_attrs();
246853
247078
  init_insertion_formatting_context();
247079
+ init_paragraph_property_block();
246854
247080
  init_table_catalog();
246855
247081
  init_comments_catalog();
246856
247082
  init_comment_package_profile();
@@ -301621,7 +301847,7 @@ var init_paragraph_ids = __esm(() => {
301621
301847
 
301622
301848
  // ../../../v2/document-api-v2-adapter/dist/story-surfaces/tracked-block-range.js
301623
301849
  function prepareTrackedBlockRangeReplacement(input) {
301624
- const author = input.context.readAuthor();
301850
+ const author = input.author ?? input.context.readAuthor();
301625
301851
  if (!author?.name)
301626
301852
  return {
301627
301853
  ok: false,
@@ -330527,7 +330753,7 @@ function runRangeCollapse(deps, plan) {
330527
330753
  function runParagraphOp(deps, apply) {
330528
330754
  const { context } = deps;
330529
330755
  const beginMutationStartedAt = performanceNowMs();
330530
- const begun = context.beginMutation({});
330756
+ const begun = context.beginMutation({ author: deps.author });
330531
330757
  if ("failure" in begun) {
330532
330758
  throw new RangePasteStepError({ code: begun.failure.code, message: begun.failure.message });
330533
330759
  }
@@ -330975,7 +331201,7 @@ var init_raw_block_ref = __esm(() => {
330975
331201
 
330976
331202
  // ../../../v2/document-api-v2-adapter/dist/story-surfaces/tracked-body-replacement.js
330977
331203
  function prepareTrackedBodyReplacement(input) {
330978
- if (!input.context.readAuthor()?.name)
331204
+ if (!(input.author ?? input.context.readAuthor())?.name)
330979
331205
  return {
330980
331206
  ok: false,
330981
331207
  code: "PRECONDITION_FAILED",
@@ -330994,7 +331220,8 @@ function prepareTrackedBodyReplacement(input) {
330994
331220
  ...input,
330995
331221
  beforeXml: before.content,
330996
331222
  afterXml: after.content,
330997
- namespaceBindings: new Map(Object.entries(before.body.namespaceBindings))
331223
+ namespaceBindings: new Map(Object.entries(before.body.namespaceBindings)),
331224
+ author: input.author
330998
331225
  });
330999
331226
  if (!replacement.ok)
331000
331227
  return replacement;
@@ -332926,6 +333153,9 @@ var init_effective_inline_uniformity = __esm(() => {
332926
333153
  });
332927
333154
 
332928
333155
  // ../../../v2/document-api-v2-adapter/dist/selection-mutation/adapter.js
333156
+ function textMutationAuthor(options) {
333157
+ return options?.author;
333158
+ }
332929
333159
  function selectionIsAllowedByDocumentProtection(context, target, index2, storyId) {
332930
333160
  const protection = new V2ProtectionAdapter(context).get().editingRestriction;
332931
333161
  if (!protection.runtimeEnforced)
@@ -332992,7 +333222,7 @@ class V2SelectionMutationAdapter {
332992
333222
  resolution: protectedEdit.resolution
332993
333223
  };
332994
333224
  }
332995
- const begun = this.context.beginMutation({ expectedRevision: options?.expectedRevision });
333225
+ const begun = this.context.beginMutation({ expectedRevision: options?.expectedRevision, author: textMutationAuthor(options) });
332996
333226
  if ("failure" in begun) {
332997
333227
  return { success: false, failure: begun.failure, resolution: edits[0].resolution };
332998
333228
  }
@@ -333361,7 +333591,8 @@ class V2SelectionMutationAdapter {
333361
333591
  resolved: wholeStory.resolved,
333362
333592
  resolution: resolution2,
333363
333593
  effectiveStory: effectiveStory2,
333364
- expectedRevision: options?.expectedRevision
333594
+ expectedRevision: options?.expectedRevision,
333595
+ author: textMutationAuthor(options)
333365
333596
  });
333366
333597
  }
333367
333598
  }
@@ -333527,7 +333758,7 @@ class V2SelectionMutationAdapter {
333527
333758
  };
333528
333759
  }
333529
333760
  const beginMutationStartedAt = nowMs6();
333530
- const begun = this.context.beginMutation({});
333761
+ const begun = this.context.beginMutation({ author: textMutationAuthor(options) });
333531
333762
  if ("failure" in begun) {
333532
333763
  return {
333533
333764
  success: false,
@@ -333755,6 +333986,9 @@ class V2SelectionMutationAdapter {
333755
333986
  }
333756
333987
  executeCrossParagraphReplace(input) {
333757
333988
  const { target, index: index2, story, storyLocator, text: text4, startedAt, storyResolveMs, offsetSpace, options, atomicFieldDelete } = input;
333989
+ if (text4.length > 0 && textMutationAuthor(options)) {
333990
+ return failureWithoutResolution("INVALID_INPUT", "Per-call author is not supported for structural cross-paragraph replacements.");
333991
+ }
333758
333992
  if (target.coordinateSpace === "tracked") {
333759
333993
  return failureWithoutResolution("CAPABILITY_UNAVAILABLE", "text-range-cross-paragraph-tracked-coordinate-unsupported");
333760
333994
  }
@@ -333863,7 +334097,7 @@ class V2SelectionMutationAdapter {
333863
334097
  return { success: true, resolution };
333864
334098
  if (text4.length > 0) {
333865
334099
  const beginMutationStartedAt = nowMs6();
333866
- const begun = this.context.beginMutation({ expectedRevision: options?.expectedRevision });
334100
+ const begun = this.context.beginMutation({ expectedRevision: options?.expectedRevision, author: textMutationAuthor(options) });
333867
334101
  if ("failure" in begun) {
333868
334102
  return { success: false, failure: begun.failure, resolution };
333869
334103
  }
@@ -333978,6 +334212,7 @@ class V2SelectionMutationAdapter {
333978
334212
  index: index2,
333979
334213
  historyLabel: "selection.delete.cross-paragraph",
333980
334214
  changeMode,
334215
+ author: textMutationAuthor(options),
333981
334216
  preflightValidated: true,
333982
334217
  recordCommitDiagnostics(diagnostics) {
333983
334218
  commitDiagnosticsRef.current = diagnostics;
@@ -334037,6 +334272,9 @@ class V2SelectionMutationAdapter {
334037
334272
  }
334038
334273
  executeCrossCellDelete(input) {
334039
334274
  const { target, index: index2, story, storyLocator, offsetSpace, options } = input;
334275
+ if (textMutationAuthor(options)) {
334276
+ return failureWithoutResolution("INVALID_INPUT", "Per-call author is not supported for cross-cell deletion.");
334277
+ }
334040
334278
  const plan = resolveCrossCellDeletePlan({
334041
334279
  context: this.context,
334042
334280
  buildOffsetMap: buildOffsetMapForCoordinateSpace3,
@@ -334100,7 +334338,7 @@ class V2SelectionMutationAdapter {
334100
334338
  };
334101
334339
  }
334102
334340
  executeTrackedWholeStoryDelete(input) {
334103
- const begun = this.context.beginMutation(input.expectedRevision ? { expectedRevision: input.expectedRevision } : undefined);
334341
+ const begun = this.context.beginMutation({ expectedRevision: input.expectedRevision, author: input.author });
334104
334342
  if ("failure" in begun) {
334105
334343
  return {
334106
334344
  success: false,
@@ -334900,7 +335138,8 @@ class V2SelectionMutationAdapter {
334900
335138
  context: this.context,
334901
335139
  beforeXml: sourceXml,
334902
335140
  afterXml: nextXml,
334903
- dryRun: options?.dryRun
335141
+ dryRun: options?.dryRun,
335142
+ author: textMutationAuthor(options)
334904
335143
  });
334905
335144
  if (!replacement.ok) {
334906
335145
  return { success: false, failure: { code: replacement.code, message: replacement.message }, resolution };
@@ -337809,7 +338048,9 @@ class V2TablesAdapter {
337809
338048
  const model = parseTableXmlModel(resolved.tableXml);
337810
338049
  mutateTablePr(model, (children2) => {
337811
338050
  let next = children2;
337812
- next = setOrRemoveChild(next, "jc", input.alignment ? singleElement2(model.prefix, "jc", { val: input.alignment }) : null);
338051
+ if (input.alignment !== undefined) {
338052
+ next = setOrRemoveChild(next, "jc", input.alignment ? singleElement2(model.prefix, "jc", { val: input.alignment }) : null);
338053
+ }
337813
338054
  if (input.autoFitMode) {
337814
338055
  if (input.autoFitMode === "fixedWidth") {
337815
338056
  next = setOrRemoveChild(next, "tblLayout", singleElement2(model.prefix, "tblLayout", { type: "fixed" }));
@@ -358918,8 +359159,9 @@ class V2TrackedChangesAdapter {
358918
359159
  if (entry.type !== "replacement")
358919
359160
  return;
358920
359161
  const rsid = side === "delete" || side === "deleted" ? entry.sides?.deleted?.rsid : entry.sides?.inserted?.rsid;
359162
+ const kind = side === "delete" || side === "deleted" ? "del" : "ins";
358921
359163
  if (rsid)
358922
- addFragments(entry.fragments.filter((fragment4) => fragment4.rsid === rsid));
359164
+ addFragments(entry.fragments.filter((fragment4) => fragment4.rsid === rsid && fragment4.kind === kind));
358923
359165
  } else {
358924
359166
  addFragments(entry.fragments);
358925
359167
  structural || (structural = entry.formattingFragments.length > 0 || entry.structuralFragments.length > 0);
@@ -359742,6 +359984,9 @@ class V2TrackedChangesAdapter {
359742
359984
  return this.decideByLogicalIds(decision, [entry.id], options);
359743
359985
  }
359744
359986
  if (target.overlap === "side-only" || target.overlap === "empties-one-side") {
359987
+ const pairingFailure = replacementSidePairingFailure(entry);
359988
+ if (pairingFailure)
359989
+ return pairingFailure;
359745
359990
  const side = target.side === "delete" || target.side === "deleted" ? "deleted" : "inserted";
359746
359991
  const rsid = side === "deleted" ? entry.sides?.deleted?.rsid : entry.sides?.inserted?.rsid;
359747
359992
  if (!rsid) {
@@ -359750,7 +359995,11 @@ class V2TrackedChangesAdapter {
359750
359995
  const permissionFailure = this.checkTrackedChangePermissions(decision, [entry], logical);
359751
359996
  if (permissionFailure)
359752
359997
  return permissionFailure;
359753
- return this.runDecideWithTargets(decision, [{ rsid }], logical, options);
359998
+ const fragments = textFragmentSelectorsForRsid(entry, rsid, side === "deleted" ? "del" : "ins");
359999
+ if (fragments.length === 0) {
360000
+ return failure7("TARGET_NOT_FOUND", `trackChanges.decide range: ${side} replacement side was not found.`);
360001
+ }
360002
+ return this.runDecideWithTargets(decision, [{ rsid, fragments }], logical, options);
359754
360003
  }
359755
360004
  const textTarget = this.buildTextTargetForLogicalRange(entry, raw, {
359756
360005
  overlap: target.overlap,
@@ -359770,6 +360019,9 @@ class V2TrackedChangesAdapter {
359770
360019
  if (entry.type !== "replacement") {
359771
360020
  return failure7("INVALID_TARGET", `trackChanges.decide: side selector requires a replacement change (id "${id}").`);
359772
360021
  }
360022
+ const pairingFailure = replacementSidePairingFailure(entry);
360023
+ if (pairingFailure)
360024
+ return pairingFailure;
359773
360025
  const rsid = side === "deleted" ? entry.sides?.deleted?.rsid : entry.sides?.inserted?.rsid;
359774
360026
  if (!rsid) {
359775
360027
  return failure7("TARGET_NOT_FOUND", `trackChanges.decide: ${side} replacement side was not found.`);
@@ -359777,7 +360029,11 @@ class V2TrackedChangesAdapter {
359777
360029
  const permissionFailure = this.checkTrackedChangePermissions(decision, [entry], logical);
359778
360030
  if (permissionFailure)
359779
360031
  return permissionFailure;
359780
- return this.runDecideWithTargets(decision, [{ rsid }], logical, options);
360032
+ const fragments = textFragmentSelectorsForRsid(entry, rsid, side === "deleted" ? "del" : "ins");
360033
+ if (fragments.length === 0) {
360034
+ return failure7("TARGET_NOT_FOUND", `trackChanges.decide: ${side} replacement side was not found.`);
360035
+ }
360036
+ return this.runDecideWithTargets(decision, [{ rsid, fragments }], logical, options);
359781
360037
  }
359782
360038
  buildTextTargetForLogicalRange(entry, raw, input) {
359783
360039
  const fragment4 = selectFragmentForLogicalRange(entry, input.side);
@@ -359988,8 +360244,13 @@ class V2TrackedChangesAdapter {
359988
360244
  return buildCachedTrackedChangeLogicalView(this.context);
359989
360245
  }
359990
360246
  }
359991
- function textFragmentSelectorsForRsid(entry, rsid) {
359992
- return entry.fragments.filter((fragment4) => fragment4.rsid === rsid).map((fragment4) => ({
360247
+ function replacementSidePairingFailure(entry) {
360248
+ if (!entry.textboxAlternateContentPairing)
360249
+ return null;
360250
+ return failure7("CAPABILITY_UNAVAILABLE", "trackChanges.decide: a mirrored text-box replacement cannot be decided by side without risking divergent representations.");
360251
+ }
360252
+ function textFragmentSelectorsForRsid(entry, rsid, kind) {
360253
+ return entry.fragments.filter((fragment4) => fragment4.rsid === rsid && (!kind || fragment4.kind === kind)).map((fragment4) => ({
359993
360254
  partUri: fragment4.partUri,
359994
360255
  byteStart: fragment4.byteStart,
359995
360256
  byteEnd: fragment4.byteEnd
@@ -369913,7 +370174,8 @@ function createV2AdapterContext(session, options = {}) {
369913
370174
  return {
369914
370175
  tx: beginSDDocumentSessionInternalTransaction(session, {
369915
370176
  expectedPackageRevision: currentInternal,
369916
- actorTag: humanActorScope.current()
370177
+ actorTag: humanActorScope.current(),
370178
+ ...options2?.author ? { authorOverride: { name: options2.author.name } } : {}
369917
370179
  })
369918
370180
  };
369919
370181
  },
@@ -397683,6 +397945,14 @@ function buildAssertOutcome(compiled) {
397683
397945
  };
397684
397946
  }
397685
397947
  function validatePlanShape(input) {
397948
+ if (Object.prototype.hasOwnProperty.call(input, "author")) {
397949
+ throw new DocumentApiValidationError2("INVALID_INPUT", "Mutation plans do not support per-call author.");
397950
+ }
397951
+ for (const step3 of Array.isArray(input.steps) ? input.steps : []) {
397952
+ if (hasPlanAuthor(step3)) {
397953
+ throw new DocumentApiValidationError2("INVALID_INPUT", "Mutation plan steps do not support per-call author.");
397954
+ }
397955
+ }
397686
397956
  if ("dryRun" in input) {
397687
397957
  throw new DocumentApiValidationError2("INVALID_INPUT", "Mutation plans do not accept dryRun; use mutations.preview.");
397688
397958
  }
@@ -397696,6 +397966,23 @@ function validatePlanShape(input) {
397696
397966
  throw new DocumentApiValidationError2("INVALID_INPUT", 'changeMode must be "direct" or "tracked".');
397697
397967
  }
397698
397968
  }
397969
+ function hasPlanAuthor(value2) {
397970
+ const pending = [value2];
397971
+ const visited = new Set;
397972
+ while (pending.length > 0) {
397973
+ const current = pending.pop();
397974
+ if (!current || typeof current !== "object" || visited.has(current))
397975
+ continue;
397976
+ visited.add(current);
397977
+ if (Object.prototype.hasOwnProperty.call(current, "author"))
397978
+ return true;
397979
+ if (Array.isArray(current))
397980
+ pending.push(...current);
397981
+ else
397982
+ pending.push(...Object.values(current));
397983
+ }
397984
+ return false;
397985
+ }
397699
397986
  function isSupportedMutationStoryScope(story) {
397700
397987
  return !story || story.kind === "story" && story.storyType === "body";
397701
397988
  }
@@ -398158,6 +398445,9 @@ class V2WriteAdapter {
398158
398445
  }
398159
398446
  const controlPayload = buildControlPayloadPlan(request.text);
398160
398447
  if (controlPayload) {
398448
+ if (options && "author" in options) {
398449
+ return failWithoutResolution("INVALID_INPUT", "Per-call author is not supported for structural control-payload inserts.");
398450
+ }
398161
398451
  const committed = rewriteAnchorParagraphWithControlPayload(this.context, anchor.storyId, anchor.blockId, controlPayload, options?.expectedRevision);
398162
398452
  if (!committed.ok) {
398163
398453
  return {
@@ -398173,7 +398463,7 @@ class V2WriteAdapter {
398173
398463
  resolution
398174
398464
  };
398175
398465
  }
398176
- const begun = this.context.beginMutation({ expectedRevision: options?.expectedRevision });
398466
+ const begun = this.context.beginMutation({ expectedRevision: options?.expectedRevision, author: "author" in (options ?? {}) ? options.author : undefined });
398177
398467
  if ("failure" in begun) {
398178
398468
  return {
398179
398469
  success: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.7.0-next.10",
3
+ "version": "1.7.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.20.0-next.10",
27
+ "@superdoc/sdk": "2.20.0-next.12",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.23.0-next.10",
33
- "@superdoc/docx-engine": "0.22.0-next.10",
32
+ "superdoc": "2.23.0-next.12",
33
+ "@superdoc/docx-engine": "0.22.0-next.12",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",