@superdoc/sdk 2.10.1-next.2 → 2.11.0-next.10
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/actions/define.cjs +788 -0
- package/dist/actions/define.d.ts +142 -0
- package/dist/actions/define.js +781 -0
- package/dist/agent/catalog.cjs +1 -0
- package/dist/agent/catalog.d.ts +8 -0
- package/dist/agent/catalog.js +1 -1
- package/dist/embedded-tools.generated.cjs +5 -5
- package/dist/embedded-tools.generated.js +5 -5
- package/dist/generated/client.cjs +2 -0
- package/dist/generated/client.d.ts +108 -0
- package/dist/generated/client.js +2 -0
- package/dist/generated/contract.cjs +1240 -782
- package/dist/generated/contract.js +1241 -783
- package/dist/generated/intent-dispatch.generated.cjs +1 -0
- package/dist/generated/intent-dispatch.generated.js +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/presets.cjs +2 -2
- package/dist/presets.js +2 -2
- package/dist/runtime/sdk-version.generated.cjs +1 -1
- package/dist/runtime/sdk-version.generated.d.ts +1 -1
- package/dist/runtime/sdk-version.generated.js +1 -1
- package/dist/tools.cjs +49 -1
- package/dist/tools.d.ts +18 -1
- package/dist/tools.js +49 -1
- package/package.json +9 -9
- package/tools/catalog.json +228 -134
- package/tools/intent_dispatch_generated.py +2 -0
- package/tools/tools-policy.json +1 -1
- package/tools/tools.anthropic.json +212 -134
- package/tools/tools.generic.json +214 -135
- package/tools/tools.openai.json +212 -134
- package/tools/tools.vercel.json +212 -134
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Customer-extensible **custom actions** for the SuperDoc LLM-tools SDK. The
|
|
3
|
+
* canonical ActionSpec has exactly ONE execution tier:
|
|
4
|
+
*
|
|
5
|
+
* - `steps` — declarative composition of built-in core actions with
|
|
6
|
+
* {{arg}} templating; dispatches through the base preset and
|
|
7
|
+
* inherits its target resolution, receipts, and verification.
|
|
8
|
+
* - `run` — a native function executed in the CALLER'S process against
|
|
9
|
+
* the typed session-bound doc handle, with synthesized
|
|
10
|
+
* truth-telling receipts (pre/post revision, partialMutation).
|
|
11
|
+
*
|
|
12
|
+
* NOTE: a third, IN-HOST tier — a JS function-expression run inside the
|
|
13
|
+
* document host via `superdoc_execute_code` — is intentionally not part of the
|
|
14
|
+
* kit yet. It lands together with the code-act execution path (and its safety
|
|
15
|
+
* envelope); until then the kit exposes only `steps` and `run`.
|
|
16
|
+
*
|
|
17
|
+
* `extendPreset` merges custom actions into the
|
|
18
|
+
* superdoc_perform_action enum, tool description, system prompt, and dispatch
|
|
19
|
+
* COHERENTLY — including excludeActions, which may name built-in actions
|
|
20
|
+
* (forwarded to the base) or custom ones (handled by the wrapper). No CLI
|
|
21
|
+
* host changes are required by either tier.
|
|
22
|
+
*
|
|
23
|
+
* Cross-runtime contract: templating semantics, input-schema defaults, and
|
|
24
|
+
* receipt shapes are identical to the Python mirror
|
|
25
|
+
* (`langs/python/superdoc/presets/custom.py`) for any JSON-serializable tool
|
|
26
|
+
* input. (NaN/Infinity/lone-surrogates are out of scope: they cannot appear in
|
|
27
|
+
* a JSON tool call.)
|
|
28
|
+
*
|
|
29
|
+
* @module
|
|
30
|
+
*/
|
|
31
|
+
import type { BoundDocApi } from '../generated/client.js';
|
|
32
|
+
import { type PresetDescriptor } from '../presets.js';
|
|
33
|
+
/** Minimal JSON Schema object describing a action's flat args. */
|
|
34
|
+
export type JSONSchemaObject = {
|
|
35
|
+
type: 'object';
|
|
36
|
+
properties: Record<string, unknown>;
|
|
37
|
+
required?: string[];
|
|
38
|
+
additionalProperties?: boolean;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* One step of a declarative (`steps`-tier) custom action: an existing built-in
|
|
43
|
+
* core action plus its args. String values may reference the custom action's
|
|
44
|
+
* own args with `{{name}}` templates — a whole-string `"{{x}}"` substitutes the
|
|
45
|
+
* raw value (preserving arrays/objects/numbers), a partial `"...{{x}}..."`
|
|
46
|
+
* interpolates as text.
|
|
47
|
+
*/
|
|
48
|
+
export type ActionStep = {
|
|
49
|
+
action: string;
|
|
50
|
+
args?: Record<string, unknown>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The shared, language-neutral custom-action contract — the canonical type.
|
|
54
|
+
*
|
|
55
|
+
* - `name` — namespaced "<ns>.<verb>" (e.g. "footnotes.add"). MUST NOT collide
|
|
56
|
+
* with a built-in core action name.
|
|
57
|
+
* - `description` — shown to the model.
|
|
58
|
+
* - `inputSchema` — JSON Schema for the FLAT args (NOT the `action`
|
|
59
|
+
* discriminator key). `properties.*.default` values are applied before
|
|
60
|
+
* execution on every tier.
|
|
61
|
+
*
|
|
62
|
+
* Exactly ONE execution tier is set:
|
|
63
|
+
*
|
|
64
|
+
* - `steps` — DECLARATIVE (recommended): a sequence of built-in core actions
|
|
65
|
+
* with `{{arg}}` templating. Dispatches through the base preset, so it
|
|
66
|
+
* inherits target resolution, placement handling, receipts, and
|
|
67
|
+
* verification. Pure data — serializable, cross-language by construction.
|
|
68
|
+
* - `run` — NATIVE escape hatch: an async function executed in the caller's
|
|
69
|
+
* process against the typed session-bound doc handle. Receipts are
|
|
70
|
+
* synthesized (pre/post revision, partialMutation, recovery).
|
|
71
|
+
*/
|
|
72
|
+
export interface ActionSpec {
|
|
73
|
+
name: string;
|
|
74
|
+
description: string;
|
|
75
|
+
inputSchema: JSONSchemaObject;
|
|
76
|
+
steps?: readonly ActionStep[];
|
|
77
|
+
run?: (doc: BoundDocApi, args: Record<string, unknown>) => unknown;
|
|
78
|
+
}
|
|
79
|
+
/** Which execution tier a spec uses. */
|
|
80
|
+
export declare function executionKindOf(spec: ActionSpec): 'steps' | 'run';
|
|
81
|
+
type DefineActionInputBase = {
|
|
82
|
+
name: string;
|
|
83
|
+
description: string;
|
|
84
|
+
/**
|
|
85
|
+
* JSON Schema object describing the action's flat args. Pass a plain JSON
|
|
86
|
+
* Schema (`{ type: 'object', properties: {...} }`). Zod (and other schema
|
|
87
|
+
* libraries) are NOT accepted directly — convert first, e.g. with
|
|
88
|
+
* `zod-to-json-schema` — otherwise `defineAction` throws a clear error rather
|
|
89
|
+
* than silently dropping your types.
|
|
90
|
+
*/
|
|
91
|
+
input?: JSONSchemaObject | Record<string, unknown>;
|
|
92
|
+
};
|
|
93
|
+
type DefineActionWithSteps = DefineActionInputBase & {
|
|
94
|
+
/** Declarative tier: built-in core actions with {{arg}} templating. */
|
|
95
|
+
steps: readonly ActionStep[];
|
|
96
|
+
run?: never;
|
|
97
|
+
};
|
|
98
|
+
type DefineActionWithRun = DefineActionInputBase & {
|
|
99
|
+
/**
|
|
100
|
+
* Native tier: runs IN THE CALLER'S PROCESS against the typed session-bound
|
|
101
|
+
* doc handle (async `doc.*` client API).
|
|
102
|
+
*/
|
|
103
|
+
run: (doc: BoundDocApi, args: Record<string, unknown>) => unknown;
|
|
104
|
+
steps?: never;
|
|
105
|
+
};
|
|
106
|
+
export type DefineActionInput = DefineActionWithSteps | DefineActionWithRun;
|
|
107
|
+
/**
|
|
108
|
+
* Author a {@link ActionSpec}. Pass exactly one execution tier: `steps`
|
|
109
|
+
* (declarative — recommended) or `run` (native function in your process).
|
|
110
|
+
*/
|
|
111
|
+
export declare function defineAction(input: DefineActionInput): ActionSpec;
|
|
112
|
+
export interface ExtendPresetOptions {
|
|
113
|
+
/** New preset id. */
|
|
114
|
+
id: string;
|
|
115
|
+
/** Optional description override. */
|
|
116
|
+
description?: string;
|
|
117
|
+
/** Custom actions to add. */
|
|
118
|
+
actions?: readonly ActionSpec[];
|
|
119
|
+
/**
|
|
120
|
+
* Of the base preset's BUILT-IN actions, keep only these. Custom actions are
|
|
121
|
+
* always included; `[]` yields a custom-only surface. Applied coherently to
|
|
122
|
+
* the superdoc_perform_action enum, description, and argument properties,
|
|
123
|
+
* the system prompt, the catalog, and dispatch (a built-in outside the
|
|
124
|
+
* allowlist is refused even on a guessed call). Unknown names throw.
|
|
125
|
+
*
|
|
126
|
+
* Prefer this over `excludeActions` for a curated surface: an allowlist does
|
|
127
|
+
* not silently grow when a later SDK release adds built-in actions.
|
|
128
|
+
*/
|
|
129
|
+
includeActions?: readonly string[];
|
|
130
|
+
/** Wholesale system-prompt addendum; defaults to an auto-generated bullet list. */
|
|
131
|
+
systemPromptExtra?: string;
|
|
132
|
+
/** When true, expose each action as its own tool instead of merging into superdoc_perform_action. */
|
|
133
|
+
standalone?: boolean;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Wrap `getPreset(baseId)` with custom actions. Returns a new
|
|
137
|
+
* {@link PresetDescriptor} that advertises and dispatches the custom actions
|
|
138
|
+
* while delegating everything else to the base preset. With
|
|
139
|
+
* `includeActions`, the base's built-in surface is narrowed to that allowlist.
|
|
140
|
+
*/
|
|
141
|
+
export declare function extendPreset(baseId: string, options: ExtendPresetOptions): PresetDescriptor;
|
|
142
|
+
export {};
|