@particle-academy/agent-integrations 0.8.0 → 0.9.1

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 (134) hide show
  1. package/README.md +8 -0
  2. package/dist/bridges/artboard.d.cts +3 -3
  3. package/dist/bridges/artboard.d.ts +3 -3
  4. package/dist/bridges/charts.d.cts +3 -3
  5. package/dist/bridges/charts.d.ts +3 -3
  6. package/dist/bridges/code.d.cts +3 -3
  7. package/dist/bridges/code.d.ts +3 -3
  8. package/dist/bridges/flow.d.cts +3 -3
  9. package/dist/bridges/flow.d.ts +3 -3
  10. package/dist/bridges/forms.d.cts +3 -3
  11. package/dist/bridges/forms.d.ts +3 -3
  12. package/dist/bridges/scene.d.cts +3 -3
  13. package/dist/bridges/scene.d.ts +3 -3
  14. package/dist/bridges/screens.d.cts +3 -3
  15. package/dist/bridges/screens.d.ts +3 -3
  16. package/dist/bridges/sheets.d.cts +3 -3
  17. package/dist/bridges/sheets.d.ts +3 -3
  18. package/dist/bridges/slides.d.cts +3 -3
  19. package/dist/bridges/slides.d.ts +3 -3
  20. package/dist/bridges/whiteboard.d.cts +3 -3
  21. package/dist/bridges/whiteboard.d.ts +3 -3
  22. package/dist/bridges-artboard.cjs +15 -54
  23. package/dist/bridges-artboard.cjs.map +1 -1
  24. package/dist/bridges-artboard.js +3 -3
  25. package/dist/bridges-charts.cjs +3 -5
  26. package/dist/bridges-charts.cjs.map +1 -1
  27. package/dist/bridges-charts.js +3 -3
  28. package/dist/bridges-code.cjs +3 -5
  29. package/dist/bridges-code.cjs.map +1 -1
  30. package/dist/bridges-code.js +3 -3
  31. package/dist/bridges-flow.cjs +3 -5
  32. package/dist/bridges-flow.cjs.map +1 -1
  33. package/dist/bridges-flow.js +2 -2
  34. package/dist/bridges-forms.cjs +3 -5
  35. package/dist/bridges-forms.cjs.map +1 -1
  36. package/dist/bridges-forms.js +3 -3
  37. package/dist/bridges-scene.cjs +3 -5
  38. package/dist/bridges-scene.cjs.map +1 -1
  39. package/dist/bridges-scene.js +3 -3
  40. package/dist/bridges-screens.cjs +3 -5
  41. package/dist/bridges-screens.cjs.map +1 -1
  42. package/dist/bridges-screens.js +3 -3
  43. package/dist/bridges-sheets.cjs +3 -5
  44. package/dist/bridges-sheets.cjs.map +1 -1
  45. package/dist/bridges-sheets.js +3 -3
  46. package/dist/bridges-slides.cjs +2 -5
  47. package/dist/bridges-slides.cjs.map +1 -1
  48. package/dist/bridges-slides.js +3 -3
  49. package/dist/bridges-whiteboard.cjs +10 -49
  50. package/dist/bridges-whiteboard.cjs.map +1 -1
  51. package/dist/bridges-whiteboard.js +4 -4
  52. package/dist/{chunk-3KSZNGNW.js → chunk-3QJSOS7G.js} +4 -4
  53. package/dist/{chunk-3KSZNGNW.js.map → chunk-3QJSOS7G.js.map} +1 -1
  54. package/dist/{chunk-4BL5M3U3.js → chunk-5AD35HS5.js} +3 -3
  55. package/dist/{chunk-4BL5M3U3.js.map → chunk-5AD35HS5.js.map} +1 -1
  56. package/dist/chunk-C3TYI5TJ.js +3 -0
  57. package/dist/chunk-C3TYI5TJ.js.map +1 -0
  58. package/dist/{chunk-57ZDHD53.js → chunk-CKK4QKD2.js} +3 -3
  59. package/dist/{chunk-57ZDHD53.js.map → chunk-CKK4QKD2.js.map} +1 -1
  60. package/dist/{chunk-LVQXIUJH.js → chunk-CPNOF4HI.js} +3 -3
  61. package/dist/{chunk-LVQXIUJH.js.map → chunk-CPNOF4HI.js.map} +1 -1
  62. package/dist/{chunk-HSTW7ZNO.js → chunk-FYGMFIY5.js} +3 -3
  63. package/dist/{chunk-HSTW7ZNO.js.map → chunk-FYGMFIY5.js.map} +1 -1
  64. package/dist/{chunk-RGO42EQ6.js → chunk-GHY3PBPN.js} +3 -3
  65. package/dist/{chunk-RGO42EQ6.js.map → chunk-GHY3PBPN.js.map} +1 -1
  66. package/dist/{chunk-IANI25IT.js → chunk-GSVVIT2O.js} +3 -3
  67. package/dist/{chunk-IANI25IT.js.map → chunk-GSVVIT2O.js.map} +1 -1
  68. package/dist/{chunk-ZHAK2DQR.js → chunk-J5KYPEYB.js} +3 -3
  69. package/dist/{chunk-ZHAK2DQR.js.map → chunk-J5KYPEYB.js.map} +1 -1
  70. package/dist/{chunk-5XELJIJR.js → chunk-KHKSQEMC.js} +3 -3
  71. package/dist/{chunk-5XELJIJR.js.map → chunk-KHKSQEMC.js.map} +1 -1
  72. package/dist/{chunk-GQ7XXK7G.js → chunk-KJ5AOOV7.js} +5 -46
  73. package/dist/chunk-KJ5AOOV7.js.map +1 -0
  74. package/dist/{chunk-KABXGJJ4.js → chunk-R5OA26MJ.js} +3 -3
  75. package/dist/{chunk-KABXGJJ4.js.map → chunk-R5OA26MJ.js.map} +1 -1
  76. package/dist/{chunk-NTDZWGYB.js → chunk-SJ7H242B.js} +3 -3
  77. package/dist/{chunk-NTDZWGYB.js.map → chunk-SJ7H242B.js.map} +1 -1
  78. package/dist/{chunk-X66JWQBB.js → chunk-UCKJAUBY.js} +3 -3
  79. package/dist/{chunk-X66JWQBB.js.map → chunk-UCKJAUBY.js.map} +1 -1
  80. package/dist/{chunk-52S7XYZK.js → chunk-ULJL53DL.js} +3 -3
  81. package/dist/{chunk-52S7XYZK.js.map → chunk-ULJL53DL.js.map} +1 -1
  82. package/dist/{chunk-XRAJSOPS.js → chunk-VUMFO2UW.js} +3 -3
  83. package/dist/{chunk-XRAJSOPS.js.map → chunk-VUMFO2UW.js.map} +1 -1
  84. package/dist/components/SharedWhiteboard/index.d.cts +3 -3
  85. package/dist/components/SharedWhiteboard/index.d.ts +3 -3
  86. package/dist/components-shared-whiteboard.cjs +13 -79
  87. package/dist/components-shared-whiteboard.cjs.map +1 -1
  88. package/dist/components-shared-whiteboard.js +6 -6
  89. package/dist/index.cjs +60 -102
  90. package/dist/index.cjs.map +1 -1
  91. package/dist/index.d.cts +16 -15
  92. package/dist/index.d.ts +16 -15
  93. package/dist/index.js +17 -17
  94. package/dist/mcp/index.d.cts +5 -5
  95. package/dist/mcp/index.d.ts +5 -5
  96. package/dist/presence/index.d.cts +10 -64
  97. package/dist/presence/index.d.ts +10 -64
  98. package/dist/presence.cjs +21 -37
  99. package/dist/presence.cjs.map +1 -1
  100. package/dist/presence.js +3 -3
  101. package/dist/registry-TFWVXQOU.js +3 -0
  102. package/dist/{registry-2DRURS6U.js.map → registry-TFWVXQOU.js.map} +1 -1
  103. package/dist/{server-C2OpfPEo.d.cts → server-BsSwfemr.d.cts} +3 -3
  104. package/dist/{server-CKAqFTyc.d.ts → server-Du3-IGqM.d.ts} +3 -3
  105. package/dist/sharing/index.d.cts +4 -4
  106. package/dist/sharing/index.d.ts +4 -4
  107. package/dist/sharing.cjs +6 -34
  108. package/dist/sharing.cjs.map +1 -1
  109. package/dist/sharing.js +1 -1
  110. package/dist/sheets-adapter.cjs +2 -9
  111. package/dist/sheets-adapter.cjs.map +1 -1
  112. package/dist/sheets-adapter.d.cts +3 -3
  113. package/dist/sheets-adapter.d.ts +3 -3
  114. package/dist/sheets-adapter.js +2 -2
  115. package/dist/{token-C1O22GxJ.d.ts → token-CrJF76oH.d.cts} +1 -1
  116. package/dist/{token-C1O22GxJ.d.cts → token-CrJF76oH.d.ts} +1 -1
  117. package/dist/{tool-host-CX3WFXgh.d.cts → tool-host-BQuUygLF.d.cts} +1 -1
  118. package/dist/{tool-host-DldwGNqR.d.ts → tool-host-C8JMMGYq.d.ts} +1 -1
  119. package/dist/{types-Cq5u8MJ8.d.cts → types-CCSBGW9T.d.cts} +1 -1
  120. package/dist/{types-DyaHnqNC.d.ts → types-DIVNcIQO.d.ts} +1 -1
  121. package/dist/{types-C2zdUpzn.d.cts → types-aOQLTW0E.d.cts} +1 -1
  122. package/dist/{types-C2zdUpzn.d.ts → types-aOQLTW0E.d.ts} +1 -1
  123. package/dist/undo/index.d.cts +6 -43
  124. package/dist/undo/index.d.ts +6 -43
  125. package/dist/undo.cjs +31 -53
  126. package/dist/undo.cjs.map +1 -1
  127. package/dist/undo.js +2 -2
  128. package/docs/agent-hookable-demos.md +7 -2
  129. package/docs/relay-server.md +21 -0
  130. package/package.json +12 -9
  131. package/dist/chunk-GQ7XXK7G.js.map +0 -1
  132. package/dist/chunk-JU2N4KK6.js +0 -34
  133. package/dist/chunk-JU2N4KK6.js.map +0 -1
  134. package/dist/registry-2DRURS6U.js +0 -3
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @particle-academy/agent-integrations
2
2
 
