@pixerate/editor 0.44.0 → 0.45.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 (82) hide show
  1. package/README.md +27 -2
  2. package/dist/agent/index.cjs +548 -45
  3. package/dist/agent/index.cjs.map +1 -1
  4. package/dist/agent/index.d.cts +47 -17
  5. package/dist/agent/index.d.ts +47 -17
  6. package/dist/agent/index.js +536 -33
  7. package/dist/agent/index.js.map +1 -1
  8. package/dist/{builtins-BLud97fC.d.cts → builtins-CZW-aYKS.d.cts} +1 -1
  9. package/dist/{builtins-D0BDyAgw.d.ts → builtins-DghNQbT-.d.ts} +1 -1
  10. package/dist/{chunk-I6BZB5ZH.cjs → chunk-EFDCLENW.cjs} +73 -6
  11. package/dist/chunk-EFDCLENW.cjs.map +1 -0
  12. package/dist/chunk-HHQ4XJWT.js +826 -0
  13. package/dist/chunk-HHQ4XJWT.js.map +1 -0
  14. package/dist/chunk-J3R2OWOE.cjs +1465 -0
  15. package/dist/chunk-J3R2OWOE.cjs.map +1 -0
  16. package/dist/chunk-K2LVZ4FA.cjs +826 -0
  17. package/dist/chunk-K2LVZ4FA.cjs.map +1 -0
  18. package/dist/{chunk-6MDQKHRH.cjs → chunk-N4MLNJPO.cjs} +21 -899
  19. package/dist/chunk-N4MLNJPO.cjs.map +1 -0
  20. package/dist/chunk-PQM5W7ZN.js +168 -0
  21. package/dist/chunk-PQM5W7ZN.js.map +1 -0
  22. package/dist/{chunk-DDADOHJW.js → chunk-Q25ZS4F7.js} +5 -883
  23. package/dist/chunk-Q25ZS4F7.js.map +1 -0
  24. package/dist/chunk-TK2XZK6Z.js +1465 -0
  25. package/dist/chunk-TK2XZK6Z.js.map +1 -0
  26. package/dist/commands/index.cjs +3 -2
  27. package/dist/commands/index.cjs.map +1 -1
  28. package/dist/commands/index.d.cts +5 -5
  29. package/dist/commands/index.d.ts +5 -5
  30. package/dist/commands/index.js +2 -1
  31. package/dist/commands/index.js.map +1 -1
  32. package/dist/extensions/index.cjs +4 -4
  33. package/dist/extensions/index.cjs.map +1 -1
  34. package/dist/extensions/index.d.cts +3 -3
  35. package/dist/extensions/index.d.ts +3 -3
  36. package/dist/extensions/index.js +12 -12
  37. package/dist/generation/index.cjs +2 -2
  38. package/dist/generation/index.d.cts +4 -4
  39. package/dist/generation/index.d.ts +4 -4
  40. package/dist/generation/index.js +1 -1
  41. package/dist/image-editor/index.cjs +24 -24
  42. package/dist/image-editor/index.cjs.map +1 -1
  43. package/dist/image-editor/index.d.cts +2 -2
  44. package/dist/image-editor/index.d.ts +2 -2
  45. package/dist/image-editor/index.js +24 -24
  46. package/dist/image-editor/index.js.map +1 -1
  47. package/dist/{index-C6gaQRH0.d.cts → index-CfOQf70b.d.cts} +1 -1
  48. package/dist/{index-DXAv_R08.d.ts → index-jwJ_onWf.d.ts} +1 -1
  49. package/dist/index.cjs +9 -9
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +4 -4
  52. package/dist/index.d.ts +4 -4
  53. package/dist/index.js +12 -12
  54. package/dist/parameters/index.d.cts +2 -2
  55. package/dist/parameters/index.d.ts +2 -2
  56. package/dist/{registry-DnzpgY27.d.cts → registry-B4l-lYts.d.cts} +1 -1
  57. package/dist/{registry-DhVUZioj.d.ts → registry-BfVD-vVg.d.ts} +1 -1
  58. package/dist/{registry-BDe-vlv3.d.ts → registry-CSlH4iUn.d.ts} +1 -1
  59. package/dist/{registry-D0GADKc7.d.cts → registry-vz6HOiiy.d.cts} +1 -1
  60. package/dist/{schema-DYDGdYL9.d.cts → schema-Di0CS6Pe.d.cts} +26 -2
  61. package/dist/{schema-DYDGdYL9.d.ts → schema-Di0CS6Pe.d.ts} +26 -2
  62. package/dist/tools/index.cjs +37 -3
  63. package/dist/tools/index.cjs.map +1 -1
  64. package/dist/tools/index.d.cts +871 -11
  65. package/dist/tools/index.d.ts +871 -11
  66. package/dist/tools/index.js +36 -2
  67. package/dist/vector/index.d.cts +2 -2
  68. package/dist/vector/index.d.ts +2 -2
  69. package/package.json +1 -1
  70. package/dist/chunk-36BLROHV.js +0 -438
  71. package/dist/chunk-36BLROHV.js.map +0 -1
  72. package/dist/chunk-5H2OPMXZ.js +0 -586
  73. package/dist/chunk-5H2OPMXZ.js.map +0 -1
  74. package/dist/chunk-6MDQKHRH.cjs.map +0 -1
  75. package/dist/chunk-D6S5M7HV.js +0 -101
  76. package/dist/chunk-D6S5M7HV.js.map +0 -1
  77. package/dist/chunk-DDADOHJW.js.map +0 -1
  78. package/dist/chunk-I6BZB5ZH.cjs.map +0 -1
  79. package/dist/chunk-MC2LQN5S.cjs +0 -586
  80. package/dist/chunk-MC2LQN5S.cjs.map +0 -1
  81. package/dist/chunk-V7CC7RZ6.cjs +0 -438
  82. package/dist/chunk-V7CC7RZ6.cjs.map +0 -1
@@ -10,20 +10,39 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkV7CC7RZ6cjs = require('../chunk-V7CC7RZ6.cjs');
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+ var _chunkK2LVZ4FAcjs = require('../chunk-K2LVZ4FA.cjs');
14
31
 
15
32
 
16
33
  var _chunkHXDMZQTDcjs = require('../chunk-HXDMZQTD.cjs');
17
34
 
18
35
 
19
- var _chunkI6BZB5ZHcjs = require('../chunk-I6BZB5ZH.cjs');
36
+ var _chunkEFDCLENWcjs = require('../chunk-EFDCLENW.cjs');
20
37
 
21
38
 
22
39
 
23
40
 
24
41
 
25
42
 
26
- var _chunkMC2LQN5Scjs = require('../chunk-MC2LQN5S.cjs');
43
+
44
+
45
+ var _chunkJ3R2OWOEcjs = require('../chunk-J3R2OWOE.cjs');
27
46
 
28
47
 
29
48
 
