@dudko.dev/agent-web-ui 0.0.1 → 0.0.3

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 (265) hide show
  1. package/README.md +94 -3
  2. package/dist/canvas.cjs +0 -1
  3. package/dist/canvas.js +1 -2
  4. package/dist/{chunk-EL2YCROY.js → chunk-D64VLIRY.js} +0 -1
  5. package/dist/chunk-G7LQTOA2.js +1439 -0
  6. package/dist/{chunk-4EHUITGU.js → chunk-S5AHUAFG.js} +6 -1
  7. package/dist/{chunk-7O64ZI6Z.js → chunk-TJBGZM6D.js} +0 -1
  8. package/dist/{chunk-P2F2P3JC.js → chunk-UNIXGP4N.js} +6 -1
  9. package/dist/{chunk-A55Q377T.js → chunk-V33T6VX3.js} +6 -1
  10. package/dist/{chunk-TPK25QGK.js → chunk-VZCQXE3P.js} +6 -1
  11. package/dist/{chunk-GB7RZJMG.js → chunk-WEYQMUKY.js} +0 -1
  12. package/dist/{chunk-KZQB35LS.js → chunk-Y6QYUFSC.js} +0 -1
  13. package/dist/controller.cjs +1890 -0
  14. package/dist/controller.d.cts +253 -0
  15. package/dist/controller.d.ts +253 -0
  16. package/dist/controller.js +481 -0
  17. package/dist/{en-CcNUz2tN.d.ts → en-Dg2MtzcJ.d.cts} +6 -0
  18. package/dist/{en-CcNUz2tN.d.cts → en-Dg2MtzcJ.d.ts} +6 -0
  19. package/dist/index.cjs +133 -1
  20. package/dist/index.d.cts +82 -4
  21. package/dist/index.d.ts +82 -4
  22. package/dist/index.js +144 -1422
  23. package/dist/{labels-UuWI7wPo.d.ts → labels-CmiTBLWD.d.cts} +68 -100
  24. package/dist/{labels-D5BrHct4.d.cts → labels-DH1ESUtm.d.ts} +68 -100
  25. package/dist/locales/be.cjs +12 -1
  26. package/dist/locales/be.d.cts +4 -2
  27. package/dist/locales/be.d.ts +4 -2
  28. package/dist/locales/be.js +7 -2
  29. package/dist/locales/bg.cjs +12 -1
  30. package/dist/locales/bg.d.cts +4 -2
  31. package/dist/locales/bg.d.ts +4 -2
  32. package/dist/locales/bg.js +7 -2
  33. package/dist/locales/ca.cjs +12 -1
  34. package/dist/locales/ca.d.cts +4 -2
  35. package/dist/locales/ca.d.ts +4 -2
  36. package/dist/locales/ca.js +7 -2
  37. package/dist/locales/cs.cjs +12 -1
  38. package/dist/locales/cs.d.cts +4 -2
  39. package/dist/locales/cs.d.ts +4 -2
  40. package/dist/locales/cs.js +7 -2
  41. package/dist/locales/da.cjs +12 -1
  42. package/dist/locales/da.d.cts +4 -2
  43. package/dist/locales/da.d.ts +4 -2
  44. package/dist/locales/da.js +7 -2
  45. package/dist/locales/de.cjs +12 -1
  46. package/dist/locales/de.d.cts +4 -2
  47. package/dist/locales/de.d.ts +4 -2
  48. package/dist/locales/de.js +7 -2
  49. package/dist/locales/el.cjs +12 -1
  50. package/dist/locales/el.d.cts +4 -2
  51. package/dist/locales/el.d.ts +4 -2
  52. package/dist/locales/el.js +7 -2
  53. package/dist/locales/en.cjs +12 -1
  54. package/dist/locales/en.d.cts +4 -2
  55. package/dist/locales/en.d.ts +4 -2
  56. package/dist/locales/en.js +7 -2
  57. package/dist/locales/es-419.cjs +16 -2
  58. package/dist/locales/es-419.d.cts +4 -2
  59. package/dist/locales/es-419.d.ts +4 -2
  60. package/dist/locales/es-419.js +6 -4
  61. package/dist/locales/es.cjs +12 -1
  62. package/dist/locales/es.d.cts +4 -2
  63. package/dist/locales/es.d.ts +4 -2
  64. package/dist/locales/es.js +2 -3
  65. package/dist/locales/fi.cjs +12 -1
  66. package/dist/locales/fi.d.cts +4 -2
  67. package/dist/locales/fi.d.ts +4 -2
  68. package/dist/locales/fi.js +7 -2
  69. package/dist/locales/fr-CA.cjs +12 -1
  70. package/dist/locales/fr-CA.d.cts +4 -2
  71. package/dist/locales/fr-CA.d.ts +4 -2
  72. package/dist/locales/fr-CA.js +2 -3
  73. package/dist/locales/fr.cjs +12 -1
  74. package/dist/locales/fr.d.cts +4 -2
  75. package/dist/locales/fr.d.ts +4 -2
  76. package/dist/locales/fr.js +2 -3
  77. package/dist/locales/gn.cjs +12 -1
  78. package/dist/locales/gn.d.cts +4 -2
  79. package/dist/locales/gn.d.ts +4 -2
  80. package/dist/locales/gn.js +7 -2
  81. package/dist/locales/hr.cjs +12 -1
  82. package/dist/locales/hr.d.cts +4 -2
  83. package/dist/locales/hr.d.ts +4 -2
  84. package/dist/locales/hr.js +7 -2
  85. package/dist/locales/ht.cjs +12 -1
  86. package/dist/locales/ht.d.cts +4 -2
  87. package/dist/locales/ht.d.ts +4 -2
  88. package/dist/locales/ht.js +7 -2
  89. package/dist/locales/hu.cjs +12 -1
  90. package/dist/locales/hu.d.cts +4 -2
  91. package/dist/locales/hu.d.ts +4 -2
  92. package/dist/locales/hu.js +7 -2
  93. package/dist/locales/index.cjs +6 -1
  94. package/dist/locales/index.d.cts +6 -4
  95. package/dist/locales/index.d.ts +6 -4
  96. package/dist/locales/index.js +1 -2
  97. package/dist/locales/it.cjs +12 -1
  98. package/dist/locales/it.d.cts +4 -2
  99. package/dist/locales/it.d.ts +4 -2
  100. package/dist/locales/it.js +7 -2
  101. package/dist/locales/nb.cjs +12 -1
  102. package/dist/locales/nb.d.cts +4 -2
  103. package/dist/locales/nb.d.ts +4 -2
  104. package/dist/locales/nb.js +7 -2
  105. package/dist/locales/nl.cjs +12 -1
  106. package/dist/locales/nl.d.cts +4 -2
  107. package/dist/locales/nl.d.ts +4 -2
  108. package/dist/locales/nl.js +7 -2
  109. package/dist/locales/pl.cjs +12 -1
  110. package/dist/locales/pl.d.cts +4 -2
  111. package/dist/locales/pl.d.ts +4 -2
  112. package/dist/locales/pl.js +7 -2
  113. package/dist/locales/pt-BR.cjs +12 -1
  114. package/dist/locales/pt-BR.d.cts +4 -2
  115. package/dist/locales/pt-BR.d.ts +4 -2
  116. package/dist/locales/pt-BR.js +7 -2
  117. package/dist/locales/pt.cjs +12 -1
  118. package/dist/locales/pt.d.cts +4 -2
  119. package/dist/locales/pt.d.ts +4 -2
  120. package/dist/locales/pt.js +7 -2
  121. package/dist/locales/qu.cjs +12 -1
  122. package/dist/locales/qu.d.cts +4 -2
  123. package/dist/locales/qu.d.ts +4 -2
  124. package/dist/locales/qu.js +7 -2
  125. package/dist/locales/ro.cjs +12 -1
  126. package/dist/locales/ro.d.cts +4 -2
  127. package/dist/locales/ro.d.ts +4 -2
  128. package/dist/locales/ro.js +7 -2
  129. package/dist/locales/ru.cjs +12 -1
  130. package/dist/locales/ru.d.cts +4 -2
  131. package/dist/locales/ru.d.ts +4 -2
  132. package/dist/locales/ru.js +7 -2
  133. package/dist/locales/sk.cjs +12 -1
  134. package/dist/locales/sk.d.cts +4 -2
  135. package/dist/locales/sk.d.ts +4 -2
  136. package/dist/locales/sk.js +7 -2
  137. package/dist/locales/sq.cjs +12 -1
  138. package/dist/locales/sq.d.cts +4 -2
  139. package/dist/locales/sq.d.ts +4 -2
  140. package/dist/locales/sq.js +7 -2
  141. package/dist/locales/sr-Latn.cjs +12 -1
  142. package/dist/locales/sr-Latn.d.cts +4 -2
  143. package/dist/locales/sr-Latn.d.ts +4 -2
  144. package/dist/locales/sr-Latn.js +2 -3
  145. package/dist/locales/sr.cjs +12 -1
  146. package/dist/locales/sr.d.cts +4 -2
  147. package/dist/locales/sr.d.ts +4 -2
  148. package/dist/locales/sr.js +2 -3
  149. package/dist/locales/sv.cjs +12 -1
  150. package/dist/locales/sv.d.cts +4 -2
  151. package/dist/locales/sv.d.ts +4 -2
  152. package/dist/locales/sv.js +7 -2
  153. package/dist/locales/tr.cjs +12 -1
  154. package/dist/locales/tr.d.cts +4 -2
  155. package/dist/locales/tr.d.ts +4 -2
  156. package/dist/locales/tr.js +7 -2
  157. package/dist/locales/uk.cjs +12 -1
  158. package/dist/locales/uk.d.cts +4 -2
  159. package/dist/locales/uk.d.ts +4 -2
  160. package/dist/locales/uk.js +7 -2
  161. package/dist/markdown.cjs +0 -1
  162. package/dist/markdown.js +1 -2
  163. package/dist/mcp-app-sandbox.cjs +0 -1
  164. package/dist/mcp-app-sandbox.js +1 -2
  165. package/dist/mcp-app.cjs +0 -1
  166. package/dist/mcp-app.d.cts +491 -3
  167. package/dist/mcp-app.d.ts +491 -3
  168. package/dist/mcp-app.js +2 -3
  169. package/dist/pipeline.cjs +0 -1
  170. package/dist/pipeline.js +1 -2
  171. package/dist/questions-Dw--IEjT.d.cts +100 -0
  172. package/dist/questions-Dw--IEjT.d.ts +100 -0
  173. package/dist/{types-BmvgYUzF.d.cts → types-CQquuZpl.d.cts} +1 -1
  174. package/dist/{types-Cr5gmUts.d.ts → types-CXZfZVP5.d.ts} +1 -1
  175. package/dist/{mcp-app-entry-BA-Ca39z.d.ts → types-DnBCok3z.d.cts} +2 -488
  176. package/dist/{mcp-app-entry-tybABaHg.d.cts → types-DnBCok3z.d.ts} +2 -488
  177. package/package.json +13 -3
  178. package/dist/canvas.cjs.map +0 -1
  179. package/dist/canvas.js.map +0 -1
  180. package/dist/chunk-4EHUITGU.js.map +0 -1
  181. package/dist/chunk-7O64ZI6Z.js.map +0 -1
  182. package/dist/chunk-A55Q377T.js.map +0 -1
  183. package/dist/chunk-EL2YCROY.js.map +0 -1
  184. package/dist/chunk-GB7RZJMG.js.map +0 -1
  185. package/dist/chunk-KZQB35LS.js.map +0 -1
  186. package/dist/chunk-P2F2P3JC.js.map +0 -1
  187. package/dist/chunk-TPK25QGK.js.map +0 -1
  188. package/dist/index.cjs.map +0 -1
  189. package/dist/index.js.map +0 -1
  190. package/dist/locales/be.cjs.map +0 -1
  191. package/dist/locales/be.js.map +0 -1
  192. package/dist/locales/bg.cjs.map +0 -1
  193. package/dist/locales/bg.js.map +0 -1
  194. package/dist/locales/ca.cjs.map +0 -1
  195. package/dist/locales/ca.js.map +0 -1
  196. package/dist/locales/cs.cjs.map +0 -1
  197. package/dist/locales/cs.js.map +0 -1
  198. package/dist/locales/da.cjs.map +0 -1
  199. package/dist/locales/da.js.map +0 -1
  200. package/dist/locales/de.cjs.map +0 -1
  201. package/dist/locales/de.js.map +0 -1
  202. package/dist/locales/el.cjs.map +0 -1
  203. package/dist/locales/el.js.map +0 -1
  204. package/dist/locales/en.cjs.map +0 -1
  205. package/dist/locales/en.js.map +0 -1
  206. package/dist/locales/es-419.cjs.map +0 -1
  207. package/dist/locales/es-419.js.map +0 -1
  208. package/dist/locales/es.cjs.map +0 -1
  209. package/dist/locales/es.js.map +0 -1
  210. package/dist/locales/fi.cjs.map +0 -1
  211. package/dist/locales/fi.js.map +0 -1
  212. package/dist/locales/fr-CA.cjs.map +0 -1
  213. package/dist/locales/fr-CA.js.map +0 -1
  214. package/dist/locales/fr.cjs.map +0 -1
  215. package/dist/locales/fr.js.map +0 -1
  216. package/dist/locales/gn.cjs.map +0 -1
  217. package/dist/locales/gn.js.map +0 -1
  218. package/dist/locales/hr.cjs.map +0 -1
  219. package/dist/locales/hr.js.map +0 -1
  220. package/dist/locales/ht.cjs.map +0 -1
  221. package/dist/locales/ht.js.map +0 -1
  222. package/dist/locales/hu.cjs.map +0 -1
  223. package/dist/locales/hu.js.map +0 -1
  224. package/dist/locales/index.cjs.map +0 -1
  225. package/dist/locales/index.js.map +0 -1
  226. package/dist/locales/it.cjs.map +0 -1
  227. package/dist/locales/it.js.map +0 -1
  228. package/dist/locales/nb.cjs.map +0 -1
  229. package/dist/locales/nb.js.map +0 -1
  230. package/dist/locales/nl.cjs.map +0 -1
  231. package/dist/locales/nl.js.map +0 -1
  232. package/dist/locales/pl.cjs.map +0 -1
  233. package/dist/locales/pl.js.map +0 -1
  234. package/dist/locales/pt-BR.cjs.map +0 -1
  235. package/dist/locales/pt-BR.js.map +0 -1
  236. package/dist/locales/pt.cjs.map +0 -1
  237. package/dist/locales/pt.js.map +0 -1
  238. package/dist/locales/qu.cjs.map +0 -1
  239. package/dist/locales/qu.js.map +0 -1
  240. package/dist/locales/ro.cjs.map +0 -1
  241. package/dist/locales/ro.js.map +0 -1
  242. package/dist/locales/ru.cjs.map +0 -1
  243. package/dist/locales/ru.js.map +0 -1
  244. package/dist/locales/sk.cjs.map +0 -1
  245. package/dist/locales/sk.js.map +0 -1
  246. package/dist/locales/sq.cjs.map +0 -1
  247. package/dist/locales/sq.js.map +0 -1
  248. package/dist/locales/sr-Latn.cjs.map +0 -1
  249. package/dist/locales/sr-Latn.js.map +0 -1
  250. package/dist/locales/sr.cjs.map +0 -1
  251. package/dist/locales/sr.js.map +0 -1
  252. package/dist/locales/sv.cjs.map +0 -1
  253. package/dist/locales/sv.js.map +0 -1
  254. package/dist/locales/tr.cjs.map +0 -1
  255. package/dist/locales/tr.js.map +0 -1
  256. package/dist/locales/uk.cjs.map +0 -1
  257. package/dist/locales/uk.js.map +0 -1
  258. package/dist/markdown.cjs.map +0 -1
  259. package/dist/markdown.js.map +0 -1
  260. package/dist/mcp-app-sandbox.cjs.map +0 -1
  261. package/dist/mcp-app-sandbox.js.map +0 -1
  262. package/dist/mcp-app.cjs.map +0 -1
  263. package/dist/mcp-app.js.map +0 -1
  264. package/dist/pipeline.cjs.map +0 -1
  265. package/dist/pipeline.js.map +0 -1
