@superdoc/sdk 2.11.0-next.3 → 2.11.0-next.5

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.
@@ -22550,7 +22550,7 @@ const CONTRACT = {
22550
22550
  "replacement",
22551
22551
  "format"
22552
22552
  ],
22553
- "description": "Aggregate type at the entity level. In paired replacement mode, a delete+insert pair shares one entity and this surfaces as 'replacement'; per-half type lives on block.textSpans[].trackedChanges[]."
22553
+ "description": "Aggregate type at the entity level. In grouped replacement mode, a delete+insert pair shares one entity and this surfaces as 'replacement'; per-half type lives on block.textSpans[].trackedChanges[]."
22554
22554
  },
22555
22555
  "blockIds": {
22556
22556
  "type": "array",
@@ -22579,7 +22579,7 @@ const CONTRACT = {
22579
22579
  },
22580
22580
  "excerpt": {
22581
22581
  "type": "string",
22582
- "description": "Short text excerpt of the changed content. Omitted for paired replacements; read block.textSpans for the per-half text."
22582
+ "description": "Short text excerpt of the changed content. Omitted for grouped replacements; read block.textSpans for the per-half text."
22583
22583
  },
22584
22584
  "author": {
22585
22585
  "type": "string",
@@ -163461,7 +163461,7 @@ const CONTRACT = {
163461
163461
  "const": "destination"
163462
163462
  }
163463
163463
  ],
163464
- "description": "Which revision side to anchor the comment on. Optional for paired replacements (defaults to inserted) and paired moves (defaults to destination); required for independent replacements where both sides are separately reviewable."
163464
+ "description": "Which revision side to anchor the comment on. Optional for grouped replacements (defaults to inserted) and paired moves (defaults to destination); required for separate replacements where both sides are reviewed independently."
163465
163465
  },
163466
163466
  "story": {
163467
163467
  "oneOf": [
@@ -165735,7 +165735,7 @@ const CONTRACT = {
165735
165735
  "const": "destination"
165736
165736
  }
165737
165737
  ],
165738
- "description": "Which revision side to anchor the comment on. Optional for paired replacements (defaults to inserted) and paired moves (defaults to destination); required for independent replacements where both sides are separately reviewable."
165738
+ "description": "Which revision side to anchor the comment on. Optional for grouped replacements (defaults to inserted) and paired moves (defaults to destination); required for separate replacements where both sides are reviewed independently."
165739
165739
  },
165740
165740
  "story": {
165741
165741
  "oneOf": [
@@ -169418,7 +169418,7 @@ const CONTRACT = {
169418
169418
  "const": "destination"
169419
169419
  }
169420
169420
  ],
169421
- "description": "Optional revision side for paired replacement or move targets."
169421
+ "description": "Optional revision side for grouped replacement or move targets."
169422
169422
  },
169423
169423
  "story": {
169424
169424
  "oneOf": [
@@ -169655,7 +169655,7 @@ const CONTRACT = {
169655
169655
  "const": "destination"
169656
169656
  }
169657
169657
  ],
169658
- "description": "Optional revision side for paired replacement or move targets."
169658
+ "description": "Optional revision side for grouped replacement or move targets."
169659
169659
  },
169660
169660
  "story": {
169661
169661
  "oneOf": [
@@ -169882,7 +169882,7 @@ const CONTRACT = {
169882
169882
  "const": "destination"
169883
169883
  }
169884
169884
  ],
169885
- "description": "Optional revision side for paired replacement or move targets."
169885
+ "description": "Optional revision side for grouped replacement or move targets."
169886
169886
  },