3
+ [![Fancified](art/fancified.svg)](https://particle.academy)
4
+
3
5
  MCP-driven agent presence in collab sessions. Each open session gets a **micro-MCP server** running in-page; agents (in-browser or external via relay) connect to it and act as participants — adding sticky notes, drawing, moving items, leaving cursor trails.
4
6
 
5
7
  Also ships the **agent UX surface**: a chat-and-tool-log panel, an on-canvas presence cursor, and a brief activity highlight for items the agent just touched.
@@ -173,6 +175,12 @@ shuttles JSON-RPC frames — it doesn't run tools or hold state.
173
175
  - **`docs/relay-protocol.md`** — the on-the-wire JSON envelope, with notes on
174
176
  the three transports the protocol supports (Reverb, WebRTC, SSE+POST).
175
177
 
178
+ The agent at the far end needs an MCP client. Beyond pasting the session URL
179
+ into an existing one (Claude Code, Cursor, …), there's
180
+ **[`mcp-relay-client`](https://github.com/Particle-Academy/mcp-relay-client)** —
181
+ a single-file, zero-dependency client (bash / Python / TS / Go) built for these
182
+ relay sessions: `curl -O …/connect.sh && bash connect.sh "<session-url>" tools`.
183
+
176
184
  Pattern (Reverb):
177
185
 
178
186
  ```ts
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-CX3WFXgh.cjs';
2
- import { B as Bridge } from '../types-Cq5u8MJ8.cjs';
3
- import '../types-C2zdUpzn.cjs';
1
+ import { T as ToolHost } from '../tool-host-BQuUygLF.cjs';
2
+ import { B as Bridge } from '../types-CCSBGW9T.cjs';
3
+ import '../types-aOQLTW0E.cjs';
4
4
 
5
5
  /**
6
6
  * Transport-level JSON shapes. These intentionally mirror fancy-artboard's
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-DldwGNqR.js';
2
- import { B as Bridge } from '../types-DyaHnqNC.js';
3
- import '../types-C2zdUpzn.js';
1
+ import { T as ToolHost } from '../tool-host-C8JMMGYq.js';
2
+ import { B as Bridge } from '../types-DIVNcIQO.js';
3
+ import '../types-aOQLTW0E.js';
4
4
 
5
5
  /**
6
6
  * Transport-level JSON shapes. These intentionally mirror fancy-artboard's
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-CX3WFXgh.cjs';
2
- import { B as Bridge } from '../types-Cq5u8MJ8.cjs';
3
- import '../types-C2zdUpzn.cjs';
1
+ import { T as ToolHost } from '../tool-host-BQuUygLF.cjs';
2
+ import { B as Bridge } from '../types-CCSBGW9T.cjs';
3
+ import '../types-aOQLTW0E.cjs';
4
4
 
5
5
  /**
6
6
  * Adapter wires a single fancy-echarts chart to the bridge. Charts are
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-DldwGNqR.js';
2
- import { B as Bridge } from '../types-DyaHnqNC.js';
3
- import '../types-C2zdUpzn.js';
1
+ import { T as ToolHost } from '../tool-host-C8JMMGYq.js';
2
+ import { B as Bridge } from '../types-DIVNcIQO.js';
3
+ import '../types-aOQLTW0E.js';
4
4
 
5
5
  /**
6
6
  * Adapter wires a single fancy-echarts chart to the bridge. Charts are
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-CX3WFXgh.cjs';
2
- import { B as Bridge } from '../types-Cq5u8MJ8.cjs';
3
- import '../types-C2zdUpzn.cjs';
1
+ import { T as ToolHost } from '../tool-host-BQuUygLF.cjs';
2
+ import { B as Bridge } from '../types-CCSBGW9T.cjs';
3
+ import '../types-aOQLTW0E.cjs';
4
4
 
5
5
  /**
6
6
  * Adapter the host wires to a fancy-code CodeEditor (typically via the
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-DldwGNqR.js';
2
- import { B as Bridge } from '../types-DyaHnqNC.js';
3
- import '../types-C2zdUpzn.js';
1
+ import { T as ToolHost } from '../tool-host-C8JMMGYq.js';
2
+ import { B as Bridge } from '../types-DIVNcIQO.js';
3
+ import '../types-aOQLTW0E.js';
4
4
 
5
5
  /**
6
6
  * Adapter the host wires to a fancy-code CodeEditor (typically via the
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-CX3WFXgh.cjs';
2
- import { B as Bridge } from '../types-Cq5u8MJ8.cjs';
3
- import '../types-C2zdUpzn.cjs';
1
+ import { T as ToolHost } from '../tool-host-BQuUygLF.cjs';
2
+ import { B as Bridge } from '../types-CCSBGW9T.cjs';
3
+ import '../types-aOQLTW0E.cjs';
4
4
 
5
5
  type FlowNode = {
6
6
  id: string;
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-DldwGNqR.js';
2
- import { B as Bridge } from '../types-DyaHnqNC.js';
3
- import '../types-C2zdUpzn.js';
1
+ import { T as ToolHost } from '../tool-host-C8JMMGYq.js';
2
+ import { B as Bridge } from '../types-DIVNcIQO.js';
3
+ import '../types-aOQLTW0E.js';
4
4
 
5
5
  type FlowNode = {
6
6
  id: string;
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-CX3WFXgh.cjs';
2
- import { B as Bridge } from '../types-Cq5u8MJ8.cjs';
3
- import '../types-C2zdUpzn.cjs';
1
+ import { T as ToolHost } from '../tool-host-BQuUygLF.cjs';
2
+ import { B as Bridge } from '../types-CCSBGW9T.cjs';
3
+ import '../types-aOQLTW0E.cjs';
4
4
 
5
5
  /**
6
6
  * Field descriptor — what the host says about each form field. Mirrors the
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-DldwGNqR.js';
2
- import { B as Bridge } from '../types-DyaHnqNC.js';
3
- import '../types-C2zdUpzn.js';
1
+ import { T as ToolHost } from '../tool-host-C8JMMGYq.js';
2
+ import { B as Bridge } from '../types-DIVNcIQO.js';
3
+ import '../types-aOQLTW0E.js';
4
4
 
5
5
  /**
6
6
  * Field descriptor — what the host says about each form field. Mirrors the
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-CX3WFXgh.cjs';
2
- import { B as Bridge } from '../types-Cq5u8MJ8.cjs';
3
- import '../types-C2zdUpzn.cjs';
1
+ import { T as ToolHost } from '../tool-host-BQuUygLF.cjs';
2
+ import { B as Bridge } from '../types-CCSBGW9T.cjs';
3
+ import '../types-aOQLTW0E.cjs';
4
4
 
5
5
  /**
6
6
  * Loose Scene types — mirror the public surface of fancy-3d's Scene
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-DldwGNqR.js';
2
- import { B as Bridge } from '../types-DyaHnqNC.js';
3
- import '../types-C2zdUpzn.js';
1
+ import { T as ToolHost } from '../tool-host-C8JMMGYq.js';
2
+ import { B as Bridge } from '../types-DIVNcIQO.js';
3
+ import '../types-aOQLTW0E.js';
4
4
 
5
5
  /**
6
6
  * Loose Scene types — mirror the public surface of fancy-3d's Scene
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-CX3WFXgh.cjs';
2
- import { B as Bridge } from '../types-Cq5u8MJ8.cjs';
3
- import '../types-C2zdUpzn.cjs';
1
+ import { T as ToolHost } from '../tool-host-BQuUygLF.cjs';
2
+ import { B as Bridge } from '../types-CCSBGW9T.cjs';
3
+ import '../types-aOQLTW0E.cjs';
4
4
 
5
5
  /**
6
6
  * Loose snapshot of a screen — what's in fancy-screens' ScreenMeta plus
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-DldwGNqR.js';
2
- import { B as Bridge } from '../types-DyaHnqNC.js';
3
- import '../types-C2zdUpzn.js';
1
+ import { T as ToolHost } from '../tool-host-C8JMMGYq.js';
2
+ import { B as Bridge } from '../types-DIVNcIQO.js';
3
+ import '../types-aOQLTW0E.js';
4
4
 
5
5
  /**
6
6
  * Loose snapshot of a screen — what's in fancy-screens' ScreenMeta plus
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-CX3WFXgh.cjs';
2
- import { B as Bridge } from '../types-Cq5u8MJ8.cjs';
3
- import '../types-C2zdUpzn.cjs';
1
+ import { T as ToolHost } from '../tool-host-BQuUygLF.cjs';
2
+ import { B as Bridge } from '../types-CCSBGW9T.cjs';
3
+ import '../types-aOQLTW0E.cjs';
4
4
 
5
5
  /**
6
6
  * Loose types — kept here so the bridge builds without a hard dep on
@@ -1,6 +1,6 @@
1
- import { T as ToolHost } from '../tool-host-DldwGNqR.js';
2
- import { B as Bridge } from '../types-DyaHnqNC.js';
3
- import '../types-C2zdUpzn.js';
1
+ import { T as ToolHost } from '../tool-host-C8JMMGYq.js';
2
+ import { B as Bridge } from '../types-DIVNcIQO.js';
3
+ import '../types-aOQLTW0E.js';
4
4
 
5
5
  /**
6
6
  * Loose types — kept here so the bridge builds without a hard dep on
@@ -1,8 +1,8 @@
1
1
  import { Deck, DeckOp } from '@particle-academy/fancy-slides';
2
2
  export { reduceDeck } from '@particle-academy/fancy-slides';
3
- import { T as ToolHost } from '../tool-host-CX3WFXgh.cjs';
4
- import { B as Bridge } from '../types-Cq5u8MJ8.cjs';
5
- import '../types-C2zdUpzn.cjs';
3
+ import { T as ToolHost } from '../tool-host-BQuUygLF.cjs';
4
+ import { B as Bridge } from '../types-CCSBGW9T.cjs';
5
+ import '../types-aOQLTW0E.cjs';
6
6
 
7
7
  /**
8
8
  * Adapter — the bridge calls into these to read or change deck state. The
@@ -1,8 +1,8 @@
1
1
  import { Deck, DeckOp } from '@particle-academy/fancy-slides';
2
2
  export { reduceDeck } from '@particle-academy/fancy-slides';
3
- import { T as ToolHost } from '../tool-host-DldwGNqR.js';
4
- import { B as Bridge } from '../types-DyaHnqNC.js';
5
- import '../types-C2zdUpzn.js';
3
+ import { T as ToolHost } from '../tool-host-C8JMMGYq.js';
4
+ import { B as Bridge } from '../types-DIVNcIQO.js';
5
+ import '../types-aOQLTW0E.js';
6
6
 
7
7
  /**
8
8
  * Adapter — the bridge calls into these to read or change deck state. The
@@ -1,7 +1,7 @@
1
1
  import { StickyNoteItem, ShapeItem, ConnectorItem, Stroke, Viewport, RemoteCursor } from '@particle-academy/fancy-whiteboard';
2
- import { T as ToolHost } from '../tool-host-CX3WFXgh.cjs';
3
- import { B as Bridge } from '../types-Cq5u8MJ8.cjs';
4
- import '../types-C2zdUpzn.cjs';
2
+ import { T as ToolHost } from '../tool-host-BQuUygLF.cjs';
3
+ import { B as Bridge } from '../types-CCSBGW9T.cjs';
4
+ import '../types-aOQLTW0E.cjs';
5
5
 
6
6
  /**
7
7
  * State accessors / mutators the bridge needs from the host. The host owns
@@ -1,7 +1,7 @@
1
1
  import { StickyNoteItem, ShapeItem, ConnectorItem, Stroke, Viewport, RemoteCursor } from '@particle-academy/fancy-whiteboard';
2
- import { T as ToolHost } from '../tool-host-DldwGNqR.js';
3
- import { B as Bridge } from '../types-DyaHnqNC.js';
4
- import '../types-C2zdUpzn.js';
2
+ import { T as ToolHost } from '../tool-host-C8JMMGYq.js';
3
+ import { B as Bridge } from '../types-DIVNcIQO.js';
4
+ import '../types-aOQLTW0E.js';
5
5
 
6
6
  /**
7
7
  * State accessors / mutators the bridge needs from the host. The host owns
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var fancyAutoCommon = require('@particle-academy/fancy-auto-common');
4
+
3
5
  // src/mcp/server.ts
4
6
  function textResult(text, structured) {
5
7
  return {
@@ -10,10 +12,6 @@ function textResult(text, structured) {
10
12
  function errorResult(text) {
11
13
  return { content: [{ type: "text", text }], isError: true };
12
14
  }
13
- var listeners = /* @__PURE__ */ new Set();
14
- function emitActivity(event) {
15
- for (const l of listeners) l(event);
16
- }
17
15
 
18
16
  // src/presence/wrap-tool-with-activity.ts
19
17
  function wrapToolWithActivity(handler, options) {
@@ -27,7 +25,7 @@ function wrapToolWithActivity(handler, options) {
27
25
  target = { kind: options.kind, screenId: options.screenId };
28
26
  }
29
27
  if (!target) return result;
30
- emitActivity({
28
+ fancyAutoCommon.emitActivity({
31
29
  agentId: options.agent.id,
32
30
  agentName: options.agent.name,
33
31
  agentColor: options.agent.color,
@@ -48,43 +46,6 @@ function extractMeta(result) {
48
46
  return void 0;
49
47
  }
50
48
 
51
- // src/undo/undo-stack.ts
52
- var stacks = /* @__PURE__ */ new Map();
53
- var CAP = 200;
54
- function getStack(agentId) {
55
- let s = stacks.get(agentId);
56
- if (!s) {
57
- s = { past: [], future: [] };
58
- stacks.set(agentId, s);
59
- }
60
- return s;
61
- }
62
- function pushUndoEntry(agentId, entry) {
63
- const s = getStack(agentId);
64
- s.past.push(entry);
65
- if (s.past.length > CAP) s.past.splice(0, s.past.length - CAP);
66
- s.future.length = 0;
67
- }
68
- async function undoOne(agentId) {
69
- const s = getStack(agentId);
70
- const entry = s.past.pop();
71
- if (!entry) return null;
72
- await entry.undo();
73
- s.future.push(entry);
74
- return entry;
75
- }
76
- async function redoOne(agentId) {
77
- const s = getStack(agentId);
78
- const entry = s.future.pop();
79
- if (!entry) return null;
80
- await entry.redo();
81
- s.past.push(entry);
82
- return entry;
83
- }
84
- function readHistory(agentId) {
85
- return getStack(agentId).past.slice();
86
- }
87
-
88
49
  // src/undo/undo-tools.ts
89
50
  var installedHosts = /* @__PURE__ */ new WeakSet();
90
51
  function ensureUndoToolsRegistered(host, options = {}) {
@@ -108,7 +69,7 @@ function registerUndoTools(host, options = {}) {
108
69
  }
109
70
  },
110
71
  async (args) => {
111
- const entry = await undoOne(agentOf(args));
72
+ const entry = await fancyAutoCommon.undoOne(agentOf(args));
112
73
  if (!entry) return errorResult("Nothing to undo.");
113
74
  return textResult(`Undid: ${entry.label}`, { entry: serialize(entry) });
114
75
  }
@@ -126,7 +87,7 @@ function registerUndoTools(host, options = {}) {
126
87
  }
127
88
  },
128
89
  async (args) => {
129
- const entry = await redoOne(agentOf(args));
90
+ const entry = await fancyAutoCommon.redoOne(agentOf(args));
130
91
  if (!entry) return errorResult("Nothing to redo.");
131
92
  return textResult(`Redid: ${entry.label}`, { entry: serialize(entry) });
132
93
  }
@@ -144,9 +105,9 @@ function registerUndoTools(host, options = {}) {
144
105
  }
145
106
  },
146
107
  async (args) => {
147
- const history2 = readHistory(agentOf(args)).map(serialize);
148
- const text = history2.map((e) => `${new Date(e.timestamp).toISOString()} ${e.bridgeId} ${e.action}: ${e.label}`).join("\n");
149
- return textResult(text || "(empty)", history2);
108
+ const history = fancyAutoCommon.readHistory(agentOf(args)).map(serialize);
109
+ const text = history.map((e) => `${new Date(e.timestamp).toISOString()} ${e.bridgeId} ${e.action}: ${e.label}`).join("\n");
110
+ return textResult(text || "(empty)", history);
150
111
  }
151
112
  )
152
113
  );
@@ -272,7 +233,7 @@ function registerArtboardBridge(host, options) {
272
233
  (s) => s.id !== sectionId ? s : { ...s, pieces: [...s.pieces.slice(0, insertAt), piece, ...s.pieces.slice(insertAt)] }
273
234
  )
274
235
  }));
275
- pushUndoEntry(agent.id, {
236
+ fancyAutoCommon.pushUndoEntry(agent.id, {
276
237
  timestamp: Date.now(),
277
238
  bridgeId: "artboard",
278
239
  action: "artboard_add_piece",
@@ -320,7 +281,7 @@ function registerArtboardBridge(host, options) {
320
281
  (s) => s.id !== sectionId ? s : { ...s, pieces: s.pieces.filter((p) => p.id !== pieceId) }
321
282
  )
322
283
  }));
323
- pushUndoEntry(agent.id, {
284
+ fancyAutoCommon.pushUndoEntry(agent.id, {
324
285
  timestamp: Date.now(),
325
286
  bridgeId: "artboard",
326
287
  action: "artboard_remove_piece",
@@ -378,7 +339,7 @@ function registerArtboardBridge(host, options) {
378
339
  })
379
340
  };
380
341
  });
381
- pushUndoEntry(agent.id, {
342
+ fancyAutoCommon.pushUndoEntry(agent.id, {
382
343
  timestamp: Date.now(),
383
344
  bridgeId: "artboard",
384
345
  action: "artboard_reorder_piece",
@@ -417,7 +378,7 @@ function registerArtboardBridge(host, options) {
417
378
  }))
418
379
  }));
419
380
  apply(label);
420
- pushUndoEntry(agent.id, {
381
+ fancyAutoCommon.pushUndoEntry(agent.id, {
421
382
  timestamp: Date.now(),
422
383
  bridgeId: "artboard",
423
384
  action: "artboard_rename_piece",
@@ -447,7 +408,7 @@ function registerArtboardBridge(host, options) {
447
408
  }))
448
409
  }));
449
410
  apply(nextContent);
450
- pushUndoEntry(agent.id, {
411
+ fancyAutoCommon.pushUndoEntry(agent.id, {
451
412
  timestamp: Date.now(),
452
413
  bridgeId: "artboard",
453
414
  action: "artboard_set_piece_content",
@@ -498,7 +459,7 @@ function registerArtboardBridge(host, options) {
498
459
  adapter.setValue((prev) => ({
499
460
  sections: [...prev.sections.slice(0, insertAt), section, ...prev.sections.slice(insertAt)]
500
461
  }));
501
- pushUndoEntry(agent.id, {
462
+ fancyAutoCommon.pushUndoEntry(agent.id, {
502
463
  timestamp: Date.now(),
503
464
  bridgeId: "artboard",
504
465
  action: "artboard_add_section",
@@ -532,7 +493,7 @@ function registerArtboardBridge(host, options) {
532
493
  )
533
494
  }));
534
495
  apply(title, subtitle);
535
- pushUndoEntry(agent.id, {
496
+ fancyAutoCommon.pushUndoEntry(agent.id, {
536
497
  timestamp: Date.now(),
537
498
  bridgeId: "artboard",
538
499
  action: "artboard_rename_section",