@@ -1,5 +1,4 @@
1
- import { AgentToolSet, McpAppResource, McpAppToolResult, IPlan, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, AskUserOption, AskUserAction, SessionHolder, ReplanMode, AgentEvent, McpAppCsp } from '@dudko.dev/agent-web';
2
- import { a as McpAppColorScheme } from './mcp-app-policy-DXKQ2jjM.cjs';
1
+ import { AgentToolSet, McpAppResource, McpAppToolResult, IPlanStep, ModelTier, TierReason, EscalationReason, DecisionPoint, DecisionFallbackReason, McpSkillConsentView, IUsage, IPlan, AskUserOption, AskUserAction, SessionHolder, ReplanMode, AgentEvent } from '@dudko.dev/agent-web';
3
2
 
4
3
  /**
5
4
  * Structural types for the core's OPTIONAL `@dudko.dev/agent-web/mcp` subpath.
@@ -992,489 +991,4 @@ interface RemoteRunView {
992
991
  ended?: 'done' | 'stopped' | 'gone';
993
992
  }
994
993
 
995
- /**
996
- * MCP Apps, the host's side: the security core of `<McpAppFrame>`, as pure code - no React, no
997
- * DOM - so every guard is unit-tested (`tests/apps.test.ts`) and proved in a real browser
998
- * (`e2e/apps.spec.ts`).
999
- *
1000
- * The frame: an app is third-party HTML WITH scripts that must talk to the page, so it gets the
1001
- * HTML preview's boundary (`html-preview.ts`) and one addition, a relay:
1002
- *
1003
- * 1. The outer `<iframe sandbox="allow-scripts">` (never `allow-same-origin`): an opaque origin,
1004
- * no access to the page's DOM, storage, IndexedDB (the key vault) or cookies; no top
1005
- * navigation, popups, forms, modals, downloads. No `allow` attribute: no camera, microphone,
1006
- * geolocation or clipboard, whatever the app asked for.
1007
- * 2. It holds a SHELL of ours (`buildMcpAppDocument`): the policy built from the resource's
1008
- * declared origins and nothing else (`mcpAppCsp`), one inner frame - the app, also
1009
- * `sandbox="allow-scripts"`, with the same policy first in its own document - and a relay
1010
- * script. The shell's `frame-src 'none'` is what stops the app navigating itself (a frame
1011
- * may always navigate itself; only the EMBEDDING document's policy decides where to).
1012
- * 3. The relay forwards messages between the page and the app, and nothing else: from the
1013
- * app's window to the page, from the page to the app's window, never the
1014
- * `ui/notifications/sandbox-*` messages the specification reserves. The app talks to
1015
- * `window.parent` as the extension's SDK does; the page accepts messages only from the outer
1016
- * frame (`event.source`), so the app writing to `window.top` directly is ignored.
1017
- * 4. The bridge (`McpAppBridge`) answers the app: a method allow-list, checked parameters, a
1018
- * cap on requests in flight, and every request that DOES something (a tool call, a link, a
1019
- * message) handed to the host, which asks the user.
1020
- *
1021
- * That is the default. Opt-in, the app runs on an origin of its own instead, behind a sandbox
1022
- * page the host serves on another origin (the specification's "sandbox proxy"): 1 - 3 change
1023
- * (see "An app on an origin of its own" below and `mcp-app-policy.ts`), 4 does not.
1024
- */
1025
- /** The revision of the extension this host speaks. */
1026
- declare const MCP_APP_PROTOCOL_VERSION = "2026-01-26";
1027
- /** An app's frame height, before it says how tall it is. */
1028
- declare const APP_DEFAULT_HEIGHT = 360;
1029
- /**
1030
- * The frame's height is the host's: the app's wish, clamped to `APP_MIN_HEIGHT` .. the cap. The
1031
- * cap is `appHeightCap` of the chat's visible height - a few screens, never less than
1032
- * `APP_MAX_HEIGHT` - so an app as tall as its content has no scroller of its own inside the
1033
- * transcript (one scroller: the chat's), and an app that grows forever stops there.
1034
- */
1035
- declare const APP_MIN_HEIGHT = 120;
1036
- /** The least the cap is (and the cap where nothing says how tall the chat is). */
1037
- declare const APP_MAX_HEIGHT = 800;
1038
- /** The cap is this many of the chat's visible heights. */
1039
- declare const APP_HEIGHT_SCREENS = 3;
1040
- /** ... and never more than this, whatever the screen. */
1041
- declare const APP_HEIGHT_CEILING = 6000;
1042
- /**
1043
- * The tallest an inline app's frame is drawn, for a chat body (or viewport) `viewHeight` px tall:
1044
- * `APP_HEIGHT_SCREENS` of it, rounded down to 100 px (the app is told it in
1045
- * `containerDimensions.maxHeight`, and a resize of a few pixels must not tell it again), at least
1046
- * `APP_MAX_HEIGHT`, at most `APP_HEIGHT_CEILING`.
1047
- */
1048
- declare const appHeightCap: (viewHeight: number | undefined) => number;
1049
- /**
1050
- * The cap of a frame that is already drawn, when the chat's height changes: `appHeightCap` of the
1051
- * new height, but never less than the cap the frame had (`current`) - a rotation, a keyboard
1052
- * resizing the page or a relayout for a touch screen must not give an app that was drawn whole a
1053
- * scroller of its own. The cap only grows while the frame is shown (at most
1054
- * `APP_HEIGHT_CEILING`); a new frame starts from the cap of its moment.
1055
- */
1056
- declare const nextAppHeightCap: (current: number, viewHeight: number | undefined) => number;
1057
- /** At most this many requests of one app wait at once (tool calls, links, messages). */
1058
- declare const MCP_APP_MAX_IN_FLIGHT = 3;
1059
- /** A message an app puts in the chat: at most this many characters. */
1060
- declare const MCP_APP_MAX_MESSAGE_CHARS = 4000;
1061
- /** A link an app asks to open: at most this many characters. */
1062
- declare const MCP_APP_MAX_URL_CHARS = 2048;
1063
- /** The arguments of a tool call an app makes: at most this many characters as JSON. */
1064
- declare const MCP_APP_MAX_ARGS_CHARS = 64000;
1065
- /** An app's wish for a height, as the frame draws it: within `APP_MIN_HEIGHT` .. `max` (the cap). */
1066
- declare const clampAppHeight: (height: number, max?: number) => number;
1067
- /**
1068
- * The policy of an app's document: scripts and styles inline, `data:` / `blob:` media, and the
1069
- * network ONLY where the resource declared it - `connectDomains` for `fetch` / XHR / WebSocket,
1070
- * `resourceDomains` for scripts, styles, images, fonts and media. Nothing declared, nothing
1071
- * reached. Nested frames, workers, plugins, forms and `<base>` are refused whatever was declared
1072
- * (`frameDomains` / `baseUriDomains` are not granted: a frame the app may embed would also be a
1073
- * place it may navigate itself to). Each entry is checked again with the core's `mcpAppOrigin`.
1074
- */
1075
- declare const mcpAppCsp: (csp?: Partial<McpAppCsp>) => string;
1076
- /** The origins the policy actually grants: what the app is told in `hostCapabilities.sandbox`. */
1077
- declare const grantedAppCsp: (csp?: Partial<McpAppCsp>) => {
1078
- connectDomains: string[];
1079
- resourceDomains: string[];
1080
- };
1081
- /**
1082
- * The relay of the shell: the app's messages to the page, the page's to the app - matched by
1083
- * `event.source`, never by anything the message says - and not the reserved
1084
- * `ui/notifications/sandbox-*` ones. It reads nothing else and runs nothing it is sent.
1085
- */
1086
- declare const MCP_APP_RELAY: string;
1087
- /**
1088
- * What goes into the OUTER frame's `srcdoc`: the shell (the app's policy first, one inner frame
1089
- * that fills it, the relay) carrying the app, escaped, as the inner frame's `srcdoc` - with the
1090
- * same policy first in it. Give the outer `<iframe>` `sandbox="allow-scripts"` and nothing else.
1091
- * `scheme` (the theme the app is told) is declared by the shell and its inner frame; give the
1092
- * outer `<iframe>` the same `color-scheme`. Only `light` / `dark` are declared.
1093
- */
1094
- declare const buildMcpAppDocument: (html: string, csp?: Partial<McpAppCsp>, scheme?: McpAppColorScheme) => string;
1095
- /** A link an app asks to open, taken apart for the prompt: the host is what the user checks. */
1096
- interface AppLink {
1097
- /** The normalised URL (what is opened). */
1098
- href: string;
1099
- /** `https://` */
1100
- scheme: string;
1101
- /** The host (and port), as the browser will go there - an internationalised name in punycode. */
1102
- host: string;
1103
- /** Everything after the host. */
1104
- rest: string;
1105
- }
1106
- /** An `http(s)` URL with a host and no credentials, at most `MCP_APP_MAX_URL_CHARS`; else none. */
1107
- declare const appLinkOf: (value: unknown) => AppLink | undefined;
1108
- /**
1109
- * The text of a `ui/message` an app sends: text blocks only (one, or a list of at most 20),
1110
- * joined, without invisible characters, at most `MCP_APP_MAX_MESSAGE_CHARS`. Anything else -
1111
- * an image, a resource, an empty or a longer text - is refused (`undefined`).
1112
- */
1113
- declare const appMessageTextOf: (content: unknown) => string | undefined;
1114
- /** A JSON-RPC message as the bridge sends it. */
1115
- type McpAppRpcMessage = {
1116
- jsonrpc: '2.0';
1117
- id: string | number;
1118
- method: string;
1119
- params?: unknown;
1120
- } | {
1121
- jsonrpc: '2.0';
1122
- method: string;
1123
- params?: unknown;
1124
- } | {
1125
- jsonrpc: '2.0';
1126
- id: string | number;
1127
- result: unknown;
1128
- } | {
1129
- jsonrpc: '2.0';
1130
- id: string | number;
1131
- error: {
1132
- code: number;
1133
- message: string;
1134
- };
1135
- };
1136
- /** The requests an app may make of this host. Any other is answered "method not found". */
1137
- declare const MCP_APP_REQUESTS: readonly ["ui/initialize", "ping", "tools/call", "ui/open-link", "ui/message", "ui/request-display-mode"];
1138
- /**
1139
- * Requests answered only when the host turned the feature on (`downloadFile` / `sampling` in
1140
- * `hostCapabilities`, a handler given to the bridge); otherwise "method not found", as before.
1141
- */
1142
- declare const MCP_APP_OPTIONAL_REQUESTS: readonly ["ui/download-file", "sampling/createMessage"];
1143
- /** The notifications this host reads. Any other is dropped. */
1144
- declare const MCP_APP_NOTIFICATIONS: readonly ["ui/notifications/initialized", "ui/notifications/size-changed"];
1145
- /** An error the bridge answers with: a JSON-RPC code and a message for the app. */
1146
- declare class McpAppRpcError extends Error {
1147
- readonly code: number;
1148
- constructor(code: number, message: string);
1149
- }
1150
- /** The host refused: the user said no, too many requests, not initialized. */
1151
- declare const MCP_APP_REFUSED = -32000;
1152
- /** How an app is shown (`hostContext.displayMode`). This host offers `inline` and `fullscreen`. */
1153
- type McpAppDisplayMode = 'inline' | 'fullscreen' | 'pip';
1154
- /** The modes the extension names (a request for any other is invalid). */
1155
- declare const MCP_APP_DISPLAY_MODES: readonly McpAppDisplayMode[];
1156
- /** A file an app asks the host to save (`ui/download-file`), as checked by `appDownloadOf`. */
1157
- type AppDownload = {
1158
- kind: 'embedded';
1159
- /** The file name, sanitized (`appFileNameOf`): what it is saved as. */
1160
- name: string;
1161
- /** The type the app declared, if it is a MIME type at all. */
1162
- mimeType?: string;
1163
- bytes: Uint8Array;
1164
- } | {
1165
- /** A `resource_link`: read with `resources/read` on the app's own server, never fetched. */
1166
- kind: 'link';
1167
- uri: string;
1168
- name: string;
1169
- mimeType?: string;
1170
- };
1171
- /** What the host does for an app (the user is asked inside these, never by the bridge). */
1172
- interface McpAppBridgeHandlers {
1173
- /** A `tools/call`: resolves with the result the app is given; throws when refused. */
1174
- callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
1175
- /** A link (already checked): resolves true when it was opened, false when the user said no. */
1176
- openLink: (link: AppLink) => Promise<boolean>;
1177
- /** A message (already cleaned): resolves true when it was accepted, false when not. */
1178
- message: (text: string) => Promise<boolean>;
1179
- /** The app's wish for a height (the caller clamps it). */
1180
- resize: (height: number) => void;
1181
- /**
1182
- * `ui/request-display-mode` for a mode the host offers and the app declared (or `inline`):
1183
- * the mode the app is in afterwards - the host may say no and answer the current one.
1184
- * Without it, an app stays where it is.
1185
- */
1186
- displayMode?: (mode: McpAppDisplayMode) => McpAppDisplayMode | Promise<McpAppDisplayMode>;
1187
- /**
1188
- * `ui/download-file` (already checked): true once the file was saved, false when the user said
1189
- * no. Without it the method is not offered (`hostCapabilities.downloadFile` absent).
1190
- */
1191
- downloadFile?: (file: AppDownload) => Promise<boolean>;
1192
- /**
1193
- * `sampling/createMessage`: the result for the app; throws (an `McpAppRpcError`) when refused.
1194
- * Without it the method is not offered (`hostCapabilities.sampling` absent).
1195
- */
1196
- sample?: (params: Record<string, unknown>) => Promise<unknown>;
1197
- }
1198
- interface McpAppBridgeOptions {
1199
- /** Send a message to the app (the page posts it to the outer frame). */
1200
- post: (message: McpAppRpcMessage) => void;
1201
- handlers: McpAppBridgeHandlers;
1202
- hostInfo: {
1203
- name: string;
1204
- version: string;
1205
- };
1206
- hostCapabilities: Record<string, unknown>;
1207
- hostContext: Record<string, unknown>;
1208
- /** The tool call's arguments: sent once the app says it is initialized. */
1209
- toolInput: Record<string, unknown>;
1210
- /** Its result; `undefined` = the app is told the call was cancelled (`reason`). */
1211
- toolResult?: unknown;
1212
- cancelledReason?: string;
1213
- maxInFlight?: number;
1214
- }
1215
- /**
1216
- * One app's conversation with the host (the extension's JSON-RPC over `postMessage`). It never
1217
- * touches the DOM: `receive` is given what arrived - from the right frame, the caller checked
1218
- * `event.source` - and `post` sends. Requests outside the allow-list get "method not found";
1219
- * before `ui/initialize`, only `ping` is answered; parameters are checked before a handler sees
1220
- * them; at most `maxInFlight` requests run at once. The tool's input and result are sent once,
1221
- * after the app's `ui/notifications/initialized`, as the specification requires.
1222
- */
1223
- declare class McpAppBridge {
1224
- private readonly o;
1225
- private initializeSeen;
1226
- private delivered;
1227
- private inFlight;
1228
- private closed;
1229
- private seq;
1230
- private appModes;
1231
- constructor(options: McpAppBridgeOptions);
1232
- /** The app said it is ready, and was given the tool's input and result. */
1233
- get initialized(): boolean;
1234
- /** Stop answering: the frame is gone or was reloaded. */
1235
- close(): void;
1236
- /** Tell the app it is being torn down (not waited for: the frame goes anyway). */
1237
- teardown(reason: string): void;
1238
- /** The display modes the app declared at `ui/initialize` (undefined: none, or not yet). */
1239
- get appDisplayModes(): readonly McpAppDisplayMode[] | undefined;
1240
- /** How the app is shown now (`hostContext.displayMode`). */
1241
- get displayMode(): McpAppDisplayMode;
1242
- /** Tell an initialized app that part of the host context changed (the theme). */
1243
- updateContext(patch: Record<string, unknown>): void;
1244
- /** One message from the app's frame. */
1245
- receive(data: unknown): void;
1246
- private send;
1247
- private error;
1248
- private notification;
1249
- private request;
1250
- }
1251
- /**
1252
- * What this host tells an app it can do (`hostCapabilities` of `ui/initialize`): only what it
1253
- * does. `downloadFile` and `sampling` (never `sampling.tools`) only when the host turned them on.
1254
- */
1255
- declare const mcpAppHostCapabilities: (csp?: Partial<McpAppCsp>, features?: {
1256
- downloadFile?: boolean;
1257
- sampling?: boolean;
1258
- }) => Record<string, unknown>;
1259
- /**
1260
- * Whether a display mode an app asks for may be given: `inline` always (the way back needs no
1261
- * permission); any other only when the host offers it AND the app declared it in
1262
- * `appCapabilities.availableDisplayModes` - an app that declared nothing stays inline (the
1263
- * specification lets a host decline it).
1264
- */
1265
- declare const appDisplayModeAllowed: (o: {
1266
- requested: McpAppDisplayMode;
1267
- current: McpAppDisplayMode;
1268
- host: readonly McpAppDisplayMode[];
1269
- app: readonly McpAppDisplayMode[] | undefined;
1270
- }) => boolean;
1271
- /**
1272
- * Whether the user just acted INSIDE the app's frame: the page's frame element has the focus
1273
- * (a click or a key in a frame focuses it) and the page has transient user activation (an
1274
- * activation in a frame reaches every page above it, for a few seconds). Where the browser has
1275
- * no `navigator.userActivation`, the focus alone.
1276
- */
1277
- declare const appGestureOf: (o: {
1278
- focused: boolean;
1279
- activation: boolean | undefined;
1280
- }) => boolean;
1281
- /** A file an app asks to save: at most this many bytes. */
1282
- declare const MCP_APP_MAX_DOWNLOAD_BYTES: number;
1283
- /** A saved file's name: at most this many characters (the extension kept). */
1284
- declare const MCP_APP_MAX_FILE_NAME_CHARS = 100;
1285
- /**
1286
- * Extensions this host never saves: programs, scripts, installers, shortcuts, disk images - and
1287
- * documents a browser runs scripts in when they are opened (HTML, SVG, XML).
1288
- */
1289
- declare const MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS: readonly string[];
1290
- /** Types this host never saves (the same kinds), and any `…+xml`. */
1291
- declare const MCP_APP_REFUSED_DOWNLOAD_TYPES: readonly string[];
1292
- /** A declared type as a bare MIME type (`text/plain`), or undefined when it is not one. */
1293
- declare const appMimeTypeOf: (value: unknown) => string | undefined;
1294
- /**
1295
- * The name a file is saved under: the last segment of a path or URI (`file:///x/report.json` →
1296
- * `report.json`; percent-encoding decoded, and split again), without what cannot be seen or
1297
- * reserved characters (`<>:"/\|?*`, controls), no leading dots (a hidden file) or trailing dots
1298
- * and spaces, not a Windows device name, at most `MCP_APP_MAX_FILE_NAME_CHARS` with the extension
1299
- * kept; `download` when nothing is left.
1300
- */
1301
- declare const appFileNameOf: (value: unknown) => string;
1302
- /** The extension of a (sanitized) file name, lowercased, without the dot; '' when none. */
1303
- declare const appFileExtensionOf: (name: string) => string;
1304
- /**
1305
- * Why a file may not be saved, or undefined when it may: an extension or a type of the refused
1306
- * lists (a program, a script, a page a browser would run), checked on the sanitized name and
1307
- * the declared type both.
1308
- */
1309
- declare const appDownloadRefusal: (name: string, mimeType?: string) => string | undefined;
1310
- /**
1311
- * What `ui/download-file` asks for, checked - or why not (a message for the app): ONE item of
1312
- * `contents` (one file per request, one prompt); an `EmbeddedResource` (`resource.uri` names
1313
- * it, `text` as UTF-8 or base64 `blob`, at most `maxBytes`) or a `ResourceLink` (a one-line URI,
1314
- * read later from the app's own server: the name is its last segment, else its `name`); the
1315
- * name sanitized and the name and type not refused (`appDownloadRefusal`).
1316
- */
1317
- declare const appDownloadOf: (params: unknown, maxBytes?: number) => AppDownload | string;
1318
- /** A file ready to be put to the user: its name, type, bytes, and where the bytes came from. */
1319
- interface AppReadyDownload {
1320
- name: string;
1321
- mimeType?: string;
1322
- bytes: Uint8Array;
1323
- source: 'embedded' | 'link';
1324
- }
1325
- /** How a linked file is read: `resources/read` on the app's OWN server (the connection's). */
1326
- type AppResourceReader = (server: string, uri: string, options: {
1327
- signal?: AbortSignal;
1328
- maxBytes: number;
1329
- }) => Promise<{
1330
- mimeType?: string;
1331
- bytes: Uint8Array;
1332
- }>;
1333
- /**
1334
- * The bytes of a checked file: an embedded one as it came; a linked one read from `server` -
1335
- * the app's own - through `read` (never a fetch of its URI), at most `maxBytes`, and the type the
1336
- * SERVER gives it judged again (an app cannot pass a page off as a text file through a link).
1337
- * Throws an `McpAppRpcError` for the app: no reader, a failed read, a refused type, too large.
1338
- */
1339
- declare const resolveAppDownload: (file: AppDownload, server: string, read: AppResourceReader | undefined, signal?: AbortSignal, maxBytes?: number) => Promise<AppReadyDownload>;
1340
- /**
1341
- * The error an app is told when the agent did not answer its sampling request: the core's
1342
- * `AppSamplingError` carries its JSON-RPC code (`-1`: the user said no, `-32602`: not a request
1343
- * this host takes, `-32000`: too many); anything else is a refusal.
1344
- */
1345
- declare const appSamplingErrorOf: (err: unknown) => McpAppRpcError;
1346
- /** What `saveAppFile` uses of the page (passed in: this module touches no DOM by itself). */
1347
- interface AppFileSaverEnv {
1348
- document: {
1349
- createElement: (tag: 'a') => HTMLAnchorElement;
1350
- body: {
1351
- append: (n: Node) => void;
1352
- };
1353
- };
1354
- URL: {
1355
- createObjectURL: (blob: Blob) => string;
1356
- revokeObjectURL: (url: string) => void;
1357
- };
1358
- setTimeout: (fn: () => void, ms: number) => unknown;
1359
- }
1360
- /**
1361
- * Save a checked file the user agreed to: a `Blob` of type `application/octet-stream` (the
1362
- * browser never renders or sniffs it as a page), a `blob:` URL of THIS page, an `<a download>`
1363
- * made here and clicked once. No navigation, no `data:` or `javascript:` URL, nothing of the app
1364
- * in the page; the URL is revoked a minute later.
1365
- */
1366
- declare const saveAppFile: (file: {
1367
- name: string;
1368
- bytes: Uint8Array;
1369
- }, env: AppFileSaverEnv) => void;
1370
- /** `<AgentChat appSandbox>` / `useMcpAppHost({ sandbox })`. */
1371
- interface McpAppSandboxOptions {
1372
- /**
1373
- * The sandbox page's base URL on another origin you serve (`mcpAppSandboxResponse` of the
1374
- * `./mcp-app-sandbox` entry), e.g. `https://apps.example.com/sandbox/v1`; an app's frame loads
1375
- * `<url>/<policy>`. `{server}` in the host name gives each server an origin of its own
1376
- * (`https://{server}.apps.example.com/sandbox/v1`; the server's name must be a DNS label - it
1377
- * needs a wildcard certificate). `https://` only; `http://` on `localhost` / `127.0.0.1`.
1378
- */
1379
- url: string;
1380
- /** How long a frame waits for the page's handshake before it falls back (default 5000 ms). */
1381
- timeoutMs?: number;
1382
- }
1383
- /** Why an app runs in the opaque frame although a sandbox URL is set. */
1384
- type McpAppSandboxReason = 'invalid' | 'insecure' | 'same-origin' | 'no-page-origin' | 'server-name' | 'too-many-origins' | 'no-answer';
1385
- type McpAppSandboxTarget = {
1386
- ok: true;
1387
- origin: string;
1388
- base: string;
1389
- } | {
1390
- ok: false;
1391
- reason: McpAppSandboxReason;
1392
- };
1393
- /** The placeholder for the server's name in `McpAppSandboxOptions.url`. */
1394
- declare const MCP_APP_SANDBOX_SERVER = "{server}";
1395
- declare const MCP_APP_SANDBOX_TIMEOUT_MS = 5000;
1396
- /** After the shell has loaded (the proxy loaded or failed), the handshake gets this much longer. */
1397
- declare const MCP_APP_SANDBOX_GRACE_MS = 1000;
1398
- /**
1399
- * The sandbox flags of the shell's frame and of the proxy's: scripts and an origin - the shell
1400
- * must keep YOUR origin (else the proxy below it would get an opaque one) and runs no script; the
1401
- * proxy is on the sandbox origin. Nothing else: no navigation, popup, form, modal, download.
1402
- */
1403
- declare const MCP_APP_SANDBOX_FRAME_TOKENS = "allow-scripts allow-same-origin";
1404
- /**
1405
- * Where an app of `server` runs, for a page on `pageOrigin`: the sandbox's origin and base URL,
1406
- * or why not. Refused: not a URL; credentials, a query or a fragment; not `https://` (`http://`
1407
- * only on `localhost` / `127.0.0.1`); a path a policy cannot name; `{server}` anywhere but the
1408
- * host name, more than once, or a server name that is not a lowercase DNS label; a page without
1409
- * an origin; and the sandbox on the PAGE'S OWN origin - `allow-same-origin` there would hand the
1410
- * app your storage and the key vault.
1411
- */
1412
- declare const mcpAppSandboxTarget: (options: McpAppSandboxOptions | undefined, server: string, pageOrigin: string | undefined) => McpAppSandboxTarget;
1413
- /** The proxy page's URL for an app's declared origins (`<base>/<policy>`), or none if too long. */
1414
- declare const mcpAppSandboxProxyUrl: (base: string, csp?: Partial<McpAppCsp>) => string | undefined;
1415
- /**
1416
- * The policy of the shell: no script at all, and frames from the proxy's exact URL only - a
1417
- * `frame-src` with a path matches that path and nothing else (the query is not part of the
1418
- * match), so the proxy's frame can never be navigated anywhere else.
1419
- */
1420
- declare const mcpAppSandboxShellCsp: (proxyUrl: string) => string;
1421
- /**
1422
- * What goes into the OUTER frame's `srcdoc` in sandbox mode: the shell - its policy first, one
1423
- * frame of the proxy page, no script, nothing of the app. Give the outer `<iframe>`
1424
- * `sandbox={MCP_APP_SANDBOX_FRAME_TOKENS}` and nothing else. Throws on a URL that is not a proxy
1425
- * URL this package builds (`mcpAppSandboxProxyUrl`). `scheme` is declared by the shell and its
1426
- * frame, and handed to the proxy page as `?scheme=` on its frame's `src` ONLY: the shell's
1427
- * `frame-src` stays the path (a source expression carries no query, and a path source ignores
1428
- * one), so the pin is the same with or without it.
1429
- */
1430
- declare const buildMcpAppSandboxShell: (proxyUrl: string, scheme?: McpAppColorScheme) => string;
1431
- /** What one message from the proxy's frame is, for the page (`McpAppSandboxLink.receive`). */
1432
- type McpAppSandboxInput = 'drop' | 'ready' | 'broken' | 'app';
1433
- interface McpAppSandboxLinkOptions {
1434
- /** The sandbox origin (`mcpAppSandboxTarget(…).origin`). */
1435
- origin: string;
1436
- /** The app, as read from its server: sent once, on the proxy's first ready. */
1437
- html: string;
1438
- csp?: Partial<McpAppCsp>;
1439
- /** Post to the proxy's window. Always called with the sandbox origin as the target - never `*`. */
1440
- post: (message: unknown, targetOrigin: string) => void;
1441
- }
1442
- /**
1443
- * The page's side of the sandbox proxy, without the DOM: which messages are the proxy's, the
1444
- * handshake, and every post to the sandbox origin. A message is the proxy's only when it comes
1445
- * from the proxy's window (`event.source`) AND from the sandbox origin (`event.origin`). The
1446
- * first `sandbox-proxy-ready` is answered with the app (`sandbox-resource-ready`); another one
1447
- * means the proxy page was loaded again - by the app - and the link breaks (`'broken'`: stop the
1448
- * app). Every other `ui/notifications/sandbox-*` message is dropped; nothing reaches the bridge
1449
- * (`'app'`) before the app was handed over.
1450
- */
1451
- declare class McpAppSandboxLink {
1452
- private readonly o;
1453
- private state;
1454
- constructor(options: McpAppSandboxLinkOptions);
1455
- /** The proxy answered and was given the app. */
1456
- get ready(): boolean;
1457
- /** The proxy page was loaded a second time: the app must be stopped. */
1458
- get broken(): boolean;
1459
- /** Whether a message event is the proxy's: its window, and the sandbox origin. */
1460
- accepts(event: {
1461
- source: unknown;
1462
- origin: string;
1463
- }, proxy: unknown): boolean;
1464
- receive(event: {
1465
- source: unknown;
1466
- origin: string;
1467
- data: unknown;
1468
- }, proxy: unknown): McpAppSandboxInput;
1469
- /** Send a message to the app, through the proxy, to the sandbox origin. Nothing once broken. */
1470
- post(message: unknown): void;
1471
- close(): void;
1472
- }
1473
- /**
1474
- * A pending consent request of THIS frame (`ApprovalView.app.frame`, set by `useAgent`); for a
1475
- * request that names no frame (a host's own gate), one of this app's server and resource.
1476
- */
1477
- declare const isApprovalOfApp: (approval: ApprovalView, app: AppView) => boolean;
1478
-
1479
- export { APP_DEFAULT_HEIGHT as V, APP_HEIGHT_CEILING as X, APP_HEIGHT_SCREENS as Y, APP_MAX_HEIGHT as Z, APP_MIN_HEIGHT as _, MCP_APP_DISPLAY_MODES as a4, MCP_APP_MAX_ARGS_CHARS as a5, MCP_APP_MAX_DOWNLOAD_BYTES as a6, MCP_APP_MAX_FILE_NAME_CHARS as a7, MCP_APP_MAX_IN_FLIGHT as a8, MCP_APP_MAX_MESSAGE_CHARS as a9, appDownloadRefusal as aA, appFileExtensionOf as aB, appFileNameOf as aC, appGestureOf as aD, appHeightCap as aE, appLinkOf as aF, appMessageTextOf as aG, appMimeTypeOf as aH, appSamplingErrorOf as aI, buildMcpAppDocument as aJ, buildMcpAppSandboxShell as aK, clampAppHeight as aL, grantedAppCsp as aM, isApprovalOfApp as aN, mcpAppCsp as aO, mcpAppHostCapabilities as aP, mcpAppSandboxProxyUrl as aQ, mcpAppSandboxShellCsp as aR, mcpAppSandboxTarget as aS, nextAppHeightCap as aT, resolveAppDownload as aU, saveAppFile as aV, MCP_APP_MAX_URL_CHARS as aa, MCP_APP_NOTIFICATIONS as ab, MCP_APP_OPTIONAL_REQUESTS as ac, MCP_APP_PROTOCOL_VERSION as ad, MCP_APP_REFUSED as ae, MCP_APP_REFUSED_DOWNLOAD_EXTENSIONS as af, MCP_APP_REFUSED_DOWNLOAD_TYPES as ag, MCP_APP_RELAY as ah, MCP_APP_REQUESTS as ai, MCP_APP_SANDBOX_FRAME_TOKENS as aj, MCP_APP_SANDBOX_GRACE_MS as ak, MCP_APP_SANDBOX_SERVER as al, MCP_APP_SANDBOX_TIMEOUT_MS as am, McpAppBridge as an, McpAppRpcError as ar, McpAppSandboxLink as au, appDisplayModeAllowed as ay, appDownloadOf as az };
1480
- export type { AppDownload as $, AgentUiState as A, BrowserOAuthProvider as B, ChatAttachment as C, DecisionView as D, ElicitationView as E, FetchView as F, MediaView as G, ModelLoadState as H, QueuedMessageView as I, ReplanState as J, SkillConsentView as K, LessonView as L, McpElicitationFieldSchema as M, StepEscalationView as N, StepView as O, TranscriptView as P, QuestionView as Q, RemoteRunView as R, SubagentView as S, ToolCallView as T, UserNoteView as U, WrittenFileView as W, McpElicitationHandler as a, AppFileSaverEnv as a0, AppLink as a1, AppReadyDownload as a2, AppResourceReader as a3, McpAppBridgeHandlers as ao, McpAppBridgeOptions as ap, McpAppDisplayMode as aq, McpAppRpcMessage as as, McpAppSandboxInput as at, McpAppSandboxLinkOptions as av, McpAppSandboxOptions as aw, McpAppSandboxTarget as ax, McpElicitationRequest as b, McpElicitationResult as c, McpElicitationOptions as d, McpElicitationSchema as e, AgentStatus as f, McpAppSandboxReason as g, ChatMessage as h, ApprovalView as i, SubagentNode as j, AppView as k, BrowserOAuthProviderOptions as l, BudgetView as m, CompactionView as n, ConnectedMcp as o, McpAppsConnectionLike as p, McpCatalogEntry as q, McpHttpServerConfig as r, McpModule as s, McpOAuthCallback as t, McpOAuthRegistration as u, McpOAuthRegistrationKind as v, McpProtocolMode as w, McpServerInstructions as x, McpServerProtocol as y, McpServerResult as z };
994
+ export type { AgentUiState as A, BrowserOAuthProvider as B, ChatAttachment as C, DecisionView as D, ElicitationView as E, FetchView as F, ModelLoadState as G, QueuedMessageView as H, ReplanState as I, SkillConsentView as J, StepEscalationView as K, LessonView as L, McpElicitationFieldSchema as M, StepView as N, TranscriptView as O, QuestionView as Q, RemoteRunView as R, SubagentView as S, ToolCallView as T, UserNoteView as U, WrittenFileView as W, ChatMessage as a, ApprovalView as b, McpElicitationHandler as c, McpElicitationRequest as d, McpElicitationResult as e, McpElicitationOptions as f, McpElicitationSchema as g, AgentStatus as h, SubagentNode as i, AppView as j, BrowserOAuthProviderOptions as k, BudgetView as l, CompactionView as m, ConnectedMcp as n, McpAppsConnectionLike as o, McpCatalogEntry as p, McpHttpServerConfig as q, McpModule as r, McpOAuthCallback as s, McpOAuthRegistration as t, McpOAuthRegistrationKind as u, McpProtocolMode as v, McpServerInstructions as w, McpServerProtocol as x, McpServerResult as y, MediaView as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudko.dev/agent-web-ui",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "private": false,
5
5
  "description": "The framework-free UI logic of @dudko.dev/agent-web, the in-browser LLM agent: the headless reducer that turns the agent's events into UI state, every UI string, the composer's and transcript's pure helpers, voice, saved chats, the sandboxed-frame and MCP Apps security cores, the MCP Apps sandbox page for a server, and the pipeline editor's logic - plus the stylesheets. No React: build a front end for any framework on it.",
6
6
  "type": "module",
@@ -71,6 +71,16 @@
71
71
  "default": "./dist/markdown.cjs"
72
72
  }