169887
169887
  "story": {
169888
169888
  "oneOf": [
@@ -170984,7 +170984,7 @@ const CONTRACT = {
170984
170984
  "source",
170985
170985
  "destination"
170986
170986
  ],
170987
- "description": "Optional revision side for paired replacement or move targets."
170987
+ "description": "Optional revision side for grouped replacement or move targets."
170988
170988
  },
170989
170989
  "story": {
170990
170990
  "$ref": "#/$defs/StoryLocator",
@@ -171042,7 +171042,7 @@ const CONTRACT = {
171042
171042
  "source",
171043
171043
  "destination"
171044
171044
  ],
171045
- "description": "Optional revision side for paired replacement or move targets."
171045
+ "description": "Optional revision side for grouped replacement or move targets."
171046
171046
  },
171047
171047
  "story": {
171048
171048
  "$ref": "#/$defs/StoryLocator",
@@ -171089,7 +171089,7 @@ const CONTRACT = {
171089
171089
  "source",
171090
171090
  "destination"
171091
171091
  ],
171092
- "description": "Optional revision side for paired replacement or move targets."
171092
+ "description": "Optional revision side for grouped replacement or move targets."
171093
171093
  },
171094
171094
  "story": {
171095
171095
  "$ref": "#/$defs/StoryLocator",
@@ -1610,7 +1610,7 @@ export const CONTRACT = {
1610
1610
  "source",
1611
1611
  "destination"
1612
1612
  ],
1613
- "description": "Which revision side to anchor the comment on. Optional for paired replacements (defaults to inserted) and paired moves (defaults to destination); required for independent replacements where both sides are separately reviewable."
1613
+ "description": "Which revision side to anchor the comment on. Optional for grouped replacements (defaults to inserted) and paired moves (defaults to destination); required for separate replacements where both sides are reviewed independently."
1614
1614
  },
1615
1615
  "story": {
1616
1616
  "$ref": "#/$defs/StoryLocator"
@@ -25466,7 +25466,7 @@ export const CONTRACT = {
25466
25466
  "replacement",
25467
25467
  "format"
25468
25468
  ],
25469
- "description": "Aggregate type at the entity level. In paired replacement mode, a delete+insert pair shares one entity and this surfaces as 'replacement'; per-half type lives on block.textSpans[].trackedChanges[]."
25469
+ "description": "Aggregate type at the entity level. In grouped replacement mode, a delete+insert pair shares one entity and this surfaces as 'replacement'; per-half type lives on block.textSpans[].trackedChanges[]."
25470
25470
  },
25471
25471
  "blockIds": {
25472
25472
  "type": "array",
@@ -25495,7 +25495,7 @@ export const CONTRACT = {
25495
25495
  },
25496
25496
  "excerpt": {
25497
25497
  "type": "string",
25498
- "description": "Short text excerpt of the changed content. Omitted for paired replacements; read block.textSpans for the per-half text."
25498
+ "description": "Short text excerpt of the changed content. Omitted for grouped replacements; read block.textSpans for the per-half text."
25499
25499
  },
25500
25500
  "author": {
25501
25501
  "type": "string",
@@ -166377,7 +166377,7 @@ export const CONTRACT = {
166377
166377
  "const": "destination"
166378
166378
  }
166379
166379
  ],
166380
- "description": "Which revision side to anchor the comment on. Optional for paired replacements (defaults to inserted) and paired moves (defaults to destination); required for independent replacements where both sides are separately reviewable."
166380
+ "description": "Which revision side to anchor the comment on. Optional for grouped replacements (defaults to inserted) and paired moves (defaults to destination); required for separate replacements where both sides are reviewed independently."
166381
166381
  },
166382
166382
  "story": {
166383
166383
  "oneOf": [
@@ -168651,7 +168651,7 @@ export const CONTRACT = {
168651
168651
  "const": "destination"
168652
168652
  }
168653
168653
  ],
168654
- "description": "Which revision side to anchor the comment on. Optional for paired replacements (defaults to inserted) and paired moves (defaults to destination); required for independent replacements where both sides are separately reviewable."
168654
+ "description": "Which revision side to anchor the comment on. Optional for grouped replacements (defaults to inserted) and paired moves (defaults to destination); required for separate replacements where both sides are reviewed independently."
168655
168655
  },
168656
168656
  "story": {
168657
168657
  "oneOf": [
@@ -172334,7 +172334,7 @@ export const CONTRACT = {
172334
172334
  "const": "destination"
172335
172335
  }
172336
172336
  ],
172337
- "description": "Optional revision side for paired replacement or move targets."
172337
+ "description": "Optional revision side for grouped replacement or move targets."
172338
172338
  },
172339
172339
  "story": {
172340
172340
  "oneOf": [
@@ -172571,7 +172571,7 @@ export const CONTRACT = {
172571
172571
  "const": "destination"
172572
172572
  }
172573
172573
  ],
172574
- "description": "Optional revision side for paired replacement or move targets."
172574
+ "description": "Optional revision side for grouped replacement or move targets."
172575
172575
  },
172576
172576
  "story": {
172577
172577
  "oneOf": [
@@ -172798,7 +172798,7 @@ export const CONTRACT = {
172798
172798
  "const": "destination"
172799
172799
  }
172800
172800
  ],
172801
- "description": "Optional revision side for paired replacement or move targets."
172801
+ "description": "Optional revision side for grouped replacement or move targets."
172802
172802
  },
172803
172803
  "story": {
172804
172804
  "oneOf": [
@@ -173900,7 +173900,7 @@ export const CONTRACT = {
173900
173900
  "source",
173901
173901
  "destination"
173902
173902
  ],
173903
- "description": "Optional revision side for paired replacement or move targets."
173903
+ "description": "Optional revision side for grouped replacement or move targets."
173904
173904
  },
173905
173905
  "story": {
173906
173906
  "$ref": "#/$defs/StoryLocator",
@@ -173958,7 +173958,7 @@ export const CONTRACT = {
173958
173958
  "source",
173959
173959
  "destination"
173960
173960
  ],
173961
- "description": "Optional revision side for paired replacement or move targets."
173961
+ "description": "Optional revision side for grouped replacement or move targets."
173962
173962
  },
173963
173963
  "story": {
173964
173964
  "$ref": "#/$defs/StoryLocator",
@@ -174005,7 +174005,7 @@ export const CONTRACT = {
174005
174005
  "source",
174006
174006
  "destination"
174007
174007
  ],
174008
- "description": "Optional revision side for paired replacement or move targets."
174008
+ "description": "Optional revision side for grouped replacement or move targets."
174009
174009
  },
174010
174010
  "story": {
174011
174011
  "$ref": "#/$defs/StoryLocator",
package/dist/index.cjs CHANGED
@@ -10,6 +10,7 @@ var skills = require('./skills.cjs');
10
10
  var tools = require('./tools.cjs');
11
11
  var intentDispatch_generated = require('./generated/intent-dispatch.generated.cjs');
12
12
  var v2PresetCompat = require('./agent/v2-preset-compat.cjs');
13
+ var define = require('./actions/define.cjs');
13
14
  var presets = require('./presets.cjs');
14
15
 
15
16
  // ---------------------------------------------------------------------------
@@ -215,6 +216,7 @@ exports.getToolCatalog = tools.getToolCatalog;
215
216
  exports.listTools = tools.listTools;
216
217
  exports.dispatchIntentTool = intentDispatch_generated.dispatchIntentTool;
217
218
  exports.wrapV2PresetCompat = v2PresetCompat.wrapV2PresetCompat;
219
+ exports.defineAction = define.defineAction;
218
220
  exports.DEFAULT_PRESET = presets.DEFAULT_PRESET;
219
221
  exports.getPreset = presets.getPreset;
220
222
  exports.listPresets = presets.listPresets;
package/dist/index.d.ts CHANGED
@@ -98,6 +98,8 @@ export type { AgentReceipt, AgentApplyArgs, AgentVerifyArgs } from './agent/runt
98
98
  export type { GetSystemPromptOptions, GetToolsOptions, GetToolsResult, PresetDescriptor } from './presets.js';
99
99
  export { createAgentToolkit } from './tools.js';
100
100
  export type { AgentToolkit, CreateAgentToolkitInput } from './tools.js';
101
+ export { defineAction } from './actions/define.js';
102
+ export type { ActionSpec, ActionStep, DefineActionInput, JSONSchemaObject } from './actions/define.js';
101
103
  export { SuperDocCliError } from './runtime/errors.js';
102
104
  export type { CollaborationAuth, DocOpenOptions, InvokeOptions, OperationSpec, OperationParamSpec, RuntimeInvoker, SuperDocClientOptions, } from './runtime/process.js';
103
105
  export type { DocOpenResult } from './generated/client.js';
package/dist/index.js CHANGED
@@ -197,4 +197,7 @@ export { chooseTools, dispatchSuperDocTool, getMcpPrompt, getSystemPrompt, getSy
197
197
  export { dispatchIntentTool } from './generated/intent-dispatch.generated.js';
198
198
  export { wrapV2PresetCompat } from './agent/v2-preset-compat.js';
199
199
  export { createAgentToolkit } from './tools.js';
200
+ // Custom-action authoring kit: `defineAction` builds an ActionSpec (steps or
201
+ // run tier); hand the specs to `createAgentToolkit({ actions })`.
202
+ export { defineAction } from './actions/define.js';
200
203
  export { SuperDocCliError } from './runtime/errors.js';
package/dist/presets.cjs CHANGED
@@ -40,8 +40,8 @@ const BUILTIN_PRESETS = {
40
40
  };
41
41
  /**
42
42
  * Mutable registry, seeded with the built-ins. Customers add their own presets
43
- * via {@link registerPreset} (e.g. one produced by `extendPreset` /
44
- * `composePreset`) so `getPreset`/`chooseTools` can resolve them by id.
43
+ * via {@link registerPreset} so `getPreset`/`chooseTools` can resolve them
44
+ * by id.
45
45
  */
46
46
  const PRESETS = { ...BUILTIN_PRESETS };
47
47
  /** List the IDs of all registered presets. */
package/dist/presets.js CHANGED
@@ -37,8 +37,8 @@ const BUILTIN_PRESETS = {
37
37
  };
38
38
  /**
39
39
  * Mutable registry, seeded with the built-ins. Customers add their own presets
40
- * via {@link registerPreset} (e.g. one produced by `extendPreset` /
41
- * `composePreset`) so `getPreset`/`chooseTools` can resolve them by id.
40
+ * via {@link registerPreset} so `getPreset`/`chooseTools` can resolve them
41
+ * by id.
42
42
  */
43
43
  const PRESETS = { ...BUILTIN_PRESETS };
44
44
  /** List the IDs of all registered presets. */
@@ -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.11.0-next.3';
6
+ const SDK_VERSION = '2.11.0-next.5';
7
7
 
8
8
  exports.SDK_VERSION = SDK_VERSION;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.11.0-next.3";
1
+ export declare const SDK_VERSION = "2.11.0-next.5";
@@ -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.11.0-next.3';
4
+ export const SDK_VERSION = '2.11.0-next.5';
package/dist/tools.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var errors = require('./runtime/errors.cjs');
3
4
  var presets = require('./presets.cjs');
5
+ var define = require('./actions/define.cjs');
4
6
 
5
7
  /**
6
8
  * Public LLM-tools API. Thin layer over the preset registry — every call here
@@ -95,6 +97,9 @@ function resolvePromptPresetArg(preset) {
95
97
  }
96
98
  return presets.DEFAULT_PRESET;
97
99
  }
100
+ /** Label for the ephemeral preset built by the one-call `customActions` path. */
101
+ const CUSTOM_TOOLKIT_PRESET_ID = 'custom_superdoc_preset';
102
+ const TOOL_PROVIDERS = new Set(['openai', 'anthropic', 'vercel', 'generic']);
98
103
  /**
99
104
  * One-call agent surface: tools, system prompt, and a pre-bound dispatcher
100
105
  * that are coherent BY CONSTRUCTION — the same preset and `excludeActions`
@@ -106,8 +111,51 @@ function resolvePromptPresetArg(preset) {
106
111
  * matching the standalone functions.
107
112
  */
108
113
  async function createAgentToolkit(input) {
109
- const presetId = input.preset ?? presets.DEFAULT_PRESET;
110
114
  const excludeActions = input.excludeActions ? [...input.excludeActions] : undefined;
115
+ // One-call custom-actions path: define your actions, hand them here as
116
+ // `customActions`, use the
117
+ // returned toolkit. We build an ephemeral extended/composed preset over
118
+ // `base` (default 'core') and drive it directly — no global registerPreset,
119
+ // and nothing for the caller to remember at dispatch time.
120
+ //
121
+ // An explicit `base` selects this path even with an empty actions list —
122
+ // otherwise `{ base: 'core', customActions: [] }` would silently fall through to
123
+ // the default (legacy) preset, a different tool family than the one named.
124
+ if ((input.customActions && input.customActions.length > 0) || input.includeActions != null || input.base != null) {
125
+ // This path builds tools directly (no chooseTools), so it must validate
126
+ // the provider itself; an unknown value would otherwise yield a silently
127
+ // mixed-dialect tool list. Mirrors the Python `create_agent_toolkit` guard.
128
+ if (!TOOL_PROVIDERS.has(input.provider)) {
129
+ throw new errors.SuperDocCliError('provider is required.', {
130
+ code: 'INVALID_ARGUMENT',
131
+ details: { provider: input.provider },
132
+ });
133
+ }
134
+ // `preset` doubles as the base to extend here (so `{ preset: 'core', actions }`
135
+ // reads naturally); `base` wins if both are given. Default base is 'core'.
136
+ const baseId = input.base ?? input.preset ?? 'core';
137
+ const descriptor = define.extendPreset(baseId, {
138
+ id: CUSTOM_TOOLKIT_PRESET_ID,
139
+ actions: input.customActions ?? [],
140
+ ...(input.includeActions != null ? { includeActions: input.includeActions } : {}),
141
+ });
142
+ const { tools, cacheStrategy } = await descriptor.getTools(input.provider, {
143
+ cache: input.cache === true,
144
+ excludeActions,
145
+ });
146
+ const systemPrompt = await descriptor.getSystemPrompt(excludeActions ? { excludeActions } : undefined);
147
+ const dispatch = (documentHandle, toolName, args = {}, invokeOptions) => descriptor.dispatch(documentHandle, toolName, args, {
148
+ ...invokeOptions,
149
+ ...(excludeActions ? { excludeActions } : {}),
150
+ });
151
+ return {
152
+ tools,
153
+ meta: { provider: input.provider, preset: descriptor.id, toolCount: tools.length, cacheStrategy },
154
+ systemPrompt,
155
+ dispatch,
156
+ };
157
+ }
158
+ const presetId = input.preset ?? presets.DEFAULT_PRESET;
111
159
  const { tools, meta } = await chooseTools({ ...input, preset: presetId, excludeActions });
112
160
  const systemPrompt = await getSystemPrompt(presetId, excludeActions ? { excludeActions } : undefined);
113
161
  const dispatch = (documentHandle, toolName, args = {}, invokeOptions) => dispatchSuperDocTool(documentHandle, toolName, args, {
package/dist/tools.d.ts CHANGED
@@ -10,6 +10,7 @@
10
10
  import type { BoundDocApi } from './generated/client.js';
11
11
  import type { InvokeOptions } from './runtime/process.js';
12
12
  import { DEFAULT_PRESET, getPreset, listPresets, registerPreset, unregisterPreset, type CacheStrategy, type GetSystemPromptOptions, type ToolCatalog, type ToolCatalogEntry, type ToolCatalogOperation, type ToolProvider } from './presets.js';
13
+ import { type ActionSpec } from './actions/define.js';
13
14
  export { DEFAULT_PRESET, getPreset, listPresets, registerPreset, unregisterPreset };
14
15
  export type { CacheStrategy, GetSystemPromptOptions, ToolCatalog, ToolCatalogEntry, ToolCatalogOperation, ToolProvider, };
15
16
  export type ToolChooserInput = {
@@ -98,7 +99,23 @@ export declare function dispatchSuperDocTool(documentHandle: BoundDocApi, toolNa
98
99
  * suitable for embedded LLM usage (OpenAI, Anthropic, Vercel APIs). For MCP
99
100
  * server instructions, use {@link getMcpPrompt} instead.
100
101
  */
101
- export type CreateAgentToolkitInput = ToolChooserInput;
102
+ export type CreateAgentToolkitInput = ToolChooserInput & {
103
+ /**
104
+ * Custom actions to expose alongside the base preset's built-ins. When set,
105
+ * the toolkit builds the extended preset FOR YOU — no `registerPreset`, no
106
+ * preset id to invent or thread through later `dispatch` calls. This is the
107
+ * path: define your actions, hand them here, use the returned toolkit.
108
+ */
109
+ customActions?: readonly ActionSpec[];
110
+ /** Base preset to extend on the custom-actions path (default `'core'`). */
111
+ base?: string;
112
+ /**
113
+ * Of the base preset's built-in actions, keep only these (`customActions`
114
+ * are always included; `[]` yields a custom-only surface). See
115
+ * `ExtendPresetOptions.includeActions`.
116
+ */
117
+ includeActions?: readonly string[];
118
+ };
102
119
  export type AgentToolkit = {
103
120
  /** Provider-shaped tool definitions (see {@link chooseTools}). */
104
121
  tools: unknown[];
package/dist/tools.js CHANGED
@@ -7,7 +7,9 @@
7
7
  * "core" tools, prompt-caching variant, lazy-load experiment), register a new
8
8
  * descriptor in `presets.ts` — no changes here required.
9
9
  */
10
+ import { SuperDocCliError } from './runtime/errors.js';
10
11
  import { DEFAULT_PRESET, getPreset, listPresets, registerPreset, unregisterPreset, } from './presets.js';
12
+ import { extendPreset } from './actions/define.js';
11
13
  export { DEFAULT_PRESET, getPreset, listPresets, registerPreset, unregisterPreset };
12
14
  /**
13
15
  * Select tools for a specific provider from a preset.
@@ -93,6 +95,9 @@ function resolvePromptPresetArg(preset) {
93
95
  }
94
96
  return DEFAULT_PRESET;
95
97
  }
98
+ /** Label for the ephemeral preset built by the one-call `customActions` path. */
99
+ const CUSTOM_TOOLKIT_PRESET_ID = 'custom_superdoc_preset';
100
+ const TOOL_PROVIDERS = new Set(['openai', 'anthropic', 'vercel', 'generic']);
96
101
  /**
97
102
  * One-call agent surface: tools, system prompt, and a pre-bound dispatcher
98
103
  * that are coherent BY CONSTRUCTION — the same preset and `excludeActions`
@@ -104,8 +109,51 @@ function resolvePromptPresetArg(preset) {
104
109
  * matching the standalone functions.
105
110
  */
106
111
  export async function createAgentToolkit(input) {
107
- const presetId = input.preset ?? DEFAULT_PRESET;
108
112
  const excludeActions = input.excludeActions ? [...input.excludeActions] : undefined;
113
+ // One-call custom-actions path: define your actions, hand them here as
114
+ // `customActions`, use the
115
+ // returned toolkit. We build an ephemeral extended/composed preset over
116
+ // `base` (default 'core') and drive it directly — no global registerPreset,
117
+ // and nothing for the caller to remember at dispatch time.
118
+ //
119
+ // An explicit `base` selects this path even with an empty actions list —
120
+ // otherwise `{ base: 'core', customActions: [] }` would silently fall through to
121
+ // the default (legacy) preset, a different tool family than the one named.
122
+ if ((input.customActions && input.customActions.length > 0) || input.includeActions != null || input.base != null) {
123
+ // This path builds tools directly (no chooseTools), so it must validate
124
+ // the provider itself; an unknown value would otherwise yield a silently
125
+ // mixed-dialect tool list. Mirrors the Python `create_agent_toolkit` guard.
126
+ if (!TOOL_PROVIDERS.has(input.provider)) {
127
+ throw new SuperDocCliError('provider is required.', {
128
+ code: 'INVALID_ARGUMENT',
129
+ details: { provider: input.provider },
130
+ });
131
+ }
132
+ // `preset` doubles as the base to extend here (so `{ preset: 'core', actions }`
133
+ // reads naturally); `base` wins if both are given. Default base is 'core'.
134
+ const baseId = input.base ?? input.preset ?? 'core';
135
+ const descriptor = extendPreset(baseId, {
136
+ id: CUSTOM_TOOLKIT_PRESET_ID,
137
+ actions: input.customActions ?? [],
138
+ ...(input.includeActions != null ? { includeActions: input.includeActions } : {}),
139
+ });
140
+ const { tools, cacheStrategy } = await descriptor.getTools(input.provider, {
141
+ cache: input.cache === true,
142
+ excludeActions,
143
+ });
144
+ const systemPrompt = await descriptor.getSystemPrompt(excludeActions ? { excludeActions } : undefined);
145
+ const dispatch = (documentHandle, toolName, args = {}, invokeOptions) => descriptor.dispatch(documentHandle, toolName, args, {
146
+ ...invokeOptions,
147
+ ...(excludeActions ? { excludeActions } : {}),
148
+ });
149
+ return {
150
+ tools,
151
+ meta: { provider: input.provider, preset: descriptor.id, toolCount: tools.length, cacheStrategy },
152
+ systemPrompt,
153
+ dispatch,
154
+ };
155
+ }
156
+ const presetId = input.preset ?? DEFAULT_PRESET;
109
157
  const { tools, meta } = await chooseTools({ ...input, preset: presetId, excludeActions });
110
158
  const systemPrompt = await getSystemPrompt(presetId, excludeActions ? { excludeActions } : undefined);
111
159
  const dispatch = (documentHandle, toolName, args = {}, invokeOptions) => dispatchSuperDocTool(documentHandle, toolName, args, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc/sdk",
3
- "version": "2.11.0-next.3",
3
+ "version": "2.11.0-next.5",
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.11.0-next.3",
42
- "@superdoc/sdk-darwin-x64": "2.11.0-next.3",
43
- "@superdoc/sdk-linux-x64": "2.11.0-next.3",
44
- "@superdoc/sdk-linux-arm64": "2.11.0-next.3",
45
- "@superdoc/sdk-windows-x64": "2.11.0-next.3"
41
+ "@superdoc/sdk-darwin-arm64": "2.11.0-next.5",
42
+ "@superdoc/sdk-darwin-x64": "2.11.0-next.5",
43
+ "@superdoc/sdk-linux-x64": "2.11.0-next.5",
44
+ "@superdoc/sdk-linux-arm64": "2.11.0-next.5",
45
+ "@superdoc/sdk-windows-x64": "2.11.0-next.5"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public"
@@ -51,9 +51,9 @@
51
51
  "build": "rm -rf dist && node scripts/embed-version.mjs && node scripts/embed-prompts.mjs && node scripts/embed-tools.mjs && tsc && pnpm run typecheck:consumer && rollup -c rollup.cjs.config.mjs && rm -rf dist/prompts && mkdir -p dist/prompts && cp src/prompts/*.md dist/prompts/ && pnpm run audit:publish",
52
52
  "audit:publish": "node ../../../../scripts/audit-publish-artifact.mjs dist --label sdk-node-dist",
53
53
  "typecheck": "tsc --noEmit",
54
- "typecheck:consumer": "tsc --noEmit --strict --skipLibCheck --target ES2022 --module NodeNext --moduleResolution NodeNext ../../../../tests/consumer-typecheck/src/sdk-per-open-collaboration-auth.mts ../../../../tests/consumer-typecheck/src/sdk-replace-file.mts ../../../../tests/consumer-typecheck/src/sdk-agent-evidence.mts",
55
- "test:agent-actions": "bun test src/__tests__/actions.test.ts src/__tests__/agent-runtime.test.ts",
56
- "test:document-host": "bun test src/runtime/__tests__/host-spawn-args.test.ts src/runtime/__tests__/document-rpc.test.ts src/__tests__/structured-document-rpc.e2e.test.ts src/__tests__/request-timeout-ms.e2e.test.ts src/__tests__/agent-evidence.e2e.test.ts src/__tests__/agent-apply.e2e.test.ts src/__tests__/find-text.e2e.test.ts",
54
+ "typecheck:consumer": "tsc --noEmit --strict --skipLibCheck --target ES2022 --module NodeNext --moduleResolution NodeNext ../../../../tests/consumer-typecheck/src/sdk-per-open-collaboration-auth.mts ../../../../tests/consumer-typecheck/src/sdk-replace-file.mts ../../../../tests/consumer-typecheck/src/sdk-agent-evidence.mts ../../../../tests/consumer-typecheck/src/sdk-custom-actions.mts",
55
+ "test:agent-actions": "bun test src/__tests__/actions.test.ts src/__tests__/agent-runtime.test.ts src/__tests__/custom-actions.test.ts",
56
+ "test:document-host": "bun test src/runtime/__tests__/host-spawn-args.test.ts src/runtime/__tests__/document-rpc.test.ts src/__tests__/structured-document-rpc.e2e.test.ts src/__tests__/request-timeout-ms.e2e.test.ts src/__tests__/agent-evidence.e2e.test.ts src/__tests__/agent-apply.e2e.test.ts src/__tests__/find-text.e2e.test.ts src/__tests__/custom-actions.e2e.test.ts",
57
57
  "smoke:product-action": "node scripts/product-action-smoke.mjs"
58
58
  }
59
59
  }
@@ -3380,7 +3380,7 @@
3380
3380
  "source",
3381
3381
  "destination"
3382
3382
  ],
3383
- "description": "Optional revision side for paired replacement or move targets."
3383
+ "description": "Optional revision side for grouped replacement or move targets."
3384
3384
  },
3385
3385
  "story": {
3386
3386
  "$ref": "#/$defs/StoryLocator",
@@ -3439,7 +3439,7 @@
3439
3439
  "source",
3440
3440
  "destination"
3441
3441
  ],
3442
- "description": "Optional revision side for paired replacement or move targets."
3442
+ "description": "Optional revision side for grouped replacement or move targets."
3443
3443
  },
3444
3444
  "story": {
3445
3445
  "$ref": "#/$defs/StoryLocator",
@@ -3487,7 +3487,7 @@
3487
3487
  "source",
3488
3488
  "destination"
3489
3489
  ],
3490
- "description": "Optional revision side for paired replacement or move targets."
3490
+ "description": "Optional revision side for grouped replacement or move targets."
3491
3491
  },
3492
3492
  "story": {
3493
3493
  "$ref": "#/$defs/StoryLocator",
@@ -43,5 +43,5 @@
43
43
  "mutates": true
44
44
  }
45
45
  ],
46
- "contractHash": "243b9ae43deca7396cb83238901d31cec3aa20fcba31f9ba5eba561f63c6c2cc"
46
+ "contractHash": "82ffe5e59606af2805b72430e4d57a216865c6cbdc78d1c68930600a1cbdc8df"
47
47
  }
@@ -2998,7 +2998,7 @@
2998
2998
  "source",
2999
2999
  "destination"
3000
3000
  ],
3001
- "description": "Optional revision side for paired replacement or move targets."
3001
+ "description": "Optional revision side for grouped replacement or move targets."
3002
3002
  },
3003
3003
  "story": {
3004
3004
  "$ref": "#/$defs/StoryLocator",
@@ -3057,7 +3057,7 @@
3057
3057
  "source",
3058
3058
  "destination"
3059
3059
  ],
3060
- "description": "Optional revision side for paired replacement or move targets."
3060
+ "description": "Optional revision side for grouped replacement or move targets."
3061
3061
  },
