@superdoc/mcp 1.10.1-next.2 → 1.10.1-next.3
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.
- package/dist/index.js +143 -17
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -31630,7 +31630,7 @@ var init_host = __esm(() => {
|
|
|
31630
31630
|
});
|
|
31631
31631
|
|
|
31632
31632
|
// ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
|
|
31633
|
-
var SDK_VERSION = "2.23.1-next.
|
|
31633
|
+
var SDK_VERSION = "2.23.1-next.3";
|
|
31634
31634
|
|
|
31635
31635
|
// ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
|
|
31636
31636
|
import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
|
|
@@ -182170,6 +182170,14 @@ function readResidentParagraphNamespaces(state, blockId) {
|
|
|
182170
182170
|
return null;
|
|
182171
182171
|
return store.paragraphs.get(blockId)?.namespaceBindings ?? store.readOnlyNamespaces.get(blockId)?.namespaceBindings ?? null;
|
|
182172
182172
|
}
|
|
182173
|
+
function readResidentParagraphNamespaceScope(state, blockId) {
|
|
182174
|
+
const namespaceBindings = readResidentParagraphNamespaces(state, blockId);
|
|
182175
|
+
if (!namespaceBindings)
|
|
182176
|
+
return null;
|
|
182177
|
+
const store = stores.get(state);
|
|
182178
|
+
const parentNamespaceBindings = store.paragraphs.get(blockId)?.parentNamespaceBindings ?? store.readOnlyNamespaces.get(blockId)?.parentNamespaceBindings;
|
|
182179
|
+
return parentNamespaceBindings ? Object.freeze({ namespaceBindings, parentNamespaceBindings }) : null;
|
|
182180
|
+
}
|
|
182173
182181
|
function prepareResidentParagraphOwnershipPublication(state, group) {
|
|
182174
182182
|
const store = stores.get(state);
|
|
182175
182183
|
if (!store)
|
|
@@ -196568,7 +196576,7 @@ function resolveEditScope(pieces, start, end, collapsedInlineAffinity, collapsed
|
|
|
196568
196576
|
let emptySdt;
|
|
196569
196577
|
let requiresCollaborationSessionSync = false;
|
|
196570
196578
|
for (;; ) {
|
|
196571
|
-
const container = current.find((piece) => piece.kind === "container" && containerContainsRange(piece, start, end))
|
|
196579
|
+
const container = start === end ? findCaretContainer(current, start, collapsedInlineAffinity, collapsedOutsideContentControl) : current.find((piece) => piece.kind === "container" && containerContainsRange(piece, start, end));
|
|
196572
196580
|
if (!container) {
|
|
196573
196581
|
if (start === end) {
|
|
196574
196582
|
return {
|
|
@@ -196671,6 +196679,9 @@ function containerContainsRange(piece, start, end) {
|
|
|
196671
196679
|
return piece.visibleStart < start && start < piece.visibleEnd;
|
|
196672
196680
|
return piece.visibleStart <= start && end <= piece.visibleEnd;
|
|
196673
196681
|
}
|
|
196682
|
+
function findCaretContainer(pieces, at, collapsedInlineAffinity, collapsedOutsideContentControl = false) {
|
|
196683
|
+
return pieces.find((piece) => piece.kind === "container" && containerContainsRange(piece, at, at)) ?? findCollapsedEdgeContainer(pieces, at, collapsedInlineAffinity, collapsedOutsideContentControl);
|
|
196684
|
+
}
|
|
196674
196685
|
function findCollapsedEdgeContainer(pieces, at, collapsedInlineAffinity, collapsedOutsideContentControl = false) {
|
|
196675
196686
|
const emptySdtsAtPoint = pieces.filter((piece) => piece.kind === "container" && piece.containerKind === "sdt" && piece.visibleStart === at && piece.visibleEnd === at);
|
|
196676
196687
|
return pieces.find((piece) => {
|
|
@@ -221834,13 +221845,57 @@ function resolveCaretRunPropertiesForInsertion(paragraphXml, charOffset, inherit
|
|
|
221834
221845
|
}
|
|
221835
221846
|
return cloneAdjacentRunPropertiesForInsert(paragraphXml, "before", paragraphMarkRunPropertiesXml, inheritedNamespaceBindings, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary);
|
|
221836
221847
|
}
|
|
221837
|
-
function
|
|
221848
|
+
function readCaretRunProperties(paragraphXml, charOffset, inheritedNamespaceBindings = {}, collapsedInlineAffinity, collapsedObjectBoundary) {
|
|
221849
|
+
const sourceXml = stripElements(paragraphXml, "txbxContent");
|
|
221850
|
+
const model = parseParagraphInlineMap(sourceXml, inheritedNamespaceBindings);
|
|
221851
|
+
let source;
|
|
221852
|
+
let properties2;
|
|
221853
|
+
if (!collapsedObjectBoundary && (model.visibleLength === 0 || collapsedOutsideContainerAt(model.pieces, charOffset, collapsedInlineAffinity))) {
|
|
221854
|
+
source = findFirstElement(sourceXml, "pPr") ?? undefined;
|
|
221855
|
+
properties2 = source ? extractParagraphMarkRunProperties(source.xml) : "";
|
|
221856
|
+
if (properties2 === null)
|
|
221857
|
+
return { ok: false, reason: "unsupported-context" };
|
|
221858
|
+
} else {
|
|
221859
|
+
let caretPieces = model.pieces;
|
|
221860
|
+
if (!collapsedObjectBoundary) {
|
|
221861
|
+
for (;; ) {
|
|
221862
|
+
const container = findCaretContainer(caretPieces, charOffset, collapsedInlineAffinity);
|
|
221863
|
+
if (!container)
|
|
221864
|
+
break;
|
|
221865
|
+
if (container.policy === "atomic" || container.policy === "fail-closed") {
|
|
221866
|
+
return { ok: false, reason: "unsupported-context" };
|
|
221867
|
+
}
|
|
221868
|
+
caretPieces = container.children;
|
|
221869
|
+
}
|
|
221870
|
+
caretPieces = caretPieces.filter((piece) => piece.kind !== "container" || piece.policy === "fail-closed");
|
|
221871
|
+
}
|
|
221872
|
+
const carrier = adjacentFormattingCarrierRun(sourceXml, "before", inheritedNamespaceBindings, charOffset, undefined, collapsedInlineAffinity, collapsedObjectBoundary, caretPieces);
|
|
221873
|
+
if (!carrier.ok)
|
|
221874
|
+
return carrier;
|
|
221875
|
+
source = carrier.run;
|
|
221876
|
+
properties2 = source ? readRunPropertiesXml(source.xml) : null;
|
|
221877
|
+
}
|
|
221878
|
+
if (!source || !properties2)
|
|
221879
|
+
return { ok: true, runPropertiesXml: null };
|
|
221880
|
+
const node2 = readXmlNodeAt(properties2, 0);
|
|
221881
|
+
if (!node2 || node2.kind !== "element")
|
|
221882
|
+
return { ok: false, reason: "unsupported-context" };
|
|
221883
|
+
if (node2.selfClosing)
|
|
221884
|
+
return { ok: true, runPropertiesXml: null };
|
|
221885
|
+
const namespaces = namespaceSourceForRunProperties(sourceXml, source, properties2, inheritedNamespaceBindings);
|
|
221886
|
+
if (!namespaces || runPropertiesContainForeignRevisionLikeElement(properties2, namespaces.openTag) !== false) {
|
|
221887
|
+
return { ok: false, reason: "unsupported-context" };
|
|
221888
|
+
}
|
|
221889
|
+
const liveProperties = normalizeClonedRunProperties(properties2);
|
|
221890
|
+
return { ok: true, runPropertiesXml: liveProperties ? namespaces.openTag + liveProperties.slice(node2.openEnd) : null };
|
|
221891
|
+
}
|
|
221892
|
+
function adjacentFormattingCarrierRun(paragraphXml, placement2, inheritedNamespaceBindings = {}, charOffset, replaceToOffset, collapsedInlineAffinity, collapsedObjectBoundary, resolvedPieces) {
|
|
221838
221893
|
const paragraphPrefix = /^<(?:(?<prefix>[\w.-]+):)?p\b/.exec(paragraphXml)?.groups?.prefix ?? "";
|
|
221839
221894
|
const additionalNamespaces = xmlFragmentAdditionalNamespaces(paragraphXml, new Map(Object.entries(inheritedNamespaceBindings)), { w: NS_W, [paragraphPrefix]: NS_W });
|
|
221840
221895
|
const parsed = collectXmlElementRanges(paragraphXml, { additionalNamespaces });
|
|
221841
221896
|
if (parsed.errors.length > 0)
|
|
221842
221897
|
return { ok: true, run: undefined };
|
|
221843
|
-
const pieces = parseParagraphInlineMap(paragraphXml, inheritedNamespaceBindings).pieces;
|
|
221898
|
+
const pieces = resolvedPieces ?? parseParagraphInlineMap(paragraphXml, inheritedNamespaceBindings).pieces;
|
|
221844
221899
|
const downstream = charOffset !== undefined && (replaceToOffset ?? charOffset) === charOffset && collapsedInlineAffinity === "downstream" ? findDownstreamVisibleCarrierAfterHiddenRun(paragraphXml, pieces, charOffset, inheritedNamespaceBindings) : null;
|
|
221845
221900
|
const carrier = collapsedObjectBoundary && charOffset !== undefined ? { ok: true, piece: visibleTextBesideObjectAt(pieces, charOffset, collapsedObjectBoundary) ?? undefined } : downstream ? { ok: true, piece: downstream } : charOffset === undefined ? adjacentFormattingCarrierPiece(pieces, placement2) : formattingCarrierPieceAtOffset(pieces, charOffset, replaceToOffset);
|
|
221846
221901
|
if (!carrier.ok)
|
|
@@ -281365,6 +281420,74 @@ function getSDDocumentSessionInternalMainRelationshipsPartUri(session) {
|
|
|
281365
281420
|
throw new Error("internal: unknown SDDocumentSession instance");
|
|
281366
281421
|
return internal.state.mainStoryId ? relsUriFor(storyPartUriFromStoryId(internal.state.mainStoryId)) : null;
|
|
281367
281422
|
}
|
|
281423
|
+
function readSDDocumentSessionInternalParagraphNamespaceScope(session, storyId, blockId, storyByteRange) {
|
|
281424
|
+
const internal = INTERNALS.get(session);
|
|
281425
|
+
if (!internal)
|
|
281426
|
+
throw new Error("internal: unknown SDDocumentSession instance");
|
|
281427
|
+
const state = internal.state;
|
|
281428
|
+
const index = getStoryParagraphIndexFromState(state, storyId);
|
|
281429
|
+
const candidates = storyByteRange ? index?.entries.filter((entry2) => entry2.blockId === blockId && entry2.byteStart >= storyByteRange[0] && entry2.byteEnd <= storyByteRange[1]) : null;
|
|
281430
|
+
const entry = candidates ? candidates.length === 1 ? candidates[0] : null : index?.byParaId(blockId);
|
|
281431
|
+
if (!entry || !storyByteRange && index.duplicateParaIds.has(blockId))
|
|
281432
|
+
return null;
|
|
281433
|
+
const canonical = !storyByteRange ? peekSDCanonicalResidentParagraph(state, storyId, blockId) : null;
|
|
281434
|
+
if (canonical)
|
|
281435
|
+
return canonical.scope;
|
|
281436
|
+
const ownership = storyId === state.mainStoryId ? readResidentParagraphOwnership(state, blockId) : null;
|
|
281437
|
+
let scope = ownership ? Object.freeze({
|
|
281438
|
+
namespaceBindings: ownership.namespaceBindings,
|
|
281439
|
+
parentNamespaceBindings: ownership.parentNamespaceBindings
|
|
281440
|
+
}) : storyId === state.mainStoryId ? readResidentParagraphNamespaceScope(state, blockId) : null;
|
|
281441
|
+
if (!ownership && entry.hasNonEditableBlockSdtContent && storyId === state.mainStoryId) {
|
|
281442
|
+
const namespaces = readResidentParagraphNamespaces(state, blockId);
|
|
281443
|
+
if (namespaces) {
|
|
281444
|
+
return { namespaceBindings: namespaces, parentNamespaceBindings: namespaces };
|
|
281445
|
+
}
|
|
281446
|
+
}
|
|
281447
|
+
let cached2 = state.paragraphNamespaceCache.get(entry.partUri);
|
|
281448
|
+
if (cached2?.revision !== entry.partRevision) {
|
|
281449
|
+
cached2 = { revision: entry.partRevision, bindingsByByteStart: new Map };
|
|
281450
|
+
state.paragraphNamespaceCache.set(entry.partUri, cached2);
|
|
281451
|
+
}
|
|
281452
|
+
scope ?? (scope = cached2.bindingsByByteStart.get(entry.byteStart) ?? null);
|
|
281453
|
+
if (!scope) {
|
|
281454
|
+
const prefix2 = readPartRangeFromStateSync(state, entry.partUri, 0, entry.byteEnd);
|
|
281455
|
+
if (!prefix2)
|
|
281456
|
+
return null;
|
|
281457
|
+
const xml = new TextDecoder().decode(prefix2);
|
|
281458
|
+
const expectedStart = new TextDecoder().decode(prefix2.subarray(0, entry.byteStart)).length;
|
|
281459
|
+
const parser = createXmlSaxParser({ namespaceAware: true, position: true });
|
|
281460
|
+
const namespaceStack = [CANONICAL_XML_EMPTY_NAMESPACE_BINDINGS];
|
|
281461
|
+
let malformed2 = false;
|
|
281462
|
+
parser.on("error", () => {
|
|
281463
|
+
malformed2 = true;
|
|
281464
|
+
});
|
|
281465
|
+
parser.on("opentag", (tag) => {
|
|
281466
|
+
const parentNamespaceBindings = namespaceStack[namespaceStack.length - 1];
|
|
281467
|
+
const namespaceBindings = Object.keys(tag.namespaceBindings).length > 0 ? { ...parentNamespaceBindings, ...tag.namespaceBindings } : parentNamespaceBindings;
|
|
281468
|
+
namespaceStack.push(namespaceBindings);
|
|
281469
|
+
if (scope || malformed2 || tag.localName !== "p" || tag.namespaceUri !== NS_W)
|
|
281470
|
+
return;
|
|
281471
|
+
const charStart = xml.lastIndexOf("<", parser.position - 1);
|
|
281472
|
+
if (charStart === expectedStart)
|
|
281473
|
+
scope = Object.freeze({
|
|
281474
|
+
namespaceBindings: createCanonicalXmlNamespaceBindings(Object.entries(namespaceBindings)),
|
|
281475
|
+
parentNamespaceBindings: createCanonicalXmlNamespaceBindings(Object.entries(parentNamespaceBindings))
|
|
281476
|
+
});
|
|
281477
|
+
});
|
|
281478
|
+
parser.on("closetag", () => {
|
|
281479
|
+
if (namespaceStack.length > 1)
|
|
281480
|
+
namespaceStack.pop();
|
|
281481
|
+
});
|
|
281482
|
+
parser.write(xml);
|
|
281483
|
+
if (!scope)
|
|
281484
|
+
return null;
|
|
281485
|
+
if (cached2.bindingsByByteStart.size >= 2048)
|
|
281486
|
+
cached2.bindingsByByteStart.clear();
|
|
281487
|
+
cached2.bindingsByByteStart.set(entry.byteStart, scope);
|
|
281488
|
+
}
|
|
281489
|
+
return scope;
|
|
281490
|
+
}
|
|
281368
281491
|
function getSDDocumentSessionInternalResidentMainStructureIdentity(session) {
|
|
281369
281492
|
const internal = INTERNALS.get(session);
|
|
281370
281493
|
if (!internal)
|
|
@@ -286295,6 +286418,7 @@ var init_sd_document_session = __esm(() => {
|
|
|
286295
286418
|
init_hyperlink_catalog();
|
|
286296
286419
|
init_field_catalog();
|
|
286297
286420
|
init_remote_paragraph_publication();
|
|
286421
|
+
init_xml_sax();
|
|
286298
286422
|
init_revision_id_export();
|
|
286299
286423
|
init_resident_review();
|
|
286300
286424
|
init_canonical_xml_analysis_frame();
|
|
@@ -287719,6 +287843,7 @@ var init_sd_document_session_internal = __esm(() => {
|
|
|
287719
287843
|
init_paragraph_inline_model();
|
|
287720
287844
|
init_simple_text_run_split();
|
|
287721
287845
|
init_compile_edit_text_inline_plan();
|
|
287846
|
+
init_insertion_formatting_context();
|
|
287722
287847
|
init_compile_edit_text();
|
|
287723
287848
|
init_tracked_inline_replacement();
|
|
287724
287849
|
init_tracked_paragraph_content();
|
|
@@ -372378,8 +372503,13 @@ async function readAttempt(context, input, readState) {
|
|
|
372378
372503
|
const paragraph3 = first ? await loadParagraph(context, first, model, resolveTableInfo, readState, collapsed ? input.pendingInline : undefined) : null;
|
|
372379
372504
|
if (!paragraph3)
|
|
372380
372505
|
recordAll("source-unavailable");
|
|
372381
|
-
else
|
|
372382
|
-
|
|
372506
|
+
else {
|
|
372507
|
+
const run = paragraph3.runAtCaret(first.startOffset);
|
|
372508
|
+
if (run)
|
|
372509
|
+
record3(run);
|
|
372510
|
+
else
|
|
372511
|
+
recordAll("unsupported-context");
|
|
372512
|
+
}
|
|
372383
372513
|
}
|
|
372384
372514
|
const properties2 = {};
|
|
372385
372515
|
for (const key3 of input.keys) {
|
|
@@ -372410,8 +372540,7 @@ async function loadParagraph(context, range, model, resolveTableInfo, readState,
|
|
|
372410
372540
|
const paragraphMarkFormatsBreakRuns = leaves.length > 0 && leaves.every((leaf) => leaf.kind === "control" && leaf.control !== "tab");
|
|
372411
372541
|
const paragraphMarkRPrXml = extractParagraphMarkRPrXml2(paragraphXml);
|
|
372412
372542
|
const readRun = (runPropertiesXml) => {
|
|
372413
|
-
|
|
372414
|
-
let sourceXml = inheritsMark ? paragraphMarkRPrXml : runPropertiesXml;
|
|
372543
|
+
let sourceXml = runPropertiesXml;
|
|
372415
372544
|
if (pendingInline) {
|
|
372416
372545
|
const patched = applyInlinePatchToRPr2(sourceXml ?? "", pendingInline);
|
|
372417
372546
|
if (patched.ok)
|
|
@@ -372428,7 +372557,6 @@ async function loadParagraph(context, range, model, resolveTableInfo, readState,
|
|
|
372428
372557
|
})
|
|
372429
372558
|
};
|
|
372430
372559
|
};
|
|
372431
|
-
const paragraphMarkRun = () => readRun(paragraphMarkRPrXml);
|
|
372432
372560
|
return {
|
|
372433
372561
|
runsInRange(start, end) {
|
|
372434
372562
|
const seen = new Set;
|
|
@@ -372439,18 +372567,16 @@ async function loadParagraph(context, range, model, resolveTableInfo, readState,
|
|
|
372439
372567
|
if (seen.has(leaf.runCharStart))
|
|
372440
372568
|
continue;
|
|
372441
372569
|
seen.add(leaf.runCharStart);
|
|
372442
|
-
runs.push(readRun(leaf.runProperties));
|
|
372570
|
+
runs.push(readRun(leaf.runProperties ?? (paragraphMarkFormatsBreakRuns ? paragraphMarkRPrXml : null)));
|
|
372443
372571
|
}
|
|
372444
372572
|
return runs;
|
|
372445
372573
|
},
|
|
372446
372574
|
runAtCaret(offset) {
|
|
372447
|
-
|
|
372448
|
-
|
|
372449
|
-
|
|
372450
|
-
|
|
372451
|
-
|
|
372452
|
-
const chosen = before ?? leaves.find((leaf) => leaf.visibleStart >= offset && leaf.visibleEnd > leaf.visibleStart);
|
|
372453
|
-
return chosen ? readRun(chosen.runProperties) : paragraphMarkRun();
|
|
372575
|
+
const scope = readSDDocumentSessionInternalParagraphNamespaceScope(context.session, range.storyId, range.startBlockId);
|
|
372576
|
+
if (!scope)
|
|
372577
|
+
return null;
|
|
372578
|
+
const carrier = readCaretRunProperties(paragraphXml, offset, scope.namespaceBindings, range.collapsedInlineAffinity, range.collapsedObjectBoundary);
|
|
372579
|
+
return carrier.ok ? readRun(carrier.runPropertiesXml) : null;
|
|
372454
372580
|
}
|
|
372455
372581
|
};
|
|
372456
372582
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/mcp",
|
|
3
|
-
"version": "1.10.1-next.
|
|
3
|
+
"version": "1.10.1-next.3",
|
|
4
4
|
"description": "Model Context Protocol server for SuperDoc, giving an AI agent tools to read and edit .docx files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
27
|
-
"@superdoc/sdk": "2.23.1-next.
|
|
27
|
+
"@superdoc/sdk": "2.23.1-next.3",
|
|
28
28
|
"debug": "^4.4.3",
|
|
29
29
|
"zod": "^4.3.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"superdoc": "2.26.1-next.
|
|
33
|
-
"@superdoc/docx-engine": "0.25.1-next.
|
|
32
|
+
"superdoc": "2.26.1-next.3",
|
|
33
|
+
"@superdoc/docx-engine": "0.25.1-next.3",
|
|
34
34
|
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
35
35
|
"@types/bun": "^1.3.8",
|
|
36
36
|
"@types/node": "22.19.2",
|