@pixerate/editor 0.140.4 → 0.141.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/agent/canvasPlayback.d.cts +15 -0
  2. package/dist/agent/canvasPlayback.d.ts +15 -0
  3. package/dist/agent/index.cjs +144 -23
  4. package/dist/agent/index.d.cts +1 -0
  5. package/dist/agent/index.d.ts +1 -0
  6. package/dist/agent/index.js +125 -4
  7. package/dist/agent/providers.d.cts +8 -0
  8. package/dist/agent/providers.d.ts +8 -0
  9. package/dist/agent/types.d.cts +3 -0
  10. package/dist/agent/types.d.ts +3 -0
  11. package/dist/animation/index.cjs +2 -2
  12. package/dist/animation/index.js +1 -1
  13. package/dist/animation/presence.d.cts +1 -75
  14. package/dist/animation/presence.d.ts +1 -75
  15. package/dist/bridge/cli.cjs +3 -3
  16. package/dist/bridge/cli.js +2 -2
  17. package/dist/bridge/index.cjs +3 -3
  18. package/dist/bridge/index.js +2 -2
  19. package/dist/canvas/index.cjs +336 -646
  20. package/dist/canvas/index.d.cts +1 -0
  21. package/dist/canvas/index.d.ts +1 -0
  22. package/dist/canvas/index.js +44 -354
  23. package/dist/canvas/playback.d.cts +14 -0
  24. package/dist/canvas/playback.d.ts +14 -0
  25. package/dist/chart/index.cjs +7 -7
  26. package/dist/chart/index.js +1 -1
  27. package/dist/chunk-6SFREX6H.cjs +406 -0
  28. package/dist/chunk-DW4CV5H4.js +591 -0
  29. package/dist/{chunk-UMS6YFA6.js → chunk-EAQ4BGNS.js} +1 -1
  30. package/dist/{chunk-AGCD3EHB.cjs → chunk-ENIZYNEF.cjs} +7 -7
  31. package/dist/chunk-MFFE55CS.js +406 -0
  32. package/dist/{chunk-BSGPXPTW.js → chunk-PEEP2YR7.js} +1 -1
  33. package/dist/{chunk-RB62U6MS.js → chunk-RFBFTLVN.js} +27 -5
  34. package/dist/chunk-UBRYHNRU.cjs +591 -0
  35. package/dist/{chunk-GEY73RUW.cjs → chunk-UJGAA6AK.cjs} +1 -1
  36. package/dist/{chunk-HDK3T2QS.cjs → chunk-Y4BWZB6J.cjs} +29 -7
  37. package/dist/commands/index.cjs +37 -1
  38. package/dist/commands/index.js +36 -0
  39. package/dist/commands/registry.d.cts +11 -0
  40. package/dist/commands/registry.d.ts +11 -0
  41. package/dist/diagram/index.cjs +7 -7
  42. package/dist/diagram/index.js +1 -1
  43. package/dist/image-editor/index.cjs +108 -16
  44. package/dist/image-editor/index.d.cts +1 -0
  45. package/dist/image-editor/index.d.ts +1 -0
  46. package/dist/image-editor/index.js +107 -15
  47. package/dist/image-editor/playback.d.cts +22 -0
  48. package/dist/image-editor/playback.d.ts +22 -0
  49. package/dist/paint-editor/index.cjs +6 -6
  50. package/dist/paint-editor/index.js +1 -1
  51. package/dist/tools/index.cjs +33 -3
  52. package/dist/tools/index.d.cts +2 -0
  53. package/dist/tools/index.d.ts +2 -0
  54. package/dist/tools/index.js +32 -2
  55. package/dist/tools/playback.d.cts +205 -0
  56. package/dist/tools/playback.d.ts +205 -0
  57. package/dist/tools/presence.d.cts +82 -0
  58. package/dist/tools/presence.d.ts +82 -0
  59. package/dist/tools/registry.d.cts +45 -6
  60. package/dist/tools/registry.d.ts +45 -6
  61. package/dist/tools/view.d.cts +2 -4
  62. package/dist/tools/view.d.ts +2 -4
  63. package/dist/vector/index.cjs +217 -100
  64. package/dist/vector/index.d.cts +1 -0
  65. package/dist/vector/index.d.ts +1 -0
  66. package/dist/vector/index.js +140 -23
  67. package/dist/vector/playback.d.cts +13 -0
  68. package/dist/vector/playback.d.ts +13 -0
  69. package/package.json +1 -1
  70. package/skills/pixerate-agent-tools/SKILL.md +13 -0
  71. package/skills/pixerate-canvas/SKILL.md +3 -0
  72. package/skills/pixerate-image-editor/SKILL.md +2 -2
  73. package/skills/pixerate-vector/SKILL.md +5 -0
  74. package/dist/chunk-BTZS3KZY.js +0 -221
  75. package/dist/chunk-MRD3NXKR.cjs +0 -221
  76. /package/dist/{chunk-K73HMKQP.js → chunk-PLKIYNJZ.js} +0 -0
  77. /package/dist/{chunk-LACYURUW.cjs → chunk-TNCWKC5M.cjs} +0 -0