3062
3062
  "story": {
3063
3063
  "$ref": "#/$defs/StoryLocator",
@@ -3105,7 +3105,7 @@
3105
3105
  "source",
3106
3106
  "destination"
3107
3107
  ],
3108
- "description": "Optional revision side for paired replacement or move targets."
3108
+ "description": "Optional revision side for grouped replacement or move targets."
3109
3109
  },
3110
3110
  "story": {
3111
3111
  "$ref": "#/$defs/StoryLocator",
@@ -3131,7 +3131,7 @@
3131
3131
  "source",
3132
3132
  "destination"
3133
3133
  ],
3134
- "description": "Optional revision side for paired replacement or move targets."
3134
+ "description": "Optional revision side for grouped replacement or move targets."
3135
3135
  },
3136
3136
  "story": {
3137
3137
  "$ref": "#/$defs/StoryLocator",
@@ -3190,7 +3190,7 @@
3190
3190
  "source",
3191
3191
  "destination"
3192
3192
  ],
3193
- "description": "Optional revision side for paired replacement or move targets."
3193
+ "description": "Optional revision side for grouped replacement or move targets."
3194
3194
  },
3195
3195
  "story": {
3196
3196
  "$ref": "#/$defs/StoryLocator",
@@ -3238,7 +3238,7 @@
3238
3238
  "source",
3239
3239
  "destination"
3240
3240
  ],