@@ -63,8 +82,8 @@ function planAgentCommand(command, snapshot, options = {}) {
63
82
  const defaultNodeSize = _nullishCoalesce(options.defaultNodeSize, () => ( { width: 200, height: 60 }));
64
83
  const idGen = _nullishCoalesce(options.idGenerator, () => ( (() => `node-${Math.random().toString(36).substring(2, 9)}`)));
65
84
  const edgeIdGen = () => `edge-${Math.random().toString(36).substring(2, 9)}`;
66
- const nodes = _nullishCoalesce(_optionalChain([snapshot, 'access', _ => _.canvas, 'optionalAccess', _2 => _2.nodes]), () => ( []));
67
- const edges = _nullishCoalesce(_optionalChain([snapshot, 'access', _3 => _3.canvas, 'optionalAccess', _4 => _4.edges]), () => ( []));
85
+ const nodes = _nullishCoalesce(_optionalChain([snapshot, 'access', _2 => _2.canvas, 'optionalAccess', _3 => _3.nodes]), () => ( []));
86
+ const edges = _nullishCoalesce(_optionalChain([snapshot, 'access', _4 => _4.canvas, 'optionalAccess', _5 => _5.edges]), () => ( []));
68
87
  switch (command.type) {
69
88
  case "canvas:add_node": {
70
89
  let pos = command.node.position;
@@ -75,8 +94,8 @@ function planAgentCommand(command, snapshot, options = {}) {
75
94
  rects[n.id] = {
76
95
  x: n.position.x,
77
96
  y: n.position.y,
78
- width: _nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _5 => _5.measured, 'optionalAccess', _6 => _6.width]), () => ( n.width)), () => ( defaultNodeSize.width)),
79
- height: _nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _7 => _7.measured, 'optionalAccess', _8 => _8.height]), () => ( n.height)), () => ( defaultNodeSize.height))
97
+ width: _nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _6 => _6.measured, 'optionalAccess', _7 => _7.width]), () => ( n.width)), () => ( defaultNodeSize.width)),
98
+ height: _nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _8 => _8.measured, 'optionalAccess', _9 => _9.height]), () => ( n.height)), () => ( defaultNodeSize.height))
80
99
  };
81
100
  }
82
101
  if (anchorId) {
@@ -256,33 +275,60 @@ function planAgentCommand(command, snapshot, options = {}) {
256
275
  }
257
276
  }
258
277
  }
