@pixerate/editor 0.47.0 → 0.48.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 (76) hide show
  1. package/dist/agent/index.cjs +246 -29
  2. package/dist/agent/index.cjs.map +1 -1
  3. package/dist/agent/index.d.cts +18 -6
  4. package/dist/agent/index.d.ts +18 -6
  5. package/dist/agent/index.js +226 -9
  6. package/dist/agent/index.js.map +1 -1
  7. package/dist/{builtins-xs7rK6ys.d.cts → builtins-1kqwLUnb.d.cts} +1 -1
  8. package/dist/{builtins-D2nMtw2W.d.ts → builtins-BKYlHH1s.d.ts} +1 -1
  9. package/dist/chart/index.cjs +214 -3541
  10. package/dist/chart/index.cjs.map +1 -1
  11. package/dist/chart/index.d.cts +4 -494
  12. package/dist/chart/index.d.ts +4 -494
  13. package/dist/chart/index.js +135 -3462
  14. package/dist/chart/index.js.map +1 -1
  15. package/dist/{chunk-5VXI5GED.js → chunk-2CJ3LPYQ.js} +3 -3
  16. package/dist/{chunk-ZFBBVGCI.js → chunk-EKYHKQPG.js} +243 -243
  17. package/dist/{chunk-ZFBBVGCI.js.map → chunk-EKYHKQPG.js.map} +1 -1
  18. package/dist/chunk-HXUL3LS7.js +113 -0
  19. package/dist/chunk-HXUL3LS7.js.map +1 -0
  20. package/dist/{chunk-REAGGLXS.js → chunk-JQ3BB3E6.js} +2 -2
  21. package/dist/chunk-LTUM52X6.js +4074 -0
  22. package/dist/chunk-LTUM52X6.js.map +1 -0
  23. package/dist/{chunk-J3R2OWOE.cjs → chunk-MUCYWI6W.cjs} +608 -15
  24. package/dist/chunk-MUCYWI6W.cjs.map +1 -0
  25. package/dist/chunk-PIMCHMZE.cjs +521 -0
  26. package/dist/chunk-PIMCHMZE.cjs.map +1 -0
  27. package/dist/{chunk-TK2XZK6Z.js → chunk-PKBWLEL7.js} +594 -1
  28. package/dist/chunk-PKBWLEL7.js.map +1 -0
  29. package/dist/chunk-PRSJJZBS.cjs +4074 -0
  30. package/dist/chunk-PRSJJZBS.cjs.map +1 -0
  31. package/dist/chunk-U6IZKC7B.cjs +113 -0
  32. package/dist/chunk-U6IZKC7B.cjs.map +1 -0
  33. package/dist/{chunk-SQC26VQV.cjs → chunk-UN33YOXW.cjs} +191 -191
  34. package/dist/{chunk-SQC26VQV.cjs.map → chunk-UN33YOXW.cjs.map} +1 -1
  35. package/dist/{chunk-PQFAHT5O.js → chunk-VKPEPWKZ.js} +27 -94
  36. package/dist/chunk-VKPEPWKZ.js.map +1 -0
  37. package/dist/{chunk-H4PICYNL.cjs → chunk-WXEHCVJQ.cjs} +113 -180
  38. package/dist/chunk-WXEHCVJQ.cjs.map +1 -0
  39. package/dist/{chunk-LYGEEDNR.cjs → chunk-XP5IUZUO.cjs} +242 -242
  40. package/dist/chunk-XP5IUZUO.cjs.map +1 -0
  41. package/dist/{chunk-C3NWJE3K.js → chunk-XUUD43OV.js} +11 -672
  42. package/dist/chunk-XUUD43OV.js.map +1 -0
  43. package/dist/{chunk-BBRK6MOI.cjs → chunk-YU4WQE5M.cjs} +100 -100
  44. package/dist/{chunk-BBRK6MOI.cjs.map → chunk-YU4WQE5M.cjs.map} +1 -1
  45. package/dist/commands/index.d.cts +1 -1
  46. package/dist/commands/index.d.ts +1 -1
  47. package/dist/controller-ChjCCMLl.d.cts +822 -0
  48. package/dist/controller-DtbEo3om.d.ts +822 -0
  49. package/dist/extensions/index.cjs +32 -4
  50. package/dist/extensions/index.cjs.map +1 -1
  51. package/dist/extensions/index.d.cts +4 -2
  52. package/dist/extensions/index.d.ts +4 -2
  53. package/dist/extensions/index.js +31 -3
  54. package/dist/{index-QrqMmZ75.d.cts → index-DoHqT1mq.d.cts} +203 -7
  55. package/dist/{index-CSUCQYAH.d.ts → index-YLZ0fKqE.d.ts} +203 -7
  56. package/dist/index.cjs +37 -12
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.d.cts +9 -7
  59. package/dist/index.d.ts +9 -7
  60. package/dist/index.js +31 -6
  61. package/dist/index.js.map +1 -1
  62. package/dist/spreadsheet/index.cjs +4 -4
  63. package/dist/spreadsheet/index.js +3 -3
  64. package/package.json +1 -1
  65. package/dist/chunk-C3NWJE3K.js.map +0 -1
  66. package/dist/chunk-H4PICYNL.cjs.map +0 -1
  67. package/dist/chunk-J3R2OWOE.cjs.map +0 -1
  68. package/dist/chunk-LYGEEDNR.cjs.map +0 -1
  69. package/dist/chunk-NEOO6QJD.cjs +0 -1182
  70. package/dist/chunk-NEOO6QJD.cjs.map +0 -1
  71. package/dist/chunk-PQFAHT5O.js.map +0 -1
  72. package/dist/chunk-TK2XZK6Z.js.map +0 -1
  73. package/dist/types-BVqWm3d1.d.cts +0 -320
  74. package/dist/types-BVqWm3d1.d.ts +0 -320
  75. /package/dist/{chunk-5VXI5GED.js.map → chunk-2CJ3LPYQ.js.map} +0 -0
  76. /package/dist/{chunk-REAGGLXS.js.map → chunk-JQ3BB3E6.js.map} +0 -0
