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