278
+ var CANVAS_TOOL_OPERATIONS = {
279
+ canvas_add_node: "add_node",
280
+ canvas_remove_nodes: "remove_nodes",
281
+ canvas_connect: "connect",
282
+ canvas_update_node: "update_node",
283
+ canvas_layout: "layout",
284
+ canvas_select: "select",
285
+ canvas_highlight: "highlight"
286
+ };
287
+ var PROMPT_TOOL_OPERATIONS = {
288
+ prompt_insert_text: "insert_text",
289
+ prompt_replace_range: "replace_range",
290
+ prompt_set_variable: "set_variable",
291
+ prompt_select: "select"
292
+ };
259
293
  function toolCallToAgentCommand(name, args = {}) {
260
294
  const ids = (value) => Array.isArray(value) && value.every((v) => typeof v === "string") ? value : null;
261
295
  const num = (value) => typeof value === "number" && Number.isFinite(value);
262
- if (name === "edit_canvas") {
263
- switch (args.operation) {
296
+ const canvasOperation = name === "edit_canvas" ? args.operation : CANVAS_TOOL_OPERATIONS[name];
297
+ if (canvasOperation !== void 0) {
298
+ switch (canvasOperation) {
264
299
  case "add_node":
265
- return args.node && typeof args.node === "object" ? { type: "canvas:add_node", node: args.node, nearNodeId: args.nearNodeId, side: args.side } : null;
300
+ return args.node && typeof args.node === "object" && !Array.isArray(args.node) ? {
301
+ type: "canvas:add_node",
302
+ node: { ...args.node, data: _nullishCoalesce(args.node.data, () => ( {})) },
303
+ nearNodeId: args.nearNodeId,
304
+ side: args.side
305
+ } : null;
266
306
  case "remove_nodes":
267
307
  return ids(args.nodeIds) ? { type: "canvas:remove_nodes", nodeIds: args.nodeIds } : null;
268
308
  case "connect":
269
309
  return typeof args.source === "string" && typeof args.target === "string" ? { type: "canvas:connect", source: args.source, target: args.target, label: args.label } : null;
270
310
  case "update_node": {
271
- const id = _nullishCoalesce(_optionalChain([args, 'access', _9 => _9.node, 'optionalAccess', _10 => _10.id]), () => ( args.id));
272
- return typeof id === "string" ? { type: "canvas:update_node", id, data: _nullishCoalesce(_nullishCoalesce(_optionalChain([args, 'access', _11 => _11.node, 'optionalAccess', _12 => _12.data]), () => ( args.data)), () => ( {})) } : null;
311
+ const id = _nullishCoalesce(_optionalChain([args, 'access', _10 => _10.node, 'optionalAccess', _11 => _11.id]), () => ( args.id));
312
+ return typeof id === "string" ? { type: "canvas:update_node", id, data: _nullishCoalesce(_nullishCoalesce(_optionalChain([args, 'access', _12 => _12.node, 'optionalAccess', _13 => _13.data]), () => ( args.data)), () => ( {})) } : null;
273
313
  }
274
314
  case "layout":
275
315
  return { type: "canvas:layout", direction: args.direction, incremental: args.incremental };
276
316
  case "select":
277
317
  return ids(args.nodeIds) ? { type: "canvas:select", nodeIds: args.nodeIds } : null;
278
318
  case "highlight":
279
- return ids(args.nodeIds) ? { type: "canvas:highlight", nodeIds: args.nodeIds } : null;
319
+ return ids(args.nodeIds) ? {
320
+ type: "canvas:highlight",
321
+ nodeIds: args.nodeIds,
322
+ ...typeof args.color === "string" ? { color: args.color } : {},
323
+ ...num(args.durationMs) ? { durationMs: args.durationMs } : {}
324
+ } : null;
280
325
  default:
281
326
  return null;
282
327
  }
283
328
  }
284
- if (name === "edit_prompt") {
285
- switch (args.operation) {
329
+ const promptOperation = name === "edit_prompt" ? args.operation : PROMPT_TOOL_OPERATIONS[name];
330
+ if (promptOperation !== void 0) {
331
+ switch (promptOperation) {
286
332
  case "insert_text":
287
333
  return typeof args.text === "string" ? { type: "prompt:insert_text", text: args.text, at: num(args.at) ? args.at : void 0 } : null;
288
334
  case "replace_range":
@@ -297,6 +343,42 @@ function toolCallToAgentCommand(name, args = {}) {
297
343
  }
298
344
  return { type: "tool:call", name, arguments: args };
299
345
  }
346
+ function validateAgentCommand(command, snapshot) {
347
+ const known = new Set((_nullishCoalesce(_optionalChain([snapshot, 'access', _14 => _14.canvas, 'optionalAccess', _15 => _15.nodes]), () => ( []))).map((n) => n.id));
348
+ const missing = (nodeIds) => {
349
+ const unknown = nodeIds.filter((id) => !known.has(id));
350
+ return unknown.length ? `Unknown node id${unknown.length > 1 ? "s" : ""}: ${unknown.map((id) => JSON.stringify(id)).join(", ")}. Call get_editor_state for the current ids.` : null;
351
+ };
352
+ const range = (from, to) => {
353
+ if (from < 0 || to < 0) return "Positions must be >= 0.";
354
+ if (from > to) return `"from" (${from}) must not be after "to" (${to}).`;
355
+ return null;
356
+ };
357
+ switch (command.type) {
358
+ case "canvas:add_node":
359
+ if (command.node.id && known.has(command.node.id)) return `A node with id "${command.node.id}" already exists.`;
360
+ return command.nearNodeId ? missing([command.nearNodeId]) : null;
361
+ case "canvas:remove_nodes":
362
+ case "canvas:highlight":
363
+ return command.nodeIds.length ? missing(command.nodeIds) : "Pass at least one node id.";
364
+ case "canvas:select":
365
+ return missing(command.nodeIds);
366
+ case "canvas:connect":
367
+ if (command.source === command.target) return "An edge needs two different nodes.";
368
+ return missing([command.source, command.target]);
369
+ case "canvas:update_node":
370
+ return missing([command.id]);
371
+ case "prompt:insert_text":
372
+ return command.at !== void 0 ? range(command.at, command.at) : null;
373
+ case "prompt:replace_range":
374
+ case "prompt:select":
375
+ return range(command.from, command.to);
376
+ case "choreography:say":
377
+ return command.atNodeId ? missing([command.atNodeId]) : null;
378
+ default:
379
+ return null;
380
+ }
381
+ }
300
382
  function planToolCall(name, args, snapshot, options) {
301
383
  const command = toolCallToAgentCommand(name, args);
302
384
  return command ? planAgentCommand(command, snapshot, options) : [];
@@ -314,12 +396,45 @@ function selectionInfo(editor) {
314
396
  const { from, to } = editor.state.selection;
315
397
  return { from, to, text: editor.state.doc.textBetween(from, to, "\n") };
316
398
  }
399
+ function checkRange(editor, from, to) {
400
+ const size = editor.state.doc.content.size;
401
+ if (from > to) throw new Error(`"from" (${from}) must not be after "to" (${to}).`);
402
+ if (to > size) throw new Error(`Position ${to} is outside the document (size ${size}).`);
403
+ }
404
+ function textBlocks(editor) {
405
+ const blocks = [];
406
+ editor.state.doc.descendants((node, pos) => {
407
+ if (!node.isTextblock) return true;
408
+ blocks.push({ type: node.type.name, from: pos + 1, to: pos + 1 + node.content.size, text: node.textContent });
409
+ return false;
410
+ });
411
+ return blocks;
412
+ }
413
+ var FIND_SCHEMA_PROPERTIES = {
414
+ matchCase: { type: "boolean", description: "Case-sensitive match (default false)." },
415
+ wholeWord: { type: "boolean", description: "Match whole words only (default false)." },
416
+ regex: {
417
+ type: "boolean",
418
+ description: "Treat the query as a JavaScript regular expression (default false: literal text)."
419
+ }
420
+ };
421
+ var CONTEXT_CHARS = 30;
422
+ function findMatches(editor, query, args, replacement) {
423
+ const options = {
424
+ matchCase: !!args.matchCase,
425
+ wholeWord: !!args.wholeWord,
426
+ ...args.regex ? { regex: true } : { literal: true }
427
+ };
428
+ const result = _chunkJ3R2OWOEcjs.searchDocument.call(void 0, editor.state.doc, query, options, replacement !== void 0 ? { replacement } : {});
429
+ if (result.error) throw new Error(`Invalid search pattern: ${result.error.message}`);
430
+ return { matches: result.matches, truncated: result.truncated };
431
+ }
317
432
  function createRichTextToolProvider(target, options) {
318
433
  const editor = () => toEditor(target);
319
434
  const getText = {
320
435
  name: "get_text",
321
436
  title: "Get document text",
322
- description: "Returns the document content (plain text by default, or HTML / markdown) and the current selection.",
437
+ description: "Returns the document content (plain text by default, or HTML / markdown), the current selection and the document size. Editing tools take document positions, not text offsets: pass `blocks: true` to get every paragraph with the positions its text spans, or use find_text to get the positions of a phrase.",
323
438
  inputSchema: {
324
439
  type: "object",
325
440
  properties: {
@@ -327,6 +442,10 @@ function createRichTextToolProvider(target, options) {
327
442
  type: "string",
328
443
  enum: ["text", "html", "markdown"],
329
444
  description: "Content format (default: text)."
445
+ },
446
+ blocks: {
447
+ type: "boolean",
448
+ description: "Also return `blocks`: each paragraph/heading/cell as {type, from, to, text} (default false)."
330
449
  }
331
450
  },
332
451
  additionalProperties: false
@@ -338,10 +457,16 @@ function createRichTextToolProvider(target, options) {
338
457
  idempotentHint: true,
339
458
  openWorldHint: false
340
459
  },
341
- handler: ({ format = "text" }) => {
460
+ handler: ({ format = "text", blocks = false }) => {
342
461
  const ed = editor();
343
462
  const content = format === "html" ? ed.getHTML() : format === "markdown" ? _chunk66IMF6ODcjs.getEditorMarkdown.call(void 0, ed) : _chunk66IMF6ODcjs.getEditorText.call(void 0, ed);
344
- return { format, content, selection: selectionInfo(ed), size: ed.state.doc.content.size };
463
+ return {
464
+ format,
465
+ content,
466
+ selection: selectionInfo(ed),
467
+ size: ed.state.doc.content.size,
468
+ ...blocks ? { blocks: textBlocks(ed) } : {}
469
+ };
345
470
  }
346
471
  };
347
472
  const insertText = {
@@ -375,6 +500,148 @@ function createRichTextToolProvider(target, options) {
375
500
  return { inserted: text.length, selection: selectionInfo(ed) };
376
501
  }
377
502
  };
503
+ const findText = {
504
+ name: "find_text",
505
+ title: "Find text",
506
+ description: "Finds a phrase (literal by default) and returns each match with its document positions {from, to}, ready for replace_range, insert_text `at` or set_selection, plus surrounding context.",
507
+ inputSchema: {
508
+ type: "object",
509
+ properties: {
510
+ query: { type: "string", minLength: 1, description: "Text (or regex) to find." },
511
+ ...FIND_SCHEMA_PROPERTIES,
512
+ maxResults: { type: "integer", minimum: 1, maximum: 500, description: "Matches returned (default 50)." }
513
+ },
514
+ required: ["query"],
515
+ additionalProperties: false
516
+ },
517
+ annotations: {
518
+ title: "Find text",
519
+ readOnlyHint: true,
520
+ destructiveHint: false,
521
+ idempotentHint: true,
522
+ openWorldHint: false
523
+ },
524
+ handler: ({ query, maxResults = 50, ...flags }) => {
525
+ const ed = editor();
526
+ const { doc } = ed.state;
527
+ const { matches, truncated } = findMatches(ed, query, flags);
528
+ return {
529
+ total: matches.length,
530
+ truncated: truncated || matches.length > maxResults,
531
+ matches: matches.slice(0, maxResults).map((m) => ({
532
+ from: m.from,
533
+ to: m.to,
534
+ text: m.text,
535
+ before: doc.textBetween(Math.max(0, m.from - CONTEXT_CHARS), m.from, "\n", " "),
536
+ after: doc.textBetween(m.to, Math.min(doc.content.size, m.to + CONTEXT_CHARS), "\n", " ")
537
+ }))
538
+ };
539
+ }
540
+ };
541
+ const replaceText = {
542
+ name: "replace_text",
543
+ title: "Find and replace",
544
+ description: "Replaces occurrences of a phrase with literal text in one undoable step, keeping the found text's formatting. Replaces every occurrence by default, or only the n-th with `occurrence`. Fails when nothing matches.",
545
+ inputSchema: {
546
+ type: "object",
547
+ properties: {
548
+ find: { type: "string", minLength: 1, description: "Text (or regex) to find." },
549
+ replace: { type: "string", description: "Replacement text (literal; an empty string deletes the matches)." },
550
+ ...FIND_SCHEMA_PROPERTIES,
551
+ occurrence: {
552
+ type: "integer",
553
+ minimum: 1,
554
+ description: "Only replace the n-th match (1-based, in document order). Default: all matches."
555
+ }
556
+ },
557
+ required: ["find", "replace"],
558
+ additionalProperties: false
559
+ },
560
+ annotations: {
561
+ title: "Find and replace",
562
+ readOnlyHint: false,
563
+ destructiveHint: true,
564
+ idempotentHint: false,
565
+ openWorldHint: false
566
+ },
567
+ handler: ({ find, replace, occurrence, ...flags }) => {
568
+ const ed = editor();
569
+ const { matches } = findMatches(ed, find, flags);
570
+ if (matches.length === 0) throw new Error(`No match for ${JSON.stringify(find)}.`);
571
+ if (occurrence !== void 0 && occurrence > matches.length) {
572
+ throw new Error(`Occurrence ${occurrence} requested, but there are only ${matches.length} matches.`);
573
+ }
574
+ const chosen = (occurrence !== void 0 ? [matches[occurrence - 1]] : matches).map((m) => ({
575
+ ...m,
576
+ replacement: String(replace).replace(/\r\n?|\n/g, "\r")
577
+ }));
578
+ const tr = ed.state.tr;
579
+ const ends = _chunkJ3R2OWOEcjs.applyReplacements.call(void 0, tr, chosen);
580
+ ed.view.dispatch(tr.scrollIntoView());
581
+ return {
582
+ replaced: chosen.length,
583
+ total: matches.length,
584
+ ranges: chosen.map((m, i) => ({ from: tr.mapping.map(m.from, -1), to: ends[i] })),
585
+ selection: selectionInfo(ed)
586
+ };
587
+ }
588
+ };
589
+ const replaceRange = {
590
+ name: "replace_range",
591
+ title: "Replace a range",
592
+ description: "Replaces the content between two document positions (from get_text `blocks` or find_text) with literal text. from === to inserts; an empty text deletes.",
593
+ inputSchema: {
594
+ type: "object",
595
+ properties: {
596
+ from: { type: "integer", minimum: 0, description: "Start document position." },
597
+ to: { type: "integer", minimum: 0, description: "End document position." },
598
+ text: { type: "string", description: "Replacement text (newlines start new paragraphs)." }
599
+ },
600
+ required: ["from", "to", "text"],
601
+ additionalProperties: false
602
+ },
603
+ annotations: {
604
+ title: "Replace a range",
605
+ readOnlyHint: false,
606
+ destructiveHint: true,
607
+ idempotentHint: false,
608
+ openWorldHint: false
609
+ },
610
+ handler: ({ from, to, text }) => {
611
+ const ed = editor();
612
+ checkRange(ed, from, to);
613
+ replaceWithText(ed, from, to, text);
614
+ return { replaced: { from, to }, selection: selectionInfo(ed), size: ed.state.doc.content.size };
615
+ }
616
+ };
617
+ const setSelection = {
618
+ name: "set_selection",
619
+ title: "Set the selection",
620
+ description: "Selects the content between two document positions (from === to places the cursor).",
621
+ inputSchema: {
622
+ type: "object",
623
+ properties: {
624
+ from: { type: "integer", minimum: 0, description: "Start document position." },
625
+ to: { type: "integer", minimum: 0, description: "End document position (default: from)." }
626
+ },
627
+ required: ["from"],
628
+ additionalProperties: false
629
+ },
630
+ annotations: {
631
+ title: "Set the selection",
632
+ readOnlyHint: false,
633
+ destructiveHint: false,
634
+ idempotentHint: true,
635
+ openWorldHint: false
636
+ },
637
+ handler: ({ from, to = from }) => {
638
+ const ed = editor();
639
+ checkRange(ed, from, to);
640
+ const { doc } = ed.state;
641
+ ed.view.dispatch(ed.state.tr.setSelection(_state.TextSelection.between(doc.resolve(from), doc.resolve(to))));
642
+ return { selection: selectionInfo(ed) };
643
+ }
644
+ };
378
645
  const replaceSelection = {
379
646
  name: "replace_selection",
380
647
  title: "Replace selection",
@@ -406,7 +673,7 @@ function createRichTextToolProvider(target, options) {
406
673
  inputSchema: {
407
674
  type: "object",
408
675
  properties: {
409
- operation: { type: "string", enum: _chunkMC2LQN5Scjs.TABLE_ACTIONS.map((a) => a.action), description: "Table operation." },
676
+ operation: { type: "string", enum: _chunkJ3R2OWOEcjs.TABLE_ACTIONS.map((a) => a.action), description: "Table operation." },
410
677
  at: { type: "integer", minimum: 0, description: "Document position to place the cursor first (e.g. inside a cell)." },
411
678
  rows: { type: "integer", minimum: 1, maximum: 100, description: "insertTable: rows (default 3)." },
412
679
  cols: { type: "integer", minimum: 1, maximum: 50, description: "insertTable: columns (default 3)." },
@@ -436,10 +703,10 @@ function createRichTextToolProvider(target, options) {
436
703
  ed.view.dispatch(ed.state.tr.setSelection(_state.TextSelection.near(ed.state.doc.resolve(at))));
437
704
  }
438
705
  const action = operation;
439
- const state = _chunkMC2LQN5Scjs.getTableActionState.call(void 0, ed, action, params);
706
+ const state = _chunkJ3R2OWOEcjs.getTableActionState.call(void 0, ed, action, params);
440
707
  if (state !== true) throw new Error(state);
441
- _chunkMC2LQN5Scjs.runTableAction.call(void 0, ed, action, params);
442
- const table = _chunkMC2LQN5Scjs.getTableState.call(void 0, ed);
708
+ _chunkJ3R2OWOEcjs.runTableAction.call(void 0, ed, action, params);
709
+ const table = _chunkJ3R2OWOEcjs.getTableState.call(void 0, ed);
443
710
  return {
444
711
  operation,
445
712
  table: table.inTable ? { rows: table.rows, columns: table.columns, row: table.row, column: table.column } : null,
@@ -453,8 +720,9 @@ function createRichTextToolProvider(target, options) {
453
720
  tools: () => {
454
721
  const ed = editor();
455
722
  if (!ed || ed.isDestroyed) return [];
456
- if (!ed.isEditable) return [getText];
457
- return _chunkMC2LQN5Scjs.isTableEnabled.call(void 0, ed) ? [getText, insertText, replaceSelection, editTable] : [getText, insertText, replaceSelection];
723
+ if (!ed.isEditable) return [getText, findText];
724
+ const tools = [getText, findText, insertText, replaceText, replaceRange, replaceSelection, setSelection];
725
+ return _chunkJ3R2OWOEcjs.isTableEnabled.call(void 0, ed) ? [...tools, editTable] : tools;
458
726
  },
459
727
  subscribe: (notify) => {
460
728
  const ed = editor();
@@ -473,6 +741,12 @@ function parseCell(ref) {
473
741
  if (!match) throw new Error(`Invalid cell reference "${ref}". Use A1 notation, e.g. "B3".`);
474
742
  return { col: _chunkEWCOFSCQcjs.colNameToIndex.call(void 0, match[1].toUpperCase()), row: parseInt(match[2], 10) - 1 };
475
743
  }
744
+ var COLUMN_REGEX = /^[A-Za-z]{1,3}$/;
745
+ function parseColumn(name) {
746
+ if (!COLUMN_REGEX.test(name.trim())) throw new Error(`Invalid column "${name}". Use a letter name, e.g. "C".`);
747
+ return _chunkEWCOFSCQcjs.colNameToIndex.call(void 0, name.trim().toUpperCase());
748
+ }
749
+ var CELL_INPUT = { type: ["string", "number", "boolean", "null"] };
476
750
  function createSpreadsheetToolProvider(controller, options) {
477
751
  const lookup = (row, col) => {
478
752
  const rowDef = controller.document.rows[row];
@@ -567,20 +841,187 @@ function createSpreadsheetToolProvider(controller, options) {
567
841
  return { cell: cell.toUpperCase(), raw: updated.raw, value: _nullishCoalesce(updated.error, () => ( updated.value)) };
568
842
  }
569
843
  };
570
- return { id: options.id, namespace: options.namespace, tools: [getRange, setCell] };
844
+ const isReadOnly = (row, col) => {
845
+ const found = lookup(row, col);
846
+ if (!found) return false;
847
+ const { rowDef, colDef } = found;
848
+ return !!(colDef.readOnly || colDef.type === "formula" || controller.getCell(rowDef.id, colDef.id).readOnly);
849
+ };
850
+ const setRange = {
851
+ name: "set_range",
852
+ title: "Set a block of cells",
853
+ description: 'Writes a 2D block of raw inputs starting at a cell (A1 notation), row by row, as one undo step. Values starting with "=" are formulas; null or "" clears a cell. The sheet grows to fit. Fails without writing anything if any target cell is read-only.',
854
+ inputSchema: {
855
+ type: "object",
856
+ properties: {
857
+ start: { type: "string", description: 'Top-left cell, e.g. "A1".' },
858
+ values: {
859
+ type: "array",
860
+ minItems: 1,
861
+ maxItems: 1e4,
862
+ items: { type: "array", items: CELL_INPUT, maxItems: 1e3 },
863
+ description: 'Rows of raw cell inputs, e.g. [["Name", "Total"], ["A", "=B3*2"]].'
864
+ }
865
+ },
866
+ required: ["start", "values"],
867
+ additionalProperties: false
868
+ },
869
+ annotations: {
870
+ title: "Set a block of cells",
871
+ readOnlyHint: false,
872
+ destructiveHint: true,
873
+ idempotentHint: true,
874
+ openWorldHint: false
875
+ },
876
+ handler: ({ start, values }) => {
877
+ const { row, col } = parseCell(start);
878
+ const rows = values;
879
+ const readOnly = [];
880
+ rows.forEach(
881
+ (line, r) => line.forEach((_, c) => {
882
+ if (isReadOnly(row + r, col + c)) readOnly.push(`${_chunkEWCOFSCQcjs.indexToColName.call(void 0, col + c)}${row + r + 1}`);
883
+ })
884
+ );
885
+ if (readOnly.length) throw new Error(`Read-only cells: ${readOnly.slice(0, 20).join(", ")}. Nothing was written.`);
886
+ controller.importRows(
887
+ rows.map((line) => line.map((v) => v === null ? "" : String(v))),
888
+ { startRow: row, startCol: col }
889
+ );
890
+ const width = Math.max(0, ...rows.map((line) => line.length));
891
+ const end = `${_chunkEWCOFSCQcjs.indexToColName.call(void 0, col + Math.max(width, 1) - 1)}${row + rows.length}`;
892
+ const errors = [];
893
+ rows.forEach(
894
+ (line, r) => line.forEach((_, c) => {
895
+ const found = lookup(row + r, col + c);
896
+ if (!found) return;
897
+ const cell = controller.getCell(found.rowDef.id, found.colDef.id);
898
+ const error = _nullishCoalesce(cell.error, () => ( (_chunkEWCOFSCQcjs.isFormulaError.call(void 0, cell.value) ? cell.value : void 0)));
899
+ if (error) errors.push({ cell: `${_chunkEWCOFSCQcjs.indexToColName.call(void 0, col + c)}${row + r + 1}`, error: String(error) });
900
+ })
901
+ );
902
+ return {
903
+ range: `${_chunkEWCOFSCQcjs.indexToColName.call(void 0, col)}${row + 1}:${end}`,
904
+ written: rows.reduce((n, line) => n + line.length, 0),
905
+ errors,
906
+ sheet: { rows: controller.document.rows.length, columns: controller.document.columns.length }
907
+ };
908
+ }
909
+ };
910
+ const COUNT = { type: "integer", minimum: 1, maximum: 1e3, description: "How many (default 1)." };
911
+ const sheetSize = () => ({ rows: controller.document.rows.length, columns: controller.document.columns.length });
912
+ const structural = (name, title, description, properties, required, destructive, handler) => ({
913
+ name,
914
+ title,
915
+ description,
916
+ inputSchema: { type: "object", properties, required, additionalProperties: false },
917
+ annotations: { title, readOnlyHint: false, destructiveHint: destructive, idempotentHint: false, openWorldHint: false },
918
+ handler
919
+ });
920
+ const insertRows = structural(
921
+ "insert_rows",
922
+ "Insert rows",
923
+ "Inserts empty rows before a row number (1-based; one past the last row appends). References below shift down.",
924
+ { before: { type: "integer", minimum: 1, description: "Row number to insert before." }, count: COUNT },
925
+ ["before"],
926
+ false,
927
+ ({ before, count = 1 }) => {
928
+ const index = before - 1;
929
+ if (index > controller.document.rows.length) throw new Error(`Row ${before} is past the end of the sheet (${controller.document.rows.length} rows).`);
930
+ for (let i = 0; i < count; i++) controller.insertRow(index);
931
+ return { inserted: count, rows: `${before}:${before + count - 1}`, sheet: sheetSize() };
932
+ }
933
+ );
934
+ const deleteRows = structural(
935
+ "delete_rows",
936
+ "Delete rows",
937
+ "Deletes rows starting at a row number (1-based) with their contents. References below shift up; references to deleted cells become #REF!.",
938
+ { start: { type: "integer", minimum: 1, description: "First row number to delete." }, count: COUNT },
939
+ ["start"],
940
+ true,
941
+ ({ start, count = 1 }) => {
942
+ const rows = controller.document.rows.slice(start - 1, start - 1 + count);
943
+ if (rows.length < count) throw new Error(`Rows ${start}-${start + count - 1} are not all in the sheet (${controller.document.rows.length} rows).`);
944
+ for (const row of rows) controller.deleteRow(row.id);
945
+ return { deleted: count, sheet: sheetSize() };
946
+ }
947
+ );
948
+ const insertColumns = structural(
949
+ "insert_columns",
950
+ "Insert columns",
951
+ "Inserts empty columns before a column letter (one past the last column appends). References to the right shift.",
952
+ { before: { type: "string", description: 'Column letter to insert before, e.g. "C".' }, count: COUNT },
953
+ ["before"],
954
+ false,
955
+ ({ before, count = 1 }) => {
956
+ const index = parseColumn(before);
957
+ if (index > controller.document.columns.length) throw new Error(`Column ${before} is past the end of the sheet (${controller.document.columns.length} columns).`);
958
+ for (let i = 0; i < count; i++) controller.insertColumn(index);
959
+ return { inserted: count, columns: `${_chunkEWCOFSCQcjs.indexToColName.call(void 0, index)}:${_chunkEWCOFSCQcjs.indexToColName.call(void 0, index + count - 1)}`, sheet: sheetSize() };
960
+ }
961
+ );
962
+ const deleteColumns = structural(
963
+ "delete_columns",
964
+ "Delete columns",
965
+ "Deletes columns starting at a column letter with their contents. References to the right shift left; references to deleted cells become #REF!.",
966
+ { start: { type: "string", description: 'First column letter to delete, e.g. "C".' }, count: COUNT },
967
+ ["start"],
968
+ true,
969
+ ({ start, count = 1 }) => {
970
+ const index = parseColumn(start);
971
+ const columns = controller.document.columns.slice(index, index + count);
972
+ if (columns.length < count) throw new Error(`Columns from ${start} (${count}) are not all in the sheet (${controller.document.columns.length} columns).`);
973
+ for (const column of columns) controller.deleteColumn(column.id);
974
+ return { deleted: count, sheet: sheetSize() };
975
+ }
976
+ );
977
+ return {
978
+ id: options.id,
979
+ namespace: options.namespace,
980
+ tools: [getRange, setCell, setRange, insertRows, deleteRows, insertColumns, deleteColumns]
981
+ };
982
+ }
983
+ function missingArgumentsMessage(name, args) {
984
+ const required = _chunkK2LVZ4FAcjs.EDIT_OPERATION_REQUIRED_ARGUMENTS[name][args.operation];
985
+ if (!required) return `Unknown operation "${args.operation}".`;
986
+ const missing = required.filter(
987
+ (key) => key === "id" ? args.id === void 0 && _optionalChain([args, 'access', _16 => _16.node, 'optionalAccess', _17 => _17.id]) === void 0 : args[key] === void 0
988
+ );
989
+ return missing.length ? `Operation "${args.operation}" requires ${required.join(", ")}; missing: ${missing.join(", ")}.` : `Operation "${args.operation}" has invalid arguments (expected ${required.join(", ")} with the types in the schema).`;
990
+ }
991
+ function describeSteps(steps) {
992
+ const nodes = [];
993
+ const edges = [];
994
+ for (const step of steps) {
995
+ if (step.type === "step:canvas_add_node") nodes.push({ id: step.node.id, position: step.node.position });
996
+ if (step.type === "step:canvas_add_edge") edges.push({ id: step.edge.id, source: step.edge.source, target: step.edge.target });
997
+ }
998
+ return {
999
+ applied: steps.length,
1000
+ steps: steps.map((s) => s.type),
1001
+ ...nodes.length || edges.length ? { created: { nodes, edges } } : {}
1002
+ };
571
1003
  }
572
1004
  function createEditorMcpToolProvider(options) {
573
1005
  const edit = (name) => async (args) => {
574
- const steps = planToolCall(name, args, options.getSnapshot(), options.plannerOptions);
575
- if (steps.length === 0) {
576
- throw new Error(`Operation "${args.operation}" is missing required arguments.`);
1006
+ const command = toolCallToAgentCommand(name, args);
1007
+ if (!command) {
1008
+ throw new Error(
1009
+ name === "edit_canvas" || name === "edit_prompt" ? missingArgumentsMessage(name, args) : `Invalid arguments for "${name}".`
1010
+ );
577
1011
  }
1012
+ const snapshot = options.getSnapshot();
1013
+ const problem = validateAgentCommand(command, snapshot);
1014
+ if (problem) throw new Error(problem);
1015
+ const steps = planAgentCommand(command, snapshot, options.plannerOptions);
578
1016
  await options.applySteps(steps);
579
- return { applied: steps.length, steps: steps.map((s) => s.type) };
1017
+ return describeSteps(steps);
580
1018
  };
1019
+ const canvas = _nullishCoalesce(_optionalChain([options, 'access', _18 => _18.surfaces, 'optionalAccess', _19 => _19.canvas]), () => ( true));
1020
+ const prompt = _nullishCoalesce(_optionalChain([options, 'access', _20 => _20.surfaces, 'optionalAccess', _21 => _21.prompt]), () => ( true));
1021
+ const editTools = options.toolStyle === "combined" ? [...canvas ? [_chunkK2LVZ4FAcjs.MCP_TOOL_EDIT_CANVAS] : [], ...prompt ? [_chunkK2LVZ4FAcjs.MCP_TOOL_EDIT_PROMPT] : []] : [...canvas ? _chunkK2LVZ4FAcjs.EDITOR_CANVAS_TOOLS : [], ...prompt ? _chunkK2LVZ4FAcjs.EDITOR_PROMPT_TOOLS : []];
581
1022
  const tools = [
582
1023
  {
583
- ..._chunkV7CC7RZ6cjs.MCP_TOOL_GET_EDITOR_STATE,
1024
+ ..._chunkK2LVZ4FAcjs.MCP_TOOL_GET_EDITOR_STATE,
584
1025
  handler: ({ includeDocument = true, includeCanvas = true }) => {
585
1026
  const snapshot = options.getSnapshot();
586
1027
  return {
@@ -589,13 +1030,12 @@ function createEditorMcpToolProvider(options) {
589
1030
  };
590
1031
  }
591
1032
  },
592
- { ..._chunkV7CC7RZ6cjs.MCP_TOOL_EDIT_CANVAS, handler: edit(_chunkV7CC7RZ6cjs.MCP_TOOL_EDIT_CANVAS.name) },
593
- { ..._chunkV7CC7RZ6cjs.MCP_TOOL_EDIT_PROMPT, handler: edit(_chunkV7CC7RZ6cjs.MCP_TOOL_EDIT_PROMPT.name) }
1033
+ ...editTools.map((definition) => ({ ...definition, handler: edit(definition.name) }))
594
1034
  ];
595
1035
  if (options.captureView) {
596
1036
  const capture = options.captureView;
597
1037
  tools.push({
598
- ..._chunkV7CC7RZ6cjs.MCP_TOOL_VIEW_EDITOR,
1038
+ ..._chunkK2LVZ4FAcjs.MCP_TOOL_VIEW_EDITOR,
599
1039
  handler: async (args) => {
600
1040
  const image = await capture(args);
601
1041
  return { content: [{ type: "image", data: image.data, mimeType: image.mimeType }] };
@@ -608,8 +1048,33 @@ function createEditorMcpToolProvider(options) {
608
1048
  // src/agent/componentTools.ts
609
1049
  var IDS = { type: "array", items: { type: "string" }, description: "Node ids (default: the selection)." };
610
1050
  var ID = { type: "string", description: "An instance, or a layer inside one (default: the first selected node)." };
1051
+ var COMPONENT_ID = { type: "string", description: "Component or component set id (from list_components)." };
1052
+ var PARENT_ID = { type: "string", description: "Frame to place the instance in (default: the canvas root)." };
1053
+ var X = { type: "number", description: "X position (canvas coordinates, or relative to the parent frame)." };
1054
+ var Y = { type: "number", description: "Y position (canvas coordinates, or relative to the parent frame)." };
611
1055
  var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
612
1056
  var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
1057
+ var DESTRUCTIVE = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false };
1058
+ var TITLES = {
1059
+ list_components: "List components",
1060
+ inspect_instance: "Inspect an instance",
1061
+ create_component: "Create a component",
1062
+ combine_as_variants: "Combine as variants",
1063
+ create_instance: "Create an instance",
1064
+ set_instance_properties: "Set instance properties",
1065
+ swap_instance: "Swap an instance",
1066
+ reset_overrides: "Reset overrides",
1067
+ push_overrides: "Push overrides to the main component",
1068
+ detach_instance: "Detach instances",
1069
+ go_to_main_component: "Go to the main component",
1070
+ restore_main_component: "Restore the main component",
1071
+ add_variant: "Add a variant",
1072
+ remove_variant: "Remove a variant",
1073
+ set_variant_properties: "Set variant properties",
1074
+ rename_variant_property: "Rename a variant property",
1075
+ rename_variant_value: "Rename a variant value"
1076
+ };
1077
+ var DESTRUCTIVE_TOOLS = /* @__PURE__ */ new Set(["reset_overrides", "push_overrides", "detach_instance", "remove_variant"]);
613
1078
  var check = (result) => {
614
1079
  if (!result.ok) throw new Error(result.reason);
615
1080
  return { ids: result.ids };
@@ -617,9 +1082,13 @@ var check = (result) => {
617
1082
  function createCanvasComponentToolProvider(controller, options = { id: "canvas-components" }) {
618
1083
  const tool = (name, description, properties, handler, extra = {}) => ({
619
1084
  name,
1085
+ title: TITLES[name],
620
1086
  description,
621
1087
  inputSchema: { type: "object", properties, ...extra.required ? { required: extra.required } : {}, additionalProperties: false },
622
- annotations: extra.readOnly ? READ : WRITE,
1088
+ annotations: {
1089
+ title: TITLES[name],
1090
+ ...extra.readOnly ? READ : DESTRUCTIVE_TOOLS.has(name) ? DESTRUCTIVE : WRITE
1091
+ },
623
1092
  handler
624
1093
  });
625
1094
  const tools = [
@@ -653,10 +1122,10 @@ function createCanvasComponentToolProvider(controller, options = { id: "canvas-c
653
1122
  "create_instance",
654
1123
  "Places an instance of a component or component set, optionally inside a frame, at a position, with property values.",
655
1124
  {
656
- componentId: { type: "string" },
657
- parentId: { type: "string" },
658
- x: { type: "number" },
659
- y: { type: "number" },
1125
+ componentId: COMPONENT_ID,
1126
+ parentId: PARENT_ID,
1127
+ x: X,
1128
+ y: Y,
660
1129
  properties: { type: "object", additionalProperties: true, description: "Variant and component property values." }
661
1130
  },
662
1131
  ({ componentId, parentId, x, y, properties }) => check(
@@ -671,21 +1140,28 @@ function createCanvasComponentToolProvider(controller, options = { id: "canvas-c
671
1140
  tool(
672
1141
  "set_instance_properties",
673
1142
  "Sets property values of instances: variant properties switch the variant (keeping compatible overrides), booleans toggle layers, text sets text, instance swap takes a component id.",
674
- { properties: { type: "object", additionalProperties: true }, ids: IDS },
1143
+ {
1144
+ properties: {
1145
+ type: "object",
1146
+ additionalProperties: true,
1147
+ description: "Property name \u2192 value (see inspect_instance for the names and types)."
1148
+ },
1149
+ ids: IDS
1150
+ },
675
1151
  ({ properties, ids }) => check(controller.setInstanceProperties(properties, ids)),
676
1152
  { required: ["properties"] }
677
1153
  ),
678
1154
  tool(
679
1155
  "swap_instance",
680
1156
  "Makes instances show another component (or a set\u2019s default variant), keeping overrides of layers with matching names.",
681
- { componentId: { type: "string" }, ids: IDS },
1157
+ { componentId: COMPONENT_ID, ids: IDS },
682
1158
  ({ componentId, ids }) => check(controller.swapInstance(componentId, ids)),
683
1159
  { required: ["componentId"] }
684
1160
  ),
685
1161
  tool(
686
1162
  "reset_overrides",
687
1163
  'Resets overrides: of a whole instance (default), of one layer, or one override group such as "data.label" or "shape.fill".',
688
- { id: ID, group: { type: "string" } },
1164
+ { id: ID, group: { type: "string", description: 'Override group, e.g. "data.label" or "shape.fill" (default: all).' } },
689
1165
  ({ id, group }) => check(controller.resetOverrides(id, group))
690
1166
  ),
691
1167
  tool(
@@ -715,7 +1191,7 @@ function createCanvasComponentToolProvider(controller, options = { id: "canvas-c
715
1191
  tool(
716
1192
  "add_variant",
717
1193
  'Adds a variant to a component set by duplicating one (default: the set\u2019s default variant) with new property values. Unnamed properties keep the source\u2019s values; new property names are added to every variant ("Default"). A combination another variant has is refused. Without values the next "VariantN" is used.',
718
- { setId: SET, from: { type: "string", description: "Variant to duplicate." }, variant: VALUES, x: { type: "number" }, y: { type: "number" } },
1194
+ { setId: SET, from: { type: "string", description: "Variant to duplicate." }, variant: VALUES, x: X, y: Y },
719
1195
  ({ setId, from, variant, x, y }) => check(
720
1196
  controller.addVariant(setId, {
721
1197
  ...from !== void 0 ? { from } : {},
@@ -740,14 +1216,23 @@ function createCanvasComponentToolProvider(controller, options = { id: "canvas-c
740
1216
  tool(
741
1217
  "rename_variant_property",
742
1218
  "Renames a variant property across a component set (instances keep their variant).",
743
- { name: { type: "string" }, newName: { type: "string" }, setId: SET },
1219
+ {
1220
+ name: { type: "string", description: "Current property name." },
1221
+ newName: { type: "string", description: "New property name." },
1222
+ setId: SET
1223
+ },
744
1224
  ({ name, newName, setId }) => check(controller.renameVariantProperty(name, newName, setId)),
745
1225
  { required: ["name", "newName"] }
746
1226
  ),
747
1227
  tool(
748
1228
  "rename_variant_value",
749
1229
  "Renames a value of a variant property across a component set (instances keep their variant).",
750
- { property: { type: "string" }, value: { type: "string" }, newValue: { type: "string" }, setId: SET },
1230
+ {
1231
+ property: { type: "string", description: "Variant property name." },
1232
+ value: { type: "string", description: "Current value." },
1233
+ newValue: { type: "string", description: "New value." },
1234
+ setId: SET
1235
+ },
751
1236
  ({ property, value, newValue, setId }) => check(controller.renameVariantValue(property, value, newValue, setId)),
752
1237
  { required: ["property", "value", "newValue"] }
753
1238
  )
@@ -776,5 +1261,23 @@ function createCanvasComponentToolProvider(controller, options = { id: "canvas-c
776
1261
 
777
1262
 
778
1263
 
779
- exports.EDITOR_MCP_TOOLS = _chunkV7CC7RZ6cjs.EDITOR_MCP_TOOLS; exports.EXPORT_EXCLUDED_SELECTORS = _chunkV7CC7RZ6cjs.EXPORT_EXCLUDED_SELECTORS; exports.MCP_TOOL_EDIT_CANVAS = _chunkV7CC7RZ6cjs.MCP_TOOL_EDIT_CANVAS; exports.MCP_TOOL_EDIT_PROMPT = _chunkV7CC7RZ6cjs.MCP_TOOL_EDIT_PROMPT; exports.MCP_TOOL_GET_EDITOR_STATE = _chunkV7CC7RZ6cjs.MCP_TOOL_GET_EDITOR_STATE; exports.MCP_TOOL_VIEW_EDITOR = _chunkV7CC7RZ6cjs.MCP_TOOL_VIEW_EDITOR; exports.TOOL_NAMESPACE_SEPARATOR = _chunkV7CC7RZ6cjs.TOOL_NAMESPACE_SEPARATOR; exports.ToolRegistry = _chunkV7CC7RZ6cjs.ToolRegistry; exports.ToolRegistryError = _chunkV7CC7RZ6cjs.ToolRegistryError; exports.createCanvasComponentToolProvider = createCanvasComponentToolProvider; exports.createEditorMcpToolProvider = createEditorMcpToolProvider; exports.createRichTextToolProvider = createRichTextToolProvider; exports.createSpreadsheetToolProvider = createSpreadsheetToolProvider; exports.createToolRegistry = _chunkV7CC7RZ6cjs.createToolRegistry; exports.normalizeSide = normalizeSide; exports.planAgentCommand = planAgentCommand; exports.planToolCall = planToolCall; exports.toToolResult = _chunkV7CC7RZ6cjs.toToolResult; exports.toolCallToAgentCommand = toolCallToAgentCommand; exports.validateJsonSchema = _chunkI6BZB5ZHcjs.validateJsonSchema;
1264
+
1265
+
1266
+
1267
+
1268
+
1269
+
1270
+
1271
+
1272
+
1273
+
1274
+
1275
+
1276
+
1277
+
1278
+
1279
+
1280
+
1281
+
1282
+ exports.EDITOR_CANVAS_TOOLS = _chunkK2LVZ4FAcjs.EDITOR_CANVAS_TOOLS; exports.EDITOR_MCP_TOOLS = _chunkK2LVZ4FAcjs.EDITOR_MCP_TOOLS; exports.EDITOR_PROMPT_TOOLS = _chunkK2LVZ4FAcjs.EDITOR_PROMPT_TOOLS; exports.EDIT_OPERATION_REQUIRED_ARGUMENTS = _chunkK2LVZ4FAcjs.EDIT_OPERATION_REQUIRED_ARGUMENTS; exports.EXPORT_EXCLUDED_SELECTORS = _chunkK2LVZ4FAcjs.EXPORT_EXCLUDED_SELECTORS; exports.JSON_RPC_ERRORS = _chunkK2LVZ4FAcjs.JSON_RPC_ERRORS; exports.MCP_PROTOCOL_VERSIONS = _chunkK2LVZ4FAcjs.MCP_PROTOCOL_VERSIONS; exports.MCP_TOOL_CANVAS_ADD_NODE = _chunkK2LVZ4FAcjs.MCP_TOOL_CANVAS_ADD_NODE; exports.MCP_TOOL_CANVAS_CONNECT = _chunkK2LVZ4FAcjs.MCP_TOOL_CANVAS_CONNECT; exports.MCP_TOOL_CANVAS_HIGHLIGHT = _chunkK2LVZ4FAcjs.MCP_TOOL_CANVAS_HIGHLIGHT; exports.MCP_TOOL_CANVAS_LAYOUT = _chunkK2LVZ4FAcjs.MCP_TOOL_CANVAS_LAYOUT; exports.MCP_TOOL_CANVAS_REMOVE_NODES = _chunkK2LVZ4FAcjs.MCP_TOOL_CANVAS_REMOVE_NODES; exports.MCP_TOOL_CANVAS_SELECT = _chunkK2LVZ4FAcjs.MCP_TOOL_CANVAS_SELECT; exports.MCP_TOOL_CANVAS_UPDATE_NODE = _chunkK2LVZ4FAcjs.MCP_TOOL_CANVAS_UPDATE_NODE; exports.MCP_TOOL_EDIT_CANVAS = _chunkK2LVZ4FAcjs.MCP_TOOL_EDIT_CANVAS; exports.MCP_TOOL_EDIT_PROMPT = _chunkK2LVZ4FAcjs.MCP_TOOL_EDIT_PROMPT; exports.MCP_TOOL_GET_EDITOR_STATE = _chunkK2LVZ4FAcjs.MCP_TOOL_GET_EDITOR_STATE; exports.MCP_TOOL_PROMPT_INSERT_TEXT = _chunkK2LVZ4FAcjs.MCP_TOOL_PROMPT_INSERT_TEXT; exports.MCP_TOOL_PROMPT_REPLACE_RANGE = _chunkK2LVZ4FAcjs.MCP_TOOL_PROMPT_REPLACE_RANGE; exports.MCP_TOOL_PROMPT_SELECT = _chunkK2LVZ4FAcjs.MCP_TOOL_PROMPT_SELECT; exports.MCP_TOOL_PROMPT_SET_VARIABLE = _chunkK2LVZ4FAcjs.MCP_TOOL_PROMPT_SET_VARIABLE; exports.MCP_TOOL_VIEW_EDITOR = _chunkK2LVZ4FAcjs.MCP_TOOL_VIEW_EDITOR; exports.TOOL_NAMESPACE_SEPARATOR = _chunkK2LVZ4FAcjs.TOOL_NAMESPACE_SEPARATOR; exports.ToolRegistry = _chunkK2LVZ4FAcjs.ToolRegistry; exports.ToolRegistryError = _chunkK2LVZ4FAcjs.ToolRegistryError; exports.createCanvasComponentToolProvider = createCanvasComponentToolProvider; exports.createEditorMcpToolProvider = createEditorMcpToolProvider; exports.createMcpServer = _chunkK2LVZ4FAcjs.createMcpServer; exports.createRichTextToolProvider = createRichTextToolProvider; exports.createSpreadsheetToolProvider = createSpreadsheetToolProvider; exports.createToolRegistry = _chunkK2LVZ4FAcjs.createToolRegistry; exports.normalizeSide = normalizeSide; exports.planAgentCommand = planAgentCommand; exports.planToolCall = planToolCall; exports.toToolResult = _chunkK2LVZ4FAcjs.toToolResult; exports.toolCallToAgentCommand = toolCallToAgentCommand; exports.validateAgentCommand = validateAgentCommand; exports.validateJsonSchema = _chunkEFDCLENWcjs.validateJsonSchema;
780
1283
  //# sourceMappingURL=index.cjs.map