@@ -2,6 +2,11 @@
2
2
 
3
3
 
4
4
 
5
+ var _chunkU6IZKC7Bcjs = require('../chunk-U6IZKC7B.cjs');
6
+
7
+
8
+
9
+
5
10
 
6
11
 
7
12
 
@@ -42,7 +47,17 @@ var _chunkRIWPYSKUcjs = require('../chunk-RIWPYSKU.cjs');
42
47
 
43
48
 
44
49
 
45
- var _chunkJ3R2OWOEcjs = require('../chunk-J3R2OWOE.cjs');
50
+
51
+
52
+
53
+
54
+
55
+ var _chunkMUCYWI6Wcjs = require('../chunk-MUCYWI6W.cjs');
56
+
57
+
58
+
59
+
60
+ var _chunkPRSJJZBScjs = require('../chunk-PRSJJZBS.cjs');
46
61
 
47
62
 
48
63
 
@@ -50,12 +65,14 @@ var _chunkJ3R2OWOEcjs = require('../chunk-J3R2OWOE.cjs');
50
65
  var _chunk66IMF6ODcjs = require('../chunk-66IMF6OD.cjs');
51
66
  require('../chunk-BVP3TSLH.cjs');
52
67
  require('../chunk-IFHKKVXH.cjs');
53
- require('../chunk-SQC26VQV.cjs');
68
+ require('../chunk-UN33YOXW.cjs');
54
69
 
55
70
 
56
71
 
57
72
 
58
- var _chunkLYGEEDNRcjs = require('../chunk-LYGEEDNR.cjs');
73
+ var _chunkXP5IUZUOcjs = require('../chunk-XP5IUZUO.cjs');
74
+ require('../chunk-TNNJXF46.cjs');
75
+ require('../chunk-QKLRAA4T.cjs');
59
76
 
60
77
 
61
78
 
