@particle-academy/agent-integrations 0.49.0 → 0.51.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 (226) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +11 -0
  3. package/dist/bridges/artboard.d.cts +3 -3
  4. package/dist/bridges/artboard.d.ts +3 -3
  5. package/dist/bridges/catalog.d.cts +3 -3
  6. package/dist/bridges/catalog.d.ts +3 -3
  7. package/dist/bridges/charts.d.cts +3 -3
  8. package/dist/bridges/charts.d.ts +3 -3
  9. package/dist/bridges/cms.d.cts +3 -3
  10. package/dist/bridges/cms.d.ts +3 -3
  11. package/dist/bridges/code.d.cts +3 -3
  12. package/dist/bridges/code.d.ts +3 -3
  13. package/dist/bridges/doc.d.cts +3 -3
  14. package/dist/bridges/doc.d.ts +3 -3
  15. package/dist/bridges/features.d.cts +3 -3
  16. package/dist/bridges/features.d.ts +3 -3
  17. package/dist/bridges/files.d.cts +3 -3
  18. package/dist/bridges/files.d.ts +3 -3
  19. package/dist/bridges/flow.d.cts +3 -3
  20. package/dist/bridges/flow.d.ts +3 -3
  21. package/dist/bridges/forms.d.cts +3 -3
  22. package/dist/bridges/forms.d.ts +3 -3
  23. package/dist/bridges/git.d.cts +3 -3
  24. package/dist/bridges/git.d.ts +3 -3
  25. package/dist/bridges/grid.d.cts +3 -3
  26. package/dist/bridges/grid.d.ts +3 -3
  27. package/dist/bridges/map.d.cts +3 -3
  28. package/dist/bridges/map.d.ts +3 -3
  29. package/dist/bridges/navigation.d.cts +3 -3
  30. package/dist/bridges/navigation.d.ts +3 -3
  31. package/dist/bridges/passkeys.d.cts +3 -3
  32. package/dist/bridges/passkeys.d.ts +3 -3
  33. package/dist/bridges/scene.d.cts +3 -3
  34. package/dist/bridges/scene.d.ts +3 -3
  35. package/dist/bridges/screen-doc.d.cts +3 -3
  36. package/dist/bridges/screen-doc.d.ts +3 -3
  37. package/dist/bridges/screens.d.cts +3 -3
  38. package/dist/bridges/screens.d.ts +3 -3
  39. package/dist/bridges/sheets.d.cts +3 -3
  40. package/dist/bridges/sheets.d.ts +3 -3
  41. package/dist/bridges/slides.d.cts +3 -3
  42. package/dist/bridges/slides.d.ts +3 -3
  43. package/dist/bridges/terminal.d.cts +3 -3
  44. package/dist/bridges/terminal.d.ts +3 -3
  45. package/dist/bridges/tui.d.cts +2 -2
  46. package/dist/bridges/tui.d.ts +2 -2
  47. package/dist/bridges/whiteboard.d.cts +3 -3
  48. package/dist/bridges/whiteboard.d.ts +3 -3
  49. package/dist/bridges-artboard.cjs +11 -5
  50. package/dist/bridges-artboard.cjs.map +1 -1
  51. package/dist/bridges-artboard.js +6 -4
  52. package/dist/bridges-artboard.js.map +1 -1
  53. package/dist/bridges-catalog.cjs +35 -13
  54. package/dist/bridges-catalog.cjs.map +1 -1
  55. package/dist/bridges-catalog.js +3 -3
  56. package/dist/bridges-charts.cjs +11 -5
  57. package/dist/bridges-charts.cjs.map +1 -1
  58. package/dist/bridges-charts.js +3 -3
  59. package/dist/bridges-cms.cjs +11 -5
  60. package/dist/bridges-cms.cjs.map +1 -1
  61. package/dist/bridges-cms.js +4 -4
  62. package/dist/bridges-code.cjs +11 -5
  63. package/dist/bridges-code.cjs.map +1 -1
  64. package/dist/bridges-code.js +3 -3
  65. package/dist/bridges-doc.cjs +11 -5
  66. package/dist/bridges-doc.cjs.map +1 -1
  67. package/dist/bridges-doc.js +3 -3
  68. package/dist/bridges-features.cjs +21 -11
  69. package/dist/bridges-features.cjs.map +1 -1
  70. package/dist/bridges-features.js +3 -3
  71. package/dist/bridges-files.cjs +11 -5
  72. package/dist/bridges-files.cjs.map +1 -1
  73. package/dist/bridges-files.js +3 -3
  74. package/dist/bridges-flow.cjs +11 -5
  75. package/dist/bridges-flow.cjs.map +1 -1
  76. package/dist/bridges-flow.js +6 -4
  77. package/dist/bridges-flow.js.map +1 -1
  78. package/dist/bridges-forms.cjs +11 -5
  79. package/dist/bridges-forms.cjs.map +1 -1
  80. package/dist/bridges-forms.js +3 -3
  81. package/dist/bridges-git.cjs +10 -5
  82. package/dist/bridges-git.cjs.map +1 -1
  83. package/dist/bridges-git.js +3 -3
  84. package/dist/bridges-grid.cjs +11 -5
  85. package/dist/bridges-grid.cjs.map +1 -1
  86. package/dist/bridges-grid.js +3 -3
  87. package/dist/bridges-map.cjs +11 -5
  88. package/dist/bridges-map.cjs.map +1 -1
  89. package/dist/bridges-map.js +3 -3
  90. package/dist/bridges-navigation.cjs +15 -9
  91. package/dist/bridges-navigation.cjs.map +1 -1
  92. package/dist/bridges-navigation.js +3 -3
  93. package/dist/bridges-passkeys.cjs +17 -7
  94. package/dist/bridges-passkeys.cjs.map +1 -1
  95. package/dist/bridges-passkeys.js +3 -3
  96. package/dist/bridges-scene.cjs +11 -5
  97. package/dist/bridges-scene.cjs.map +1 -1
  98. package/dist/bridges-scene.js +3 -3
  99. package/dist/bridges-screen-doc.cjs +14 -6
  100. package/dist/bridges-screen-doc.cjs.map +1 -1
  101. package/dist/bridges-screen-doc.js +4 -4
  102. package/dist/bridges-screens.cjs +11 -5
  103. package/dist/bridges-screens.cjs.map +1 -1
  104. package/dist/bridges-screens.js +3 -3
  105. package/dist/bridges-sheets.cjs +11 -5
  106. package/dist/bridges-sheets.cjs.map +1 -1
  107. package/dist/bridges-sheets.js +3 -3
  108. package/dist/bridges-slides.cjs +11 -5
  109. package/dist/bridges-slides.cjs.map +1 -1
  110. package/dist/bridges-slides.js +3 -3
  111. package/dist/bridges-terminal.cjs +11 -5
  112. package/dist/bridges-terminal.cjs.map +1 -1
  113. package/dist/bridges-terminal.js +3 -3
  114. package/dist/bridges-tui.cjs +1 -1
  115. package/dist/bridges-tui.cjs.map +1 -1
  116. package/dist/bridges-tui.js +2 -2
  117. package/dist/bridges-whiteboard.cjs +11 -5
  118. package/dist/bridges-whiteboard.cjs.map +1 -1
  119. package/dist/bridges-whiteboard.js +3 -3
  120. package/dist/{chunk-CZV3WUW5.js → chunk-3GFKC6OK.js} +20 -7
  121. package/dist/chunk-3GFKC6OK.js.map +1 -0
  122. package/dist/{chunk-JLHVQWOV.js → chunk-6Q3PMT7K.js} +4 -4
  123. package/dist/chunk-6Q3PMT7K.js.map +1 -0
  124. package/dist/{chunk-AXWMWYH5.js → chunk-C4AQ2YBW.js} +7 -6
  125. package/dist/chunk-C4AQ2YBW.js.map +1 -0
  126. package/dist/{chunk-CS3CHGYC.js → chunk-CI5ZVHDY.js} +32 -14
  127. package/dist/chunk-CI5ZVHDY.js.map +1 -0
  128. package/dist/{chunk-5ZWNCHZS.js → chunk-CKJL5C7A.js} +8 -6
  129. package/dist/chunk-CKJL5C7A.js.map +1 -0
  130. package/dist/{chunk-HOZCDDRA.js → chunk-CP3EHLZJ.js} +8 -6
  131. package/dist/chunk-CP3EHLZJ.js.map +1 -0
  132. package/dist/{chunk-VFWFT3OK.js → chunk-DNF3QVTW.js} +8 -6
  133. package/dist/chunk-DNF3QVTW.js.map +1 -0
  134. package/dist/{chunk-OHNGURUJ.js → chunk-HNVHAY4A.js} +12 -10
  135. package/dist/chunk-HNVHAY4A.js.map +1 -0
  136. package/dist/{chunk-GVTBMJU6.js → chunk-KAEPC6N4.js} +18 -12
  137. package/dist/chunk-KAEPC6N4.js.map +1 -0
  138. package/dist/{chunk-3WVXAB3D.js → chunk-M423JOQ3.js} +3 -3
  139. package/dist/{chunk-3WVXAB3D.js.map → chunk-M423JOQ3.js.map} +1 -1
  140. package/dist/{chunk-SWWJUOCY.js → chunk-MKC633WU.js} +3 -3
  141. package/dist/{chunk-SWWJUOCY.js.map → chunk-MKC633WU.js.map} +1 -1
  142. package/dist/{chunk-LQB42OSA.js → chunk-MKJE6V4Z.js} +8 -6
  143. package/dist/chunk-MKJE6V4Z.js.map +1 -0
  144. package/dist/{chunk-MIDZWKIF.js → chunk-NB5AQIR2.js} +8 -6
  145. package/dist/chunk-NB5AQIR2.js.map +1 -0
  146. package/dist/{chunk-VMRUW4B4.js → chunk-OUUHFR4N.js} +8 -6
  147. package/dist/chunk-OUUHFR4N.js.map +1 -0
  148. package/dist/{chunk-FCXSR7I5.js → chunk-P6SJBP5T.js} +8 -6
  149. package/dist/chunk-P6SJBP5T.js.map +1 -0
  150. package/dist/{chunk-5JLTXHX6.js → chunk-PMPBI6I3.js} +7 -5
  151. package/dist/chunk-PMPBI6I3.js.map +1 -0
  152. package/dist/{chunk-G6CRHFWU.js → chunk-PV4FZDYX.js} +14 -8
  153. package/dist/chunk-PV4FZDYX.js.map +1 -0
  154. package/dist/{chunk-3UUF5KKZ.js → chunk-QEVSNDJW.js} +8 -6
  155. package/dist/chunk-QEVSNDJW.js.map +1 -0
  156. package/dist/{chunk-VOCUGTZB.js → chunk-S4DA2UTJ.js} +8 -6
  157. package/dist/chunk-S4DA2UTJ.js.map +1 -0
  158. package/dist/{chunk-RVMM4BHK.js → chunk-V6EHKHSF.js} +8 -6
  159. package/dist/chunk-V6EHKHSF.js.map +1 -0
  160. package/dist/{chunk-36MKPTVD.js → chunk-VE7TRWZR.js} +8 -6
  161. package/dist/chunk-VE7TRWZR.js.map +1 -0
  162. package/dist/{chunk-Z5NL5D4J.js → chunk-VFUKZ6UA.js} +8 -6
  163. package/dist/chunk-VFUKZ6UA.js.map +1 -0
  164. package/dist/{chunk-3HVYUMQF.js → chunk-VHB3VE53.js} +8 -6
  165. package/dist/chunk-VHB3VE53.js.map +1 -0
  166. package/dist/{chunk-R4XXOGQH.js → chunk-ZDKYKJFH.js} +10 -6
  167. package/dist/chunk-ZDKYKJFH.js.map +1 -0
  168. package/dist/components-shared-whiteboard.cjs +29 -10
  169. package/dist/components-shared-whiteboard.cjs.map +1 -1
  170. package/dist/components-shared-whiteboard.js +3 -3
  171. package/dist/dom-navigation/index.d.cts +3 -3
  172. package/dist/dom-navigation/index.d.ts +3 -3
  173. package/dist/index.cjs +140 -64
  174. package/dist/index.cjs.map +1 -1
  175. package/dist/index.d.cts +5 -5
  176. package/dist/index.d.ts +5 -5
  177. package/dist/index.js +26 -26
  178. package/dist/mcp/index.d.cts +5 -5
  179. package/dist/mcp/index.d.ts +5 -5
  180. package/dist/mcp/stdio.d.cts +3 -3
  181. package/dist/mcp/stdio.d.ts +3 -3
  182. package/dist/mcp.cjs +18 -5
  183. package/dist/mcp.cjs.map +1 -1
  184. package/dist/mcp.js +1 -1
  185. package/dist/presence/index.d.cts +1 -1
  186. package/dist/presence/index.d.ts +1 -1
  187. package/dist/{server-1y0n61R5.d.cts → server-DJJygNo1.d.cts} +2 -2
  188. package/dist/{server-vq6qVl3T.d.ts → server-Dwo9LOxh.d.ts} +2 -2
  189. package/dist/sharing/index.d.cts +3 -3
  190. package/dist/sharing/index.d.ts +3 -3
  191. package/dist/sheets-adapter.d.cts +3 -3
  192. package/dist/sheets-adapter.d.ts +3 -3
  193. package/dist/{tool-host-LYfdPE8u.d.ts → tool-host-BBSaU7IJ.d.cts} +10 -4
  194. package/dist/{tool-host-D67N2a2h.d.cts → tool-host-BqJRPr_T.d.ts} +10 -4
  195. package/dist/{types-DP5yQZQU.d.cts → types-D_H2f-wF.d.cts} +1 -1
  196. package/dist/{types-VX_9je7w.d.ts → types-D_TzdBsK.d.ts} +1 -1
  197. package/dist/{types-gzIpsUDE.d.cts → types-ITRQFAir.d.cts} +26 -1
  198. package/dist/{types-gzIpsUDE.d.ts → types-ITRQFAir.d.ts} +26 -1
  199. package/dist/undo/index.d.cts +2 -2
  200. package/dist/undo/index.d.ts +2 -2
  201. package/dist/undo.cjs +7 -3
  202. package/dist/undo.cjs.map +1 -1
  203. package/dist/undo.js +3 -3
  204. package/package.json +1 -1
  205. package/dist/chunk-36MKPTVD.js.map +0 -1
  206. package/dist/chunk-3HVYUMQF.js.map +0 -1
  207. package/dist/chunk-3UUF5KKZ.js.map +0 -1
  208. package/dist/chunk-5JLTXHX6.js.map +0 -1
  209. package/dist/chunk-5ZWNCHZS.js.map +0 -1
  210. package/dist/chunk-AXWMWYH5.js.map +0 -1
  211. package/dist/chunk-CS3CHGYC.js.map +0 -1
  212. package/dist/chunk-CZV3WUW5.js.map +0 -1
  213. package/dist/chunk-FCXSR7I5.js.map +0 -1
  214. package/dist/chunk-G6CRHFWU.js.map +0 -1
  215. package/dist/chunk-GVTBMJU6.js.map +0 -1
  216. package/dist/chunk-HOZCDDRA.js.map +0 -1
  217. package/dist/chunk-JLHVQWOV.js.map +0 -1
  218. package/dist/chunk-LQB42OSA.js.map +0 -1
  219. package/dist/chunk-MIDZWKIF.js.map +0 -1
  220. package/dist/chunk-OHNGURUJ.js.map +0 -1
  221. package/dist/chunk-R4XXOGQH.js.map +0 -1
  222. package/dist/chunk-RVMM4BHK.js.map +0 -1
  223. package/dist/chunk-VFWFT3OK.js.map +0 -1
  224. package/dist/chunk-VMRUW4B4.js.map +0 -1
  225. package/dist/chunk-VOCUGTZB.js.map +0 -1
  226. package/dist/chunk-Z5NL5D4J.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { M as MicroMcpServer } from './server-1y0n61R5.cjs';