@@ -1,5 +1,7 @@
1
1
  import { type JsonSchema, type SchemaValidationError } from './schema.js';
2
2
  import { ToolRegistryView, type ToolViewOptions } from './view.js';
3
+ import type { ToolPlanner } from './playback.js';
4
+ import type { PresenceActorInfo } from './presence.js';
3
5
  /**
4
6
  * MCP-shaped tool definition, as returned by `tools/list`.
5
7
  */
@@ -47,6 +49,14 @@ export interface ToolCallContext {
47
49
  /** Id of the provider that owns the tool. */
48
50
  providerId: string;
49
51
  signal?: AbortSignal;
52
+ /** Who is calling (an MCP client, a scripted agent), for agent playback's cursors and queues. */
53
+ actor?: PresenceActorInfo;
54
+ }
55
+ /** Options for `callTool`. */
56
+ export interface ToolCallOptions {
57
+ signal?: AbortSignal;
58
+ /** Who is calling; agent playback gives each actor its own cursor and queue. */
59
+ actor?: PresenceActorInfo;
50
60
  }
51
61
  /**
52
62
  * Handler return values are normalized into an {@link McpToolResult}: a full
@@ -57,6 +67,17 @@ export interface ToolCallContext {
57
67
  export type AgentToolHandler = (args: Record<string, any>, context: ToolCallContext) => unknown | Promise<unknown>;
58
68
  export interface AgentTool extends McpToolDefinition {
59
69
  handler: AgentToolHandler;
70
+ /**
71
+ * How agent playback acts this tool out (see `createAgentPlayback`): `'self'` when the
72
+ * handler drives its own cursor (a director), `false` to never play it. Default: play it
73
+ * from `plan`, or from the ids in its arguments and result.
74
+ */
75
+ playback?: 'self' | false;
76
+ /**
77
+ * Pure planner for agent playback: the cursor steps (surface coordinates) that act out a
78
+ * call with these arguments, given the state before the call. Not sent to clients.
79
+ */
80
+ plan?: ToolPlanner;
60
81
  }
61
82
  /**
62
83
  * A source of tools, typically one per mounted editor, spreadsheet or canvas.
@@ -83,7 +104,23 @@ export interface AgentToolProvider {
83
104
  tools: readonly AgentTool[] | (() => readonly AgentTool[]);
84
105
  /** Lets the provider signal that its tool list changed; returns an unsubscribe function. */
85
106
  subscribe?: (notify: () => void) => () => void;
107
+ /** The playback surface its calls are acted out on (default: the provider id). */
108
+ playbackSurface?: string;
86
109
  }
110
+ /** A tool call as a {@link ToolMiddleware} sees it (arguments already validated). */
111
+ export interface ToolMiddlewareCall {
112
+ /** The exposed (possibly namespaced) name. */
113
+ name: string;
114
+ tool: AgentTool;
115
+ provider: AgentToolProvider;
116
+ args: Record<string, any>;
117
+ context: ToolCallContext;
118
+ }
119
+ /**
120
+ * Wraps every tool call of a registry (`registry.use`): call `next()` to run the handler (or
121
+ * the next middleware) and return its value. A throw becomes an `isError` result.
122
+ */
123
+ export type ToolMiddleware = (call: ToolMiddlewareCall, next: () => Promise<unknown>) => Promise<unknown>;
87
124
  export type ToolErrorCode = 'unknown_tool' | 'invalid_arguments' | 'tool_failed';
88
125
  /** Structured error carried in `structuredContent.error` of a failed call. */
