@superdoc/sdk 2.13.1-next.8 → 2.13.1-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.
@@ -95,6 +95,15 @@ function stripCorruptedToolArgKeys(value) {
95
95
  }
96
96
  return clean;
97
97
  }
98
+ /**
99
+ * Arguments the action surface used to advertise and no longer accepts. A model
100
+ * prompted from an older surface (or trained on one) still sends them, and the
101
+ * generic "Unknown argument(s)" message does not say what to reach for instead,
102
+ * so the call dead-ends. Naming the replacement makes the refusal recoverable.
103
+ */
104
+ const RETIRED_ACTION_ARGS = {
105
+ dryRun: "dryRun is not supported by superdoc_perform_action: no action previews a mutation. To make an edit reviewable before it is final, pass changeMode: 'tracked' on an action that records tracked changes; to take one back, use the undo_changes action.",
106
+ };
98
107
  function validateAgentToolArgs(toolName, args) {
99
108
  const definition = catalog.AGENT_TOOL_DEFINITIONS.find((entry) => entry.name === toolName);
100
109
  if (definition == null)
@@ -105,9 +114,21 @@ function validateAgentToolArgs(toolName, args) {
105
114
  const knownKeys = new Set(Object.keys(properties));
106
115
  const unknownKeys = Object.keys(args).filter((key) => !knownKeys.has(key));
107
116
  if (unknownKeys.length > 0) {
108
- throw new errors.SuperDocCliError(`Unknown argument(s) for ${toolName}: ${unknownKeys.join(', ')}`, {
117
+ // hasOwn, not `in`: an argument named `constructor` or `toString` would
118
+ // otherwise match the prototype chain and report a native function as its
119
+ // replacement guidance.
120
+ const retiredKeys = unknownKeys.filter((key) => Object.hasOwn(RETIRED_ACTION_ARGS, key));
121
+ const message = retiredKeys.length > 0
122
+ ? retiredKeys.map((key) => RETIRED_ACTION_ARGS[key]).join(' ')
123
+ : `Unknown argument(s) for ${toolName}: ${unknownKeys.join(', ')}`;
124
+ throw new errors.SuperDocCliError(message, {
109
125
  code: 'INVALID_ARGUMENT',
110
- details: { toolName, unknownKeys, knownKeys: [...knownKeys] },
126
+ details: {
127
+ toolName,
128
+ unknownKeys,
129
+ knownKeys: [...knownKeys],
130
+ ...(retiredKeys.length > 0 ? { retiredKeys } : {}),
131
+ },
111
132
  });
112
133
  }
113
134
  const missingKeys = required.filter((key) => args[key] == null);
@@ -91,6 +91,15 @@ function stripCorruptedToolArgKeys(value) {
91
91
  }
92
92
  return clean;
93
93
  }
94
+ /**
95
+ * Arguments the action surface used to advertise and no longer accepts. A model
96
+ * prompted from an older surface (or trained on one) still sends them, and the
97
+ * generic "Unknown argument(s)" message does not say what to reach for instead,
98
+ * so the call dead-ends. Naming the replacement makes the refusal recoverable.
99
+ */
100
+ const RETIRED_ACTION_ARGS = {
101
+ dryRun: "dryRun is not supported by superdoc_perform_action: no action previews a mutation. To make an edit reviewable before it is final, pass changeMode: 'tracked' on an action that records tracked changes; to take one back, use the undo_changes action.",
102
+ };
94
103
  function validateAgentToolArgs(toolName, args) {
95
104
  const definition = AGENT_TOOL_DEFINITIONS.find((entry) => entry.name === toolName);
96
105
  if (definition == null)
@@ -101,9 +110,21 @@ function validateAgentToolArgs(toolName, args) {
101
110
  const knownKeys = new Set(Object.keys(properties));
102
111
  const unknownKeys = Object.keys(args).filter((key) => !knownKeys.has(key));
103
112
  if (unknownKeys.length > 0) {
104
- throw new SuperDocCliError(`Unknown argument(s) for ${toolName}: ${unknownKeys.join(', ')}`, {
113
+ // hasOwn, not `in`: an argument named `constructor` or `toString` would
114
+ // otherwise match the prototype chain and report a native function as its
115
+ // replacement guidance.
116
+ const retiredKeys = unknownKeys.filter((key) => Object.hasOwn(RETIRED_ACTION_ARGS, key));
117
+ const message = retiredKeys.length > 0
118
+ ? retiredKeys.map((key) => RETIRED_ACTION_ARGS[key]).join(' ')
119
+ : `Unknown argument(s) for ${toolName}: ${unknownKeys.join(', ')}`;
120
+ throw new SuperDocCliError(message, {
105
121
  code: 'INVALID_ARGUMENT',
106
- details: { toolName, unknownKeys, knownKeys: [...knownKeys] },
122
+ details: {
123
+ toolName,
124
+ unknownKeys,
125
+ knownKeys: [...knownKeys],
126
+ ...(retiredKeys.length > 0 ? { retiredKeys } : {}),
127
+ },
107
128
  });
108
129
  }
109
130
  const missingKeys = required.filter((key) => args[key] == null);
@@ -74,7 +74,7 @@ ACTIONS (superdoc_perform_action with flat args)
74
74
  - move_table: tableOrdinal? (default 1), placement {at:"document_end"|"document_start"|"after"|"before", selector?}. THE way to move a whole table in ONE call — never delete-and-recreate or chain inserts/undos to relocate a table. changeMode:"tracked" records the move for review.
75
75
  - delete_table: tableOrdinal? (default 1), changeMode?. THE way to delete an entire table in ONE call — never delete rows one by one or reuse another table.
76
76
  - style_table: tableOrdinal? (default 1), accentColor? (header fill hex). ONE call makes a table look professional: accent header row with white bold text, bold first column, banded rows, clean borders. Use after create_table or on any existing table. changeMode:"tracked" records the formatting for review.
77
- - insert_table_row: tableOrdinal (1-based), rowIndex (0-based; omit to append), position:"above"|"below", optional cellTexts. dryRun:true for preview.
77
+ - insert_table_row: tableOrdinal (1-based), rowIndex (0-based; omit to append), position:"above"|"below", optional cellTexts.
78
78
  - insert_table_column: tableOrdinal, columnIndex (0-based; omit to append right), position:"left"|"right", optional headerText.
79
79
  - delete_table_row / delete_table_column: rowIndex or columnIndex required, tableOrdinal optional.
80
80
  - split_table: tableOrdinal, rowIndex (>=1), optional separatorText.
@@ -103,7 +103,7 @@ OPERATING RULES
103
103
  - For anchored rewrites or multi-term edits, prefer textSearch selectors over copied nodeIds. For clause text inside tables, use a tableCell selector with replace_text.
104
104
  - For tab-indented headings, replace only the visible text with replace_text (rewrite_block can delete the tab node).
105
105
  - For BULK or PATTERN transforms (every percentage, every date), use ONE replace_text call with multiple edits. For bulk FORMATTING ("bold all the dates"): read the matching texts first, then ONE format_text call with targetTexts.
106
- - For preview-only requests ("show what it would look like", "don't save"), pass dryRun:true and make NO other mutating call; describe the preview from the receipt.
106
+ - For preview-only requests ("show what it would look like", "don't save"), make NO mutating call — read the document with superdoc_inspect and describe the change in your answer. If they want to SEE it in the document before it is final, make the edit with changeMode:"tracked" so it lands as a reviewable suggestion they can accept or reject — but only on an action that records tracked changes; for an action marked Direct edit, describe the change instead of making it.
107
107
  - Pure count questions: superdoc_inspect countsOnly:true, then stop. Use includeDomains to keep snapshots small.
108
108
  - Do not include doc or sessionId in tool args. Never rely on benchmark routing, eval metadata, or fixture names.
109
109
  - If the runtime truly cannot express the request, say what is missing instead of faking success.
@@ -3,6 +3,6 @@
3
3
  // AUTO-GENERATED by scripts/embed-version.mjs — DO NOT EDIT.
4
4
  // Source of truth: package.json. Regenerated on every SDK build so the
5
5
  // SDK retains its own version identity when bundled into another package.
6
- const SDK_VERSION = '2.13.1-next.8';
6
+ const SDK_VERSION = '2.13.1-next.9';
7
7
 
8
8
  exports.SDK_VERSION = SDK_VERSION;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.13.1-next.8";
1
+ export declare const SDK_VERSION = "2.13.1-next.9";
@@ -1,4 +1,4 @@
1
1
  // AUTO-GENERATED by scripts/embed-version.mjs — DO NOT EDIT.
2
2
  // Source of truth: package.json. Regenerated on every SDK build so the
3
3
  // SDK retains its own version identity when bundled into another package.
4
- export const SDK_VERSION = '2.13.1-next.8';
4
+ export const SDK_VERSION = '2.13.1-next.9';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/sdk",
3
- "version": "2.13.1-next.8",
3
+ "version": "2.13.1-next.9",
4
4
  "description": "Node SDK for SuperDoc, wrapping the SuperDoc CLI to read and edit .docx files from JavaScript and TypeScript.",
5
5
  "private": false,
6
6
  "license": "AGPL-3.0",
@@ -38,11 +38,11 @@
38
38
  "typescript": "^5.9.2"
39
39
  },
40
40
  "optionalDependencies": {
41
- "@superdoc/sdk-darwin-arm64": "2.13.1-next.8",
42
- "@superdoc/sdk-darwin-x64": "2.13.1-next.8",
43
- "@superdoc/sdk-linux-x64": "2.13.1-next.8",
44
- "@superdoc/sdk-linux-arm64": "2.13.1-next.8",
45
- "@superdoc/sdk-windows-x64": "2.13.1-next.8"
41
+ "@superdoc/sdk-darwin-arm64": "2.13.1-next.9",
42
+ "@superdoc/sdk-darwin-x64": "2.13.1-next.9",
43
+ "@superdoc/sdk-linux-x64": "2.13.1-next.9",
44
+ "@superdoc/sdk-linux-arm64": "2.13.1-next.9",
45
+ "@superdoc/sdk-windows-x64": "2.13.1-next.9"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public"
@@ -428,7 +428,6 @@ When formatting newly created content, use the right source:
428
428
  - **Do NOT hardcode formatting values.** Always read from blocks data and replicate.
429
429
  - **Do NOT copy heading/title formatting onto body paragraphs.** Read from body text blocks (alignment "justify" or "left"), not title blocks.
430
430
  - **Pass structured objects, not JSON-encoded strings.** Fields like `at`, `target`, and `inline` expect objects, not serialized JSON strings.
431
- - **Only pass `dryRun` when the action's schema explicitly lists it.** Do not assume every action accepts it. Prefer a real call over a preview for destructive actions unless dryRun is documented for that action.
432
431
  - **If blocks still report `underline: true` after you explicitly removed it, treat it as a style inheritance artifact.** Do not retry formatting to fix it.
433
432
  - **On "Unknown field" errors, drop the unrecognized field and retry.** Use the narrowest working call shape rather than guessing alternative field names.
434
433
  - **Table styling crosses two tools.** Borders / shading / cnf flags / spacing are on `superdoc_table`; cell-text alignment and font color/weight are on `superdoc_format` (paragraph- and run-level). A "style the whole table" pass calls both. See the Tables: cross-tool workflows section for the full recipe.
@@ -478,7 +478,6 @@ When formatting newly created content, use the right source:
478
478
  - **Do NOT hardcode formatting values.** Always read from blocks data and replicate.
479
479
  - **Do NOT copy heading/title formatting onto body paragraphs.** Read from body text blocks (alignment "justify" or "left"), not title blocks.
480
480
  - **Pass structured objects, not JSON-encoded strings.** Fields like `at`, `target`, and `inline` expect objects, not serialized JSON strings.
481
- - **Only pass `dryRun` when the action's schema explicitly lists it.** Do not assume every action accepts it. Prefer a real call over a preview for destructive actions unless dryRun is documented for that action.
482
481
  - **If blocks still report `underline: true` after you explicitly removed it, treat it as a style inheritance artifact.** Do not retry formatting to fix it.
483
482
  - **On "Unknown field" errors, drop the unrecognized field and retry.** Use the narrowest working call shape rather than guessing alternative field names.
484
483
  - **Table styling crosses two tools.** Borders / shading / cnf flags / spacing are on `superdoc_table`; cell-text alignment and font color/weight are on `superdoc_format` (paragraph- and run-level). A "style the whole table" pass calls both. See the Tables: cross-tool workflows section for the full recipe.
@@ -432,7 +432,6 @@ When formatting newly created content, use the right source:
432
432
  - **Do NOT hardcode formatting values.** Always read from blocks data and replicate.
433
433
  - **Do NOT copy heading/title formatting onto body paragraphs.** Read from body text blocks (alignment "justify" or "left"), not title blocks.
434
434
  - **Pass structured objects, not JSON-encoded strings.** Fields like `at`, `target`, and `inline` expect objects, not serialized JSON strings.
435
- - **Only pass `dryRun` when the action's schema explicitly lists it.** Do not assume every action accepts it. Prefer a real call over a preview for destructive actions unless dryRun is documented for that action.
436
435
  - **If blocks still report `underline: true` after you explicitly removed it, treat it as a style inheritance artifact.** Do not retry formatting to fix it.
437
436
  - **On "Unknown field" errors, drop the unrecognized field and retry.** Use the narrowest working call shape rather than guessing alternative field names.
438
437
  - **Table styling crosses two tools.** Borders / shading / cnf flags / spacing are on `superdoc_table`; cell-text alignment and font color/weight are on `superdoc_format` (paragraph- and run-level). A "style the whole table" pass calls both. See the Tables: cross-tool workflows section for the full recipe.