@superdoc/mcp 1.12.0-next.7 → 1.12.0-next.9
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 +126 -8
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -31651,7 +31651,7 @@ var init_host = __esm(() => {
|
|
|
31651
31651
|
});
|
|
31652
31652
|
|
|
31653
31653
|
// ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
|
|
31654
|
-
var SDK_VERSION = "2.25.0-next.
|
|
31654
|
+
var SDK_VERSION = "2.25.0-next.9";
|
|
31655
31655
|
|
|
31656
31656
|
// ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
|
|
31657
31657
|
import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
|
|
@@ -195393,9 +195393,12 @@ function readContentControlBlockGroups(bytes) {
|
|
|
195393
195393
|
}
|
|
195394
195394
|
return { groups, leadingXml, trailingXml: sliceWithoutWrappers(cursor, container.closeStart) };
|
|
195395
195395
|
}
|
|
195396
|
-
function prepareContentControlRewrite(current, entry) {
|
|
195396
|
+
function prepareContentControlRewrite(current, entry, paragraph) {
|
|
195397
195397
|
if (entry.kind !== "modify")
|
|
195398
195398
|
return null;
|
|
195399
|
+
const localized = paragraph && prepareParagraphContentControlRewrite(current, entry, paragraph);
|
|
195400
|
+
if (localized)
|
|
195401
|
+
return localized;
|
|
195399
195402
|
const normalized = normalizePartPatches([...entry.patches]);
|
|
195400
195403
|
if (!normalized.ok)
|
|
195401
195404
|
return null;
|
|
@@ -195416,6 +195419,40 @@ function prepareContentControlRewrite(current, entry) {
|
|
|
195416
195419
|
trailingXmlChanged: before.trailingXml !== after.trailingXml
|
|
195417
195420
|
};
|
|
195418
195421
|
}
|
|
195422
|
+
function prepareParagraphContentControlRewrite(current, entry, paragraph) {
|
|
195423
|
+
if (entry.kind !== "modify" || entry.patches.length !== 1)
|
|
195424
|
+
return null;
|
|
195425
|
+
const patch = entry.patches[0];
|
|
195426
|
+
if (patch.kind !== "replaceBytes" || patch.startByte !== paragraph.byteStart || patch.endByte !== paragraph.byteEnd || paragraph.byteStart < 0 || paragraph.byteEnd > current.length || paragraph.byteEnd <= paragraph.byteStart)
|
|
195427
|
+
return null;
|
|
195428
|
+
const beforeXml = TD29.decode(current.subarray(paragraph.byteStart, paragraph.byteEnd));
|
|
195429
|
+
const afterXml = TD29.decode(patch.bytes);
|
|
195430
|
+
const namespaces = namespaceBindingsAtPosition(current, paragraph.byteStart);
|
|
195431
|
+
const capture = (xml) => {
|
|
195432
|
+
const parsed = collectXmlElementRanges(xml, { fragment: true, additionalNamespaces: { ...namespaces } });
|
|
195433
|
+
if (parsed.errors.length)
|
|
195434
|
+
return null;
|
|
195435
|
+
const paragraphs2 = parsed.ranges.filter((range) => range.tag.namespaceUri === W2 && range.tag.localName === "p");
|
|
195436
|
+
const root = paragraphs2[0];
|
|
195437
|
+
if (paragraphs2.length !== 1 || !root || root.start !== 0 || root.end !== xml.length || root.tag.attributes.find((attribute2) => attribute2.namespaceUri === W14 && attribute2.localName === "paraId")?.value !== paragraph.blockId || parsed.ranges.some((range) => range.tag.namespaceUri === W2 && range.tag.localName === "sectPr"))
|
|
195438
|
+
return null;
|
|
195439
|
+
return {
|
|
195440
|
+
open: xml.slice(root.start, root.openEnd),
|
|
195441
|
+
properties: parsed.ranges.filter((range) => range.tag.namespaceUri === W2 && range.tag.localName === "pPr").map((range) => xml.slice(range.start, range.end))
|
|
195442
|
+
};
|
|
195443
|
+
};
|
|
195444
|
+
const before = capture(beforeXml);
|
|
195445
|
+
const after = capture(afterXml);
|
|
195446
|
+
if (!before || !after || before.open !== after.open || before.properties.length !== after.properties.length || before.properties.some((xml, ordinal) => xml !== after.properties[ordinal]))
|
|
195447
|
+
return null;
|
|
195448
|
+
return {
|
|
195449
|
+
removedBlockIds: [],
|
|
195450
|
+
addedBlockIds: [],
|
|
195451
|
+
leadingBlockIds: [],
|
|
195452
|
+
trailingXmlChanged: false,
|
|
195453
|
+
contentBlockIds: beforeXml === afterXml ? [] : [paragraph.blockId]
|
|
195454
|
+
};
|
|
195455
|
+
}
|
|
195419
195456
|
function snapshot(xml, parsed = collectXmlElementRanges(xml)) {
|
|
195420
195457
|
if (parsed.errors.length)
|
|
195421
195458
|
return null;
|
|
@@ -195450,6 +195487,7 @@ var init_content_control_rewrite = __esm(() => {
|
|
|
195450
195487
|
init_xml_sax();
|
|
195451
195488
|
init_paragraph_index();
|
|
195452
195489
|
init_patch_substrate();
|
|
195490
|
+
init_paragraph_para_id_attrs();
|
|
195453
195491
|
TD29 = new TextDecoder;
|
|
195454
195492
|
});
|
|
195455
195493
|
|
|
@@ -245747,13 +245785,17 @@ function runStorySurfaceRewriteCommit(input) {
|
|
|
245747
245785
|
const controlOwner = op.storyPartOwnership[0];
|
|
245748
245786
|
const controlBytes = controlOwner && input.state.packageBytes.get(controlOwner.partUri);
|
|
245749
245787
|
const controlPatch = controlOwner && effectivePerPart[controlOwner.partUri];
|
|
245788
|
+
const controlIndex = op.contentControlRewrite && controlOwner && getStoryParagraphIndexFromState(input.state, controlOwner.storyId);
|
|
245789
|
+
const controlParagraph = op.targetBlockIds.length === 1 && controlIndex && !controlIndex.duplicateParaIds.has(op.targetBlockIds[0]) ? controlIndex.byParaId(op.targetBlockIds[0]) : undefined;
|
|
245790
|
+
const controlScope = controlOwner && op.indexRefreshScope?.perPart[controlOwner.partUri];
|
|
245791
|
+
const localizedControlParagraph = controlScope?.kind === "paragraph" && controlParagraph && controlParagraph.partUri === controlOwner?.partUri && controlScope.beforeWindow.startByte === controlParagraph.byteStart && controlScope.beforeWindow.endByte === controlParagraph.byteEnd ? controlParagraph : undefined;
|
|
245750
245792
|
const localizedControl = op.contentControlRewrite && op.changeMode !== "tracked" && controlBytes && controlPatch ? prepareLocalizedContentControlRewrite(controlBytes, controlPatch, controlOwner ? getStoryParagraphIndexFromState(input.state, controlOwner.storyId) : undefined, input.state) : null;
|
|
245751
245793
|
if (localizedControl && controlOwner) {
|
|
245752
245794
|
forwardPatchGroup.indexRefreshScope = {
|
|
245753
245795
|
perPart: { ...forwardPatchGroup.indexRefreshScope?.perPart, [controlOwner.partUri]: localizedControl.scope }
|
|
245754
245796
|
};
|
|
245755
245797
|
}
|
|
245756
|
-
const contentControlRewrite = localizedControl?.rewrite ?? (op.contentControlRewrite && controlBytes && controlPatch ? prepareContentControlRewrite(controlBytes, controlPatch) : null);
|
|
245798
|
+
const contentControlRewrite = localizedControl?.rewrite ?? (op.contentControlRewrite && controlBytes && controlPatch ? prepareContentControlRewrite(controlBytes, controlPatch, localizedControlParagraph) : null);
|
|
245757
245799
|
if (op.contentControlRewrite && (op.family !== "storyBlocks" || op.storyPartOwnership.length !== 1 || !contentControlRewrite)) {
|
|
245758
245800
|
return rejected7(input.txId, "unsupported-context");
|
|
245759
245801
|
}
|
|
@@ -401285,6 +401327,7 @@ class V2ContentControlsAdapter {
|
|
|
401285
401327
|
return this.validateDryRun(input, options, target);
|
|
401286
401328
|
return this.commitDocument(nextXml, "content-control-create", input, options, target, {
|
|
401287
401329
|
partUri: part.partUri,
|
|
401330
|
+
...!tracked && !part.story && input.kind === "inline" && input.at?.start.kind === "text" && input.at.end.kind === "text" && input.at.start.blockId === input.at.end.blockId && !Object.keys(plannedContent.perPart ?? {}).length && !plannedContent.semanticStyleDependencies?.length ? { localizedParagraph: part.paragraphs.find((paragraph4) => paragraph4.blockId === (input.at?.start.kind === "text" ? input.at.start.blockId : undefined)) } : {},
|
|
401288
401331
|
affectedStories: [part.story ?? { kind: "story", storyType: "body" }],
|
|
401289
401332
|
storySurface: {
|
|
401290
401333
|
family: "storyBlocks",
|
|
@@ -402793,6 +402836,7 @@ class V2ContentControlsAdapter {
|
|
|
402793
402836
|
}
|
|
402794
402837
|
}
|
|
402795
402838
|
}
|
|
402839
|
+
const localized = partUri === DOCUMENT_PART_URI5 && commitOptions.storySurface?.contentControlRewrite && commitOptions.storySurface.family === "storyBlocks" && options?.changeMode !== "tracked" && commitOptions.storySurface.changeMode !== "tracked" && !Object.keys(commitOptions.extraPerPart ?? {}).length && !commitOptions.semanticStyleDependencies?.length ? this.localizedParagraphPatch(before, nextXml, current, commitOptions.localizedParagraph) : null;
|
|
402796
402840
|
const insertionCharOffset = commitOptions.insertionCharOffset;
|
|
402797
402841
|
const insertedLength = nextXml.length - before.length;
|
|
402798
402842
|
const bomLength = current[0] === 239 && current[1] === 187 && current[2] === 191 ? 3 : 0;
|
|
@@ -402802,12 +402846,28 @@ class V2ContentControlsAdapter {
|
|
|
402802
402846
|
atByte: bomLength + encodeXml(before.slice(0, insertionCharOffset)).length,
|
|
402803
402847
|
bytes: encodeXml(nextXml.slice(insertionCharOffset, insertionCharOffset + insertedLength))
|
|
402804
402848
|
} : null;
|
|
402805
|
-
const
|
|
402849
|
+
const expectedRevision = expectedRevisionFrom(input, options);
|
|
402850
|
+
const committed = localized ? commitKernelStorySurfacePatch({
|
|
402851
|
+
context: this.context,
|
|
402852
|
+
txIdPrefix: prefix2,
|
|
402853
|
+
expectedRevision: expectedRevision == null ? undefined : String(expectedRevision),
|
|
402854
|
+
appliedChangeMode: "direct",
|
|
402855
|
+
perPart: { [partUri]: localized.entry },
|
|
402856
|
+
storyIds: [localized.storyId],
|
|
402857
|
+
storySurface: { family: "storyBlocks", contentControlRewrite: true, changeMode: "direct", targetBlockIds: [localized.blockId] },
|
|
402858
|
+
signalLanesToRebuild: ["paragraphIndex", "noteAnchorRefs"],
|
|
402859
|
+
indexRefreshScope: { perPart: { [partUri]: {
|
|
402860
|
+
kind: "paragraph",
|
|
402861
|
+
blockIds: [localized.blockId],
|
|
402862
|
+
beforeWindow: localized.beforeWindow
|
|
402863
|
+
} } },
|
|
402864
|
+
createdRefs: commitOptions.createdRefs
|
|
402865
|
+
}) : localizedInsertion ? commitKernelStorySurfacePatch({
|
|
402806
402866
|
context: this.context,
|
|
402807
402867
|
txIdPrefix: prefix2,
|
|
402808
402868
|
appliedChangeMode: commitOptions.storySurface?.changeMode ?? options?.changeMode ?? "direct",
|
|
402809
402869
|
perPart: { [partUri]: { kind: "modify", patches: [localizedInsertion] } },
|
|
402810
|
-
expectedRevision:
|
|
402870
|
+
expectedRevision: expectedRevision === undefined ? undefined : String(expectedRevision),
|
|
402811
402871
|
storySurface: commitOptions.storySurface,
|
|
402812
402872
|
signalLanesToRebuild: commitOptions.signalLanesToRebuild,
|
|
402813
402873
|
storyIds: this.load().parts.filter((part) => part.partUri === partUri && !part.xmlRange).map((part) => part.storyId),
|
|
@@ -402845,6 +402905,31 @@ class V2ContentControlsAdapter {
|
|
|
402845
402905
|
}
|
|
402846
402906
|
return result;
|
|
402847
402907
|
}
|
|
402908
|
+
localizedParagraphPatch(before, after, bytes, paragraph4) {
|
|
402909
|
+
if (!paragraph4)
|
|
402910
|
+
return null;
|
|
402911
|
+
const nextEnd = after.length - before.length + paragraph4.end;
|
|
402912
|
+
if (nextEnd < paragraph4.start || before.slice(paragraph4.start, paragraph4.end) !== paragraph4.xml || before.slice(0, paragraph4.start) !== after.slice(0, paragraph4.start) || before.slice(paragraph4.end) !== after.slice(nextEnd))
|
|
402913
|
+
return null;
|
|
402914
|
+
const index2 = getSDDocumentSessionInternalParagraphIndex(this.context.session);
|
|
402915
|
+
if (!index2 || index2.duplicateParaIds.has(paragraph4.blockId))
|
|
402916
|
+
return null;
|
|
402917
|
+
const entry = index2.byParaId(paragraph4.blockId);
|
|
402918
|
+
if (!entry || entry.partUri !== DOCUMENT_PART_URI5 || decodeXml(bytes.subarray(entry.byteStart, entry.byteEnd)) !== paragraph4.xml)
|
|
402919
|
+
return null;
|
|
402920
|
+
return {
|
|
402921
|
+
blockId: entry.blockId,
|
|
402922
|
+
storyId: entry.storyId,
|
|
402923
|
+
beforeWindow: { startByte: entry.byteStart, endByte: entry.byteEnd },
|
|
402924
|
+
entry: { kind: "modify", patches: [{
|
|
402925
|
+
kind: "replaceBytes",
|
|
402926
|
+
order: 0,
|
|
402927
|
+
startByte: entry.byteStart,
|
|
402928
|
+
endByte: entry.byteEnd,
|
|
402929
|
+
bytes: encodeXml(after.slice(paragraph4.start, nextEnd))
|
|
402930
|
+
}] }
|
|
402931
|
+
};
|
|
402932
|
+
}
|
|
402848
402933
|
}
|
|
402849
402934
|
function contentControlTextBlockIds(control2) {
|
|
402850
402935
|
const target = control2.sourceSelectionTarget;
|
|
@@ -489894,6 +489979,11 @@ function scopeFromHandle(handle) {
|
|
|
489894
489979
|
});
|
|
489895
489980
|
}
|
|
489896
489981
|
const { rootDoc, scope } = handle;
|
|
489982
|
+
if (scope._item?.deleted) {
|
|
489983
|
+
invalidStoryShardTarget("story-shard handle is no longer current; reopen the shared document with join", {
|
|
489984
|
+
shardId: handle.shardId
|
|
489985
|
+
});
|
|
489986
|
+
}
|
|
489897
489987
|
const hasRoots = scope.get(STORY_SHARD_ROOT.meta) instanceof YMap && scope.get(STORY_SHARD_ROOT.blocks) instanceof YArray && scope.get(STORY_SHARD_ROOT.order) instanceof YMap && scope.get(STORY_SHARD_ROOT.tables) instanceof YMap;
|
|
489898
489988
|
if (!hasRoots) {
|
|
489899
489989
|
rootDoc.transact(() => {
|
|
@@ -509714,6 +509804,20 @@ function mirrorStructuralParagraphTargets(input, managedIds) {
|
|
|
509714
509804
|
}
|
|
509715
509805
|
function mirrorContentControlRewrite(input) {
|
|
509716
509806
|
const rewrite = input.extension.contentControlRewrite;
|
|
509807
|
+
const source = input.prepared.source;
|
|
509808
|
+
const index2 = loadStoryParagraphIndex(input.session, input.storyId);
|
|
509809
|
+
const scoped = source.kind === "storySurfaceRewrite" && source.operationId === "content-control-create" && source.changeMode !== "tracked" && input.prepared.localApplyBundle.indexRefreshScope?.perPart[input.prepared.resolvedTargets.storyPartOwnership[0]?.partUri ?? ""]?.kind === "paragraph";
|
|
509810
|
+
if (scoped && rewrite.contentBlockIds.length && !rewrite.addedBlockIds.length && !rewrite.removedBlockIds.length && !rewrite.leadingBlockIds.length && !rewrite.trailingXmlChanged) {
|
|
509811
|
+
const ordinaryBodyParagraphs = rewrite.contentBlockIds.every((id2) => index2?.byParaId(id2)?.directBodyChildOrdinal != null);
|
|
509812
|
+
if (ordinaryBodyParagraphs) {
|
|
509813
|
+
const context = loadStorySyncContext(input.session, input.storyId, rewrite.contentBlockIds);
|
|
509814
|
+
const payloads2 = rewrite.contentBlockIds.map((id2) => readSessionBlockPayload(context, id2));
|
|
509815
|
+
if (!payloads2.some((payload) => /<(?:[\w.-]+:)?(?:ins|del|moveFrom|moveTo)(?=[\s/>])/.test(payload.xml))) {
|
|
509816
|
+
syncBlockPayloads(input.doc, payloads2);
|
|
509817
|
+
return;
|
|
509818
|
+
}
|
|
509819
|
+
}
|
|
509820
|
+
}
|
|
509717
509821
|
if (rewrite.localized) {
|
|
509718
509822
|
const localized = rewrite.localized;
|
|
509719
509823
|
const blockIds = [...new Set([...rewrite.contentBlockIds, ...rewrite.leadingBlockIds])];
|
|
@@ -510367,15 +510471,17 @@ function loadStorySyncContext(session, storyId, blockIds) {
|
|
|
510367
510471
|
throw new Error(`story-surface session sync could not load bytes for ${partUri}`);
|
|
510368
510472
|
}
|
|
510369
510473
|
const rootNamespaceBindings2 = readRootNamespaceBindingsFromBytes(bytes);
|
|
510474
|
+
const paragraphs2 = blockIds ? blockIds.map((id2) => index2.byParaId(id2)).filter((entry) => entry != null) : index2.entries;
|
|
510475
|
+
const ordinaryBodyParagraphs = blockIds && paragraphs2.length === blockIds.length && paragraphs2.every((entry) => entry.directBodyChildOrdinal != null);
|
|
510370
510476
|
return {
|
|
510371
510477
|
storyId,
|
|
510372
510478
|
storyKind: story?.storyKind ?? inferStoryKindFromStoryId(storyId),
|
|
510373
510479
|
partUri,
|
|
510374
510480
|
index: index2,
|
|
510375
510481
|
bytes,
|
|
510376
|
-
tableRefsByBlockId: buildParagraphTableRefsFromCatalog({
|
|
510482
|
+
tableRefsByBlockId: ordinaryBodyParagraphs ? new Map : buildParagraphTableRefsFromCatalog({
|
|
510377
510483
|
catalog: readTableCatalogForSession(session, storyId),
|
|
510378
|
-
paragraphs:
|
|
510484
|
+
paragraphs: paragraphs2.map((entry) => ({
|
|
510379
510485
|
blockId: entry.blockId,
|
|
510380
510486
|
byteStart: entry.byteStart,
|
|
510381
510487
|
byteEnd: entry.byteEnd
|
|
@@ -515086,6 +515192,12 @@ function createCollabV2SessionProjectionController(options) {
|
|
|
515086
515192
|
});
|
|
515087
515193
|
}
|
|
515088
515194
|
function ensureProjectionSubscriptions() {
|
|
515195
|
+
for (const handle of [...options.projectionRegistry.listStories(), ...options.projectionRegistry.listPackageParts()]) {
|
|
515196
|
+
if (handle.rootDoc && handle.scope && getUnitScope(handle.rootDoc, handle.shardId) !== handle.scope) {
|
|
515197
|
+
runtime.markAllDirty();
|
|
515198
|
+
throw new CollabV2DiagnosticError(COLLAB_V2_DIAGNOSTICS.COLLAB_V2_CONNECTION_INPUT_INVALID, "shared document content is no longer current in this editor; reopen the shared document with join", { shardId: handle.shardId });
|
|
515199
|
+
}
|
|
515200
|
+
}
|
|
515089
515201
|
let registryShapeChanged = false;
|
|
515090
515202
|
const currentImport = getPackagePartsMap(options.rootDoc);
|
|
515091
515203
|
if (currentImport !== subscribedImport) {
|
|
@@ -515320,7 +515432,13 @@ function createCollabV2SessionProjectionController(options) {
|
|
|
515320
515432
|
message: `read-freshness matrix has no row for "${operationId}".`
|
|
515321
515433
|
};
|
|
515322
515434
|
}
|
|
515323
|
-
|
|
515435
|
+
try {
|
|
515436
|
+
ensureProjectionSubscriptions();
|
|
515437
|
+
} catch (error51) {
|
|
515438
|
+
if (!(error51 instanceof CollabV2DiagnosticError) || error51.code !== COLLAB_V2_DIAGNOSTICS.COLLAB_V2_CONNECTION_INPUT_INVALID)
|
|
515439
|
+
throw error51;
|
|
515440
|
+
return { ok: false, code: "PRECONDITION_FAILED", message: error51.message };
|
|
515441
|
+
}
|
|
515324
515442
|
if (localBackendSyncDepth === 0) {
|
|
515325
515443
|
const changed = (handle) => {
|
|
515326
515444
|
const doc2 = shardDurableDoc(handle);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/mcp",
|
|
3
|
-
"version": "1.12.0-next.
|
|
3
|
+
"version": "1.12.0-next.9",
|
|
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.25.0-next.
|
|
27
|
+
"@superdoc/sdk": "2.25.0-next.9",
|
|
28
28
|
"debug": "^4.4.3",
|
|
29
29
|
"zod": "^4.3.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"superdoc": "2.28.0-next.
|
|
33
|
-
"@superdoc/docx-engine": "0.27.0-next.
|
|
32
|
+
"superdoc": "2.28.0-next.11",
|
|
33
|
+
"@superdoc/docx-engine": "0.27.0-next.10",
|
|
34
34
|
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
35
35
|
"@types/bun": "^1.3.8",
|
|
36
36
|
"@types/node": "22.19.2",
|