@pixerate/editor 0.142.1 → 0.144.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 +80 -38
- package/dist/agent/index.js +56 -14
- package/dist/agent/planner.d.cts +7 -2
- package/dist/agent/planner.d.ts +7 -2
- package/dist/canvas/index.cjs +103 -101
- package/dist/canvas/index.js +3 -1
- package/dist/canvas/layout.d.cts +15 -2
- package/dist/canvas/layout.d.ts +15 -2
- package/dist/{chunk-XH32BATE.cjs → chunk-AG2EXVCR.cjs} +2 -2
- package/dist/{chunk-X2HQP7DF.cjs → chunk-D2ENR3LB.cjs} +43 -4
- package/dist/{chunk-UBRYHNRU.cjs → chunk-EL4PSKFT.cjs} +46 -4
- package/dist/{chunk-54GVEVXS.js → chunk-HUHBJWTD.js} +43 -4
- package/dist/{chunk-Y6SGC6KO.js → chunk-SA37RU2O.js} +1 -1
- package/dist/{chunk-DW4CV5H4.js → chunk-U4VE4UI2.js} +45 -3
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.js +1 -1
- package/dist/tools/index.cjs +5 -3
- package/dist/tools/index.js +4 -2
- package/dist/tools/playback.d.cts +18 -4
- package/dist/tools/playback.d.ts +18 -4
- package/package.json +1 -1
- package/skills/pixerate-agent-tools/SKILL.md +7 -1
package/dist/agent/index.cjs
CHANGED
|
@@ -12,13 +12,14 @@ var _chunkGLQQ2VILcjs = require('../chunk-GLQQ2VIL.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
var _chunkEL4PSKFTcjs = require('../chunk-EL4PSKFT.cjs');
|
|
16
17
|
require('../chunk-4EFNS2HV.cjs');
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
|
|
21
|
-
var
|
|
22
|
+
var _chunkAG2EXVCRcjs = require('../chunk-AG2EXVCR.cjs');
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
|
|
@@ -53,7 +54,8 @@ var _chunkY4BWZB6Jcjs = require('../chunk-Y4BWZB6J.cjs');
|
|
|
53
54
|
|
|
54
55
|
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
|
|
58
|
+
var _chunkD2ENR3LBcjs = require('../chunk-D2ENR3LB.cjs');
|
|
57
59
|
|
|
58
60
|
|
|
59
61
|
|
|
@@ -184,20 +186,33 @@ function planAgentCommand(command, snapshot, options = {}) {
|
|
|
184
186
|
let pos = command.node.position;
|
|
185
187
|
const anchorId = command.nearNodeId && nodes.some((n) => n.id === command.nearNodeId) ? command.nearNodeId : void 0;
|
|
186
188
|
if (!pos) {
|
|
189
|
+
const draft = command.node;
|
|
190
|
+
const nodeSize = {
|
|
191
|
+
width: _nullishCoalesce(_nullishCoalesce(_optionalChain([draft, 'access', _6 => _6.measured, 'optionalAccess', _7 => _7.width]), () => ( draft.width)), () => ( defaultNodeSize.width)),
|
|
192
|
+
height: _nullishCoalesce(_nullishCoalesce(_optionalChain([draft, 'access', _8 => _8.measured, 'optionalAccess', _9 => _9.height]), () => ( draft.height)), () => ( defaultNodeSize.height))
|
|
193
|
+
};
|
|
194
|
+
const view = typeof options.visibleRect === "function" ? options.visibleRect() : options.visibleRect;
|
|
187
195
|
const rects = {};
|
|
188
196
|
for (const n of nodes) {
|
|
189
197
|
rects[n.id] = {
|
|
190
198
|
x: n.position.x,
|
|
191
199
|
y: n.position.y,
|
|
192
|
-
width: _nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access',
|
|
193
|
-
height: _nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access',
|
|
200
|
+
width: _nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _10 => _10.measured, 'optionalAccess', _11 => _11.width]), () => ( n.width)), () => ( defaultNodeSize.width)),
|
|
201
|
+
height: _nullishCoalesce(_nullishCoalesce(_optionalChain([n, 'access', _12 => _12.measured, 'optionalAccess', _13 => _13.height]), () => ( n.height)), () => ( defaultNodeSize.height))
|
|
194
202
|
};
|
|
195
203
|
}
|
|
196
204
|
if (anchorId) {
|
|
197
|
-
pos =
|
|
205
|
+
pos = _chunkEL4PSKFTcjs.placeBeside.call(void 0,
|
|
206
|
+
rects,
|
|
207
|
+
nodeSize,
|
|
208
|
+
normalizeSide(command.side),
|
|
209
|
+
anchorId
|
|
210
|
+
);
|
|
211
|
+
} else if (view) {
|
|
212
|
+
pos = _chunkEL4PSKFTcjs.placeInView.call(void 0, rects, nodeSize, view);
|
|
198
213
|
} else if (nodes.length > 0) {
|
|
199
214
|
const lastNode = nodes[nodes.length - 1];
|
|
200
|
-
pos =
|
|
215
|
+
pos = _chunkEL4PSKFTcjs.placeBeside.call(void 0, rects, nodeSize, "right", lastNode.id);
|
|
201
216
|
} else {
|
|
202
217
|
pos = { x: 100, y: 100 };
|
|
203
218
|
}
|
|
@@ -265,12 +280,14 @@ function planAgentCommand(command, snapshot, options = {}) {
|
|
|
265
280
|
stored[n.id] = { ...n.position };
|
|
266
281
|
}
|
|
267
282
|
}
|
|
268
|
-
layouted =
|
|
283
|
+
layouted = _chunkEL4PSKFTcjs.ensureLayout.call(void 0, nodes, edges, {
|
|
269
284
|
direction: dir,
|
|
270
285
|
storedPositions: stored
|
|
271
286
|
});
|
|
272
287
|
} else {
|
|
273
|
-
layouted =
|
|
288
|
+
layouted = _chunkEL4PSKFTcjs.getLayoutedNodes.call(void 0, nodes, edges, void 0, {
|
|
289
|
+
direction: dir
|
|
290
|
+
});
|
|
274
291
|
}
|
|
275
292
|
const positions = {};
|
|
276
293
|
for (const node of layouted) {
|
|
@@ -401,13 +418,26 @@ function toolCallToAgentCommand(name, args = {}) {
|
|
|
401
418
|
case "remove_nodes":
|
|
402
419
|
return ids(args.nodeIds) ? { type: "canvas:remove_nodes", nodeIds: args.nodeIds } : null;
|
|
403
420
|
case "connect":
|
|
404
|
-
return typeof args.source === "string" && typeof args.target === "string" ? {
|
|
421
|
+
return typeof args.source === "string" && typeof args.target === "string" ? {
|
|
422
|
+
type: "canvas:connect",
|
|
423
|
+
source: args.source,
|
|
424
|
+
target: args.target,
|
|
425
|
+
label: args.label
|
|
426
|
+
} : null;
|
|
405
427
|
case "update_node": {
|
|
406
|
-
const id = _nullishCoalesce(_optionalChain([args, 'access',
|
|
407
|
-
return typeof id === "string" ? {
|
|
428
|
+
const id = _nullishCoalesce(_optionalChain([args, 'access', _14 => _14.node, 'optionalAccess', _15 => _15.id]), () => ( args.id));
|
|
429
|
+
return typeof id === "string" ? {
|
|
430
|
+
type: "canvas:update_node",
|
|
431
|
+
id,
|
|
432
|
+
data: _nullishCoalesce(_nullishCoalesce(_optionalChain([args, 'access', _16 => _16.node, 'optionalAccess', _17 => _17.data]), () => ( args.data)), () => ( {}))
|
|
433
|
+
} : null;
|
|
408
434
|
}
|
|
409
435
|
case "layout":
|
|
410
|
-
return {
|
|
436
|
+
return {
|
|
437
|
+
type: "canvas:layout",
|
|
438
|
+
direction: args.direction,
|
|
439
|
+
incremental: args.incremental
|
|
440
|
+
};
|
|
411
441
|
case "select":
|
|
412
442
|
return ids(args.nodeIds) ? { type: "canvas:select", nodeIds: args.nodeIds } : null;
|
|
413
443
|
case "highlight":
|
|
@@ -425,9 +455,18 @@ function toolCallToAgentCommand(name, args = {}) {
|
|
|
425
455
|
if (promptOperation !== void 0) {
|
|
426
456
|
switch (promptOperation) {
|
|
427
457
|
case "insert_text":
|
|
428
|
-
return typeof args.text === "string" ? {
|
|
458
|
+
return typeof args.text === "string" ? {
|
|
459
|
+
type: "prompt:insert_text",
|
|
460
|
+
text: args.text,
|
|
461
|
+
at: num(args.at) ? args.at : void 0
|
|
462
|
+
} : null;
|
|
429
463
|
case "replace_range":
|
|
430
|
-
return typeof args.text === "string" && num(args.from) && num(args.to) ? {
|
|
464
|
+
return typeof args.text === "string" && num(args.from) && num(args.to) ? {
|
|
465
|
+
type: "prompt:replace_range",
|
|
466
|
+
from: args.from,
|
|
467
|
+
to: args.to,
|
|
468
|
+
text: args.text
|
|
469
|
+
} : null;
|
|
431
470
|
case "set_variable":
|
|
432
471
|
return typeof args.name === "string" ? { type: "prompt:set_variable", name: args.name, value: args.value } : null;
|
|
433
472
|
case "select":
|
|
@@ -439,7 +478,7 @@ function toolCallToAgentCommand(name, args = {}) {
|
|
|
439
478
|
return { type: "tool:call", name, arguments: args };
|
|
440
479
|
}
|
|
441
480
|
function validateAgentCommand(command, snapshot) {
|
|
442
|
-
const known = new Set((_nullishCoalesce(_optionalChain([snapshot, 'access',
|
|
481
|
+
const known = new Set((_nullishCoalesce(_optionalChain([snapshot, 'access', _18 => _18.canvas, 'optionalAccess', _19 => _19.nodes]), () => ( []))).map((n) => n.id));
|
|
443
482
|
const missing = (nodeIds) => {
|
|
444
483
|
const unknown = nodeIds.filter((id) => !known.has(id));
|
|
445
484
|
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;
|
|
@@ -451,7 +490,8 @@ function validateAgentCommand(command, snapshot) {
|
|
|
451
490
|
};
|
|
452
491
|
switch (command.type) {
|
|
453
492
|
case "canvas:add_node":
|
|
454
|
-
if (command.node.id && known.has(command.node.id))
|
|
493
|
+
if (command.node.id && known.has(command.node.id))
|
|
494
|
+
return `A node with id "${command.node.id}" already exists.`;
|
|
455
495
|
return command.nearNodeId ? missing([command.nearNodeId]) : null;
|
|
456
496
|
case "canvas:remove_nodes":
|
|
457
497
|
case "canvas:highlight":
|
|
@@ -459,7 +499,8 @@ function validateAgentCommand(command, snapshot) {
|
|
|
459
499
|
case "canvas:select":
|
|
460
500
|
return missing(command.nodeIds);
|
|
461
501
|
case "canvas:connect":
|
|
462
|
-
if (command.source === command.target)
|
|
502
|
+
if (command.source === command.target)
|
|
503
|
+
return "An edge needs two different nodes.";
|
|
463
504
|
return missing([command.source, command.target]);
|
|
464
505
|
case "canvas:update_node":
|
|
465
506
|
return missing([command.id]);
|
|
@@ -486,14 +527,14 @@ var _history = require('@tiptap/pm/history');
|
|
|
486
527
|
// src/agent/canvasPlayback.ts
|
|
487
528
|
var centre = (r) => ({ x: r.x + r.width / 2, y: r.y + r.height / 2 });
|
|
488
529
|
var labelOf = (data) => {
|
|
489
|
-
const label = _nullishCoalesce(_nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
530
|
+
const label = _nullishCoalesce(_nullishCoalesce(_optionalChain([data, 'optionalAccess', _20 => _20.label]), () => ( _optionalChain([data, 'optionalAccess', _21 => _21.title]))), () => ( _optionalChain([data, 'optionalAccess', _22 => _22.text])));
|
|
490
531
|
return typeof label === "string" && label.trim() ? label : null;
|
|
491
532
|
};
|
|
492
533
|
function planCanvasPlaybackSteps(steps, nodes, rectOptions) {
|
|
493
|
-
const placed = new Map(
|
|
534
|
+
const placed = new Map(_chunkEL4PSKFTcjs.createNodeLookup.call(void 0, nodes));
|
|
494
535
|
const rectOf = (id) => {
|
|
495
536
|
const node = placed.get(id);
|
|
496
|
-
return node ?
|
|
537
|
+
return node ? _chunkEL4PSKFTcjs.getNodeRect.call(void 0, node, placed, rectOptions) : null;
|
|
497
538
|
};
|
|
498
539
|
const before = [];
|
|
499
540
|
const after = [];
|
|
@@ -545,7 +586,7 @@ function planCanvasPlaybackSteps(steps, nodes, rectOptions) {
|
|
|
545
586
|
const node = placed.get(id);
|
|
546
587
|
if (node) placed.set(id, { ...node, position });
|
|
547
588
|
}
|
|
548
|
-
const rect =
|
|
589
|
+
const rect = _chunkD2ENR3LBcjs.unionRects.call(void 0, moved.map(([id]) => rectOf(id)));
|
|
549
590
|
if (rect) after.push({ type: "move", to: centre(rect) }, { type: "focus", rect }, { type: "wait", ms: 450 });
|
|
550
591
|
break;
|
|
551
592
|
}
|
|
@@ -560,7 +601,7 @@ function planCanvasToolPlayback(name, args, snapshot, plannerOptions, rectOption
|
|
|
560
601
|
const command = toolCallToAgentCommand(name, args);
|
|
561
602
|
if (!command || !command.type.startsWith("canvas:") || validateAgentCommand(command, snapshot)) return null;
|
|
562
603
|
const steps = planAgentCommand(command, snapshot, plannerOptions);
|
|
563
|
-
const planned = planCanvasPlaybackSteps(steps, _nullishCoalesce(_optionalChain([snapshot, 'access',
|
|
604
|
+
const planned = planCanvasPlaybackSteps(steps, _nullishCoalesce(_optionalChain([snapshot, 'access', _23 => _23.canvas, 'optionalAccess', _24 => _24.nodes]), () => ( [])), rectOptions);
|
|
564
605
|
return planned.length ? planned : null;
|
|
565
606
|
}
|
|
566
607
|
|
|
@@ -678,7 +719,7 @@ function createDocumentChartTools(editor) {
|
|
|
678
719
|
const ed = editor();
|
|
679
720
|
checkPosition(ed, at);
|
|
680
721
|
const spec = checkedSpec(input);
|
|
681
|
-
const id = _nullishCoalesce(_optionalChain([ed, 'access',
|
|
722
|
+
const id = _nullishCoalesce(_optionalChain([ed, 'access', _25 => _25.extensionManager, 'access', _26 => _26.extensions, 'access', _27 => _27.find, 'call', _28 => _28((e) => e.name === "chart"), 'optionalAccess', _29 => _29.options, 'access', _30 => _30.generateId, 'optionalCall', _31 => _31()]), () => ( `chart-${Date.now().toString(36)}`));
|
|
682
723
|
const node = { type: "chart", attrs: { id, spec, width, ...height !== void 0 ? { height } : {} } };
|
|
683
724
|
const chain = ed.chain().command(({ tr }) => (_history.closeHistory.call(void 0, tr), true));
|
|
684
725
|
const ok = (at !== void 0 ? chain.insertContentAt(at, node) : chain.insertContent(node)).run();
|
|
@@ -893,7 +934,7 @@ function createDocumentFormatTools(editor, changed) {
|
|
|
893
934
|
const formatText = (ed) => {
|
|
894
935
|
const { schema } = ed;
|
|
895
936
|
const has = (name) => !!schema.marks[name];
|
|
896
|
-
const hasAttr = (mark, attr) => !!_optionalChain([schema, 'access',
|
|
937
|
+
const hasAttr = (mark, attr) => !!_optionalChain([schema, 'access', _32 => _32.marks, 'access', _33 => _33[mark], 'optionalAccess', _34 => _34.spec, 'access', _35 => _35.attrs, 'optionalAccess', _36 => _36[attr]]);
|
|
897
938
|
const properties = { ...RANGE_PROPERTIES };
|
|
898
939
|
for (const [arg, mark, what] of TOGGLE_MARKS) {
|
|
899
940
|
if (has(mark)) properties[arg] = { type: "boolean", description: `${what} true sets it, false clears it; omit to leave it.` };
|
|
@@ -968,7 +1009,7 @@ function createDocumentFormatTools(editor, changed) {
|
|
|
968
1009
|
const blockTypes = (ed) => BLOCK_TYPES.filter(([, node]) => !!ed.schema.nodes[node] && (!LIST_ITEMS[node] || !!ed.schema.nodes[LIST_ITEMS[node]]));
|
|
969
1010
|
const headingLevels = (ed) => {
|
|
970
1011
|
const ext = ed.extensionManager.extensions.find((e) => e.name === "heading");
|
|
971
|
-
return _nullishCoalesce(_optionalChain([ext, 'optionalAccess',
|
|
1012
|
+
return _nullishCoalesce(_optionalChain([ext, 'optionalAccess', _37 => _37.options, 'optionalAccess', _38 => _38.levels]), () => ( [1, 2, 3, 4, 5, 6]));
|
|
972
1013
|
};
|
|
973
1014
|
const setBlockType = (ed) => {
|
|
974
1015
|
const types = blockTypes(ed);
|
|
@@ -1018,8 +1059,8 @@ function createDocumentFormatTools(editor, changed) {
|
|
|
1018
1059
|
const setTextAlign = (ed) => {
|
|
1019
1060
|
const ext = ed.extensionManager.extensions.find((e) => e.name === "textAlign");
|
|
1020
1061
|
if (!ext) return null;
|
|
1021
|
-
const alignments = (_nullishCoalesce(_optionalChain([ext, 'access',
|
|
1022
|
-
const types = _nullishCoalesce(_optionalChain([ext, 'access',
|
|
1062
|
+
const alignments = (_nullishCoalesce(_optionalChain([ext, 'access', _39 => _39.options, 'optionalAccess', _40 => _40.alignments]), () => ( ["left", "center", "right", "justify"]))).slice();
|
|
1063
|
+
const types = _nullishCoalesce(_optionalChain([ext, 'access', _41 => _41.options, 'optionalAccess', _42 => _42.types]), () => ( ["heading", "paragraph"]));
|
|
1023
1064
|
return {
|
|
1024
1065
|
name: "set_text_align",
|
|
1025
1066
|
title: "Align text",
|
|
@@ -1086,13 +1127,13 @@ function textBlocks(editor) {
|
|
|
1086
1127
|
function createTextPresence(editor, providerId, option) {
|
|
1087
1128
|
const config = option === false ? null : option === true || option === void 0 ? {} : option;
|
|
1088
1129
|
const caret = {
|
|
1089
|
-
id: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
1090
|
-
name: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
1091
|
-
color: _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
1130
|
+
id: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _43 => _43.id]), () => ( providerId)),
|
|
1131
|
+
name: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _44 => _44.name]), () => ( _chunkL434J57Vcjs.DEFAULT_AGENT_CARET_NAME)),
|
|
1132
|
+
color: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _45 => _45.color]), () => ( _chunkL434J57Vcjs.DEFAULT_AGENT_CARET_COLOR))
|
|
1092
1133
|
};
|
|
1093
|
-
const typing = !_optionalChain([config, 'optionalAccess',
|
|
1094
|
-
const idleMs = _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
1095
|
-
const changedMs = _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
|
1134
|
+
const typing = !_optionalChain([config, 'optionalAccess', _46 => _46.typing]) ? null : config.typing === true ? {} : config.typing;
|
|
1135
|
+
const idleMs = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _47 => _47.idleMs]), () => ( 12e3));
|
|
1136
|
+
const changedMs = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _48 => _48.changedMs]), () => ( 1500));
|
|
1096
1137
|
let idleTimer;
|
|
1097
1138
|
let tintTimer;
|
|
1098
1139
|
const live = () => {
|
|
@@ -1839,7 +1880,7 @@ function missingArgumentsMessage(name, args) {
|
|
|
1839
1880
|
const required = _chunkSVFEVKLFcjs.EDIT_OPERATION_REQUIRED_ARGUMENTS[name][args.operation];
|
|
1840
1881
|
if (!required) return `Unknown operation "${args.operation}".`;
|
|
1841
1882
|
const missing = required.filter(
|
|
1842
|
-
(key) => key === "id" ? args.id === void 0 && _optionalChain([args, 'access',
|
|
1883
|
+
(key) => key === "id" ? args.id === void 0 && _optionalChain([args, 'access', _49 => _49.node, 'optionalAccess', _50 => _50.id]) === void 0 : args[key] === void 0
|
|
1843
1884
|
);
|
|
1844
1885
|
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).`;
|
|
1845
1886
|
}
|
|
@@ -1871,8 +1912,8 @@ function createEditorMcpToolProvider(options) {
|
|
|
1871
1912
|
await options.applySteps(steps);
|
|
1872
1913
|
return describeSteps(steps);
|
|
1873
1914
|
};
|
|
1874
|
-
const canvas = _nullishCoalesce(_optionalChain([options, 'access',
|
|
1875
|
-
const prompt = _nullishCoalesce(_optionalChain([options, 'access',
|
|
1915
|
+
const canvas = _nullishCoalesce(_optionalChain([options, 'access', _51 => _51.surfaces, 'optionalAccess', _52 => _52.canvas]), () => ( true));
|
|
1916
|
+
const prompt = _nullishCoalesce(_optionalChain([options, 'access', _53 => _53.surfaces, 'optionalAccess', _54 => _54.prompt]), () => ( true));
|
|
1876
1917
|
const editTools = options.toolStyle === "combined" ? [...canvas ? [_chunkSVFEVKLFcjs.MCP_TOOL_EDIT_CANVAS] : [], ...prompt ? [_chunkSVFEVKLFcjs.MCP_TOOL_EDIT_PROMPT] : []] : [...canvas ? _chunkSVFEVKLFcjs.EDITOR_CANVAS_TOOLS : [], ...prompt ? _chunkSVFEVKLFcjs.EDITOR_PROMPT_TOOLS : []];
|
|
1877
1918
|
const tools = [
|
|
1878
1919
|
{
|
|
@@ -2205,4 +2246,5 @@ function createCanvasComponentToolProvider(controller, options = { id: "canvas-c
|
|
|
2205
2246
|
|
|
2206
2247
|
|
|
2207
2248
|
|
|
2208
|
-
|
|
2249
|
+
|
|
2250
|
+
exports.AgentPlayback = _chunkD2ENR3LBcjs.AgentPlayback; exports.CAPTURE_EXCLUDE_SELECTOR = _chunkSVFEVKLFcjs.CAPTURE_EXCLUDE_SELECTOR; exports.CAPTURE_OVERLAY_SELECTORS = _chunkSVFEVKLFcjs.CAPTURE_OVERLAY_SELECTORS; exports.EDITOR_CANVAS_TOOLS = _chunkSVFEVKLFcjs.EDITOR_CANVAS_TOOLS; exports.EDITOR_MCP_TOOLS = _chunkSVFEVKLFcjs.EDITOR_MCP_TOOLS; exports.EDITOR_PROMPT_TOOLS = _chunkSVFEVKLFcjs.EDITOR_PROMPT_TOOLS; exports.EDIT_OPERATION_REQUIRED_ARGUMENTS = _chunkSVFEVKLFcjs.EDIT_OPERATION_REQUIRED_ARGUMENTS; exports.EXPORT_EXCLUDED_SELECTORS = _chunkSVFEVKLFcjs.EXPORT_EXCLUDED_SELECTORS; exports.JSON_RPC_ERRORS = _chunkY4BWZB6Jcjs.JSON_RPC_ERRORS; exports.MCP_PROTOCOL_VERSIONS = _chunkY4BWZB6Jcjs.MCP_PROTOCOL_VERSIONS; exports.MCP_TOOL_CANVAS_ADD_NODE = _chunkSVFEVKLFcjs.MCP_TOOL_CANVAS_ADD_NODE; exports.MCP_TOOL_CANVAS_CONNECT = _chunkSVFEVKLFcjs.MCP_TOOL_CANVAS_CONNECT; exports.MCP_TOOL_CANVAS_HIGHLIGHT = _chunkSVFEVKLFcjs.MCP_TOOL_CANVAS_HIGHLIGHT; exports.MCP_TOOL_CANVAS_LAYOUT = _chunkSVFEVKLFcjs.MCP_TOOL_CANVAS_LAYOUT; exports.MCP_TOOL_CANVAS_REMOVE_NODES = _chunkSVFEVKLFcjs.MCP_TOOL_CANVAS_REMOVE_NODES; exports.MCP_TOOL_CANVAS_SELECT = _chunkSVFEVKLFcjs.MCP_TOOL_CANVAS_SELECT; exports.MCP_TOOL_CANVAS_UPDATE_NODE = _chunkSVFEVKLFcjs.MCP_TOOL_CANVAS_UPDATE_NODE; exports.MCP_TOOL_EDIT_CANVAS = _chunkSVFEVKLFcjs.MCP_TOOL_EDIT_CANVAS; exports.MCP_TOOL_EDIT_PROMPT = _chunkSVFEVKLFcjs.MCP_TOOL_EDIT_PROMPT; exports.MCP_TOOL_GET_EDITOR_STATE = _chunkSVFEVKLFcjs.MCP_TOOL_GET_EDITOR_STATE; exports.MCP_TOOL_PROMPT_INSERT_TEXT = _chunkSVFEVKLFcjs.MCP_TOOL_PROMPT_INSERT_TEXT; exports.MCP_TOOL_PROMPT_REPLACE_RANGE = _chunkSVFEVKLFcjs.MCP_TOOL_PROMPT_REPLACE_RANGE; exports.MCP_TOOL_PROMPT_SELECT = _chunkSVFEVKLFcjs.MCP_TOOL_PROMPT_SELECT; exports.MCP_TOOL_PROMPT_SET_VARIABLE = _chunkSVFEVKLFcjs.MCP_TOOL_PROMPT_SET_VARIABLE; exports.MCP_TOOL_VIEW_EDITOR = _chunkSVFEVKLFcjs.MCP_TOOL_VIEW_EDITOR; exports.PRESENCE_COLORS = _chunkUJGAA6AKcjs.PRESENCE_COLORS; exports.PerformanceQueue = _chunkUJGAA6AKcjs.PerformanceQueue; exports.PresenceStore = _chunkUJGAA6AKcjs.PresenceStore; exports.TOOL_BRIDGE_DEFAULT_PORT = _chunkY4BWZB6Jcjs.TOOL_BRIDGE_DEFAULT_PORT; exports.TOOL_BRIDGE_PROTOCOL = _chunkY4BWZB6Jcjs.TOOL_BRIDGE_PROTOCOL; exports.TOOL_DISCOVERY_TOOLS = _chunkY4BWZB6Jcjs.TOOL_DISCOVERY_TOOLS; exports.TOOL_NAMESPACE_SEPARATOR = _chunkY4BWZB6Jcjs.TOOL_NAMESPACE_SEPARATOR; exports.ToolRegistry = _chunkY4BWZB6Jcjs.ToolRegistry; exports.ToolRegistryError = _chunkY4BWZB6Jcjs.ToolRegistryError; exports.ToolRegistryView = _chunkY4BWZB6Jcjs.ToolRegistryView; exports.UNSAFE_JSON_KEYS = _chunk2BSBFBOAcjs.UNSAFE_JSON_KEYS; exports.baseToolName = _chunkY4BWZB6Jcjs.baseToolName; exports.captureInputSchema = _chunkN2FGYZ4Qcjs.captureInputSchema; exports.captureOutputSize = _chunkN2FGYZ4Qcjs.captureOutputSize; exports.cloneElementWithStyles = _chunkSVFEVKLFcjs.cloneElementWithStyles; exports.connectToolBridge = _chunkY4BWZB6Jcjs.connectToolBridge; exports.createAgentPlayback = _chunkD2ENR3LBcjs.createAgentPlayback; exports.createCanvasComponentToolProvider = createCanvasComponentToolProvider; exports.createCaptureTool = _chunkN2FGYZ4Qcjs.createCaptureTool; exports.createCaptureToolProvider = _chunkN2FGYZ4Qcjs.createCaptureToolProvider; exports.createDocumentChartTools = createDocumentChartTools; exports.createEditorMcpToolProvider = createEditorMcpToolProvider; exports.createElementCaptureSurface = _chunkSVFEVKLFcjs.createElementCaptureSurface; exports.createInstantPresenceClock = _chunkUJGAA6AKcjs.createInstantPresenceClock; exports.createMcpServer = _chunkY4BWZB6Jcjs.createMcpServer; exports.createPlaybackToolProvider = _chunkD2ENR3LBcjs.createPlaybackToolProvider; exports.createRichTextToolProvider = createRichTextToolProvider; exports.createSpreadsheetToolProvider = createSpreadsheetToolProvider; exports.createToolRegistry = _chunkY4BWZB6Jcjs.createToolRegistry; exports.derivePlaybackSteps = _chunkD2ENR3LBcjs.derivePlaybackSteps; exports.elementToSvg = _chunkSVFEVKLFcjs.elementToSvg; exports.errorResult = _chunkY4BWZB6Jcjs.errorResult; exports.isUnsafeJsonKey = _chunk2BSBFBOAcjs.isUnsafeJsonKey; exports.listSkills = _chunkY4BWZB6Jcjs.listSkills; exports.normalizeSide = normalizeSide; exports.parseSkillFrontmatter = _chunkY4BWZB6Jcjs.parseSkillFrontmatter; exports.planAgentCommand = planAgentCommand; exports.planCanvasPlaybackSteps = planCanvasPlaybackSteps; exports.planCanvasToolPlayback = planCanvasToolPlayback; exports.planToolCall = planToolCall; exports.playbackRefsFromArgs = _chunkD2ENR3LBcjs.playbackRefsFromArgs; exports.playbackRefsFromResult = _chunkD2ENR3LBcjs.playbackRefsFromResult; exports.rasterizeElement = _chunkSVFEVKLFcjs.rasterizeElement; exports.readSkillFile = _chunkY4BWZB6Jcjs.readSkillFile; exports.readingTime = _chunkD2ENR3LBcjs.readingTime; exports.realPresenceClock = _chunkUJGAA6AKcjs.realPresenceClock; exports.resolveCaptureRequest = _chunkN2FGYZ4Qcjs.resolveCaptureRequest; exports.runToolScript = _chunkAG2EXVCRcjs.runToolScript; exports.searchTokens = _chunkY4BWZB6Jcjs.searchTokens; exports.searchTools = _chunkY4BWZB6Jcjs.searchTools; exports.stripPrototypeKeys = _chunk2BSBFBOAcjs.stripPrototypeKeys; exports.summarize = _chunkY4BWZB6Jcjs.summarize; exports.toCapturedImageData = _chunkN2FGYZ4Qcjs.toCapturedImageData; exports.toToolResult = _chunkY4BWZB6Jcjs.toToolResult; exports.toolCallToAgentCommand = toolCallToAgentCommand; exports.toolResultError = _chunkAG2EXVCRcjs.toolResultError; exports.toolResultValue = _chunkAG2EXVCRcjs.toolResultValue; exports.toolsetInstructions = _chunkY4BWZB6Jcjs.toolsetInstructions; exports.toolsetName = _chunkY4BWZB6Jcjs.toolsetName; exports.tweenPresenceCursor = _chunkUJGAA6AKcjs.tweenPresenceCursor; exports.unionCaptureRects = _chunkN2FGYZ4Qcjs.unionCaptureRects; exports.unionRects = _chunkD2ENR3LBcjs.unionRects; exports.unknownToolMessage = _chunkY4BWZB6Jcjs.unknownToolMessage; exports.validateAgentCommand = validateAgentCommand; exports.validateJsonSchema = _chunkWOFXZ3XUcjs.validateJsonSchema;
|
package/dist/agent/index.js
CHANGED
|
@@ -11,14 +11,15 @@ import {
|
|
|
11
11
|
ensureLayout,
|
|
12
12
|
getLayoutedNodes,
|
|
13
13
|
getNodeRect,
|
|
14
|
-
placeBeside
|
|
15
|
-
|
|
14
|
+
placeBeside,
|
|
15
|
+
placeInView
|
|
16
|
+
} from "../chunk-U4VE4UI2.js";
|
|
16
17
|
import "../chunk-7KZ2HKKC.js";
|
|
17
18
|
import {
|
|
18
19
|
runToolScript,
|
|
19
20
|
toolResultError,
|
|
20
21
|
toolResultValue
|
|
21
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-SA37RU2O.js";
|
|
22
23
|
import {
|
|
23
24
|
JSON_RPC_ERRORS,
|
|
24
25
|
MCP_PROTOCOL_VERSIONS,
|
|
@@ -48,12 +49,13 @@ import {
|
|
|
48
49
|
import {
|
|
49
50
|
AgentPlayback,
|
|
50
51
|
createAgentPlayback,
|
|
52
|
+
createPlaybackToolProvider,
|
|
51
53
|
derivePlaybackSteps,
|
|
52
54
|
playbackRefsFromArgs,
|
|
53
55
|
playbackRefsFromResult,
|
|
54
56
|
readingTime,
|
|
55
57
|
unionRects
|
|
56
|
-
} from "../chunk-
|
|
58
|
+
} from "../chunk-HUHBJWTD.js";
|
|
57
59
|
import {
|
|
58
60
|
CAPTURE_EXCLUDE_SELECTOR,
|
|
59
61
|
CAPTURE_OVERLAY_SELECTORS,
|
|
@@ -184,6 +186,12 @@ function planAgentCommand(command, snapshot, options = {}) {
|
|
|
184
186
|
let pos = command.node.position;
|
|
185
187
|
const anchorId = command.nearNodeId && nodes.some((n) => n.id === command.nearNodeId) ? command.nearNodeId : void 0;
|
|
186
188
|
if (!pos) {
|
|
189
|
+
const draft = command.node;
|
|
190
|
+
const nodeSize = {
|
|
191
|
+
width: draft.measured?.width ?? draft.width ?? defaultNodeSize.width,
|
|
192
|
+
height: draft.measured?.height ?? draft.height ?? defaultNodeSize.height
|
|
193
|
+
};
|
|
194
|
+
const view = typeof options.visibleRect === "function" ? options.visibleRect() : options.visibleRect;
|
|
187
195
|
const rects = {};
|
|
188
196
|
for (const n of nodes) {
|
|
189
197
|
rects[n.id] = {
|
|
@@ -194,10 +202,17 @@ function planAgentCommand(command, snapshot, options = {}) {
|
|
|
194
202
|
};
|
|
195
203
|
}
|
|
196
204
|
if (anchorId) {
|
|
197
|
-
pos = placeBeside(
|
|
205
|
+
pos = placeBeside(
|
|
206
|
+
rects,
|
|
207
|
+
nodeSize,
|
|
208
|
+
normalizeSide(command.side),
|
|
209
|
+
anchorId
|
|
210
|
+
);
|
|
211
|
+
} else if (view) {
|
|
212
|
+
pos = placeInView(rects, nodeSize, view);
|
|
198
213
|
} else if (nodes.length > 0) {
|
|
199
214
|
const lastNode = nodes[nodes.length - 1];
|
|
200
|
-
pos = placeBeside(rects,
|
|
215
|
+
pos = placeBeside(rects, nodeSize, "right", lastNode.id);
|
|
201
216
|
} else {
|
|
202
217
|
pos = { x: 100, y: 100 };
|
|
203
218
|
}
|
|
@@ -270,7 +285,9 @@ function planAgentCommand(command, snapshot, options = {}) {
|
|
|
270
285
|
storedPositions: stored
|
|
271
286
|
});
|
|
272
287
|
} else {
|
|
273
|
-
layouted = getLayoutedNodes(nodes, edges, void 0, {
|
|
288
|
+
layouted = getLayoutedNodes(nodes, edges, void 0, {
|
|
289
|
+
direction: dir
|
|
290
|
+
});
|
|
274
291
|
}
|
|
275
292
|
const positions = {};
|
|
276
293
|
for (const node of layouted) {
|
|
@@ -401,13 +418,26 @@ function toolCallToAgentCommand(name, args = {}) {
|
|
|
401
418
|
case "remove_nodes":
|
|
402
419
|
return ids(args.nodeIds) ? { type: "canvas:remove_nodes", nodeIds: args.nodeIds } : null;
|
|
403
420
|
case "connect":
|
|
404
|
-
return typeof args.source === "string" && typeof args.target === "string" ? {
|
|
421
|
+
return typeof args.source === "string" && typeof args.target === "string" ? {
|
|
422
|
+
type: "canvas:connect",
|
|
423
|
+
source: args.source,
|
|
424
|
+
target: args.target,
|
|
425
|
+
label: args.label
|
|
426
|
+
} : null;
|
|
405
427
|
case "update_node": {
|
|
406
428
|
const id = args.node?.id ?? args.id;
|
|
407
|
-
return typeof id === "string" ? {
|
|
429
|
+
return typeof id === "string" ? {
|
|
430
|
+
type: "canvas:update_node",
|
|
431
|
+
id,
|
|
432
|
+
data: args.node?.data ?? args.data ?? {}
|
|
433
|
+
} : null;
|
|
408
434
|
}
|
|
409
435
|
case "layout":
|
|
410
|
-
return {
|
|
436
|
+
return {
|
|
437
|
+
type: "canvas:layout",
|
|
438
|
+
direction: args.direction,
|
|
439
|
+
incremental: args.incremental
|
|
440
|
+
};
|
|
411
441
|
case "select":
|
|
412
442
|
return ids(args.nodeIds) ? { type: "canvas:select", nodeIds: args.nodeIds } : null;
|
|
413
443
|
case "highlight":
|
|
@@ -425,9 +455,18 @@ function toolCallToAgentCommand(name, args = {}) {
|
|
|
425
455
|
if (promptOperation !== void 0) {
|
|
426
456
|
switch (promptOperation) {
|
|
427
457
|
case "insert_text":
|
|
428
|
-
return typeof args.text === "string" ? {
|
|
458
|
+
return typeof args.text === "string" ? {
|
|
459
|
+
type: "prompt:insert_text",
|
|
460
|
+
text: args.text,
|
|
461
|
+
at: num(args.at) ? args.at : void 0
|
|
462
|
+
} : null;
|
|
429
463
|
case "replace_range":
|
|
430
|
-
return typeof args.text === "string" && num(args.from) && num(args.to) ? {
|
|
464
|
+
return typeof args.text === "string" && num(args.from) && num(args.to) ? {
|
|
465
|
+
type: "prompt:replace_range",
|
|
466
|
+
from: args.from,
|
|
467
|
+
to: args.to,
|
|
468
|
+
text: args.text
|
|
469
|
+
} : null;
|
|
431
470
|
case "set_variable":
|
|
432
471
|
return typeof args.name === "string" ? { type: "prompt:set_variable", name: args.name, value: args.value } : null;
|
|
433
472
|
case "select":
|
|
@@ -451,7 +490,8 @@ function validateAgentCommand(command, snapshot) {
|
|
|
451
490
|
};
|
|
452
491
|
switch (command.type) {
|
|
453
492
|
case "canvas:add_node":
|
|
454
|
-
if (command.node.id && known.has(command.node.id))
|
|
493
|
+
if (command.node.id && known.has(command.node.id))
|
|
494
|
+
return `A node with id "${command.node.id}" already exists.`;
|
|
455
495
|
return command.nearNodeId ? missing([command.nearNodeId]) : null;
|
|
456
496
|
case "canvas:remove_nodes":
|
|
457
497
|
case "canvas:highlight":
|
|
@@ -459,7 +499,8 @@ function validateAgentCommand(command, snapshot) {
|
|
|
459
499
|
case "canvas:select":
|
|
460
500
|
return missing(command.nodeIds);
|
|
461
501
|
case "canvas:connect":
|
|
462
|
-
if (command.source === command.target)
|
|
502
|
+
if (command.source === command.target)
|
|
503
|
+
return "An edge needs two different nodes.";
|
|
463
504
|
return missing([command.source, command.target]);
|
|
464
505
|
case "canvas:update_node":
|
|
465
506
|
return missing([command.id]);
|
|
@@ -2166,6 +2207,7 @@ export {
|
|
|
2166
2207
|
createElementCaptureSurface,
|
|
2167
2208
|
createInstantPresenceClock,
|
|
2168
2209
|
createMcpServer,
|
|
2210
|
+
createPlaybackToolProvider,
|
|
2169
2211
|
createRichTextToolProvider,
|
|
2170
2212
|
createSpreadsheetToolProvider,
|
|
2171
2213
|
createToolRegistry,
|
package/dist/agent/planner.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CanvasEdge, CanvasNode, Side } from
|
|
2
|
-
import type { AgentCommand, AgentStep, EditorSnapshot } from
|
|
1
|
+
import type { CanvasEdge, CanvasNode, Rect, Side } from "../canvas/types.cjs";
|
|
2
|
+
import type { AgentCommand, AgentStep, EditorSnapshot } from "./types.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Normalizes a placement side from either the planner vocabulary (`right | below | left | above`)
|
|
5
5
|
* or the MCP tool schema vocabulary (`top | right | bottom | left`). Unknown values fall back to `right`.
|
|
@@ -14,6 +14,11 @@ export declare function planAgentCommand<TNode extends CanvasNode = CanvasNode,
|
|
|
14
14
|
height: number;
|
|
15
15
|
};
|
|
16
16
|
idGenerator?: () => string;
|
|
17
|
+
/**
|
|
18
|
+
* The visible part of the canvas (flow coordinates), or a getter for it. Unanchored new
|
|
19
|
+
* nodes go in free space at its centre instead of beside the last node.
|
|
20
|
+
*/
|
|
21
|
+
visibleRect?: Rect | null | (() => Rect | null | undefined);
|
|
17
22
|
}): AgentStep<TNode, TEdge>[];
|
|
18
23
|
/**
|
|
19
24
|
* Converts an MCP tool call into a planner command. `edit_canvas` /
|
package/dist/agent/planner.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CanvasEdge, CanvasNode, Side } from
|
|
2
|
-
import type { AgentCommand, AgentStep, EditorSnapshot } from
|
|
1
|
+
import type { CanvasEdge, CanvasNode, Rect, Side } from "../canvas/types.js";
|
|
2
|
+
import type { AgentCommand, AgentStep, EditorSnapshot } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Normalizes a placement side from either the planner vocabulary (`right | below | left | above`)
|
|
5
5
|
* or the MCP tool schema vocabulary (`top | right | bottom | left`). Unknown values fall back to `right`.
|
|
@@ -14,6 +14,11 @@ export declare function planAgentCommand<TNode extends CanvasNode = CanvasNode,
|
|
|
14
14
|
height: number;
|
|
15
15
|
};
|
|
16
16
|
idGenerator?: () => string;
|
|
17
|
+
/**
|
|
18
|
+
* The visible part of the canvas (flow coordinates), or a getter for it. Unanchored new
|
|
19
|
+
* nodes go in free space at its centre instead of beside the last node.
|
|
20
|
+
*/
|
|
21
|
+
visibleRect?: Rect | null | (() => Rect | null | undefined);
|
|
17
22
|
}): AgentStep<TNode, TEdge>[];
|
|
18
23
|
/**
|
|
19
24
|
* Converts an MCP tool call into a planner command. `edit_canvas` /
|