2
- export { a as McpServerOptions, T as Transport, e as errorResult, r as rpcError, t as textResult } from './server-1y0n61R5.cjs';
3
- export { T as ToolHost, a as ToolRegistry } from './tool-host-D67N2a2h.cjs';
1
+ import { M as MicroMcpServer } from './server-DJJygNo1.cjs';
2
+ export { a as McpServerOptions, T as Transport, e as errorResult, r as rpcError, t as textResult } from './server-DJJygNo1.cjs';
3
+ export { T as ToolHost, a as ToolRegistry } from './tool-host-BBSaU7IJ.cjs';
4
4
  export { InProcessTransport, RelayChannel, RelayTransport, attachInProcess, attachRelay } from './mcp/index.cjs';
5
- export { C as CallToolResult, d as ContentBlock, I as InitializeResult, J as JsonObject, c as JsonRpcMessage, e as JsonRpcNotification, f as JsonRpcRequest, g as JsonValue, M as MCP_PROTOCOL_VERSION, b as ServerCapabilities, S as ServerInfo, h as ToolCallContext, T as ToolDefinition, a as ToolHandler } from './types-gzIpsUDE.cjs';
5
+ export { C as CallToolResult, e as ContentBlock, I as InitializeResult, J as JsonObject, d as JsonRpcMessage, f as JsonRpcNotification, g as JsonRpcRequest, h as JsonValue, M as MCP_PROTOCOL_VERSION, R as RegisterToolOptions, c as ServerCapabilities, S as ServerInfo, i as ToolCallContext, T as ToolDefinition, a as ToolHandler } from './types-ITRQFAir.cjs';
6
6
  export { HumanPlusDisposition, HumanPlusEvent, HumanPlusEventPage, HumanPlusEventQuery, HumanPlusEventStore, MemoryHumanPlusEventStore, NewHumanPlusEvent } from './human-plus/index.cjs';
7
7
  export { TuiBridgeOptions, TuiSurfaceRegistryLike, registerTuiBridge } from './bridges/tui.cjs';
8
- export { B as Bridge, a as BridgeFactory } from './types-DP5yQZQU.cjs';
8
+ export { B as Bridge, a as BridgeFactory } from './types-D_H2f-wF.cjs';
9
9
  import { FormFieldDescriptor } from './bridges/forms.cjs';
10
10
  export { FormBridgeAdapter, FormBridgeOptions, registerFormBridge } from './bridges/forms.cjs';
11
11
  export { SheetsBridgeAdapter, SheetsBridgeOptions, registerSheetsBridge } from './bridges/sheets.cjs';
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { M as MicroMcpServer } from './server-vq6qVl3T.js';
2
- export { a as McpServerOptions, T as Transport, e as errorResult, r as rpcError, t as textResult } from './server-vq6qVl3T.js';
3
- export { T as ToolHost, a as ToolRegistry } from './tool-host-LYfdPE8u.js';
1
+ import { M as MicroMcpServer } from './server-Dwo9LOxh.js';
2
+ export { a as McpServerOptions, T as Transport, e as errorResult, r as rpcError, t as textResult } from './server-Dwo9LOxh.js';
3
+ export { T as ToolHost, a as ToolRegistry } from './tool-host-BqJRPr_T.js';
4
4
  export { InProcessTransport, RelayChannel, RelayTransport, attachInProcess, attachRelay } from './mcp/index.js';
5
- export { C as CallToolResult, d as ContentBlock, I as InitializeResult, J as JsonObject, c as JsonRpcMessage, e as JsonRpcNotification, f as JsonRpcRequest, g as JsonValue, M as MCP_PROTOCOL_VERSION, b as ServerCapabilities, S as ServerInfo, h as ToolCallContext, T as ToolDefinition, a as ToolHandler } from './types-gzIpsUDE.js';
5
+ export { C as CallToolResult, e as ContentBlock, I as InitializeResult, J as JsonObject, d as JsonRpcMessage, f as JsonRpcNotification, g as JsonRpcRequest, h as JsonValue, M as MCP_PROTOCOL_VERSION, R as RegisterToolOptions, c as ServerCapabilities, S as ServerInfo, i as ToolCallContext, T as ToolDefinition, a as ToolHandler } from './types-ITRQFAir.js';
6
6
  export { HumanPlusDisposition, HumanPlusEvent, HumanPlusEventPage, HumanPlusEventQuery, HumanPlusEventStore, MemoryHumanPlusEventStore, NewHumanPlusEvent } from './human-plus/index.js';
7
7
  export { TuiBridgeOptions, TuiSurfaceRegistryLike, registerTuiBridge } from './bridges/tui.js';
8
- export { B as Bridge, a as BridgeFactory } from './types-VX_9je7w.js';
8
+ export { B as Bridge, a as BridgeFactory } from './types-D_TzdBsK.js';
9
9
  import { FormFieldDescriptor } from './bridges/forms.js';
10
10
  export { FormBridgeAdapter, FormBridgeOptions, registerFormBridge } from './bridges/forms.js';
11
11
  export { SheetsBridgeAdapter, SheetsBridgeOptions, registerSheetsBridge } from './bridges/sheets.js';
package/dist/index.js CHANGED
@@ -4,45 +4,45 @@ import './chunk-IJ6JX5VC.js';
4
4
  import { createSessionDescriptor, attachSseRelay } from './chunk-6TZ5IBRN.js';
5
5
  export { SseRelayTransport, attachSseRelay, buildShareConfig, buildShareUrl, createSessionDescriptor, describeSession, readSessionFromUrl } from './chunk-6TZ5IBRN.js';
6
6
  export { attachHeuristicsSink, mapActivityToEvent as mapActivityToHeuristicsEvent } from './chunk-7R6RMROL.js';
7
- export { useUndoStack } from './chunk-3WVXAB3D.js';
8
- export { registerTuiBridge } from './chunk-JLHVQWOV.js';
7
+ export { useUndoStack } from './chunk-M423JOQ3.js';
8
+ export { registerTuiBridge } from './chunk-6Q3PMT7K.js';
9
9
  import { useAgentActivity } from './chunk-UCKJAUBY.js';
10
10
  export { useAgentActivity, useAgentActivityForScreen } from './chunk-UCKJAUBY.js';
11
- import { registerNavigationBridge } from './chunk-OHNGURUJ.js';
12
- export { registerNavigationBridge } from './chunk-OHNGURUJ.js';
11
+ import { registerNavigationBridge } from './chunk-HNVHAY4A.js';
12
+ export { registerNavigationBridge } from './chunk-HNVHAY4A.js';
13
13
  export { MemoryHumanPlusEventStore } from './chunk-PMI4C5S4.js';
14
14
  export { useSheetsActivityHighlights, useSheetsAdapter } from './chunk-KHKSQEMC.js';
15
15
  import { ConnectorButtons } from './chunk-5HNTNIWY.js';
16
16
  export { CLAUDE_CONNECTORS_URL, CONNECTOR_GLYPHS, CONNECTOR_TARGETS, ClaudeMark, ConnectorButtons, CursorMark, DesktopMark, VscodeMark, WrenchMark, buildCursorDeeplink, buildManualConfig, buildManualConfigSnippet, buildVscodeDeeplink, connectorHref, encodeBase64Json, slugifyServerName } from './chunk-5HNTNIWY.js';
17
17
  export { DEFAULT_MCPB_ENTRY_POINT, MCPB_MANIFEST_VERSION, MCPB_MIN_NODE, buildMcpbManifest, buildMcpbProxyStub } from './chunk-GO2Y6H6U.js';