73
73
  },
74
+ "./controller": {
75
+ "import": {
76
+ "types": "./dist/controller.d.ts",
77
+ "default": "./dist/controller.js"
78
+ },
79
+ "require": {
80
+ "types": "./dist/controller.d.cts",
81
+ "default": "./dist/controller.cjs"
82
+ }
83
+ },
74
84
  "./locales": {
75
85
  "import": {
76
86
  "types": "./dist/locales/index.d.ts",
@@ -172,8 +182,8 @@
172
182
  "prettier": "^3.10.1",
173
183
  "tsup": "^9.0.0",
174
184
  "typescript": "^6.0.3",
175
- "@dudko.dev/test-servers": "0.0.0",
176
- "@dudko.dev/agent-web": "0.0.53"
185
+ "@dudko.dev/agent-web": "0.0.54",
186
+ "@dudko.dev/test-servers": "0.0.0"
177
187
  },
178
188
  "scripts": {
179
189
  "build": "tsup",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/canvas/index.ts","../src/canvas/labels.ts","../src/canvas/geometry.ts"],"sourcesContent":["// The generic canvas's maths (pure functions) and its strings: nothing of agents, no React, no\n// import at all. The React canvas (`@dudko.dev/agent-web-react/pipeline`'s `Canvas`) draws with it;\n// another framework's canvas can too.\nexport { defaultCanvasLabels } from './labels.js'\nexport type { CanvasLabels } from './labels.js'\nexport {\n boundsOf,\n centerOn,\n clamp,\n curvePath,\n curvePoint,\n DEFAULT_MAX_ZOOM,\n DEFAULT_MIN_ZOOM,\n distanceToCurve,\n edgeCurve,\n fitViewport,\n hitEdge,\n hitNode,\n IDENTITY_VIEWPORT,\n inputAnchor,\n isRectVisible,\n outputAnchor,\n panBy,\n pinchViewport,\n readingOrder,\n rectContains,\n screenToWorld,\n snapPoint,\n snapTo,\n worldToScreen,\n zoomAt,\n} from './geometry.js'\nexport type {\n Curve,\n EdgeCurveOptions,\n FitOptions,\n Point,\n Rect,\n Size,\n Viewport,\n} from './geometry.js'\n","// The canvas's strings: what it shows and says to a screen reader. Generic - nothing of agents.\n\n/** Every string the canvas shows or says. */\nexport interface CanvasLabels {\n /** The canvas's own name for a screen reader. */\n canvas: string\n /** How to use it with a keyboard; read once, when the canvas is focused. */\n help: string\n /** `aria-roledescription` of a node. */\n node: string\n edge: (from: string, to: string, description?: string) => string\n port: (node: string, port?: string) => string\n connectsTo: (names: string) => string\n receivesFrom: (names: string) => string\n zoomIn: string\n zoomOut: string\n fit: string\n zoomLevel: (percent: number) => string\n /** Shown (and announced) while a connection is being made without dragging. */\n connectHint: (from: string) => string\n cancel: string\n connected: (from: string, to: string) => string\n}\n\nexport const defaultCanvasLabels: CanvasLabels = {\n canvas: 'Canvas',\n help: 'Tab moves between nodes and their connections. Arrow keys move the selected node, Enter opens it, Delete removes it, C starts a connection, Escape clears the selection. On the canvas itself the arrow keys pan, plus and minus zoom, 0 fits everything.',\n node: 'node',\n edge: (from, to, description) =>\n `Connection from ${from} to ${to}${description ? `: ${description}` : ''}`,\n port: (node, port) => `Connect ${node}${port ? ` (${port})` : ''} to another node`,\n connectsTo: (names) => `Connects to: ${names}.`,\n receivesFrom: (names) => `Receives from: ${names}.`,\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n fit: 'Fit to view',\n zoomLevel: (percent) => `${percent}%`,\n connectHint: (from) => `Pick the node to connect ${from} to`,\n cancel: 'Cancel',\n connected: (from, to) => `Connected ${from} to ${to}`,\n}\n","// The canvas's maths: viewport transforms, fitting, hit testing and the shape of an edge.\n// Pure functions over plain numbers - no DOM, no React - so they are unit-tested as they are.\n\nexport interface Point {\n x: number\n y: number\n}\n\nexport interface Size {\n width: number\n height: number\n}\n\nexport interface Rect extends Point, Size {}\n\n/**\n * Where the world sits on the screen: a world point `p` is drawn at\n * `p * zoom + (x, y)`, in pixels from the canvas's top-left corner.\n */\nexport interface Viewport {\n x: number\n y: number\n zoom: number\n}\n\n/** The four control points of a cubic Bezier curve. */\nexport interface Curve {\n p0: Point\n p1: Point\n p2: Point\n p3: Point\n}\n\nexport const DEFAULT_MIN_ZOOM = 0.25\nexport const DEFAULT_MAX_ZOOM = 2\nexport const IDENTITY_VIEWPORT: Viewport = { x: 0, y: 0, zoom: 1 }\n\nexport const clamp = (value: number, min: number, max: number): number =>\n Math.min(max, Math.max(min, value))\n\nexport const screenToWorld = (point: Point, viewport: Viewport): Point => ({\n x: (point.x - viewport.x) / viewport.zoom,\n y: (point.y - viewport.y) / viewport.zoom,\n})\n\nexport const worldToScreen = (point: Point, viewport: Viewport): Point => ({\n x: point.x * viewport.zoom + viewport.x,\n y: point.y * viewport.zoom + viewport.y,\n})\n\nexport const panBy = (viewport: Viewport, dx: number, dy: number): Viewport => ({\n ...viewport,\n x: viewport.x + dx,\n y: viewport.y + dy,\n})\n\n/** Set the zoom, keeping the world point under `anchor` (a screen point) where it is. */\nexport const zoomAt = (\n viewport: Viewport,\n zoom: number,\n anchor: Point,\n minZoom = DEFAULT_MIN_ZOOM,\n maxZoom = DEFAULT_MAX_ZOOM,\n): Viewport => {\n const next = clamp(zoom, minZoom, maxZoom)\n if (next === viewport.zoom) return viewport\n const world = screenToWorld(anchor, viewport)\n return { zoom: next, x: anchor.x - world.x * next, y: anchor.y - world.y * next }\n}\n\n/**\n * Two fingers moved from `before` to `after` (screen points): zoom by how far apart they went,\n * and keep the world point that was between them under the point that is between them now.\n */\nexport const pinchViewport = (\n viewport: Viewport,\n before: [Point, Point],\n after: [Point, Point],\n minZoom = DEFAULT_MIN_ZOOM,\n maxZoom = DEFAULT_MAX_ZOOM,\n): Viewport => {\n const distance = (a: Point, b: Point) => Math.hypot(a.x - b.x, a.y - b.y)\n const middle = (a: Point, b: Point): Point => ({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 })\n const was = distance(before[0], before[1])\n const is = distance(after[0], after[1])\n const zoom = clamp(was > 0 ? (viewport.zoom * is) / was : viewport.zoom, minZoom, maxZoom)\n const world = screenToWorld(middle(before[0], before[1]), viewport)\n const at = middle(after[0], after[1])\n return { zoom, x: at.x - world.x * zoom, y: at.y - world.y * zoom }\n}\n\n/** The smallest rectangle around all of `rects`; undefined when there are none. */\nexport const boundsOf = (rects: Rect[]): Rect | undefined => {\n if (rects.length === 0) return undefined\n let left = Infinity\n let top = Infinity\n let right = -Infinity\n let bottom = -Infinity\n for (const r of rects) {\n left = Math.min(left, r.x)\n top = Math.min(top, r.y)\n right = Math.max(right, r.x + r.width)\n bottom = Math.max(bottom, r.y + r.height)\n }\n return { x: left, y: top, width: right - left, height: bottom - top }\n}\n\nexport interface FitOptions {\n /** Free space kept around the content, in screen pixels (default 48). */\n padding?: number\n minZoom?: number\n /** Fitting never zooms in past this (default 1: a small graph is not blown up). */\n maxZoom?: number\n}\n\n// One axis of a fit: centred when the content fits, from its start (the padding kept) when it\n// does not - a graph too large for the canvas at the smallest zoom shows where it begins.\nconst fitAxis = (start: number, length: number, room: number, zoom: number, padding: number) =>\n length * zoom <= room - padding * 2 + 0.5\n ? (room - length * zoom) / 2 - start * zoom\n : padding - start * zoom\n\n/**\n * The viewport that shows all of `rects` centred in a canvas of `size`. When they do not fit at\n * `minZoom`, it shows them from their top-left corner at that zoom instead.\n */\nexport const fitViewport = (rects: Rect[], size: Size, options: FitOptions = {}): Viewport => {\n const bounds = boundsOf(rects)\n if (!bounds || size.width <= 0 || size.height <= 0) return IDENTITY_VIEWPORT\n const { minZoom = DEFAULT_MIN_ZOOM, maxZoom = 1 } = options\n // A narrow canvas cannot afford the padding a wide one has.\n const padding = Math.min(options.padding ?? 48, size.width / 8, size.height / 8)\n const zoom = clamp(\n Math.min(\n (size.width - padding * 2) / Math.max(bounds.width, 1),\n (size.height - padding * 2) / Math.max(bounds.height, 1),\n ),\n minZoom,\n maxZoom,\n )\n return {\n zoom,\n x: fitAxis(bounds.x, bounds.width, size.width, zoom, padding),\n y: fitAxis(bounds.y, bounds.height, size.height, zoom, padding),\n }\n}\n\n/** The viewport with `rect` in the middle of a canvas of `size`, at the zoom given. */\nexport const centerOn = (rect: Rect, size: Size, zoom: number): Viewport => ({\n zoom,\n x: size.width / 2 - (rect.x + rect.width / 2) * zoom,\n y: size.height / 2 - (rect.y + rect.height / 2) * zoom,\n})\n\n/** Is any part of `rect` (world) inside a canvas of `size` under `viewport`? */\nexport const isRectVisible = (rect: Rect, size: Size, viewport: Viewport): boolean => {\n const a = worldToScreen(rect, viewport)\n const b = worldToScreen({ x: rect.x + rect.width, y: rect.y + rect.height }, viewport)\n return b.x > 0 && b.y > 0 && a.x < size.width && a.y < size.height\n}\n\nexport const snapTo = (value: number, grid: number): number =>\n // `+ 0`: a rounded-away negative is 0, not -0.\n grid > 0 ? Math.round(value / grid) * grid + 0 : value\n\nexport const snapPoint = (point: Point, grid: number): Point => ({\n x: snapTo(point.x, grid),\n y: snapTo(point.y, grid),\n})\n\nexport const rectContains = (rect: Rect, point: Point): boolean =>\n point.x >= rect.x &&\n point.x <= rect.x + rect.width &&\n point.y >= rect.y &&\n point.y <= rect.y + rect.height\n\n/** The id of the node under `point` (world). Later nodes are drawn on top, so they win. */\nexport const hitNode = <T extends Rect & { id: string }>(\n nodes: T[],\n point: Point,\n): string | undefined => {\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (rectContains(nodes[i], point)) return nodes[i].id\n }\n return undefined\n}\n\n/** Where an edge enters a node: the middle of its left side. */\nexport const inputAnchor = (rect: Rect): Point => ({ x: rect.x, y: rect.y + rect.height / 2 })\n\n/** Where an edge leaves a node that has `count` output ports: spread down its right side. */\nexport const outputAnchor = (rect: Rect, index = 0, count = 1): Point => ({\n x: rect.x + rect.width,\n y: rect.y + (rect.height * (index + 1)) / (Math.max(count, 1) + 1),\n})\n\nexport interface EdgeCurveOptions {\n /**\n * How far an edge that runs backwards (its target is to the left of its source) swings below\n * the two nodes so that it does not cross them (default 90).\n */\n clearance?: number\n}\n\n/**\n * The curve of an edge that leaves `from` to the right and enters `to` from the left. A forward\n * edge is a plain S; a backward one (a loop) swings out and around.\n */\nexport const edgeCurve = (from: Point, to: Point, options: EdgeCurveOptions = {}): Curve => {\n const dx = to.x - from.x\n const dy = to.y - from.y\n if (dx >= 40) {\n const reach = Math.max(dx / 2, 40)\n return {\n p0: from,\n p1: { x: from.x + reach, y: from.y },\n p2: { x: to.x - reach, y: to.y },\n p3: to,\n }\n }\n const reach = clamp(60 + Math.abs(dx) / 4, 60, 220)\n const clearance = options.clearance ?? 90\n // Nearly level: go around below. Otherwise the height difference already keeps it clear.\n const swing = Math.abs(dy) < clearance ? clearance + Math.abs(dy) / 2 : 0\n return {\n p0: from,\n p1: { x: from.x + reach, y: from.y + swing },\n p2: { x: to.x - reach, y: to.y + swing },\n p3: to,\n }\n}\n\nconst round = (n: number): number => Math.round(n * 100) / 100\n\n/** The SVG path data of a curve. */\nexport const curvePath = ({ p0, p1, p2, p3 }: Curve): string =>\n `M ${round(p0.x)} ${round(p0.y)} C ${round(p1.x)} ${round(p1.y)}, ${round(p2.x)} ${round(p2.y)}, ${round(p3.x)} ${round(p3.y)}`\n\n/** The point of a curve at `t` in 0..1. */\nexport const curvePoint = ({ p0, p1, p2, p3 }: Curve, t: number): Point => {\n const u = 1 - t\n const a = u * u * u\n const b = 3 * u * u * t\n const c = 3 * u * t * t\n const d = t * t * t\n return {\n x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,\n y: a * p0.y + b * p1.y + c * p2.y + d * p3.y,\n }\n}\n\nconst distanceToSegment = (p: Point, a: Point, b: Point): number => {\n const dx = b.x - a.x\n const dy = b.y - a.y\n const length = dx * dx + dy * dy\n const t = length === 0 ? 0 : clamp(((p.x - a.x) * dx + (p.y - a.y) * dy) / length, 0, 1)\n return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy))\n}\n\n/** How far `point` is from a curve (the curve is walked in `samples` straight pieces). */\nexport const distanceToCurve = (curve: Curve, point: Point, samples = 24): number => {\n let best = Infinity\n let previous = curve.p0\n for (let i = 1; i <= samples; i++) {\n const next = curvePoint(curve, i / samples)\n best = Math.min(best, distanceToSegment(point, previous, next))\n previous = next\n }\n return best\n}\n\n/** The id of the edge within `tolerance` of `point`, the nearest one when several are. */\nexport const hitEdge = (\n edges: { id: string; curve: Curve }[],\n point: Point,\n tolerance = 8,\n): string | undefined => {\n let best: string | undefined\n let bestDistance = Infinity\n for (const edge of edges) {\n const distance = distanceToCurve(edge.curve, point)\n if (distance <= tolerance && distance < bestDistance) {\n best = edge.id\n bestDistance = distance\n }\n }\n return best\n}\n\n/**\n * The order a keyboard walks the nodes in: left to right, then top to bottom - the direction a\n * graph that flows from its entry to its end is read in. Nodes in the same column (within\n * `column` pixels) count as level.\n */\nexport const readingOrder = <T extends Point & { id: string }>(nodes: T[], column = 40): string[] =>\n nodes\n .map((node, index) => ({ node, index }))\n .sort((a, b) => {\n const ax = Math.round(a.node.x / column)\n const bx = Math.round(b.node.x / column)\n return ax - bx || a.node.y - b.node.y || a.index - b.index\n })\n .map(({ node }) => node.id)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwBO,IAAM,sBAAoC;AAAA,EAC/C,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM,CAAC,MAAM,IAAI,gBACf,mBAAmB,IAAI,OAAO,EAAE,GAAG,cAAc,KAAK,WAAW,KAAK,EAAE;AAAA,EAC1E,MAAM,CAAC,MAAM,SAAS,WAAW,IAAI,GAAG,OAAO,KAAK,IAAI,MAAM,EAAE;AAAA,EAChE,YAAY,CAAC,UAAU,gBAAgB,KAAK;AAAA,EAC5C,cAAc,CAAC,UAAU,kBAAkB,KAAK;AAAA,EAChD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,KAAK;AAAA,EACL,WAAW,CAAC,YAAY,GAAG,OAAO;AAAA,EAClC,aAAa,CAAC,SAAS,4BAA4B,IAAI;AAAA,EACvD,QAAQ;AAAA,EACR,WAAW,CAAC,MAAM,OAAO,aAAa,IAAI,OAAO,EAAE;AACrD;;;ACPO,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,oBAA8B,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,EAAE;AAE1D,IAAM,QAAQ,CAAC,OAAe,KAAa,QAChD,KAAK,IAAI,K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W,MAAM;AACrB,WAAS,IAAI,GAAG,KAAK,SAAS,KAAK;AACjC,UAAM,OAAO,WAAW,OAAO,IAAI,OAAO;AAC1C,WAAO,KAAK,IAAI,MAAM,kBAAkB,OAAO,UAAU,IAAI,CAAC;AAC9D,eAAW;AAAA,EACb;AACA,SAAO;AACT;AAGO,IAAM,UAAU,CACrB,OACA,OACA,YAAY,MACW;AACvB,MAAI;AACJ,MAAI,eAAe;AACnB,aAAW,QAAQ,OAAO;AACxB,UAAM,WAAW,gBAAgB,KAAK,OAAO,KAAK;AAClD,QAAI,YAAY,aAAa,WAAW,cAAc;AACpD,aAAO,KAAK;AACZ,qBAAe;AAAA,IACjB;AAAA,EACF;AACA,SAAO;AACT;AAOO,IAAM,eAAe,CAAmC,OAAY,SAAS,OAClF,MACG,IAAI,CAAC,MAAM,WAAW,EAAE,MAAM,MAAM,EAAE,EACtC,KAAK,CAAC,GAAG,MAAM;AACd,QAAM,KAAK,KAAK,MAAM,EAAE,KAAK,IAAI,MAAM;AACvC,QAAM,KAAK,KAAK,MAAM,EAAE,KAAK,IAAI,MAAM;AACvC,SAAO,KAAK,MAAM,EAAE,KAAK,IAAI,EAAE,KAAK,KAAK,EAAE,QAAQ,EAAE;AACvD,CAAC,EACA,IAAI,CAAC,EAAE,KAAK,MAAM,KAAK,EAAE;","names":["reach"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/canvas/geometry.ts"],"sourcesContent":["// The canvas's maths: viewport transforms, fitting, hit testing and the shape of an edge.\n// Pure functions over plain numbers - no DOM, no React - so they are unit-tested as they are.\n\nexport interface Point {\n x: number\n y: number\n}\n\nexport interface Size {\n width: number\n height: number\n}\n\nexport interface Rect extends Point, Size {}\n\n/**\n * Where the world sits on the screen: a world point `p` is drawn at\n * `p * zoom + (x, y)`, in pixels from the canvas's top-left corner.\n */\nexport interface Viewport {\n x: number\n y: number\n zoom: number\n}\n\n/** The four control points of a cubic Bezier curve. */\nexport interface Curve {\n p0: Point\n p1: Point\n p2: Point\n p3: Point\n}\n\nexport const DEFAULT_MIN_ZOOM = 0.25\nexport const DEFAULT_MAX_ZOOM = 2\nexport const IDENTITY_VIEWPORT: Viewport = { x: 0, y: 0, zoom: 1 }\n\nexport const clamp = (value: number, min: number, max: number): number =>\n Math.min(max, Math.max(min, value))\n\nexport const screenToWorld = (point: Point, viewport: Viewport): Point => ({\n x: (point.x - viewport.x) / viewport.zoom,\n y: (point.y - viewport.y) / viewport.zoom,\n})\n\nexport const worldToScreen = (point: Point, viewport: Viewport): Point => ({\n x: point.x * viewport.zoom + viewport.x,\n y: point.y * viewport.zoom + viewport.y,\n})\n\nexport const panBy = (viewport: Viewport, dx: number, dy: number): Viewport => ({\n ...viewport,\n x: viewport.x + dx,\n y: viewport.y + dy,\n})\n\n/** Set the zoom, keeping the world point under `anchor` (a screen point) where it is. */\nexport const zoomAt = (\n viewport: Viewport,\n zoom: number,\n anchor: Point,\n minZoom = DEFAULT_MIN_ZOOM,\n maxZoom = DEFAULT_MAX_ZOOM,\n): Viewport => {\n const next = clamp(zoom, minZoom, maxZoom)\n if (next === viewport.zoom) return viewport\n const world = screenToWorld(anchor, viewport)\n return { zoom: next, x: anchor.x - world.x * next, y: anchor.y - world.y * next }\n}\n\n/**\n * Two fingers moved from `before` to `after` (screen points): zoom by how far apart they went,\n * and keep the world point that was between them under the point that is between them now.\n */\nexport const pinchViewport = (\n viewport: Viewport,\n before: [Point, Point],\n after: [Point, Point],\n minZoom = DEFAULT_MIN_ZOOM,\n maxZoom = DEFAULT_MAX_ZOOM,\n): Viewport => {\n const distance = (a: Point, b: Point) => Math.hypot(a.x - b.x, a.y - b.y)\n const middle = (a: Point, b: Point): Point => ({ x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 })\n const was = distance(before[0], before[1])\n const is = distance(after[0], after[1])\n const zoom = clamp(was > 0 ? (viewport.zoom * is) / was : viewport.zoom, minZoom, maxZoom)\n const world = screenToWorld(middle(before[0], before[1]), viewport)\n const at = middle(after[0], after[1])\n return { zoom, x: at.x - world.x * zoom, y: at.y - world.y * zoom }\n}\n\n/** The smallest rectangle around all of `rects`; undefined when there are none. */\nexport const boundsOf = (rects: Rect[]): Rect | undefined => {\n if (rects.length === 0) return undefined\n let left = Infinity\n let top = Infinity\n let right = -Infinity\n let bottom = -Infinity\n for (const r of rects) {\n left = Math.min(left, r.x)\n top = Math.min(top, r.y)\n right = Math.max(right, r.x + r.width)\n bottom = Math.max(bottom, r.y + r.height)\n }\n return { x: left, y: top, width: right - left, height: bottom - top }\n}\n\nexport interface FitOptions {\n /** Free space kept around the content, in screen pixels (default 48). */\n padding?: number\n minZoom?: number\n /** Fitting never zooms in past this (default 1: a small graph is not blown up). */\n maxZoom?: number\n}\n\n// One axis of a fit: centred when the content fits, from its start (the padding kept) when it\n// does not - a graph too large for the canvas at the smallest zoom shows where it begins.\nconst fitAxis = (start: number, length: number, room: number, zoom: number, padding: number) =>\n length * zoom <= room - padding * 2 + 0.5\n ? (room - length * zoom) / 2 - start * zoom\n : padding - start * zoom\n\n/**\n * The viewport that shows all of `rects` centred in a canvas of `size`. When they do not fit at\n * `minZoom`, it shows them from their top-left corner at that zoom instead.\n */\nexport const fitViewport = (rects: Rect[], size: Size, options: FitOptions = {}): Viewport => {\n const bounds = boundsOf(rects)\n if (!bounds || size.width <= 0 || size.height <= 0) return IDENTITY_VIEWPORT\n const { minZoom = DEFAULT_MIN_ZOOM, maxZoom = 1 } = options\n // A narrow canvas cannot afford the padding a wide one has.\n const padding = Math.min(options.padding ?? 48, size.width / 8, size.height / 8)\n const zoom = clamp(\n Math.min(\n (size.width - padding * 2) / Math.max(bounds.width, 1),\n (size.height - padding * 2) / Math.max(bounds.height, 1),\n ),\n minZoom,\n maxZoom,\n )\n return {\n zoom,\n x: fitAxis(bounds.x, bounds.width, size.width, zoom, padding),\n y: fitAxis(bounds.y, bounds.height, size.height, zoom, padding),\n }\n}\n\n/** The viewport with `rect` in the middle of a canvas of `size`, at the zoom given. */\nexport const centerOn = (rect: Rect, size: Size, zoom: number): Viewport => ({\n zoom,\n x: size.width / 2 - (rect.x + rect.width / 2) * zoom,\n y: size.height / 2 - (rect.y + rect.height / 2) * zoom,\n})\n\n/** Is any part of `rect` (world) inside a canvas of `size` under `viewport`? */\nexport const isRectVisible = (rect: Rect, size: Size, viewport: Viewport): boolean => {\n const a = worldToScreen(rect, viewport)\n const b = worldToScreen({ x: rect.x + rect.width, y: rect.y + rect.height }, viewport)\n return b.x > 0 && b.y > 0 && a.x < size.width && a.y < size.height\n}\n\nexport const snapTo = (value: number, grid: number): number =>\n // `+ 0`: a rounded-away negative is 0, not -0.\n grid > 0 ? Math.round(value / grid) * grid + 0 : value\n\nexport const snapPoint = (point: Point, grid: number): Point => ({\n x: snapTo(point.x, grid),\n y: snapTo(point.y, grid),\n})\n\nexport const rectContains = (rect: Rect, point: Point): boolean =>\n point.x >= rect.x &&\n point.x <= rect.x + rect.width &&\n point.y >= rect.y &&\n point.y <= rect.y + rect.height\n\n/** The id of the node under `point` (world). Later nodes are drawn on top, so they win. */\nexport const hitNode = <T extends Rect & { id: string }>(\n nodes: T[],\n point: Point,\n): string | undefined => {\n for (let i = nodes.length - 1; i >= 0; i--) {\n if (rectContains(nodes[i], point)) return nodes[i].id\n }\n return undefined\n}\n\n/** Where an edge enters a node: the middle of its left side. */\nexport const inputAnchor = (rect: Rect): Point => ({ x: rect.x, y: rect.y + rect.height / 2 })\n\n/** Where an edge leaves a node that has `count` output ports: spread down its right side. */\nexport const outputAnchor = (rect: Rect, index = 0, count = 1): Point => ({\n x: rect.x + rect.width,\n y: rect.y + (rect.height * (index + 1)) / (Math.max(count, 1) + 1),\n})\n\nexport interface EdgeCurveOptions {\n /**\n * How far an edge that runs backwards (its target is to the left of its source) swings below\n * the two nodes so that it does not cross them (default 90).\n */\n clearance?: number\n}\n\n/**\n * The curve of an edge that leaves `from` to the right and enters `to` from the left. A forward\n * edge is a plain S; a backward one (a loop) swings out and around.\n */\nexport const edgeCurve = (from: Point, to: Point, options: EdgeCurveOptions = {}): Curve => {\n const dx = to.x - from.x\n const dy = to.y - from.y\n if (dx >= 40) {\n const reach = Math.max(dx / 2, 40)\n return {\n p0: from,\n p1: { x: from.x + reach, y: from.y },\n p2: { x: to.x - reach, y: to.y },\n p3: to,\n }\n }\n const reach = clamp(60 + Math.abs(dx) / 4, 60, 220)\n const clearance = options.clearance ?? 90\n // Nearly level: go around below. Otherwise the height difference already keeps it clear.\n const swing = Math.abs(dy) < clearance ? clearance + Math.abs(dy) / 2 : 0\n return {\n p0: from,\n p1: { x: from.x + reach, y: from.y + swing },\n p2: { x: to.x - reach, y: to.y + swing },\n p3: to,\n }\n}\n\nconst round = (n: number): number => Math.round(n * 100) / 100\n\n/** The SVG path data of a curve. */\nexport const curvePath = ({ p0, p1, p2, p3 }: Curve): string =>\n `M ${round(p0.x)} ${round(p0.y)} C ${round(p1.x)} ${round(p1.y)}, ${round(p2.x)} ${round(p2.y)}, ${round(p3.x)} ${round(p3.y)}`\n\n/** The point of a curve at `t` in 0..1. */\nexport const curvePoint = ({ p0, p1, p2, p3 }: Curve, t: number): Point => {\n const u = 1 - t\n const a = u * u * u\n const b = 3 * u * u * t\n const c = 3 * u * t * t\n const d = t * t * t\n return {\n x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,\n y: a * p0.y + b * p1.y + c * p2.y + d * p3.y,\n }\n}\n\nconst distanceToSegment = (p: Point, a: Point, b: Point): number => {\n const dx = b.x - a.x\n const dy = b.y - a.y\n const length = dx * dx + dy * dy\n const t = length === 0 ? 0 : clamp(((p.x - a.x) * dx + (p.y - a.y) * dy) / length, 0, 1)\n return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy))\n}\n\n/** How far `point` is from a curve (the curve is walked in `samples` straight pieces). */\nexport const distanceToCurve = (curve: Curve, point: Point, samples = 24): number => {\n let best = Infinity\n let previous = curve.p0\n for (let i = 1; i <= samples; i++) {\n const next = curvePoint(curve, i / samples)\n best = Math.min(best, distanceToSegment(point, previous, next))\n previous = next\n }\n return best\n}\n\n/** The id of the edge within `tolerance` of `point`, the nearest one when several are. */\nexport const hitEdge = (\n edges: { id: string; curve: Curve }[],\n point: Point,\n tolerance = 8,\n): string | undefined => {\n let best: string | undefined\n let bestDistance = Infinity\n for (const edge of edges) {\n const distance = distanceToCurve(edge.curve, point)\n if (distance <= tolerance && distance < bestDistance) {\n best = edge.id\n bestDistance = distance\n }\n }\n return best\n}\n\n/**\n * The order a keyboard walks the nodes in: left to right, then top to bottom - the direction a\n * graph that flows from its entry to its end is read in. Nodes in the same column (within\n * `column` pixels) count as level.\n */\nexport const readingOrder = <T extends Point & { id: string }>(nodes: T[], column = 40): string[] =>\n nodes\n .map((node, index) => ({ node, index }))\n .sort((a, b) => {\n const ax = Math.round(a.node.x / column)\n const bx = Math.round(b.node.x / column)\n return ax - bx || a.node.y - b.node.y || a.index - b.index\n })\n .map(({ node }) => node.id)\n"],"mappings":";;;;;AAiCO,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,oBAA8B,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,EAAE;AAE1D,IAAM,QAAQ,CAAC,OAAe,KAAa,QAChD,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAE7B,IAAM,gBAAgB,CAAC,OAAc,cAA+B;AAAA,EACzE,IAAI,MAAM,IAAI,SAAS,KAAK,SAAS;AAAA,EACrC,IAAI,MAAM,IAAI,SAAS,KAAK,SAAS;AACvC;AAEO,IAAM,gBAAgB,CAAC,OAAc,cAA+B;AAAA,EACzE,GAAG,MAAM,IAAI,SAAS,OAAO,SAAS;AAAA,EACtC,GAAG,MAAM,IAAI,SAAS,OAAO,SAAS;AACxC;AAEO,IAAM,QAAQ,CAAC,UAAoB,IAAY,QAA0B;AAAA,EAC9E,GAAG;AAAA,EACH,GAAG,SAAS,IAAI;AAAA,EAChB,GAAG,SAAS,IAAI;AAClB;AAGO,IAAM,SAAS,CACpB,UACA,MACA,QACA,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