3241
- "description": "Optional revision side for paired replacement or move targets."
3241
+ "description": "Optional revision side for grouped replacement or move targets."
3242
3242
  },
3243
3243
  "story": {
3244
3244
  "$ref": "#/$defs/StoryLocator",
@@ -3018,7 +3018,7 @@
3018
3018
  "source",
3019
3019
  "destination"
3020
3020
  ],
3021
- "description": "Optional revision side for paired replacement or move targets."
3021
+ "description": "Optional revision side for grouped replacement or move targets."
3022
3022
  },
3023
3023
  "story": {
3024
3024
  "$ref": "#/$defs/StoryLocator",
@@ -3077,7 +3077,7 @@
3077
3077
  "source",
3078
3078
  "destination"
3079
3079
  ],
3080
- "description": "Optional revision side for paired replacement or move targets."
3080
+ "description": "Optional revision side for grouped replacement or move targets."
3081
3081
  },
3082
3082
  "story": {
3083
3083
  "$ref": "#/$defs/StoryLocator",
@@ -3125,7 +3125,7 @@
3125
3125
  "source",
3126
3126
  "destination"
3127
3127
  ],
3128
- "description": "Optional revision side for paired replacement or move targets."
3128
+ "description": "Optional revision side for grouped replacement or move targets."
3129
3129
  },
3130
3130
  "story": {
3131
3131
  "$ref": "#/$defs/StoryLocator",