@@ -387,6 +404,204 @@ function planToolCall(name, args, snapshot, options) {
387
404
 
388
405
  // src/agent/providers.ts
389
406
  var _state = require('@tiptap/pm/state');
407
+
408
+ // src/agent/documentChartTools.ts
409
+ var _history = require('@tiptap/pm/history');
410
+ var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
411
+ var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
412
+ var WRITE_IDEMPOTENT = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
413
+ var SIZE_WIDTH = {
414
+ type: ["number", "null"],
415
+ minimum: 50,
416
+ maximum: 4096,
417
+ description: "Width in pixels, or null to fill the line (default null)."
418
+ };
419
+ var SIZE_HEIGHT = { type: "number", minimum: 50, maximum: 4096, description: "Height in pixels (default 320)." };
420
+ var SPEC_PROPERTIES = {
421
+ ..._chunkU6IZKC7Bcjs.CHART_UPDATE_PROPERTIES,
422
+ categories: { type: "array", items: { type: "string" }, description: "Category labels in order (x axis labels, or pie slices)." },
423
+ series: {
424
+ type: "array",
425
+ description: "The series, each with one value per category (padded with gaps).",
426
+ items: {
427
+ type: "object",
428
+ properties: { id: { type: "string", description: "Stable id (default: from the name)." }, ..._chunkU6IZKC7Bcjs.SERIES_PROPS },
429
+ required: ["name", "values"],
430
+ additionalProperties: false
431
+ }
432
+ }
433
+ };
434
+ function cleanSeries(series) {
435
+ if (!Array.isArray(series)) return series;
436
+ return series.map((s) => s && typeof s === "object" ? Object.fromEntries(Object.entries(s).filter(([, v]) => v !== null)) : s);
437
+ }
438
+ function checkedSpec(input) {
439
+ const { spec, issues } = _chunkPRSJJZBScjs.normalizeChartSpec.call(void 0, { ...input, ...input.series !== void 0 ? { series: cleanSeries(input.series) } : {} });
440
+ if (issues.length) throw new Error(`The chart was not changed: ${issues.map((i) => i.message).join(" ")}`);
441
+ return spec;
442
+ }
443
+ function describe(chart, includeSpec) {
444
+ const { spec, node } = chart;
445
+ return {
446
+ id: chart.id,
447
+ pos: chart.pos,
448
+ type: spec.type,
449
+ title: spec.title,
450
+ categories: spec.categories,
451
+ series: spec.series.map((s) => ({ id: s.id, name: s.name })),
452
+ width: _nullishCoalesce(node.attrs.width, () => ( null)),
453
+ height: node.attrs.height,
454
+ description: _chunkPRSJJZBScjs.describeChart.call(void 0, spec),
455
+ ...includeSpec ? { spec } : {}
456
+ };
457
+ }
458
+ function sparklines(doc) {
459
+ const found = [];
460
+ doc.descendants((node, pos) => {
461
+ if (node.type.name === "sparkline") found.push({ pos, kind: node.attrs.kind, values: node.attrs.values, label: _chunkMUCYWI6Wcjs.sparklineLabel.call(void 0, node) });
462
+ });
463
+ return found;
464
+ }
465
+ function checkPosition(editor, at) {
466
+ const size = editor.state.doc.content.size;
467
+ if (at !== void 0 && at > size) throw new Error(`Position ${at} is outside the document (size ${size}).`);
468
+ }
469
+ function createDocumentChartTools(editor) {
470
+ const chartType = () => editor().schema.nodes.chart;
471
+ const findChart = (args) => {
472
+ const charts = _chunkMUCYWI6Wcjs.getDocumentCharts.call(void 0, editor().state.doc);
473
+ const list = charts.map((c) => `"${c.id}" at ${c.pos}`).join(", ") || "none; add one with insert_chart";
474
+ if (args.chartId !== void 0) {
475
+ const chart = charts.find((c) => c.id === args.chartId);
476
+ if (!chart) throw new Error(`There is no chart "${args.chartId}" in the document. Charts: ${list}.`);
477
+ if (args.pos !== void 0 && args.pos !== chart.pos) throw new Error(`Chart "${args.chartId}" is at ${chart.pos}, not ${args.pos}; pass one of chartId or pos.`);
478
+ return chart;
479
+ }
480
+ if (args.pos !== void 0) {
481
+ const chart = charts.find((c) => c.pos === args.pos);
482
+ if (!chart) throw new Error(`There is no chart at position ${args.pos}. Charts: ${list}.`);
483
+ return chart;
484
+ }
485
+ throw new Error(`Pass chartId or pos (from list_document_charts). Charts: ${list}.`);
486
+ };
487
+ const listCharts = {
488
+ name: "list_document_charts",
489
+ title: "List charts in the document",
490
+ description: "Lists the charts in the document in order: id, document position, type, title, categories, series (ids and names), size in pixels and a plain-language description of the data. Also lists inline sparklines (position, kind, values). Pass the id or position to update_chart_in_document.",
491
+ inputSchema: {
492
+ type: "object",
493
+ properties: { includeSpec: { type: "boolean", description: "Also return each chart's full spec (default false)." } },
494
+ additionalProperties: false
495
+ },
496
+ annotations: { title: "List charts in the document", ...READ },
497
+ handler: ({ includeSpec = false }) => {
498
+ const doc = editor().state.doc;
499
+ return { charts: _chunkMUCYWI6Wcjs.getDocumentCharts.call(void 0, doc).map((c) => describe(c, includeSpec)), sparklines: editor().schema.nodes.sparkline ? sparklines(doc) : [] };
500
+ }
501
+ };
502
+ const insertChart = {
503
+ name: "insert_chart",
504
+ title: "Insert a chart",
505
+ description: "Inserts a chart block at a document position (or the cursor), as one undo step. Give the categories and series (one value per category) and any presentation fields (type, titles, axes, legend, stacking, palette, \u2026). Invalid fields change nothing and come back as sentences. Returns the new chart's id, position and stored spec.",
506
+ inputSchema: {
507
+ type: "object",
508
+ properties: {
509
+ spec: { type: "object", description: "The chart: categories and series, plus optional presentation fields.", properties: SPEC_PROPERTIES, required: ["categories", "series"], additionalProperties: false },
510
+ at: { type: "integer", minimum: 0, description: "Document position (default: the selection). A position inside a paragraph splits it." },
511
+ width: SIZE_WIDTH,
512
+ height: SIZE_HEIGHT
513
+ },
514
+ required: ["spec"],
515
+ additionalProperties: false
516
+ },
517
+ annotations: { title: "Insert a chart", ...WRITE },
518
+ handler: ({ spec: input, at, width = null, height }) => {
519
+ const ed = editor();
520
+ checkPosition(ed, at);
521
+ const spec = checkedSpec(input);
522
+ const id = _nullishCoalesce(_optionalChain([ed, 'access', _16 => _16.extensionManager, 'access', _17 => _17.extensions, 'access', _18 => _18.find, 'call', _19 => _19((e) => e.name === "chart"), 'optionalAccess', _20 => _20.options, 'access', _21 => _21.generateId, 'optionalCall', _22 => _22()]), () => ( `chart-${Date.now().toString(36)}`));
523
+ const node = { type: "chart", attrs: { id, spec, width, ...height !== void 0 ? { height } : {} } };
524
+ const chain = ed.chain().command(({ tr }) => (_history.closeHistory.call(void 0, tr), true));
525
+ const ok = (at !== void 0 ? chain.insertContentAt(at, node) : chain.insertContent(node)).run();
526
+ const chart = _chunkMUCYWI6Wcjs.getDocumentCharts.call(void 0, ed.state.doc).find((c) => c.id === id);
527
+ if (!ok || !chart) throw new Error(`A chart cannot go at ${_nullishCoalesce(at, () => ( ed.state.selection.from))}; pass a position between blocks or inside a paragraph.`);
528
+ return { id: chart.id, pos: chart.pos, spec: chart.spec, width: chart.node.attrs.width, height: chart.node.attrs.height };
529
+ }
530
+ };
531
+ const updateChart = {
532
+ name: "update_chart_in_document",
533
+ title: "Change a chart in the document",
534
+ description: "Changes one chart (by id or position from list_document_charts) as one undo step: data (categories, series \u2014 given series replace all) and / or presentation fields, which merge into the current spec (axes and legend field by field), plus its size. All-or-nothing: invalid values change nothing and come back as sentences. Returns the chart's id, position and new spec.",
535
+ inputSchema: {
536
+ type: "object",
537
+ properties: {
538
+ chartId: { type: "string", description: "Chart id from list_document_charts." },
539
+ pos: { type: "integer", minimum: 0, description: "Document position of the chart (from list_document_charts), instead of chartId." },
540
+ changes: { type: "object", description: "Fields to change; omitted fields keep their value.", properties: SPEC_PROPERTIES, additionalProperties: false },
541
+ width: SIZE_WIDTH,
542
+ height: { ...SIZE_HEIGHT, description: "Height in pixels (default: unchanged)." }
543
+ },
544
+ additionalProperties: false
545
+ },
546
+ annotations: { title: "Change a chart in the document", ...WRITE_IDEMPOTENT },
547
+ handler: ({ chartId, pos, changes, width, height }) => {
548
+ const ed = editor();
549
+ const chart = findChart({ chartId, pos });
550
+ if (!changes && width === void 0 && height === void 0) throw new Error('Nothing to change: pass changes, width or height, e.g. {"changes": {"type": "line"}}.');
551
+ const s = chart.spec;
552
+ const patch = _nullishCoalesce(changes, () => ( {}));
553
+ const spec = checkedSpec({
554
+ ...s,
555
+ ...patch,
556
+ xAxis: patch.xAxis ? { ...s.xAxis, ...patch.xAxis } : s.xAxis,
557
+ yAxis: patch.yAxis ? { ...s.yAxis, ...patch.yAxis } : s.yAxis,
558
+ yAxis2: patch.yAxis2 ? { ...s.yAxis2, ...patch.yAxis2 } : s.yAxis2,
559
+ legend: patch.legend ? { ...s.legend, ...patch.legend } : s.legend
560
+ });
561
+ const attrs = { ...chart.node.attrs, spec, ...width !== void 0 ? { width } : {}, ...height !== void 0 ? { height } : {} };
562
+ ed.view.dispatch(_history.closeHistory.call(void 0, ed.state.tr.setNodeMarkup(chart.pos, void 0, attrs)));
563
+ return { id: chart.id, pos: chart.pos, spec, width: attrs.width, height: attrs.height };
564
+ }
565
+ };
566
+ const insertSparkline = {
567
+ name: "insert_sparkline",
568
+ title: "Insert a sparkline",
569
+ description: "Inserts a word-sized chart into the text at a document position (or the cursor), as one undo step. Returns its position and stored values.",
570
+ inputSchema: {
571
+ type: "object",
572
+ properties: {
573
+ values: { type: "array", items: _chunkU6IZKC7Bcjs.VALUE, minItems: 1, maxItems: _chunkMUCYWI6Wcjs.MAX_SPARKLINE_VALUES, description: "Values in order (null for a gap)." },
574
+ kind: { type: "string", enum: [..._chunkMUCYWI6Wcjs.SPARKLINE_KINDS], description: "line (default), column, or win-loss (sign only)." },
575
+ at: { type: "integer", minimum: 0, description: "Document position inside a paragraph (default: the selection)." },
576
+ width: { type: "number", minimum: 4, maximum: 1e3, description: "Width in pixels (default 80)." },
577
+ height: { type: "number", minimum: 4, maximum: 200, description: "Height in pixels (default 18)." },
578
+ color: { type: "string", description: "CSS colour (default: the first palette colour)." },
579
+ label: { type: "string", description: 'Accessible label (default: "Trend from <first> to <last>").' }
580
+ },
581
+ required: ["values"],
582
+ additionalProperties: false
583
+ },
584
+ annotations: { title: "Insert a sparkline", ...WRITE },
585
+ handler: ({ values, kind = "line", at, width = 80, height = 18, color = null, label = null }) => {
586
+ const ed = editor();
587
+ checkPosition(ed, at);
588
+ const parsed = values.map((v) => _chunkPRSJJZBScjs.parseChartValue.call(void 0, v));
589
+ const bad = parsed.findIndex((v) => v === void 0);
590
+ if (bad >= 0) throw new Error(`values[${bad}] ("${String(values[bad])}") is not a number; pass numbers, numeric text or null. Nothing was inserted.`);
591
+ const pos = _nullishCoalesce(at, () => ( ed.state.selection.from));
592
+ if (!ed.state.doc.resolve(pos).parent.inlineContent) throw new Error(`Position ${pos} is between blocks; a sparkline goes inside a paragraph (use a position from get_text {blocks: true}).`);
593
+ const stored = _chunkMUCYWI6Wcjs.normalizeSparklineValues.call(void 0, parsed);
594
+ ed.chain().command(({ tr }) => (_history.closeHistory.call(void 0, tr), true)).insertContentAt(pos, { type: "sparkline", attrs: { values: stored, kind, width, height, color, label } }).run();
595
+ return { pos, kind, values: stored };
596
+ }
597
+ };
598
+ return {
599
+ read: () => chartType() ? [listCharts] : [],
600
+ write: () => chartType() ? [insertChart, updateChart, ...editor().schema.nodes.sparkline ? [insertSparkline] : []] : []
601
+ };
602
+ }
603
+
604
+ // src/agent/providers.ts
390
605
  var toEditor = (target) => "commands" in target ? target : target.editor;
391
606
  function replaceWithText(editor, from, to, text) {
392
607
  const { state, view } = editor;
@@ -426,12 +641,13 @@ function findMatches(editor, query, args, replacement) {
426
641
  wholeWord: !!args.wholeWord,
427
642
  ...args.regex ? { regex: true } : { literal: true }
428
643
  };
429
- const result = _chunkJ3R2OWOEcjs.searchDocument.call(void 0, editor.state.doc, query, options, replacement !== void 0 ? { replacement } : {});
644
+ const result = _chunkMUCYWI6Wcjs.searchDocument.call(void 0, editor.state.doc, query, options, replacement !== void 0 ? { replacement } : {});
430
645
  if (result.error) throw new Error(`Invalid search pattern: ${result.error.message}`);
431
646
  return { matches: result.matches, truncated: result.truncated };
432
647
  }
433
648
  function createRichTextToolProvider(target, options) {
434
649
  const editor = () => toEditor(target);
650
+ const charts = createDocumentChartTools(editor);
435
651
  const getText = {
436
652
  name: "get_text",
437
653
  title: "Get document text",
@@ -577,7 +793,7 @@ function createRichTextToolProvider(target, options) {
577
793
  replacement: String(replace).replace(/\r\n?|\n/g, "\r")
578
794
  }));
579
795
  const tr = ed.state.tr;
580
- const ends = _chunkJ3R2OWOEcjs.applyReplacements.call(void 0, tr, chosen);
796
+ const ends = _chunkMUCYWI6Wcjs.applyReplacements.call(void 0, tr, chosen);
581
797
  ed.view.dispatch(tr.scrollIntoView());
582
798
  return {
583
799
  replaced: chosen.length,
@@ -674,7 +890,7 @@ function createRichTextToolProvider(target, options) {
674
890
  inputSchema: {
675
891
  type: "object",
676
892
  properties: {
677
- operation: { type: "string", enum: _chunkJ3R2OWOEcjs.TABLE_ACTIONS.map((a) => a.action), description: "Table operation." },
893
+ operation: { type: "string", enum: _chunkMUCYWI6Wcjs.TABLE_ACTIONS.map((a) => a.action), description: "Table operation." },
678
894
  at: { type: "integer", minimum: 0, description: "Document position to place the cursor first (e.g. inside a cell)." },
679
895
  rows: { type: "integer", minimum: 1, maximum: 100, description: "insertTable: rows (default 3)." },
680
896
  cols: { type: "integer", minimum: 1, maximum: 50, description: "insertTable: columns (default 3)." },
@@ -704,10 +920,10 @@ function createRichTextToolProvider(target, options) {
704
920
  ed.view.dispatch(ed.state.tr.setSelection(_state.TextSelection.near(ed.state.doc.resolve(at))));
705
921
  }
706
922
  const action = operation;
707
- const state = _chunkJ3R2OWOEcjs.getTableActionState.call(void 0, ed, action, params);
923
+ const state = _chunkMUCYWI6Wcjs.getTableActionState.call(void 0, ed, action, params);
708
924
  if (state !== true) throw new Error(state);
709
- _chunkJ3R2OWOEcjs.runTableAction.call(void 0, ed, action, params);
710
- const table = _chunkJ3R2OWOEcjs.getTableState.call(void 0, ed);
925
+ _chunkMUCYWI6Wcjs.runTableAction.call(void 0, ed, action, params);
926
+ const table = _chunkMUCYWI6Wcjs.getTableState.call(void 0, ed);
711
927
  return {
712
928
  operation,
713
929
  table: table.inTable ? { rows: table.rows, columns: table.columns, row: table.row, column: table.column } : null,
@@ -721,9 +937,9 @@ function createRichTextToolProvider(target, options) {
721
937
  tools: () => {
722
938
  const ed = editor();
723
939
  if (!ed || ed.isDestroyed) return [];
724
- if (!ed.isEditable) return [getText, findText];
940
+ if (!ed.isEditable) return [getText, findText, ...charts.read()];
725
941
  const tools = [getText, findText, insertText, replaceText, replaceRange, replaceSelection, setSelection];
726
- return _chunkJ3R2OWOEcjs.isTableEnabled.call(void 0, ed) ? [...tools, editTable] : tools;
942
+ return [...tools, ..._chunkMUCYWI6Wcjs.isTableEnabled.call(void 0, ed) ? [editTable] : [], ...charts.read(), ...charts.write()];
727
943
  },
728
944
  subscribe: (notify) => {
729
945
  const ed = editor();
@@ -740,12 +956,12 @@ var CELL_REF_REGEX = /^\$?([A-Za-z]{1,3})\$?(\d{1,7})$/;
740
956
  function parseCell(ref) {
741
957
  const match = CELL_REF_REGEX.exec(ref.trim());
742
958
  if (!match) throw new Error(`Invalid cell reference "${ref}". Use A1 notation, e.g. "B3".`);
743
- return { col: _chunkLYGEEDNRcjs.colNameToIndex.call(void 0, match[1].toUpperCase()), row: parseInt(match[2], 10) - 1 };
959
+ return { col: _chunkXP5IUZUOcjs.colNameToIndex.call(void 0, match[1].toUpperCase()), row: parseInt(match[2], 10) - 1 };
744
960
  }
745
961
  var COLUMN_REGEX = /^[A-Za-z]{1,3}$/;
746
962
  function parseColumn(name) {
747
963
  if (!COLUMN_REGEX.test(name.trim())) throw new Error(`Invalid column "${name}". Use a letter name, e.g. "C".`);
748
- return _chunkLYGEEDNRcjs.colNameToIndex.call(void 0, name.trim().toUpperCase());
964
+ return _chunkXP5IUZUOcjs.colNameToIndex.call(void 0, name.trim().toUpperCase());
749
965
  }
750
966
  var CELL_INPUT = { type: ["string", "number", "boolean", "null"] };
751
967
  function createSpreadsheetToolProvider(controller, options) {
@@ -794,14 +1010,14 @@ function createSpreadsheetToolProvider(controller, options) {
794
1010
  const cell = controller.getCell(found.rowDef.id, found.colDef.id);
795
1011
  valueRow.push(_nullishCoalesce(cell.error, () => ( cell.value)));
796
1012
  rawRow.push(cell.raw);
797
- const error = _nullishCoalesce(cell.error, () => ( (_chunkLYGEEDNRcjs.isFormulaError.call(void 0, cell.value) ? cell.value : void 0)));
798
- if (error) errors.push({ cell: `${_chunkLYGEEDNRcjs.indexToColName.call(void 0, c)}${r + 1}`, error });
1013
+ const error = _nullishCoalesce(cell.error, () => ( (_chunkXP5IUZUOcjs.isFormulaError.call(void 0, cell.value) ? cell.value : void 0)));
1014
+ if (error) errors.push({ cell: `${_chunkXP5IUZUOcjs.indexToColName.call(void 0, c)}${r + 1}`, error });
799
1015
  }
800
1016
  values.push(valueRow);
801
1017
  raw.push(rawRow);
802
1018
  }
803
1019
  return {
804
- range: values.length && values[0].length ? `${_chunkLYGEEDNRcjs.indexToColName.call(void 0, c0)}${r0 + 1}:${_chunkLYGEEDNRcjs.indexToColName.call(void 0, c1)}${r1 + 1}` : null,
1020
+ range: values.length && values[0].length ? `${_chunkXP5IUZUOcjs.indexToColName.call(void 0, c0)}${r0 + 1}:${_chunkXP5IUZUOcjs.indexToColName.call(void 0, c1)}${r1 + 1}` : null,
805
1021
  values,
806
1022
  raw,
807
1023
  errors,
@@ -880,7 +1096,7 @@ function createSpreadsheetToolProvider(controller, options) {
880
1096
  const readOnly = [];
881
1097
  rows.forEach(
882
1098
  (line, r) => line.forEach((_, c) => {
883
- if (isReadOnly(row + r, col + c)) readOnly.push(`${_chunkLYGEEDNRcjs.indexToColName.call(void 0, col + c)}${row + r + 1}`);
1099
+ if (isReadOnly(row + r, col + c)) readOnly.push(`${_chunkXP5IUZUOcjs.indexToColName.call(void 0, col + c)}${row + r + 1}`);
884
1100
  })
885
1101
  );
886
1102
  if (readOnly.length) throw new Error(`Read-only cells: ${readOnly.slice(0, 20).join(", ")}. Nothing was written.`);
@@ -889,19 +1105,19 @@ function createSpreadsheetToolProvider(controller, options) {
889
1105
  { startRow: row, startCol: col }
890
1106
  );
891
1107
  const width = Math.max(0, ...rows.map((line) => line.length));
892
- const end = `${_chunkLYGEEDNRcjs.indexToColName.call(void 0, col + Math.max(width, 1) - 1)}${row + rows.length}`;
1108
+ const end = `${_chunkXP5IUZUOcjs.indexToColName.call(void 0, col + Math.max(width, 1) - 1)}${row + rows.length}`;
893
1109
  const errors = [];
894
1110
  rows.forEach(
895
1111
  (line, r) => line.forEach((_, c) => {
896
1112
  const found = lookup(row + r, col + c);
897
1113
  if (!found) return;
898
1114
  const cell = controller.getCell(found.rowDef.id, found.colDef.id);
899
- const error = _nullishCoalesce(cell.error, () => ( (_chunkLYGEEDNRcjs.isFormulaError.call(void 0, cell.value) ? cell.value : void 0)));
900
- if (error) errors.push({ cell: `${_chunkLYGEEDNRcjs.indexToColName.call(void 0, col + c)}${row + r + 1}`, error: String(error) });
1115
+ const error = _nullishCoalesce(cell.error, () => ( (_chunkXP5IUZUOcjs.isFormulaError.call(void 0, cell.value) ? cell.value : void 0)));
1116
+ if (error) errors.push({ cell: `${_chunkXP5IUZUOcjs.indexToColName.call(void 0, col + c)}${row + r + 1}`, error: String(error) });
901
1117
  })
902
1118
  );
903
1119
  return {
904
- range: `${_chunkLYGEEDNRcjs.indexToColName.call(void 0, col)}${row + 1}:${end}`,
1120
+ range: `${_chunkXP5IUZUOcjs.indexToColName.call(void 0, col)}${row + 1}:${end}`,
905
1121
  written: rows.reduce((n, line) => n + line.length, 0),
906
1122
  errors,
907
1123
  sheet: { rows: controller.document.rows.length, columns: controller.document.columns.length }
@@ -957,7 +1173,7 @@ function createSpreadsheetToolProvider(controller, options) {
957
1173
  const index = parseColumn(before);
958
1174
  if (index > controller.document.columns.length) throw new Error(`Column ${before} is past the end of the sheet (${controller.document.columns.length} columns).`);
959
1175
  for (let i = 0; i < count; i++) controller.insertColumn(index);
960
- return { inserted: count, columns: `${_chunkLYGEEDNRcjs.indexToColName.call(void 0, index)}:${_chunkLYGEEDNRcjs.indexToColName.call(void 0, index + count - 1)}`, sheet: sheetSize() };
1176
+ return { inserted: count, columns: `${_chunkXP5IUZUOcjs.indexToColName.call(void 0, index)}:${_chunkXP5IUZUOcjs.indexToColName.call(void 0, index + count - 1)}`, sheet: sheetSize() };
961
1177
  }
962
1178
  );
963
1179
  const deleteColumns = structural(
@@ -985,7 +1201,7 @@ function missingArgumentsMessage(name, args) {
985
1201
  const required = _chunkXFYUFVAXcjs.EDIT_OPERATION_REQUIRED_ARGUMENTS[name][args.operation];
986
1202
  if (!required) return `Unknown operation "${args.operation}".`;
987
1203
  const missing = required.filter(
988
- (key) => key === "id" ? args.id === void 0 && _optionalChain([args, 'access', _16 => _16.node, 'optionalAccess', _17 => _17.id]) === void 0 : args[key] === void 0
1204
+ (key) => key === "id" ? args.id === void 0 && _optionalChain([args, 'access', _23 => _23.node, 'optionalAccess', _24 => _24.id]) === void 0 : args[key] === void 0
989
1205
  );
990
1206
  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).`;
991
1207
  }
@@ -1017,8 +1233,8 @@ function createEditorMcpToolProvider(options) {
1017
1233
  await options.applySteps(steps);
1018
1234
  return describeSteps(steps);
1019
1235
  };
1020
- const canvas = _nullishCoalesce(_optionalChain([options, 'access', _18 => _18.surfaces, 'optionalAccess', _19 => _19.canvas]), () => ( true));
1021
- const prompt = _nullishCoalesce(_optionalChain([options, 'access', _20 => _20.surfaces, 'optionalAccess', _21 => _21.prompt]), () => ( true));
1236
+ const canvas = _nullishCoalesce(_optionalChain([options, 'access', _25 => _25.surfaces, 'optionalAccess', _26 => _26.canvas]), () => ( true));
1237
+ const prompt = _nullishCoalesce(_optionalChain([options, 'access', _27 => _27.surfaces, 'optionalAccess', _28 => _28.prompt]), () => ( true));
1022
1238
  const editTools = options.toolStyle === "combined" ? [...canvas ? [_chunkXFYUFVAXcjs.MCP_TOOL_EDIT_CANVAS] : [], ...prompt ? [_chunkXFYUFVAXcjs.MCP_TOOL_EDIT_PROMPT] : []] : [...canvas ? _chunkXFYUFVAXcjs.EDITOR_CANVAS_TOOLS : [], ...prompt ? _chunkXFYUFVAXcjs.EDITOR_PROMPT_TOOLS : []];
1023
1239
  const tools = [
1024
1240
  {
@@ -1053,8 +1269,8 @@ var COMPONENT_ID = { type: "string", description: "Component or component set id
1053
1269
  var PARENT_ID = { type: "string", description: "Frame to place the instance in (default: the canvas root)." };
1054
1270
  var X = { type: "number", description: "X position (canvas coordinates, or relative to the parent frame)." };
1055
1271
  var Y = { type: "number", description: "Y position (canvas coordinates, or relative to the parent frame)." };
1056
- var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
1057
- var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
1272
+ var READ2 = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
1273
+ var WRITE2 = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
1058
1274
  var DESTRUCTIVE = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false };
1059
1275
  var TITLES = {
1060
1276
  list_components: "List components",
@@ -1088,7 +1304,7 @@ function createCanvasComponentToolProvider(controller, options = { id: "canvas-c
1088
1304
  inputSchema: { type: "object", properties, ...extra.required ? { required: extra.required } : {}, additionalProperties: false },
1089
1305
  annotations: {
1090
1306
  title: TITLES[name],
1091
- ...extra.readOnly ? READ : DESTRUCTIVE_TOOLS.has(name) ? DESTRUCTIVE : WRITE
1307
+ ...extra.readOnly ? READ2 : DESTRUCTIVE_TOOLS.has(name) ? DESTRUCTIVE : WRITE2
1092
1308
  },
1093
1309
  handler
1094
1310
  });
@@ -1280,5 +1496,6 @@ function createCanvasComponentToolProvider(controller, options = { id: "canvas-c
1280
1496
 
1281
1497
 
1282
1498
 
1283
- exports.EDITOR_CANVAS_TOOLS = _chunkXFYUFVAXcjs.EDITOR_CANVAS_TOOLS; exports.EDITOR_MCP_TOOLS = _chunkXFYUFVAXcjs.EDITOR_MCP_TOOLS; exports.EDITOR_PROMPT_TOOLS = _chunkXFYUFVAXcjs.EDITOR_PROMPT_TOOLS; exports.EDIT_OPERATION_REQUIRED_ARGUMENTS = _chunkXFYUFVAXcjs.EDIT_OPERATION_REQUIRED_ARGUMENTS; exports.EXPORT_EXCLUDED_SELECTORS = _chunkXFYUFVAXcjs.EXPORT_EXCLUDED_SELECTORS; exports.JSON_RPC_ERRORS = _chunkXFYUFVAXcjs.JSON_RPC_ERRORS; exports.MCP_PROTOCOL_VERSIONS = _chunkXFYUFVAXcjs.MCP_PROTOCOL_VERSIONS; exports.MCP_TOOL_CANVAS_ADD_NODE = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_ADD_NODE; exports.MCP_TOOL_CANVAS_CONNECT = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_CONNECT; exports.MCP_TOOL_CANVAS_HIGHLIGHT = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_HIGHLIGHT; exports.MCP_TOOL_CANVAS_LAYOUT = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_LAYOUT; exports.MCP_TOOL_CANVAS_REMOVE_NODES = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_REMOVE_NODES; exports.MCP_TOOL_CANVAS_SELECT = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_SELECT; exports.MCP_TOOL_CANVAS_UPDATE_NODE = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_UPDATE_NODE; exports.MCP_TOOL_EDIT_CANVAS = _chunkXFYUFVAXcjs.MCP_TOOL_EDIT_CANVAS; exports.MCP_TOOL_EDIT_PROMPT = _chunkXFYUFVAXcjs.MCP_TOOL_EDIT_PROMPT; exports.MCP_TOOL_GET_EDITOR_STATE = _chunkXFYUFVAXcjs.MCP_TOOL_GET_EDITOR_STATE; exports.MCP_TOOL_PROMPT_INSERT_TEXT = _chunkXFYUFVAXcjs.MCP_TOOL_PROMPT_INSERT_TEXT; exports.MCP_TOOL_PROMPT_REPLACE_RANGE = _chunkXFYUFVAXcjs.MCP_TOOL_PROMPT_REPLACE_RANGE; exports.MCP_TOOL_PROMPT_SELECT = _chunkXFYUFVAXcjs.MCP_TOOL_PROMPT_SELECT; exports.MCP_TOOL_PROMPT_SET_VARIABLE = _chunkXFYUFVAXcjs.MCP_TOOL_PROMPT_SET_VARIABLE; exports.MCP_TOOL_VIEW_EDITOR = _chunkXFYUFVAXcjs.MCP_TOOL_VIEW_EDITOR; exports.TOOL_NAMESPACE_SEPARATOR = _chunkXFYUFVAXcjs.TOOL_NAMESPACE_SEPARATOR; exports.ToolRegistry = _chunkXFYUFVAXcjs.ToolRegistry; exports.ToolRegistryError = _chunkXFYUFVAXcjs.ToolRegistryError; exports.createCanvasComponentToolProvider = createCanvasComponentToolProvider; exports.createEditorMcpToolProvider = createEditorMcpToolProvider; exports.createMcpServer = _chunkXFYUFVAXcjs.createMcpServer; exports.createRichTextToolProvider = createRichTextToolProvider; exports.createSpreadsheetToolProvider = createSpreadsheetToolProvider; exports.createToolRegistry = _chunkXFYUFVAXcjs.createToolRegistry; exports.normalizeSide = normalizeSide; exports.planAgentCommand = planAgentCommand; exports.planToolCall = planToolCall; exports.toToolResult = _chunkXFYUFVAXcjs.toToolResult; exports.toolCallToAgentCommand = toolCallToAgentCommand; exports.validateAgentCommand = validateAgentCommand; exports.validateJsonSchema = _chunkRIWPYSKUcjs.validateJsonSchema;
1499
+
1500
+ exports.EDITOR_CANVAS_TOOLS = _chunkXFYUFVAXcjs.EDITOR_CANVAS_TOOLS; exports.EDITOR_MCP_TOOLS = _chunkXFYUFVAXcjs.EDITOR_MCP_TOOLS; exports.EDITOR_PROMPT_TOOLS = _chunkXFYUFVAXcjs.EDITOR_PROMPT_TOOLS; exports.EDIT_OPERATION_REQUIRED_ARGUMENTS = _chunkXFYUFVAXcjs.EDIT_OPERATION_REQUIRED_ARGUMENTS; exports.EXPORT_EXCLUDED_SELECTORS = _chunkXFYUFVAXcjs.EXPORT_EXCLUDED_SELECTORS; exports.JSON_RPC_ERRORS = _chunkXFYUFVAXcjs.JSON_RPC_ERRORS; exports.MCP_PROTOCOL_VERSIONS = _chunkXFYUFVAXcjs.MCP_PROTOCOL_VERSIONS; exports.MCP_TOOL_CANVAS_ADD_NODE = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_ADD_NODE; exports.MCP_TOOL_CANVAS_CONNECT = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_CONNECT; exports.MCP_TOOL_CANVAS_HIGHLIGHT = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_HIGHLIGHT; exports.MCP_TOOL_CANVAS_LAYOUT = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_LAYOUT; exports.MCP_TOOL_CANVAS_REMOVE_NODES = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_REMOVE_NODES; exports.MCP_TOOL_CANVAS_SELECT = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_SELECT; exports.MCP_TOOL_CANVAS_UPDATE_NODE = _chunkXFYUFVAXcjs.MCP_TOOL_CANVAS_UPDATE_NODE; exports.MCP_TOOL_EDIT_CANVAS = _chunkXFYUFVAXcjs.MCP_TOOL_EDIT_CANVAS; exports.MCP_TOOL_EDIT_PROMPT = _chunkXFYUFVAXcjs.MCP_TOOL_EDIT_PROMPT; exports.MCP_TOOL_GET_EDITOR_STATE = _chunkXFYUFVAXcjs.MCP_TOOL_GET_EDITOR_STATE; exports.MCP_TOOL_PROMPT_INSERT_TEXT = _chunkXFYUFVAXcjs.MCP_TOOL_PROMPT_INSERT_TEXT; exports.MCP_TOOL_PROMPT_REPLACE_RANGE = _chunkXFYUFVAXcjs.MCP_TOOL_PROMPT_REPLACE_RANGE; exports.MCP_TOOL_PROMPT_SELECT = _chunkXFYUFVAXcjs.MCP_TOOL_PROMPT_SELECT; exports.MCP_TOOL_PROMPT_SET_VARIABLE = _chunkXFYUFVAXcjs.MCP_TOOL_PROMPT_SET_VARIABLE; exports.MCP_TOOL_VIEW_EDITOR = _chunkXFYUFVAXcjs.MCP_TOOL_VIEW_EDITOR; exports.TOOL_NAMESPACE_SEPARATOR = _chunkXFYUFVAXcjs.TOOL_NAMESPACE_SEPARATOR; exports.ToolRegistry = _chunkXFYUFVAXcjs.ToolRegistry; exports.ToolRegistryError = _chunkXFYUFVAXcjs.ToolRegistryError; exports.createCanvasComponentToolProvider = createCanvasComponentToolProvider; exports.createDocumentChartTools = createDocumentChartTools; exports.createEditorMcpToolProvider = createEditorMcpToolProvider; exports.createMcpServer = _chunkXFYUFVAXcjs.createMcpServer; exports.createRichTextToolProvider = createRichTextToolProvider; exports.createSpreadsheetToolProvider = createSpreadsheetToolProvider; exports.createToolRegistry = _chunkXFYUFVAXcjs.createToolRegistry; exports.normalizeSide = normalizeSide; exports.planAgentCommand = planAgentCommand; exports.planToolCall = planToolCall; exports.toToolResult = _chunkXFYUFVAXcjs.toToolResult; exports.toolCallToAgentCommand = toolCallToAgentCommand; exports.validateAgentCommand = validateAgentCommand; exports.validateJsonSchema = _chunkRIWPYSKUcjs.validateJsonSchema;
1284
1501
  //# sourceMappingURL=index.cjs.map