@superdoc-dev/sdk 1.3.0-next.7 → 1.3.0-next.70

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.
@@ -33,6 +33,7 @@ function dispatchIntentTool(toolName, args, execute) {
33
33
  case 'set_alignment': return execute('doc.format.paragraph.setAlignment', rest);
34
34
  case 'set_indentation': return execute('doc.format.paragraph.setIndentation', rest);
35
35
  case 'set_spacing': return execute('doc.format.paragraph.setSpacing', rest);
36
+ case 'set_flow_options': return execute('doc.format.paragraph.setFlowOptions', rest);
36
37
  case 'set_direction': return execute('doc.format.paragraph.setDirection', rest);
37
38
  default: throw new Error(`Unknown action for superdoc_format: ${action}`);
38
39
  }
@@ -42,6 +43,7 @@ function dispatchIntentTool(toolName, args, execute) {
42
43
  switch (action) {
43
44
  case 'paragraph': return execute('doc.create.paragraph', rest);
44
45
  case 'heading': return execute('doc.create.heading', rest);
46
+ case 'table': return execute('doc.create.table', rest);
45
47
  default: throw new Error(`Unknown action for superdoc_create: ${action}`);
46
48
  }
47
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"intent-dispatch.generated.d.ts","sourceRoot":"","sources":["../../src/generated/intent-dispatch.generated.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,GACxE,OAAO,CAyFT"}
1
+ {"version":3,"file":"intent-dispatch.generated.d.ts","sourceRoot":"","sources":["../../src/generated/intent-dispatch.generated.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,GACxE,OAAO,CA2FT"}
@@ -31,6 +31,7 @@ export function dispatchIntentTool(toolName, args, execute) {
31
31
  case 'set_alignment': return execute('doc.format.paragraph.setAlignment', rest);
32
32
  case 'set_indentation': return execute('doc.format.paragraph.setIndentation', rest);
33
33
  case 'set_spacing': return execute('doc.format.paragraph.setSpacing', rest);
34
+ case 'set_flow_options': return execute('doc.format.paragraph.setFlowOptions', rest);
34
35
  case 'set_direction': return execute('doc.format.paragraph.setDirection', rest);
35
36
  default: throw new Error(`Unknown action for superdoc_format: ${action}`);
36
37
  }
@@ -40,6 +41,7 @@ export function dispatchIntentTool(toolName, args, execute) {
40
41
  switch (action) {
41
42
  case 'paragraph': return execute('doc.create.paragraph', rest);
42
43
  case 'heading': return execute('doc.create.heading', rest);
44
+ case 'table': return execute('doc.create.table', rest);
43
45
  default: throw new Error(`Unknown action for superdoc_create: ${action}`);
44
46
  }
45
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/sdk",
3
- "version": "1.3.0-next.7",
3
+ "version": "1.3.0-next.70",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -26,11 +26,11 @@
26
26
  "typescript": "^5.9.2"
27
27
  },
28
28
  "optionalDependencies": {
29
- "@superdoc-dev/sdk-darwin-arm64": "1.3.0-next.7",
30
- "@superdoc-dev/sdk-darwin-x64": "1.3.0-next.7",
31
- "@superdoc-dev/sdk-linux-x64": "1.3.0-next.7",
32
- "@superdoc-dev/sdk-linux-arm64": "1.3.0-next.7",
33
- "@superdoc-dev/sdk-windows-x64": "1.3.0-next.7"
29
+ "@superdoc-dev/sdk-darwin-arm64": "1.3.0-next.70",
30
+ "@superdoc-dev/sdk-linux-x64": "1.3.0-next.70",
31
+ "@superdoc-dev/sdk-darwin-x64": "1.3.0-next.70",
32
+ "@superdoc-dev/sdk-linux-arm64": "1.3.0-next.70",
33
+ "@superdoc-dev/sdk-windows-x64": "1.3.0-next.70"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
@@ -5,7 +5,7 @@
5
5
  "tools": [
6
6
  {
7
7
  "toolName": "superdoc_get_content",
8
- "description": "Read document content. Use action \"info\" for structure and styles, \"blocks\" for all block IDs and types, \"text\" or \"markdown\" for content. Call info or blocks before editing.",
8
+ "description": "Read document content in various formats. Call this first in any workflow to understand document structure before making edits. Action \"blocks\" returns structured block data with nodeId, nodeType, textPreview, formatting properties (fontFamily, fontSize, color, bold, underline, alignment), and ref handles for immediate use with superdoc_edit or superdoc_format. Action \"text\" and \"markdown\" return the full document as plain text or Markdown. Action \"html\" returns HTML. Action \"info\" returns document metadata: word count, paragraph count, page count, outline, available styles, and capability flags. The \"blocks\" action supports pagination via \"offset\" and \"limit\", and filtering via \"nodeTypes\". Other actions ignore these parameters. This tool never modifies the document. Do NOT call superdoc_edit or superdoc_format without first reading blocks to get valid refs and formatting reference values.",
9
9
  "inputSchema": {
10
10
  "type": "object",
11
11
  "properties": {
@@ -81,7 +81,7 @@
81
81
  },
82
82
  {
83
83
  "toolName": "superdoc_edit",
84
- "description": "Insert, replace, delete text, or undo/redo",
84
+ "description": "Refs expire after any mutation; always re-search before the next edit. Modify document text: insert new content, replace existing text, delete a range, or undo/redo. Use this for single text modifications. For 2+ edits that must succeed or fail atomically, use superdoc_mutations instead. For replace and delete, pass a \"ref\" from superdoc_search or superdoc_get_content blocks. A search ref covers only the matched substring; a block ref covers the entire block text, so use block refs when rewriting or shortening whole paragraphs. Insert supports plain text (default), markdown, or html via the \"type\" parameter. Use \"placement\" (before, after, insideStart, insideEnd) to control position relative to the target. Supports \"dryRun\" to preview changes and \"changeMode: tracked\" to record edits as tracked changes. Do NOT build \"target\" objects manually when a ref is available; prefer \"ref\" for simpler, more reliable targeting.",
85
85
  "inputSchema": {
86
86
  "type": "object",
87
87
  "properties": {
@@ -303,7 +303,7 @@
303
303
  ]
304
304
  }
305
305
  ],
306
- "description": "Target address object. Use 'ref' instead if you have a search handle. Format: {kind:'text', blockId, range:{start,end}} or {kind:'block', nodeType, nodeId}."
306
+ "description": "Target address. For inline/set_style: prefer 'ref' from superdoc_search, or use {kind:'selection', start:{kind:'text', blockId, offset}, end:{kind:'text', blockId, offset}}. For paragraph actions (set_alignment, set_indentation, set_spacing, set_direction, set_flow_options): use {kind:'block', nodeType:'paragraph'|'heading'|'listItem', nodeId:'<nodeId from blocks list>'}."
307
307
  },
308
308
  "value": {
309
309
  "type": "string",
@@ -320,7 +320,7 @@
320
320
  },
321
321
  "ref": {
322
322
  "type": "string",
323
- "description": "Handle ref string returned by a prior search/query result."
323
+ "description": "Handle ref from superdoc_search result (pass handle.ref value directly). Preferred over building a target object."
324
324
  },
325
325
  "content": {
326
326
  "oneOf": [
@@ -360,22 +360,6 @@
360
360
  },
361
361
  "description": "Controls nesting behavior. tables: 'allow' permits inserting tables inside other tables. Only for actions 'insert', 'replace'. Omit for other actions."
362
362
  },
363
- "blockId": {
364
- "type": "string",
365
- "description": "Block ID of the target paragraph."
366
- },
367
- "start": {
368
- "type": "number",
369
- "description": "Start offset within the block (character index)."
370
- },
371
- "end": {
372
- "type": "number",
373
- "description": "End offset within the block (character index)."
374
- },
375
- "offset": {
376
- "type": "number",
377
- "description": "Character offset for insertion (alias for --start/--end with same value). Only for action 'insert'. Omit for other actions."
378
- },
379
363
  "text": {
380
364
  "type": "string",
381
365
  "description": "Replacement text content. Only for action 'replace'. Omit for other actions."
@@ -462,7 +446,7 @@
462
446
  },
463
447
  {
464
448
  "toolName": "superdoc_format",
465
- "description": "Change text and paragraph formatting. Use action \"inline\" with a search ref for bold/italic/etc. Use action \"set_style\" with a styleId from superdoc_get_content info to apply a named paragraph style.",
449
+ "description": "Change text and paragraph formatting. Use this after superdoc_create to style new content, or with a search ref to restyle existing text. Action \"inline\" applies character formatting (bold, italic, underline, color, fontSize, fontFamily, highlight, strike, vertAlign) to a text range via \"ref\". Action \"set_style\" applies a named paragraph style by styleId (get available styles from superdoc_get_content info). Actions \"set_alignment\", \"set_indentation\", \"set_spacing\", \"set_direction\", and \"set_flow_options\" change paragraph-level properties and require a block target: {kind:\"block\", nodeType:\"paragraph\", nodeId:\"<nodeId>\"}, NOT a ref. Use \"set_flow_options\" with pageBreakBefore:true to start a paragraph on a new page. Supports \"dryRun\" and \"changeMode: tracked\" for inline formatting. Paragraph-level actions do NOT support tracked changes. Do NOT use a search ref for paragraph-level actions; they require a block target with nodeId. Do NOT use {kind:\"block\", start:{kind:\"nodeEdge\",...}} or selection-like structures for paragraph actions. ONLY {kind:\"block\", nodeType, nodeId} is accepted. Do NOT issue multiple superdoc_format calls in parallel; each call invalidates refs for subsequent calls. Format one block at a time. Do NOT hardcode formatting values; always read them from superdoc_get_content blocks and replicate.",
466
450
  "inputSchema": {
467
451
  "type": "object",
468
452
  "properties": {
@@ -472,11 +456,12 @@
472
456
  "inline",
473
457
  "set_alignment",
474
458
  "set_direction",
459
+ "set_flow_options",
475
460
  "set_indentation",
476
461
  "set_spacing",
477
462
  "set_style"
478
463
  ],
479
- "description": "The action to perform. One of: inline, set_alignment, set_direction, set_indentation, set_spacing, set_style."
464
+ "description": "The action to perform. One of: inline, set_alignment, set_direction, set_flow_options, set_indentation, set_spacing, set_style."
480
465
  },
481
466
  "force": {
482
467
  "type": "boolean",
@@ -651,7 +636,7 @@
651
636
  "start",
652
637
  "end"
653
638
  ],
654
- "description": "Selection target: {kind:'selection', start:{kind:'text', blockId, offset}, end:{kind:'text', blockId, offset}}. Use 'ref' instead when you have a search result handle. Required for actions 'set_style', 'set_alignment', 'set_indentation', 'set_spacing', 'set_direction'."
639
+ "description": "Selection target: {kind:'selection', start:{kind:'text', blockId, offset}, end:{kind:'text', blockId, offset}}. Use 'ref' instead when you have a search result handle. Required for actions 'set_style', 'set_alignment', 'set_indentation', 'set_spacing', 'set_flow_options', 'set_direction'."
655
640
  },
656
641
  "inline": {
657
642
  "type": "object",
@@ -969,6 +954,18 @@
969
954
  "atLeast"
970
955
  ]
971
956
  },
957
+ "contextualSpacing": {
958
+ "type": "boolean",
959
+ "description": "Only for action 'set_flow_options'. Omit for other actions."
960
+ },
961
+ "pageBreakBefore": {
962
+ "type": "boolean",
963
+ "description": "Only for action 'set_flow_options'. Omit for other actions."
964
+ },
965
+ "suppressAutoHyphens": {
966
+ "type": "boolean",
967
+ "description": "Only for action 'set_flow_options'. Omit for other actions."
968
+ },
972
969
  "direction": {
973
970
  "type": "string",
974
971
  "enum": [
@@ -1037,6 +1034,24 @@
1037
1034
  "target"
1038
1035
  ]
1039
1036
  },
1037
+ {
1038
+ "operationId": "doc.format.paragraph.setFlowOptions",
1039
+ "intentAction": "set_flow_options",
1040
+ "requiredOneOf": [
1041
+ [
1042
+ "target",
1043
+ "contextualSpacing"
1044
+ ],
1045
+ [
1046
+ "target",
1047
+ "pageBreakBefore"
1048
+ ],
1049
+ [
1050
+ "target",
1051
+ "suppressAutoHyphens"
1052
+ ]
1053
+ ]
1054
+ },
1040
1055
  {
1041
1056
  "operationId": "doc.format.paragraph.setDirection",
1042
1057
  "intentAction": "set_direction",
@@ -1049,7 +1064,7 @@
1049
1064
  },
1050
1065
  {
1051
1066
  "toolName": "superdoc_create",
1052
- "description": "Create one paragraph or heading per call. After creating, search for it and apply formatting (fontFamily, fontSize) from neighboring blocks. For multiple paragraphs, use superdoc_mutations with text.insert steps instead of calling create repeatedly.",
1067
+ "description": "You MUST call superdoc_format after this tool to match document styling. Create a single paragraph, heading, or table in the document. Returns a nodeId for chaining subsequent creates and for use as a block target in superdoc_format. When the user asks for a \"heading\", use action \"heading\" with a level (default 1). Use action \"paragraph\" only when the user asks for regular body text. Before creating, call superdoc_get_content blocks to read formatting from regular body text paragraphs (non-empty, non-title blocks with alignment \"justify\" or \"left\"). After creating, re-fetch blocks with superdoc_get_content to get a fresh ref for the new block, then apply TWO format calls: (1) superdoc_format action \"inline\" for character styling, AND (2) superdoc_format action \"set_alignment\" with the block target for paragraph alignment. Both calls are REQUIRED. For body paragraphs: inline {bold:false, underline:false, fontFamily, fontSize, color from body blocks}, alignment \"justify\". Ignore underline:true from blocks data for body text; it is a style artifact. For headings: inline {bold:true, underline:true, fontSize scaled up, fontFamily, color}, alignment \"center\". Position with \"at\": {kind:\"documentEnd\"} (default), {kind:\"documentStart\"}, or {kind:\"after\"/\"before\", target:{kind:\"block\", nodeType, nodeId}} for relative placement. When creating multiple items in sequence, use the previous response nodeId as the next \"at\" target to maintain correct ordering. Do NOT use newlines in \"text\" to create multiple paragraphs; call this tool separately for each one.",
1053
1068
  "inputSchema": {
1054
1069
  "type": "object",
1055
1070
  "properties": {
@@ -1057,9 +1072,10 @@
1057
1072
  "type": "string",
1058
1073
  "enum": [
1059
1074
  "heading",
1060
- "paragraph"
1075
+ "paragraph",
1076
+ "table"
1061
1077
  ],
1062
- "description": "The action to perform. One of: heading, paragraph."
1078
+ "description": "The action to perform. One of: heading, paragraph, table."
1063
1079
  },
1064
1080
  "force": {
1065
1081
  "type": "boolean",
@@ -1203,6 +1219,14 @@
1203
1219
  "level": {
1204
1220
  "type": "number",
1205
1221
  "description": "Heading level (1-6). Required for action 'heading'."
1222
+ },
1223
+ "rows": {
1224
+ "type": "number",
1225
+ "description": "Required for action 'table'."
1226
+ },
1227
+ "columns": {
1228
+ "type": "number",
1229
+ "description": "Required for action 'table'."
1206
1230
  }
1207
1231
  },
1208
1232
  "required": [
@@ -1222,12 +1246,20 @@
1222
1246
  "required": [
1223
1247
  "level"
1224
1248
  ]
1249
+ },
1250
+ {
1251
+ "operationId": "doc.create.table",
1252
+ "intentAction": "table",
1253
+ "required": [
1254
+ "rows",
1255
+ "columns"
1256
+ ]
1225
1257
  }
1226
1258
  ]
1227
1259
  },
1228
1260
  {
1229
1261
  "toolName": "superdoc_list",
1230
- "description": "Create and manipulate lists",
1262
+ "description": "Create and manipulate bullet and numbered lists. To create a list: first create all paragraphs at the SAME location using superdoc_create (chain each using the previous nodeId as the \"at\" target). Then call action \"create\" with mode:\"fromParagraphs\", a preset (\"disc\" for bullet, \"decimal\" for numbered), and a range target: {from:{kind:\"block\", nodeType:\"paragraph\", nodeId:\"<first>\"}, to:{kind:\"block\", nodeType:\"paragraph\", nodeId:\"<last>\"}}. The range converts ALL paragraphs between from and to into list items. Make sure no other content exists between them. Action \"set_type\" converts between bullet and ordered (target any item in the list, kind:\"ordered\" or \"bullet\"). Action \"insert\" adds a new item before/after a target list item. Actions \"indent\" and \"outdent\" change nesting level; \"set_level\" jumps to a specific level (0-8). Action \"detach\" converts a list item back to a plain paragraph. Do NOT target paragraphs with indent/outdent/set_type; these actions require a listItem target.",
1231
1263
  "inputSchema": {
1232
1264
  "type": "object",
1233
1265
  "properties": {
@@ -1536,7 +1568,7 @@
1536
1568
  },
1537
1569
  {
1538
1570
  "toolName": "superdoc_comment",
1539
- "description": "Comment threads — create, edit, delete",
1571
+ "description": "Manage document comment threads: create, read, update, and delete. To create a comment, first use superdoc_search to find the target text, then pass action \"create\" with the comment text and a target: {kind:\"text\", blockId:\"<blockId>\", range:{start:<N>, end:<N>}} using the blockId and highlightRange from the search result. For threaded replies, pass \"parentId\" with the parent comment ID. Action \"list\" returns all comments with optional pagination (limit, offset) and filtering (includeResolved:true to include resolved). Action \"get\" retrieves a single comment by ID. Action \"update\" changes status to \"resolved\" or marks as internal. Action \"delete\" removes a comment or reply by ID. Do NOT pass \"ref\", \"id\", or \"parentId\" when creating a new top-level comment; only \"action\", \"text\", and \"target\" are needed.",
1540
1572
  "inputSchema": {
1541
1573
  "type": "object",
1542
1574
  "properties": {
@@ -1672,7 +1704,7 @@
1672
1704
  },
1673
1705
  {
1674
1706
  "toolName": "superdoc_track_changes",
1675
- "description": "Review and resolve tracked changes",
1707
+ "description": "Review and resolve tracked changes (insertions, deletions, format changes) in the document. Action \"list\" returns all tracked changes with optional filtering by type (insert, delete, format) and pagination (limit, offset). Each change includes an ID, type, author, timestamp, and content preview. Action \"decide\" accepts or rejects changes. Pass decision:\"accept\" to apply the change permanently, or decision:\"reject\" to discard it. Target a single change with {id:\"<changeId>\"} or all changes at once with {scope:\"all\"}. Do NOT use this tool unless the document has tracked changes. Use superdoc_get_content info to check the tracked change count first.",
1676
1708
  "inputSchema": {
1677
1709
  "type": "object",
1678
1710
  "properties": {
@@ -1774,7 +1806,7 @@
1774
1806
  },
1775
1807
  {
1776
1808
  "toolName": "superdoc_search",
1777
- "description": "Find text or nodes in the document",
1809
+ "description": "Refs expire after any mutation; always re-search before the next edit. Find text patterns or nodes in the document and get ref handles for targeting edits and formatting. Use this to locate content before calling superdoc_edit or superdoc_format. Text search returns handle.ref covering only the matched substring. Node search finds blocks by type (paragraph, heading, table, listItem, etc.). The \"require\" parameter controls match cardinality: \"first\" returns one match, \"all\" returns every match, \"exactlyOne\" fails if not exactly one match. Supports scoping via \"within\" to search inside a single block. Do NOT use regex or markdown formatting markers (#, **, etc.) in search patterns; patterns are plain text only. Do NOT use this tool when you already have a ref from superdoc_get_content blocks or superdoc_create; use that ref directly.",
1778
1810
  "inputSchema": {
1779
1811
  "type": "object",
1780
1812
  "properties": {
@@ -1939,7 +1971,7 @@
1939
1971
  },
1940
1972
  {
1941
1973
  "toolName": "superdoc_mutations",
1942
- "description": "Atomic multi-step batch edits (escape hatch)",
1974
+ "description": "All steps succeed or all fail; no partial application. Execute multiple text edits atomically in a single batch. Use this INSTEAD OF multiple sequential superdoc_edit calls when you need 2+ text changes that should succeed or fail together. Each step has an id (e.g. \"s1\"), an op (text.rewrite, text.insert, text.delete, format.apply, assert), a \"where\" clause for targeting ({by:\"select\", select:{...}, require:\"first\"|\"exactlyOne\"|\"all\"} or {by:\"ref\", ref:\"...\"}), and \"args\" with operation-specific parameters. Action \"preview\" dry-runs the plan without modifying the document. Action \"apply\" executes it. CRITICAL: split mutations by phase. Text mutations (text.rewrite, text.insert, text.delete) go in one call. Formatting (format.apply) goes in a separate call with fresh refs from a new superdoc_search. Do NOT create two steps that target overlapping text in the same block; combine them into a single text.rewrite step. Overlapping steps fail with PLAN_CONFLICT_OVERLAP. Do NOT use this for single edits; use superdoc_edit instead. Do NOT mix text mutations and formatting in the same call.",
1943
1975
  "inputSchema": {
1944
1976
  "type": "object",
1945
1977
  "properties": {
@@ -53,6 +53,8 @@ def dispatch_intent_tool(
53
53
  return execute('doc.format.paragraph.setIndentation', rest)
54
54
  elif action == 'set_spacing':
55
55
  return execute('doc.format.paragraph.setSpacing', rest)
56
+ elif action == 'set_flow_options':
57
+ return execute('doc.format.paragraph.setFlowOptions', rest)
56
58
  elif action == 'set_direction':
57
59
  return execute('doc.format.paragraph.setDirection', rest)
58
60
  else:
@@ -64,6 +66,8 @@ def dispatch_intent_tool(
64
66
  return execute('doc.create.paragraph', rest)
65
67
  elif action == 'heading':
66
68
  return execute('doc.create.heading', rest)
69
+ elif action == 'table':
70
+ return execute('doc.create.table', rest)
67
71
  else:
68
72
  raise SuperDocError(f'Unknown action for superdoc_create: {action}', code='TOOL_DISPATCH_NOT_FOUND', details={'toolName': 'superdoc_create', 'action': action})
69
73
  elif tool_name == 'superdoc_list':