89
126
  export interface ToolCallError {
@@ -152,9 +189,7 @@ export interface ToolSource {
152
189
  listTools(): McpListToolsResult;
153
190
  hasTool(name: string): boolean;
154
191
  getTool(name: string): McpToolDefinition | undefined;
155
- callTool(name: string, args?: Record<string, unknown>, options?: {
156
- signal?: AbortSignal;
157
- }): Promise<McpToolResult>;
192
+ callTool(name: string, args?: Record<string, unknown>, options?: ToolCallOptions): Promise<McpToolResult>;
158
193
  onListChanged(listener: (tools: McpToolDefinition[]) => void): () => void;
159
194
  /** The toolsets behind `listTools()`, in listing order. */
160
195
  toolsets(): ToolsetInfo[];
@@ -182,6 +217,7 @@ export declare class ToolRegistry implements ToolSource {
182
217
  };
183
218
  private readonly entries;
184
219
  private readonly listeners;
220
+ private readonly middleware;
185
221
  private readonly options;
186
222
  private timer;
187
223
  private lastSignature;
@@ -194,6 +230,11 @@ export declare class ToolRegistry implements ToolSource {
194
230
  register(provider: AgentToolProvider): () => void;
195
231
  /** Removes a provider by id or instance. Returns whether it was registered. */
196
232
  unregister(providerOrId: string | AgentToolProvider): boolean;
233
+ /**
234
+ * Adds a middleware that wraps every tool call (first added runs outermost), e.g. agent
235
+ * playback's `playback.middleware`. Returns a function that removes it.
236
+ */
237
+ use(middleware: ToolMiddleware): () => void;
197
238
  /** Registered provider ids in registration order. */
198
239
  providerIds(): string[];
199
240
  /**
@@ -222,9 +263,7 @@ export declare class ToolRegistry implements ToolSource {
222
263
  * `structuredContent.error` (MCP transports may map `unknown_tool` to a
223
264
  * JSON-RPC `-32602` error instead).
224
265
  */
225
- callTool(name: string, args?: Record<string, unknown>, options?: {
226
- signal?: AbortSignal;
227
- }): Promise<McpToolResult>;
266
+ callTool(name: string, args?: Record<string, unknown>, options?: ToolCallOptions): Promise<McpToolResult>;
228
267
  /**
229
268
  * Subscribes to tool-list changes. Notifications are coalesced: many
230
269
  * registrations or provider signals within the delay window produce one
@@ -1,4 +1,4 @@
1
- import type { McpListToolsResult, McpToolDefinition, McpToolResult, ToolSource, ToolsetInfo } from './registry.cjs';
1
+ import type { McpListToolsResult, McpToolDefinition, McpToolResult, ToolCallOptions, ToolSource, ToolsetInfo } from './registry.cjs';
2
2
  import { type SkillFiles } from './skills.cjs';
3
3
  export interface ToolDiscoveryOptions {
4
4
  /** Toolsets listed from the start (default none: the agent enables what it needs). */
@@ -76,9 +76,7 @@ export declare class ToolRegistryView implements ToolSource {
76
76
  listTools(): McpListToolsResult;
77
77
  hasTool(name: string): boolean;
78
78
  getTool(name: string): McpToolDefinition | undefined;
79
- callTool(name: string, args?: Record<string, unknown>, options?: {
80
- signal?: AbortSignal;
81
- }): Promise<McpToolResult>;
79
+ callTool(name: string, args?: Record<string, unknown>, options?: ToolCallOptions): Promise<McpToolResult>;
82
80
  onListChanged(listener: (tools: McpToolDefinition[]) => void): () => void;
83
81
  /** Stops following the source and drops every listener. */
84
82
  dispose(): void;
@@ -1,4 +1,4 @@
1
- import type { McpListToolsResult, McpToolDefinition, McpToolResult, ToolSource, ToolsetInfo } from './registry.js';
1
+ import type { McpListToolsResult, McpToolDefinition, McpToolResult, ToolCallOptions, ToolSource, ToolsetInfo } from './registry.js';
2
2
  import { type SkillFiles } from './skills.js';
3
3
  export interface ToolDiscoveryOptions {
4
4
  /** Toolsets listed from the start (default none: the agent enables what it needs). */
@@ -76,9 +76,7 @@ export declare class ToolRegistryView implements ToolSource {
76
76
  listTools(): McpListToolsResult;
77
77
  hasTool(name: string): boolean;
78
78
  getTool(name: string): McpToolDefinition | undefined;
79
- callTool(name: string, args?: Record<string, unknown>, options?: {
80
- signal?: AbortSignal;
81
- }): Promise<McpToolResult>;
79
+ callTool(name: string, args?: Record<string, unknown>, options?: ToolCallOptions): Promise<McpToolResult>;
82
80
  onListChanged(listener: (tools: McpToolDefinition[]) => void): () => void;
83
81
  /** Stops following the source and drops every listener. */
84
82
  dispose(): void;