@datalayer/reactor-excalidraw 0.0.0 → 1.3.11

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/lib/scene.js ADDED
@@ -0,0 +1,168 @@
1
+ /*
2
+ * Copyright (c) 2026-Present Datalayer, Inc.
3
+ *
4
+ * BSD 3-Clause License
5
+ */
6
+ /** An empty drawing. */
7
+ export const emptyScene = () => ({
8
+ elements: [],
9
+ appState: {},
10
+ files: {},
11
+ });
12
+ /**
13
+ * Read a drawing's stored string.
14
+ *
15
+ * Tolerant on purpose: a drawing that cannot be parsed reads as an empty one
16
+ * rather than throwing, because the alternative is a tool call that fails on
17
+ * a document the editor itself opens quite happily.
18
+ */
19
+ export function parseScene(data) {
20
+ if (!data) {
21
+ return emptyScene();
22
+ }
23
+ let parsed;
24
+ try {
25
+ parsed = JSON.parse(data);
26
+ }
27
+ catch {
28
+ return emptyScene();
29
+ }
30
+ // The legacy shape: the elements array on its own.
31
+ if (Array.isArray(parsed)) {
32
+ return {
33
+ elements: parsed,
34
+ appState: {},
35
+ files: {},
36
+ };
37
+ }
38
+ if (!parsed || typeof parsed !== 'object') {
39
+ return emptyScene();
40
+ }
41
+ const scene = parsed;
42
+ return {
43
+ elements: Array.isArray(scene.elements) ? scene.elements : [],
44
+ appState: scene.appState ?? {},
45
+ files: scene.files ?? {},
46
+ };
47
+ }
48
+ /** Write a scene back to the string a host stores. */
49
+ export function serializeScene(scene) {
50
+ return JSON.stringify({
51
+ elements: scene.elements,
52
+ appState: scene.appState,
53
+ files: scene.files,
54
+ });
55
+ }
56
+ /** The elements that are actually on the canvas. */
57
+ export const liveElements = (scene) => scene.elements.filter(element => !element?.isDeleted);
58
+ /** Reduce one element to its summary. */
59
+ export function summarizeElement(element) {
60
+ const summary = {
61
+ id: String(element?.id ?? ''),
62
+ type: String(element?.type ?? 'unknown'),
63
+ x: Number(element?.x ?? 0),
64
+ y: Number(element?.y ?? 0),
65
+ width: Number(element?.width ?? 0),
66
+ height: Number(element?.height ?? 0),
67
+ };
68
+ if (typeof element?.text === 'string' && element.text.length > 0) {
69
+ summary.text = element.text;
70
+ }
71
+ if (element?.strokeColor) {
72
+ summary.strokeColor = String(element.strokeColor);
73
+ }
74
+ if (element?.backgroundColor) {
75
+ summary.backgroundColor = String(element.backgroundColor);
76
+ }
77
+ if (element?.containerId) {
78
+ summary.containerId = String(element.containerId);
79
+ }
80
+ if (element?.startBinding?.elementId) {
81
+ summary.startBoundElementId = String(element.startBinding.elementId);
82
+ }
83
+ if (element?.endBinding?.elementId) {
84
+ summary.endBoundElementId = String(element.endBinding.elementId);
85
+ }
86
+ if (Array.isArray(element?.groupIds) && element.groupIds.length > 0) {
87
+ summary.groupIds = element.groupIds.map(String);
88
+ }
89
+ return summary;
90
+ }
91
+ /**
92
+ * The text a container shows, gathered from the element bound inside it.
93
+ *
94
+ * Excalidraw does not put a label on the shape; it makes a separate text
95
+ * element whose `containerId` points back. Reading a rectangle on its own
96
+ * therefore says nothing about what the rectangle is called, which is
97
+ * usually the only thing worth knowing about it.
98
+ */
99
+ export function withBoundText(elements) {
100
+ const textByContainer = new Map();
101
+ for (const element of elements) {
102
+ if (element?.type === 'text' && element?.containerId && element?.text) {
103
+ textByContainer.set(String(element.containerId), String(element.text));
104
+ }
105
+ }
106
+ return elements.map(element => {
107
+ const summary = summarizeElement(element);
108
+ if (summary.text === undefined) {
109
+ const bound = textByContainer.get(summary.id);
110
+ if (bound) {
111
+ summary.text = bound;
112
+ }
113
+ }
114
+ return summary;
115
+ });
116
+ }
117
+ /**
118
+ * A one-line description of a drawing, for a listing.
119
+ *
120
+ * What is in it and what it says — "3 rectangles, 2 arrows: Start, Finish" —
121
+ * which is enough to pick the right drawing out of a document holding
122
+ * several.
123
+ */
124
+ export function describeScene(scene) {
125
+ const elements = liveElements(scene);
126
+ if (elements.length === 0) {
127
+ return 'empty drawing';
128
+ }
129
+ const counts = new Map();
130
+ const labels = [];
131
+ for (const element of elements) {
132
+ const type = String(element?.type ?? 'unknown');
133
+ if (type === 'text') {
134
+ const text = String(element?.text ?? '').trim();
135
+ if (text) {
136
+ labels.push(text);
137
+ }
138
+ // Bound text is the container's label, not a shape of its own.
139
+ if (element?.containerId) {
140
+ continue;
141
+ }
142
+ }
143
+ counts.set(type, (counts.get(type) ?? 0) + 1);
144
+ }
145
+ const shapes = [...counts.entries()]
146
+ .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
147
+ .map(([type, count]) => `${count} ${type}${count > 1 ? 's' : ''}`)
148
+ .join(', ');
149
+ const said = labels.slice(0, 3).join(', ');
150
+ return said ? `${shapes}: ${said}` : shapes;
151
+ }
152
+ /**
153
+ * Stamp an element as changed.
154
+ *
155
+ * Excalidraw reconciles concurrent edits by comparing `version` and, when
156
+ * those tie, `versionNonce`. An element written back with its old version is
157
+ * an element a collaborating client is entitled to discard, so every
158
+ * mutation goes through here.
159
+ */
160
+ export function touchElement(element) {
161
+ return {
162
+ ...element,
163
+ version: Number(element?.version ?? 1) + 1,
164
+ versionNonce: Math.floor(Math.random() * 2 ** 31),
165
+ updated: Date.now(),
166
+ };
167
+ }
168
+ //# sourceMappingURL=scene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene.js","sourceRoot":"","sources":["../src/scene.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmCH,wBAAwB;AACxB,MAAM,CAAC,MAAM,UAAU,GAAG,GAAoB,EAAE,CAAC,CAAC;IAChD,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,KAAK,EAAE,EAAE;CACV,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAA+B;IACxD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC;IACD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;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C,IAAI,CAAC,CAAC;IAC3C,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAC9C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,OAA8B;IAE9B,OAAO;QACL,GAAG,OAAO;QACV,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC;QAC1C,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;QACjD,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;KACpB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,230 @@
1
+ /**
2
+ * What each Excalidraw tool takes.
3
+ *
4
+ * The element shape here is Excalidraw's own "skeleton" — the reduced form
5
+ * `convertToExcalidrawElements` accepts, where a rectangle is `{type, x, y,
6
+ * width, height}` rather than the thirty-field record the scene stores. That
7
+ * is deliberate: the skeleton is the only part of the drawing format that is
8
+ * meant to be written by hand, and everything it leaves out (seeds, version
9
+ * nonces, fractional indices, binding geometry) is exactly what a model
10
+ * should not be inventing.
11
+ *
12
+ * @module schemas
13
+ */
14
+ import { z } from 'zod';
15
+ /**
16
+ * A shape, as written rather than as stored.
17
+ *
18
+ * Kept deliberately close to Excalidraw's skeleton type: the fields a
19
+ * diagram actually needs, with everything derived left to the converter.
20
+ */
21
+ export declare const elementSkeletonSchema: z.ZodObject<{
22
+ type: z.ZodEnum<{
23
+ rectangle: "rectangle";
24
+ ellipse: "ellipse";
25
+ diamond: "diamond";
26
+ text: "text";
27
+ arrow: "arrow";
28
+ line: "line";
29
+ frame: "frame";
30
+ }>;
31
+ x: z.ZodNumber;
32
+ y: z.ZodNumber;
33
+ width: z.ZodOptional<z.ZodNumber>;
34
+ height: z.ZodOptional<z.ZodNumber>;
35
+ id: z.ZodOptional<z.ZodString>;
36
+ text: z.ZodOptional<z.ZodString>;
37
+ label: z.ZodOptional<z.ZodString>;
38
+ fontSize: z.ZodOptional<z.ZodNumber>;
39
+ strokeColor: z.ZodOptional<z.ZodString>;
40
+ backgroundColor: z.ZodOptional<z.ZodString>;
41
+ fillStyle: z.ZodOptional<z.ZodEnum<{
42
+ hachure: "hachure";
43
+ "cross-hatch": "cross-hatch";
44
+ solid: "solid";
45
+ }>>;
46
+ strokeWidth: z.ZodOptional<z.ZodNumber>;
47
+ strokeStyle: z.ZodOptional<z.ZodEnum<{
48
+ solid: "solid";
49
+ dashed: "dashed";
50
+ dotted: "dotted";
51
+ }>>;
52
+ roughness: z.ZodOptional<z.ZodNumber>;
53
+ opacity: z.ZodOptional<z.ZodNumber>;
54
+ angle: z.ZodOptional<z.ZodNumber>;
55
+ startId: z.ZodOptional<z.ZodString>;
56
+ endId: z.ZodOptional<z.ZodString>;
57
+ points: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodNumber>>>;
58
+ children: z.ZodOptional<z.ZodArray<z.ZodString>>;
59
+ name: z.ZodOptional<z.ZodString>;
60
+ }, z.core.$strip>;
61
+ export type ElementSkeleton = z.infer<typeof elementSkeletonSchema>;
62
+ export declare const excalidrawInsertNodeParamsSchema: z.ZodObject<{
63
+ afterId: z.ZodString;
64
+ elements: z.ZodOptional<z.ZodArray<z.ZodObject<{
65
+ type: z.ZodEnum<{
66
+ rectangle: "rectangle";
67
+ ellipse: "ellipse";
68
+ diamond: "diamond";
69
+ text: "text";
70
+ arrow: "arrow";
71
+ line: "line";
72
+ frame: "frame";
73
+ }>;
74
+ x: z.ZodNumber;
75
+ y: z.ZodNumber;
76
+ width: z.ZodOptional<z.ZodNumber>;
77
+ height: z.ZodOptional<z.ZodNumber>;
78
+ id: z.ZodOptional<z.ZodString>;
79
+ text: z.ZodOptional<z.ZodString>;
80
+ label: z.ZodOptional<z.ZodString>;
81
+ fontSize: z.ZodOptional<z.ZodNumber>;
82
+ strokeColor: z.ZodOptional<z.ZodString>;
83
+ backgroundColor: z.ZodOptional<z.ZodString>;
84
+ fillStyle: z.ZodOptional<z.ZodEnum<{
85
+ hachure: "hachure";
86
+ "cross-hatch": "cross-hatch";
87
+ solid: "solid";
88
+ }>>;
89
+ strokeWidth: z.ZodOptional<z.ZodNumber>;
90
+ strokeStyle: z.ZodOptional<z.ZodEnum<{
91
+ solid: "solid";
92
+ dashed: "dashed";
93
+ dotted: "dotted";
94
+ }>>;
95
+ roughness: z.ZodOptional<z.ZodNumber>;
96
+ opacity: z.ZodOptional<z.ZodNumber>;
97
+ angle: z.ZodOptional<z.ZodNumber>;
98
+ startId: z.ZodOptional<z.ZodString>;
99
+ endId: z.ZodOptional<z.ZodString>;
100
+ points: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodNumber>>>;
101
+ children: z.ZodOptional<z.ZodArray<z.ZodString>>;
102
+ name: z.ZodOptional<z.ZodString>;
103
+ }, z.core.$strip>>>;
104
+ width: z.ZodOptional<z.ZodNumber>;
105
+ height: z.ZodOptional<z.ZodNumber>;
106
+ }, z.core.$strip>;
107
+ export declare const excalidrawListDrawingsParamsSchema: z.ZodObject<{}, z.core.$strip>;
108
+ export declare const excalidrawReadSceneParamsSchema: z.ZodObject<{
109
+ blockId: z.ZodString;
110
+ detail: z.ZodOptional<z.ZodEnum<{
111
+ summary: "summary";
112
+ full: "full";
113
+ }>>;
114
+ }, z.core.$strip>;
115
+ export declare const excalidrawAddElementsParamsSchema: z.ZodObject<{
116
+ blockId: z.ZodString;
117
+ elements: z.ZodArray<z.ZodObject<{
118
+ type: z.ZodEnum<{
119
+ rectangle: "rectangle";
120
+ ellipse: "ellipse";
121
+ diamond: "diamond";
122
+ text: "text";
123
+ arrow: "arrow";
124
+ line: "line";
125
+ frame: "frame";
126
+ }>;
127
+ x: z.ZodNumber;
128
+ y: z.ZodNumber;
129
+ width: z.ZodOptional<z.ZodNumber>;
130
+ height: z.ZodOptional<z.ZodNumber>;
131
+ id: z.ZodOptional<z.ZodString>;
132
+ text: z.ZodOptional<z.ZodString>;
133
+ label: z.ZodOptional<z.ZodString>;
134
+ fontSize: z.ZodOptional<z.ZodNumber>;
135
+ strokeColor: z.ZodOptional<z.ZodString>;
136
+ backgroundColor: z.ZodOptional<z.ZodString>;
137
+ fillStyle: z.ZodOptional<z.ZodEnum<{
138
+ hachure: "hachure";
139
+ "cross-hatch": "cross-hatch";
140
+ solid: "solid";
141
+ }>>;
142
+ strokeWidth: z.ZodOptional<z.ZodNumber>;
143
+ strokeStyle: z.ZodOptional<z.ZodEnum<{
144
+ solid: "solid";
145
+ dashed: "dashed";
146
+ dotted: "dotted";
147
+ }>>;
148
+ roughness: z.ZodOptional<z.ZodNumber>;
149
+ opacity: z.ZodOptional<z.ZodNumber>;
150
+ angle: z.ZodOptional<z.ZodNumber>;
151
+ startId: z.ZodOptional<z.ZodString>;
152
+ endId: z.ZodOptional<z.ZodString>;
153
+ points: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodNumber>>>;
154
+ children: z.ZodOptional<z.ZodArray<z.ZodString>>;
155
+ name: z.ZodOptional<z.ZodString>;
156
+ }, z.core.$strip>>;
157
+ }, z.core.$strip>;
158
+ export declare const excalidrawUpdateElementsParamsSchema: z.ZodObject<{
159
+ blockId: z.ZodString;
160
+ updates: z.ZodArray<z.ZodObject<{
161
+ id: z.ZodString;
162
+ x: z.ZodOptional<z.ZodNumber>;
163
+ y: z.ZodOptional<z.ZodNumber>;
164
+ width: z.ZodOptional<z.ZodNumber>;
165
+ height: z.ZodOptional<z.ZodNumber>;
166
+ text: z.ZodOptional<z.ZodString>;
167
+ strokeColor: z.ZodOptional<z.ZodString>;
168
+ backgroundColor: z.ZodOptional<z.ZodString>;
169
+ fillStyle: z.ZodOptional<z.ZodEnum<{
170
+ hachure: "hachure";
171
+ "cross-hatch": "cross-hatch";
172
+ solid: "solid";
173
+ }>>;
174
+ strokeWidth: z.ZodOptional<z.ZodNumber>;
175
+ strokeStyle: z.ZodOptional<z.ZodEnum<{
176
+ solid: "solid";
177
+ dashed: "dashed";
178
+ dotted: "dotted";
179
+ }>>;
180
+ opacity: z.ZodOptional<z.ZodNumber>;
181
+ angle: z.ZodOptional<z.ZodNumber>;
182
+ }, z.core.$strip>>;
183
+ }, z.core.$strip>;
184
+ export declare const excalidrawDeleteElementsParamsSchema: z.ZodObject<{
185
+ blockId: z.ZodString;
186
+ elementIds: z.ZodArray<z.ZodString>;
187
+ }, z.core.$strip>;
188
+ export declare const excalidrawConnectElementsParamsSchema: z.ZodObject<{
189
+ blockId: z.ZodString;
190
+ fromId: z.ZodString;
191
+ toId: z.ZodString;
192
+ label: z.ZodOptional<z.ZodString>;
193
+ strokeColor: z.ZodOptional<z.ZodString>;
194
+ strokeStyle: z.ZodOptional<z.ZodEnum<{
195
+ solid: "solid";
196
+ dashed: "dashed";
197
+ dotted: "dotted";
198
+ }>>;
199
+ }, z.core.$strip>;
200
+ export declare const excalidrawSetAppStateParamsSchema: z.ZodObject<{
201
+ blockId: z.ZodString;
202
+ viewBackgroundColor: z.ZodOptional<z.ZodString>;
203
+ gridSize: z.ZodOptional<z.ZodNumber>;
204
+ }, z.core.$strip>;
205
+ export declare const excalidrawResizeParamsSchema: z.ZodObject<{
206
+ blockId: z.ZodString;
207
+ width: z.ZodOptional<z.ZodNumber>;
208
+ height: z.ZodOptional<z.ZodNumber>;
209
+ }, z.core.$strip>;
210
+ export declare const excalidrawClearSceneParamsSchema: z.ZodObject<{
211
+ blockId: z.ZodString;
212
+ }, z.core.$strip>;
213
+ export declare const excalidrawFromMermaidParamsSchema: z.ZodObject<{
214
+ blockId: z.ZodOptional<z.ZodString>;
215
+ afterId: z.ZodOptional<z.ZodString>;
216
+ mermaid: z.ZodString;
217
+ fontSize: z.ZodOptional<z.ZodNumber>;
218
+ }, z.core.$strip>;
219
+ export type ExcalidrawInsertNodeParams = z.infer<typeof excalidrawInsertNodeParamsSchema>;
220
+ export type ExcalidrawListDrawingsParams = z.infer<typeof excalidrawListDrawingsParamsSchema>;
221
+ export type ExcalidrawReadSceneParams = z.infer<typeof excalidrawReadSceneParamsSchema>;
222
+ export type ExcalidrawAddElementsParams = z.infer<typeof excalidrawAddElementsParamsSchema>;
223
+ export type ExcalidrawUpdateElementsParams = z.infer<typeof excalidrawUpdateElementsParamsSchema>;
224
+ export type ExcalidrawDeleteElementsParams = z.infer<typeof excalidrawDeleteElementsParamsSchema>;
225
+ export type ExcalidrawConnectElementsParams = z.infer<typeof excalidrawConnectElementsParamsSchema>;
226
+ export type ExcalidrawSetAppStateParams = z.infer<typeof excalidrawSetAppStateParamsSchema>;
227
+ export type ExcalidrawResizeParams = z.infer<typeof excalidrawResizeParamsSchema>;
228
+ export type ExcalidrawClearSceneParams = z.infer<typeof excalidrawClearSceneParamsSchema>;
229
+ export type ExcalidrawFromMermaidParams = z.infer<typeof excalidrawFromMermaidParamsSchema>;
230
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiEhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAqBpE,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgB3C,CAAC;AAEH,eAAO,MAAM,kCAAkC,gCAAe,CAAC;AAE/D,eAAO,MAAM,+BAA+B;;;;;;iBAQ1C,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK5C,CAAC;AAEH,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;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0,0 +1,209 @@
1
+ /*
2
+ * Copyright (c) 2026-Present Datalayer, Inc.
3
+ *
4
+ * BSD 3-Clause License
5
+ */
6
+ /**
7
+ * What each Excalidraw tool takes.
8
+ *
9
+ * The element shape here is Excalidraw's own "skeleton" — the reduced form
10
+ * `convertToExcalidrawElements` accepts, where a rectangle is `{type, x, y,
11
+ * width, height}` rather than the thirty-field record the scene stores. That
12
+ * is deliberate: the skeleton is the only part of the drawing format that is
13
+ * meant to be written by hand, and everything it leaves out (seeds, version
14
+ * nonces, fractional indices, binding geometry) is exactly what a model
15
+ * should not be inventing.
16
+ *
17
+ * @module schemas
18
+ */
19
+ import { z } from 'zod';
20
+ /** Colours, arrowheads and so on are Excalidraw's own vocabulary. */
21
+ const colorSchema = z
22
+ .string()
23
+ .describe("CSS colour, e.g. '#1e1e1e', '#e03131', 'transparent'");
24
+ /**
25
+ * A shape, as written rather than as stored.
26
+ *
27
+ * Kept deliberately close to Excalidraw's skeleton type: the fields a
28
+ * diagram actually needs, with everything derived left to the converter.
29
+ */
30
+ export const elementSkeletonSchema = z.object({
31
+ type: z
32
+ .enum(['rectangle', 'ellipse', 'diamond', 'text', 'arrow', 'line', 'frame'])
33
+ .describe('What to draw'),
34
+ x: z.number().describe('Left edge, in scene coordinates'),
35
+ y: z.number().describe('Top edge, in scene coordinates'),
36
+ width: z.number().optional().describe('Width in pixels (shapes only)'),
37
+ height: z.number().optional().describe('Height in pixels (shapes only)'),
38
+ id: z
39
+ .string()
40
+ .optional()
41
+ .describe('Your own id for this element, so a later arrow can point at it by name. Any string; Excalidraw keeps it.'),
42
+ text: z.string().optional().describe("The text itself, for type 'text'"),
43
+ label: z
44
+ .string()
45
+ .optional()
46
+ .describe('Text to put inside the shape. Excalidraw binds it to the shape, so moving the shape moves the label.'),
47
+ fontSize: z
48
+ .number()
49
+ .optional()
50
+ .describe('Font size in pixels, e.g. 16, 20, 28'),
51
+ strokeColor: colorSchema.optional().describe('Outline colour'),
52
+ backgroundColor: colorSchema.optional().describe('Fill colour'),
53
+ fillStyle: z
54
+ .enum(['hachure', 'cross-hatch', 'solid'])
55
+ .optional()
56
+ .describe('How the fill is drawn'),
57
+ strokeWidth: z.number().optional().describe('Outline thickness, 1 | 2 | 4'),
58
+ strokeStyle: z
59
+ .enum(['solid', 'dashed', 'dotted'])
60
+ .optional()
61
+ .describe('Outline style'),
62
+ roughness: z
63
+ .number()
64
+ .optional()
65
+ .describe('0 for architect (clean), 1 for artist, 2 for cartoonist'),
66
+ opacity: z.number().optional().describe('0-100'),
67
+ angle: z.number().optional().describe('Rotation in radians'),
68
+ startId: z
69
+ .string()
70
+ .optional()
71
+ .describe("For 'arrow' and 'line': the id of the element the arrow starts at. The arrow stays attached when either element moves."),
72
+ endId: z
73
+ .string()
74
+ .optional()
75
+ .describe("For 'arrow' and 'line': the id of the element the arrow points at."),
76
+ points: z
77
+ .array(z.array(z.number()))
78
+ .optional()
79
+ .describe("For 'arrow' and 'line' without bindings: points relative to x,y, e.g. [[0,0],[120,0]]"),
80
+ children: z
81
+ .array(z.string())
82
+ .optional()
83
+ .describe("For 'frame': the ids of the elements it contains"),
84
+ name: z.string().optional().describe("For 'frame': its name"),
85
+ });
86
+ /**
87
+ * Where a new drawing goes. In a document, the vocabulary `insertBlock` uses;
88
+ * a host with one place for drawings ignores it.
89
+ */
90
+ const afterIdSchema = z
91
+ .string()
92
+ .describe("Where to put the drawing: 'TOP' for the beginning of the document, 'BOTTOM' for the end, or the block_id to insert after");
93
+ /**
94
+ * Which drawing a call is about. Named `blockId` because a drawing in a
95
+ * document is a block; a host that keeps drawings elsewhere hands out its own
96
+ * ids under the same name.
97
+ */
98
+ const blockIdSchema = z
99
+ .string()
100
+ .describe('The id of the drawing, from excalidrawListDrawings');
101
+ export const excalidrawInsertNodeParamsSchema = z.object({
102
+ afterId: afterIdSchema,
103
+ elements: z
104
+ .array(elementSkeletonSchema)
105
+ .optional()
106
+ .describe('The drawing itself. Omit to insert an empty canvas for a person to draw on.'),
107
+ width: z
108
+ .number()
109
+ .optional()
110
+ .describe('Rendered width in pixels. Omit to size to the content.'),
111
+ height: z
112
+ .number()
113
+ .optional()
114
+ .describe('Rendered height in pixels. Omit to size to the content.'),
115
+ });
116
+ export const excalidrawListDrawingsParamsSchema = z.object({});
117
+ export const excalidrawReadSceneParamsSchema = z.object({
118
+ blockId: blockIdSchema,
119
+ detail: z
120
+ .enum(['summary', 'full'])
121
+ .optional()
122
+ .describe("'summary' (default) gives each element's id, type, position, size and text — enough to change it. 'full' gives the raw Excalidraw elements, which is large; ask for it only when you need a field the summary omits."),
123
+ });
124
+ export const excalidrawAddElementsParamsSchema = z.object({
125
+ blockId: blockIdSchema,
126
+ elements: z
127
+ .array(elementSkeletonSchema)
128
+ .describe('The elements to add. Existing elements are left alone.'),
129
+ });
130
+ export const excalidrawUpdateElementsParamsSchema = z.object({
131
+ blockId: blockIdSchema,
132
+ updates: z
133
+ .array(z.object({
134
+ id: z.string().describe('The element id, from excalidrawReadScene'),
135
+ x: z.number().optional(),
136
+ y: z.number().optional(),
137
+ width: z.number().optional(),
138
+ height: z.number().optional(),
139
+ text: z
140
+ .string()
141
+ .optional()
142
+ .describe("New text. On a shape this rewrites the label bound inside it; on a 'text' element it rewrites the element."),
143
+ strokeColor: colorSchema.optional(),
144
+ backgroundColor: colorSchema.optional(),
145
+ fillStyle: z.enum(['hachure', 'cross-hatch', 'solid']).optional(),
146
+ strokeWidth: z.number().optional(),
147
+ strokeStyle: z.enum(['solid', 'dashed', 'dotted']).optional(),
148
+ opacity: z.number().optional().describe('0-100'),
149
+ angle: z.number().optional().describe('Rotation in radians'),
150
+ }))
151
+ .describe('One entry per element to change. Fields left out are kept.'),
152
+ });
153
+ export const excalidrawDeleteElementsParamsSchema = z.object({
154
+ blockId: blockIdSchema,
155
+ elementIds: z
156
+ .array(z.string())
157
+ .describe('The ids to remove, from excalidrawReadScene'),
158
+ });
159
+ export const excalidrawConnectElementsParamsSchema = z.object({
160
+ blockId: blockIdSchema,
161
+ fromId: z.string().describe('The element the arrow starts at'),
162
+ toId: z.string().describe('The element the arrow points at'),
163
+ label: z
164
+ .string()
165
+ .optional()
166
+ .describe('Text to sit on the arrow, e.g. "yes", "then"'),
167
+ strokeColor: colorSchema.optional(),
168
+ strokeStyle: z.enum(['solid', 'dashed', 'dotted']).optional(),
169
+ });
170
+ export const excalidrawSetAppStateParamsSchema = z.object({
171
+ blockId: blockIdSchema,
172
+ viewBackgroundColor: colorSchema
173
+ .optional()
174
+ .describe('The canvas colour behind the drawing'),
175
+ gridSize: z
176
+ .number()
177
+ .optional()
178
+ .describe('Grid spacing in pixels. 0 turns the grid off.'),
179
+ });
180
+ export const excalidrawResizeParamsSchema = z.object({
181
+ blockId: blockIdSchema,
182
+ width: z
183
+ .number()
184
+ .optional()
185
+ .describe('Rendered width in pixels. Omit to go back to sizing by content.'),
186
+ height: z
187
+ .number()
188
+ .optional()
189
+ .describe('Rendered height in pixels. Omit to go back to sizing by content.'),
190
+ });
191
+ export const excalidrawClearSceneParamsSchema = z.object({
192
+ blockId: blockIdSchema,
193
+ });
194
+ export const excalidrawFromMermaidParamsSchema = z.object({
195
+ blockId: blockIdSchema
196
+ .optional()
197
+ .describe('The drawing to replace. Omit to insert a new drawing instead, positioned by afterId.'),
198
+ afterId: afterIdSchema
199
+ .optional()
200
+ .describe("Where a new drawing goes: 'TOP', 'BOTTOM', or a block_id. Ignored when blockId is given."),
201
+ mermaid: z
202
+ .string()
203
+ .describe('Mermaid source. Flowcharts, sequence diagrams and class diagrams convert to real shapes; anything else comes across as an image.'),
204
+ fontSize: z
205
+ .number()
206
+ .optional()
207
+ .describe('Font size for the generated text, in pixels'),
208
+ });
209
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAA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,iCAAiC,GAAG,CAAC,CAAC,MAAM,CAAC;IACxD,OAAO,EAAE,aAAa;SACnB,QAAQ,EAAE;SACV,QAAQ,CACP,sFAAsF,CACvF;IACH,OAAO,EAAE,aAAa;SACnB,QAAQ,EAAE;SACV,QAAQ,CACP,0FAA0F,CAC3F;IACH,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,CACP,kIAAkI,CACnI;IACH,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,6CAA6C,CAAC;CAC3D,CAAC,CAAC"}
package/lib/tools.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ import type { ToolDefinition, ToolExecutor, ToolOperation } from '@datalayer/reactor/tools';
2
+ import type { ExcalidrawToolHandler } from './handlers';
3
+ /** The plugin's short name: the tools bundle's id and the commands' namespace. */
4
+ export declare const EXCALIDRAW_TOOLS_NAME = "excalidraw";
5
+ /** What a host registers with an agent: what exists, and what runs it. */
6
+ export declare const excalidrawTools: {
7
+ name: string;
8
+ definitions: ToolDefinition[];
9
+ operations: Record<string, ToolOperation<unknown, unknown>>;
10
+ };
11
+ /** The reactor command a tool's operation runs as: `excalidraw.excalidrawReadScene`. */
12
+ export declare const excalidrawCommandOf: (operation: string) => string;
13
+ /**
14
+ * The executor the operations hand their validated calls to, over a set of
15
+ * handlers. Refuses an operation it has no handler for.
16
+ */
17
+ export declare function createExcalidrawExecutor(handlers: Record<string, ExcalidrawToolHandler>): ToolExecutor;
18
+ /**
19
+ * The tools as a reactor `AgentTools` bundle: each tool is the plugin's
20
+ * command of its operation, with the tool's name, description and
21
+ * parameters.
22
+ */
23
+ export declare const EXCALIDRAW_AGENT_TOOLS: import("@datalayer/reactor").AgentToolBundle;
24
+ /**
25
+ * The operation names the three halves disagree about, if any.
26
+ *
27
+ * A definition without an operation is a tool the model can call and nothing
28
+ * answers; an operation without a handler is a call that reaches the executor
29
+ * and finds nothing to run. Neither shows up until an agent tries it, which
30
+ * is far too late — so this is checked in the tests, where it is cheap.
31
+ */
32
+ export declare function excalidrawToolMismatches(handlers: Record<string, ExcalidrawToolHandler>): string[];
33
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGxD,kFAAkF;AAClF,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,0EAA0E;AAC1E,eAAO,MAAM,eAAe,EAAE;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;CAK7D,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,GAAI,WAAW,MAAM,KAAG,MACf,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAC9C,YAAY,CAUd;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,8CAYjC,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAC9C,MAAM,EAAE,CAuBV"}