@superdoc/mcp 1.11.0-next.7 → 1.11.0-next.8
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 +73 -2
- 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.24.0-next.
|
|
31633
|
+
var SDK_VERSION = "2.24.0-next.8";
|
|
31634
31634
|
|
|
31635
31635
|
// ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
|
|
31636
31636
|
import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
|
|
@@ -283322,6 +283322,68 @@ async function serializeSDDocumentSessionInternalPackageToSinkAsync(session, sin
|
|
|
283322
283322
|
}
|
|
283323
283323
|
return saveSourceBackedStreamingToSink(internal, reader.partUri, sink, options);
|
|
283324
283324
|
}
|
|
283325
|
+
function readRemoteParagraphBytes(state, storyId) {
|
|
283326
|
+
const index = getStoryParagraphIndexFromState(state, storyId);
|
|
283327
|
+
if (!index)
|
|
283328
|
+
return null;
|
|
283329
|
+
const first = index.entries[0];
|
|
283330
|
+
const head = first ? readPartRangeFromStateSync(state, first.partUri, 0, first.byteStart) : null;
|
|
283331
|
+
if (first && !head)
|
|
283332
|
+
return null;
|
|
283333
|
+
const declarations = head ? new TextDecoder().decode(head).matchAll(/xmlns(?::([A-Za-z_][\w.-]*))?="([^"]*)"/g) : [];
|
|
283334
|
+
const namespaceBindings = createCanonicalXmlNamespaceBindings([...declarations].map((match) => [match[1] ?? "", match[2]]));
|
|
283335
|
+
const paragraphs2 = new Map;
|
|
283336
|
+
for (const entry of index.entries) {
|
|
283337
|
+
const bytes = readPartRangeFromStateSync(state, entry.partUri, entry.byteStart, entry.byteEnd);
|
|
283338
|
+
if (!bytes)
|
|
283339
|
+
return null;
|
|
283340
|
+
const ambiguous = paragraphs2.has(entry.blockId) || index.duplicateParaIds.has(entry.blockId);
|
|
283341
|
+
paragraphs2.set(entry.blockId, ambiguous ? null : bytes);
|
|
283342
|
+
}
|
|
283343
|
+
return { paragraphs: paragraphs2, namespaceBindings };
|
|
283344
|
+
}
|
|
283345
|
+
function sameRemoteParagraphText(before, beforeBindings, after, afterBindings) {
|
|
283346
|
+
try {
|
|
283347
|
+
const decoder7 = new TextDecoder;
|
|
283348
|
+
const previous = parseParagraphInlineMap(decoder7.decode(before), beforeBindings);
|
|
283349
|
+
const next = parseParagraphInlineMap(decoder7.decode(after), afterBindings);
|
|
283350
|
+
return previous.visibleText() === next.visibleText() && previous.trackedText() === next.trackedText();
|
|
283351
|
+
} catch {
|
|
283352
|
+
return false;
|
|
283353
|
+
}
|
|
283354
|
+
}
|
|
283355
|
+
function listParagraphIdsInWholeBlocks(blockWindows) {
|
|
283356
|
+
const decoder7 = new TextDecoder;
|
|
283357
|
+
const blockIds = new Set;
|
|
283358
|
+
for (const blockWindow of blockWindows) {
|
|
283359
|
+
const xml = decoder7.decode(blockWindow).trim();
|
|
283360
|
+
const wholeBlocks = /^<w:(p|tbl|sdt)[\s>/]/.test(xml) && /(<\/w:(p|tbl|sdt)>|\/>)$/.test(xml);
|
|
283361
|
+
if (xml && !wholeBlocks)
|
|
283362
|
+
return null;
|
|
283363
|
+
for (const open2 of xml.matchAll(/<w:p(?=[\s>/])[^>]*>/g)) {
|
|
283364
|
+
const paraId = open2[0].match(/w14:paraId="([^"]+)"/)?.[1];
|
|
283365
|
+
if (!paraId)
|
|
283366
|
+
return null;
|
|
283367
|
+
blockIds.add(paraId);
|
|
283368
|
+
}
|
|
283369
|
+
}
|
|
283370
|
+
return [...blockIds];
|
|
283371
|
+
}
|
|
283372
|
+
function listChangedRemoteParagraphs(before, after) {
|
|
283373
|
+
const sameBytes2 = (left, right) => left.byteLength === right.byteLength && left.every((value, index) => value === right[index]);
|
|
283374
|
+
const changed = new Set;
|
|
283375
|
+
for (const [blockId, previous] of before.paragraphs) {
|
|
283376
|
+
const next = after.paragraphs.get(blockId);
|
|
283377
|
+
if (!previous || !next)
|
|
283378
|
+
changed.add(blockId);
|
|
283379
|
+
else if (!sameBytes2(previous, next) && !sameRemoteParagraphText(previous, before.namespaceBindings, next, after.namespaceBindings))
|
|
283380
|
+
changed.add(blockId);
|
|
283381
|
+
}
|
|
283382
|
+
for (const [blockId, next] of after.paragraphs)
|
|
283383
|
+
if (!next || !before.paragraphs.has(blockId))
|
|
283384
|
+
changed.add(blockId);
|
|
283385
|
+
return [...changed];
|
|
283386
|
+
}
|
|
283325
283387
|
function applySDDocumentSessionInternalProjection(session, input) {
|
|
283326
283388
|
const internal = INTERNALS.get(session);
|
|
283327
283389
|
if (!internal)
|
|
@@ -283369,6 +283431,10 @@ function applySDDocumentSessionInternalProjection(session, input) {
|
|
|
283369
283431
|
});
|
|
283370
283432
|
const remoteParagraphInput = !input.packageReplaced && inventoryUnchanged && requestedChangedPartUris.size === 1 && requestedChangedStoryIds.size === 1 && textPart?.bytes === null && textPart.patches?.length === 1 && textStory?.storyKind === "main" && textStory.partUri === textPart.partUri ? { storyId: textStory.storyId, partUri: textPart.partUri, patch: textPart.patches[0] } : null;
|
|
283371
283433
|
const remoteTextInput = remoteParagraphInput ? captureSDRemoteTextRenderInput(state, remoteParagraphInput.storyId, remoteParagraphInput.partUri, remoteParagraphInput.patch) : null;
|
|
283434
|
+
const mainStoryRemoteChange = !input.packageReplaced && inventoryUnchanged && requestedChangedPartUris.size === 1 && requestedChangedStoryIds.size === 1 && textStory?.storyKind === "main" && textStory.storyId === state.mainStoryId && textPart !== undefined && textStory.partUri === textPart.partUri ? textStory.storyId : null;
|
|
283435
|
+
const wholeStoryRemoteChange = mainStoryRemoteChange && textPart?.bytes ? mainStoryRemoteChange : null;
|
|
283436
|
+
const paragraphsBeforeRemoteChange = wholeStoryRemoteChange ? readRemoteParagraphBytes(state, wholeStoryRemoteChange) : null;
|
|
283437
|
+
const patchedRemoteWindows = mainStoryRemoteChange && !textPart?.bytes && textPart?.patches?.length ? textPart.patches.map((patch) => readPartRangeFromStateSync(state, textPart.partUri, patch.startByte, patch.endByte)) : null;
|
|
283372
283438
|
const publishRemoteParagraph = inventoryUnchanged ? remoteParagraphCandidate : null;
|
|
283373
283439
|
const publishRemoteResidentParagraph = inventoryUnchanged && remoteParagraphInput ? captureRemoteResidentParagraphPublication(state, remoteParagraphInput.storyId, remoteParagraphInput.partUri, remoteParagraphInput.patch) : null;
|
|
283374
283440
|
const coverageHints = new Map;
|
|
@@ -283586,6 +283652,10 @@ function applySDDocumentSessionInternalProjection(session, input) {
|
|
|
283586
283652
|
const remoteGeneration = (REMOTE_PROJECTION_GENERATIONS.get(session) ?? 0) + 1;
|
|
283587
283653
|
REMOTE_PROJECTION_GENERATIONS.set(session, remoteGeneration);
|
|
283588
283654
|
const remoteText = remoteTextInput && changedStoryIds.size === 1 && changedPartUris.size === 1 ? sealSDRemoteTextRenderInput(state, remoteTextInput) : null;
|
|
283655
|
+
const paragraphsAfterRemoteChange = wholeStoryRemoteChange && paragraphsBeforeRemoteChange && changedStoryIds.size === 1 && changedStoryIds.has(wholeStoryRemoteChange) && changedPartUris.size === 1 ? readRemoteParagraphBytes(state, wholeStoryRemoteChange) : null;
|
|
283656
|
+
const remoteChangeIsNarrow = remoteText?.classification != null;
|
|
283657
|
+
const remoteChangedParagraphs = wholeStoryRemoteChange && paragraphsBeforeRemoteChange && paragraphsAfterRemoteChange ? { storyId: wholeStoryRemoteChange, blockIds: listChangedRemoteParagraphs(paragraphsBeforeRemoteChange, paragraphsAfterRemoteChange) } : null;
|
|
283658
|
+
const patchedRemoteParagraphs = !remoteChangedParagraphs && mainStoryRemoteChange && patchedRemoteWindows && !remoteChangeIsNarrow && patchedRemoteWindows.every((blockWindow) => blockWindow !== null) && changedStoryIds.size === 1 && changedStoryIds.has(mainStoryRemoteChange) && changedPartUris.size === 1 ? listParagraphIdsInWholeBlocks([...patchedRemoteWindows, ...textPart.patches.map((patch) => patch.bytes)]) : null;
|
|
283589
283659
|
return snapshotSDRenderCommitEnvelope({
|
|
283590
283660
|
documentEpoch: state.documentRef.documentId,
|
|
283591
283661
|
commitSequence: state.renderCommitSequence,
|
|
@@ -283610,7 +283680,8 @@ function applySDDocumentSessionInternalProjection(session, input) {
|
|
|
283610
283680
|
...remoteText ? { localizedBodyText: remoteText.localizedBodyText } : {}
|
|
283611
283681
|
},
|
|
283612
283682
|
...remoteText ? { sourceProjectionEffect: remoteText.sourceProjectionEffect } : {},
|
|
283613
|
-
remote: { generation: remoteGeneration }
|
|
283683
|
+
remote: { generation: remoteGeneration },
|
|
283684
|
+
...remoteChangedParagraphs && !input.packageReplaced ? { remoteChangedParagraphs } : patchedRemoteParagraphs && mainStoryRemoteChange && !input.packageReplaced ? { remoteChangedParagraphs: { storyId: mainStoryRemoteChange, blockIds: patchedRemoteParagraphs } } : {}
|
|
283614
283685
|
});
|
|
283615
283686
|
}
|
|
283616
283687
|
function validateSDDocumentSessionInternalPackageBytes(bytes) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/mcp",
|
|
3
|
-
"version": "1.11.0-next.
|
|
3
|
+
"version": "1.11.0-next.8",
|
|
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.24.0-next.
|
|
27
|
+
"@superdoc/sdk": "2.24.0-next.8",
|
|
28
28
|
"debug": "^4.4.3",
|
|
29
29
|
"zod": "^4.3.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"superdoc": "2.27.0-next.
|
|
33
|
-
"@superdoc/docx-engine": "0.26.0-next.
|
|
32
|
+
"superdoc": "2.27.0-next.8",
|
|
33
|
+
"@superdoc/docx-engine": "0.26.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",
|