@widgetic/canvas 0.5.39 → 0.5.41

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 (134) hide show
  1. package/README.md +7 -3
  2. package/dist/canvas/DomCanvas.svelte +7 -3
  3. package/dist/canvas/DomCanvas.svelte.d.ts +8 -0
  4. package/dist/canvas/autosaveScheduler.js +89 -37
  5. package/dist/canvas/boardFrame.js +1 -1
  6. package/dist/canvas/boardSurface.js +1 -1
  7. package/dist/canvas/canvasLogger.js +19 -7
  8. package/dist/canvas/chromeLayout.d.ts +2 -0
  9. package/dist/canvas/chromeLayout.js +31 -17
  10. package/dist/canvas/eventScope.js +14 -10
  11. package/dist/canvas/host/CanvasHost.d.ts +6 -0
  12. package/dist/canvas/host/CanvasHost.js +1556 -1255
  13. package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
  14. package/dist/canvas/host/CanvasHostApi.js +25 -4
  15. package/dist/canvas/host/browserServices.js +116 -65
  16. package/dist/canvas/host/conversion.js +170 -82
  17. package/dist/canvas/host/hostObject.js +7 -7
  18. package/dist/canvas/host/pageEvents.js +4 -4
  19. package/dist/canvas/host/screenRects.js +31 -28
  20. package/dist/canvas/host/strokeSnap.js +143 -88
  21. package/dist/canvas/openMarks.js +2 -2
  22. package/dist/canvas/outsideClickDeselect.js +7 -6
  23. package/dist/canvas/panZoomPosition.js +2 -2
  24. package/dist/canvas/preferredTextFont.js +25 -13
  25. package/dist/canvas/shapes/ShapeLibrary.js +148 -138
  26. package/dist/canvas/shapes/shapeImageStore.js +3 -3
  27. package/dist/canvas/shapes/strokeShapeSnap.js +233 -188
  28. package/dist/canvas/toolbarPosition.js +2 -2
  29. package/dist/canvas/ui/CanvasContextMenu.svelte +69 -39
  30. package/dist/canvas/ui/CanvasHint.svelte +17 -4
  31. package/dist/canvas/ui/CanvasHint.svelte.d.ts +2 -17
  32. package/dist/canvas/ui/CanvasToolbar.svelte +27 -10
  33. package/dist/canvas/ui/ColorField.svelte +1 -1
  34. package/dist/canvas/ui/SelectionPanel.svelte +24 -20
  35. package/dist/canvas/ui/ShapesMenu.svelte +0 -2
  36. package/dist/canvas/ui/ToolButton.svelte +11 -3
  37. package/dist/canvas/ui/ToolButton.svelte.d.ts +2 -0
  38. package/dist/canvas/ui/WidgetActions.svelte +1 -1
  39. package/dist/canvas/ui/ZoomControl.svelte +39 -4
  40. package/dist/canvas/ui/ZoomControl.svelte.d.ts +2 -2
  41. package/dist/canvas/ui/colorModel.js +32 -21
  42. package/dist/canvas/ui/colorPickerMessages.js +5 -5
  43. package/dist/canvas/ui/floatingCard.d.ts +7 -5
  44. package/dist/canvas/ui/floatingCard.js +23 -21
  45. package/dist/canvas/ui/floatingLayer.js +6 -5
  46. package/dist/canvas/ui/keyHints.d.ts +5 -0
  47. package/dist/canvas/ui/keyHints.js +23 -7
  48. package/dist/canvas/ui/popoverSide.js +3 -2
  49. package/dist/canvas/ui/selectionTraits.js +40 -34
  50. package/dist/canvas/ui/sizeLabelVisibility.d.ts +5 -2
  51. package/dist/canvas/ui/sizeLabelVisibility.js +7 -6
  52. package/dist/canvas/ui/widgetSelectionPanel.d.ts +6 -0
  53. package/dist/canvas/ui/widgetSelectionPanel.js +9 -0
  54. package/dist/canvas/view/ObjectView.svelte +2 -1
  55. package/dist/canvas/view/SelectionOverlay.svelte +34 -14
  56. package/dist/canvas/view/erasingMarks.js +7 -7
  57. package/dist/canvas/view/geometry.d.ts +14 -4
  58. package/dist/canvas/view/geometry.js +103 -77
  59. package/dist/components/preferenceStorage.js +2 -2
  60. package/dist/engine/EngineCore.d.ts +4 -1
  61. package/dist/engine/EngineCore.js +801 -695
  62. package/dist/engine/codec/canvasDocument.js +173 -173
  63. package/dist/engine/codec/hostReadableKeys.js +1 -1
  64. package/dist/engine/core/arrange.js +38 -26
  65. package/dist/engine/core/arrow.d.ts +10 -3
  66. package/dist/engine/core/arrow.js +96 -75
  67. package/dist/engine/core/arrowBinding.d.ts +69 -0
  68. package/dist/engine/core/arrowBinding.js +344 -0
  69. package/dist/engine/core/arrowBindingRecords.d.ts +43 -0
  70. package/dist/engine/core/arrowBindingRecords.js +141 -0
  71. package/dist/engine/core/brush.js +94 -67
  72. package/dist/engine/core/defaults.js +51 -90
  73. package/dist/engine/core/freehand.js +163 -147
  74. package/dist/engine/core/geometry.js +54 -47
  75. package/dist/engine/core/history.js +50 -33
  76. package/dist/engine/core/hitTest.d.ts +3 -0
  77. package/dist/engine/core/hitTest.js +83 -69
  78. package/dist/engine/core/matrix.js +20 -18
  79. package/dist/engine/core/pathData.js +210 -183
  80. package/dist/engine/core/rotationReset.js +6 -5
  81. package/dist/engine/core/scene.d.ts +3 -0
  82. package/dist/engine/core/scene.js +192 -129
  83. package/dist/engine/core/scribble.js +84 -59
  84. package/dist/engine/core/shapePaths.js +15 -12
  85. package/dist/engine/core/shapeTools.js +63 -72
  86. package/dist/engine/core/snapping.js +117 -65
  87. package/dist/engine/core/style.js +64 -31
  88. package/dist/engine/core/transform.js +94 -83
  89. package/dist/engine/core/types.d.ts +29 -0
  90. package/dist/engine/core/types.js +4 -4
  91. package/dist/engine/core/viewport.js +36 -23
  92. package/dist/engine/input/PointerController.js +476 -447
  93. package/dist/engine/input/arrowHandles.js +12 -12
  94. package/dist/engine/input/gestures.d.ts +12 -1
  95. package/dist/engine/input/gestures.js +342 -251
  96. package/dist/engine/input/hoverCursor.js +1 -1
  97. package/dist/engine/input/keyboard.d.ts +9 -1
  98. package/dist/engine/input/keyboard.js +46 -27
  99. package/dist/engine/input/selectionHandles.js +50 -45
  100. package/dist/engine/input/types.js +1 -1
  101. package/dist/engine/render/rasterize.js +158 -86
  102. package/dist/engine/state.d.ts +6 -1
  103. package/dist/engine/state.js +17 -5
  104. package/dist/engine/text/layoutText.js +62 -43
  105. package/dist/engine/text/textMetrics.js +10 -8
  106. package/dist/engine/widgets.js +137 -101
  107. package/dist/fonts/interFont.js +68 -17
  108. package/dist/fonts/workspaceFonts.js +90 -32
  109. package/dist/i18n/labels.js +6 -5
  110. package/dist/i18n/language.js +4 -4
  111. package/dist/i18n/messages.d.ts +6 -6
  112. package/dist/i18n/messages.js +7 -7
  113. package/dist/i18n/shortcuts.d.ts +12 -0
  114. package/dist/i18n/shortcuts.js +32 -18
  115. package/dist/settings/workspaceToolSettings.js +48 -32
  116. package/dist/tools/components/catalog.d.ts +11 -0
  117. package/dist/tools/components/catalog.js +270 -0
  118. package/dist/tools/components/grouping.d.ts +9 -0
  119. package/dist/tools/components/grouping.js +33 -0
  120. package/dist/tools/definitions.d.ts +19 -0
  121. package/dist/tools/definitions.js +147 -0
  122. package/dist/tools/executors.d.ts +7 -0
  123. package/dist/tools/executors.js +324 -0
  124. package/dist/tools/hostAdapter.d.ts +14 -0
  125. package/dist/tools/hostAdapter.js +40 -0
  126. package/dist/tools/index.d.ts +6 -0
  127. package/dist/tools/index.js +6 -0
  128. package/dist/tools/sceneSummary.d.ts +24 -0
  129. package/dist/tools/sceneSummary.js +170 -0
  130. package/dist/tools/sketchIntent.d.ts +17 -0
  131. package/dist/tools/sketchIntent.js +166 -0
  132. package/dist/tools/types.d.ts +54 -0
  133. package/dist/tools/types.js +11 -0
  134. package/package.json +7 -2
