@superdoc/mcp 1.2.0-next.5 → 1.2.0-next.7

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 +60 -15
  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.15.0-next.5";
31317
+ var SDK_VERSION = "2.15.0-next.7";
31318
31318
 
31319
31319
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
31320
31320
  import { chmodSync, existsSync } from "node:fs";
@@ -134122,6 +134122,13 @@ function parseDirectRunSequence(xml, allowRevisions) {
134122
134122
  originalText += value;
134123
134123
  }
134124
134124
  };
134125
+ const isProofingBoundary = (tag) => {
134126
+ if (tag.uri !== W_NS || tag.local !== "proofErr" || !tag.isSelfClosing)
134127
+ return false;
134128
+ const attributes = Object.values(tag.attributes);
134129
+ const typeAttributes = attributes.filter((attribute) => typeof attribute !== "string" && attribute.uri === W_NS && attribute.local === "type");
134130
+ return typeAttributes.length === 1 && typeof typeAttributes[0] !== "string" && PROOFING_BOUNDARY_TYPES.has(typeAttributes[0].value) && attributes.every((attribute) => typeof attribute !== "string" && (attribute === typeAttributes[0] || attribute.uri === "http://www.w3.org/2000/xmlns/" && (attribute.local === tag.prefix || attribute.local === "w" || tag.prefix === "" && attribute.local === "xmlns") && attribute.value === W_NS));
134131
+ };
134125
134132
  const parser = new import_saxes3.SaxesParser({
134126
134133
  xmlns: true,
134127
134134
  additionalNamespaces: replayAdditionalNamespaces(xml)
@@ -134138,6 +134145,10 @@ function parseDirectRunSequence(xml, allowRevisions) {
134138
134145
  return;
134139
134146
  }
134140
134147
  if (parent === "wrapper") {
134148
+ if (isProofingBoundary(tag)) {
134149
+ stack.push("control");
134150
+ return;
134151
+ }
134141
134152
  rootCount += 1;
134142
134153
  if (tag.uri === W_NS && tag.local === "r") {
134143
134154
  stack.push("run");
@@ -134168,6 +134179,10 @@ function parseDirectRunSequence(xml, allowRevisions) {
134168
134179
  return;
134169
134180
  }
134170
134181
  if (parent === "revision") {
134182
+ if (isProofingBoundary(tag)) {
134183
+ stack.push("control");
134184
+ return;
134185
+ }
134171
134186
  if (tag.uri !== W_NS || tag.local !== "r")
134172
134187
  valid = false;
134173
134188
  activeRevisionRunCount += 1;
@@ -134598,7 +134613,7 @@ function validateRunContents(xml, options) {
134598
134613
  if (withoutBookmarks === null || UNSUPPORTED_XML.test(withoutBookmarks) || RELATIONSHIP_REFERENCE.test(withoutBookmarks)) {
134599
134614
  return { ok: false, reason: "target runs require unsupported structural or relationship replay" };
134600
134615
  }
134601
- const namespaceResult = validateReplayNamespaces(withoutBookmarks, "target runs use namespace prefixes that cannot be replayed safely");
134616
+ const namespaceResult = validateReplayNamespaces(withoutBookmarks.replace(PROOFING_BOUNDARY_TAG_RE, ""), "target runs use namespace prefixes that cannot be replayed safely");
134602
134617
  if (!namespaceResult.ok)
134603
134618
  return namespaceResult;
134604
134619
  if (!parseDirectRunSequence(withoutBookmarks, false)) {
@@ -134625,7 +134640,7 @@ function validateCompareReplayPayload(payload, options = {}) {
134625
134640
  if (payload.targetRevisionReplay.policy !== "preserve-target-revision-set" || payload.targetRunXml === undefined) {
134626
134641
  return { ok: false, reason: "target revision replay policy is incomplete" };
134627
134642
  }
134628
- const namespaceResult = validateReplayNamespaces(payload.targetRunXml, "target revision runs use namespace prefixes that cannot be replayed safely");
134643
+ const namespaceResult = validateReplayNamespaces(payload.targetRunXml.replace(PROOFING_BOUNDARY_TAG_RE, ""), "target revision runs use namespace prefixes that cannot be replayed safely");
134629
134644
  if (!namespaceResult.ok)
134630
134645
  return namespaceResult;
134631
134646
  const inspected = inspectDirectParagraphRevisionRuns(payload.targetRunXml);
@@ -134645,12 +134660,14 @@ function validateCompareReplayPayload(payload, options = {}) {
134645
134660
  }
134646
134661
  return { ok: true };
134647
134662
  }
134648
- var import_saxes3, UNSUPPORTED_XML, RELATIONSHIP_REFERENCE, W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", DIRECT_RUN_PROPERTY_ELEMENTS;
134663
+ var import_saxes3, UNSUPPORTED_XML, RELATIONSHIP_REFERENCE, W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", PROOFING_BOUNDARY_TYPES, PROOFING_BOUNDARY_TAG_RE, DIRECT_RUN_PROPERTY_ELEMENTS;
134649
134664
  var init_replayability = __esm(() => {
134650
134665
  init_note_xml_validation();
134651
134666
  import_saxes3 = __toESM(require_saxes(), 1);
134652
134667
  UNSUPPORTED_XML = /<(?:[\w.-]+:)?(?:hyperlink|drawing|pict|object|fldSimple|fldChar|instrText|commentReference|commentRangeStart|commentRangeEnd|permStart|permEnd|sdt|customXml|oMath|oMathPara|footnoteReference|endnoteReference|ins|del|moveFrom|moveTo|pPrChange|rPrChange|sectPr)\b/i;
134653
134668
  RELATIONSHIP_REFERENCE = /\s(?:r:id|r:embed|r:link)\s*=/i;
134669
+ PROOFING_BOUNDARY_TYPES = new Set(["spellStart", "spellEnd", "gramStart", "gramEnd"]);
134670
+ PROOFING_BOUNDARY_TAG_RE = /<(?:[A-Za-z_][\w.-]*:)?proofErr\b(?:[^>"']|"[^"]*"|'[^']*')*\/>/g;
134654
134671
  DIRECT_RUN_PROPERTY_ELEMENTS = new Set([
134655
134672
  "rStyle",
134656
134673
  "rFonts",
@@ -134790,7 +134807,10 @@ function canonicalName(namespace, localName2) {
134790
134807
  }
134791
134808
  function computeRunSignature(runXml) {
134792
134809
  const canonicalXml = canonicalizeXmlForSignature(runXml);
134793
- const normalized = normalizeRunXmlForSignature(canonicalXml.replace(REVISION_ATTR_RE, "").replace(COMMENT_MARKUP_RE, (markup, name, attributes) => isWordprocessingElement3(name, attributes, canonicalXml) ? "" : markup).replace(NOTE_REFERENCE_MARKUP_RE, (markup, runName, runAttributes, _rPrName, nestedName, nestedAttributes, standaloneName, standaloneAttributes) => {
134810
+ const normalized = normalizeRunXmlForSignature(canonicalXml.replace(REVISION_ATTR_RE, (attribute, offset, xml) => {
134811
+ const precedingTag = xml.slice(xml.lastIndexOf("<", offset), offset);
134812
+ return /^<w:proofErr(?:\s|$)/.test(precedingTag) ? attribute : "";
134813
+ }).replace(REVISION_ELEMENT_RE, (markup) => markup.replace(REVISION_ID_ATTR_RE, "")).replace(COMMENT_MARKUP_RE, (markup, name, attributes) => isWordprocessingElement3(name, attributes, canonicalXml) ? "" : markup).replace(NOTE_REFERENCE_MARKUP_RE, (markup, runName, runAttributes, _rPrName, nestedName, nestedAttributes, standaloneName, standaloneAttributes) => {
134794
134814
  const name = nestedName ?? standaloneName;
134795
134815
  const attributes = nestedAttributes ?? standaloneAttributes;
134796
134816
  if (!isWordprocessingElement3(name, attributes, canonicalXml))
@@ -134817,7 +134837,7 @@ function normalizeRunXmlForSignature(runXml) {
134817
134837
  continue;
134818
134838
  const index = match.index ?? 0;
134819
134839
  if (index > lastIndex) {
134820
- const interstitial = runXml.slice(lastIndex, index);
134840
+ const interstitial = stripProofingBoundaries(runXml.slice(lastIndex, index));
134821
134841
  if (interstitial.trim().length > 0) {
134822
134842
  pieces.push(interstitial);
134823
134843
  activeTextProperties = "";
@@ -134846,12 +134866,15 @@ function normalizeRunXmlForSignature(runXml) {
134846
134866
  if (!sawRun)
134847
134867
  return runXml;
134848
134868
  if (lastIndex < runXml.length) {
134849
- const trailing = runXml.slice(lastIndex);
134869
+ const trailing = stripProofingBoundaries(runXml.slice(lastIndex));
134850
134870
  if (trailing.trim().length > 0)
134851
134871
  pieces.push(trailing);
134852
134872
  }
134853
134873
  return pieces.join("");
134854
134874
  }
134875
+ function stripProofingBoundaries(xml) {
134876
+ return xml.replace(PROOFING_BOUNDARY_MARKUP_RE, "");
134877
+ }
134855
134878
  function normalizeRunControls(content, namespaceContext) {
134856
134879
  return [...content.matchAll(RUN_CONTROL_RE)].filter((match) => isWordprocessingElement3(match[1], match[3], namespaceContext)).map((match) => {
134857
134880
  const attributes = [...match[3].matchAll(ATTRIBUTE_RE)].filter((attribute) => attribute[1] !== "xmlns" && !attribute[1].startsWith("xmlns:")).map((attribute) => {
@@ -134884,10 +134907,13 @@ function isWordprocessingElement3(name, attributes, namespaceContext) {
134884
134907
  return true;
134885
134908
  return (declaration[2] ?? declaration[3] ?? "") === WORDPROCESSINGML_NAMESPACE2;
134886
134909
  }
134887
- var REVISION_ATTR_RE, COMMENT_MARKUP_RE, NOTE_REFERENCE_MARKUP_RE, RUN_RE, RUN_PROPERTIES_RE, EMPTY_RUN_PROPERTIES_RE, TEXTISH_RE, RUN_CONTROL_RE, ATTRIBUTE_RE, WORDPROCESSINGML_NAMESPACE2 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", WORDPROCESSINGML_2010_NAMESPACE = "http://schemas.microsoft.com/office/word/2010/wordml", MARKUP_COMPATIBILITY_NAMESPACE = "http://schemas.openxmlformats.org/markup-compatibility/2006", XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace", XML_TAG_RE;
134910
+ var REVISION_ATTR_RE, REVISION_ELEMENT_RE, REVISION_ID_ATTR_RE, COMMENT_MARKUP_RE, PROOFING_BOUNDARY_MARKUP_RE, NOTE_REFERENCE_MARKUP_RE, RUN_RE, RUN_PROPERTIES_RE, EMPTY_RUN_PROPERTIES_RE, TEXTISH_RE, RUN_CONTROL_RE, ATTRIBUTE_RE, WORDPROCESSINGML_NAMESPACE2 = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", WORDPROCESSINGML_2010_NAMESPACE = "http://schemas.microsoft.com/office/word/2010/wordml", MARKUP_COMPATIBILITY_NAMESPACE = "http://schemas.openxmlformats.org/markup-compatibility/2006", XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace", XML_TAG_RE;
134888
134911
  var init_run_signature = __esm(() => {
134889
- REVISION_ATTR_RE = /\s+(?:w:rsid\w*|w14:paraId|w14:textId|w:id)="[^"]*"/g;
134912
+ REVISION_ATTR_RE = /\s+(?:w:rsid\w*|w14:paraId|w14:textId)="[^"]*"/g;
134913
+ REVISION_ELEMENT_RE = /<w:(?:ins|del|moveFrom|moveTo)\b[^>]*>/g;
134914
+ REVISION_ID_ATTR_RE = /\s+w:id="[^"]*"/g;
134890
134915
  COMMENT_MARKUP_RE = /<((?:[\w.-]+:)?(?:commentRangeStart|commentRangeEnd|commentReference))\b([^>]*)\/>/g;
134916
+ PROOFING_BOUNDARY_MARKUP_RE = /<w:proofErr w:type="(?:spellStart|spellEnd|gramStart|gramEnd)"\/>/g;
134891
134917
  NOTE_REFERENCE_MARKUP_RE = /<((?:[\w.-]+:)?r)\b([^>]*)>(?:<((?:[\w.-]+:)?rPr)\b[^>]*(?:\/>|>[\s\S]*?<\/\3>))?<((?:[\w.-]+:)?(?:footnoteReference|endnoteReference))\b([^>]*)\/><\/\1>|<((?:[\w.-]+:)?(?:footnoteReference|endnoteReference))\b([^>]*)\/>/g;
134892
134918
  RUN_RE = /<((?:[\w.-]+:)?r)\b([^>]*)>([\s\S]*?)<\/\1>/g;
134893
134919
  RUN_PROPERTIES_RE = /<((?:[\w.-]+:)?rPr)\b([^>]*)(?:\/>|>[\s\S]*?<\/\1>)/g;
@@ -219993,15 +220019,31 @@ function canonicalizeCompareBodyRunXml(xml, referenceSteps) {
219993
220019
  let result = "";
219994
220020
  let cursor = 0;
219995
220021
  for (const token of tokens) {
219996
- const canonicalGap = canonicalizeWordprocessingReplayXml(xml.slice(cursor, token.start));
220022
+ const canonicalGap = canonicalizeProofingRunGap(xml.slice(cursor, token.start));
219997
220023
  if (canonicalGap === null)
219998
220024
  return null;
219999
220025
  result += canonicalGap + token.xml;
220000
220026
  cursor = token.end;
220001
220027
  }
220002
- const canonicalTail = canonicalizeWordprocessingReplayXml(xml.slice(cursor));
220028
+ const canonicalTail = canonicalizeProofingRunGap(xml.slice(cursor));
220003
220029
  return canonicalTail === null ? null : result + canonicalTail;
220004
220030
  }
220031
+ function canonicalizeProofingRunGap(xml) {
220032
+ const markerRe = /<(?:[A-Za-z_][\w.-]*:)?proofErr\b(?:[^>"']|"[^"]*"|'[^']*')*\/>/g;
220033
+ let result = "";
220034
+ let cursor = 0;
220035
+ for (const marker of xml.matchAll(markerRe)) {
220036
+ const index = marker.index ?? 0;
220037
+ const before = canonicalizeWordprocessingReplayXml(xml.slice(cursor, index));
220038
+ const canonicalMarker = canonicalizeWordprocessingReplayXml(marker[0]);
220039
+ if (before === null || canonicalMarker === null)
220040
+ return null;
220041
+ result += before + canonicalMarker;
220042
+ cursor = index + marker[0].length;
220043
+ }
220044
+ const trailing = canonicalizeWordprocessingReplayXml(xml.slice(cursor));
220045
+ return trailing === null ? null : result + trailing;
220046
+ }
220005
220047
  function collectProtectedReferenceTokens(xml, referenceSteps) {
220006
220048
  const tokens = [];
220007
220049
  for (let index = 0;index < referenceSteps.length; index += 1) {
@@ -239472,7 +239514,7 @@ function toRoman(ordinal) {
239472
239514
  }
239473
239515
  function extractParagraphText(paraXml) {
239474
239516
  let out = "";
239475
- for (const match of paraXml.matchAll(/<[\w.-]+:t\b[^>]*>([\s\S]*?)<\/[\w.-]+:t>/g)) {
239517
+ for (const match of paraXml.matchAll(/<[\w.-]+:t\b[^>]*?(?<!\/)>([\s\S]*?)<\/[\w.-]+:t>/g)) {
239476
239518
  out += decodeXmlText(match[1] ?? "");
239477
239519
  }
239478
239520
  return out;
@@ -393882,6 +393924,7 @@ function createHocuspocusSingleDocAdapter(config2) {
393882
393924
  token: typeof config2.token === "string" || config2.token == null ? config2.token ?? null : config2.token,
393883
393925
  parameters: config2.params ?? {},
393884
393926
  preserveConnection: false,
393927
+ broadcast: config2.broadcast ?? true,
393885
393928
  quiet: true,
393886
393929
  onSynced() {
393887
393930
  if (!hasSynced) {
@@ -407429,7 +407472,7 @@ function parseRun2(runXml, textTagLocalName = "t", inheritedNamespaceBindings =
407429
407472
  atomKind: INLINE_ATOM_KIND.noteRef,
407430
407473
  id: attrLocal2(next.openTagInner, "id"),
407431
407474
  xml: next.xml,
407432
- meta: { kind: local },
407475
+ meta: { kind: local, runAttributes: attributes },
407433
407476
  visibleLength: 0
407434
407477
  });
407435
407478
  } else if (local === "sym" || local === "noBreakHyphen") {
@@ -407440,7 +407483,7 @@ function parseRun2(runXml, textTagLocalName = "t", inheritedNamespaceBindings =
407440
407483
  atomKind: INLINE_ATOM_KIND.preserved,
407441
407484
  id: null,
407442
407485
  xml: next.xml,
407443
- meta: { tag: local, container: "run-child" },
407486
+ meta: { tag: local, container: "run-child", runAttributes: attributes },
407444
407487
  visibleLength: 0
407445
407488
  });
407446
407489
  }
@@ -420672,7 +420715,9 @@ function serializeBlockXml(block, extraAtoms = [], context = { inherited: CANONI
420672
420715
  const atomXml = atom.kind === "synthetic-comment-marker" ? `<${w}:${atom.meta.marker} ${w}:id="${xmlEscape(String(atom.meta.commentId))}"/>` : atom.xml;
420673
420716
  const attributedBreakXml = runBackedAttributedBreakXml(atom);
420674
420717
  if (atomEmissionMode(atom) === "run-child") {
420675
- sb.push(serializeInlineRunAtom(attributedBreakXml ?? atomXml, runAttributes, w));
420718
+ const atomRunAttributes = atom.meta.runAttributes;
420719
+ const attributes = atomRunAttributes && typeof atomRunAttributes === "object" && !Array.isArray(atomRunAttributes) ? atomRunAttributes : runAttributes;
420720
+ sb.push(serializeInlineRunAtom(attributedBreakXml ?? atomXml, attributes, w));
420676
420721
  } else {
420677
420722
  sb.push(atomXml);
420678
420723
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.2.0-next.5",
3
+ "version": "1.2.0-next.7",
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.15.0-next.5",
27
+ "@superdoc/sdk": "2.15.0-next.7",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },
31
31
  "devDependencies": {
32
- "superdoc": "2.18.0-next.5",
33
- "@superdoc/docx-engine": "0.17.0-next.6",
32
+ "superdoc": "2.18.0-next.7",
33
+ "@superdoc/docx-engine": "0.17.0-next.8",
34
34
  "@superdoc/document-api": "0.1.0-alpha.0",
35
35
  "@types/bun": "^1.3.8",
36
36
  "@types/node": "22.19.2",