@pixerate/editor 0.53.0 → 0.55.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.
Files changed (129) hide show
  1. package/dist/agent/index.cjs +20 -12
  2. package/dist/agent/index.cjs.map +1 -1
  3. package/dist/agent/index.d.cts +4 -3
  4. package/dist/agent/index.d.ts +4 -3
  5. package/dist/agent/index.js +18 -10
  6. package/dist/agent/index.js.map +1 -1
  7. package/dist/animation/index.cjs +16 -2
  8. package/dist/animation/index.cjs.map +1 -1
  9. package/dist/animation/index.d.cts +4 -226
  10. package/dist/animation/index.d.ts +4 -226
  11. package/dist/animation/index.js +15 -1
  12. package/dist/animation-editor/index.cjs +2221 -0
  13. package/dist/animation-editor/index.cjs.map +1 -0
  14. package/dist/animation-editor/index.d.cts +1117 -0
  15. package/dist/animation-editor/index.d.ts +1117 -0
  16. package/dist/animation-editor/index.js +2221 -0
  17. package/dist/animation-editor/index.js.map +1 -0
  18. package/dist/bezier-BfwIbVTl.d.cts +548 -0
  19. package/dist/bezier-DYBvLgUH.d.ts +548 -0
  20. package/dist/bridge/cli.cjs +36 -0
  21. package/dist/bridge/cli.cjs.map +1 -0
  22. package/dist/bridge/cli.d.cts +1 -0
  23. package/dist/bridge/cli.d.ts +1 -0
  24. package/dist/bridge/cli.js +36 -0
  25. package/dist/bridge/cli.js.map +1 -0
  26. package/dist/bridge/index.cjs +16 -0
  27. package/dist/bridge/index.cjs.map +1 -0
  28. package/dist/bridge/index.d.cts +65 -0
  29. package/dist/bridge/index.d.ts +65 -0
  30. package/dist/bridge/index.js +16 -0
  31. package/dist/bridge/index.js.map +1 -0
  32. package/dist/bridge-client-C5OziCRK.d.cts +148 -0
  33. package/dist/bridge-client-C5dRjrz5.d.ts +148 -0
  34. package/dist/canvas/index.cjs +1564 -557
  35. package/dist/canvas/index.cjs.map +1 -1
  36. package/dist/canvas/index.d.cts +411 -7
  37. package/dist/canvas/index.d.ts +411 -7
  38. package/dist/canvas/index.js +1559 -552
  39. package/dist/canvas/index.js.map +1 -1
  40. package/dist/chart/index.cjs +34 -76
  41. package/dist/chart/index.cjs.map +1 -1
  42. package/dist/chart/index.d.cts +9 -38
  43. package/dist/chart/index.d.ts +9 -38
  44. package/dist/chart/index.js +23 -65
  45. package/dist/chart/index.js.map +1 -1
  46. package/dist/chunk-AWKPSOSX.js +401 -0
  47. package/dist/chunk-AWKPSOSX.js.map +1 -0
  48. package/dist/chunk-B6DSIEXA.js +96 -0
  49. package/dist/chunk-B6DSIEXA.js.map +1 -0
  50. package/dist/chunk-EGFUVXKK.cjs +96 -0
  51. package/dist/chunk-EGFUVXKK.cjs.map +1 -0
  52. package/dist/{chunk-AMWXSYCI.js → chunk-GPWNYQ7R.js} +2 -370
  53. package/dist/chunk-GPWNYQ7R.js.map +1 -0
  54. package/dist/{chunk-TO22LX34.js → chunk-GTMJ4Y3S.js} +2208 -2920
  55. package/dist/chunk-GTMJ4Y3S.js.map +1 -0
  56. package/dist/chunk-H5K77C7Y.cjs +3848 -0
  57. package/dist/chunk-H5K77C7Y.cjs.map +1 -0
  58. package/dist/chunk-K73CKYUM.cjs +458 -0
  59. package/dist/chunk-K73CKYUM.cjs.map +1 -0
  60. package/dist/chunk-MLREO6J3.cjs +737 -0
  61. package/dist/chunk-MLREO6J3.cjs.map +1 -0
  62. package/dist/chunk-NONDTTH7.js +5979 -0
  63. package/dist/chunk-NONDTTH7.js.map +1 -0
  64. package/dist/chunk-NV22EMOZ.cjs +401 -0
  65. package/dist/chunk-NV22EMOZ.cjs.map +1 -0
  66. package/dist/{chunk-YNSK4MGT.cjs → chunk-O2UH7LZE.cjs} +1549 -2261
  67. package/dist/chunk-O2UH7LZE.cjs.map +1 -0
  68. package/dist/chunk-PTMIGXZ2.js +467 -0
  69. package/dist/chunk-PTMIGXZ2.js.map +1 -0
  70. package/dist/chunk-QIWFEEWG.cjs +467 -0
  71. package/dist/chunk-QIWFEEWG.cjs.map +1 -0
  72. package/dist/chunk-VWZB6BCY.js +737 -0
  73. package/dist/chunk-VWZB6BCY.js.map +1 -0
  74. package/dist/chunk-WWJNC7SX.js +3848 -0
  75. package/dist/chunk-WWJNC7SX.js.map +1 -0
  76. package/dist/chunk-XCXQDPID.cjs +5979 -0
  77. package/dist/chunk-XCXQDPID.cjs.map +1 -0
  78. package/dist/color-E9pwm--w.d.cts +33 -0
  79. package/dist/color-E9pwm--w.d.ts +33 -0
  80. package/dist/commands/index.cjs +2 -2
  81. package/dist/commands/index.cjs.map +1 -1
  82. package/dist/commands/index.d.cts +1 -1
  83. package/dist/commands/index.d.ts +1 -1
  84. package/dist/commands/index.js +3 -3
  85. package/dist/diagram/index.cjs +1167 -0
  86. package/dist/diagram/index.cjs.map +1 -0
  87. package/dist/diagram/index.d.cts +810 -0
  88. package/dist/diagram/index.d.ts +810 -0
  89. package/dist/diagram/index.js +1167 -0
  90. package/dist/diagram/index.js.map +1 -0
  91. package/dist/{easing-DTmX99QG.d.cts → easing-CNGk-W6d.d.cts} +1 -1
  92. package/dist/{easing-DTmX99QG.d.ts → easing-CNGk-W6d.d.ts} +1 -1
  93. package/dist/generation/index.d.cts +2 -2
  94. package/dist/generation/index.d.ts +2 -2
  95. package/dist/image-editor/index.d.cts +1 -1
  96. package/dist/image-editor/index.d.ts +1 -1
  97. package/dist/parameters/index.d.cts +1 -1
  98. package/dist/parameters/index.d.ts +1 -1
  99. package/dist/pathfinder-BZL8aSu0.d.cts +469 -0
  100. package/dist/pathfinder-CNtsbCRK.d.ts +469 -0
  101. package/dist/player-Dg0FT0UI.d.cts +193 -0
  102. package/dist/player-W-5DX3Go.d.ts +193 -0
  103. package/dist/presence-Cb6WhcrQ.d.cts +77 -0
  104. package/dist/presence-Cb6WhcrQ.d.ts +77 -0
  105. package/dist/{registry-CSlH4iUn.d.ts → registry-7AZFuand.d.ts} +1 -1
  106. package/dist/{registry-B4l-lYts.d.cts → registry-DIpIaCkH.d.cts} +1 -1
  107. package/dist/svg-CLg2zqZA.d.cts +847 -0
  108. package/dist/svg-CPK82TtU.d.ts +847 -0
  109. package/dist/tools/index.cjs +10 -2
  110. package/dist/tools/index.cjs.map +1 -1
  111. package/dist/tools/index.d.cts +3 -74
  112. package/dist/tools/index.d.ts +3 -74
  113. package/dist/tools/index.js +12 -4
  114. package/dist/types-BULrFyuQ.d.cts +316 -0
  115. package/dist/types-BULrFyuQ.d.ts +316 -0
  116. package/dist/vector/index.cjs +1328 -6752
  117. package/dist/vector/index.cjs.map +1 -1
  118. package/dist/vector/index.d.cts +7 -847
  119. package/dist/vector/index.d.ts +7 -847
  120. package/dist/vector/index.js +645 -6069
  121. package/dist/vector/index.js.map +1 -1
  122. package/package.json +19 -1
  123. package/dist/chunk-AMWXSYCI.js.map +0 -1
  124. package/dist/chunk-TO22LX34.js.map +0 -1
  125. package/dist/chunk-XFYUFVAX.cjs +0 -826
  126. package/dist/chunk-XFYUFVAX.cjs.map +0 -1
  127. package/dist/chunk-YNSK4MGT.cjs.map +0 -1
  128. package/dist/pathfinder-B9xh_pCZ.d.ts +0 -1013
  129. package/dist/pathfinder-QdG70sr9.d.cts +0 -1013