18
- export { registerGitBridge } from './chunk-AXWMWYH5.js';
19
- export { registerFilesBridge } from './chunk-Z5NL5D4J.js';
20
- export { registerTerminalBridge } from './chunk-5ZWNCHZS.js';
21
- export { registerCatalogBridge } from './chunk-CS3CHGYC.js';
22
- export { registerFeaturesBridge } from './chunk-GVTBMJU6.js';
23
- export { PASSKEY_BRIDGE_TOOLS, registerPasskeyBridge } from './chunk-G6CRHFWU.js';
24
- export { cmsReducer, registerCmsBridge } from './chunk-SWWJUOCY.js';
25
- export { registerCodeBridge } from './chunk-FCXSR7I5.js';
26
- export { registerChartsBridge } from './chunk-36MKPTVD.js';
27
- export { registerGridBridge } from './chunk-MIDZWKIF.js';
28
- export { registerSceneBridge } from './chunk-RVMM4BHK.js';
29
- export { registerScreensBridge } from './chunk-HOZCDDRA.js';
30
- export { SCREEN_TEXT_NODE_TYPE, registerScreenDocBridge } from './chunk-5JLTXHX6.js';
31
- export { registerDocBridge } from './chunk-3HVYUMQF.js';
32
- export { registerSlidesBridge } from './chunk-VMRUW4B4.js';
33
- export { registerMapBridge } from './chunk-3UUF5KKZ.js';
18
+ export { registerGitBridge } from './chunk-C4AQ2YBW.js';
19
+ export { registerFilesBridge } from './chunk-VFUKZ6UA.js';
20
+ export { registerTerminalBridge } from './chunk-CKJL5C7A.js';
21
+ export { registerCatalogBridge } from './chunk-CI5ZVHDY.js';
22
+ export { registerFeaturesBridge } from './chunk-KAEPC6N4.js';
23
+ export { PASSKEY_BRIDGE_TOOLS, registerPasskeyBridge } from './chunk-PV4FZDYX.js';
24
+ export { cmsReducer, registerCmsBridge } from './chunk-MKC633WU.js';
25
+ export { registerCodeBridge } from './chunk-P6SJBP5T.js';
26
+ export { registerChartsBridge } from './chunk-VE7TRWZR.js';
27
+ export { registerGridBridge } from './chunk-NB5AQIR2.js';
28
+ export { registerSceneBridge } from './chunk-V6EHKHSF.js';
29
+ export { registerScreensBridge } from './chunk-CP3EHLZJ.js';
30
+ export { SCREEN_TEXT_NODE_TYPE, registerScreenDocBridge } from './chunk-PMPBI6I3.js';
31
+ export { registerDocBridge } from './chunk-VHB3VE53.js';
32
+ export { registerSlidesBridge } from './chunk-OUUHFR4N.js';
33
+ export { registerMapBridge } from './chunk-QEVSNDJW.js';
34
34
  export { RelayTransport, attachRelay } from './chunk-G6N2TQVO.js';
35
35
  import { attachInProcess } from './chunk-AFUULW5E.js';
36
36
  export { InProcessTransport, attachInProcess } from './chunk-AFUULW5E.js';
37
- import { registerFormBridge } from './chunk-VFWFT3OK.js';
38
- export { registerFormBridge } from './chunk-VFWFT3OK.js';
39
- export { registerSheetsBridge } from './chunk-VOCUGTZB.js';
40
- export { clearStack as clearUndoStack, ensureUndoToolsRegistered, pushUndoEntry, readHistory as readUndoHistory, redoOne, registerUndoTools, resetAllUndoStacks, undoOne } from './chunk-R4XXOGQH.js';
37
+ import { registerFormBridge } from './chunk-DNF3QVTW.js';
38
+ export { registerFormBridge } from './chunk-DNF3QVTW.js';
39
+ export { registerSheetsBridge } from './chunk-S4DA2UTJ.js';
40
+ export { clearStack as clearUndoStack, ensureUndoToolsRegistered, pushUndoEntry, readHistory as readUndoHistory, redoOne, registerUndoTools, resetAllUndoStacks, undoOne } from './chunk-ZDKYKJFH.js';
41
41
  export { wrapToolWithActivity } from './chunk-2VENWGLZ.js';
42
42
  import { emitActivity, onActivity } from './chunk-C3TYI5TJ.js';
43
43
  export { emitActivity, onActivity, readActivityHistory, resetActivityRegistry } from './chunk-C3TYI5TJ.js';
44
- import { MicroMcpServer } from './chunk-CZV3WUW5.js';
45
- export { MCP_PROTOCOL_VERSION, MicroMcpServer, ToolRegistry, errorResult, rpcError, textResult } from './chunk-CZV3WUW5.js';
44
+ import { MicroMcpServer } from './chunk-3GFKC6OK.js';
45
+ export { MCP_PROTOCOL_VERSION, MicroMcpServer, ToolRegistry, errorResult, rpcError, textResult } from './chunk-3GFKC6OK.js';
46
46
  import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
47
47
  import { jsx, jsxs } from 'react/jsx-runtime';
48
48
  import { createPortal } from 'react-dom';
@@ -1,8 +1,8 @@
1
- import { T as Transport, M as MicroMcpServer } from '../server-1y0n61R5.cjs';
2
- export { a as McpServerOptions, e as errorResult, r as rpcError, t as textResult } from '../server-1y0n61R5.cjs';
3
- import { c as JsonRpcMessage } from '../types-gzIpsUDE.cjs';
4
- export { C as CallToolResult, d as ContentBlock, I as InitializeResult, i as JSONRPC_INTERNAL_ERROR, j as JSONRPC_INVALID_PARAMS, k as JSONRPC_INVALID_REQUEST, l as JSONRPC_METHOD_NOT_FOUND, m as JSONRPC_PARSE_ERROR, J as JsonObject, n as JsonRpcError, o as JsonRpcId, e as JsonRpcNotification, f as JsonRpcRequest, p as JsonRpcSuccess, g as JsonValue, M as MCP_PROTOCOL_VERSION, R as RegisteredTool, b as ServerCapabilities, S as ServerInfo, q as ToolAnnotations, h as ToolCallContext, T as ToolDefinition, a as ToolHandler, r as ToolInputSchema } from '../types-gzIpsUDE.cjs';
5
- import '../tool-host-D67N2a2h.cjs';
1
+ import { T as Transport, M as MicroMcpServer } from '../server-DJJygNo1.cjs';
2
+ export { a as McpServerOptions, e as errorResult, r as rpcError, t as textResult } from '../server-DJJygNo1.cjs';
3
+ import { d as JsonRpcMessage } from '../types-ITRQFAir.cjs';
4
+ export { C as CallToolResult, e as ContentBlock, I as InitializeResult, j as JSONRPC_INTERNAL_ERROR, k as JSONRPC_INVALID_PARAMS, l as JSONRPC_INVALID_REQUEST, m as JSONRPC_METHOD_NOT_FOUND, n as JSONRPC_PARSE_ERROR, J as JsonObject, o as JsonRpcError, p as JsonRpcId, f as JsonRpcNotification, g as JsonRpcRequest, q as JsonRpcSuccess, h as JsonValue, M as MCP_PROTOCOL_VERSION, R as RegisterToolOptions, b as RegisteredTool, c as ServerCapabilities, S as ServerInfo, r as ToolAnnotations, i as ToolCallContext, T as ToolDefinition, a as ToolHandler, s as ToolInputSchema } from '../types-ITRQFAir.cjs';
5
+ import '../tool-host-BBSaU7IJ.cjs';
6
6
 
7
7
  /**
8
8
  * InProcessTransport — direct function-call wiring between an in-page MCP
@@ -1,8 +1,8 @@
1
- import { T as Transport, M as MicroMcpServer } from '../server-vq6qVl3T.js';
2
- export { a as McpServerOptions, e as errorResult, r as rpcError, t as textResult } from '../server-vq6qVl3T.js';
3
- import { c as JsonRpcMessage } from '../types-gzIpsUDE.js';
4
- export { C as CallToolResult, d as ContentBlock, I as InitializeResult, i as JSONRPC_INTERNAL_ERROR, j as JSONRPC_INVALID_PARAMS, k as JSONRPC_INVALID_REQUEST, l as JSONRPC_METHOD_NOT_FOUND, m as JSONRPC_PARSE_ERROR, J as JsonObject, n as JsonRpcError, o as JsonRpcId, e as JsonRpcNotification, f as JsonRpcRequest, p as JsonRpcSuccess, g as JsonValue, M as MCP_PROTOCOL_VERSION, R as RegisteredTool, b as ServerCapabilities, S as ServerInfo, q as ToolAnnotations, h as ToolCallContext, T as ToolDefinition, a as ToolHandler, r as ToolInputSchema } from '../types-gzIpsUDE.js';
5
- import '../tool-host-LYfdPE8u.js';
1
+ import { T as Transport, M as MicroMcpServer } from '../server-Dwo9LOxh.js';
2
+ export { a as McpServerOptions, e as errorResult, r as rpcError, t as textResult } from '../server-Dwo9LOxh.js';
3
+ import { d as JsonRpcMessage } from '../types-ITRQFAir.js';
4
+ export { C as CallToolResult, e as ContentBlock, I as InitializeResult, j as JSONRPC_INTERNAL_ERROR, k as JSONRPC_INVALID_PARAMS, l as JSONRPC_INVALID_REQUEST, m as JSONRPC_METHOD_NOT_FOUND, n as JSONRPC_PARSE_ERROR, J as JsonObject, o as JsonRpcError, p as JsonRpcId, f as JsonRpcNotification, g as JsonRpcRequest, q as JsonRpcSuccess, h as JsonValue, M as MCP_PROTOCOL_VERSION, R as RegisterToolOptions, b as RegisteredTool, c as ServerCapabilities, S as ServerInfo, r as ToolAnnotations, i as ToolCallContext, T as ToolDefinition, a as ToolHandler, s as ToolInputSchema } from '../types-ITRQFAir.js';
5
+ import '../tool-host-BqJRPr_T.js';
6
6
 
7
7
  /**
8
8
  * InProcessTransport — direct function-call wiring between an in-page MCP
@@ -1,6 +1,6 @@
1
- import { T as Transport, M as MicroMcpServer } from '../server-1y0n61R5.cjs';
2
- import { c as JsonRpcMessage } from '../types-gzIpsUDE.cjs';
3
- import '../tool-host-D67N2a2h.cjs';
1
+ import { T as Transport, M as MicroMcpServer } from '../server-DJJygNo1.cjs';
2
+ import { d as JsonRpcMessage } from '../types-ITRQFAir.cjs';
3
+ import '../tool-host-BBSaU7IJ.cjs';
4
4
 
5
5
  /**
6
6
  * StdioTransport — newline-delimited JSON-RPC over a byte stream pair.
@@ -1,6 +1,6 @@
1
- import { T as Transport, M as MicroMcpServer } from '../server-vq6qVl3T.js';
2
- import { c as JsonRpcMessage } from '../types-gzIpsUDE.js';
3
- import '../tool-host-LYfdPE8u.js';
1
+ import { T as Transport, M as MicroMcpServer } from '../server-Dwo9LOxh.js';
2
+ import { d as JsonRpcMessage } from '../types-ITRQFAir.js';
3
+ import '../tool-host-BqJRPr_T.js';
4
4
 
5
5
  /**
6
6
  * StdioTransport — newline-delimited JSON-RPC over a byte stream pair.
package/dist/mcp.cjs CHANGED
@@ -28,13 +28,23 @@ var ToolRegistry = class {
28
28
  */
29
29
  this.withdrawn = /* @__PURE__ */ new Set();
30
30
  }
