@pixerate/editor 0.139.1 → 0.140.1
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/README.md +25 -4
- package/dist/agent/formatTools.d.cts +15 -0
- package/dist/agent/formatTools.d.ts +15 -0
- package/dist/agent/index.cjs +408 -49
- package/dist/agent/index.js +375 -16
- package/dist/agent/providers.d.cts +5 -3
- package/dist/agent/providers.d.ts +5 -3
- package/dist/animation-editor/effect-tools.d.cts +1 -1
- package/dist/animation-editor/effect-tools.d.ts +1 -1
- package/dist/animation-editor/index.cjs +250 -116
- package/dist/animation-editor/index.js +228 -94
- package/dist/animation-editor/instructions.d.cts +1 -1
- package/dist/animation-editor/instructions.d.ts +1 -1
- package/dist/animation-editor/parse.d.cts +3 -1
- package/dist/animation-editor/parse.d.ts +3 -1
- package/dist/animation-editor/tools.d.cts +8 -3
- package/dist/animation-editor/tools.d.ts +8 -3
- package/dist/bridge/cli.cjs +4 -3
- package/dist/bridge/cli.js +3 -2
- package/dist/bridge/index.cjs +8 -3
- package/dist/bridge/index.d.cts +7 -0
- package/dist/bridge/index.d.ts +7 -0
- package/dist/bridge/index.js +9 -4
- package/dist/bridge/skills.d.cts +9 -0
- package/dist/bridge/skills.d.ts +9 -0
- package/dist/canvas/effect-tools.d.cts +1 -1
- package/dist/canvas/effect-tools.d.ts +1 -1
- package/dist/canvas/index.cjs +22 -17
- package/dist/canvas/index.js +8 -3
- package/dist/chart/file-tools.d.cts +1 -1
- package/dist/chart/file-tools.d.ts +1 -1
- package/dist/chart/index.cjs +7 -1
- package/dist/chart/index.js +7 -1
- package/dist/chart/tools.d.cts +1 -1
- package/dist/chart/tools.d.ts +1 -1
- package/dist/chunk-2BSBFBOA.cjs +46 -0
- package/dist/{chunk-SWZTQWY7.js → chunk-2INPJDNY.js} +1 -1
- package/dist/{chunk-CCKP4XAN.cjs → chunk-34RQAGWI.cjs} +27 -7
- package/dist/{chunk-HXCBQ7A6.cjs → chunk-3AJMR7EG.cjs} +7 -4
- package/dist/{chunk-BKMU3V6K.js → chunk-5ED73EC6.js} +8 -1
- package/dist/{chunk-NKBUVQJW.cjs → chunk-5WOY52O6.cjs} +15 -15
- package/dist/{chunk-VRIR53SW.js → chunk-6GAYGQDC.js} +10 -8
- package/dist/{chunk-HZZXBTLB.js → chunk-6IN474P4.js} +25 -5
- package/dist/{chunk-KHMVB3SJ.js → chunk-7KWJEYIK.js} +4 -1
- package/dist/{chunk-R47NQICB.cjs → chunk-AGCD3EHB.cjs} +47 -10
- package/dist/{chunk-6I63VZ45.js → chunk-CXXKJBQZ.js} +5 -1
- package/dist/{chunk-6NXVDJDR.cjs → chunk-G43MNQ4C.cjs} +5 -5
- package/dist/chunk-HDK3T2QS.cjs +1159 -0
- package/dist/chunk-HF5QZS7Z.js +46 -0
- package/dist/{chunk-S7I3RI5Z.cjs → chunk-HMGWFXEC.cjs} +27 -24
- package/dist/{chunk-6NCBFBXA.js → chunk-IQ6KKXOU.js} +1 -1
- package/dist/{chunk-T6Y5FV7G.cjs → chunk-L434J57V.cjs} +10 -8
- package/dist/{chunk-UCRL6JEV.cjs → chunk-L5OWG2NA.cjs} +8 -3
- package/dist/{chunk-CZRWP6IW.cjs → chunk-N2FGYZ4Q.cjs} +8 -1
- package/dist/{chunk-GUPQ5BNA.cjs → chunk-PUR6BZFA.cjs} +112 -111
- package/dist/chunk-RB62U6MS.js +1159 -0
- package/dist/{chunk-3V746PF4.cjs → chunk-RUZQMYXH.cjs} +4 -1
- package/dist/{chunk-HGHXGCKG.cjs → chunk-SVFEVKLF.cjs} +1 -1
- package/dist/{chunk-PCNCT4ZY.js → chunk-UMS6YFA6.js} +40 -3
- package/dist/{chunk-4LGWAJDI.js → chunk-V5OOP74P.js} +5 -2
- package/dist/{chunk-BWT4IWLK.cjs → chunk-VKF3PWKR.cjs} +7 -7
- package/dist/{chunk-PQMADRCI.js → chunk-WBJ6BG4R.js} +23 -22
- package/dist/{chunk-WIYAOZZU.js → chunk-WHKNYFM2.js} +7 -2
- package/dist/{chunk-TBSPPVTT.js → chunk-XCK7QK5D.js} +1 -1
- package/dist/{chunk-F652BKMS.cjs → chunk-YN6JKAUE.cjs} +6 -2
- package/dist/{chunk-YTGF4TJR.js → chunk-ZLZKGHSZ.js} +5 -2
- package/dist/{chunk-USU2FL3N.js → chunk-ZNHB5RG6.js} +1 -1
- package/dist/commands/agentTools.d.cts +1 -1
- package/dist/commands/agentTools.d.ts +1 -1
- package/dist/commands/index.cjs +3 -0
- package/dist/commands/index.js +3 -0
- package/dist/compare/index.cjs +4 -3
- package/dist/compare/index.js +3 -2
- package/dist/diagram/index.cjs +3 -0
- package/dist/diagram/index.js +3 -0
- package/dist/diagram/tools.d.cts +1 -1
- package/dist/diagram/tools.d.ts +1 -1
- package/dist/effects/index.cjs +32 -32
- package/dist/effects/index.js +1 -1
- package/dist/effects/tools.d.cts +5 -1
- package/dist/effects/tools.d.ts +5 -1
- package/dist/export/index.cjs +4 -3
- package/dist/export/index.js +3 -2
- package/dist/extensions/index.cjs +11 -8
- package/dist/extensions/index.d.cts +1 -0
- package/dist/extensions/index.d.ts +1 -0
- package/dist/extensions/index.js +10 -7
- package/dist/extensions/safe-merge-attributes.d.cts +10 -0
- package/dist/extensions/safe-merge-attributes.d.ts +10 -0
- package/dist/generation/index.cjs +7 -1
- package/dist/generation/index.js +7 -1
- package/dist/image-editor/index.cjs +25 -18
- package/dist/image-editor/index.js +10 -3
- package/dist/image-editor/provider-effect-tools.d.cts +1 -1
- package/dist/image-editor/provider-effect-tools.d.ts +1 -1
- package/dist/image-editor/tools.d.cts +1 -1
- package/dist/image-editor/tools.d.ts +1 -1
- package/dist/index.cjs +42 -29
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -9
- package/dist/paint-editor/effect-tools.d.cts +1 -1
- package/dist/paint-editor/effect-tools.d.ts +1 -1
- package/dist/paint-editor/index.cjs +18 -8
- package/dist/paint-editor/index.js +13 -3
- package/dist/paint-editor/tools.d.cts +1 -1
- package/dist/paint-editor/tools.d.ts +1 -1
- package/dist/persistence/index.cjs +3 -2
- package/dist/persistence/index.js +2 -1
- package/dist/serializers/index.cjs +5 -4
- package/dist/serializers/index.js +4 -3
- package/dist/tools/bridge-client.d.cts +3 -3
- package/dist/tools/bridge-client.d.ts +3 -3
- package/dist/tools/capture.d.cts +5 -1
- package/dist/tools/capture.d.ts +5 -1
- package/dist/tools/definitions.d.cts +2 -2
- package/dist/tools/definitions.d.ts +2 -2
- package/dist/tools/index.cjs +39 -5
- package/dist/tools/index.d.cts +4 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.js +39 -5
- package/dist/tools/mcp-server.d.cts +24 -6
- package/dist/tools/mcp-server.d.ts +24 -6
- package/dist/tools/registry.d.cts +81 -6
- package/dist/tools/registry.d.ts +81 -6
- package/dist/tools/safe-json.d.cts +27 -0
- package/dist/tools/safe-json.d.ts +27 -0
- package/dist/tools/search.d.cts +30 -0
- package/dist/tools/search.d.ts +30 -0
- package/dist/tools/skills.d.cts +26 -0
- package/dist/tools/skills.d.ts +26 -0
- package/dist/tools/view.d.cts +95 -0
- package/dist/tools/view.d.ts +95 -0
- package/dist/vector/effect-tools.d.cts +1 -1
- package/dist/vector/effect-tools.d.ts +1 -1
- package/dist/vector/index.cjs +13 -7
- package/dist/vector/index.js +8 -2
- package/dist/video-editor/effect-tools.d.cts +1 -1
- package/dist/video-editor/effect-tools.d.ts +1 -1
- package/dist/video-editor/index.cjs +275 -269
- package/dist/video-editor/index.js +8 -2
- package/dist/video-editor/tools.d.cts +1 -1
- package/dist/video-editor/tools.d.ts +1 -1
- package/package.json +31 -29
- package/skills/README.md +8 -3
- package/skills/pixerate-agent-tools/SKILL.md +33 -7
- package/skills/pixerate-animation-editor/SKILL.md +7 -0
- package/skills/pixerate-rich-text/SKILL.md +18 -4
- package/dist/chunk-5RRYDFU2.js +0 -466
- package/dist/chunk-SPVIXXIB.cjs +0 -466
- /package/dist/{chunk-SMJK5HBJ.js → chunk-K73HMKQP.js} +0 -0
- /package/dist/{chunk-DDF6WQ62.cjs → chunk-LACYURUW.cjs} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type JsonSchema, type SchemaValidationError } from './schema.cjs';
|
|
2
|
+
import { ToolRegistryView, type ToolViewOptions } from './view.cjs';
|
|
2
3
|
/**
|
|
3
4
|
* MCP-shaped tool definition, as returned by `tools/list`.
|
|
4
5
|
*/
|
|
@@ -59,12 +60,25 @@ export interface AgentTool extends McpToolDefinition {
|
|
|
59
60
|
}
|
|
60
61
|
/**
|
|
61
62
|
* A source of tools, typically one per mounted editor, spreadsheet or canvas.
|
|
63
|
+
* Each provider is a toolset: its tools are exposed as `<namespace>__<name>`
|
|
64
|
+
* (see {@link ToolRegistryOptions.namespaces}) and grouped under that name by
|
|
65
|
+
* `toolsets()`, `registry.view()` and the discovery tools.
|
|
62
66
|
*/
|
|
63
67
|
export interface AgentToolProvider {
|
|
64
|
-
/** Unique id within a registry, e.g. `doc-1`.
|
|
68
|
+
/** Unique id within a registry, e.g. `doc-1`. The default namespace. */
|
|
65
69
|
id: string;
|
|
66
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Prefix for this provider's tools (`<namespace>__<name>`). Defaults to the
|
|
72
|
+
* `id`. Pass `''` to expose bare names (prefixed by `id` only on a collision).
|
|
73
|
+
* Providers may share a namespace when their tool names differ.
|
|
74
|
+
*/
|
|
67
75
|
namespace?: string;
|
|
76
|
+
/** Short name of the toolset for agents and UIs, e.g. "Chart editor". */
|
|
77
|
+
title?: string;
|
|
78
|
+
/** What the toolset covers and when to use it, in a sentence or two. */
|
|
79
|
+
description?: string;
|
|
80
|
+
/** Name of the agent skill that documents these tools, e.g. `pixerate-chart`. */
|
|
81
|
+
skill?: string;
|
|
68
82
|
/** Tools, or a function returning the current tools (re-read on every `listTools`). */
|
|
69
83
|
tools: readonly AgentTool[] | (() => readonly AgentTool[]);
|
|
70
84
|
/** Lets the provider signal that its tool list changed; returns an unsubscribe function. */
|
|
@@ -84,7 +98,18 @@ export declare class ToolRegistryError extends Error {
|
|
|
84
98
|
}
|
|
85
99
|
export interface ToolRegistryOptions {
|
|
86
100
|
/**
|
|
87
|
-
*
|
|
101
|
+
* `always` (default): every tool is exposed as `<namespace>__<name>`, where the
|
|
102
|
+
* namespace is the provider's `namespace` or else its `id`, so names don't
|
|
103
|
+
* change when another editor mounts. `on-collision`: only providers with an
|
|
104
|
+
* explicit `namespace` are prefixed; other tools keep their bare name unless
|
|
105
|
+
* two providers share it (see `onCollision`).
|
|
106
|
+
*
|
|
107
|
+
* Either way, `callTool`, `hasTool` and `getTool` also accept a bare name
|
|
108
|
+
* when exactly one exposed tool has it.
|
|
109
|
+
*/
|
|
110
|
+
namespaces?: 'always' | 'on-collision';
|
|
111
|
+
/**
|
|
112
|
+
* What to do when two unprefixed tools share a name:
|
|
88
113
|
* `namespace` (default) exposes every colliding tool as `<providerId>__<name>`;
|
|
89
114
|
* `error` makes `register` throw.
|
|
90
115
|
*/
|
|
@@ -96,6 +121,48 @@ export interface ToolRegistryOptions {
|
|
|
96
121
|
}
|
|
97
122
|
/** Separator between namespace and tool name; valid in MCP and LLM tool-name charsets. */
|
|
98
123
|
export declare const TOOL_NAMESPACE_SEPARATOR = "__";
|
|
124
|
+
/** The toolset a provider belongs to: its namespace, or else its id. */
|
|
125
|
+
export declare function toolsetName(provider: Pick<AgentToolProvider, 'id' | 'namespace'>): string;
|
|
126
|
+
/** The name a tool was registered under, without its namespace (`chart__get_chart` → `get_chart`). */
|
|
127
|
+
export declare function baseToolName(name: string): string;
|
|
128
|
+
/** A group of tools from one or more providers that share a namespace. */
|
|
129
|
+
export interface ToolsetInfo {
|
|
130
|
+
/** Toolset name: the providers' namespace, or the provider id. */
|
|
131
|
+
name: string;
|
|
132
|
+
title?: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
/** Agent skill that documents these tools. */
|
|
135
|
+
skill?: string;
|
|
136
|
+
/** Ids of the providers in this toolset. */
|
|
137
|
+
providers: string[];
|
|
138
|
+
/** Exposed names of its tools, in listing order. */
|
|
139
|
+
tools: string[];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Anything that serves tools the way a {@link ToolRegistry} does: a registry,
|
|
143
|
+
* a {@link ToolRegistryView} of one, or the MCP bridge's registry.
|
|
144
|
+
* `createMcpServer` and `connectToolBridge` accept any of them.
|
|
145
|
+
*/
|
|
146
|
+
export interface ToolSource {
|
|
147
|
+
readonly capabilities: {
|
|
148
|
+
tools: {
|
|
149
|
+
listChanged: boolean;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
listTools(): McpListToolsResult;
|
|
153
|
+
hasTool(name: string): boolean;
|
|
154
|
+
getTool(name: string): McpToolDefinition | undefined;
|
|
155
|
+
callTool(name: string, args?: Record<string, unknown>, options?: {
|
|
156
|
+
signal?: AbortSignal;
|
|
157
|
+
}): Promise<McpToolResult>;
|
|
158
|
+
onListChanged(listener: (tools: McpToolDefinition[]) => void): () => void;
|
|
159
|
+
/** The toolsets behind `listTools()`, in listing order. */
|
|
160
|
+
toolsets(): ToolsetInfo[];
|
|
161
|
+
}
|
|
162
|
+
/** `unknown_tool` message, naming the tools a bare name could mean. */
|
|
163
|
+
export declare function unknownToolMessage(name: string, candidates?: readonly string[]): string;
|
|
164
|
+
/** An `isError` tool result carrying a {@link ToolCallError}. */
|
|
165
|
+
export declare function errorResult(error: ToolCallError): McpToolResult;
|
|
99
166
|
/** Normalizes a handler's return value into an MCP `tools/call` result. */
|
|
100
167
|
export declare function toToolResult(value: unknown): McpToolResult;
|
|
101
168
|
/**
|
|
@@ -106,7 +173,7 @@ export declare function toToolResult(value: unknown): McpToolResult;
|
|
|
106
173
|
* tool list changes, mirroring MCP's `notifications/tools/list_changed`, so an
|
|
107
174
|
* MCP server can be a thin wrapper around it.
|
|
108
175
|
*/
|
|
109
|
-
export declare class ToolRegistry {
|
|
176
|
+
export declare class ToolRegistry implements ToolSource {
|
|
110
177
|
/** MCP server capabilities this registry supports. */
|
|
111
178
|
readonly capabilities: {
|
|
112
179
|
readonly tools: {
|
|
@@ -136,10 +203,18 @@ export declare class ToolRegistry {
|
|
|
136
203
|
private resolve;
|
|
137
204
|
/** MCP `tools/list` result for the current providers. */
|
|
138
205
|
listTools(): McpListToolsResult;
|
|
139
|
-
/** Whether a tool with this exposed name exists. */
|
|
206
|
+
/** Whether a tool with this exposed name (or unique bare name) exists. */
|
|
140
207
|
hasTool(name: string): boolean;
|
|
141
|
-
/** Looks up a tool definition by exposed name. */
|
|
208
|
+
/** Looks up a tool definition by exposed name (or unique bare name). */
|
|
142
209
|
getTool(name: string): McpToolDefinition | undefined;
|
|
210
|
+
/** The registered providers grouped by namespace, in listing order. */
|
|
211
|
+
toolsets(): ToolsetInfo[];
|
|
212
|
+
/**
|
|
213
|
+
* A filtered, optionally self-discovering view of this registry: serve it
|
|
214
|
+
* with `createMcpServer` or `connectToolBridge` instead of the registry to
|
|
215
|
+
* show an agent only some toolsets. See {@link ToolRegistryView}.
|
|
216
|
+
*/
|
|
217
|
+
view(options?: ToolViewOptions): ToolRegistryView;
|
|
143
218
|
/**
|
|
144
219
|
* Calls a tool by exposed name and returns an MCP `tools/call` result.
|
|
145
220
|
* Never rejects: unknown tools, invalid arguments and handler errors come
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type JsonSchema, type SchemaValidationError } from './schema.js';
|
|
2
|
+
import { ToolRegistryView, type ToolViewOptions } from './view.js';
|
|
2
3
|
/**
|
|
3
4
|
* MCP-shaped tool definition, as returned by `tools/list`.
|
|
4
5
|
*/
|
|
@@ -59,12 +60,25 @@ export interface AgentTool extends McpToolDefinition {
|
|
|
59
60
|
}
|
|
60
61
|
/**
|
|
61
62
|
* A source of tools, typically one per mounted editor, spreadsheet or canvas.
|
|
63
|
+
* Each provider is a toolset: its tools are exposed as `<namespace>__<name>`
|
|
64
|
+
* (see {@link ToolRegistryOptions.namespaces}) and grouped under that name by
|
|
65
|
+
* `toolsets()`, `registry.view()` and the discovery tools.
|
|
62
66
|
*/
|
|
63
67
|
export interface AgentToolProvider {
|
|
64
|
-
/** Unique id within a registry, e.g. `doc-1`.
|
|
68
|
+
/** Unique id within a registry, e.g. `doc-1`. The default namespace. */
|
|
65
69
|
id: string;
|
|
66
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Prefix for this provider's tools (`<namespace>__<name>`). Defaults to the
|
|
72
|
+
* `id`. Pass `''` to expose bare names (prefixed by `id` only on a collision).
|
|
73
|
+
* Providers may share a namespace when their tool names differ.
|
|
74
|
+
*/
|
|
67
75
|
namespace?: string;
|
|
76
|
+
/** Short name of the toolset for agents and UIs, e.g. "Chart editor". */
|
|
77
|
+
title?: string;
|
|
78
|
+
/** What the toolset covers and when to use it, in a sentence or two. */
|
|
79
|
+
description?: string;
|
|
80
|
+
/** Name of the agent skill that documents these tools, e.g. `pixerate-chart`. */
|
|
81
|
+
skill?: string;
|
|
68
82
|
/** Tools, or a function returning the current tools (re-read on every `listTools`). */
|
|
69
83
|
tools: readonly AgentTool[] | (() => readonly AgentTool[]);
|
|
70
84
|
/** Lets the provider signal that its tool list changed; returns an unsubscribe function. */
|
|
@@ -84,7 +98,18 @@ export declare class ToolRegistryError extends Error {
|
|
|
84
98
|
}
|
|
85
99
|
export interface ToolRegistryOptions {
|
|
86
100
|
/**
|
|
87
|
-
*
|
|
101
|
+
* `always` (default): every tool is exposed as `<namespace>__<name>`, where the
|
|
102
|
+
* namespace is the provider's `namespace` or else its `id`, so names don't
|
|
103
|
+
* change when another editor mounts. `on-collision`: only providers with an
|
|
104
|
+
* explicit `namespace` are prefixed; other tools keep their bare name unless
|
|
105
|
+
* two providers share it (see `onCollision`).
|
|
106
|
+
*
|
|
107
|
+
* Either way, `callTool`, `hasTool` and `getTool` also accept a bare name
|
|
108
|
+
* when exactly one exposed tool has it.
|
|
109
|
+
*/
|
|
110
|
+
namespaces?: 'always' | 'on-collision';
|
|
111
|
+
/**
|
|
112
|
+
* What to do when two unprefixed tools share a name:
|
|
88
113
|
* `namespace` (default) exposes every colliding tool as `<providerId>__<name>`;
|
|
89
114
|
* `error` makes `register` throw.
|
|
90
115
|
*/
|
|
@@ -96,6 +121,48 @@ export interface ToolRegistryOptions {
|
|
|
96
121
|
}
|
|
97
122
|
/** Separator between namespace and tool name; valid in MCP and LLM tool-name charsets. */
|
|
98
123
|
export declare const TOOL_NAMESPACE_SEPARATOR = "__";
|
|
124
|
+
/** The toolset a provider belongs to: its namespace, or else its id. */
|
|
125
|
+
export declare function toolsetName(provider: Pick<AgentToolProvider, 'id' | 'namespace'>): string;
|
|
126
|
+
/** The name a tool was registered under, without its namespace (`chart__get_chart` → `get_chart`). */
|
|
127
|
+
export declare function baseToolName(name: string): string;
|
|
128
|
+
/** A group of tools from one or more providers that share a namespace. */
|
|
129
|
+
export interface ToolsetInfo {
|
|
130
|
+
/** Toolset name: the providers' namespace, or the provider id. */
|
|
131
|
+
name: string;
|
|
132
|
+
title?: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
/** Agent skill that documents these tools. */
|
|
135
|
+
skill?: string;
|
|
136
|
+
/** Ids of the providers in this toolset. */
|
|
137
|
+
providers: string[];
|
|
138
|
+
/** Exposed names of its tools, in listing order. */
|
|
139
|
+
tools: string[];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Anything that serves tools the way a {@link ToolRegistry} does: a registry,
|
|
143
|
+
* a {@link ToolRegistryView} of one, or the MCP bridge's registry.
|
|
144
|
+
* `createMcpServer` and `connectToolBridge` accept any of them.
|
|
145
|
+
*/
|
|
146
|
+
export interface ToolSource {
|
|
147
|
+
readonly capabilities: {
|
|
148
|
+
tools: {
|
|
149
|
+
listChanged: boolean;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
listTools(): McpListToolsResult;
|
|
153
|
+
hasTool(name: string): boolean;
|
|
154
|
+
getTool(name: string): McpToolDefinition | undefined;
|
|
155
|
+
callTool(name: string, args?: Record<string, unknown>, options?: {
|
|
156
|
+
signal?: AbortSignal;
|
|
157
|
+
}): Promise<McpToolResult>;
|
|
158
|
+
onListChanged(listener: (tools: McpToolDefinition[]) => void): () => void;
|
|
159
|
+
/** The toolsets behind `listTools()`, in listing order. */
|
|
160
|
+
toolsets(): ToolsetInfo[];
|
|
161
|
+
}
|
|
162
|
+
/** `unknown_tool` message, naming the tools a bare name could mean. */
|
|
163
|
+
export declare function unknownToolMessage(name: string, candidates?: readonly string[]): string;
|
|
164
|
+
/** An `isError` tool result carrying a {@link ToolCallError}. */
|
|
165
|
+
export declare function errorResult(error: ToolCallError): McpToolResult;
|
|
99
166
|
/** Normalizes a handler's return value into an MCP `tools/call` result. */
|
|
100
167
|
export declare function toToolResult(value: unknown): McpToolResult;
|
|
101
168
|
/**
|
|
@@ -106,7 +173,7 @@ export declare function toToolResult(value: unknown): McpToolResult;
|
|
|
106
173
|
* tool list changes, mirroring MCP's `notifications/tools/list_changed`, so an
|
|
107
174
|
* MCP server can be a thin wrapper around it.
|
|
108
175
|
*/
|
|
109
|
-
export declare class ToolRegistry {
|
|
176
|
+
export declare class ToolRegistry implements ToolSource {
|
|
110
177
|
/** MCP server capabilities this registry supports. */
|
|
111
178
|
readonly capabilities: {
|
|
112
179
|
readonly tools: {
|
|
@@ -136,10 +203,18 @@ export declare class ToolRegistry {
|
|
|
136
203
|
private resolve;
|
|
137
204
|
/** MCP `tools/list` result for the current providers. */
|
|
138
205
|
listTools(): McpListToolsResult;
|
|
139
|
-
/** Whether a tool with this exposed name exists. */
|
|
206
|
+
/** Whether a tool with this exposed name (or unique bare name) exists. */
|
|
140
207
|
hasTool(name: string): boolean;
|
|
141
|
-
/** Looks up a tool definition by exposed name. */
|
|
208
|
+
/** Looks up a tool definition by exposed name (or unique bare name). */
|
|
142
209
|
getTool(name: string): McpToolDefinition | undefined;
|
|
210
|
+
/** The registered providers grouped by namespace, in listing order. */
|
|
211
|
+
toolsets(): ToolsetInfo[];
|
|
212
|
+
/**
|
|
213
|
+
* A filtered, optionally self-discovering view of this registry: serve it
|
|
214
|
+
* with `createMcpServer` or `connectToolBridge` instead of the registry to
|
|
215
|
+
* show an agent only some toolsets. See {@link ToolRegistryView}.
|
|
216
|
+
*/
|
|
217
|
+
view(options?: ToolViewOptions): ToolRegistryView;
|
|
143
218
|
/**
|
|
144
219
|
* Calls a tool by exposed name and returns an MCP `tools/call` result.
|
|
145
220
|
* Never rejects: unknown tools, invalid arguments and handler errors come
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guards against prototype pollution from untrusted JSON (GHSA-cp6q-959q-f8rh).
|
|
3
|
+
*
|
|
4
|
+
* `JSON.parse('{"__proto__": {...}}')` creates an *own* `__proto__` key. Code
|
|
5
|
+
* that later copies keys with bracket assignment (`out[key] = value`,
|
|
6
|
+
* `Object.assign`) turns it into the copy's prototype, so the copy inherits
|
|
7
|
+
* attacker-chosen properties that `for…in` loops (ProseMirror's
|
|
8
|
+
* `DOMSerializer.renderSpec`, for one) then treat as real ones. TipTap's
|
|
9
|
+
* `mergeAttributes()` did exactly that before `@tiptap/core` 2.27.3 / 3.30.4.
|
|
10
|
+
*
|
|
11
|
+
* This file has no dependencies so the tool layer can use it.
|
|
12
|
+
*/
|
|
13
|
+
/** Keys that are dropped from untrusted JSON objects. */
|
|
14
|
+
export declare const UNSAFE_JSON_KEYS: ReadonlySet<string>;
|
|
15
|
+
/** Whether `key` is one of {@link UNSAFE_JSON_KEYS}. */
|
|
16
|
+
export declare const isUnsafeJsonKey: (key: string) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Returns `value` without own `__proto__`, `constructor` and `prototype` keys
|
|
19
|
+
* at any depth of its plain objects and arrays. Run untrusted JSON through it
|
|
20
|
+
* before handing it to `setContent`, `Node.fromJSON`, `Slice.fromJSON` or any
|
|
21
|
+
* code that merges objects key by key.
|
|
22
|
+
*
|
|
23
|
+
* Returns `value` itself when there is nothing to strip, and a copy otherwise,
|
|
24
|
+
* so the input is never mutated. Non-plain objects (class instances) pass
|
|
25
|
+
* through untouched.
|
|
26
|
+
*/
|
|
27
|
+
export declare function stripPrototypeKeys<T>(value: T): T;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guards against prototype pollution from untrusted JSON (GHSA-cp6q-959q-f8rh).
|
|
3
|
+
*
|
|
4
|
+
* `JSON.parse('{"__proto__": {...}}')` creates an *own* `__proto__` key. Code
|
|
5
|
+
* that later copies keys with bracket assignment (`out[key] = value`,
|
|
6
|
+
* `Object.assign`) turns it into the copy's prototype, so the copy inherits
|
|
7
|
+
* attacker-chosen properties that `for…in` loops (ProseMirror's
|
|
8
|
+
* `DOMSerializer.renderSpec`, for one) then treat as real ones. TipTap's
|
|
9
|
+
* `mergeAttributes()` did exactly that before `@tiptap/core` 2.27.3 / 3.30.4.
|
|
10
|
+
*
|
|
11
|
+
* This file has no dependencies so the tool layer can use it.
|
|
12
|
+
*/
|
|
13
|
+
/** Keys that are dropped from untrusted JSON objects. */
|
|
14
|
+
export declare const UNSAFE_JSON_KEYS: ReadonlySet<string>;
|
|
15
|
+
/** Whether `key` is one of {@link UNSAFE_JSON_KEYS}. */
|
|
16
|
+
export declare const isUnsafeJsonKey: (key: string) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Returns `value` without own `__proto__`, `constructor` and `prototype` keys
|
|
19
|
+
* at any depth of its plain objects and arrays. Run untrusted JSON through it
|
|
20
|
+
* before handing it to `setContent`, `Node.fromJSON`, `Slice.fromJSON` or any
|
|
21
|
+
* code that merges objects key by key.
|
|
22
|
+
*
|
|
23
|
+
* Returns `value` itself when there is nothing to strip, and a copy otherwise,
|
|
24
|
+
* so the input is never mutated. Non-plain objects (class instances) pass
|
|
25
|
+
* through untouched.
|
|
26
|
+
*/
|
|
27
|
+
export declare function stripPrototypeKeys<T>(value: T): T;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { McpToolDefinition, ToolsetInfo } from './registry.cjs';
|
|
2
|
+
/** A tool as `search_tools` ranks it. */
|
|
3
|
+
export interface ToolSearchResult {
|
|
4
|
+
/** Exposed tool name, to call or to pass to `enable_tools`. */
|
|
5
|
+
name: string;
|
|
6
|
+
toolset: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
/** The first sentence of the tool's description. */
|
|
9
|
+
summary: string;
|
|
10
|
+
readOnly: boolean;
|
|
11
|
+
score: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolSearchOptions {
|
|
14
|
+
/** Only search this toolset. */
|
|
15
|
+
toolset?: string;
|
|
16
|
+
/** Maximum results (default 10). */
|
|
17
|
+
limit?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Lower-cased, stemmed word tokens of `text`, splitting snake_case and camelCase. */
|
|
20
|
+
export declare function searchTokens(text: string): string[];
|
|
21
|
+
/** The first sentence of a description, for compact listings. */
|
|
22
|
+
export declare function summarize(description: string | undefined, max?: number): string;
|
|
23
|
+
/**
|
|
24
|
+
* Ranks tools against a free-text query: every query word scores by the
|
|
25
|
+
* fields it appears in (name, title, toolset, description, arguments), weighted by how
|
|
26
|
+
* rare the word is across all tools, so "trendline" outranks "chart". A word
|
|
27
|
+
* that prefixes a longer one ("trend" → "trendline") counts at half weight.
|
|
28
|
+
* Pure and dependency-free; `search_tools` uses it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function searchTools(tools: readonly McpToolDefinition[], toolsets: readonly ToolsetInfo[], query: string, options?: ToolSearchOptions): ToolSearchResult[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { McpToolDefinition, ToolsetInfo } from './registry.js';
|
|
2
|
+
/** A tool as `search_tools` ranks it. */
|
|
3
|
+
export interface ToolSearchResult {
|
|
4
|
+
/** Exposed tool name, to call or to pass to `enable_tools`. */
|
|
5
|
+
name: string;
|
|
6
|
+
toolset: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
/** The first sentence of the tool's description. */
|
|
9
|
+
summary: string;
|
|
10
|
+
readOnly: boolean;
|
|
11
|
+
score: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolSearchOptions {
|
|
14
|
+
/** Only search this toolset. */
|
|
15
|
+
toolset?: string;
|
|
16
|
+
/** Maximum results (default 10). */
|
|
17
|
+
limit?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Lower-cased, stemmed word tokens of `text`, splitting snake_case and camelCase. */
|
|
20
|
+
export declare function searchTokens(text: string): string[];
|
|
21
|
+
/** The first sentence of a description, for compact listings. */
|
|
22
|
+
export declare function summarize(description: string | undefined, max?: number): string;
|
|
23
|
+
/**
|
|
24
|
+
* Ranks tools against a free-text query: every query word scores by the
|
|
25
|
+
* fields it appears in (name, title, toolset, description, arguments), weighted by how
|
|
26
|
+
* rare the word is across all tools, so "trendline" outranks "chart". A word
|
|
27
|
+
* that prefixes a longer one ("trend" → "trendline") counts at half weight.
|
|
28
|
+
* Pure and dependency-free; `search_tools` uses it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function searchTools(tools: readonly McpToolDefinition[], toolsets: readonly ToolsetInfo[], query: string, options?: ToolSearchOptions): ToolSearchResult[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent skill files (`skills/<name>/SKILL.md` plus its `references/*.md`), keyed by
|
|
3
|
+
* path relative to the skills directory: `pixerate-chart/SKILL.md`,
|
|
4
|
+
* `pixerate-vector/references/commands.md`. In Node, `loadSkillFiles()` from
|
|
5
|
+
* `@pixerate/editor/bridge` reads the ones shipped with the package; in a browser,
|
|
6
|
+
* import them as text (with Vite, `import.meta.glob('…/skills/**\/*.md', { query: '?raw', import: 'default', eager: true })`).
|
|
7
|
+
*/
|
|
8
|
+
export type SkillFiles = Readonly<Record<string, string>>;
|
|
9
|
+
export interface SkillInfo {
|
|
10
|
+
/** Skill name (its directory), e.g. `pixerate-chart`. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** The frontmatter `description`: what the skill covers and when to use it. */
|
|
13
|
+
description: string;
|
|
14
|
+
/** Other files of the skill relative to its directory, e.g. `references/commands.md`. */
|
|
15
|
+
references: string[];
|
|
16
|
+
}
|
|
17
|
+
/** Reads `name` and `description` from a SKILL.md's YAML frontmatter. */
|
|
18
|
+
export declare function parseSkillFrontmatter(markdown: string): {
|
|
19
|
+
name?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
body: string;
|
|
22
|
+
};
|
|
23
|
+
/** The skills in a set of skill files, sorted by name. */
|
|
24
|
+
export declare function listSkills(files: SkillFiles): SkillInfo[];
|
|
25
|
+
/** One file of a skill (`SKILL.md` by default), or `undefined` if there is none. */
|
|
26
|
+
export declare function readSkillFile(files: SkillFiles, skill: string, file?: string): string | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent skill files (`skills/<name>/SKILL.md` plus its `references/*.md`), keyed by
|
|
3
|
+
* path relative to the skills directory: `pixerate-chart/SKILL.md`,
|
|
4
|
+
* `pixerate-vector/references/commands.md`. In Node, `loadSkillFiles()` from
|
|
5
|
+
* `@pixerate/editor/bridge` reads the ones shipped with the package; in a browser,
|
|
6
|
+
* import them as text (with Vite, `import.meta.glob('…/skills/**\/*.md', { query: '?raw', import: 'default', eager: true })`).
|
|
7
|
+
*/
|
|
8
|
+
export type SkillFiles = Readonly<Record<string, string>>;
|
|
9
|
+
export interface SkillInfo {
|
|
10
|
+
/** Skill name (its directory), e.g. `pixerate-chart`. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** The frontmatter `description`: what the skill covers and when to use it. */
|
|
13
|
+
description: string;
|
|
14
|
+
/** Other files of the skill relative to its directory, e.g. `references/commands.md`. */
|
|
15
|
+
references: string[];
|
|
16
|
+
}
|
|
17
|
+
/** Reads `name` and `description` from a SKILL.md's YAML frontmatter. */
|
|
18
|
+
export declare function parseSkillFrontmatter(markdown: string): {
|
|
19
|
+
name?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
body: string;
|
|
22
|
+
};
|
|
23
|
+
/** The skills in a set of skill files, sorted by name. */
|
|
24
|
+
export declare function listSkills(files: SkillFiles): SkillInfo[];
|
|
25
|
+
/** One file of a skill (`SKILL.md` by default), or `undefined` if there is none. */
|
|
26
|
+
export declare function readSkillFile(files: SkillFiles, skill: string, file?: string): string | undefined;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { McpListToolsResult, McpToolDefinition, McpToolResult, ToolSource, ToolsetInfo } from './registry.cjs';
|
|
2
|
+
import { type SkillFiles } from './skills.cjs';
|
|
3
|
+
export interface ToolDiscoveryOptions {
|
|
4
|
+
/** Toolsets listed from the start (default none: the agent enables what it needs). */
|
|
5
|
+
enabled?: readonly string[];
|
|
6
|
+
/** Skill files `get_skill` serves (see {@link SkillFiles}). Without them there is no `get_skill`. */
|
|
7
|
+
skills?: SkillFiles;
|
|
8
|
+
/** Default and maximum number of `search_tools` results (default 10, at most 50). */
|
|
9
|
+
searchLimit?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ToolViewOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Toolsets the agent may see and call (names from `registry.toolsets()`), or a
|
|
14
|
+
* predicate. Default: all. Change it later with `setToolsets`, e.g. to follow
|
|
15
|
+
* the focused editor.
|
|
16
|
+
*/
|
|
17
|
+
toolsets?: readonly string[] | ((toolset: ToolsetInfo) => boolean);
|
|
18
|
+
/** Only expose tools annotated `readOnlyHint: true`; write tools are refused with the reason. */
|
|
19
|
+
readOnly?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Serve discovery tools (`list_toolsets`, `search_tools`, `enable_tools`,
|
|
22
|
+
* `disable_tools` and, with skills, `get_skill`) and list only the toolsets
|
|
23
|
+
* and tools that are enabled, so a large catalogue costs the agent a handful
|
|
24
|
+
* of tool definitions until it asks for more. Tools that are allowed but not
|
|
25
|
+
* enabled can still be called by name.
|
|
26
|
+
*/
|
|
27
|
+
discovery?: boolean | ToolDiscoveryOptions;
|
|
28
|
+
}
|
|
29
|
+
/** Names of the tools a discovery view adds. */
|
|
30
|
+
export declare const TOOL_DISCOVERY_TOOLS: readonly ["list_toolsets", "search_tools", "enable_tools", "disable_tools", "get_skill"];
|
|
31
|
+
/**
|
|
32
|
+
* A filtered view of a {@link ToolSource} (usually a `ToolRegistry`, from
|
|
33
|
+
* `registry.view()`) that is itself a `ToolSource`, so `createMcpServer`,
|
|
34
|
+
* `connectToolBridge` and further views accept it.
|
|
35
|
+
*
|
|
36
|
+
* - **Scope** an agent to some toolsets (`toolsets`) or to read tools
|
|
37
|
+
* (`readOnly`). Tools outside the scope are neither listed nor callable.
|
|
38
|
+
* - **Discover** (`discovery`): list only what the agent enabled, plus tools to
|
|
39
|
+
* browse and search the rest and to enable it. `listChanged` fires whenever
|
|
40
|
+
* the listing changes.
|
|
41
|
+
*/
|
|
42
|
+
export declare class ToolRegistryView implements ToolSource {
|
|
43
|
+
private readonly source;
|
|
44
|
+
readonly capabilities: {
|
|
45
|
+
readonly tools: {
|
|
46
|
+
readonly listChanged: true;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
private allow;
|
|
50
|
+
private readonly readOnly;
|
|
51
|
+
private readonly discovery;
|
|
52
|
+
private readonly enabledSets;
|
|
53
|
+
private readonly enabledTools;
|
|
54
|
+
private readonly listeners;
|
|
55
|
+
private readonly meta;
|
|
56
|
+
private unsubscribe;
|
|
57
|
+
private lastSignature;
|
|
58
|
+
constructor(source: ToolSource, options?: ToolViewOptions);
|
|
59
|
+
/** Changes which toolsets the agent may use (`undefined`: all). Fires `listChanged` if the listing changes. */
|
|
60
|
+
setToolsets(toolsets: ToolViewOptions['toolsets']): void;
|
|
61
|
+
/**
|
|
62
|
+
* Lists more tools in a discovery view, as the `enable_tools` tool does.
|
|
63
|
+
* Throws for names the view does not allow. Returns the tool names newly listed.
|
|
64
|
+
*/
|
|
65
|
+
enableTools(selection: {
|
|
66
|
+
tools?: readonly string[];
|
|
67
|
+
toolsets?: readonly string[];
|
|
68
|
+
}): string[];
|
|
69
|
+
/** Stops listing tools in a discovery view, as `disable_tools` does. Returns the tool names no longer listed. */
|
|
70
|
+
disableTools(selection: {
|
|
71
|
+
tools?: readonly string[];
|
|
72
|
+
toolsets?: readonly string[];
|
|
73
|
+
}): string[];
|
|
74
|
+
/** Allowed toolsets, each with only its allowed tools. */
|
|
75
|
+
toolsets(): ToolsetInfo[];
|
|
76
|
+
listTools(): McpListToolsResult;
|
|
77
|
+
hasTool(name: string): boolean;
|
|
78
|
+
getTool(name: string): McpToolDefinition | undefined;
|
|
79
|
+
callTool(name: string, args?: Record<string, unknown>, options?: {
|
|
80
|
+
signal?: AbortSignal;
|
|
81
|
+
}): Promise<McpToolResult>;
|
|
82
|
+
onListChanged(listener: (tools: McpToolDefinition[]) => void): () => void;
|
|
83
|
+
/** Stops following the source and drops every listener. */
|
|
84
|
+
dispose(): void;
|
|
85
|
+
private changed;
|
|
86
|
+
private signature;
|
|
87
|
+
private allowsSet;
|
|
88
|
+
private catalogue;
|
|
89
|
+
private listed;
|
|
90
|
+
/** Resolves an exposed or unique bare name among the allowed tools, or explains why it isn't one. */
|
|
91
|
+
private find;
|
|
92
|
+
/** Normalizes names to exposed tool and toolset names, or throws naming every unknown one. */
|
|
93
|
+
private checkSelection;
|
|
94
|
+
private createDiscoveryTools;
|
|
95
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { McpListToolsResult, McpToolDefinition, McpToolResult, ToolSource, ToolsetInfo } from './registry.js';
|
|
2
|
+
import { type SkillFiles } from './skills.js';
|
|
3
|
+
export interface ToolDiscoveryOptions {
|
|
4
|
+
/** Toolsets listed from the start (default none: the agent enables what it needs). */
|
|
5
|
+
enabled?: readonly string[];
|
|
6
|
+
/** Skill files `get_skill` serves (see {@link SkillFiles}). Without them there is no `get_skill`. */
|
|
7
|
+
skills?: SkillFiles;
|
|
8
|
+
/** Default and maximum number of `search_tools` results (default 10, at most 50). */
|
|
9
|
+
searchLimit?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ToolViewOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Toolsets the agent may see and call (names from `registry.toolsets()`), or a
|
|
14
|
+
* predicate. Default: all. Change it later with `setToolsets`, e.g. to follow
|
|
15
|
+
* the focused editor.
|
|
16
|
+
*/
|
|
17
|
+
toolsets?: readonly string[] | ((toolset: ToolsetInfo) => boolean);
|
|
18
|
+
/** Only expose tools annotated `readOnlyHint: true`; write tools are refused with the reason. */
|
|
19
|
+
readOnly?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Serve discovery tools (`list_toolsets`, `search_tools`, `enable_tools`,
|
|
22
|
+
* `disable_tools` and, with skills, `get_skill`) and list only the toolsets
|
|
23
|
+
* and tools that are enabled, so a large catalogue costs the agent a handful
|
|
24
|
+
* of tool definitions until it asks for more. Tools that are allowed but not
|
|
25
|
+
* enabled can still be called by name.
|
|
26
|
+
*/
|
|
27
|
+
discovery?: boolean | ToolDiscoveryOptions;
|
|
28
|
+
}
|
|
29
|
+
/** Names of the tools a discovery view adds. */
|
|
30
|
+
export declare const TOOL_DISCOVERY_TOOLS: readonly ["list_toolsets", "search_tools", "enable_tools", "disable_tools", "get_skill"];
|
|
31
|
+
/**
|
|
32
|
+
* A filtered view of a {@link ToolSource} (usually a `ToolRegistry`, from
|
|
33
|
+
* `registry.view()`) that is itself a `ToolSource`, so `createMcpServer`,
|
|
34
|
+
* `connectToolBridge` and further views accept it.
|
|
35
|
+
*
|
|
36
|
+
* - **Scope** an agent to some toolsets (`toolsets`) or to read tools
|
|
37
|
+
* (`readOnly`). Tools outside the scope are neither listed nor callable.
|
|
38
|
+
* - **Discover** (`discovery`): list only what the agent enabled, plus tools to
|
|
39
|
+
* browse and search the rest and to enable it. `listChanged` fires whenever
|
|
40
|
+
* the listing changes.
|
|
41
|
+
*/
|
|
42
|
+
export declare class ToolRegistryView implements ToolSource {
|
|
43
|
+
private readonly source;
|
|
44
|
+
readonly capabilities: {
|
|
45
|
+
readonly tools: {
|
|
46
|
+
readonly listChanged: true;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
private allow;
|
|
50
|
+
private readonly readOnly;
|
|
51
|
+
private readonly discovery;
|
|
52
|
+
private readonly enabledSets;
|
|
53
|
+
private readonly enabledTools;
|
|
54
|
+
private readonly listeners;
|
|
55
|
+
private readonly meta;
|
|
56
|
+
private unsubscribe;
|
|
57
|
+
private lastSignature;
|
|
58
|
+
constructor(source: ToolSource, options?: ToolViewOptions);
|
|
59
|
+
/** Changes which toolsets the agent may use (`undefined`: all). Fires `listChanged` if the listing changes. */
|
|
60
|
+
setToolsets(toolsets: ToolViewOptions['toolsets']): void;
|
|
61
|
+
/**
|
|
62
|
+
* Lists more tools in a discovery view, as the `enable_tools` tool does.
|
|
63
|
+
* Throws for names the view does not allow. Returns the tool names newly listed.
|
|
64
|
+
*/
|
|
65
|
+
enableTools(selection: {
|
|
66
|
+
tools?: readonly string[];
|
|
67
|
+
toolsets?: readonly string[];
|
|
68
|
+
}): string[];
|
|
69
|
+
/** Stops listing tools in a discovery view, as `disable_tools` does. Returns the tool names no longer listed. */
|
|
70
|
+
disableTools(selection: {
|
|
71
|
+
tools?: readonly string[];
|
|
72
|
+
toolsets?: readonly string[];
|
|
73
|
+
}): string[];
|
|
74
|
+
/** Allowed toolsets, each with only its allowed tools. */
|
|
75
|
+
toolsets(): ToolsetInfo[];
|
|
76
|
+
listTools(): McpListToolsResult;
|
|
77
|
+
hasTool(name: string): boolean;
|
|
78
|
+
getTool(name: string): McpToolDefinition | undefined;
|
|
79
|
+
callTool(name: string, args?: Record<string, unknown>, options?: {
|
|
80
|
+
signal?: AbortSignal;
|
|
81
|
+
}): Promise<McpToolResult>;
|
|
82
|
+
onListChanged(listener: (tools: McpToolDefinition[]) => void): () => void;
|
|
83
|
+
/** Stops following the source and drops every listener. */
|
|
84
|
+
dispose(): void;
|
|
85
|
+
private changed;
|
|
86
|
+
private signature;
|
|
87
|
+
private allowsSet;
|
|
88
|
+
private catalogue;
|
|
89
|
+
private listed;
|
|
90
|
+
/** Resolves an exposed or unique bare name among the allowed tools, or explains why it isn't one. */
|
|
91
|
+
private find;
|
|
92
|
+
/** Normalizes names to exposed tool and toolset names, or throws naming every unknown one. */
|
|
93
|
+
private checkSelection;
|
|
94
|
+
private createDiscoveryTools;
|
|
95
|
+
}
|
|
@@ -9,7 +9,7 @@ import type { VectorEditorController } from './controller.cjs';
|
|
|
9
9
|
export interface VectorEffectsToolProviderOptions {
|
|
10
10
|
/** Provider id (unique per registry). Default `vector-effects`. */
|
|
11
11
|
id?: string;
|
|
12
|
-
/**
|
|
12
|
+
/** Tool-name prefix (`<namespace>__<name>`); defaults to the provider id, `''` for bare names. */
|
|
13
13
|
namespace?: string;
|
|
14
14
|
/** The document cannot be edited: write tools are hidden. A string is the reason. */
|
|
15
15
|
readOnly?: boolean | string | (() => boolean | string);
|
|
@@ -9,7 +9,7 @@ import type { VectorEditorController } from './controller.js';
|
|
|
9
9
|
export interface VectorEffectsToolProviderOptions {
|
|
10
10
|
/** Provider id (unique per registry). Default `vector-effects`. */
|
|
11
11
|
id?: string;
|
|
12
|
-
/**
|
|
12
|
+
/** Tool-name prefix (`<namespace>__<name>`); defaults to the provider id, `''` for bare names. */
|
|
13
13
|
namespace?: string;
|
|
14
14
|
/** The document cannot be edited: write tools are hidden. A string is the reason. */
|
|
15
15
|
readOnly?: boolean | string | (() => boolean | string);
|