@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.
@@ -88,12 +88,13 @@ import {
88
88
  matchSize,
89
89
  overlaps,
90
90
  placeBeside,
91
+ placeInView,
91
92
  readStyleSize,
92
93
  reorderNodes,
93
94
  toggleLockNodes,
94
95
  unlockNodes,
95
96
  withStyleSize
96
- } from "../chunk-DW4CV5H4.js";
97
+ } from "../chunk-U4VE4UI2.js";
97
98
  import {
98
99
  DEFAULT_ARRANGE_SHORTCUTS,
99
100
  matchArrangeShortcut
@@ -12057,6 +12058,7 @@ export {
12057
12058
  pathfinder,
12058
12059
  pieScene,
12059
12060
  placeBeside,
12061
+ placeInView,
12060
12062
  planarSplit,
12061
12063
  playCanvasSceneTransition,
12062
12064
  playWebAnimations,
@@ -1,4 +1,4 @@
1
- import type { CanvasEdge, CanvasLayoutOptions, CanvasNode, IncrementalLayoutOptions, PlaceBesideOptions, Rect, Side, XYPosition } from './types.cjs';
1
+ import type { CanvasEdge, CanvasLayoutOptions, CanvasNode, IncrementalLayoutOptions, PlaceBesideOptions, Rect, Side, XYPosition } from "./types.cjs";
2
2
  export declare const DEFAULT_NODE_WIDTH = 200;
3
3
  export declare const DEFAULT_NODE_HEIGHT = 60;
4
4
  export declare const DEFAULT_PLACEMENT_GAP = 48;
@@ -42,7 +42,7 @@ export declare function overlaps(a: Rect, b: Rect, pad?: number): boolean;
42
42
  /**
43
43
  * Maps directed layout flow to its natural forward growth side.
44
44
  */
45
- export declare function flowSide(direction?: 'LR' | 'TB' | 'RL' | 'BT'): Side;
45
+ export declare function flowSide(direction?: "LR" | "TB" | "RL" | "BT"): Side;
46
46
  /**
47
47
  * Incremental layout blending:
48
48
  * Keeps established/manual node positions intact. Runs Dagre on the entire graph,
@@ -58,3 +58,16 @@ export declare function placeBeside(rects: Record<string, Rect>, size: {
58
58
  width: number;
59
59
  height: number;
60
60
  }, side: Side, nearNodeId?: string, options?: PlaceBesideOptions): XYPosition;
61
+ /**
62
+ * Where a node of `size` goes when nothing anchors it: centred in `view` (the visible part of
63
+ * the canvas, in flow coordinates) when that is free, else the nearest free spot in rings
64
+ * around the centre, so new work appears where the user is looking and never on top of
65
+ * `rects`.
66
+ */
67
+ export declare function placeInView(rects: Record<string, Rect>, size: {
68
+ width: number;
69
+ height: number;
70
+ }, view: Rect, options?: {
71
+ gap?: number;
72
+ maxRings?: number;
73
+ }): XYPosition;
@@ -1,4 +1,4 @@
1
- import type { CanvasEdge, CanvasLayoutOptions, CanvasNode, IncrementalLayoutOptions, PlaceBesideOptions, Rect, Side, XYPosition } from './types.js';
1
+ import type { CanvasEdge, CanvasLayoutOptions, CanvasNode, IncrementalLayoutOptions, PlaceBesideOptions, Rect, Side, XYPosition } from "./types.js";
2
2
  export declare const DEFAULT_NODE_WIDTH = 200;
3
3
  export declare const DEFAULT_NODE_HEIGHT = 60;
4
4
  export declare const DEFAULT_PLACEMENT_GAP = 48;
@@ -42,7 +42,7 @@ export declare function overlaps(a: Rect, b: Rect, pad?: number): boolean;
42
42
  /**
43
43
  * Maps directed layout flow to its natural forward growth side.
44
44
  */
45
- export declare function flowSide(direction?: 'LR' | 'TB' | 'RL' | 'BT'): Side;
45
+ export declare function flowSide(direction?: "LR" | "TB" | "RL" | "BT"): Side;
46
46
  /**
47
47
  * Incremental layout blending:
48
48
  * Keeps established/manual node positions intact. Runs Dagre on the entire graph,
@@ -58,3 +58,16 @@ export declare function placeBeside(rects: Record<string, Rect>, size: {
58
58
  width: number;
59
59
  height: number;
60
60
  }, side: Side, nearNodeId?: string, options?: PlaceBesideOptions): XYPosition;
61
+ /**
62
+ * Where a node of `size` goes when nothing anchors it: centred in `view` (the visible part of
63
+ * the canvas, in flow coordinates) when that is free, else the nearest free spot in rings
64
+ * around the centre, so new work appears where the user is looking and never on top of
65
+ * `rects`.
66
+ */
67
+ export declare function placeInView(rects: Record<string, Rect>, size: {
68
+ width: number;
69
+ height: number;
70
+ }, view: Rect, options?: {
71
+ gap?: number;
72
+ maxRings?: number;
73
+ }): XYPosition;
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkX2HQP7DFcjs = require('./chunk-X2HQP7DF.cjs');
3
+ var _chunkD2ENR3LBcjs = require('./chunk-D2ENR3LB.cjs');
4
4
 
5
5
  // src/tools/script.ts
6
6
  function toolResultValue(result) {
@@ -36,7 +36,7 @@ async function runToolScript(source, script, options = {}) {
36
36
  if (step.say) {
37
37
  emit({ type: "say", step: i, text: step.say });
38
38
  _optionalChain([options, 'access', _6 => _6.playback, 'optionalAccess', _7 => _7.say, 'call', _8 => _8(step.say, options.actor ? { actor: options.actor } : {})]);
39
- await pause(_chunkX2HQP7DFcjs.readingTime.call(void 0, step.say));
39
+ await pause(_chunkD2ENR3LBcjs.readingTime.call(void 0, step.say));
40
40
  }
41
41
  if (!step.tool) continue;
42
42
  if (control.stopped) return finish(false);
@@ -107,7 +107,7 @@ var AgentPlayback = (_class = class {
107
107
  constructor(options = {}) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);
108
108
  this.clock = _nullishCoalesce(options.clock, () => ( _chunkUJGAA6AKcjs.realPresenceClock));
109
109
  this.speed = _nullishCoalesce(options.speed, () => ( 1));
110
- this.reads = _nullishCoalesce(options.reads, () => ( "glance"));
110
+ this.reads = _nullishCoalesce(options.reads, () => ( "skip"));
111
111
  this.linger = _nullishCoalesce(options.linger, () => ( 1500));
112
112
  this.defaultActor = _nullishCoalesce(options.actor, () => ( { id: "agent", name: "Agent" }));
113
113
  }
@@ -143,11 +143,16 @@ var AgentPlayback = (_class = class {
143
143
  surface(id) {
144
144
  return this.surfaces.get(id);
145
145
  }
146
- /** Shows `text` in the actor's bubble on the surface it last worked on (until its next step). */
146
+ /**
147
+ * Shows `text` in the actor's bubble on the surface it last worked on (until its next step).
148
+ * Returns that surface's id, or null when the actor has no cursor on screen (nothing shown).
149
+ */
147
150
  say(text, options = {}) {
148
151
  const actor = this.actorState(options.actor);
149
152
  const surface = actor.surface ? this.surfaces.get(actor.surface) : void 0;
150
- if (_optionalChain([surface, 'optionalAccess', _5 => _5.presence, 'access', _6 => _6.get, 'call', _7 => _7(actor.info.id)])) surface.presence.set({ id: actor.info.id, message: text });
153
+ if (!_optionalChain([surface, 'optionalAccess', _5 => _5.presence, 'access', _6 => _6.get, 'call', _7 => _7(actor.info.id)])) return null;
154
+ surface.presence.set({ id: actor.info.id, message: text });
155
+ return actor.surface;
151
156
  }
152
157
  /** Finishes every running performance at once (the calls still run and keep their results). */
153
158
  stop() {
@@ -396,6 +401,40 @@ var AgentPlayback = (_class = class {
396
401
  function createAgentPlayback(options = {}) {
397
402
  return new AgentPlayback(options);
398
403
  }
404
+ function createPlaybackToolProvider(playback, options = {}) {
405
+ const title = "Say a note by your cursor";
406
+ return {
407
+ id: _nullishCoalesce(options.id, () => ( "playback")),
408
+ namespace: options.namespace,
409
+ title: "Agent playback",
410
+ description: "Notes shown beside your cursor while the host plays your calls on screen.",
411
+ skill: "pixerate-agent-tools",
412
+ tools: [
413
+ {
414
+ name: "say",
415
+ title,
416
+ description: "Shows a short note in the bubble beside your cursor on the editor you last worked on, so the user can follow what you are doing; it stays until your next call. Changes no document. Returns shown (whether a cursor was on screen to show it) and surface (that editor, or null).",
417
+ inputSchema: {
418
+ type: "object",
419
+ properties: {
420
+ text: { type: "string", minLength: 1, maxLength: 200, description: "The note: one short sentence, at most 200 characters." }
421
+ },
422
+ required: ["text"],
423
+ additionalProperties: false
424
+ },
425
+ annotations: { title, readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
426
+ playback: false,
427
+ handler: ({ text }, context) => {
428
+ const note = String(text).trim();
429
+ if (!note) throw new Error('text is empty; pass the note to show, e.g. "Aligning the cards."');
430
+ const surface = playback.say(note, { actor: context.actor });
431
+ return { shown: surface !== null, surface };
432
+ }
433
+ }
434
+ ]
435
+ };
436
+ }
437
+
399
438
 
400
439
 
401
440
 
@@ -405,4 +444,4 @@ function createAgentPlayback(options = {}) {
405
444
 
406
445
 
407
446
 
408
- exports.playbackRefsFromArgs = playbackRefsFromArgs; exports.playbackRefsFromResult = playbackRefsFromResult; exports.derivePlaybackSteps = derivePlaybackSteps; exports.readingTime = readingTime; exports.unionRects = unionRects; exports.AgentPlayback = AgentPlayback; exports.createAgentPlayback = createAgentPlayback;
447
+ exports.playbackRefsFromArgs = playbackRefsFromArgs; exports.playbackRefsFromResult = playbackRefsFromResult; exports.derivePlaybackSteps = derivePlaybackSteps; exports.readingTime = readingTime; exports.unionRects = unionRects; exports.AgentPlayback = AgentPlayback; exports.createAgentPlayback = createAgentPlayback; exports.createPlaybackToolProvider = createPlaybackToolProvider;
@@ -4,8 +4,14 @@ var DEFAULT_NODE_WIDTH = 200;
4
4
  var DEFAULT_NODE_HEIGHT = 60;
5
5
  var DEFAULT_PLACEMENT_GAP = 48;
6
6
  function getCenteredNodePosition(width = 0, height = 0, screenToFlowPosition, screenDimensions) {
7
- const rect = _nullishCoalesce(screenDimensions, () => ( (typeof document !== "undefined" ? { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight } : { width: 1920, height: 1080 })));
8
- const flowPos = screenToFlowPosition({ x: rect.width / 2, y: rect.height / 2 });
7
+ const rect = _nullishCoalesce(screenDimensions, () => ( (typeof document !== "undefined" ? {
8
+ width: document.documentElement.clientWidth,
9
+ height: document.documentElement.clientHeight
10
+ } : { width: 1920, height: 1080 })));
11
+ const flowPos = screenToFlowPosition({
12
+ x: rect.width / 2,
13
+ y: rect.height / 2
14
+ });
9
15
  return {
10
16
  x: flowPos.x - width / 2,
11
17
  y: flowPos.y - height / 2
@@ -73,7 +79,10 @@ function getLayoutedNodes(nodes, edges, getNodesBounds, options = {}) {
73
79
  function estimateNodeSize(node, defaultWidth = DEFAULT_NODE_WIDTH, defaultHeight = DEFAULT_NODE_HEIGHT) {
74
80
  const label = String(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([node, 'access', _10 => _10.data, 'optionalAccess', _11 => _11.label]), () => ( _optionalChain([node, 'access', _12 => _12.data, 'optionalAccess', _13 => _13.title]))), () => ( node.id)), () => ( "")));
75
81
  const lines = label.split(/\n|<br\s*\/?>/);
76
- const longest = Math.max(...lines.map((l) => l.replace(/<[^>]+>/g, "").length), 1);
82
+ const longest = Math.max(
83
+ ...lines.map((l) => l.replace(/<[^>]+>/g, "").length),
84
+ 1
85
+ );
77
86
  const width = Math.min(480, Math.max(defaultWidth, longest * 8 + 48));
78
87
  const height = Math.max(defaultHeight, lines.length * 20 + 24);
79
88
  return { width, height };
@@ -203,6 +212,38 @@ function placeBeside(rects, size, side, nearNodeId, options = {}) {
203
212
  y: Math.round(baseY)
204
213
  };
205
214
  }
215
+ function placeInView(rects, size, view, options = {}) {
216
+ const gap = _nullishCoalesce(options.gap, () => ( DEFAULT_PLACEMENT_GAP));
217
+ const maxRings = _nullishCoalesce(options.maxRings, () => ( 24));
218
+ const obstacles = Object.values(rects);
219
+ const start = {
220
+ x: view.x + view.width / 2 - size.width / 2,
221
+ y: view.y + view.height / 2 - size.height / 2
222
+ };
223
+ const free = (p) => !obstacles.some(
224
+ (o) => overlaps({ ...p, width: size.width, height: size.height }, o, gap / 2)
225
+ );
226
+ if (free(start)) return { x: Math.round(start.x), y: Math.round(start.y) };
227
+ const stepX = size.width + gap;
228
+ const stepY = size.height + gap;
229
+ for (let ring = 1; ring <= maxRings; ring++) {
230
+ const candidates = [];
231
+ for (let i = -ring; i <= ring; i++) {
232
+ candidates.push(
233
+ { x: start.x + ring * stepX, y: start.y + i * stepY },
234
+ { x: start.x - ring * stepX, y: start.y + i * stepY },
235
+ { x: start.x + i * stepX, y: start.y + ring * stepY },
236
+ { x: start.x + i * stepX, y: start.y - ring * stepY }
237
+ );
238
+ }
239
+ candidates.sort(
240
+ (a, b) => Math.hypot(a.x - start.x, a.y - start.y) - Math.hypot(b.x - start.x, b.y - start.y)
241
+ );
242
+ const spot = candidates.find(free);
243
+ if (spot) return { x: Math.round(spot.x), y: Math.round(spot.y) };
244
+ }
245
+ return { x: Math.round(start.x), y: Math.round(start.y) };
246
+ }
206
247
 
207
248
  // src/canvas/arrange.ts
208
249
  var LOCKED_DATA_KEY = "locked";
@@ -588,4 +629,5 @@ function invertNodeUpdates(nodes, updates) {
588
629
 
589
630
 
590
631
 
591
- exports.DEFAULT_NODE_WIDTH = DEFAULT_NODE_WIDTH; exports.DEFAULT_NODE_HEIGHT = DEFAULT_NODE_HEIGHT; exports.DEFAULT_PLACEMENT_GAP = DEFAULT_PLACEMENT_GAP; exports.getCenteredNodePosition = getCenteredNodePosition; exports.centerNodes = centerNodes; exports.getLayoutedNodes = getLayoutedNodes; exports.estimateNodeSize = estimateNodeSize; exports.boundsOf = boundsOf; exports.centre = centre; exports.overlaps = overlaps; exports.flowSide = flowSide; exports.ensureLayout = ensureLayout; exports.placeBeside = placeBeside; exports.LOCKED_DATA_KEY = LOCKED_DATA_KEY; exports.LOCKED_PREVIOUS_FLAGS_KEY = LOCKED_PREVIOUS_FLAGS_KEY; exports.readStyleSize = readStyleSize; exports.withStyleSize = withStyleSize; exports.getNodeSize = getNodeSize; exports.getAbsolutePosition = getAbsolutePosition; exports.createNodeLookup = createNodeLookup; exports.getNodeRect = getNodeRect; exports.isLocked = isLocked; exports.lockNodes = lockNodes; exports.unlockNodes = unlockNodes; exports.toggleLockNodes = toggleLockNodes; exports.alignNodes = alignNodes; exports.distributeNodes = distributeNodes; exports.matchSize = matchSize; exports.reorderNodes = reorderNodes; exports.applyNodeUpdates = applyNodeUpdates; exports.invertNodeUpdates = invertNodeUpdates;
632
+
633
+ exports.DEFAULT_NODE_WIDTH = DEFAULT_NODE_WIDTH; exports.DEFAULT_NODE_HEIGHT = DEFAULT_NODE_HEIGHT; exports.DEFAULT_PLACEMENT_GAP = DEFAULT_PLACEMENT_GAP; exports.getCenteredNodePosition = getCenteredNodePosition; exports.centerNodes = centerNodes; exports.getLayoutedNodes = getLayoutedNodes; exports.estimateNodeSize = estimateNodeSize; exports.boundsOf = boundsOf; exports.centre = centre; exports.overlaps = overlaps; exports.flowSide = flowSide; exports.ensureLayout = ensureLayout; exports.placeBeside = placeBeside; exports.placeInView = placeInView; exports.LOCKED_DATA_KEY = LOCKED_DATA_KEY; exports.LOCKED_PREVIOUS_FLAGS_KEY = LOCKED_PREVIOUS_FLAGS_KEY; exports.readStyleSize = readStyleSize; exports.withStyleSize = withStyleSize; exports.getNodeSize = getNodeSize; exports.getAbsolutePosition = getAbsolutePosition; exports.createNodeLookup = createNodeLookup; exports.getNodeRect = getNodeRect; exports.isLocked = isLocked; exports.lockNodes = lockNodes; exports.unlockNodes = unlockNodes; exports.toggleLockNodes = toggleLockNodes; exports.alignNodes = alignNodes; exports.distributeNodes = distributeNodes; exports.matchSize = matchSize; exports.reorderNodes = reorderNodes; exports.applyNodeUpdates = applyNodeUpdates; exports.invertNodeUpdates = invertNodeUpdates;
@@ -107,7 +107,7 @@ var AgentPlayback = class {
107
107
  constructor(options = {}) {
108
108
  this.clock = options.clock ?? realPresenceClock;
109
109
  this.speed = options.speed ?? 1;
110
- this.reads = options.reads ?? "glance";
110
+ this.reads = options.reads ?? "skip";
111
111
  this.linger = options.linger ?? 1500;
112
112
  this.defaultActor = options.actor ?? { id: "agent", name: "Agent" };
113
113
  }
@@ -143,11 +143,16 @@ var AgentPlayback = class {
143
143
  surface(id) {
144
144
  return this.surfaces.get(id);
145
145
  }
146
- /** Shows `text` in the actor's bubble on the surface it last worked on (until its next step). */
146
+ /**
147
+ * Shows `text` in the actor's bubble on the surface it last worked on (until its next step).
148
+ * Returns that surface's id, or null when the actor has no cursor on screen (nothing shown).
149
+ */
147
150
  say(text, options = {}) {
148
151
  const actor = this.actorState(options.actor);
149
152
  const surface = actor.surface ? this.surfaces.get(actor.surface) : void 0;
150
- if (surface?.presence.get(actor.info.id)) surface.presence.set({ id: actor.info.id, message: text });
153
+ if (!surface?.presence.get(actor.info.id)) return null;
154
+ surface.presence.set({ id: actor.info.id, message: text });
155
+ return actor.surface;
151
156
  }
152
157
  /** Finishes every running performance at once (the calls still run and keep their results). */
153
158
  stop() {
@@ -396,6 +401,39 @@ var AgentPlayback = class {
396
401
  function createAgentPlayback(options = {}) {
397
402
  return new AgentPlayback(options);
398
403
  }
404
+ function createPlaybackToolProvider(playback, options = {}) {
405
+ const title = "Say a note by your cursor";
406
+ return {
407
+ id: options.id ?? "playback",
408
+ namespace: options.namespace,
409
+ title: "Agent playback",
410
+ description: "Notes shown beside your cursor while the host plays your calls on screen.",
411
+ skill: "pixerate-agent-tools",
412
+ tools: [
413
+ {
414
+ name: "say",
415
+ title,
416
+ description: "Shows a short note in the bubble beside your cursor on the editor you last worked on, so the user can follow what you are doing; it stays until your next call. Changes no document. Returns shown (whether a cursor was on screen to show it) and surface (that editor, or null).",
417
+ inputSchema: {
418
+ type: "object",
419
+ properties: {
420
+ text: { type: "string", minLength: 1, maxLength: 200, description: "The note: one short sentence, at most 200 characters." }
421
+ },
422
+ required: ["text"],
423
+ additionalProperties: false
424
+ },
425
+ annotations: { title, readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
426
+ playback: false,
427
+ handler: ({ text }, context) => {
428
+ const note = String(text).trim();
429
+ if (!note) throw new Error('text is empty; pass the note to show, e.g. "Aligning the cards."');
430
+ const surface = playback.say(note, { actor: context.actor });
431
+ return { shown: surface !== null, surface };
432
+ }
433
+ }
434
+ ]
435
+ };
436
+ }
399
437
 
400
438
  export {
401
439
  playbackRefsFromArgs,
@@ -404,5 +442,6 @@ export {
404
442
  readingTime,
405
443
  unionRects,
406
444
  AgentPlayback,
407
- createAgentPlayback
445
+ createAgentPlayback,
446
+ createPlaybackToolProvider
408
447
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readingTime
3
- } from "./chunk-54GVEVXS.js";
3
+ } from "./chunk-HUHBJWTD.js";
4
4
 
5
5
  // src/tools/script.ts
6
6
  function toolResultValue(result) {
@@ -4,8 +4,14 @@ var DEFAULT_NODE_WIDTH = 200;
4
4
  var DEFAULT_NODE_HEIGHT = 60;
5
5
  var DEFAULT_PLACEMENT_GAP = 48;
6
6
  function getCenteredNodePosition(width = 0, height = 0, screenToFlowPosition, screenDimensions) {
7
- const rect = screenDimensions ?? (typeof document !== "undefined" ? { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight } : { width: 1920, height: 1080 });
8
- const flowPos = screenToFlowPosition({ x: rect.width / 2, y: rect.height / 2 });
7
+ const rect = screenDimensions ?? (typeof document !== "undefined" ? {
8
+ width: document.documentElement.clientWidth,
9
+ height: document.documentElement.clientHeight
10
+ } : { width: 1920, height: 1080 });
11
+ const flowPos = screenToFlowPosition({
12
+ x: rect.width / 2,
13
+ y: rect.height / 2
14
+ });
9
15
  return {
10
16
  x: flowPos.x - width / 2,
11
17
  y: flowPos.y - height / 2
@@ -73,7 +79,10 @@ function getLayoutedNodes(nodes, edges, getNodesBounds, options = {}) {
73
79
  function estimateNodeSize(node, defaultWidth = DEFAULT_NODE_WIDTH, defaultHeight = DEFAULT_NODE_HEIGHT) {
74
80
  const label = String(node.data?.label ?? node.data?.title ?? node.id ?? "");
75
81
  const lines = label.split(/\n|<br\s*\/?>/);
76
- const longest = Math.max(...lines.map((l) => l.replace(/<[^>]+>/g, "").length), 1);
82
+ const longest = Math.max(
83
+ ...lines.map((l) => l.replace(/<[^>]+>/g, "").length),
84
+ 1
85
+ );
77
86
  const width = Math.min(480, Math.max(defaultWidth, longest * 8 + 48));
78
87
  const height = Math.max(defaultHeight, lines.length * 20 + 24);
79
88
  return { width, height };
@@ -203,6 +212,38 @@ function placeBeside(rects, size, side, nearNodeId, options = {}) {
203
212
  y: Math.round(baseY)
204
213
  };
205
214
  }
215
+ function placeInView(rects, size, view, options = {}) {
216
+ const gap = options.gap ?? DEFAULT_PLACEMENT_GAP;
217
+ const maxRings = options.maxRings ?? 24;
218
+ const obstacles = Object.values(rects);
219
+ const start = {
220
+ x: view.x + view.width / 2 - size.width / 2,
221
+ y: view.y + view.height / 2 - size.height / 2
222
+ };
223
+ const free = (p) => !obstacles.some(
224
+ (o) => overlaps({ ...p, width: size.width, height: size.height }, o, gap / 2)
225
+ );
226
+ if (free(start)) return { x: Math.round(start.x), y: Math.round(start.y) };
227
+ const stepX = size.width + gap;
228
+ const stepY = size.height + gap;
229
+ for (let ring = 1; ring <= maxRings; ring++) {
230
+ const candidates = [];
231
+ for (let i = -ring; i <= ring; i++) {
232
+ candidates.push(
233
+ { x: start.x + ring * stepX, y: start.y + i * stepY },
234
+ { x: start.x - ring * stepX, y: start.y + i * stepY },
235
+ { x: start.x + i * stepX, y: start.y + ring * stepY },
236
+ { x: start.x + i * stepX, y: start.y - ring * stepY }
237
+ );
238
+ }
239
+ candidates.sort(
240
+ (a, b) => Math.hypot(a.x - start.x, a.y - start.y) - Math.hypot(b.x - start.x, b.y - start.y)
241
+ );
242
+ const spot = candidates.find(free);
243
+ if (spot) return { x: Math.round(spot.x), y: Math.round(spot.y) };
244
+ }
245
+ return { x: Math.round(start.x), y: Math.round(start.y) };
246
+ }
206
247
 
207
248
  // src/canvas/arrange.ts
208
249
  var LOCKED_DATA_KEY = "locked";
@@ -570,6 +611,7 @@ export {
570
611
  flowSide,
571
612
  ensureLayout,
572
613
  placeBeside,
614
+ placeInView,
573
615
  LOCKED_DATA_KEY,
574
616
  LOCKED_PREVIOUS_FLAGS_KEY,
575
617
  readStyleSize,
@@ -29,7 +29,7 @@ var _chunkGLQQ2VILcjs = require('../chunk-GLQQ2VIL.cjs');
29
29
  var _chunk4EFNS2HVcjs = require('../chunk-4EFNS2HV.cjs');
30
30
 
31
31
 
32
- var _chunkX2HQP7DFcjs = require('../chunk-X2HQP7DF.cjs');
32
+ var _chunkD2ENR3LBcjs = require('../chunk-D2ENR3LB.cjs');
33
33
  require('../chunk-UJGAA6AK.cjs');
34
34
 
35
35
 
@@ -608,7 +608,7 @@ function createCommandToolProvider(registry, options = {}) {
608
608
  const surface = _nullishCoalesce(_nullishCoalesce(spec.playbackSurface, () => ( spec.scope)), () => ( (id.includes(".") ? id.slice(0, id.indexOf(".")) : void 0)));
609
609
  const planned = _optionalChain([spec, 'access', _24 => _24.plan, 'optionalCall', _25 => _25(context(), _nullishCoalesce(params, () => ( {})))]);
610
610
  const own = !planned ? [] : Array.isArray(planned) ? planned : planned.steps;
611
- const steps = own.length ? own : _chunkX2HQP7DFcjs.derivePlaybackSteps.call(void 0, params);
611
+ const steps = own.length ? own : _chunkD2ENR3LBcjs.derivePlaybackSteps.call(void 0, params);
612
612
  return {
613
613
  steps,
614
614
  ...surface ? { surface } : {},
@@ -29,7 +29,7 @@ import {
29
29
  } from "../chunk-7KZ2HKKC.js";
30
30
  import {
31
31
  derivePlaybackSteps
32
- } from "../chunk-54GVEVXS.js";
32
+ } from "../chunk-HUHBJWTD.js";
33
33
  import "../chunk-PEEP2YR7.js";
34
34
  import {
35
35
  validateJsonSchema
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkXH32BATEcjs = require('../chunk-XH32BATE.cjs');
5
+ var _chunkAG2EXVCRcjs = require('../chunk-AG2EXVCR.cjs');
6
6
 
7
7
 
8
8
 
@@ -37,7 +37,8 @@ var _chunkY4BWZB6Jcjs = require('../chunk-Y4BWZB6J.cjs');
37
37
 
38
38
 
39
39
 
40
- var _chunkX2HQP7DFcjs = require('../chunk-X2HQP7DF.cjs');
40
+
41
+ var _chunkD2ENR3LBcjs = require('../chunk-D2ENR3LB.cjs');
41
42
 
42
43
 
43
44
 
@@ -169,4 +170,5 @@ var _chunkWOFXZ3XUcjs = require('../chunk-WOFXZ3XU.cjs');
169
170
 
170
171
 
171
172
 
172
- exports.AgentPlayback = _chunkX2HQP7DFcjs.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 = _chunkX2HQP7DFcjs.createAgentPlayback; exports.createCaptureTool = _chunkN2FGYZ4Qcjs.createCaptureTool; exports.createCaptureToolProvider = _chunkN2FGYZ4Qcjs.createCaptureToolProvider; exports.createElementCaptureSurface = _chunkSVFEVKLFcjs.createElementCaptureSurface; exports.createInstantPresenceClock = _chunkUJGAA6AKcjs.createInstantPresenceClock; exports.createMcpServer = _chunkY4BWZB6Jcjs.createMcpServer; exports.createToolRegistry = _chunkY4BWZB6Jcjs.createToolRegistry; exports.derivePlaybackSteps = _chunkX2HQP7DFcjs.derivePlaybackSteps; exports.elementToSvg = _chunkSVFEVKLFcjs.elementToSvg; exports.errorResult = _chunkY4BWZB6Jcjs.errorResult; exports.isUnsafeJsonKey = _chunk2BSBFBOAcjs.isUnsafeJsonKey; exports.listSkills = _chunkY4BWZB6Jcjs.listSkills; exports.parseSkillFrontmatter = _chunkY4BWZB6Jcjs.parseSkillFrontmatter; exports.playbackRefsFromArgs = _chunkX2HQP7DFcjs.playbackRefsFromArgs; exports.playbackRefsFromResult = _chunkX2HQP7DFcjs.playbackRefsFromResult; exports.rasterizeElement = _chunkSVFEVKLFcjs.rasterizeElement; exports.readSkillFile = _chunkY4BWZB6Jcjs.readSkillFile; exports.readingTime = _chunkX2HQP7DFcjs.readingTime; exports.realPresenceClock = _chunkUJGAA6AKcjs.realPresenceClock; exports.resolveCaptureRequest = _chunkN2FGYZ4Qcjs.resolveCaptureRequest; exports.runToolScript = _chunkXH32BATEcjs.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.toolResultError = _chunkXH32BATEcjs.toolResultError; exports.toolResultValue = _chunkXH32BATEcjs.toolResultValue; exports.toolsetInstructions = _chunkY4BWZB6Jcjs.toolsetInstructions; exports.toolsetName = _chunkY4BWZB6Jcjs.toolsetName; exports.tweenPresenceCursor = _chunkUJGAA6AKcjs.tweenPresenceCursor; exports.unionCaptureRects = _chunkN2FGYZ4Qcjs.unionCaptureRects; exports.unionRects = _chunkX2HQP7DFcjs.unionRects; exports.unknownToolMessage = _chunkY4BWZB6Jcjs.unknownToolMessage; exports.validateJsonSchema = _chunkWOFXZ3XUcjs.validateJsonSchema;
173
+
174
+ 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.createCaptureTool = _chunkN2FGYZ4Qcjs.createCaptureTool; exports.createCaptureToolProvider = _chunkN2FGYZ4Qcjs.createCaptureToolProvider; exports.createElementCaptureSurface = _chunkSVFEVKLFcjs.createElementCaptureSurface; exports.createInstantPresenceClock = _chunkUJGAA6AKcjs.createInstantPresenceClock; exports.createMcpServer = _chunkY4BWZB6Jcjs.createMcpServer; exports.createPlaybackToolProvider = _chunkD2ENR3LBcjs.createPlaybackToolProvider; 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.parseSkillFrontmatter = _chunkY4BWZB6Jcjs.parseSkillFrontmatter; 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.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.validateJsonSchema = _chunkWOFXZ3XUcjs.validateJsonSchema;
@@ -2,7 +2,7 @@ import {
2
2
  runToolScript,
3
3
  toolResultError,
4
4
  toolResultValue
5
- } from "../chunk-Y6SGC6KO.js";
5
+ } from "../chunk-SA37RU2O.js";
6
6
  import {
7
7
  JSON_RPC_ERRORS,
8
8
  MCP_PROTOCOL_VERSIONS,
@@ -32,12 +32,13 @@ import {
32
32
  import {
33
33
  AgentPlayback,
34
34
  createAgentPlayback,
35
+ createPlaybackToolProvider,
35
36
  derivePlaybackSteps,
36
37
  playbackRefsFromArgs,
37
38
  playbackRefsFromResult,
38
39
  readingTime,
39
40
  unionRects
40
- } from "../chunk-54GVEVXS.js";
41
+ } from "../chunk-HUHBJWTD.js";
41
42
  import {
42
43
  CAPTURE_EXCLUDE_SELECTOR,
43
44
  CAPTURE_OVERLAY_SELECTORS,
@@ -139,6 +140,7 @@ export {
139
140
  createElementCaptureSurface,
140
141
  createInstantPresenceClock,
141
142
  createMcpServer,
143
+ createPlaybackToolProvider,
142
144
  createToolRegistry,
143
145
  derivePlaybackSteps,
144
146
  elementToSvg,
@@ -1,4 +1,4 @@
1
- import type { ToolMiddleware, ToolRegistry } from './registry.cjs';
1
+ import type { AgentToolProvider, ToolMiddleware, ToolRegistry } from './registry.cjs';
2
2
  import { type PresenceActorInfo, type PresenceClock, type PresenceStore } from './presence.cjs';
3
3
  export interface PlaybackPoint {
4
4
  x: number;
@@ -116,7 +116,7 @@ export interface AgentPlaybackOptions {
116
116
  clock?: PresenceClock;
117
117
  /** 1 = natural pace, 2 = twice as fast, `Infinity` = no animation (default 1). */
118
118
  speed?: number;
119
- /** Read-only tools: `glance` moves to their target only (default), `skip` doesn't, `play` plays them like writes. */
119
+ /** Read-only tools: `skip` shows only changes (default), `glance` moves to their target only, `play` plays them like writes. */
120
120
  reads?: PlaybackReads;
121
121
  /** Hide a cursor this long after its actor's last call (ms, default 1500; 0 keeps it). */
122
122
  linger?: number;
@@ -183,10 +183,13 @@ export declare class AgentPlayback {
183
183
  attach(id: string, surface: PlaybackSurface): () => void;
184
184
  /** The surface attached under `id`. */
185
185
  surface(id: string): PlaybackSurface | undefined;
186
- /** Shows `text` in the actor's bubble on the surface it last worked on (until its next step). */
186
+ /**
187
+ * Shows `text` in the actor's bubble on the surface it last worked on (until its next step).
188
+ * Returns that surface's id, or null when the actor has no cursor on screen (nothing shown).
189
+ */
187
190
  say(text: string, options?: {
188
191
  actor?: PresenceActorInfo;
189
- }): void;
192
+ }): string | null;
190
193
  /** Finishes every running performance at once (the calls still run and keep their results). */
191
194
  stop(): void;
192
195
  /** Collects every step played from now on (for tests). */
@@ -203,3 +206,14 @@ export declare class AgentPlayback {
203
206
  }
204
207
  /** An {@link AgentPlayback}: install it on a registry and attach editor surfaces to see calls played. */
205
208
  export declare function createAgentPlayback(options?: AgentPlaybackOptions): AgentPlayback;
209
+ export interface PlaybackToolProviderOptions {
210
+ /** Provider id and default namespace (default `playback`, so the tool is `playback__say`). */
211
+ id?: string;
212
+ namespace?: string;
213
+ }
214
+ /**
215
+ * The optional `say` tool: lets an agent put a short note in its cursor's bubble, through
216
+ * {@link AgentPlayback.say}. Register it only where a UI shows the cursors; it changes no document
217
+ * and is never played itself. Without a cursor on screen it shows nothing and says so.
218
+ */
219
+ export declare function createPlaybackToolProvider(playback: AgentPlayback, options?: PlaybackToolProviderOptions): AgentToolProvider;
@@ -1,4 +1,4 @@
1
- import type { ToolMiddleware, ToolRegistry } from './registry.js';
1
+ import type { AgentToolProvider, ToolMiddleware, ToolRegistry } from './registry.js';
2
2
  import { type PresenceActorInfo, type PresenceClock, type PresenceStore } from './presence.js';
3
3
  export interface PlaybackPoint {
4
4
  x: number;
@@ -116,7 +116,7 @@ export interface AgentPlaybackOptions {
116
116
  clock?: PresenceClock;
117
117
  /** 1 = natural pace, 2 = twice as fast, `Infinity` = no animation (default 1). */
118
118
  speed?: number;
119
- /** Read-only tools: `glance` moves to their target only (default), `skip` doesn't, `play` plays them like writes. */
119
+ /** Read-only tools: `skip` shows only changes (default), `glance` moves to their target only, `play` plays them like writes. */
120
120
  reads?: PlaybackReads;
121
121
  /** Hide a cursor this long after its actor's last call (ms, default 1500; 0 keeps it). */
122
122
  linger?: number;
@@ -183,10 +183,13 @@ export declare class AgentPlayback {
183
183
  attach(id: string, surface: PlaybackSurface): () => void;
184
184
  /** The surface attached under `id`. */
185
185
  surface(id: string): PlaybackSurface | undefined;
186
- /** Shows `text` in the actor's bubble on the surface it last worked on (until its next step). */
186
+ /**
187
+ * Shows `text` in the actor's bubble on the surface it last worked on (until its next step).
188
+ * Returns that surface's id, or null when the actor has no cursor on screen (nothing shown).
189
+ */
187
190
  say(text: string, options?: {
188
191
  actor?: PresenceActorInfo;
189
- }): void;
192
+ }): string | null;
190
193
  /** Finishes every running performance at once (the calls still run and keep their results). */
191
194
  stop(): void;
192
195
  /** Collects every step played from now on (for tests). */
@@ -203,3 +206,14 @@ export declare class AgentPlayback {
203
206
  }
204
207
  /** An {@link AgentPlayback}: install it on a registry and attach editor surfaces to see calls played. */
205
208
  export declare function createAgentPlayback(options?: AgentPlaybackOptions): AgentPlayback;
209
+ export interface PlaybackToolProviderOptions {
210
+ /** Provider id and default namespace (default `playback`, so the tool is `playback__say`). */
211
+ id?: string;
212
+ namespace?: string;
213
+ }
214
+ /**
215
+ * The optional `say` tool: lets an agent put a short note in its cursor's bubble, through
216
+ * {@link AgentPlayback.say}. Register it only where a UI shows the cursors; it changes no document
217
+ * and is never played itself. Without a cursor on screen it shows nothing and says so.
218
+ */
219
+ export declare function createPlaybackToolProvider(playback: AgentPlayback, options?: PlaybackToolProviderOptions): AgentToolProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.142.1",
3
+ "version": "0.144.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",