@pixerate/editor 0.21.0 → 0.23.0
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 +100 -13
- package/THIRD_PARTY_NOTICES.md +88 -0
- package/dist/agent/index.cjs +86 -111
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +69 -211
- package/dist/agent/index.d.ts +69 -211
- package/dist/agent/index.js +77 -102
- package/dist/agent/index.js.map +1 -1
- package/dist/arrangeShortcuts-B8O3f8-P.d.cts +184 -0
- package/dist/arrangeShortcuts-sLlD2rSX.d.ts +184 -0
- package/dist/canvas/index.cjs +2112 -60
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +712 -181
- package/dist/canvas/index.d.ts +712 -181
- package/dist/canvas/index.js +2105 -53
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-26BVFKHU.cjs +453 -0
- package/dist/chunk-26BVFKHU.cjs.map +1 -0
- package/dist/chunk-2H7ZHPEJ.js +762 -0
- package/dist/chunk-2H7ZHPEJ.js.map +1 -0
- package/dist/chunk-7DWMJCAT.js +453 -0
- package/dist/chunk-7DWMJCAT.js.map +1 -0
- package/dist/{chunk-TVRC4KVT.cjs → chunk-AA4ZEVCC.cjs} +845 -90
- package/dist/chunk-AA4ZEVCC.cjs.map +1 -0
- package/dist/chunk-ARRTP33I.js +101 -0
- package/dist/chunk-ARRTP33I.js.map +1 -0
- package/dist/{chunk-LA7PEGU3.cjs → chunk-CL37JGFW.cjs} +4 -4
- package/dist/{chunk-LA7PEGU3.cjs.map → chunk-CL37JGFW.cjs.map} +1 -1
- package/dist/chunk-CPOKFNBG.cjs +101 -0
- package/dist/chunk-CPOKFNBG.cjs.map +1 -0
- package/dist/chunk-G2I4QJOT.cjs +762 -0
- package/dist/chunk-G2I4QJOT.cjs.map +1 -0
- package/dist/{chunk-4QPLEUL2.cjs → chunk-GVSMRPHB.cjs} +1046 -54
- package/dist/chunk-GVSMRPHB.cjs.map +1 -0
- package/dist/{chunk-KYRZDWM4.js → chunk-JJDLPEWL.js} +2 -2
- package/dist/{chunk-GVW4P7BG.js → chunk-K3R5NG2D.js} +448 -54
- package/dist/chunk-K3R5NG2D.js.map +1 -0
- package/dist/{chunk-3TYMNULT.js → chunk-MJZBNWG7.js} +807 -52
- package/dist/chunk-MJZBNWG7.js.map +1 -0
- package/dist/{chunk-A7DKIA72.js → chunk-QBJ22YZR.js} +1059 -93
- package/dist/chunk-QBJ22YZR.js.map +1 -0
- package/dist/{chunk-CYFJCKC4.js → chunk-QGHGJ56O.js} +997 -5
- package/dist/chunk-QGHGJ56O.js.map +1 -0
- package/dist/{chunk-JYRIOFEN.cjs → chunk-RIKBJLS2.cjs} +1064 -98
- package/dist/chunk-RIKBJLS2.cjs.map +1 -0
- package/dist/{chunk-U6NDQFOK.cjs → chunk-XDMXXC4Z.cjs} +569 -175
- package/dist/chunk-XDMXXC4Z.cjs.map +1 -0
- package/dist/commands/index.cjs +860 -0
- package/dist/commands/index.cjs.map +1 -0
- package/dist/commands/index.d.cts +592 -0
- package/dist/commands/index.d.ts +592 -0
- package/dist/commands/index.js +860 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/{controller-OUdxPY-X.d.ts → controller-pePCJLT1.d.cts} +216 -11
- package/dist/{controller-OUdxPY-X.d.cts → controller-pePCJLT1.d.ts} +216 -11
- package/dist/extensions/index.cjs +14 -4
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +3 -3
- package/dist/extensions/index.d.ts +3 -3
- package/dist/extensions/index.js +13 -3
- package/dist/history/index.cjs +12 -2
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +211 -7
- package/dist/history/index.d.ts +211 -7
- package/dist/history/index.js +13 -3
- package/dist/image-editor/index.cjs +418 -13
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +154 -3
- package/dist/image-editor/index.d.ts +154 -3
- package/dist/image-editor/index.js +417 -12
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{index-k3mFbPx_.d.cts → index-CCr_z9kF.d.cts} +3 -3
- package/dist/{index-Ng1pG7JE.d.ts → index-Ck6ajwXh.d.ts} +3 -3
- package/dist/index.cjs +275 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +296 -47
- package/dist/index.d.ts +296 -47
- package/dist/index.js +266 -74
- package/dist/index.js.map +1 -1
- package/dist/registry-D5-R90p0.d.cts +209 -0
- package/dist/registry-D5-R90p0.d.ts +209 -0
- package/dist/{registry-iAHbqkYt.d.cts → registry-GJI4gToU.d.cts} +15 -4
- package/dist/{registry-iAHbqkYt.d.ts → registry-GJI4gToU.d.ts} +15 -4
- package/dist/serializers/index.cjs +3 -3
- package/dist/serializers/index.d.cts +1 -1
- package/dist/serializers/index.d.ts +1 -1
- package/dist/serializers/index.js +2 -2
- package/dist/spreadsheet/index.cjs +23 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +97 -10
- package/dist/spreadsheet/index.d.ts +97 -10
- package/dist/spreadsheet/index.js +22 -2
- package/dist/{track-changes-G8JcWB8b.d.cts → track-changes-BSF58RK0.d.cts} +92 -9
- package/dist/{track-changes-G8JcWB8b.d.ts → track-changes-BSF58RK0.d.ts} +92 -9
- package/dist/{types-DMe0vFB1.d.cts → types-DX4Mh4SL.d.cts} +1 -1
- package/dist/{types-DMe0vFB1.d.ts → types-DX4Mh4SL.d.ts} +1 -1
- package/dist/types-GT5a5YAX.d.cts +86 -0
- package/dist/types-GT5a5YAX.d.ts +86 -0
- package/package.json +8 -2
- package/dist/chunk-2TWGLC5K.cjs +0 -262
- package/dist/chunk-2TWGLC5K.cjs.map +0 -1
- package/dist/chunk-3TYMNULT.js.map +0 -1
- package/dist/chunk-4QPLEUL2.cjs.map +0 -1
- package/dist/chunk-A7DKIA72.js.map +0 -1
- package/dist/chunk-CYFJCKC4.js.map +0 -1
- package/dist/chunk-GVW4P7BG.js.map +0 -1
- package/dist/chunk-JYRIOFEN.cjs.map +0 -1
- package/dist/chunk-KAADNAPF.js +0 -262
- package/dist/chunk-KAADNAPF.js.map +0 -1
- package/dist/chunk-TVRC4KVT.cjs.map +0 -1
- package/dist/chunk-U6NDQFOK.cjs.map +0 -1
- package/dist/types-BZgcDsC5.d.cts +0 -42
- package/dist/types-BZgcDsC5.d.ts +0 -42
- /package/dist/{chunk-KYRZDWM4.js.map → chunk-JJDLPEWL.js.map} +0 -0
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { C as CanvasNode,
|
|
1
|
+
import { C as CanvasNode, b as CanvasEdge, X as XYPosition, S as Side } from '../types-DX4Mh4SL.js';
|
|
2
|
+
import { A as AgentToolProvider } from '../registry-D5-R90p0.js';
|
|
3
|
+
export { a as AgentTool, b as AgentToolHandler, J as JsonSchema, c as JsonSchemaType, M as McpListToolsResult, d as McpToolContent, e as McpToolDefinition, f as McpToolResult, S as SchemaValidationError, T as TOOL_NAMESPACE_SEPARATOR, g as ToolCallContext, h as ToolCallError, i as ToolErrorCode, j as ToolRegistry, k as ToolRegistryError, l as ToolRegistryOptions, m as createToolRegistry, t as toToolResult, v as validateJsonSchema } from '../registry-D5-R90p0.js';
|
|
2
4
|
import { Editor } from '@tiptap/core';
|
|
3
|
-
import {
|
|
5
|
+
import { S as SpreadsheetController } from '../controller-pePCJLT1.js';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Agent presence state for visual multiplayer/agent choreography.
|
|
@@ -196,6 +198,14 @@ declare function planToolCall<TNode extends CanvasNode = CanvasNode, TEdge exten
|
|
|
196
198
|
*/
|
|
197
199
|
declare const MCP_TOOL_GET_EDITOR_STATE: {
|
|
198
200
|
readonly name: "get_editor_state";
|
|
201
|
+
readonly title: "Get editor state";
|
|
202
|
+
readonly annotations: {
|
|
203
|
+
readonly title: "Get editor state";
|
|
204
|
+
readonly readOnlyHint: true;
|
|
205
|
+
readonly destructiveHint: false;
|
|
206
|
+
readonly idempotentHint: true;
|
|
207
|
+
readonly openWorldHint: false;
|
|
208
|
+
};
|
|
199
209
|
readonly description: "Retrieves the current state of the document, variables, selection, and canvas graph (nodes and edges).";
|
|
200
210
|
readonly inputSchema: {
|
|
201
211
|
readonly type: "object";
|
|
@@ -213,6 +223,14 @@ declare const MCP_TOOL_GET_EDITOR_STATE: {
|
|
|
213
223
|
};
|
|
214
224
|
declare const MCP_TOOL_EDIT_CANVAS: {
|
|
215
225
|
readonly name: "edit_canvas";
|
|
226
|
+
readonly title: "Edit the canvas";
|
|
227
|
+
readonly annotations: {
|
|
228
|
+
readonly title: "Edit the canvas";
|
|
229
|
+
readonly readOnlyHint: false;
|
|
230
|
+
readonly destructiveHint: true;
|
|
231
|
+
readonly idempotentHint: false;
|
|
232
|
+
readonly openWorldHint: false;
|
|
233
|
+
};
|
|
216
234
|
readonly description: "Applies high-level structural operations to the visual canvas (adding nodes, connecting edges, organizing layout, or moving elements).";
|
|
217
235
|
readonly inputSchema: {
|
|
218
236
|
readonly type: "object";
|
|
@@ -269,6 +287,14 @@ declare const MCP_TOOL_EDIT_CANVAS: {
|
|
|
269
287
|
};
|
|
270
288
|
declare const MCP_TOOL_EDIT_PROMPT: {
|
|
271
289
|
readonly name: "edit_prompt";
|
|
290
|
+
readonly title: "Edit the prompt";
|
|
291
|
+
readonly annotations: {
|
|
292
|
+
readonly title: "Edit the prompt";
|
|
293
|
+
readonly readOnlyHint: false;
|
|
294
|
+
readonly destructiveHint: true;
|
|
295
|
+
readonly idempotentHint: false;
|
|
296
|
+
readonly openWorldHint: false;
|
|
297
|
+
};
|
|
272
298
|
readonly description: "Applies edits to the prompt template document, including inserting text, replacing ranges, and setting variables.";
|
|
273
299
|
readonly inputSchema: {
|
|
274
300
|
readonly type: "object";
|
|
@@ -307,6 +333,14 @@ declare const MCP_TOOL_EDIT_PROMPT: {
|
|
|
307
333
|
};
|
|
308
334
|
declare const MCP_TOOL_VIEW_EDITOR: {
|
|
309
335
|
readonly name: "view_editor";
|
|
336
|
+
readonly title: "View the editor";
|
|
337
|
+
readonly annotations: {
|
|
338
|
+
readonly title: "View the editor";
|
|
339
|
+
readonly readOnlyHint: true;
|
|
340
|
+
readonly destructiveHint: false;
|
|
341
|
+
readonly idempotentHint: true;
|
|
342
|
+
readonly openWorldHint: false;
|
|
343
|
+
};
|
|
310
344
|
readonly description: "Captures a visual image snapshot (JPEG or PNG) of the editor canvas or viewport for multimodal evaluation. Active agent cursor indicators are automatically excluded from the snapshot.";
|
|
311
345
|
readonly inputSchema: {
|
|
312
346
|
readonly type: "object";
|
|
@@ -335,6 +369,14 @@ declare const MCP_TOOL_VIEW_EDITOR: {
|
|
|
335
369
|
declare const EXPORT_EXCLUDED_SELECTORS: readonly [".pixerate-presence", ".agent-presence", ".ursula-presence"];
|
|
336
370
|
declare const EDITOR_MCP_TOOLS: readonly [{
|
|
337
371
|
readonly name: "get_editor_state";
|
|
372
|
+
readonly title: "Get editor state";
|
|
373
|
+
readonly annotations: {
|
|
374
|
+
readonly title: "Get editor state";
|
|
375
|
+
readonly readOnlyHint: true;
|
|
376
|
+
readonly destructiveHint: false;
|
|
377
|
+
readonly idempotentHint: true;
|
|
378
|
+
readonly openWorldHint: false;
|
|
379
|
+
};
|
|
338
380
|
readonly description: "Retrieves the current state of the document, variables, selection, and canvas graph (nodes and edges).";
|
|
339
381
|
readonly inputSchema: {
|
|
340
382
|
readonly type: "object";
|
|
@@ -351,6 +393,14 @@ declare const EDITOR_MCP_TOOLS: readonly [{
|
|
|
351
393
|
};
|
|
352
394
|
}, {
|
|
353
395
|
readonly name: "edit_canvas";
|
|
396
|
+
readonly title: "Edit the canvas";
|
|
397
|
+
readonly annotations: {
|
|
398
|
+
readonly title: "Edit the canvas";
|
|
399
|
+
readonly readOnlyHint: false;
|
|
400
|
+
readonly destructiveHint: true;
|
|
401
|
+
readonly idempotentHint: false;
|
|
402
|
+
readonly openWorldHint: false;
|
|
403
|
+
};
|
|
354
404
|
readonly description: "Applies high-level structural operations to the visual canvas (adding nodes, connecting edges, organizing layout, or moving elements).";
|
|
355
405
|
readonly inputSchema: {
|
|
356
406
|
readonly type: "object";
|
|
@@ -406,6 +456,14 @@ declare const EDITOR_MCP_TOOLS: readonly [{
|
|
|
406
456
|
};
|
|
407
457
|
}, {
|
|
408
458
|
readonly name: "edit_prompt";
|
|
459
|
+
readonly title: "Edit the prompt";
|
|
460
|
+
readonly annotations: {
|
|
461
|
+
readonly title: "Edit the prompt";
|
|
462
|
+
readonly readOnlyHint: false;
|
|
463
|
+
readonly destructiveHint: true;
|
|
464
|
+
readonly idempotentHint: false;
|
|
465
|
+
readonly openWorldHint: false;
|
|
466
|
+
};
|
|
409
467
|
readonly description: "Applies edits to the prompt template document, including inserting text, replacing ranges, and setting variables.";
|
|
410
468
|
readonly inputSchema: {
|
|
411
469
|
readonly type: "object";
|
|
@@ -443,6 +501,14 @@ declare const EDITOR_MCP_TOOLS: readonly [{
|
|
|
443
501
|
};
|
|
444
502
|
}, {
|
|
445
503
|
readonly name: "view_editor";
|
|
504
|
+
readonly title: "View the editor";
|
|
505
|
+
readonly annotations: {
|
|
506
|
+
readonly title: "View the editor";
|
|
507
|
+
readonly readOnlyHint: true;
|
|
508
|
+
readonly destructiveHint: false;
|
|
509
|
+
readonly idempotentHint: true;
|
|
510
|
+
readonly openWorldHint: false;
|
|
511
|
+
};
|
|
446
512
|
readonly description: "Captures a visual image snapshot (JPEG or PNG) of the editor canvas or viewport for multimodal evaluation. Active agent cursor indicators are automatically excluded from the snapshot.";
|
|
447
513
|
readonly inputSchema: {
|
|
448
514
|
readonly type: "object";
|
|
@@ -465,214 +531,6 @@ declare const EDITOR_MCP_TOOLS: readonly [{
|
|
|
465
531
|
};
|
|
466
532
|
}];
|
|
467
533
|
|
|
468
|
-
/**
|
|
469
|
-
* JSON-Schema-lite: the subset of JSON Schema used by MCP tool `inputSchema`s,
|
|
470
|
-
* plus a small validator for tool-call arguments. Unknown keywords are ignored.
|
|
471
|
-
*/
|
|
472
|
-
type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
473
|
-
interface JsonSchema {
|
|
474
|
-
type?: JsonSchemaType | readonly JsonSchemaType[];
|
|
475
|
-
description?: string;
|
|
476
|
-
title?: string;
|
|
477
|
-
enum?: readonly unknown[];
|
|
478
|
-
const?: unknown;
|
|
479
|
-
default?: unknown;
|
|
480
|
-
properties?: {
|
|
481
|
-
readonly [key: string]: JsonSchema;
|
|
482
|
-
};
|
|
483
|
-
required?: readonly string[];
|
|
484
|
-
additionalProperties?: boolean | JsonSchema;
|
|
485
|
-
items?: JsonSchema;
|
|
486
|
-
minItems?: number;
|
|
487
|
-
maxItems?: number;
|
|
488
|
-
minimum?: number;
|
|
489
|
-
maximum?: number;
|
|
490
|
-
minLength?: number;
|
|
491
|
-
maxLength?: number;
|
|
492
|
-
pattern?: string;
|
|
493
|
-
[keyword: string]: unknown;
|
|
494
|
-
}
|
|
495
|
-
interface SchemaValidationError {
|
|
496
|
-
/** JSON-pointer-like path to the offending value, e.g. `/node/id` (`""` is the root). */
|
|
497
|
-
path: string;
|
|
498
|
-
message: string;
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Validates `value` against `schema` and returns every error found (an empty
|
|
502
|
-
* array means valid). Supports `type` (incl. arrays of types), `enum`, `const`,
|
|
503
|
-
* `properties`, `required`, `additionalProperties`, `items`, `minItems`,
|
|
504
|
-
* `maxItems`, `minimum`, `maximum`, `minLength`, `maxLength` and `pattern`.
|
|
505
|
-
*/
|
|
506
|
-
declare function validateJsonSchema(value: unknown, schema: JsonSchema | undefined, path?: string): SchemaValidationError[];
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* MCP-shaped tool definition, as returned by `tools/list`.
|
|
510
|
-
*/
|
|
511
|
-
interface McpToolDefinition {
|
|
512
|
-
name: string;
|
|
513
|
-
title?: string;
|
|
514
|
-
description?: string;
|
|
515
|
-
inputSchema: JsonSchema & {
|
|
516
|
-
type: 'object';
|
|
517
|
-
};
|
|
518
|
-
outputSchema?: JsonSchema;
|
|
519
|
-
annotations?: {
|
|
520
|
-
title?: string;
|
|
521
|
-
readOnlyHint?: boolean;
|
|
522
|
-
destructiveHint?: boolean;
|
|
523
|
-
idempotentHint?: boolean;
|
|
524
|
-
openWorldHint?: boolean;
|
|
525
|
-
[key: string]: unknown;
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
type McpToolContent = {
|
|
529
|
-
type: 'text';
|
|
530
|
-
text: string;
|
|
531
|
-
} | {
|
|
532
|
-
type: 'image';
|
|
533
|
-
data: string;
|
|
534
|
-
mimeType: string;
|
|
535
|
-
} | {
|
|
536
|
-
type: string;
|
|
537
|
-
[key: string]: unknown;
|
|
538
|
-
};
|
|
539
|
-
/** MCP `tools/call` result. */
|
|
540
|
-
interface McpToolResult {
|
|
541
|
-
content: McpToolContent[];
|
|
542
|
-
structuredContent?: Record<string, unknown>;
|
|
543
|
-
isError?: boolean;
|
|
544
|
-
}
|
|
545
|
-
/** MCP `tools/list` result. */
|
|
546
|
-
interface McpListToolsResult {
|
|
547
|
-
tools: McpToolDefinition[];
|
|
548
|
-
}
|
|
549
|
-
interface ToolCallContext {
|
|
550
|
-
/** Name the tool was called by (possibly namespaced). */
|
|
551
|
-
name: string;
|
|
552
|
-
/** Id of the provider that owns the tool. */
|
|
553
|
-
providerId: string;
|
|
554
|
-
signal?: AbortSignal;
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Handler return values are normalized into an {@link McpToolResult}: a full
|
|
558
|
-
* result (`{ content: [...] }`) is passed through, a string becomes a text
|
|
559
|
-
* block, `undefined` becomes an empty result, and anything else is returned
|
|
560
|
-
* as `structuredContent` (plain objects) plus a JSON text block.
|
|
561
|
-
*/
|
|
562
|
-
type AgentToolHandler = (args: Record<string, any>, context: ToolCallContext) => unknown | Promise<unknown>;
|
|
563
|
-
interface AgentTool extends McpToolDefinition {
|
|
564
|
-
handler: AgentToolHandler;
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* A source of tools, typically one per mounted editor, spreadsheet or canvas.
|
|
568
|
-
*/
|
|
569
|
-
interface AgentToolProvider {
|
|
570
|
-
/** Unique id within a registry, e.g. `doc-1`. Used as the namespace on collisions. */
|
|
571
|
-
id: string;
|
|
572
|
-
/** Always prefix this provider's tools with `<namespace>__`. */
|
|
573
|
-
namespace?: string;
|
|
574
|
-
/** Tools, or a function returning the current tools (re-read on every `listTools`). */
|
|
575
|
-
tools: readonly AgentTool[] | (() => readonly AgentTool[]);
|
|
576
|
-
/** Lets the provider signal that its tool list changed; returns an unsubscribe function. */
|
|
577
|
-
subscribe?: (notify: () => void) => () => void;
|
|
578
|
-
}
|
|
579
|
-
type ToolErrorCode = 'unknown_tool' | 'invalid_arguments' | 'tool_failed';
|
|
580
|
-
/** Structured error carried in `structuredContent.error` of a failed call. */
|
|
581
|
-
interface ToolCallError {
|
|
582
|
-
code: ToolErrorCode;
|
|
583
|
-
message: string;
|
|
584
|
-
tool: string;
|
|
585
|
-
details?: SchemaValidationError[];
|
|
586
|
-
}
|
|
587
|
-
declare class ToolRegistryError extends Error {
|
|
588
|
-
readonly code: 'duplicate_provider' | 'name_collision' | 'invalid_tool';
|
|
589
|
-
constructor(code: ToolRegistryError['code'], message: string);
|
|
590
|
-
}
|
|
591
|
-
interface ToolRegistryOptions {
|
|
592
|
-
/**
|
|
593
|
-
* What to do when two providers contribute the same tool name:
|
|
594
|
-
* `namespace` (default) exposes every colliding tool as `<providerId>__<name>`;
|
|
595
|
-
* `error` makes `register` throw.
|
|
596
|
-
*/
|
|
597
|
-
onCollision?: 'namespace' | 'error';
|
|
598
|
-
/** Coalescing window for `listChanged` notifications in ms (default 0: same tick). */
|
|
599
|
-
listChangedDelayMs?: number;
|
|
600
|
-
/** Validate arguments against `inputSchema` before calling handlers (default `true`). */
|
|
601
|
-
validateArguments?: boolean;
|
|
602
|
-
}
|
|
603
|
-
/** Separator between namespace and tool name; valid in MCP and LLM tool-name charsets. */
|
|
604
|
-
declare const TOOL_NAMESPACE_SEPARATOR = "__";
|
|
605
|
-
/** Normalizes a handler's return value into an MCP `tools/call` result. */
|
|
606
|
-
declare function toToolResult(value: unknown): McpToolResult;
|
|
607
|
-
/**
|
|
608
|
-
* Transport-agnostic registry of agent tools contributed by live providers.
|
|
609
|
-
*
|
|
610
|
-
* `listTools()` and `callTool()` return MCP `tools/list` / `tools/call`
|
|
611
|
-
* result shapes, and `onListChanged` fires (coalesced) whenever the exposed
|
|
612
|
-
* tool list changes, mirroring MCP's `notifications/tools/list_changed`, so an
|
|
613
|
-
* MCP server can be a thin wrapper around it.
|
|
614
|
-
*/
|
|
615
|
-
declare class ToolRegistry {
|
|
616
|
-
/** MCP server capabilities this registry supports. */
|
|
617
|
-
readonly capabilities: {
|
|
618
|
-
readonly tools: {
|
|
619
|
-
readonly listChanged: true;
|
|
620
|
-
};
|
|
621
|
-
};
|
|
622
|
-
private readonly entries;
|
|
623
|
-
private readonly listeners;
|
|
624
|
-
private readonly options;
|
|
625
|
-
private timer;
|
|
626
|
-
private lastSignature;
|
|
627
|
-
constructor(options?: ToolRegistryOptions);
|
|
628
|
-
/**
|
|
629
|
-
* Registers a provider and returns a function that unregisters it.
|
|
630
|
-
* Throws a {@link ToolRegistryError} for a duplicate provider id, an invalid
|
|
631
|
-
* tool name, or (with `onCollision: 'error'`) a tool name collision.
|
|
632
|
-
*/
|
|
633
|
-
register(provider: AgentToolProvider): () => void;
|
|
634
|
-
/** Removes a provider by id or instance. Returns whether it was registered. */
|
|
635
|
-
unregister(providerOrId: string | AgentToolProvider): boolean;
|
|
636
|
-
/** Registered provider ids in registration order. */
|
|
637
|
-
providerIds(): string[];
|
|
638
|
-
/**
|
|
639
|
-
* Resolves exposed names. Tools are ordered by provider registration, then
|
|
640
|
-
* by their order within the provider.
|
|
641
|
-
*/
|
|
642
|
-
private resolve;
|
|
643
|
-
/** MCP `tools/list` result for the current providers. */
|
|
644
|
-
listTools(): McpListToolsResult;
|
|
645
|
-
/** Whether a tool with this exposed name exists. */
|
|
646
|
-
hasTool(name: string): boolean;
|
|
647
|
-
/** Looks up a tool definition by exposed name. */
|
|
648
|
-
getTool(name: string): McpToolDefinition | undefined;
|
|
649
|
-
/**
|
|
650
|
-
* Calls a tool by exposed name and returns an MCP `tools/call` result.
|
|
651
|
-
* Never rejects: unknown tools, invalid arguments and handler errors come
|
|
652
|
-
* back as `isError: true` results with a {@link ToolCallError} in
|
|
653
|
-
* `structuredContent.error` (MCP transports may map `unknown_tool` to a
|
|
654
|
-
* JSON-RPC `-32602` error instead).
|
|
655
|
-
*/
|
|
656
|
-
callTool(name: string, args?: Record<string, unknown>, options?: {
|
|
657
|
-
signal?: AbortSignal;
|
|
658
|
-
}): Promise<McpToolResult>;
|
|
659
|
-
/**
|
|
660
|
-
* Subscribes to tool-list changes. Notifications are coalesced: many
|
|
661
|
-
* registrations or provider signals within the delay window produce one
|
|
662
|
-
* call, and none if the exposed list ends up unchanged (e.g. a provider
|
|
663
|
-
* unmounted and remounted). Returns an unsubscribe function.
|
|
664
|
-
*/
|
|
665
|
-
onListChanged(listener: (tools: McpToolDefinition[]) => void): () => void;
|
|
666
|
-
/** Schedules a coalesced `listChanged` check; providers may call it directly. */
|
|
667
|
-
notifyListChanged(): void;
|
|
668
|
-
/** Runs a pending `listChanged` check immediately. */
|
|
669
|
-
flush(): void;
|
|
670
|
-
private signature;
|
|
671
|
-
/** Unregisters every provider and listener and cancels pending notifications. */
|
|
672
|
-
dispose(): void;
|
|
673
|
-
}
|
|
674
|
-
declare function createToolRegistry(options?: ToolRegistryOptions): ToolRegistry;
|
|
675
|
-
|
|
676
534
|
interface ToolProviderOptions {
|
|
677
535
|
/** Provider id (unique per registry). */
|
|
678
536
|
id: string;
|
|
@@ -723,4 +581,4 @@ interface EditorMcpToolProviderOptions<TNode extends CanvasNode = CanvasNode, TE
|
|
|
723
581
|
*/
|
|
724
582
|
declare function createEditorMcpToolProvider<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge>(options: EditorMcpToolProviderOptions<TNode, TEdge>): AgentToolProvider;
|
|
725
583
|
|
|
726
|
-
export { type AgentCommand, type AgentPresence, type AgentStep,
|
|
584
|
+
export { type AgentCommand, type AgentPresence, type AgentStep, AgentToolProvider, EDITOR_MCP_TOOLS, EXPORT_EXCLUDED_SELECTORS, type EditorMcpToolProviderOptions, type EditorSnapshot, MCP_TOOL_EDIT_CANVAS, MCP_TOOL_EDIT_PROMPT, MCP_TOOL_GET_EDITOR_STATE, MCP_TOOL_VIEW_EDITOR, type RichTextToolTarget, type ToolProviderOptions, createEditorMcpToolProvider, createRichTextToolProvider, createSpreadsheetToolProvider, normalizeSide, planAgentCommand, planToolCall, toolCallToAgentCommand };
|
package/dist/agent/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
validateJsonSchema
|
|
3
|
+
} from "../chunk-ARRTP33I.js";
|
|
1
4
|
import {
|
|
2
5
|
getEditorMarkdown,
|
|
3
6
|
getEditorText,
|
|
4
7
|
plainTextToSlice
|
|
5
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-MJZBNWG7.js";
|
|
6
9
|
import {
|
|
7
10
|
colNameToIndex,
|
|
8
11
|
indexToColName,
|
|
9
12
|
isFormulaError
|
|
10
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-QBJ22YZR.js";
|
|
11
14
|
import {
|
|
12
15
|
ensureLayout,
|
|
13
16
|
getLayoutedNodes,
|
|
@@ -276,6 +279,14 @@ function planToolCall(name, args, snapshot, options) {
|
|
|
276
279
|
// src/agent/tools.ts
|
|
277
280
|
var MCP_TOOL_GET_EDITOR_STATE = {
|
|
278
281
|
name: "get_editor_state",
|
|
282
|
+
title: "Get editor state",
|
|
283
|
+
annotations: {
|
|
284
|
+
title: "Get editor state",
|
|
285
|
+
readOnlyHint: true,
|
|
286
|
+
destructiveHint: false,
|
|
287
|
+
idempotentHint: true,
|
|
288
|
+
openWorldHint: false
|
|
289
|
+
},
|
|
279
290
|
description: "Retrieves the current state of the document, variables, selection, and canvas graph (nodes and edges).",
|
|
280
291
|
inputSchema: {
|
|
281
292
|
type: "object",
|
|
@@ -293,6 +304,14 @@ var MCP_TOOL_GET_EDITOR_STATE = {
|
|
|
293
304
|
};
|
|
294
305
|
var MCP_TOOL_EDIT_CANVAS = {
|
|
295
306
|
name: "edit_canvas",
|
|
307
|
+
title: "Edit the canvas",
|
|
308
|
+
annotations: {
|
|
309
|
+
title: "Edit the canvas",
|
|
310
|
+
readOnlyHint: false,
|
|
311
|
+
destructiveHint: true,
|
|
312
|
+
idempotentHint: false,
|
|
313
|
+
openWorldHint: false
|
|
314
|
+
},
|
|
296
315
|
description: "Applies high-level structural operations to the visual canvas (adding nodes, connecting edges, organizing layout, or moving elements).",
|
|
297
316
|
inputSchema: {
|
|
298
317
|
type: "object",
|
|
@@ -355,6 +374,14 @@ var MCP_TOOL_EDIT_CANVAS = {
|
|
|
355
374
|
};
|
|
356
375
|
var MCP_TOOL_EDIT_PROMPT = {
|
|
357
376
|
name: "edit_prompt",
|
|
377
|
+
title: "Edit the prompt",
|
|
378
|
+
annotations: {
|
|
379
|
+
title: "Edit the prompt",
|
|
380
|
+
readOnlyHint: false,
|
|
381
|
+
destructiveHint: true,
|
|
382
|
+
idempotentHint: false,
|
|
383
|
+
openWorldHint: false
|
|
384
|
+
},
|
|
358
385
|
description: "Applies edits to the prompt template document, including inserting text, replacing ranges, and setting variables.",
|
|
359
386
|
inputSchema: {
|
|
360
387
|
type: "object",
|
|
@@ -393,6 +420,14 @@ var MCP_TOOL_EDIT_PROMPT = {
|
|
|
393
420
|
};
|
|
394
421
|
var MCP_TOOL_VIEW_EDITOR = {
|
|
395
422
|
name: "view_editor",
|
|
423
|
+
title: "View the editor",
|
|
424
|
+
annotations: {
|
|
425
|
+
title: "View the editor",
|
|
426
|
+
readOnlyHint: true,
|
|
427
|
+
destructiveHint: false,
|
|
428
|
+
idempotentHint: true,
|
|
429
|
+
openWorldHint: false
|
|
430
|
+
},
|
|
396
431
|
description: "Captures a visual image snapshot (JPEG or PNG) of the editor canvas or viewport for multimodal evaluation. Active agent cursor indicators are automatically excluded from the snapshot.",
|
|
397
432
|
inputSchema: {
|
|
398
433
|
type: "object",
|
|
@@ -426,103 +461,6 @@ var EDITOR_MCP_TOOLS = [
|
|
|
426
461
|
MCP_TOOL_VIEW_EDITOR
|
|
427
462
|
];
|
|
428
463
|
|
|
429
|
-
// src/agent/schema.ts
|
|
430
|
-
function typeOf(value) {
|
|
431
|
-
if (value === null) return "null";
|
|
432
|
-
if (Array.isArray(value)) return "array";
|
|
433
|
-
if (typeof value === "number") return Number.isInteger(value) ? "integer" : "number";
|
|
434
|
-
if (typeof value === "string" || typeof value === "boolean" || typeof value === "object") {
|
|
435
|
-
return typeof value;
|
|
436
|
-
}
|
|
437
|
-
return "undefined";
|
|
438
|
-
}
|
|
439
|
-
function matchesType(value, type) {
|
|
440
|
-
const actual = typeOf(value);
|
|
441
|
-
if (type === "number") return actual === "number" || actual === "integer";
|
|
442
|
-
return actual === type;
|
|
443
|
-
}
|
|
444
|
-
var isEqual = (a, b) => a === b || JSON.stringify(a) === JSON.stringify(b);
|
|
445
|
-
function validateJsonSchema(value, schema, path = "") {
|
|
446
|
-
if (!schema || typeof schema !== "object") return [];
|
|
447
|
-
const errors = [];
|
|
448
|
-
const at = path || "/";
|
|
449
|
-
if (schema.type !== void 0) {
|
|
450
|
-
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
451
|
-
if (!types.some((t) => matchesType(value, t))) {
|
|
452
|
-
errors.push({ path: at, message: `Expected ${types.join(" | ")}, got ${typeOf(value)}.` });
|
|
453
|
-
return errors;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
if (schema.const !== void 0 && !isEqual(value, schema.const)) {
|
|
457
|
-
errors.push({ path: at, message: `Expected ${JSON.stringify(schema.const)}.` });
|
|
458
|
-
}
|
|
459
|
-
if (schema.enum && !schema.enum.some((option) => isEqual(value, option))) {
|
|
460
|
-
errors.push({
|
|
461
|
-
path: at,
|
|
462
|
-
message: `Expected one of ${schema.enum.map((o) => JSON.stringify(o)).join(", ")}, got ${JSON.stringify(value)}.`
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
if (typeof value === "string") {
|
|
466
|
-
if (schema.minLength !== void 0 && value.length < schema.minLength) {
|
|
467
|
-
errors.push({ path: at, message: `Must be at least ${schema.minLength} characters.` });
|
|
468
|
-
}
|
|
469
|
-
if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
|
|
470
|
-
errors.push({ path: at, message: `Must be at most ${schema.maxLength} characters.` });
|
|
471
|
-
}
|
|
472
|
-
if (schema.pattern !== void 0) {
|
|
473
|
-
let regex = null;
|
|
474
|
-
try {
|
|
475
|
-
regex = new RegExp(schema.pattern, "u");
|
|
476
|
-
} catch {
|
|
477
|
-
}
|
|
478
|
-
if (regex && !regex.test(value)) {
|
|
479
|
-
errors.push({ path: at, message: `Must match pattern ${schema.pattern}.` });
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
if (typeof value === "number") {
|
|
484
|
-
if (schema.minimum !== void 0 && value < schema.minimum) {
|
|
485
|
-
errors.push({ path: at, message: `Must be >= ${schema.minimum}.` });
|
|
486
|
-
}
|
|
487
|
-
if (schema.maximum !== void 0 && value > schema.maximum) {
|
|
488
|
-
errors.push({ path: at, message: `Must be <= ${schema.maximum}.` });
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
if (Array.isArray(value)) {
|
|
492
|
-
if (schema.minItems !== void 0 && value.length < schema.minItems) {
|
|
493
|
-
errors.push({ path: at, message: `Must have at least ${schema.minItems} items.` });
|
|
494
|
-
}
|
|
495
|
-
if (schema.maxItems !== void 0 && value.length > schema.maxItems) {
|
|
496
|
-
errors.push({ path: at, message: `Must have at most ${schema.maxItems} items.` });
|
|
497
|
-
}
|
|
498
|
-
if (schema.items) {
|
|
499
|
-
value.forEach((item, index) => {
|
|
500
|
-
errors.push(...validateJsonSchema(item, schema.items, `${path}/${index}`));
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
if (typeOf(value) === "object") {
|
|
505
|
-
const obj = value;
|
|
506
|
-
for (const key of schema.required ?? []) {
|
|
507
|
-
if (obj[key] === void 0) {
|
|
508
|
-
errors.push({ path: `${path}/${key}`, message: `Missing required property "${key}".` });
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
const properties = schema.properties ?? {};
|
|
512
|
-
for (const [key, child] of Object.entries(obj)) {
|
|
513
|
-
if (child === void 0) continue;
|
|
514
|
-
if (key in properties) {
|
|
515
|
-
errors.push(...validateJsonSchema(child, properties[key], `${path}/${key}`));
|
|
516
|
-
} else if (schema.additionalProperties === false) {
|
|
517
|
-
errors.push({ path: `${path}/${key}`, message: `Unknown property "${key}".` });
|
|
518
|
-
} else if (typeof schema.additionalProperties === "object") {
|
|
519
|
-
errors.push(...validateJsonSchema(child, schema.additionalProperties, `${path}/${key}`));
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
return errors;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
464
|
// src/agent/registry.ts
|
|
527
465
|
var ToolRegistryError = class extends Error {
|
|
528
466
|
code;
|
|
@@ -773,6 +711,7 @@ function createRichTextToolProvider(target, options) {
|
|
|
773
711
|
const editor = () => toEditor(target);
|
|
774
712
|
const getText = {
|
|
775
713
|
name: "get_text",
|
|
714
|
+
title: "Get document text",
|
|
776
715
|
description: "Returns the document content (plain text by default, or HTML / markdown) and the current selection.",
|
|
777
716
|
inputSchema: {
|
|
778
717
|
type: "object",
|
|
@@ -785,7 +724,13 @@ function createRichTextToolProvider(target, options) {
|
|
|
785
724
|
},
|
|
786
725
|
additionalProperties: false
|
|
787
726
|
},
|
|
788
|
-
annotations: {
|
|
727
|
+
annotations: {
|
|
728
|
+
title: "Get document text",
|
|
729
|
+
readOnlyHint: true,
|
|
730
|
+
destructiveHint: false,
|
|
731
|
+
idempotentHint: true,
|
|
732
|
+
openWorldHint: false
|
|
733
|
+
},
|
|
789
734
|
handler: ({ format = "text" }) => {
|
|
790
735
|
const ed = editor();
|
|
791
736
|
const content = format === "html" ? ed.getHTML() : format === "markdown" ? getEditorMarkdown(ed) : getEditorText(ed);
|
|
@@ -794,6 +739,7 @@ function createRichTextToolProvider(target, options) {
|
|
|
794
739
|
};
|
|
795
740
|
const insertText = {
|
|
796
741
|
name: "insert_text",
|
|
742
|
+
title: "Insert text",
|
|
797
743
|
description: "Inserts literal text (newlines start new paragraphs) at a document position, or at the cursor when `at` is omitted.",
|
|
798
744
|
inputSchema: {
|
|
799
745
|
type: "object",
|
|
@@ -804,6 +750,13 @@ function createRichTextToolProvider(target, options) {
|
|
|
804
750
|
required: ["text"],
|
|
805
751
|
additionalProperties: false
|
|
806
752
|
},
|
|
753
|
+
annotations: {
|
|
754
|
+
title: "Insert text",
|
|
755
|
+
readOnlyHint: false,
|
|
756
|
+
destructiveHint: false,
|
|
757
|
+
idempotentHint: false,
|
|
758
|
+
openWorldHint: false
|
|
759
|
+
},
|
|
807
760
|
handler: ({ text, at }) => {
|
|
808
761
|
const ed = editor();
|
|
809
762
|
const size = ed.state.doc.content.size;
|
|
@@ -817,6 +770,7 @@ function createRichTextToolProvider(target, options) {
|
|
|
817
770
|
};
|
|
818
771
|
const replaceSelection = {
|
|
819
772
|
name: "replace_selection",
|
|
773
|
+
title: "Replace selection",
|
|
820
774
|
description: "Replaces the selected content with literal text (an empty string deletes the selection).",
|
|
821
775
|
inputSchema: {
|
|
822
776
|
type: "object",
|
|
@@ -824,7 +778,13 @@ function createRichTextToolProvider(target, options) {
|
|
|
824
778
|
required: ["text"],
|
|
825
779
|
additionalProperties: false
|
|
826
780
|
},
|
|
827
|
-
annotations: {
|
|
781
|
+
annotations: {
|
|
782
|
+
title: "Replace selection",
|
|
783
|
+
readOnlyHint: false,
|
|
784
|
+
destructiveHint: true,
|
|
785
|
+
idempotentHint: false,
|
|
786
|
+
openWorldHint: false
|
|
787
|
+
},
|
|
828
788
|
handler: ({ text }) => {
|
|
829
789
|
const ed = editor();
|
|
830
790
|
const { from, to } = ed.state.selection;
|
|
@@ -865,6 +825,7 @@ function createSpreadsheetToolProvider(controller, options) {
|
|
|
865
825
|
};
|
|
866
826
|
const getRange = {
|
|
867
827
|
name: "get_range",
|
|
828
|
+
title: "Read cells",
|
|
868
829
|
description: 'Reads a cell range in A1 notation (e.g. "A1:C5" or "B2") and returns computed values, raw input and errors.',
|
|
869
830
|
inputSchema: {
|
|
870
831
|
type: "object",
|
|
@@ -874,7 +835,13 @@ function createSpreadsheetToolProvider(controller, options) {
|
|
|
874
835
|
required: ["range"],
|
|
875
836
|
additionalProperties: false
|
|
876
837
|
},
|
|
877
|
-
annotations: {
|
|
838
|
+
annotations: {
|
|
839
|
+
title: "Read cells",
|
|
840
|
+
readOnlyHint: true,
|
|
841
|
+
destructiveHint: false,
|
|
842
|
+
idempotentHint: true,
|
|
843
|
+
openWorldHint: false
|
|
844
|
+
},
|
|
878
845
|
handler: ({ range }) => {
|
|
879
846
|
const [startRef, endRef = startRef] = String(range).split(":");
|
|
880
847
|
const start = parseCell(startRef);
|
|
@@ -913,6 +880,7 @@ function createSpreadsheetToolProvider(controller, options) {
|
|
|
913
880
|
};
|
|
914
881
|
const setCell = {
|
|
915
882
|
name: "set_cell",
|
|
883
|
+
title: "Set a cell",
|
|
916
884
|
description: 'Sets the raw input of one cell (A1 notation). Values starting with "=" are formulas.',
|
|
917
885
|
inputSchema: {
|
|
918
886
|
type: "object",
|
|
@@ -923,6 +891,13 @@ function createSpreadsheetToolProvider(controller, options) {
|
|
|
923
891
|
required: ["cell", "value"],
|
|
924
892
|
additionalProperties: false
|
|
925
893
|
},
|
|
894
|
+
annotations: {
|
|
895
|
+
title: "Set a cell",
|
|
896
|
+
readOnlyHint: false,
|
|
897
|
+
destructiveHint: true,
|
|
898
|
+
idempotentHint: true,
|
|
899
|
+
openWorldHint: false
|
|
900
|
+
},
|
|
926
901
|
handler: ({ cell, value }) => {
|
|
927
902
|
const { row, col } = parseCell(cell);
|
|
928
903
|
const found = lookup(row, col);
|