@superdoc/mcp 1.0.0-next.3 → 1.0.0-next.4

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 +311 -59
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -31979,7 +31979,7 @@ var init_contract = __esm(() => {
31979
31979
  "Response envelopes include elapsed_ms for all operations.",
31980
31980
  "JSON output mode is the default and must always be supported."
31981
31981
  ],
31982
- operationCount: 465,
31982
+ operationCount: 466,
31983
31983
  operations: [
31984
31984
  {
31985
31985
  id: "doc.get",
@@ -42888,6 +42888,25 @@ var init_contract = __esm(() => {
42888
42888
  ],
42889
42889
  errors: []
42890
42890
  },
42891
+ {
42892
+ id: "doc.discover",
42893
+ command: [
42894
+ "discover"
42895
+ ],
42896
+ description: "Find CLI operations from a natural-language intent. Returns an adaptive relevant set capped at ten results and expands the leading operation input shape.",
42897
+ category: "session",
42898
+ stability: "stable",
42899
+ mutates: false,
42900
+ requiresDocumentContext: false,
42901
+ capabilities: [],
42902
+ aliases: [],
42903
+ examples: [
42904
+ 'superdoc discover "create a footnote"',
42905
+ 'superdoc discover "add an sdt" --limit 10',
42906
+ 'superdoc discover "change table cell padding" --pretty'
42907
+ ],
42908
+ errors: []
42909
+ },
42891
42910
  {
42892
42911
  id: "doc.describe",
42893
42912
  command: [
@@ -43946,18 +43965,19 @@ var init_contract = __esm(() => {
43946
43965
  "doc.insertlinebreak": 437,
43947
43966
  "doc.executecode": 438,
43948
43967
  "doc.status": 439,
43949
- "doc.describe": 440,
43950
- "doc.describecommand": 441,
43951
- "doc.session.list": 442,
43952
- "doc.session.save": 443,
43953
- "doc.session.close": 444,
43954
- "doc.session.setdefault": 445,
43955
- "doc.preset.list": 446,
43956
- "doc.preset.getcatalog": 447,
43957
- "doc.preset.gettools": 448,
43958
- "doc.preset.getsystemprompt": 449,
43959
- "doc.preset.getmcpprompt": 450,
43960
- "doc.preset.dispatch": 451,
43968
+ "doc.discover": 440,
43969
+ "doc.describe": 441,
43970
+ "doc.describecommand": 442,
43971
+ "doc.session.list": 443,
43972
+ "doc.session.save": 444,
43973
+ "doc.session.close": 445,
43974
+ "doc.session.setdefault": 446,
43975
+ "doc.preset.list": 447,
43976
+ "doc.preset.getcatalog": 448,
43977
+ "doc.preset.gettools": 449,
43978
+ "doc.preset.getsystemprompt": 450,
43979
+ "doc.preset.getmcpprompt": 451,
43980
+ "doc.preset.dispatch": 452,
43961
43981
  get: 0,
43962
43982
  find: 1,
43963
43983
  "get-node": 2,
@@ -44398,32 +44418,33 @@ var init_contract = __esm(() => {
44398
44418
  "insert line-break": 437,
44399
44419
  "execute code": 438,
44400
44420
  status: 439,
44401
- describe: 440,
44402
- "describe command": 441,
44403
- "session list": 442,
44404
- "session save": 443,
44405
- "session close": 444,
44406
- "session set-default": 445,
44407
- "preset list": 446,
44408
- "preset get-catalog": 447,
44409
- "preset get-tools": 448,
44410
- "preset get-system-prompt": 449,
44411
- "preset get-mcp-prompt": 450,
44412
- "preset dispatch": 451,
44413
- "lists exit": 452,
44414
- "format strikethrough": 453,
44415
- "track-changes accept": 454,
44416
- "track-changes reject": 455,
44417
- "track-changes accept-all": 456,
44418
- "track-changes reject-all": 457,
44419
- "comments add": 458,
44420
- "comments reply": 459,
44421
- "comments edit": 460,
44422
- "comments move": 461,
44423
- "comments resolve": 462,
44424
- "comments remove": 463,
44425
- "comments set-internal": 464,
44426
- "session use": 445,
44421
+ discover: 440,
44422
+ describe: 441,
44423
+ "describe command": 442,
44424
+ "session list": 443,
44425
+ "session save": 444,
44426
+ "session close": 445,
44427
+ "session set-default": 446,
44428
+ "preset list": 447,
44429
+ "preset get-catalog": 448,
44430
+ "preset get-tools": 449,
44431
+ "preset get-system-prompt": 450,
44432
+ "preset get-mcp-prompt": 451,
44433
+ "preset dispatch": 452,
44434
+ "lists exit": 453,
44435
+ "format strikethrough": 454,
44436
+ "track-changes accept": 455,
44437
+ "track-changes reject": 456,
44438
+ "track-changes accept-all": 457,
44439
+ "track-changes reject-all": 458,
44440
+ "comments add": 459,
44441
+ "comments reply": 460,
44442
+ "comments edit": 461,
44443
+ "comments move": 462,
44444
+ "comments resolve": 463,
44445
+ "comments remove": 464,
44446
+ "comments set-internal": 465,
44447
+ "session use": 446,
44427
44448
  getnode: 2,
44428
44449
  getnodebyid: 3,
44429
44450
  gettext: 4,
@@ -44853,17 +44874,17 @@ var init_contract = __esm(() => {
44853
44874
  inserttab: 436,
44854
44875
  insertlinebreak: 437,
44855
44876
  executecode: 438,
44856
- describecommand: 441,
44857
- "session.list": 442,
44858
- "session.save": 443,
44859
- "session.close": 444,
44860
- "session.setdefault": 445,
44861
- "preset.list": 446,
44862
- "preset.getcatalog": 447,
44863
- "preset.gettools": 448,
44864
- "preset.getsystemprompt": 449,
44865
- "preset.getmcpprompt": 450,
44866
- "preset.dispatch": 451
44877
+ describecommand: 442,
44878
+ "session.list": 443,
44879
+ "session.save": 444,
44880
+ "session.close": 445,
44881
+ "session.setdefault": 446,
44882
+ "preset.list": 447,
44883
+ "preset.getcatalog": 448,
44884
+ "preset.gettools": 449,
44885
+ "preset.getsystemprompt": 450,
44886
+ "preset.getmcpprompt": 451,
44887
+ "preset.dispatch": 452
44867
44888
  }
44868
44889
  },
44869
44890
  operations: {
@@ -346303,6 +346324,175 @@ var init_contract = __esm(() => {
346303
346324
  ]
346304
346325
  }
346305
346326
  },
346327
+ "doc.discover": {
346328
+ operationId: "doc.discover",
346329
+ sdkSurface: "internal",
346330
+ command: "discover",
346331
+ commandTokens: [
346332
+ "discover"
346333
+ ],
346334
+ category: "session",
346335
+ description: "Find CLI operations from a natural-language intent. Returns an adaptive relevant set capped at ten results and expands the leading operation input shape.",
346336
+ requiresDocumentContext: false,
346337
+ docRequirement: "none",
346338
+ responseEnvelopeKey: null,
346339
+ params: [
346340
+ {
346341
+ name: "query",
346342
+ kind: "doc",
346343
+ type: "string",
346344
+ required: true,
346345
+ description: "Natural-language description of the operation to find."
346346
+ },
346347
+ {
346348
+ name: "limit",
346349
+ kind: "flag",
346350
+ type: "number",
346351
+ description: "Maximum results to return, from 1 through 10. Defaults to 10."
346352
+ }
346353
+ ],
346354
+ constraints: null,
346355
+ inputSchema: {
346356
+ type: "object",
346357
+ properties: {
346358
+ query: {
346359
+ type: "string",
346360
+ description: "Natural-language description of the operation to find."
346361
+ },
346362
+ limit: {
346363
+ type: "number",
346364
+ description: "Maximum results to return, from 1 through 10. Defaults to 10."
346365
+ }
346366
+ },
346367
+ required: [
346368
+ "query"
346369
+ ],
346370
+ additionalProperties: false
346371
+ },
346372
+ mutates: false,
346373
+ idempotency: "idempotent",
346374
+ supportsTrackedMode: false,
346375
+ supportsDryRun: false,
346376
+ outputSchema: {
346377
+ type: "object",
346378
+ properties: {
346379
+ contractVersion: {
346380
+ type: "string"
346381
+ },
346382
+ query: {
346383
+ type: "string"
346384
+ },
346385
+ interpretation: {
346386
+ type: "string",
346387
+ enum: [
346388
+ "clear",
346389
+ "ambiguous",
346390
+ "broad",
346391
+ "no-match"
346392
+ ]
346393
+ },
346394
+ resultCount: {
346395
+ type: "number"
346396
+ },
346397
+ maxResults: {
346398
+ type: "number"
346399
+ },
346400
+ capped: {
346401
+ type: "boolean"
346402
+ },
346403
+ results: {
346404
+ type: "array",
346405
+ items: {
346406
+ type: "object",
346407
+ properties: {
346408
+ rank: {
346409
+ type: "number"
346410
+ },
346411
+ operationId: {
346412
+ type: "string"
346413
+ },
346414
+ command: {
346415
+ type: "string"
346416
+ },
346417
+ description: {
346418
+ type: "string"
346419
+ },
346420
+ referenceGroup: {
346421
+ type: "string"
346422
+ },
346423
+ relevance: {
346424
+ type: "string",
346425
+ enum: [
346426
+ "exact",
346427
+ "strong",
346428
+ "relevant",
346429
+ "related"
346430
+ ]
346431
+ },
346432
+ score: {
346433
+ type: "number",
346434
+ description: "Query-relative ranking score; not a probability."
346435
+ },
346436
+ matched: {
346437
+ type: "array",
346438
+ items: {
346439
+ type: "string"
346440
+ }
346441
+ },
346442
+ useWhen: {
346443
+ type: "string"
346444
+ },
346445
+ avoidWhen: {
346446
+ type: "array",
346447
+ items: {
346448
+ type: "string"
346449
+ }
346450
+ },
346451
+ defaults: {
346452
+ type: "object"
346453
+ },
346454
+ schemaCommand: {
346455
+ type: "string"
346456
+ },
346457
+ input: {
346458
+ type: "object"
346459
+ },
346460
+ relations: {
346461
+ type: "array",
346462
+ items: {
346463
+ type: "object"
346464
+ }
346465
+ }
346466
+ },
346467
+ required: [
346468
+ "rank",
346469
+ "operationId",
346470
+ "command",
346471
+ "description",
346472
+ "referenceGroup",
346473
+ "relevance",
346474
+ "score",
346475
+ "matched",
346476
+ "schemaCommand"
346477
+ ]
346478
+ }
346479
+ },
346480
+ guidance: {
346481
+ type: "string"
346482
+ }
346483
+ },
346484
+ required: [
346485
+ "contractVersion",
346486
+ "query",
346487
+ "interpretation",
346488
+ "resultCount",
346489
+ "maxResults",
346490
+ "capped",
346491
+ "results"
346492
+ ]
346493
+ },
346494
+ skipAsATool: true
346495
+ },
346306
346496
  "doc.describe": {
346307
346497
  operationId: "doc.describe",
346308
346498
  sdkSurface: "client",
@@ -347730,6 +347920,7 @@ function createDocApi(runtime) {
347730
347920
  insertLineBreak: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.insertLineBreak"], params, options),
347731
347921
  executeCode: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.executeCode"], params, options),
347732
347922
  status: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.status"], params, options),
347923
+ discover: (params, options) => runtime.invoke(CONTRACT.operations["doc.discover"], params, options),
347733
347924
  describe: (params = {}, options) => runtime.invoke(CONTRACT.operations["doc.describe"], params, options),
347734
347925
  describeCommand: (params, options) => runtime.invoke(CONTRACT.operations["doc.describeCommand"], params, options),
347735
347926
  session: {
@@ -349450,7 +349641,7 @@ var init_host = __esm(() => {
349450
349641
  });
349451
349642
 
349452
349643
  // ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
349453
- var SDK_VERSION = "2.13.0-next.5";
349644
+ var SDK_VERSION = "2.13.0-next.6";
349454
349645
 
349455
349646
  // ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
349456
349647
  import { chmodSync, existsSync } from "node:fs";
@@ -691062,6 +691253,9 @@ function isRunBackedAttributedBreak(segment) {
691062
691253
  return segment.atomKind === INLINE_ATOM_KIND.preserved && segment.visibleLength === 1 && segment.meta.tag === "br" && segment.meta.container === "run-child";
691063
691254
  }
691064
691255
  function parseDeletedTextRunXml(runXml) {
691256
+ return parseDeletedTextRunSegmentsXml(runXml).filter((segment) => segment.kind === "run");
691257
+ }
691258
+ function parseDeletedTextRunSegmentsXml(runXml) {
691065
691259
  const out = [];
691066
691260
  let cursor = 0;
691067
691261
  while (cursor < runXml.length) {
@@ -691069,7 +691263,7 @@ function parseDeletedTextRunXml(runXml) {
691069
691263
  if (!next)
691070
691264
  break;
691071
691265
  if (localName2(next.openTagInner) === "r") {
691072
- out.push(...parseRun2(next.xml, "delText").filter((segment) => segment.kind === "run"));
691266
+ out.push(...parseRun2(next.xml, "delText"));
691073
691267
  }
691074
691268
  cursor = next.end;
691075
691269
  }
@@ -708116,17 +708310,44 @@ function applyTrackedTextDecisionsToStory(input) {
708116
708310
  }
708117
708311
  }
708118
708312
  if (span.trackedKind === "del" && input.decision === "reject") {
708313
+ const found = findBlockMap(input.doc, span.blockId)?.block;
708314
+ if (!found)
708315
+ throw new Error(`target block ${span.blockId} is not present in the story shard`);
708119
708316
  let offset = span.startOffset;
708120
- for (const run of span.deletedRuns) {
708317
+ let restoredBreakXml = null;
708318
+ let restoredBreakOrdinal = 0;
708319
+ for (const segment of span.deletedSegments) {
708320
+ if (segment.kind === "atom") {
708321
+ restoredBreakXml = typeof segment.meta.sourceXml === "string" ? segment.meta.sourceXml : segment.xml;
708322
+ continue;
708323
+ }
708121
708324
  insertText2({
708122
708325
  doc: input.doc,
708123
708326
  blockId: span.blockId,
708124
708327
  offset,
708125
- text: run.text,
708126
- attributes: exactRunAttributes(run.attributes),
708328
+ text: segment.text,
708329
+ attributes: exactRunAttributes(segment.attributes),
708127
708330
  origin: STORY_SURFACE_BACKEND_ORIGIN
708128
708331
  });
708129
- offset += run.text.length;
708332
+ if (restoredBreakXml) {
708333
+ if (segment.text !== `
708334
+ `) {
708335
+ throw new Error(`attributed break restoration in ${span.blockId} has no matching break character`);
708336
+ }
708337
+ restoredBreakOrdinal += 1;
708338
+ getBlockAtoms(found).push([
708339
+ createRestoredAttributedBreakAtom({
708340
+ id: `${span.startAtomId}:restored-break:${input.txId}:${restoredBreakOrdinal}`,
708341
+ offset,
708342
+ sourceXml: restoredBreakXml
708343
+ })
708344
+ ]);
708345
+ restoredBreakXml = null;
708346
+ }
708347
+ offset += segment.text.length;
708348
+ }
708349
+ if (restoredBreakXml) {
708350
+ throw new Error(`attributed break restoration in ${span.blockId} is incomplete`);
708130
708351
  }
708131
708352
  }
708132
708353
  }
@@ -708186,8 +708407,24 @@ function collectLiveTrackedTextSpansInBlock(block, rsid, trackedKind) {
708186
708407
  const end = ends[endIndex];
708187
708408
  usedEnds.add(endIndex);
708188
708409
  const contained = atoms.filter((atom) => atom.index > start.index && atom.index < end.index);
708189
- const preservedForSpan = trackedKind === "del" ? contained.filter((atom) => atom.atomKind === INLINE_ATOM_KIND.preserved && atom.meta.tag === "delTextRun" && String(atom.meta.rsid ?? "") === rsid) : [];
708190
- const deletedRuns = preservedForSpan.flatMap((atom) => parseDeletedTextRunXml(atom.xml));
708410
+ const preservedWithSegments = trackedKind === "del" ? contained.flatMap((atom) => {
708411
+ if (atom.atomKind !== INLINE_ATOM_KIND.preserved)
708412
+ return [];
708413
+ const isDeletedTextRun = atom.meta.tag === "delTextRun" && String(atom.meta.rsid ?? "") === rsid;
708414
+ const isOpaqueDeletionRun = atom.meta.tag === "r" && atom.meta.container === "tracked-deletion";
708415
+ if (!isDeletedTextRun && !isOpaqueDeletionRun)
708416
+ return [];
708417
+ const segments = parseDeletedTextRunSegmentsXml(atom.xml);
708418
+ const isOpaquePlainBreakRun = segments.length > 0 && segments.every((segment) => segment.kind === "run" && segment.text.length > 0 && /^\n+$/.test(segment.text));
708419
+ if (isOpaqueDeletionRun && !segments.some((segment) => segment.kind === "atom") && !isOpaquePlainBreakRun)
708420
+ return [];
708421
+ if (segments.some((segment) => segment.kind === "atom" && !(segment.meta.tag === "br" && segment.visibleLength === 1)))
708422
+ return [];
708423
+ return [{ atom, segments }];
708424
+ }) : [];
708425
+ const preservedForSpan = preservedWithSegments.map(({ atom }) => atom);
708426
+ const deletedSegments = preservedWithSegments.flatMap(({ segments }) => segments);
708427
+ const deletedRuns = deletedSegments.filter((segment) => segment.kind === "run");
708191
708428
  const deletedTextLength2 = deletedRuns.reduce((length3, run) => length3 + run.text.length, 0);
708192
708429
  spans.push({
708193
708430
  trackedKind,
@@ -708198,7 +708435,8 @@ function collectLiveTrackedTextSpansInBlock(block, rsid, trackedKind) {
708198
708435
  endAtomId: end.id,
708199
708436
  preservedAtomIds: preservedForSpan.map((atom) => atom.id),
708200
708437
  containedAtomIds: contained.map((atom) => atom.id),
708201
- deletedRuns
708438
+ deletedRuns,
708439
+ deletedSegments
708202
708440
  });
708203
708441
  }
708204
708442
  return spans;
@@ -709381,6 +709619,20 @@ function createPreservedAtom(input) {
709381
709619
  atom.set(ATOM_KEY.meta, input.meta);
709382
709620
  return atom;
709383
709621
  }
709622
+ function createRestoredAttributedBreakAtom(input) {
709623
+ const atom = new YMap;
709624
+ atom.set(ATOM_KEY.id, input.id);
709625
+ atom.set(ATOM_KEY.kind, INLINE_ATOM_KIND.preserved);
709626
+ atom.set(ATOM_KEY.visibleOffset, input.offset);
709627
+ atom.set(ATOM_KEY.length, 1);
709628
+ atom.set(ATOM_KEY.xml, "");
709629
+ atom.set(ATOM_KEY.meta, {
709630
+ tag: "br",
709631
+ container: "run-child",
709632
+ sourceXml: input.sourceXml
709633
+ });
709634
+ return atom;
709635
+ }
709384
709636
  function createTrackedAnchor(input) {
709385
709637
  const anchor = new YMap;
709386
709638
  anchor.set(ANCHOR_KEY.id, input.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/mcp",
3
- "version": "1.0.0-next.3",
3
+ "version": "1.0.0-next.4",
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,7 +24,7 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@modelcontextprotocol/sdk": "^1.26.0",
27
- "@superdoc/sdk": "2.13.0-next.5",
27
+ "@superdoc/sdk": "2.13.0-next.6",
28
28
  "debug": "^4.4.3",
29
29
  "zod": "^4.3.6"
30
30
  },