@superdoc/mcp 1.8.0-next.6 → 1.8.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.
- package/dist/index.js +174 -5
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -31616,7 +31616,7 @@ var init_host = __esm(() => {
|
|
|
31616
31616
|
});
|
|
31617
31617
|
|
|
31618
31618
|
// ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
|
|
31619
|
-
var SDK_VERSION = "2.21.0-next.
|
|
31619
|
+
var SDK_VERSION = "2.21.0-next.7";
|
|
31620
31620
|
|
|
31621
31621
|
// ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
|
|
31622
31622
|
import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
|
|
@@ -233558,9 +233558,9 @@ function hasOverlappingTrackedWrapper(xml, target) {
|
|
|
233558
233558
|
const targetXml = xml.slice(target.byteStart, target.byteEnd);
|
|
233559
233559
|
const targetOpenEnd = targetXml.indexOf(">");
|
|
233560
233560
|
const targetCloseStart = targetXml.lastIndexOf("</");
|
|
233561
|
-
if (targetOpenEnd < 0 || targetCloseStart < targetOpenEnd ||
|
|
233561
|
+
if (targetOpenEnd < 0 || targetCloseStart < targetOpenEnd || new RegExp(`<(?:${RAW_XML_NCNAME_PATTERN}:)?(?:ins|del|moveFrom|moveTo)\\b`, "u").test(targetXml.slice(targetOpenEnd + 1, targetCloseStart)))
|
|
233562
233562
|
return true;
|
|
233563
|
-
const tokenRe =
|
|
233563
|
+
const tokenRe = new RegExp(`<(\\/?)(?:(${RAW_XML_NCNAME_PATTERN}):)?(ins|del|moveFrom|moveTo)\\b[^>]*(\\/?)>`, "gu");
|
|
233564
233564
|
let depth = 0;
|
|
233565
233565
|
for (let match = tokenRe.exec(xml);match; match = tokenRe.exec(xml)) {
|
|
233566
233566
|
if (match.index >= target.byteStart)
|
|
@@ -235121,6 +235121,154 @@ var init_image_review_resources = __esm(() => {
|
|
|
235121
235121
|
UNCHANGED_IMAGE_OWNER = Symbol("unchanged-image-review-owner");
|
|
235122
235122
|
});
|
|
235123
235123
|
|
|
235124
|
+
// ../../../v2/editor-core/dist/document/transactions/tracked-changes/accepted-insertion-replacement.js
|
|
235125
|
+
function indexReplacementSource(input) {
|
|
235126
|
+
const parsed = input.elements();
|
|
235127
|
+
if (parsed.errors.length)
|
|
235128
|
+
return null;
|
|
235129
|
+
const rangesByStart = new Map;
|
|
235130
|
+
const parentByStart = new Map;
|
|
235131
|
+
const previousByStart = new Map;
|
|
235132
|
+
const nextByStart = new Map;
|
|
235133
|
+
const childrenByStart = new Map;
|
|
235134
|
+
const parents = [];
|
|
235135
|
+
for (const range of [...parsed.ranges].sort((a, b) => a.start - b.start || b.end - a.end)) {
|
|
235136
|
+
while (parents.length && range.start >= parents.at(-1).end)
|
|
235137
|
+
parents.pop();
|
|
235138
|
+
const parent = parents.at(-1);
|
|
235139
|
+
if (parent) {
|
|
235140
|
+
parentByStart.set(range.start, parent);
|
|
235141
|
+
const children = childrenByStart.get(parent.start) ?? [];
|
|
235142
|
+
const previous = children.at(-1);
|
|
235143
|
+
if (previous) {
|
|
235144
|
+
previousByStart.set(range.start, previous);
|
|
235145
|
+
nextByStart.set(previous.start, range);
|
|
235146
|
+
}
|
|
235147
|
+
children.push(range);
|
|
235148
|
+
childrenByStart.set(parent.start, children);
|
|
235149
|
+
}
|
|
235150
|
+
rangesByStart.set(range.start, range);
|
|
235151
|
+
parents.push(range);
|
|
235152
|
+
}
|
|
235153
|
+
const fragmentsByStart = new Map(input.catalogFragments.map((f) => [f.byteStart, f]));
|
|
235154
|
+
const selectedStarts = input.selectedFragments.map((f) => f.byteStart).sort((a, b) => a - b);
|
|
235155
|
+
const selectedEnds = input.selectedFragments.map((f) => f.byteEnd).sort((a, b) => a - b);
|
|
235156
|
+
return { rangesByStart, parentByStart, previousByStart, nextByStart, childrenByStart, fragmentsByStart, selectedStarts, selectedEnds };
|
|
235157
|
+
}
|
|
235158
|
+
function countBefore(values, target, includeEqual = false) {
|
|
235159
|
+
let low = 0;
|
|
235160
|
+
let high = values.length;
|
|
235161
|
+
while (low < high) {
|
|
235162
|
+
const mid = low + high >>> 1;
|
|
235163
|
+
if (values[mid] < target || includeEqual && values[mid] === target)
|
|
235164
|
+
low = mid + 1;
|
|
235165
|
+
else
|
|
235166
|
+
high = mid;
|
|
235167
|
+
}
|
|
235168
|
+
return low;
|
|
235169
|
+
}
|
|
235170
|
+
function createAcceptedInsertionReplacementResolver(input) {
|
|
235171
|
+
const { xml } = input;
|
|
235172
|
+
let index;
|
|
235173
|
+
return (fragment3) => {
|
|
235174
|
+
if (fragment3.kind !== "ins")
|
|
235175
|
+
return null;
|
|
235176
|
+
const firstStart = fragment3.openEndChar;
|
|
235177
|
+
if (firstStart == null)
|
|
235178
|
+
return null;
|
|
235179
|
+
const firstTagStart = xml.indexOf("<", firstStart);
|
|
235180
|
+
if (firstTagStart < 0 || firstTagStart >= fragment3.byteEnd || xml.slice(firstStart, firstTagStart).trim())
|
|
235181
|
+
return null;
|
|
235182
|
+
const firstTagEnd = xml.indexOf(">", firstTagStart);
|
|
235183
|
+
const firstKind = parseRawXmlElementTag(xml.slice(firstTagStart, firstTagEnd + 1))?.localName;
|
|
235184
|
+
if (firstKind !== "del" && firstKind !== "r")
|
|
235185
|
+
return null;
|
|
235186
|
+
const prefixShape = firstKind === "r";
|
|
235187
|
+
if (index === undefined)
|
|
235188
|
+
index = indexReplacementSource(input);
|
|
235189
|
+
const source = index;
|
|
235190
|
+
if (!source)
|
|
235191
|
+
return null;
|
|
235192
|
+
const outer = source.rangesByStart.get(fragment3.byteStart);
|
|
235193
|
+
if (!outer || outer.end !== fragment3.byteEnd)
|
|
235194
|
+
return null;
|
|
235195
|
+
const childStart = prefixShape ? source.childrenByStart.get(outer.start)?.at(-1)?.start : firstTagStart;
|
|
235196
|
+
const deletion = childStart == null ? undefined : source.fragmentsByStart.get(childStart);
|
|
235197
|
+
if (!deletion || deletion.kind !== "del" || deletion.byteStart <= fragment3.byteStart || deletion.byteEnd >= fragment3.byteEnd)
|
|
235198
|
+
return null;
|
|
235199
|
+
const child = source.rangesByStart.get(deletion.byteStart);
|
|
235200
|
+
if (!child || child.end !== deletion.byteEnd || (prefixShape ? xml.slice(child.end, outer.closeStart).trim() : xml.slice(outer.openEnd, child.start).trim()))
|
|
235201
|
+
return null;
|
|
235202
|
+
const container = source.parentByStart.get(outer.start);
|
|
235203
|
+
if (!container || container.tag.namespaceUri !== NS_W || container.tag.localName !== "p")
|
|
235204
|
+
return null;
|
|
235205
|
+
const adjacent = prefixShape ? source.nextByStart.get(outer.start) : source.previousByStart.get(outer.start);
|
|
235206
|
+
if (!adjacent || adjacent.tag.namespaceUri !== NS_W || adjacent.tag.localName !== "ins" || (prefixShape ? xml.slice(outer.end, adjacent.start).trim() : xml.slice(adjacent.end, outer.start).trim()))
|
|
235207
|
+
return null;
|
|
235208
|
+
const insertion = source.fragmentsByStart.get(adjacent.start);
|
|
235209
|
+
if (!insertion || insertion.kind !== "ins" || insertion.byteEnd !== adjacent.end || insertion.date !== deletion.date || !deletion.date)
|
|
235210
|
+
return null;
|
|
235211
|
+
const identity = (f) => buildReviewIdentity({ ...f.author, email: f.authorEmail });
|
|
235212
|
+
if (!isSameReviewGroupIdentity(identity(insertion), identity(deletion)) || isSameReviewGroupIdentity(identity(fragment3), identity(deletion)) || !fragment3.author.name || !deletion.author.name || fragment3.author.name === deletion.author.name && (!fragment3.authorEmail || !deletion.authorEmail || fragment3.authorEmail === deletion.authorEmail))
|
|
235213
|
+
return null;
|
|
235214
|
+
const insRsid = readXmlAttribute(adjacent.tag, NS_W, "rsidR")?.value;
|
|
235215
|
+
const delRsid = readXmlAttribute(child.tag, NS_W, "rsidDel")?.value;
|
|
235216
|
+
if (!insRsid || insRsid !== delRsid)
|
|
235217
|
+
return null;
|
|
235218
|
+
if (countBefore(source.selectedStarts, prefixShape ? adjacent.end : outer.end) - countBefore(source.selectedEnds, prefixShape ? outer.start : adjacent.start, true) !== 1)
|
|
235219
|
+
return null;
|
|
235220
|
+
const directChildren3 = (parent, start, end) => {
|
|
235221
|
+
let cursor = start;
|
|
235222
|
+
const direct = [];
|
|
235223
|
+
for (const range of source.childrenByStart.get(parent.start) ?? []) {
|
|
235224
|
+
if (range.end <= start)
|
|
235225
|
+
continue;
|
|
235226
|
+
if (range.start >= end)
|
|
235227
|
+
break;
|
|
235228
|
+
if (range.start < start || range.end > end)
|
|
235229
|
+
return [];
|
|
235230
|
+
if (xml.slice(cursor, range.start).trim())
|
|
235231
|
+
return [];
|
|
235232
|
+
direct.push(range);
|
|
235233
|
+
cursor = range.end;
|
|
235234
|
+
}
|
|
235235
|
+
return xml.slice(cursor, end).trim() ? [] : direct;
|
|
235236
|
+
};
|
|
235237
|
+
const textRuns = (parent, start = parent.openEnd, end = parent.closeStart) => {
|
|
235238
|
+
const runs = directChildren3(parent, start, end);
|
|
235239
|
+
if (xml.slice(start, end).trim() && !runs.length)
|
|
235240
|
+
return false;
|
|
235241
|
+
return runs.every((r) => {
|
|
235242
|
+
if (r.tag.namespaceUri !== NS_W || r.tag.localName !== "r")
|
|
235243
|
+
return false;
|
|
235244
|
+
const content = directChildren3(r, r.openEnd, r.closeStart);
|
|
235245
|
+
return (!xml.slice(r.openEnd, r.closeStart).trim() || content.length > 0) && content.every((element) => element.tag.namespaceUri === NS_W && ["rPr", "t", "delText"].includes(element.tag.localName));
|
|
235246
|
+
});
|
|
235247
|
+
};
|
|
235248
|
+
if (!textRuns(adjacent) || !textRuns(child) || !(prefixShape ? textRuns(outer, outer.openEnd, child.start) : textRuns(outer, child.end)))
|
|
235249
|
+
return null;
|
|
235250
|
+
const deletionContent = closeNamespaceScope(xml.slice(child.openEnd, child.closeStart), child.namespaceBindings, container.namespaceBindings, { referencedOnly: true });
|
|
235251
|
+
if (deletionContent === null)
|
|
235252
|
+
return null;
|
|
235253
|
+
const scopedDeletion = xml.slice(child.start, child.openEnd) + deletionContent + xml.slice(child.closeStart, child.end);
|
|
235254
|
+
const movedDeletion = closeNamespaceScope(scopedDeletion, child.namespaceBindings, container.namespaceBindings, { referencedOnly: true });
|
|
235255
|
+
const exposedRuns = closeNamespaceScope(prefixShape ? xml.slice(outer.openEnd, child.start) : xml.slice(child.end, outer.closeStart), outer.namespaceBindings, container.namespaceBindings, { referencedOnly: true });
|
|
235256
|
+
if (movedDeletion === null || exposedRuns === null)
|
|
235257
|
+
return null;
|
|
235258
|
+
if (prefixShape)
|
|
235259
|
+
return {
|
|
235260
|
+
start: outer.start,
|
|
235261
|
+
end: outer.end,
|
|
235262
|
+
replacement: exposedRuns + movedDeletion + xml.slice(child.end, outer.closeStart)
|
|
235263
|
+
};
|
|
235264
|
+
return { start: adjacent.start, end: outer.end, replacement: movedDeletion + xml.slice(adjacent.start, adjacent.end) + xml.slice(adjacent.end, outer.start) + xml.slice(outer.openEnd, child.start) + exposedRuns };
|
|
235265
|
+
};
|
|
235266
|
+
}
|
|
235267
|
+
var init_accepted_insertion_replacement = __esm(() => {
|
|
235268
|
+
init_xml_sax();
|
|
235269
|
+
init_xml_namespace_scope();
|
|
235270
|
+
});
|
|
235271
|
+
|
|
235124
235272
|
// ../../../v2/editor-core/dist/document/transactions/tracked-changes/compound-move-paragraph.js
|
|
235125
235273
|
function collectSelectedCompoundMoveWrapperIds(xml, paragraph, selected, paragraphMark) {
|
|
235126
235274
|
if (selected.length < 2)
|
|
@@ -235879,6 +236027,22 @@ function runTrackedChangeDecideCommitWithLookupContext(lookupContext, input, xml
|
|
|
235879
236027
|
}
|
|
235880
236028
|
const decodedSourceLength = workingXml.length;
|
|
235881
236029
|
const partPartials = partialFragmentByteRanges.get(partUri);
|
|
236030
|
+
const acceptedInsertionReplacements = new Map;
|
|
236031
|
+
if (op.decision === "accept") {
|
|
236032
|
+
const resolveReplacement = createAcceptedInsertionReplacementResolver({
|
|
236033
|
+
xml: sourceXml,
|
|
236034
|
+
catalogFragments: catalog.byPart.get(partUri) ?? [],
|
|
236035
|
+
selectedFragments: sorted,
|
|
236036
|
+
elements: () => xmlAnalysis.original(partUri, sourceXml)
|
|
236037
|
+
});
|
|
236038
|
+
for (const fragment3 of sorted) {
|
|
236039
|
+
if (partPartials?.has(`${fragment3.byteStart}|${fragment3.byteEnd}`))
|
|
236040
|
+
continue;
|
|
236041
|
+
const rewrite = resolveReplacement(fragment3);
|
|
236042
|
+
if (rewrite)
|
|
236043
|
+
acceptedInsertionReplacements.set(trackedChangeFragmentKey(fragment3), rewrite);
|
|
236044
|
+
}
|
|
236045
|
+
}
|
|
235882
236046
|
const moveRangePairPlan = moveRangePlansByPart.get(partUri);
|
|
235883
236047
|
if (!moveRangePairPlan)
|
|
235884
236048
|
return rejected13(txId, "patch-precondition-failed");
|
|
@@ -236088,6 +236252,9 @@ function runTrackedChangeDecideCommitWithLookupContext(lookupContext, input, xml
|
|
|
236088
236252
|
}
|
|
236089
236253
|
const removedTrackedHyperlink = !specialRewrite && (op.decision === "reject" && f.kind === "ins" || op.decision === "accept" && f.kind === "del" && removesHyperlinkOwner(fOriginal)) ? componentContext || !useImmutableAssembler ? findRemovedTrackedHyperlinkWrapper(activeXml, f, componentContext?.namespaceBindings) : removedTrackedHyperlinks.get(trackedChangeFragmentKey(fOriginal)) ?? null : null;
|
|
236090
236254
|
let wholeReplacement = result.replacement;
|
|
236255
|
+
const acceptedReplacement = acceptedInsertionReplacements.get(trackedChangeFragmentKey(fOriginal));
|
|
236256
|
+
if (acceptedReplacement)
|
|
236257
|
+
wholeReplacement = acceptedReplacement.replacement;
|
|
236091
236258
|
if (result.deletedRange) {
|
|
236092
236259
|
const preserveAdjacentEndBoundaryWIdsForDrop = preserveAdjacentEndBoundaryWIdsForDroppedRange({
|
|
236093
236260
|
partXml: activeXml,
|
|
@@ -236148,8 +236315,9 @@ function runTrackedChangeDecideCommitWithLookupContext(lookupContext, input, xml
|
|
|
236148
236315
|
}
|
|
236149
236316
|
}
|
|
236150
236317
|
const consumedParentInsertion = !specialRewrite && !componentContext && op.decision === "accept" && f.kind === "del" && isSessionCreatedTextFragment(f, sessionCreatedTrackedChangeRsids, sessionCreatedTrackedChangeWIds) ? emptyParentInsertionConsumedByDeletion(lookupContext, activeXml, f, wholeReplacement) : null;
|
|
236151
|
-
const
|
|
236152
|
-
const
|
|
236318
|
+
const acceptedReplacementOffset = f.byteStart - fOriginal.byteStart;
|
|
236319
|
+
const spliceStart = acceptedReplacement ? acceptedReplacement.start + acceptedReplacementOffset : consumedParentInsertion?.start ?? removedTrackedHyperlink?.start ?? f.byteStart;
|
|
236320
|
+
const spliceEnd = acceptedReplacement ? acceptedReplacement.end + acceptedReplacementOffset : consumedParentInsertion?.end ?? removedTrackedHyperlink?.end ?? f.byteEnd;
|
|
236153
236321
|
if (componentContext && component) {
|
|
236154
236322
|
componentContext.workingXml = measureSDTxPerf("trackedChangeTextSpliceMs", () => activeXml.slice(0, spliceStart) + wholeReplacement + activeXml.slice(spliceEnd));
|
|
236155
236323
|
recordSDTxPerf("trackedChangeTextSplices", 1);
|
|
@@ -240369,6 +240537,7 @@ var init_compile_tracked_change_decide = __esm(() => {
|
|
|
240369
240537
|
init_bibliography_review_resources();
|
|
240370
240538
|
init_image_review_resources();
|
|
240371
240539
|
init_decision_xml_analysis();
|
|
240540
|
+
init_accepted_insertion_replacement();
|
|
240372
240541
|
init_compound_move_paragraph();
|
|
240373
240542
|
init_prepared_mutation();
|
|
240374
240543
|
init_patch_substrate();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/mcp",
|
|
3
|
-
"version": "1.8.0-next.
|
|
3
|
+
"version": "1.8.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.21.0-next.
|
|
27
|
+
"@superdoc/sdk": "2.21.0-next.7",
|
|
28
28
|
"debug": "^4.4.3",
|
|
29
29
|
"zod": "^4.3.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"superdoc": "2.24.0-next.
|
|
33
|
-
"@superdoc/docx-engine": "0.23.0-next.
|
|
32
|
+
"superdoc": "2.24.0-next.7",
|
|
33
|
+
"@superdoc/docx-engine": "0.23.0-next.7",
|
|
34
34
|
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
35
35
|
"@types/bun": "^1.3.8",
|
|
36
36
|
"@types/node": "22.19.2",
|