@@ -0,0 +1,270 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import { createPathObject, createRectObject, createTextObject } from '../../engine/core/defaults.js';
11
+ import { buildArrow } from '../../engine/core/arrow.js';
12
+ import { serializePathData } from '../../engine/core/pathData.js';
13
+ import { packGroup } from './grouping.js';
14
+ function snap(value) {
15
+ return Math.round(value / 8) * 8;
16
+ }
17
+ var STROKE = '#9ca3af';
18
+ var STROKE_WIDTH = 2;
19
+ export function drawUiComponent(kind, x, y, width, height, label) {
20
+ var objects = [];
21
+ var px = snap(x);
22
+ var py = snap(y);
23
+ var w = snap(Math.max(160, width));
24
+ var h = snap(Math.max(120, height));
25
+ switch (kind) {
26
+ case 'video_player': {
27
+ var title = createTextObject({
28
+ x: px,
29
+ y: py - 28,
30
+ text: (label === null || label === void 0 ? void 0 : label.trim()) || 'Video player',
31
+ fontSize: 14,
32
+ fontWeight: 'bold',
33
+ autoWidth: true
34
+ });
35
+ var thumbW = w;
36
+ var thumbH = snap(thumbW * (9 / 16));
37
+ var frame = createRectObject({
38
+ x: px,
39
+ y: py,
40
+ width: thumbW,
41
+ height: thumbH,
42
+ roundness: 10,
43
+ stroke: STROKE,
44
+ strokeWidth: STROKE_WIDTH
45
+ });
46
+ var screen = createRectObject({
47
+ x: px + 12,
48
+ y: py + 12,
49
+ width: thumbW - 24,
50
+ height: thumbH - 24,
51
+ roundness: 8,
52
+ fill: '#f3f4f6',
53
+ stroke: 'transparent',
54
+ strokeWidth: 0
55
+ });
56
+ var screenLabel = createTextObject({
57
+ x: px + 16,
58
+ y: py + 4,
59
+ text: 'Thumbnail',
60
+ fontSize: 11,
61
+ autoWidth: true
62
+ });
63
+ var playSize = 56;
64
+ var play = createRectObject({
65
+ x: px + thumbW / 2 - playSize / 2,
66
+ y: py + thumbH / 2 - playSize / 2,
67
+ width: playSize,
68
+ height: playSize,
69
+ roundness: 100,
70
+ fill: '#e5e7eb',
71
+ stroke: '#d1d5db',
72
+ strokeWidth: 1
73
+ });
74
+ var screenGroup = packGroup([frame, screen, play, screenLabel], {});
75
+ var navBar = createRectObject({
76
+ x: px,
77
+ y: py + thumbH + 16,
78
+ width: thumbW,
79
+ height: 40,
80
+ roundness: 8,
81
+ fill: '#f9fafb',
82
+ stroke: STROKE,
83
+ strokeWidth: STROKE_WIDTH
84
+ });
85
+ var navThumbs = [];
86
+ for (var i = 0; i < 5; i++) {
87
+ navThumbs.push(createRectObject({
88
+ x: px + 16 + i * 56,
89
+ y: py + thumbH + 32,
90
+ width: 40,
91
+ height: 8,
92
+ roundness: 4,
93
+ fill: '#d1d5db',
94
+ stroke: 'transparent',
95
+ strokeWidth: 0
96
+ }));
97
+ }
98
+ var navTitle = createTextObject({
99
+ x: px,
100
+ y: py + thumbH + 4,
101
+ text: 'Navigation',
102
+ fontSize: 12,
103
+ fontWeight: 'bold',
104
+ autoWidth: true
105
+ });
106
+ var navGroup = packGroup(__spreadArray([navBar, navTitle], navThumbs, true), {});
107
+ objects.push.apply(objects, __spreadArray(__spreadArray([title], screenGroup.objects, false), navGroup.objects, false));
108
+ return {
109
+ objects: objects,
110
+ rootLabel: 'Video player',
111
+ highlightIds: [navGroup.groupId]
112
+ };
113
+ }
114
+ case 'navigation_bar': {
115
+ var bar = createRectObject({
116
+ x: px,
117
+ y: py + 20,
118
+ width: w,
119
+ height: snap(Math.min(48, h)),
120
+ roundness: 8,
121
+ stroke: STROKE,
122
+ strokeWidth: STROKE_WIDTH,
123
+ fill: '#f9fafb'
124
+ });
125
+ var title = createTextObject({
126
+ x: px,
127
+ y: py,
128
+ text: (label === null || label === void 0 ? void 0 : label.trim()) || 'Navigation bar',
129
+ fontSize: 12,
130
+ fontWeight: 'bold',
131
+ autoWidth: true
132
+ });
133
+ var tabs = [];
134
+ for (var i = 0; i < 4; i++) {
135
+ tabs.push(createTextObject({
136
+ x: px + 16 + i * 96,
137
+ y: py + 36,
138
+ text: "Nav ".concat(i + 1),
139
+ fontSize: 14,
140
+ autoWidth: true
141
+ }));
142
+ }
143
+ var packed = packGroup(__spreadArray([bar], tabs, true), {});
144
+ objects.push.apply(objects, __spreadArray([title], packed.objects, false));
145
+ return { objects: objects, rootLabel: (label === null || label === void 0 ? void 0 : label.trim()) || 'Navigation bar' };
146
+ }
147
+ case 'button': {
148
+ var btnH = snap(Math.max(44, Math.min(48, h)));
149
+ var btnW = snap(Math.max(128, w));
150
+ var btn = createRectObject({
151
+ x: px,
152
+ y: py + 22,
153
+ width: btnW,
154
+ height: btnH,
155
+ roundness: 8,
156
+ fill: '#f9fafb',
157
+ stroke: STROKE,
158
+ strokeWidth: STROKE_WIDTH
159
+ });
160
+ var caption = createTextObject({
161
+ x: px + 16,
162
+ y: py + 34,
163
+ text: label !== null && label !== void 0 ? label : 'Button',
164
+ fontSize: 15,
165
+ autoWidth: true
166
+ });
167
+ var title = createTextObject({
168
+ x: px,
169
+ y: py,
170
+ text: 'Button',
171
+ fontSize: 11,
172
+ color: '#6b7280',
173
+ autoWidth: true
174
+ });
175
+ var packed = packGroup([btn, caption], {});
176
+ objects.push.apply(objects, __spreadArray([title], packed.objects, false));
177
+ return { objects: objects, rootLabel: label !== null && label !== void 0 ? label : 'Button' };
178
+ }
179
+ case 'card': {
180
+ var cardH = snap(Math.max(160, h));
181
+ var card = createRectObject({
182
+ x: px,
183
+ y: py + 24,
184
+ width: w,
185
+ height: cardH,
186
+ roundness: 12,
187
+ stroke: STROKE,
188
+ strokeWidth: STROKE_WIDTH,
189
+ fill: '#ffffff'
190
+ });
191
+ var heading = createTextObject({
192
+ x: px + 16,
193
+ y: py + 40,
194
+ text: label !== null && label !== void 0 ? label : 'Card title',
195
+ fontSize: 18,
196
+ fontWeight: 'bold',
197
+ autoWidth: true
198
+ });
199
+ var body = createRectObject({
200
+ x: px + 16,
201
+ y: py + 72,
202
+ width: w - 32,
203
+ height: Math.max(48, cardH - 96),
204
+ roundness: 6,
205
+ fill: '#f3f4f6',
206
+ stroke: 'transparent',
207
+ strokeWidth: 0
208
+ });
209
+ var title = createTextObject({ x: px, y: py, text: 'Card', fontSize: 11, color: '#6b7280', autoWidth: true });
210
+ var packed = packGroup([card, heading, body], {});
211
+ objects.push.apply(objects, __spreadArray([title], packed.objects, false));
212
+ return { objects: objects, rootLabel: label !== null && label !== void 0 ? label : 'Card' };
213
+ }
214
+ case 'form': {
215
+ var title = createTextObject({ x: px, y: py, text: label !== null && label !== void 0 ? label : 'Form', fontSize: 12, fontWeight: 'bold', autoWidth: true });
216
+ var fields = [];
217
+ for (var i = 0; i < 3; i++) {
218
+ fields.push(createRectObject({
219
+ x: px,
220
+ y: py + 32 + i * 48,
221
+ width: w,
222
+ height: 36,
223
+ roundness: 6,
224
+ stroke: STROKE,
225
+ strokeWidth: 1,
226
+ fill: '#fff'
227
+ }));
228
+ }
229
+ var packed = packGroup(fields, {});
230
+ objects.push.apply(objects, __spreadArray([title], packed.objects, false));
231
+ return { objects: objects, rootLabel: label !== null && label !== void 0 ? label : 'Form' };
232
+ }
233
+ default: {
234
+ var box = createRectObject({
235
+ x: px,
236
+ y: py + 20,
237
+ width: w,
238
+ height: h,
239
+ roundness: 8,
240
+ stroke: STROKE,
241
+ strokeWidth: STROKE_WIDTH
242
+ });
243
+ var title = createTextObject({
244
+ x: px,
245
+ y: py,
246
+ text: label !== null && label !== void 0 ? label : kind.replace(/_/g, ' '),
247
+ fontSize: 14,
248
+ autoWidth: true
249
+ });
250
+ objects.push(title, box);
251
+ return { objects: objects, rootLabel: label !== null && label !== void 0 ? label : kind };
252
+ }
253
+ }
254
+ }
255
+ export function makeArrowBetween(fromX, fromY, toX, toY, strokeWidth) {
256
+ if (strokeWidth === void 0) { strokeWidth = 2; }
257
+ var geometry = buildArrow({ x: fromX, y: fromY }, { x: toX, y: toY }, 0, strokeWidth);
258
+ return createPathObject({
259
+ x: geometry.box.x,
260
+ y: geometry.box.y,
261
+ width: geometry.box.width,
262
+ height: geometry.box.height,
263
+ d: serializePathData(geometry.commands),
264
+ shape: 'arrow',
265
+ arrow: geometry.spec,
266
+ stroke: '#111827',
267
+ strokeWidth: strokeWidth,
268
+ fill: 'transparent'
269
+ });
270
+ }
@@ -0,0 +1,9 @@
1
+ import type { ObjectId, SceneObject } from '../../engine/core/types.js';
2
+ /** Insert a group and its members in list order (group before members). */
3
+ export declare function packGroup(members: SceneObject[], options?: {
4
+ groupId?: ObjectId;
5
+ parentId?: ObjectId | null;
6
+ }): {
7
+ groupId: ObjectId;
8
+ objects: SceneObject[];
9
+ };
@@ -0,0 +1,33 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import { createGroupObject, createObjectId } from '../../engine/core/defaults.js';
22
+ /** Insert a group and its members in list order (group before members). */
23
+ export function packGroup(members, options) {
24
+ var _a, _b;
25
+ if (options === void 0) { options = {}; }
26
+ var groupId = (_a = options.groupId) !== null && _a !== void 0 ? _a : createObjectId('gp');
27
+ var parentId = (_b = options.parentId) !== null && _b !== void 0 ? _b : null;
28
+ var withParents = members.map(function (object) { return (__assign(__assign({}, object), { parentId: groupId })); });
29
+ return {
30
+ groupId: groupId,
31
+ objects: __spreadArray([createGroupObject({ id: groupId, parentId: parentId })], withParents, true)
32
+ };
33
+ }
@@ -0,0 +1,19 @@
1
+ import type { CanvasToolDefinition } from './types.js';
2
+ import { CANVAS_TOOL_NAMES } from './types.js';
3
+ export declare const CANVAS_TOOL_DEFINITIONS: CanvasToolDefinition[];
4
+ export declare function isCanvasToolName(name: string): name is (typeof CANVAS_TOOL_NAMES)[number];
5
+ /** OpenAI / MCP-style tool list for the gateway LLM loop. */
6
+ export declare function toOpenAiTools(): Array<{
7
+ type: 'function';
8
+ function: {
9
+ name: string;
10
+ description: string;
11
+ parameters: Record<string, unknown>;
12
+ };
13
+ }>;
14
+ /** MCP tool catalogue (names + inputSchema only). */
15
+ export declare function toMcpTools(): Array<{
16
+ name: string;
17
+ description: string;
18
+ inputSchema: Record<string, unknown>;
19
+ }>;
@@ -0,0 +1,147 @@
1
+ import { CANVAS_TOOL_NAMES } from './types.js';
2
+ export var CANVAS_TOOL_DEFINITIONS = [
3
+ {
4
+ name: 'get_canvas',
5
+ description: 'Read a compact summary of everything on the canvas: element ids, kinds, text labels, bounding boxes and z-order.',
6
+ parameters: {
7
+ type: 'object',
8
+ properties: {},
9
+ additionalProperties: false
10
+ }
11
+ },
12
+ {
13
+ name: 'draw_ui_component',
14
+ description: 'Draw a wireframe UI component from the catalogue as grouped primitives. Use for video players, nav bars, cards, buttons, forms, tables, carousels, modals.',
15
+ parameters: {
16
+ type: 'object',
17
+ required: ['component', 'x', 'y'],
18
+ properties: {
19
+ component: {
20
+ type: 'string',
21
+ enum: ['video_player', 'navigation_bar', 'card', 'button', 'form', 'table', 'carousel', 'modal']
22
+ },
23
+ x: { type: 'number' },
24
+ y: { type: 'number' },
25
+ width: { type: 'number', minimum: 40, maximum: 2000 },
26
+ height: { type: 'number', minimum: 40, maximum: 2000 },
27
+ label: { type: 'string', maxLength: 120 }
28
+ },
29
+ additionalProperties: false
30
+ }
31
+ },
32
+ {
33
+ name: 'add_shape',
34
+ description: 'Add a primitive rectangle, rounded rectangle, ellipse, or diamond.',
35
+ parameters: {
36
+ type: 'object',
37
+ required: ['shape', 'x', 'y', 'width', 'height'],
38
+ properties: {
39
+ shape: { type: 'string', enum: ['rectangle', 'rounded', 'ellipse', 'diamond'] },
40
+ x: { type: 'number' },
41
+ y: { type: 'number' },
42
+ width: { type: 'number', minimum: 4, maximum: 4000 },
43
+ height: { type: 'number', minimum: 4, maximum: 4000 },
44
+ label: { type: 'string', maxLength: 200 }
45
+ },
46
+ additionalProperties: false
47
+ }
48
+ },
49
+ {
50
+ name: 'add_text',
51
+ description: 'Place a text label on the canvas.',
52
+ parameters: {
53
+ type: 'object',
54
+ required: ['text', 'x', 'y'],
55
+ properties: {
56
+ text: { type: 'string', minLength: 1, maxLength: 500 },
57
+ x: { type: 'number' },
58
+ y: { type: 'number' },
59
+ width: { type: 'number', minimum: 20, maximum: 2000 }
60
+ },
61
+ additionalProperties: false
62
+ }
63
+ },
64
+ {
65
+ name: 'add_arrow',
66
+ description: 'Draw an arrow from a start point or element to an end point or element.',
67
+ parameters: {
68
+ type: 'object',
69
+ properties: {
70
+ fromId: { type: 'string' },
71
+ toId: { type: 'string' },
72
+ fromX: { type: 'number' },
73
+ fromY: { type: 'number' },
74
+ toX: { type: 'number' },
75
+ toY: { type: 'number' },
76
+ label: { type: 'string', maxLength: 120 }
77
+ },
78
+ additionalProperties: false
79
+ }
80
+ },
81
+ {
82
+ name: 'move_elements',
83
+ description: 'Move elements by id. Use dx/dy for a relative move, or x/y to set the top-left of the first id.',
84
+ parameters: {
85
+ type: 'object',
86
+ required: ['ids'],
87
+ properties: {
88
+ ids: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: 50 },
89
+ dx: { type: 'number' },
90
+ dy: { type: 'number' },
91
+ x: { type: 'number' },
92
+ y: { type: 'number' }
93
+ },
94
+ additionalProperties: false
95
+ }
96
+ },
97
+ {
98
+ name: 'delete_elements',
99
+ description: 'Delete elements by id, or pass ids ["all"] to remove every sketch object.',
100
+ parameters: {
101
+ type: 'object',
102
+ required: ['ids'],
103
+ properties: {
104
+ ids: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: 500 }
105
+ },
106
+ additionalProperties: false
107
+ }
108
+ },
109
+ {
110
+ name: 'clear_canvas',
111
+ description: 'Remove every object from the canvas.',
112
+ parameters: { type: 'object', properties: {}, additionalProperties: false }
113
+ },
114
+ {
115
+ name: 'name_components_with_arrows',
116
+ description: 'For each non-text shape, add a readable name label and an arrow pointing at it.',
117
+ parameters: {
118
+ type: 'object',
119
+ properties: {
120
+ prefix: { type: 'string', maxLength: 40 }
121
+ },
122
+ additionalProperties: false
123
+ }
124
+ }
125
+ ];
126
+ export function isCanvasToolName(name) {
127
+ return CANVAS_TOOL_NAMES.includes(name);
128
+ }
129
+ /** OpenAI / MCP-style tool list for the gateway LLM loop. */
130
+ export function toOpenAiTools() {
131
+ return CANVAS_TOOL_DEFINITIONS.map(function (tool) { return ({
132
+ type: 'function',
133
+ function: {
134
+ name: tool.name,
135
+ description: tool.description,
136
+ parameters: tool.parameters
137
+ }
138
+ }); });
139
+ }
140
+ /** MCP tool catalogue (names + inputSchema only). */
141
+ export function toMcpTools() {
142
+ return CANVAS_TOOL_DEFINITIONS.map(function (tool) { return ({
143
+ name: tool.name,
144
+ description: tool.description,
145
+ inputSchema: tool.parameters
146
+ }); });
147
+ }
@@ -0,0 +1,7 @@
1
+ import type { ObjectId } from '../engine/core/types.js';
2
+ import type { CanvasToolHost, CanvasToolName, ToolResult } from './types.js';
3
+ export declare function executeCanvasTool(host: CanvasToolHost, name: CanvasToolName, args: Record<string, unknown>): ToolResult;
4
+ /** Navigation wireframe group (label "Navigation"). */
5
+ export declare function findNavigationId(scene: ReturnType<CanvasToolHost['getScene']>): ObjectId | null;
6
+ export declare function findVideoThumbnailBounds(scene: ReturnType<CanvasToolHost['getScene']>): import("../engine/core/types.js").Rect | null;
7
+ export declare function findVideoPlayerRoot(scene: ReturnType<CanvasToolHost['getScene']>): ObjectId | null;