@@ -0,0 +1,65 @@
1
+ import { M as McpServer } from '../bridge-client-C5OziCRK.cjs';
2
+ export { T as TOOL_BRIDGE_DEFAULT_PORT, a as TOOL_BRIDGE_PROTOCOL } from '../bridge-client-C5OziCRK.cjs';
3
+ import { T as ToolRegistry } from '../registry-DIpIaCkH.cjs';
4
+ import '../schema-Di0CS6Pe.cjs';
5
+
6
+ interface ToolBridgeOptions {
7
+ /** The MCP server's name. */
8
+ name: string;
9
+ version?: string;
10
+ /** Said to the model in the MCP `initialize` result, before the bridge's own usage notes. */
11
+ instructions?: string;
12
+ /** WebSocket port editors connect to (default 4477; 0 picks a free one). */
13
+ port?: number;
14
+ /** Shared secret pages must send as `?token=`. Recommended: any local page can otherwise connect. */
15
+ token?: string;
16
+ /** Browser origins allowed besides localhost ones (e.g. "https://app.example.com"). */
17
+ origins?: readonly string[];
18
+ /** How long a page has to answer a call (ms, default 60 000). */
19
+ timeoutMs?: number;
20
+ /**
21
+ * While another process holds the port, how often to try again (ms, default 2000; 0 never).
22
+ * Until it gets the port, tools say why.
23
+ */
24
+ retryMs?: number;
25
+ /**
26
+ * Where MCP messages come from and go to. Default: stdio (one JSON message per line on
27
+ * stdin / stdout). `false` serves no transport; call `bridge.mcp.handle` yourself.
28
+ */
29
+ stdio?: {
30
+ input: NodeJS.ReadableStream;
31
+ output: NodeJS.WritableStream;
32
+ } | false;
33
+ /** Diagnostics (default: stderr, since stdout carries MCP). */
34
+ log?: (message: string) => void;
35
+ }
36
+ /** An editor as `list_editors` reports it. */
37
+ interface ToolBridgeEditorInfo {
38
+ id: string;
39
+ name: string;
40
+ kind?: string;
41
+ tools: number;
42
+ /** Seconds since the editor last connected or answered a call. */
43
+ idleSeconds: number;
44
+ }
45
+ interface ToolBridge {
46
+ /** The WebSocket port editors connect to. */
47
+ readonly port: number;
48
+ /** The MCP server (handle messages yourself when `stdio` is false). */
49
+ readonly mcp: McpServer;
50
+ /** The registry the MCP server serves: `list_editors` plus every tool the pages expose. */
51
+ readonly registry: ToolRegistry;
52
+ /** The connected editors. */
53
+ editors(): ToolBridgeEditorInfo[];
54
+ /** Stops listening, disconnects editors, fails pending calls and closes MCP. */
55
+ close(): Promise<void>;
56
+ }
57
+ /** Whether a browser origin is this machine (localhost, 127.0.0.1, [::1], *.localhost). */
58
+ declare function isLocalOrigin(origin: string): boolean;
59
+ /**
60
+ * Starts a bridge: listens for editors on 127.0.0.1 and serves their tools, plus
61
+ * `list_editors`, over MCP. Resolves once the port is bound (or known to be taken).
62
+ */
63
+ declare function createToolBridge(options: ToolBridgeOptions): Promise<ToolBridge>;
64
+
65
+ export { type ToolBridge, type ToolBridgeEditorInfo, type ToolBridgeOptions, createToolBridge, isLocalOrigin };
@@ -0,0 +1,65 @@
1
+ import { M as McpServer } from '../bridge-client-C5dRjrz5.js';
2
+ export { T as TOOL_BRIDGE_DEFAULT_PORT, a as TOOL_BRIDGE_PROTOCOL } from '../bridge-client-C5dRjrz5.js';
3
+ import { T as ToolRegistry } from '../registry-7AZFuand.js';
4
+ import '../schema-Di0CS6Pe.js';
5
+
6
+ interface ToolBridgeOptions {
7
+ /** The MCP server's name. */
8
+ name: string;
9
+ version?: string;
10
+ /** Said to the model in the MCP `initialize` result, before the bridge's own usage notes. */
11
+ instructions?: string;
12
+ /** WebSocket port editors connect to (default 4477; 0 picks a free one). */
13
+ port?: number;
14
+ /** Shared secret pages must send as `?token=`. Recommended: any local page can otherwise connect. */
15
+ token?: string;
16
+ /** Browser origins allowed besides localhost ones (e.g. "https://app.example.com"). */
17
+ origins?: readonly string[];
18
+ /** How long a page has to answer a call (ms, default 60 000). */
19
+ timeoutMs?: number;
20
+ /**
21
+ * While another process holds the port, how often to try again (ms, default 2000; 0 never).
22
+ * Until it gets the port, tools say why.
23
+ */
24
+ retryMs?: number;
25
+ /**
26
+ * Where MCP messages come from and go to. Default: stdio (one JSON message per line on
27
+ * stdin / stdout). `false` serves no transport; call `bridge.mcp.handle` yourself.
28
+ */
29
+ stdio?: {
30
+ input: NodeJS.ReadableStream;
31
+ output: NodeJS.WritableStream;
32
+ } | false;
33
+ /** Diagnostics (default: stderr, since stdout carries MCP). */
34
+ log?: (message: string) => void;
35
+ }
36
+ /** An editor as `list_editors` reports it. */
37
+ interface ToolBridgeEditorInfo {
38
+ id: string;
39
+ name: string;
40
+ kind?: string;
41
+ tools: number;
42
+ /** Seconds since the editor last connected or answered a call. */
43
+ idleSeconds: number;
44
+ }
45
+ interface ToolBridge {
46
+ /** The WebSocket port editors connect to. */
47
+ readonly port: number;
48
+ /** The MCP server (handle messages yourself when `stdio` is false). */
49
+ readonly mcp: McpServer;
50
+ /** The registry the MCP server serves: `list_editors` plus every tool the pages expose. */
51
+ readonly registry: ToolRegistry;
52
+ /** The connected editors. */
53
+ editors(): ToolBridgeEditorInfo[];
54
+ /** Stops listening, disconnects editors, fails pending calls and closes MCP. */
55
+ close(): Promise<void>;
56
+ }
57
+ /** Whether a browser origin is this machine (localhost, 127.0.0.1, [::1], *.localhost). */
58
+ declare function isLocalOrigin(origin: string): boolean;
59
+ /**
60
+ * Starts a bridge: listens for editors on 127.0.0.1 and serves their tools, plus
61
+ * `list_editors`, over MCP. Resolves once the port is bound (or known to be taken).
62
+ */
63
+ declare function createToolBridge(options: ToolBridgeOptions): Promise<ToolBridge>;
64
+
65
+ export { type ToolBridge, type ToolBridgeEditorInfo, type ToolBridgeOptions, createToolBridge, isLocalOrigin };
@@ -0,0 +1,16 @@
1
+ import {
2
+ createToolBridge,
3
+ isLocalOrigin
4
+ } from "../chunk-AWKPSOSX.js";
5
+ import {
6
+ TOOL_BRIDGE_DEFAULT_PORT,
7
+ TOOL_BRIDGE_PROTOCOL
8
+ } from "../chunk-PTMIGXZ2.js";
9
+ import "../chunk-4FX5ACVG.js";
10
+ export {
11
+ TOOL_BRIDGE_DEFAULT_PORT,
12
+ TOOL_BRIDGE_PROTOCOL,
13
+ createToolBridge,
14
+ isLocalOrigin
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,148 @@
1
+ import { T as ToolRegistry, M as McpToolDefinition, a as McpToolResult } from './registry-DIpIaCkH.cjs';
2
+
3
+ /** MCP protocol revisions this server speaks, newest first. */
4
+ declare const MCP_PROTOCOL_VERSIONS: readonly ["2025-06-18", "2025-03-26", "2024-11-05"];
5
+ type JsonRpcId = string | number;
6
+ interface JsonRpcRequest {
7
+ jsonrpc: '2.0';
8
+ id?: JsonRpcId | null;
9
+ method: string;
10
+ params?: Record<string, any>;
11
+ }
12
+ interface JsonRpcResponse {
13
+ jsonrpc: '2.0';
14
+ id: JsonRpcId | null;
15
+ result?: unknown;
16
+ error?: {
17
+ code: number;
18
+ message: string;
19
+ data?: unknown;
20
+ };
21
+ }
22
+ interface JsonRpcNotification {
23
+ jsonrpc: '2.0';
24
+ method: string;
25
+ params?: Record<string, unknown>;
26
+ }
27
+ /** Standard JSON-RPC error codes used by the server. */
28
+ declare const JSON_RPC_ERRORS: {
29
+ readonly parseError: -32700;
30
+ readonly invalidRequest: -32600;
31
+ readonly methodNotFound: -32601;
32
+ readonly invalidParams: -32602;
33
+ readonly internalError: -32603;
34
+ };
35
+ interface McpServerOptions {
36
+ /** `serverInfo` sent in the `initialize` result. */
37
+ name: string;
38
+ version: string;
39
+ title?: string;
40
+ /** Usage hints for the client's model, sent in the `initialize` result. */
41
+ instructions?: string;
42
+ /**
43
+ * Sends server → client messages (`notifications/tools/list_changed`).
44
+ * Without it the server still answers requests but announces nothing.
45
+ */
46
+ send?: (message: JsonRpcNotification) => void;
47
+ }
48
+ interface McpServer {
49
+ /**
50
+ * Handles one client message (a JSON string or a parsed object) and
51
+ * resolves to the response to send back, or `null` for notifications.
52
+ * Never rejects.
53
+ */
54
+ handle(message: string | JsonRpcRequest): Promise<JsonRpcResponse | null>;
55
+ /** Whether the client has completed the `initialize` handshake. */
56
+ readonly initialized: boolean;
57
+ /** Stops list-changed notifications and aborts running tool calls. */
58
+ close(): void;
59
+ }
60
+ /**
61
+ * A transport-agnostic MCP server for a {@link ToolRegistry}: wire `handle`
62
+ * to any transport (stdio lines, a WebSocket, `postMessage`, an HTTP POST
63
+ * handler) and pass `send` for server → client notifications.
64
+ *
65
+ * Supports `initialize` (with protocol version negotiation), `ping`,
66
+ * `tools/list`, `tools/call` and `notifications/cancelled` (aborts the
67
+ * call's `signal`), and announces `notifications/tools/list_changed` after
68
+ * the client sends `notifications/initialized`. An unknown tool is a
69
+ * JSON-RPC `-32602` error, as the MCP spec asks; invalid arguments and
70
+ * handler failures are `isError` tool results the model can read and fix.
71
+ */
72
+ declare function createMcpServer(registry: ToolRegistry, options: McpServerOptions): McpServer;
73
+
74
+ /** Protocol version spoken between `connectToolBridge` and `createToolBridge`. */
75
+ declare const TOOL_BRIDGE_PROTOCOL = 1;
76
+ /** Default port the bridge listens on (127.0.0.1 only). */
77
+ declare const TOOL_BRIDGE_DEFAULT_PORT = 4477;
78
+ /** Editor → bridge messages. */
79
+ type ToolBridgeEditorMessage = {
80
+ t: 'hello';
81
+ v: number;
82
+ name: string;
83
+ kind?: string;
84
+ tools: McpToolDefinition[];
85
+ } | {
86
+ t: 'tools';
87
+ tools: McpToolDefinition[];
88
+ } | {
89
+ t: 'result';
90
+ id: string;
91
+ result: McpToolResult;
92
+ };
93
+ /** Bridge → editor messages. */
94
+ type ToolBridgeServerMessage = {
95
+ t: 'welcome';
96
+ v: number;
97
+ id: string;
98
+ } | {
99
+ t: 'call';
100
+ id: string;
101
+ name: string;
102
+ arguments: Record<string, unknown>;
103
+ } | {
104
+ t: 'cancel';
105
+ id: string;
106
+ reason?: string;
107
+ };
108
+ type ToolBridgeStatus = 'connecting' | 'connected' | 'disconnected' | 'closed';
109
+ /** The parts of a WebSocket the client uses (the browser's, Node's global one, or `ws`). */
110
+ interface ToolBridgeSocket {
111
+ readonly readyState: number;
112
+ send(data: string): void;
113
+ close(code?: number, reason?: string): void;
114
+ addEventListener(type: 'open' | 'close' | 'error' | 'message', listener: (event: any) => void): void;
115
+ }
116
+ interface ConnectToolBridgeOptions {
117
+ /** Bridge URL (default `ws://127.0.0.1:4477`). */
118
+ url?: string;
119
+ /** The bridge's token, if it was started with one (sent as `?token=`). */
120
+ token?: string;
121
+ /** How this editor is listed to the agent (`list_editors`), e.g. "Diagram — Order flow". */
122
+ name: string;
123
+ /** What kind of editor this is ("diagram", "chart", "document"…), shown in `list_editors`. */
124
+ kind?: string;
125
+ /** Reconnect after the bridge goes away (default true), backing off up to 10 s. */
126
+ reconnect?: boolean;
127
+ /** WebSocket constructor (default: the global one). */
128
+ WebSocket?: new (url: string) => ToolBridgeSocket;
129
+ /** Called when the connection state changes. */
130
+ onStatus?: (status: ToolBridgeStatus, detail?: string) => void;
131
+ }
132
+ interface ToolBridgeConnection {
133
+ readonly status: ToolBridgeStatus;
134
+ /** The id the bridge gave this editor (`list_editors`), once connected. */
135
+ readonly editorId: string | null;
136
+ /** Disconnects and stops reconnecting; running calls are aborted. */
137
+ close(): void;
138
+ }
139
+ /**
140
+ * Connects a `ToolRegistry` to a local MCP bridge (`createToolBridge` /
141
+ * `pixerate-mcp-bridge`), so an MCP client (Claude Desktop, Claude Code, an IDE) can call
142
+ * the page's tools: the registry's tool list is sent on connect and whenever it changes,
143
+ * calls run through `registry.callTool` with an `AbortSignal` the bridge cancels, and the
144
+ * connection comes back after the bridge restarts.
145
+ */
146
+ declare function connectToolBridge(registry: ToolRegistry, options: ConnectToolBridgeOptions): ToolBridgeConnection;
147
+
148
+ export { type ConnectToolBridgeOptions as C, JSON_RPC_ERRORS as J, type McpServer as M, TOOL_BRIDGE_DEFAULT_PORT as T, TOOL_BRIDGE_PROTOCOL as a, type JsonRpcId as b, type JsonRpcNotification as c, type JsonRpcRequest as d, type JsonRpcResponse as e, MCP_PROTOCOL_VERSIONS as f, type McpServerOptions as g, type ToolBridgeConnection as h, type ToolBridgeEditorMessage as i, type ToolBridgeServerMessage as j, type ToolBridgeSocket as k, type ToolBridgeStatus as l, connectToolBridge as m, createMcpServer as n };
@@ -0,0 +1,148 @@
1
+ import { T as ToolRegistry, M as McpToolDefinition, a as McpToolResult } from './registry-7AZFuand.js';
2
+
3
+ /** MCP protocol revisions this server speaks, newest first. */
4
+ declare const MCP_PROTOCOL_VERSIONS: readonly ["2025-06-18", "2025-03-26", "2024-11-05"];
5
+ type JsonRpcId = string | number;
6
+ interface JsonRpcRequest {
7
+ jsonrpc: '2.0';
8
+ id?: JsonRpcId | null;
9
+ method: string;
10
+ params?: Record<string, any>;
11
+ }
12
+ interface JsonRpcResponse {
13
+ jsonrpc: '2.0';
14
+ id: JsonRpcId | null;
15
+ result?: unknown;
16
+ error?: {
17
+ code: number;
18
+ message: string;
19
+ data?: unknown;
20
+ };
21
+ }
22
+ interface JsonRpcNotification {
23
+ jsonrpc: '2.0';
24
+ method: string;
25
+ params?: Record<string, unknown>;
26
+ }
27
+ /** Standard JSON-RPC error codes used by the server. */
28
+ declare const JSON_RPC_ERRORS: {
29
+ readonly parseError: -32700;
30
+ readonly invalidRequest: -32600;
31
+ readonly methodNotFound: -32601;
32
+ readonly invalidParams: -32602;
33
+ readonly internalError: -32603;
34
+ };
35
+ interface McpServerOptions {
36
+ /** `serverInfo` sent in the `initialize` result. */
37
+ name: string;
38
+ version: string;
39
+ title?: string;
40
+ /** Usage hints for the client's model, sent in the `initialize` result. */
41
+ instructions?: string;
42
+ /**
43
+ * Sends server → client messages (`notifications/tools/list_changed`).
44
+ * Without it the server still answers requests but announces nothing.
45
+ */
46
+ send?: (message: JsonRpcNotification) => void;
47
+ }
48
+ interface McpServer {
49
+ /**
50
+ * Handles one client message (a JSON string or a parsed object) and
51
+ * resolves to the response to send back, or `null` for notifications.
52
+ * Never rejects.
53
+ */
54
+ handle(message: string | JsonRpcRequest): Promise<JsonRpcResponse | null>;
55
+ /** Whether the client has completed the `initialize` handshake. */
56
+ readonly initialized: boolean;
57
+ /** Stops list-changed notifications and aborts running tool calls. */
58
+ close(): void;
59
+ }
60
+ /**
61
+ * A transport-agnostic MCP server for a {@link ToolRegistry}: wire `handle`
62
+ * to any transport (stdio lines, a WebSocket, `postMessage`, an HTTP POST
63
+ * handler) and pass `send` for server → client notifications.
64
+ *
65
+ * Supports `initialize` (with protocol version negotiation), `ping`,
66
+ * `tools/list`, `tools/call` and `notifications/cancelled` (aborts the
67
+ * call's `signal`), and announces `notifications/tools/list_changed` after
68
+ * the client sends `notifications/initialized`. An unknown tool is a
69
+ * JSON-RPC `-32602` error, as the MCP spec asks; invalid arguments and
70
+ * handler failures are `isError` tool results the model can read and fix.
71
+ */
72
+ declare function createMcpServer(registry: ToolRegistry, options: McpServerOptions): McpServer;
73
+
74
+ /** Protocol version spoken between `connectToolBridge` and `createToolBridge`. */
75
+ declare const TOOL_BRIDGE_PROTOCOL = 1;
76
+ /** Default port the bridge listens on (127.0.0.1 only). */
77
+ declare const TOOL_BRIDGE_DEFAULT_PORT = 4477;
78
+ /** Editor → bridge messages. */
79
+ type ToolBridgeEditorMessage = {
80
+ t: 'hello';
81
+ v: number;
82
+ name: string;
83
+ kind?: string;
84
+ tools: McpToolDefinition[];
85
+ } | {
86
+ t: 'tools';
87
+ tools: McpToolDefinition[];
88
+ } | {
89
+ t: 'result';
90
+ id: string;
91
+ result: McpToolResult;
92
+ };
93
+ /** Bridge → editor messages. */
94
+ type ToolBridgeServerMessage = {
95
+ t: 'welcome';
96
+ v: number;
97
+ id: string;
98
+ } | {
99
+ t: 'call';
100
+ id: string;
101
+ name: string;
102
+ arguments: Record<string, unknown>;
103
+ } | {
104
+ t: 'cancel';
105
+ id: string;
106
+ reason?: string;
107
+ };
108
+ type ToolBridgeStatus = 'connecting' | 'connected' | 'disconnected' | 'closed';
109
+ /** The parts of a WebSocket the client uses (the browser's, Node's global one, or `ws`). */
110
+ interface ToolBridgeSocket {
111
+ readonly readyState: number;
112
+ send(data: string): void;
113
+ close(code?: number, reason?: string): void;
114
+ addEventListener(type: 'open' | 'close' | 'error' | 'message', listener: (event: any) => void): void;
115
+ }
116
+ interface ConnectToolBridgeOptions {
117
+ /** Bridge URL (default `ws://127.0.0.1:4477`). */
118
+ url?: string;
119
+ /** The bridge's token, if it was started with one (sent as `?token=`). */
120
+ token?: string;
121
+ /** How this editor is listed to the agent (`list_editors`), e.g. "Diagram — Order flow". */
122
+ name: string;
123
+ /** What kind of editor this is ("diagram", "chart", "document"…), shown in `list_editors`. */
124
+ kind?: string;
125
+ /** Reconnect after the bridge goes away (default true), backing off up to 10 s. */
126
+ reconnect?: boolean;
127
+ /** WebSocket constructor (default: the global one). */
128
+ WebSocket?: new (url: string) => ToolBridgeSocket;
129
+ /** Called when the connection state changes. */
130
+ onStatus?: (status: ToolBridgeStatus, detail?: string) => void;
131
+ }
132
+ interface ToolBridgeConnection {
133
+ readonly status: ToolBridgeStatus;
134
+ /** The id the bridge gave this editor (`list_editors`), once connected. */
135
+ readonly editorId: string | null;
136
+ /** Disconnects and stops reconnecting; running calls are aborted. */
137
+ close(): void;
138
+ }
139
+ /**
140
+ * Connects a `ToolRegistry` to a local MCP bridge (`createToolBridge` /
141
+ * `pixerate-mcp-bridge`), so an MCP client (Claude Desktop, Claude Code, an IDE) can call
142
+ * the page's tools: the registry's tool list is sent on connect and whenever it changes,
143
+ * calls run through `registry.callTool` with an `AbortSignal` the bridge cancels, and the
144
+ * connection comes back after the bridge restarts.
145
+ */
146
+ declare function connectToolBridge(registry: ToolRegistry, options: ConnectToolBridgeOptions): ToolBridgeConnection;
147
+
148
+ export { type ConnectToolBridgeOptions as C, JSON_RPC_ERRORS as J, type McpServer as M, TOOL_BRIDGE_DEFAULT_PORT as T, TOOL_BRIDGE_PROTOCOL as a, type JsonRpcId as b, type JsonRpcNotification as c, type JsonRpcRequest as d, type JsonRpcResponse as e, MCP_PROTOCOL_VERSIONS as f, type McpServerOptions as g, type ToolBridgeConnection as h, type ToolBridgeEditorMessage as i, type ToolBridgeServerMessage as j, type ToolBridgeSocket as k, type ToolBridgeStatus as l, connectToolBridge as m, createMcpServer as n };