31
- registerTool(definition, handler) {
32
- this.tools.set(definition.name, { definition, handler });
33
- this.withdrawn.delete(definition.name);
31
+ registerTool(definition, handler, options = {}) {
32
+ const name = definition.name;
33
+ const { owner, replace = false } = options;
34
+ const held = this.tools.get(name);
35
+ if (held && !replace && (owner === void 0 || held.owner !== owner)) {
36
+ throw new Error(
37
+ `Tool "${name}" is already registered by ${describeOwner(held.owner)}; ${describeOwner(owner)} cannot register it too. Two registrants for one name would leave the first one listed but unreachable. Give one of them a different tool name, dispose the first registration, or pass { replace: true } to take the name over deliberately.`
38
+ );
39
+ }
40
+ const record = owner === void 0 ? { definition, handler } : { definition, handler, owner };
41
+ this.tools.set(name, record);
42
+ this.withdrawn.delete(name);
34
43
  this.onToolsChanged();
35
44
  return () => {
36
- if (this.tools.delete(definition.name)) {
37
- this.withdrawn.add(definition.name);
45
+ if (this.tools.get(name) === record) {
46
+ this.tools.delete(name);
47
+ this.withdrawn.add(name);
38
48
  this.onToolsChanged();
39
49
  }
40
50
  };
@@ -63,6 +73,9 @@ var ToolRegistry = class {
63
73
  onToolsChanged() {
64
74
  }
65
75
  };
76
+ function describeOwner(owner) {
77
+ return owner === void 0 ? "an unnamed registrant (pass { owner } to registerTool to identify it)" : `"${owner}"`;
78
+ }
66
79
 
67
80
  // src/mcp/server.ts
68
81
  var MicroMcpServer = class extends ToolRegistry {
package/dist/mcp.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/mcp/types.ts","../src/mcp/tool-host.ts","../src/mcp/server.ts","../src/mcp/transports/in-process.ts","../src/mcp/transports/relay.ts"],"names":[],"mappings":";;;AA+CO,IAAM,mBAAA,GAAsB;AAC5B,IAAM,uBAAA,GAA0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AAA;AACtE,IAAA,MAAM,UAAU,OAAO,OAAA,KAAY,WAC9B,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA,GACnB,OAAA;AACJ,IAAA,MAAM,IAAA,CAAK,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA;AAAA,EACzC;AAAA,EAEA,KAAA,GAAc;AACZ,IAAA,IAAA,CAAK,QAAQ,OAAA,IAAU;AAAA,EACzB;AACF;AAKO,SAAS,WAAA,CAAY,QAAwB,OAAA,EAAuC;AACzF,EAAA,MAAM,SAAA,GAAY,IAAI,cAAA,CAAe,OAAO,CAAA;AAC5C,EAAA,SAAA,CAAU,WAAW,MAAM,CAAA;AAC3B,EAAA,MAAA,CAAO,OAAO,SAAS,CAAA;AACvB,EAAA,OAAO,SAAA;AACT","file":"mcp.cjs","sourcesContent":["/**\n * Minimal MCP (Model Context Protocol) types — covers the subset this\n * package implements: initialize, tools/list, tools/call, plus JSON-RPC.\n *\n * Aligned with the public MCP spec but trimmed to v0.1 needs. See\n * https://spec.modelcontextprotocol.io/ for the full surface.\n */\n\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | { [key: string]: JsonValue }\n | JsonValue[];\n\nexport type JsonObject = { [key: string]: JsonValue };\n\nexport type JsonRpcId = string | number | null;\n\nexport type JsonRpcRequest = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n method: string;\n params?: JsonObject;\n};\n\nexport type JsonRpcNotification = {\n jsonrpc: \"2.0\";\n method: string;\n params?: JsonObject;\n};\n\nexport type JsonRpcSuccess = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n result: JsonValue;\n};\n\nexport type JsonRpcError = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n error: { code: number; message: string; data?: JsonValue };\n};\n\nexport type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcSuccess | JsonRpcError;\n\nexport const JSONRPC_PARSE_ERROR = -32700;\nexport const JSONRPC_INVALID_REQUEST = -32600;\nexport const JSONRPC_METHOD_NOT_FOUND = -32601;\nexport const JSONRPC_INVALID_PARAMS = -32602;\nexport const JSONRPC_INTERNAL_ERROR = -32603;\n\nexport type ServerCapabilities = {\n tools?: { listChanged?: boolean };\n resources?: { listChanged?: boolean; subscribe?: boolean };\n prompts?: { listChanged?: boolean };\n logging?: Record<string, never>;\n experimental?: Record<string, JsonValue>;\n};\n\nexport type ServerInfo = {\n name: string;\n version: string;\n title?: string;\n};\n\nexport type InitializeResult = {\n protocolVersion: string;\n capabilities: ServerCapabilities;\n serverInfo: ServerInfo;\n instructions?: string;\n};\n\nexport type ToolInputSchema = {\n /** The JSON Schema dialect, when a server states it (e.g. draft-07). */\n $schema?: string;\n type: \"object\";\n properties?: Record<string, JsonValue>;\n required?: string[];\n additionalProperties?: boolean;\n};\n\n/** Behaviour hints a client may use when presenting or gating a tool. */\nexport type ToolAnnotations = {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n};\n\n/**\n * A tool as `tools/list` reports it. Every field is passed to the client\n * verbatim, so the optional ones below are the spec's, not extensions.\n */\nexport type ToolDefinition = {\n name: string;\n title?: string;\n description?: string;\n inputSchema: ToolInputSchema;\n /** JSON Schema for `structuredContent`, when the tool returns it. */\n outputSchema?: ToolInputSchema;\n annotations?: ToolAnnotations;\n /** 2025-11-25: whether the tool may run as a task. */\n execution?: { taskSupport?: \"forbidden\" | \"optional\" | \"required\" };\n _meta?: { [key: string]: JsonValue };\n};\n\nexport type ContentBlock =\n | { type: \"text\"; text: string }\n | { type: \"image\"; data: string; mimeType: string }\n | { type: \"resource\"; resource: { uri: string; text?: string; mimeType?: string } };\n\nexport type CallToolResult = {\n content: ContentBlock[];\n isError?: boolean;\n /** Structured tool output — non-spec but useful for typed bridges. */\n structuredContent?: JsonValue;\n};\n\n/** Handler signature for a tool registered on the MicroMcpServer. */\nexport type ToolCallContext = { transport?: unknown };\nexport type ToolHandler = (args: JsonObject, context?: ToolCallContext) => Promise<CallToolResult> | CallToolResult;\n\n/** Internal record kept by the server. */\nexport type RegisteredTool = {\n definition: ToolDefinition;\n handler: ToolHandler;\n};\n\nexport const MCP_PROTOCOL_VERSION = \"2025-06-18\";\n","import type {\n CallToolResult,\n JsonObject,\n RegisteredTool,\n ToolDefinition,\n ToolHandler,\n} from \"./types\";\n\n/**\n * ToolHost — the minimal surface a bridge needs to register its tools.\n *\n * Bridges (whiteboard, flow, sheets, code, charts, screens, scene, form)\n * speak only through this interface. The MCP server implements it\n * alongside its transport / JSON-RPC duties, and the standalone\n * {@link ToolRegistry} implements it for in-process agents that don't\n * need any of MCP's wire framing.\n *\n * Net effect: every bridge works equally well behind an MCP server\n * (browser ↔ external agents over SSE) or behind a plain registry\n * (in-process agent calling `host.callTool(\"sheet_set_cell\", { … })`).\n */\nexport interface ToolHost {\n /** Register a tool. Returns a disposer that unregisters it. */\n registerTool(definition: ToolDefinition, handler: ToolHandler): () => void;\n\n /** Look up an already-registered tool's definition + handler, or null. */\n getTool(name: string): RegisteredTool | null;\n\n /** Snapshot of all currently-registered tool definitions. */\n listTools(): ToolDefinition[];\n\n /**\n * Invoke a registered tool directly, bypassing any transport layer.\n * Throws if no tool is registered under `name`.\n *\n * This is the single entry point in-process agents use to drive the\n * surface — no JSON-RPC framing, no transport plumbing.\n */\n callTool(name: string, args?: JsonObject): Promise<CallToolResult>;\n}\n\n/**\n * Standalone in-memory ToolHost. Use this when no MCP server is needed —\n * e.g. an in-process agent that just wants to register the same bridges\n * and call them directly.\n *\n * Example:\n *\n * const host = new ToolRegistry();\n * registerSheetsBridge(host, { adapter });\n * const result = await host.callTool(\"sheet_set_cell\", { address: \"B3\", value: 42 });\n *\n * Pair with a MicroMcpServer in the same app to expose the same tools\n * to remote agents over SSE while in-process agents still get\n * zero-overhead direct calls.\n */\nexport class ToolRegistry implements ToolHost {\n protected readonly tools = new Map<string, RegisteredTool>();\n\n /**\n * Tools that existed and were withdrawn, kept so a call that races an unmount\n * can say WHICH thing happened.\n *\n * The tool surface is dynamic by design — \"site tools always, page tools while\n * mounted\" — so an agent deciding to call a tool while the human navigates\n * away is normal traffic, not an edge case. Reporting that as `Unknown tool`\n * is the least useful thing available: it reads as \"the agent is broken\" or\n * \"you asked for something imaginary\", when the truth is \"that surface just\n * closed\".\n *\n * Names only. Nothing about the handler is retained, so this cannot keep a\n * disposed surface alive.\n */\n protected readonly withdrawn = new Set<string>();\n\n registerTool(definition: ToolDefinition, handler: ToolHandler): () => void {\n this.tools.set(definition.name, { definition, handler });\n // A remounted surface must stop apologising for a previous unmount.\n this.withdrawn.delete(definition.name);\n this.onToolsChanged();\n return () => {\n if (this.tools.delete(definition.name)) {\n this.withdrawn.add(definition.name);\n this.onToolsChanged();\n }\n };\n }\n\n /** Why `name` is not callable, phrased for whoever has to act on it. */\n protected missingToolMessage(name: string): string {\n return this.withdrawn.has(name)\n ? `Tool \"${name}\" was withdrawn: the surface it targets is no longer mounted. `\n + `Call tools/list for the current surface — the site-wide tools remain available.`\n : `Unknown tool: ${name}`;\n }\n\n getTool(name: string): RegisteredTool | null {\n return this.tools.get(name) ?? null;\n }\n\n listTools(): ToolDefinition[] {\n return Array.from(this.tools.values()).map((t) => t.definition);\n }\n\n async callTool(name: string, args: JsonObject = {}): Promise<CallToolResult> {\n const tool = this.tools.get(name);\n if (!tool) {\n throw new Error(this.missingToolMessage(name));\n }\n return tool.handler(args);\n }\n\n /**\n * Hook for subclasses (e.g. MicroMcpServer) to notify subscribers\n * when the tool catalog changes. Default no-op.\n */\n protected onToolsChanged(): void {}\n}\n","import {\n type CallToolResult,\n type JsonObject,\n type JsonRpcMessage,\n type JsonRpcRequest,\n type JsonRpcId,\n type RegisteredTool,\n type ServerCapabilities,\n type ServerInfo,\n type ToolDefinition,\n type ToolHandler,\n JSONRPC_INTERNAL_ERROR,\n JSONRPC_INVALID_PARAMS,\n JSONRPC_METHOD_NOT_FOUND,\n MCP_PROTOCOL_VERSION,\n} from \"./types\";\nimport { ToolRegistry } from \"./tool-host\";\n\nexport type McpServerOptions = {\n info: ServerInfo;\n /** Defaults to { tools: { listChanged: true } } */\n capabilities?: ServerCapabilities;\n /** Free-text instructions surfaced to clients during initialize. */\n instructions?: string;\n /**\n * The protocol revisions this server speaks, NEWEST FIRST.\n *\n * `initialize` echoes the client's requested revision when it is in this\n * list, and answers the first entry otherwise — the spec's rule, which leaves\n * the client to decide whether it can live with the answer.\n *\n * Defaults to `[MCP_PROTOCOL_VERSION]`: one revision, answered whatever the\n * client asks, which is exactly what this server did before the option\n * existed. Only list a revision the tools you register are correct under.\n */\n protocolVersions?: readonly string[];\n};\n\nexport type Transport = {\n /** Called by the server when it has a message to deliver to the client. */\n send: (message: JsonRpcMessage) => void;\n /** Called by the server when it's torn down so the transport can clean up. */\n close?: () => void;\n};\n\n/**\n * MicroMcpServer — protocol-level MCP server, transport-agnostic.\n *\n * Use it like:\n *\n * const server = new MicroMcpServer({ info: { name: \"session\", version: \"0.1\" } });\n * server.registerTool({ name: \"...\", inputSchema: { type: \"object\" } }, async (args) => ({...}));\n * const transport = new InProcessTransport();\n * server.attach(transport);\n * transport.deliver({ ... }); // client → server frames\n *\n * The same server can serve multiple transports (e.g. an in-process agent\n * AND a relayed external client) by attaching each one.\n */\nexport class MicroMcpServer extends ToolRegistry {\n private transports = new Set<Transport>();\n /**\n * Transports owed a `tools/list_changed` at the end of this tick. Empty when\n * none is scheduled. See {@link scheduleListChangedNotification}.\n */\n private listChangedOwed = new Set<Transport>();\n\n readonly info: ServerInfo;\n readonly capabilities: ServerCapabilities;\n readonly instructions?: string;\n readonly protocolVersions: readonly string[];\n\n constructor(options: McpServerOptions) {\n super();\n this.info = options.info;\n this.capabilities = options.capabilities ?? { tools: { listChanged: true } };\n this.instructions = options.instructions;\n if (options.protocolVersions && options.protocolVersions.length === 0) {\n // No answer exists for a client's initialize. Fail here, next to the\n // mistake, rather than in a handshake nobody is watching.\n throw new Error(\"MicroMcpServer: protocolVersions is empty — a server must speak at least one protocol revision.\");\n }\n this.protocolVersions = options.protocolVersions ? [...options.protocolVersions] : [MCP_PROTOCOL_VERSION];\n }\n\n attach(transport: Transport): () => void {\n this.transports.add(transport);\n return () => this.detach(transport);\n }\n\n detach(transport: Transport): void {\n if (this.transports.delete(transport)) {\n transport.close?.();\n }\n }\n\n unregisterTool(name: string): void {\n if (this.tools.delete(name)) {\n this.scheduleListChangedNotification();\n }\n }\n\n protected onToolsChanged(): void {\n this.scheduleListChangedNotification();\n }\n\n /**\n * Receive a JSON-RPC frame from a client (called by the transport).\n * The transport is responsible for sending the response back.\n */\n async receive(transport: Transport, message: JsonRpcMessage): Promise<void> {\n if (!(\"method\" in message)) return; // It's a response, not a request — ignore.\n\n const isNotification = !(\"id\" in message);\n if (isNotification) {\n // Notifications are fire-and-forget. We ignore unknown methods.\n return;\n }\n\n const request = message as JsonRpcRequest;\n try {\n const result = await this.handle(request, transport);\n transport.send({ jsonrpc: \"2.0\", id: request.id, result });\n } catch (err) {\n transport.send({\n jsonrpc: \"2.0\",\n id: request.id,\n error: this.toRpcError(err),\n });\n }\n }\n\n private async handle(request: JsonRpcRequest, transport: Transport): Promise<any> {\n const { method, params } = request;\n switch (method) {\n case \"initialize\":\n return {\n protocolVersion: this.negotiate(params?.protocolVersion),\n capabilities: this.capabilities,\n serverInfo: this.info,\n ...(this.instructions ? { instructions: this.instructions } : {}),\n };\n\n case \"tools/list\":\n return { tools: this.listTools() };\n\n case \"tools/call\": {\n const name = params?.name;\n const args = (params?.arguments ?? {}) as JsonObject;\n if (typeof name !== \"string\") {\n throw rpcError(JSONRPC_INVALID_PARAMS, \"tools/call requires `name`\");\n }\n const tool = this.tools.get(name);\n if (!tool) {\n throw rpcError(JSONRPC_METHOD_NOT_FOUND, this.missingToolMessage(name));\n }\n const result = await tool.handler(args, { transport });\n return result satisfies CallToolResult;\n }\n\n case \"ping\":\n return {};\n\n default:\n throw rpcError(JSONRPC_METHOD_NOT_FOUND, `Unsupported method: ${method}`);\n }\n }\n\n /** The revision to answer `initialize` with: the one asked for if spoken, else the newest. */\n private negotiate(requested: unknown): string {\n return typeof requested === \"string\" && this.protocolVersions.includes(requested)\n ? requested\n : this.protocolVersions[0];\n }\n\n /**\n * Tell the transports that SAW the old tool list that it changed.\n *\n * Changes in one tick coalesce into one notification. The recipients are the\n * transports attached at the moment of a change, not at the moment the\n * notification goes out: a transport attached afterwards never had the old\n * list, so \"your list is stale\" is noise to it — and on stdio, where a host\n * builds the server and attaches stdin/stdout in the same tick, it was the\n * first frame a client received, before it had even sent `initialize`.\n */\n private scheduleListChangedNotification(): void {\n if (this.transports.size === 0) return;\n const scheduled = this.listChangedOwed.size > 0;\n for (const t of this.transports) this.listChangedOwed.add(t);\n if (scheduled) return;\n queueMicrotask(() => {\n const owed = this.listChangedOwed;\n this.listChangedOwed = new Set();\n for (const t of owed) {\n // Detached since the change: it is not listening any more.\n if (this.transports.has(t)) t.send({ jsonrpc: \"2.0\", method: \"notifications/tools/list_changed\" });\n }\n });\n }\n\n /** Send an application notification to every client, or one attached transport. */\n notify(message: JsonRpcMessage, transport?: Transport): void {\n if (transport) transport.send(message);\n else this.broadcast(message);\n }\n\n private broadcast(message: JsonRpcMessage): void {\n for (const t of this.transports) t.send(message);\n }\n\n private toRpcError(err: unknown): { code: number; message: string; data?: any } {\n if (err && typeof err === \"object\" && \"code\" in err && \"message\" in err) {\n return err as any;\n }\n return {\n code: JSONRPC_INTERNAL_ERROR,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nexport function rpcError(code: number, message: string, data?: any) {\n return { code, message, ...(data !== undefined ? { data } : {}) };\n}\n\n/**\n * Helper to build a CallToolResult from a string or structured value.\n */\nexport function textResult(text: string, structured?: any): CallToolResult {\n return {\n content: [{ type: \"text\", text }],\n ...(structured !== undefined ? { structuredContent: structured } : {}),\n };\n}\n\nexport function errorResult(text: string): CallToolResult {\n return { content: [{ type: \"text\", text }], isError: true };\n}\n\n// Internal helper so the JsonRpcId import isn't dropped by tsup\ntype _KeepIdImport = JsonRpcId;\n","import type { JsonRpcMessage } from \"../types\";\nimport type { MicroMcpServer, Transport } from \"../server\";\n\n/**\n * InProcessTransport — direct function-call wiring between an in-page MCP\n * client (e.g. an embedded chat agent) and a MicroMcpServer running in\n * the same JS context. No serialization, no network.\n *\n * Usage:\n *\n * const t = new InProcessTransport();\n * server.attach(t);\n * t.onServerMessage((msg) => { ... }); // client subscribes\n * t.send({ jsonrpc: \"2.0\", id: 1, method: \"tools/list\" }); // client → server\n */\nexport class InProcessTransport implements Transport {\n private server?: MicroMcpServer;\n private listeners = new Set<(msg: JsonRpcMessage) => void>();\n\n /** Bind to a server. Called from the client's setup, not directly. */\n bindServer(server: MicroMcpServer): void {\n this.server = server;\n }\n\n /** Server → client (delivered to subscribed listeners). */\n send(message: JsonRpcMessage): void {\n for (const l of this.listeners) l(message);\n }\n\n /** Client → server. Awaitable so callers can flush. */\n async deliver(message: JsonRpcMessage): Promise<void> {\n if (!this.server) throw new Error(\"InProcessTransport has no bound server\");\n await this.server.receive(this, message);\n }\n\n /** Subscribe to messages the server pushes to this client. */\n onServerMessage(listener: (msg: JsonRpcMessage) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n close(): void {\n this.listeners.clear();\n }\n}\n\n/**\n * Convenience: create a server-attached in-process transport in one call.\n */\nexport function attachInProcess(server: MicroMcpServer): InProcessTransport {\n const transport = new InProcessTransport();\n transport.bindServer(server);\n server.attach(transport);\n return transport;\n}\n","import type { JsonRpcMessage } from \"../types\";\nimport type { MicroMcpServer, Transport } from \"../server\";\n\n/**\n * RelayTransport — wraps any duplex JSON-frame channel (e.g. a Reverb\n * websocket private channel, a WebRTC data channel) so external agents\n * can talk to a browser-side MicroMcpServer.\n *\n * The host app owns the actual channel. This class only handles framing\n * (JSON.stringify / JSON.parse) and the server contract.\n *\n * Channel contract:\n * - host calls `transport.deliverFromRemote(payload)` with each frame\n * it receives from the remote agent\n * - host implements `sendToRemote(frame)` so the transport can deliver\n * server → client frames outward\n *\n * See docs/relay-protocol.md for the wire format.\n */\nexport type RelayChannel = {\n sendToRemote: (frame: JsonRpcMessage) => void;\n /** Optional: notify the channel that the server is gone. */\n onClose?: () => void;\n};\n\nexport class RelayTransport implements Transport {\n private server?: MicroMcpServer;\n constructor(private channel: RelayChannel) {}\n\n bindServer(server: MicroMcpServer): void {\n this.server = server;\n }\n\n send(message: JsonRpcMessage): void {\n this.channel.sendToRemote(message);\n }\n\n /**\n * Host calls this with each frame received from the remote agent. Accepts\n * either a parsed object or a raw JSON string.\n */\n async deliverFromRemote(payload: JsonRpcMessage | string): Promise<void> {\n if (!this.server) throw new Error(\"RelayTransport has no bound server\");\n const message = typeof payload === \"string\"\n ? (JSON.parse(payload) as JsonRpcMessage)\n : payload;\n await this.server.receive(this, message);\n }\n\n close(): void {\n this.channel.onClose?.();\n }\n}\n\n/**\n * Convenience wiring. Returns the bound transport.\n */\nexport function attachRelay(server: MicroMcpServer, channel: RelayChannel): RelayTransport {\n const transport = new RelayTransport(channel);\n transport.bindServer(server);\n server.attach(transport);\n return transport;\n}\n"]}
1
+ {"version":3,"sources":["../src/mcp/types.ts","../src/mcp/tool-host.ts","../src/mcp/server.ts","../src/mcp/transports/in-process.ts","../src/mcp/transports/relay.ts"],"names":[],"mappings":";;;AA+CO,IAAM,mBAAA,GAAsB;AAC5B,IAAM,uBAAA,GAA0B;AAChC,IAAM,wBAAA,GAA2B;AACjC,IAAM,sBAAA,GAAyB;AAC/B,IAAM,sBAAA,GAAyB;AA0G/B,IAAM,oBAAA,GAAuB;;;AC9F7B,IAAM,eAAN,MAAuC;AAAA,EAAvC,WAAA,GAAA;AACL,IAAA,IAAA,CAAmB,KAAA,uBAAY,GAAA,EAA4B;AAgB3D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA,IAAA,CAAmB,SAAA,uBAAgB,GAAA,EAAY;AAAA,EAAA;AAAA,EA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AE/C,YAAoB,OAAA,EAAuB;AAAvB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAAA,EAAwB;AAAA,EAE5C,WAAW,MAAA,EAA8B;AACvC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA,EAEA,KAAK,OAAA,EAA+B;AAClC,IAAA,IAAA,CAAK,OAAA,CAAQ,aAAa,OAAO,CAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,kBAAkB,OAAA,EAAiD;AACvE,IAAA,IAAI,CAAC,IAAA,CAAK,MAAA,EAAQ,MAAM,IAAI,MAAM,oCAAoC,CAAA;AACtE,IAAA,MAAM,UAAU,OAAO,OAAA,KAAY,WAC9B,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA,GACnB,OAAA;AACJ,IAAA,MAAM,IAAA,CAAK,MAAA,CAAO,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA;AAAA,EACzC;AAAA,EAEA,KAAA,GAAc;AACZ,IAAA,IAAA,CAAK,QAAQ,OAAA,IAAU;AAAA,EACzB;AACF;AAKO,SAAS,WAAA,CAAY,QAAwB,OAAA,EAAuC;AACzF,EAAA,MAAM,SAAA,GAAY,IAAI,cAAA,CAAe,OAAO,CAAA;AAC5C,EAAA,SAAA,CAAU,WAAW,MAAM,CAAA;AAC3B,EAAA,MAAA,CAAO,OAAO,SAAS,CAAA;AACvB,EAAA,OAAO,SAAA;AACT","file":"mcp.cjs","sourcesContent":["/**\n * Minimal MCP (Model Context Protocol) types — covers the subset this\n * package implements: initialize, tools/list, tools/call, plus JSON-RPC.\n *\n * Aligned with the public MCP spec but trimmed to v0.1 needs. See\n * https://spec.modelcontextprotocol.io/ for the full surface.\n */\n\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | { [key: string]: JsonValue }\n | JsonValue[];\n\nexport type JsonObject = { [key: string]: JsonValue };\n\nexport type JsonRpcId = string | number | null;\n\nexport type JsonRpcRequest = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n method: string;\n params?: JsonObject;\n};\n\nexport type JsonRpcNotification = {\n jsonrpc: \"2.0\";\n method: string;\n params?: JsonObject;\n};\n\nexport type JsonRpcSuccess = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n result: JsonValue;\n};\n\nexport type JsonRpcError = {\n jsonrpc: \"2.0\";\n id: JsonRpcId;\n error: { code: number; message: string; data?: JsonValue };\n};\n\nexport type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcSuccess | JsonRpcError;\n\nexport const JSONRPC_PARSE_ERROR = -32700;\nexport const JSONRPC_INVALID_REQUEST = -32600;\nexport const JSONRPC_METHOD_NOT_FOUND = -32601;\nexport const JSONRPC_INVALID_PARAMS = -32602;\nexport const JSONRPC_INTERNAL_ERROR = -32603;\n\nexport type ServerCapabilities = {\n tools?: { listChanged?: boolean };\n resources?: { listChanged?: boolean; subscribe?: boolean };\n prompts?: { listChanged?: boolean };\n logging?: Record<string, never>;\n experimental?: Record<string, JsonValue>;\n};\n\nexport type ServerInfo = {\n name: string;\n version: string;\n title?: string;\n};\n\nexport type InitializeResult = {\n protocolVersion: string;\n capabilities: ServerCapabilities;\n serverInfo: ServerInfo;\n instructions?: string;\n};\n\nexport type ToolInputSchema = {\n /** The JSON Schema dialect, when a server states it (e.g. draft-07). */\n $schema?: string;\n type: \"object\";\n properties?: Record<string, JsonValue>;\n required?: string[];\n additionalProperties?: boolean;\n};\n\n/** Behaviour hints a client may use when presenting or gating a tool. */\nexport type ToolAnnotations = {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n};\n\n/**\n * A tool as `tools/list` reports it. Every field is passed to the client\n * verbatim, so the optional ones below are the spec's, not extensions.\n */\nexport type ToolDefinition = {\n name: string;\n title?: string;\n description?: string;\n inputSchema: ToolInputSchema;\n /** JSON Schema for `structuredContent`, when the tool returns it. */\n outputSchema?: ToolInputSchema;\n annotations?: ToolAnnotations;\n /** 2025-11-25: whether the tool may run as a task. */\n execution?: { taskSupport?: \"forbidden\" | \"optional\" | \"required\" };\n _meta?: { [key: string]: JsonValue };\n};\n\nexport type ContentBlock =\n | { type: \"text\"; text: string }\n | { type: \"image\"; data: string; mimeType: string }\n | { type: \"resource\"; resource: { uri: string; text?: string; mimeType?: string } };\n\nexport type CallToolResult = {\n content: ContentBlock[];\n isError?: boolean;\n /** Structured tool output — non-spec but useful for typed bridges. */\n structuredContent?: JsonValue;\n};\n\n/** Handler signature for a tool registered on the MicroMcpServer. */\nexport type ToolCallContext = { transport?: unknown };\nexport type ToolHandler = (args: JsonObject, context?: ToolCallContext) => Promise<CallToolResult> | CallToolResult;\n\n/**\n * Options for `ToolHost.registerTool`.\n *\n * Tool names are one namespace shared by every bridge and agent on a host, so a\n * name belongs to whoever registered it. A second registrant for a held name is\n * refused rather than silently replacing the first.\n */\nexport type RegisterToolOptions = {\n /**\n * Who is registering — a stable identity for the surface, e.g. the bridge id\n * (`\"whiteboard\"`, `\"chart:revenue\"`). The SAME owner may register a name it\n * already holds again; that replaces the tool, which is what a React remount\n * needs. A different owner is refused. A registration without an owner is a\n * registrant nobody can identify, so it never matches another one.\n */\n owner?: string;\n /**\n * Take the name over whoever holds it. The explicit opt-in for the one thing\n * `registerTool` used to do implicitly; reach for it only when replacing\n * another registrant's tool is the point.\n */\n replace?: boolean;\n};\n\n/** Internal record kept by the server. */\nexport type RegisteredTool = {\n definition: ToolDefinition;\n handler: ToolHandler;\n /** The registrant that holds this name, when it identified itself. */\n owner?: string;\n};\n\nexport const MCP_PROTOCOL_VERSION = \"2025-06-18\";\n","import type {\n CallToolResult,\n JsonObject,\n RegisteredTool,\n RegisterToolOptions,\n ToolDefinition,\n ToolHandler,\n} from \"./types\";\n\n/**\n * ToolHost — the minimal surface a bridge needs to register its tools.\n *\n * Bridges (whiteboard, flow, sheets, code, charts, screens, scene, form)\n * speak only through this interface. The MCP server implements it\n * alongside its transport / JSON-RPC duties, and the standalone\n * {@link ToolRegistry} implements it for in-process agents that don't\n * need any of MCP's wire framing.\n *\n * Net effect: every bridge works equally well behind an MCP server\n * (browser ↔ external agents over SSE) or behind a plain registry\n * (in-process agent calling `host.callTool(\"sheet_set_cell\", { … })`).\n */\nexport interface ToolHost {\n /**\n * Register a tool. Returns a disposer that unregisters it.\n *\n * Throws when the name is already held by a DIFFERENT registrant (see\n * {@link RegisterToolOptions.owner}), unless `replace: true` is passed. The\n * same owner registering again replaces its own tool.\n */\n registerTool(definition: ToolDefinition, handler: ToolHandler, options?: RegisterToolOptions): () => void;\n\n /** Look up an already-registered tool's definition + handler, or null. */\n getTool(name: string): RegisteredTool | null;\n\n /** Snapshot of all currently-registered tool definitions. */\n listTools(): ToolDefinition[];\n\n /**\n * Invoke a registered tool directly, bypassing any transport layer.\n * Throws if no tool is registered under `name`.\n *\n * This is the single entry point in-process agents use to drive the\n * surface — no JSON-RPC framing, no transport plumbing.\n */\n callTool(name: string, args?: JsonObject): Promise<CallToolResult>;\n}\n\n/**\n * Standalone in-memory ToolHost. Use this when no MCP server is needed —\n * e.g. an in-process agent that just wants to register the same bridges\n * and call them directly.\n *\n * Example:\n *\n * const host = new ToolRegistry();\n * registerSheetsBridge(host, { adapter });\n * const result = await host.callTool(\"sheet_set_cell\", { address: \"B3\", value: 42 });\n *\n * Pair with a MicroMcpServer in the same app to expose the same tools\n * to remote agents over SSE while in-process agents still get\n * zero-overhead direct calls.\n */\nexport class ToolRegistry implements ToolHost {\n protected readonly tools = new Map<string, RegisteredTool>();\n\n /**\n * Tools that existed and were withdrawn, kept so a call that races an unmount\n * can say WHICH thing happened.\n *\n * The tool surface is dynamic by design — \"site tools always, page tools while\n * mounted\" — so an agent deciding to call a tool while the human navigates\n * away is normal traffic, not an edge case. Reporting that as `Unknown tool`\n * is the least useful thing available: it reads as \"the agent is broken\" or\n * \"you asked for something imaginary\", when the truth is \"that surface just\n * closed\".\n *\n * Names only. Nothing about the handler is retained, so this cannot keep a\n * disposed surface alive.\n */\n protected readonly withdrawn = new Set<string>();\n\n registerTool(definition: ToolDefinition, handler: ToolHandler, options: RegisterToolOptions = {}): () => void {\n const name = definition.name;\n const { owner, replace = false } = options;\n const held = this.tools.get(name);\n\n // A name is one surface's. Replacing it silently left the first surface\n // listed but unreachable — every call went to the second handler and\n // nothing said so. Only the same identified owner may re-register (a\n // remount); anyone else must ask for it with `replace: true`.\n if (held && !replace && (owner === undefined || held.owner !== owner)) {\n throw new Error(\n `Tool \"${name}\" is already registered by ${describeOwner(held.owner)}; `\n + `${describeOwner(owner)} cannot register it too. `\n + `Two registrants for one name would leave the first one listed but unreachable. `\n + `Give one of them a different tool name, dispose the first registration, `\n + `or pass { replace: true } to take the name over deliberately.`,\n );\n }\n\n const record: RegisteredTool = owner === undefined ? { definition, handler } : { definition, handler, owner };\n this.tools.set(name, record);\n // A remounted surface must stop apologising for a previous unmount.\n this.withdrawn.delete(name);\n this.onToolsChanged();\n return () => {\n // Only withdraw what THIS registration put there. A replaced registration's\n // disposer often runs late (a remount's cleanup), and must not take its\n // successor down with it.\n if (this.tools.get(name) === record) {\n this.tools.delete(name);\n this.withdrawn.add(name);\n this.onToolsChanged();\n }\n };\n }\n\n /** Why `name` is not callable, phrased for whoever has to act on it. */\n protected missingToolMessage(name: string): string {\n return this.withdrawn.has(name)\n ? `Tool \"${name}\" was withdrawn: the surface it targets is no longer mounted. `\n + `Call tools/list for the current surface — the site-wide tools remain available.`\n : `Unknown tool: ${name}`;\n }\n\n getTool(name: string): RegisteredTool | null {\n return this.tools.get(name) ?? null;\n }\n\n listTools(): ToolDefinition[] {\n return Array.from(this.tools.values()).map((t) => t.definition);\n }\n\n async callTool(name: string, args: JsonObject = {}): Promise<CallToolResult> {\n const tool = this.tools.get(name);\n if (!tool) {\n throw new Error(this.missingToolMessage(name));\n }\n return tool.handler(args);\n }\n\n /**\n * Hook for subclasses (e.g. MicroMcpServer) to notify subscribers\n * when the tool catalog changes. Default no-op.\n */\n protected onToolsChanged(): void {}\n}\n\nfunction describeOwner(owner: string | undefined): string {\n return owner === undefined\n ? \"an unnamed registrant (pass { owner } to registerTool to identify it)\"\n : `\"${owner}\"`;\n}\n","import {\n type CallToolResult,\n type JsonObject,\n type JsonRpcMessage,\n type JsonRpcRequest,\n type JsonRpcId,\n type RegisteredTool,\n type ServerCapabilities,\n type ServerInfo,\n type ToolDefinition,\n type ToolHandler,\n JSONRPC_INTERNAL_ERROR,\n JSONRPC_INVALID_PARAMS,\n JSONRPC_METHOD_NOT_FOUND,\n MCP_PROTOCOL_VERSION,\n} from \"./types\";\nimport { ToolRegistry } from \"./tool-host\";\n\nexport type McpServerOptions = {\n info: ServerInfo;\n /** Defaults to { tools: { listChanged: true } } */\n capabilities?: ServerCapabilities;\n /** Free-text instructions surfaced to clients during initialize. */\n instructions?: string;\n /**\n * The protocol revisions this server speaks, NEWEST FIRST.\n *\n * `initialize` echoes the client's requested revision when it is in this\n * list, and answers the first entry otherwise — the spec's rule, which leaves\n * the client to decide whether it can live with the answer.\n *\n * Defaults to `[MCP_PROTOCOL_VERSION]`: one revision, answered whatever the\n * client asks, which is exactly what this server did before the option\n * existed. Only list a revision the tools you register are correct under.\n */\n protocolVersions?: readonly string[];\n};\n\nexport type Transport = {\n /** Called by the server when it has a message to deliver to the client. */\n send: (message: JsonRpcMessage) => void;\n /** Called by the server when it's torn down so the transport can clean up. */\n close?: () => void;\n};\n\n/**\n * MicroMcpServer — protocol-level MCP server, transport-agnostic.\n *\n * Use it like:\n *\n * const server = new MicroMcpServer({ info: { name: \"session\", version: \"0.1\" } });\n * server.registerTool({ name: \"...\", inputSchema: { type: \"object\" } }, async (args) => ({...}));\n * const transport = new InProcessTransport();\n * server.attach(transport);\n * transport.deliver({ ... }); // client → server frames\n *\n * The same server can serve multiple transports (e.g. an in-process agent\n * AND a relayed external client) by attaching each one.\n */\nexport class MicroMcpServer extends ToolRegistry {\n private transports = new Set<Transport>();\n /**\n * Transports owed a `tools/list_changed` at the end of this tick. Empty when\n * none is scheduled. See {@link scheduleListChangedNotification}.\n */\n private listChangedOwed = new Set<Transport>();\n\n readonly info: ServerInfo;\n readonly capabilities: ServerCapabilities;\n readonly instructions?: string;\n readonly protocolVersions: readonly string[];\n\n constructor(options: McpServerOptions) {\n super();\n this.info = options.info;\n this.capabilities = options.capabilities ?? { tools: { listChanged: true } };\n this.instructions = options.instructions;\n if (options.protocolVersions && options.protocolVersions.length === 0) {\n // No answer exists for a client's initialize. Fail here, next to the\n // mistake, rather than in a handshake nobody is watching.\n throw new Error(\"MicroMcpServer: protocolVersions is empty — a server must speak at least one protocol revision.\");\n }\n this.protocolVersions = options.protocolVersions ? [...options.protocolVersions] : [MCP_PROTOCOL_VERSION];\n }\n\n attach(transport: Transport): () => void {\n this.transports.add(transport);\n return () => this.detach(transport);\n }\n\n detach(transport: Transport): void {\n if (this.transports.delete(transport)) {\n transport.close?.();\n }\n }\n\n unregisterTool(name: string): void {\n if (this.tools.delete(name)) {\n this.scheduleListChangedNotification();\n }\n }\n\n protected onToolsChanged(): void {\n this.scheduleListChangedNotification();\n }\n\n /**\n * Receive a JSON-RPC frame from a client (called by the transport).\n * The transport is responsible for sending the response back.\n */\n async receive(transport: Transport, message: JsonRpcMessage): Promise<void> {\n if (!(\"method\" in message)) return; // It's a response, not a request — ignore.\n\n const isNotification = !(\"id\" in message);\n if (isNotification) {\n // Notifications are fire-and-forget. We ignore unknown methods.\n return;\n }\n\n const request = message as JsonRpcRequest;\n try {\n const result = await this.handle(request, transport);\n transport.send({ jsonrpc: \"2.0\", id: request.id, result });\n } catch (err) {\n transport.send({\n jsonrpc: \"2.0\",\n id: request.id,\n error: this.toRpcError(err),\n });\n }\n }\n\n private async handle(request: JsonRpcRequest, transport: Transport): Promise<any> {\n const { method, params } = request;\n switch (method) {\n case \"initialize\":\n return {\n protocolVersion: this.negotiate(params?.protocolVersion),\n capabilities: this.capabilities,\n serverInfo: this.info,\n ...(this.instructions ? { instructions: this.instructions } : {}),\n };\n\n case \"tools/list\":\n return { tools: this.listTools() };\n\n case \"tools/call\": {\n const name = params?.name;\n const args = (params?.arguments ?? {}) as JsonObject;\n if (typeof name !== \"string\") {\n throw rpcError(JSONRPC_INVALID_PARAMS, \"tools/call requires `name`\");\n }\n const tool = this.tools.get(name);\n if (!tool) {\n throw rpcError(JSONRPC_METHOD_NOT_FOUND, this.missingToolMessage(name));\n }\n const result = await tool.handler(args, { transport });\n return result satisfies CallToolResult;\n }\n\n case \"ping\":\n return {};\n\n default:\n throw rpcError(JSONRPC_METHOD_NOT_FOUND, `Unsupported method: ${method}`);\n }\n }\n\n /** The revision to answer `initialize` with: the one asked for if spoken, else the newest. */\n private negotiate(requested: unknown): string {\n return typeof requested === \"string\" && this.protocolVersions.includes(requested)\n ? requested\n : this.protocolVersions[0];\n }\n\n /**\n * Tell the transports that SAW the old tool list that it changed.\n *\n * Changes in one tick coalesce into one notification. The recipients are the\n * transports attached at the moment of a change, not at the moment the\n * notification goes out: a transport attached afterwards never had the old\n * list, so \"your list is stale\" is noise to it — and on stdio, where a host\n * builds the server and attaches stdin/stdout in the same tick, it was the\n * first frame a client received, before it had even sent `initialize`.\n */\n private scheduleListChangedNotification(): void {\n if (this.transports.size === 0) return;\n const scheduled = this.listChangedOwed.size > 0;\n for (const t of this.transports) this.listChangedOwed.add(t);\n if (scheduled) return;\n queueMicrotask(() => {\n const owed = this.listChangedOwed;\n this.listChangedOwed = new Set();\n for (const t of owed) {\n // Detached since the change: it is not listening any more.\n if (this.transports.has(t)) t.send({ jsonrpc: \"2.0\", method: \"notifications/tools/list_changed\" });\n }\n });\n }\n\n /** Send an application notification to every client, or one attached transport. */\n notify(message: JsonRpcMessage, transport?: Transport): void {\n if (transport) transport.send(message);\n else this.broadcast(message);\n }\n\n private broadcast(message: JsonRpcMessage): void {\n for (const t of this.transports) t.send(message);\n }\n\n private toRpcError(err: unknown): { code: number; message: string; data?: any } {\n if (err && typeof err === \"object\" && \"code\" in err && \"message\" in err) {\n return err as any;\n }\n return {\n code: JSONRPC_INTERNAL_ERROR,\n message: err instanceof Error ? err.message : String(err),\n };\n }\n}\n\nexport function rpcError(code: number, message: string, data?: any) {\n return { code, message, ...(data !== undefined ? { data } : {}) };\n}\n\n/**\n * Helper to build a CallToolResult from a string or structured value.\n */\nexport function textResult(text: string, structured?: any): CallToolResult {\n return {\n content: [{ type: \"text\", text }],\n ...(structured !== undefined ? { structuredContent: structured } : {}),\n };\n}\n\nexport function errorResult(text: string): CallToolResult {\n return { content: [{ type: \"text\", text }], isError: true };\n}\n\n// Internal helper so the JsonRpcId import isn't dropped by tsup\ntype _KeepIdImport = JsonRpcId;\n","import type { JsonRpcMessage } from \"../types\";\nimport type { MicroMcpServer, Transport } from \"../server\";\n\n/**\n * InProcessTransport — direct function-call wiring between an in-page MCP\n * client (e.g. an embedded chat agent) and a MicroMcpServer running in\n * the same JS context. No serialization, no network.\n *\n * Usage:\n *\n * const t = new InProcessTransport();\n * server.attach(t);\n * t.onServerMessage((msg) => { ... }); // client subscribes\n * t.send({ jsonrpc: \"2.0\", id: 1, method: \"tools/list\" }); // client → server\n */\nexport class InProcessTransport implements Transport {\n private server?: MicroMcpServer;\n private listeners = new Set<(msg: JsonRpcMessage) => void>();\n\n /** Bind to a server. Called from the client's setup, not directly. */\n bindServer(server: MicroMcpServer): void {\n this.server = server;\n }\n\n /** Server → client (delivered to subscribed listeners). */\n send(message: JsonRpcMessage): void {\n for (const l of this.listeners) l(message);\n }\n\n /** Client → server. Awaitable so callers can flush. */\n async deliver(message: JsonRpcMessage): Promise<void> {\n if (!this.server) throw new Error(\"InProcessTransport has no bound server\");\n await this.server.receive(this, message);\n }\n\n /** Subscribe to messages the server pushes to this client. */\n onServerMessage(listener: (msg: JsonRpcMessage) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n close(): void {\n this.listeners.clear();\n }\n}\n\n/**\n * Convenience: create a server-attached in-process transport in one call.\n */\nexport function attachInProcess(server: MicroMcpServer): InProcessTransport {\n const transport = new InProcessTransport();\n transport.bindServer(server);\n server.attach(transport);\n return transport;\n}\n","import type { JsonRpcMessage } from \"../types\";\nimport type { MicroMcpServer, Transport } from \"../server\";\n\n/**\n * RelayTransport — wraps any duplex JSON-frame channel (e.g. a Reverb\n * websocket private channel, a WebRTC data channel) so external agents\n * can talk to a browser-side MicroMcpServer.\n *\n * The host app owns the actual channel. This class only handles framing\n * (JSON.stringify / JSON.parse) and the server contract.\n *\n * Channel contract:\n * - host calls `transport.deliverFromRemote(payload)` with each frame\n * it receives from the remote agent\n * - host implements `sendToRemote(frame)` so the transport can deliver\n * server → client frames outward\n *\n * See docs/relay-protocol.md for the wire format.\n */\nexport type RelayChannel = {\n sendToRemote: (frame: JsonRpcMessage) => void;\n /** Optional: notify the channel that the server is gone. */\n onClose?: () => void;\n};\n\nexport class RelayTransport implements Transport {\n private server?: MicroMcpServer;\n constructor(private channel: RelayChannel) {}\n\n bindServer(server: MicroMcpServer): void {\n this.server = server;\n }\n\n send(message: JsonRpcMessage): void {\n this.channel.sendToRemote(message);\n }\n\n /**\n * Host calls this with each frame received from the remote agent. Accepts\n * either a parsed object or a raw JSON string.\n */\n async deliverFromRemote(payload: JsonRpcMessage | string): Promise<void> {\n if (!this.server) throw new Error(\"RelayTransport has no bound server\");\n const message = typeof payload === \"string\"\n ? (JSON.parse(payload) as JsonRpcMessage)\n : payload;\n await this.server.receive(this, message);\n }\n\n close(): void {\n this.channel.onClose?.();\n }\n}\n\n/**\n * Convenience wiring. Returns the bound transport.\n */\nexport function attachRelay(server: MicroMcpServer, channel: RelayChannel): RelayTransport {\n const transport = new RelayTransport(channel);\n transport.bindServer(server);\n server.attach(transport);\n return transport;\n}\n"]}
package/dist/mcp.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { RelayTransport, attachRelay } from './chunk-G6N2TQVO.js';
2
2
  export { InProcessTransport, attachInProcess } from './chunk-AFUULW5E.js';
3
- export { JSONRPC_INTERNAL_ERROR, JSONRPC_INVALID_PARAMS, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_PARSE_ERROR, MCP_PROTOCOL_VERSION, MicroMcpServer, errorResult, rpcError, textResult } from './chunk-CZV3WUW5.js';
3
+ export { JSONRPC_INTERNAL_ERROR, JSONRPC_INVALID_PARAMS, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_PARSE_ERROR, MCP_PROTOCOL_VERSION, MicroMcpServer, errorResult, rpcError, textResult } from './chunk-3GFKC6OK.js';
4
4
  //# sourceMappingURL=mcp.js.map
5
5
  //# sourceMappingURL=mcp.js.map
@@ -1,6 +1,6 @@
1
1
  import { AutoTarget, ActivityFilter, AutoActivityEvent } from '@particle-academy/fancy-auto-common';
2
2
  export { ActivityFilter, AutoActivityEvent as AgentActivityEvent, AutoActivityListener as AgentActivityListener, AutoTarget as AgentTarget, AutoTargetKind as AgentTargetKind, emitActivity, onActivity, readActivityHistory, resetActivityRegistry } from '@particle-academy/fancy-auto-common';
3
- import { C as CallToolResult } from '../types-gzIpsUDE.cjs';
3
+ import { C as CallToolResult } from '../types-ITRQFAir.cjs';
4
4
 
5
5
  type ActivityAgent = {
6
6
  id: string;
@@ -1,6 +1,6 @@
1
1
  import { AutoTarget, ActivityFilter, AutoActivityEvent } from '@particle-academy/fancy-auto-common';
2
2
  export { ActivityFilter, AutoActivityEvent as AgentActivityEvent, AutoActivityListener as AgentActivityListener, AutoTarget as AgentTarget, AutoTargetKind as AgentTargetKind, emitActivity, onActivity, readActivityHistory, resetActivityRegistry } from '@particle-academy/fancy-auto-common';
3
- import { C as CallToolResult } from '../types-gzIpsUDE.js';
3
+ import { C as CallToolResult } from '../types-ITRQFAir.js';
4
4
 
5
5
  type ActivityAgent = {
6
6
  id: string;
@@ -1,5 +1,5 @@
1
- import { S as ServerInfo, b as ServerCapabilities, c as JsonRpcMessage, C as CallToolResult } from './types-gzIpsUDE.cjs';
2
- import { a as ToolRegistry } from './tool-host-D67N2a2h.cjs';
1
+ import { S as ServerInfo, c as ServerCapabilities, d as JsonRpcMessage, C as CallToolResult } from './types-ITRQFAir.cjs';
2
+ import { a as ToolRegistry } from './tool-host-BBSaU7IJ.cjs';
3
3
 
4
4
  type McpServerOptions = {
5
5
  info: ServerInfo;
@@ -1,5 +1,5 @@
1
- import { S as ServerInfo, b as ServerCapabilities, c as JsonRpcMessage, C as CallToolResult } from './types-gzIpsUDE.js';
2
- import { a as ToolRegistry } from './tool-host-LYfdPE8u.js';
1
+ import { S as ServerInfo, c as ServerCapabilities, d as JsonRpcMessage, C as CallToolResult } from './types-ITRQFAir.js';
2
+ import { a as ToolRegistry } from './tool-host-BqJRPr_T.js';
3
3
 
4
4
  type McpServerOptions = {
5
5
  info: ServerInfo;
@@ -1,8 +1,8 @@
1
1
  export { S as SessionDescriptor, b as buildShareConfig, a as buildShareUrl, e as constantTimeEqual, c as createSessionDescriptor, d as describeSession, r as readSessionFromUrl } from '../token-BZ8doMam.cjs';
2
- import { c as JsonRpcMessage } from '../types-gzIpsUDE.cjs';
3
- import { T as Transport, M as MicroMcpServer } from '../server-1y0n61R5.cjs';
2
+ import { d as JsonRpcMessage } from '../types-ITRQFAir.cjs';
3
+ import { T as Transport, M as MicroMcpServer } from '../server-DJJygNo1.cjs';
4
4
  import { AutoActivityEvent } from '@particle-academy/fancy-auto-common';
5
- import '../tool-host-D67N2a2h.cjs';
5
+ import '../tool-host-BBSaU7IJ.cjs';
6
6
 
7
7
  /**
8
8
  * SseRelayTransport — bridges the in-page MicroMcpServer to a host-app
@@ -1,8 +1,8 @@
1
1
  export { S as SessionDescriptor, b as buildShareConfig, a as buildShareUrl, e as constantTimeEqual, c as createSessionDescriptor, d as describeSession, r as readSessionFromUrl } from '../token-BZ8doMam.js';
2
- import { c as JsonRpcMessage } from '../types-gzIpsUDE.js';
3
- import { T as Transport, M as MicroMcpServer } from '../server-vq6qVl3T.js';
2
+ import { d as JsonRpcMessage } from '../types-ITRQFAir.js';
3
+ import { T as Transport, M as MicroMcpServer } from '../server-Dwo9LOxh.js';
4
4
  import { AutoActivityEvent } from '@particle-academy/fancy-auto-common';
5
- import '../tool-host-LYfdPE8u.js';
5
+ import '../tool-host-BqJRPr_T.js';
6
6
 
7
7
  /**
8
8
  * SseRelayTransport — bridges the in-page MicroMcpServer to a host-app
@@ -1,7 +1,7 @@
1
1
  import { SheetsBridgeAdapter } from './bridges/sheets.cjs';
2
- import './tool-host-D67N2a2h.cjs';
3
- import './types-gzIpsUDE.cjs';
4
- import './types-DP5yQZQU.cjs';
2
+ import './tool-host-BBSaU7IJ.cjs';
3
+ import './types-ITRQFAir.cjs';
4
+ import './types-D_H2f-wF.cjs';
5
5
  import '@particle-academy/fancy-sheets';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { SheetsBridgeAdapter } from './bridges/sheets.js';
2
- import './tool-host-LYfdPE8u.js';
3
- import './types-gzIpsUDE.js';
4
- import './types-VX_9je7w.js';
2
+ import './tool-host-BqJRPr_T.js';
3
+ import './types-ITRQFAir.js';
4
+ import './types-D_TzdBsK.js';
5
5
  import '@particle-academy/fancy-sheets';
6
6
 
7
7
  /**
@@ -1,4 +1,4 @@
1
- import { T as ToolDefinition, a as ToolHandler, R as RegisteredTool, J as JsonObject, C as CallToolResult } from './types-gzIpsUDE.js';
1
+ import { T as ToolDefinition, a as ToolHandler, R as RegisterToolOptions, b as RegisteredTool, J as JsonObject, C as CallToolResult } from './types-ITRQFAir.cjs';
2
2
 
3
3
  /**
4
4
  * ToolHost — the minimal surface a bridge needs to register its tools.
@@ -14,8 +14,14 @@ import { T as ToolDefinition, a as ToolHandler, R as RegisteredTool, J as JsonOb
14
14
  * (in-process agent calling `host.callTool("sheet_set_cell", { … })`).
15
15
  */
16
16
  interface ToolHost {
17
- /** Register a tool. Returns a disposer that unregisters it. */
18
- registerTool(definition: ToolDefinition, handler: ToolHandler): () => void;
17
+ /**
18
+ * Register a tool. Returns a disposer that unregisters it.
19
+ *
20
+ * Throws when the name is already held by a DIFFERENT registrant (see
21
+ * {@link RegisterToolOptions.owner}), unless `replace: true` is passed. The
22
+ * same owner registering again replaces its own tool.
23
+ */
24
+ registerTool(definition: ToolDefinition, handler: ToolHandler, options?: RegisterToolOptions): () => void;
19
25
  /** Look up an already-registered tool's definition + handler, or null. */
20
26
  getTool(name: string): RegisteredTool | null;
21
27
  /** Snapshot of all currently-registered tool definitions. */
@@ -61,7 +67,7 @@ declare class ToolRegistry implements ToolHost {
61
67
  * disposed surface alive.
62
68
  */
63
69
  protected readonly withdrawn: Set<string>;
64
- registerTool(definition: ToolDefinition, handler: ToolHandler): () => void;
70
+ registerTool(definition: ToolDefinition, handler: ToolHandler, options?: RegisterToolOptions): () => void;
65
71
  /** Why `name` is not callable, phrased for whoever has to act on it. */
66
72
  protected missingToolMessage(name: string): string;
67
73
  getTool(name: string): RegisteredTool | null;
@@ -1,4 +1,4 @@
1
- import { T as ToolDefinition, a as ToolHandler, R as RegisteredTool, J as JsonObject, C as CallToolResult } from './types-gzIpsUDE.cjs';
1
+ import { T as ToolDefinition, a as ToolHandler, R as RegisterToolOptions, b as RegisteredTool, J as JsonObject, C as CallToolResult } from './types-ITRQFAir.js';
2
2
 
3
3
  /**
4
4
  * ToolHost — the minimal surface a bridge needs to register its tools.
@@ -14,8 +14,14 @@ import { T as ToolDefinition, a as ToolHandler, R as RegisteredTool, J as JsonOb
14
14
  * (in-process agent calling `host.callTool("sheet_set_cell", { … })`).
15
15
  */
16
16
  interface ToolHost {
17
- /** Register a tool. Returns a disposer that unregisters it. */
18
- registerTool(definition: ToolDefinition, handler: ToolHandler): () => void;
17
+ /**
18
+ * Register a tool. Returns a disposer that unregisters it.
19
+ *
20
+ * Throws when the name is already held by a DIFFERENT registrant (see
21
+ * {@link RegisterToolOptions.owner}), unless `replace: true` is passed. The
22
+ * same owner registering again replaces its own tool.
23
+ */
24
+ registerTool(definition: ToolDefinition, handler: ToolHandler, options?: RegisterToolOptions): () => void;
19
25
  /** Look up an already-registered tool's definition + handler, or null. */
20
26
  getTool(name: string): RegisteredTool | null;
21
27
  /** Snapshot of all currently-registered tool definitions. */
@@ -61,7 +67,7 @@ declare class ToolRegistry implements ToolHost {
61
67
  * disposed surface alive.
62
68
  */
63
69
  protected readonly withdrawn: Set<string>;
64
- registerTool(definition: ToolDefinition, handler: ToolHandler): () => void;
70
+ registerTool(definition: ToolDefinition, handler: ToolHandler, options?: RegisterToolOptions): () => void;
65
71
  /** Why `name` is not callable, phrased for whoever has to act on it. */
66
72
  protected missingToolMessage(name: string): string;
67
73
  getTool(name: string): RegisteredTool | null;
@@ -1,4 +1,4 @@
1
- import { T as ToolHost } from './tool-host-D67N2a2h.cjs';
1
+ import { T as ToolHost } from './tool-host-BBSaU7IJ.cjs';
2
2
 
3
3
  /**
4
4
  * Bridge — registers a cohesive set of MCP tools/resources for a single
@@ -1,4 +1,4 @@
1
- import { T as ToolHost } from './tool-host-LYfdPE8u.js';
1
+ import { T as ToolHost } from './tool-host-BqJRPr_T.js';
2
2
 
3
3
  /**
4
4
  * Bridge — registers a cohesive set of MCP tools/resources for a single
@@ -130,11 +130,36 @@ type ToolCallContext = {
130
130
  transport?: unknown;
131
131
  };
132
132
  type ToolHandler = (args: JsonObject, context?: ToolCallContext) => Promise<CallToolResult> | CallToolResult;
133
+ /**
134
+ * Options for `ToolHost.registerTool`.
135
+ *
136
+ * Tool names are one namespace shared by every bridge and agent on a host, so a
137
+ * name belongs to whoever registered it. A second registrant for a held name is
138
+ * refused rather than silently replacing the first.
139
+ */
140
+ type RegisterToolOptions = {
141
+ /**
142
+ * Who is registering — a stable identity for the surface, e.g. the bridge id
143
+ * (`"whiteboard"`, `"chart:revenue"`). The SAME owner may register a name it
144
+ * already holds again; that replaces the tool, which is what a React remount
145
+ * needs. A different owner is refused. A registration without an owner is a
146
+ * registrant nobody can identify, so it never matches another one.
147
+ */
148
+ owner?: string;
149
+ /**
150
+ * Take the name over whoever holds it. The explicit opt-in for the one thing
151
+ * `registerTool` used to do implicitly; reach for it only when replacing
152
+ * another registrant's tool is the point.
153
+ */
154
+ replace?: boolean;
155
+ };
133
156
  /** Internal record kept by the server. */
134
157
  type RegisteredTool = {
135
158
  definition: ToolDefinition;
136
159
  handler: ToolHandler;
160
+ /** The registrant that holds this name, when it identified itself. */
161
+ owner?: string;
137
162
  };
138
163
  declare const MCP_PROTOCOL_VERSION = "2025-06-18";
139
164
 
140
- export { type CallToolResult as C, type InitializeResult as I, type JsonObject as J, MCP_PROTOCOL_VERSION as M, type RegisteredTool as R, type ServerInfo as S, type ToolDefinition as T, type ToolHandler as a, type ServerCapabilities as b, type JsonRpcMessage as c, type ContentBlock as d, type JsonRpcNotification as e, type JsonRpcRequest as f, type JsonValue as g, type ToolCallContext as h, JSONRPC_INTERNAL_ERROR as i, JSONRPC_INVALID_PARAMS as j, JSONRPC_INVALID_REQUEST as k, JSONRPC_METHOD_NOT_FOUND as l, JSONRPC_PARSE_ERROR as m, type JsonRpcError as n, type JsonRpcId as o, type JsonRpcSuccess as p, type ToolAnnotations as q, type ToolInputSchema as r };
165
+ export { type CallToolResult as C, type InitializeResult as I, type JsonObject as J, MCP_PROTOCOL_VERSION as M, type RegisterToolOptions as R, type ServerInfo as S, type ToolDefinition as T, type ToolHandler as a, type RegisteredTool as b, type ServerCapabilities as c, type JsonRpcMessage as d, type ContentBlock as e, type JsonRpcNotification as f, type JsonRpcRequest as g, type JsonValue as h, type ToolCallContext as i, JSONRPC_INTERNAL_ERROR as j, JSONRPC_INVALID_PARAMS as k, JSONRPC_INVALID_REQUEST as l, JSONRPC_METHOD_NOT_FOUND as m, JSONRPC_PARSE_ERROR as n, type JsonRpcError as o, type JsonRpcId as p, type JsonRpcSuccess as q, type ToolAnnotations as r, type ToolInputSchema as s };