@mountaya/elements 0.0.0-stage → 0.2.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 (828) hide show
  1. package/CHANGELOG.md +273 -0
  2. package/LICENCE.fr.txt +280 -0
  3. package/LICENSE.txt +262 -0
  4. package/README.md +1510 -2
  5. package/THIRD-PARTY-NOTICES.txt +103 -0
  6. package/dist/agent/index.cjs +1211 -0
  7. package/dist/agent/index.cjs.map +1 -0
  8. package/dist/agent/index.d.cts +1966 -0
  9. package/dist/agent/index.d.ts +1966 -0
  10. package/dist/agent/index.js +1181 -0
  11. package/dist/agent/index.js.map +1 -0
  12. package/dist/camera/index.cjs +2512 -0
  13. package/dist/camera/index.cjs.map +1 -0
  14. package/dist/camera/index.d.cts +1723 -0
  15. package/dist/camera/index.d.ts +1723 -0
  16. package/dist/camera/index.js +2443 -0
  17. package/dist/camera/index.js.map +1 -0
  18. package/dist/chunk-5pTPpv4v.d.cts +897 -0
  19. package/dist/chunk-5pTPpv4v.d.ts +897 -0
  20. package/dist/chunk-6JzFMFHh.d.ts +119 -0
  21. package/dist/chunk-6qyuJVvt.d.ts +513 -0
  22. package/dist/chunk-9fp0lDic.cjs +583 -0
  23. package/dist/chunk-9fp0lDic.cjs.map +1 -0
  24. package/dist/chunk-A48H1rDg.d.cts +73 -0
  25. package/dist/chunk-A48H1rDg.d.ts +73 -0
  26. package/dist/chunk-B-m1AchR.cjs +57 -0
  27. package/dist/chunk-B-m1AchR.cjs.map +1 -0
  28. package/dist/chunk-B-qFTf04.d.ts +216 -0
  29. package/dist/chunk-B0YROiZh.d.cts +1475 -0
  30. package/dist/chunk-B14wgOvH.d.cts +68 -0
  31. package/dist/chunk-B19l3j9r.cjs +150 -0
  32. package/dist/chunk-B19l3j9r.cjs.map +1 -0
  33. package/dist/chunk-B2PtjVKg.cjs +86 -0
  34. package/dist/chunk-B2PtjVKg.cjs.map +1 -0
  35. package/dist/chunk-B56Oyb7W.cjs +70 -0
  36. package/dist/chunk-B56Oyb7W.cjs.map +1 -0
  37. package/dist/chunk-B5WGMQwK.cjs +113 -0
  38. package/dist/chunk-B5WGMQwK.cjs.map +1 -0
  39. package/dist/chunk-B98mKrdu.d.cts +302 -0
  40. package/dist/chunk-BB0PmqIM.d.cts +44 -0
  41. package/dist/chunk-BBikve0Z.cjs +269 -0
  42. package/dist/chunk-BBikve0Z.cjs.map +1 -0
  43. package/dist/chunk-BHeXmM0X.js +37 -0
  44. package/dist/chunk-BHeXmM0X.js.map +1 -0
  45. package/dist/chunk-BI8WZLpU.cjs +281 -0
  46. package/dist/chunk-BI8WZLpU.cjs.map +1 -0
  47. package/dist/chunk-BIEc_SkR.cjs +29 -0
  48. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  49. package/dist/chunk-BJ6L6_W9.cjs +553 -0
  50. package/dist/chunk-BJ6L6_W9.cjs.map +1 -0
  51. package/dist/chunk-BJ91UCbB.js +11 -0
  52. package/dist/chunk-BJ91UCbB.js.map +1 -0
  53. package/dist/chunk-BJEZWTKj.cjs +166 -0
  54. package/dist/chunk-BJEZWTKj.cjs.map +1 -0
  55. package/dist/chunk-BJz54mfg.cjs +10 -0
  56. package/dist/chunk-BJz54mfg.cjs.map +1 -0
  57. package/dist/chunk-BNX5LAfN.d.cts +912 -0
  58. package/dist/chunk-BP6KgA86.js +35 -0
  59. package/dist/chunk-BP6KgA86.js.map +1 -0
  60. package/dist/chunk-BRnjQq6K.d.cts +157 -0
  61. package/dist/chunk-BSiMEwPS.js +46 -0
  62. package/dist/chunk-BSiMEwPS.js.map +1 -0
  63. package/dist/chunk-BTPjDw_y.cjs +16 -0
  64. package/dist/chunk-BTPjDw_y.cjs.map +1 -0
  65. package/dist/chunk-BTUUABGI.js +17 -0
  66. package/dist/chunk-BTUUABGI.js.map +1 -0
  67. package/dist/chunk-BUeL9y7s.cjs +45 -0
  68. package/dist/chunk-BUeL9y7s.cjs.map +1 -0
  69. package/dist/chunk-BWMuCNc9.cjs +172 -0
  70. package/dist/chunk-BWMuCNc9.cjs.map +1 -0
  71. package/dist/chunk-BWjRfhpF.js +126 -0
  72. package/dist/chunk-BWjRfhpF.js.map +1 -0
  73. package/dist/chunk-BZ5KyZXI.d.ts +302 -0
  74. package/dist/chunk-B_4SVmvh.js +94 -0
  75. package/dist/chunk-B_4SVmvh.js.map +1 -0
  76. package/dist/chunk-BcTUuZQ3.js +95 -0
  77. package/dist/chunk-BcTUuZQ3.js.map +1 -0
  78. package/dist/chunk-BdkqSsJe.cjs +140 -0
  79. package/dist/chunk-BdkqSsJe.cjs.map +1 -0
  80. package/dist/chunk-BfktMVmI.js +70 -0
  81. package/dist/chunk-BfktMVmI.js.map +1 -0
  82. package/dist/chunk-BfzQb0EK.cjs +6 -0
  83. package/dist/chunk-BhWfT-22.d.cts +808 -0
  84. package/dist/chunk-BjJcqX5J.cjs +60 -0
  85. package/dist/chunk-BjJcqX5J.cjs.map +1 -0
  86. package/dist/chunk-Bk0L8g5J.d.cts +77 -0
  87. package/dist/chunk-Bk0L8g5J.d.ts +77 -0
  88. package/dist/chunk-Bl4_uVa6.cjs +11 -0
  89. package/dist/chunk-Bl4_uVa6.cjs.map +1 -0
  90. package/dist/chunk-BlKF4lrp.js +43 -0
  91. package/dist/chunk-BlKF4lrp.js.map +1 -0
  92. package/dist/chunk-Bm1FieGR.js +4 -0
  93. package/dist/chunk-Bm1FieGR.js.map +1 -0
  94. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  95. package/dist/chunk-BpN3hr6a.cjs +541 -0
  96. package/dist/chunk-BpN3hr6a.cjs.map +1 -0
  97. package/dist/chunk-Bq_WHTfd.d.cts +119 -0
  98. package/dist/chunk-Bqt4LBBz.cjs +648 -0
  99. package/dist/chunk-Bqt4LBBz.cjs.map +1 -0
  100. package/dist/chunk-Bqt97zwf.d.cts +54 -0
  101. package/dist/chunk-Bqt97zwf.d.ts +54 -0
  102. package/dist/chunk-BsBiN4w6.d.cts +245 -0
  103. package/dist/chunk-BvTpOUoC.cjs +207 -0
  104. package/dist/chunk-BvTpOUoC.cjs.map +1 -0
  105. package/dist/chunk-BwK6Hl3q.cjs +446 -0
  106. package/dist/chunk-BwK6Hl3q.cjs.map +1 -0
  107. package/dist/chunk-BxDQZDXR.d.cts +76 -0
  108. package/dist/chunk-BxDQZDXR.d.ts +76 -0
  109. package/dist/chunk-BxUio8kX.js +20 -0
  110. package/dist/chunk-BxUio8kX.js.map +1 -0
  111. package/dist/chunk-BxaocpFi.d.cts +1 -0
  112. package/dist/chunk-Bywi0K1N.js +36 -0
  113. package/dist/chunk-Bywi0K1N.js.map +1 -0
  114. package/dist/chunk-C-IlmkDl.js +59 -0
  115. package/dist/chunk-C-IlmkDl.js.map +1 -0
  116. package/dist/chunk-C5PtVewq.d.ts +389 -0
  117. package/dist/chunk-C5dpC7mQ.js +19 -0
  118. package/dist/chunk-C5dpC7mQ.js.map +1 -0
  119. package/dist/chunk-C5q1sgSa.js +46 -0
  120. package/dist/chunk-C5q1sgSa.js.map +1 -0
  121. package/dist/chunk-C6fU9G5I.cjs +221 -0
  122. package/dist/chunk-C6fU9G5I.cjs.map +1 -0
  123. package/dist/chunk-C71dpWUK.js +5 -0
  124. package/dist/chunk-C71dpWUK.js.map +1 -0
  125. package/dist/chunk-C82N1gQX.d.ts +1831 -0
  126. package/dist/chunk-C8HdaHpu.js +118 -0
  127. package/dist/chunk-C8HdaHpu.js.map +1 -0
  128. package/dist/chunk-C8ZGryck.js +236 -0
  129. package/dist/chunk-C8ZGryck.js.map +1 -0
  130. package/dist/chunk-C95NG0oD.cjs +43 -0
  131. package/dist/chunk-C95NG0oD.cjs.map +1 -0
  132. package/dist/chunk-C9aR8DXb.js +9 -0
  133. package/dist/chunk-C9aR8DXb.js.map +1 -0
  134. package/dist/chunk-CAUZnoCs.d.ts +525 -0
  135. package/dist/chunk-CBXWWuM9.cjs +82 -0
  136. package/dist/chunk-CBXWWuM9.cjs.map +1 -0
  137. package/dist/chunk-CC_Kquu7.d.cts +125 -0
  138. package/dist/chunk-CC_Kquu7.d.ts +125 -0
  139. package/dist/chunk-CCp85vXg.cjs +60 -0
  140. package/dist/chunk-CCp85vXg.cjs.map +1 -0
  141. package/dist/chunk-CEcB1_uK.js +39 -0
  142. package/dist/chunk-CEcB1_uK.js.map +1 -0
  143. package/dist/chunk-CFIo021l.d.cts +216 -0
  144. package/dist/chunk-CH_IZoJE.js +33 -0
  145. package/dist/chunk-CH_IZoJE.js.map +1 -0
  146. package/dist/chunk-CHrasH_g.cjs +25 -0
  147. package/dist/chunk-CHrasH_g.cjs.map +1 -0
  148. package/dist/chunk-CJVoSaAE.cjs +3 -0
  149. package/dist/chunk-CJp8nGcb.js +96 -0
  150. package/dist/chunk-CJp8nGcb.js.map +1 -0
  151. package/dist/chunk-CJwUtkOt.js +112 -0
  152. package/dist/chunk-CJwUtkOt.js.map +1 -0
  153. package/dist/chunk-CKhCOVIf.d.cts +751 -0
  154. package/dist/chunk-CKiVSRYg.js +50 -0
  155. package/dist/chunk-CKiVSRYg.js.map +1 -0
  156. package/dist/chunk-CKtd19eD.cjs +59 -0
  157. package/dist/chunk-CKtd19eD.cjs.map +1 -0
  158. package/dist/chunk-CL92KE3j.d.ts +3188 -0
  159. package/dist/chunk-CLqUlkAe.js +54 -0
  160. package/dist/chunk-CLqUlkAe.js.map +1 -0
  161. package/dist/chunk-CMG5OV0q.cjs +4741 -0
  162. package/dist/chunk-CMG5OV0q.cjs.map +1 -0
  163. package/dist/chunk-CN_TKSgm.js +10 -0
  164. package/dist/chunk-CN_TKSgm.js.map +1 -0
  165. package/dist/chunk-CNe6MtqV.cjs +29 -0
  166. package/dist/chunk-CNe6MtqV.cjs.map +1 -0
  167. package/dist/chunk-COQkDTC5.js +83 -0
  168. package/dist/chunk-COQkDTC5.js.map +1 -0
  169. package/dist/chunk-CPBl6K4M.cjs +168 -0
  170. package/dist/chunk-CPBl6K4M.cjs.map +1 -0
  171. package/dist/chunk-CPx0ZYFB.d.ts +3 -0
  172. package/dist/chunk-CQQhcP_C.d.ts +197 -0
  173. package/dist/chunk-CTNoajFh.d.cts +389 -0
  174. package/dist/chunk-CTd-qgJc.cjs +384 -0
  175. package/dist/chunk-CTd-qgJc.cjs.map +1 -0
  176. package/dist/chunk-CW80YYtU.cjs +1056 -0
  177. package/dist/chunk-CW80YYtU.cjs.map +1 -0
  178. package/dist/chunk-CWpqBgkF.d.cts +24 -0
  179. package/dist/chunk-CWpqBgkF.d.ts +24 -0
  180. package/dist/chunk-CXjRArgy.d.ts +3 -0
  181. package/dist/chunk-CXonfH3-.cjs +14 -0
  182. package/dist/chunk-CXonfH3-.cjs.map +1 -0
  183. package/dist/chunk-CYcouGXN.d.ts +825 -0
  184. package/dist/chunk-CZDAzEBw.cjs +1621 -0
  185. package/dist/chunk-CZDAzEBw.cjs.map +1 -0
  186. package/dist/chunk-C_fQFr70.d.cts +159 -0
  187. package/dist/chunk-C_fQFr70.d.ts +159 -0
  188. package/dist/chunk-CbOtHnnB.cjs +359 -0
  189. package/dist/chunk-CbOtHnnB.cjs.map +1 -0
  190. package/dist/chunk-CdA6ZMGk.d.cts +825 -0
  191. package/dist/chunk-Ce1_thm7.js +146 -0
  192. package/dist/chunk-Ce1_thm7.js.map +1 -0
  193. package/dist/chunk-CeD8Hw0j.d.cts +3188 -0
  194. package/dist/chunk-CeiTuMyt.d.cts +525 -0
  195. package/dist/chunk-Ch1OLzLi.js +1 -0
  196. package/dist/chunk-Cizu_j1N.cjs +87 -0
  197. package/dist/chunk-Cizu_j1N.cjs.map +1 -0
  198. package/dist/chunk-CjDe9z6A.d.cts +427 -0
  199. package/dist/chunk-Cl1etdlu.js +63 -0
  200. package/dist/chunk-Cl1etdlu.js.map +1 -0
  201. package/dist/chunk-CmoVJDoz.js +4 -0
  202. package/dist/chunk-CmoVJDoz.js.map +1 -0
  203. package/dist/chunk-CnLucxjG.cjs +197 -0
  204. package/dist/chunk-CnLucxjG.cjs.map +1 -0
  205. package/dist/chunk-CsWjBmdi.cjs +56 -0
  206. package/dist/chunk-CsWjBmdi.cjs.map +1 -0
  207. package/dist/chunk-CuseO5MZ.d.cts +3 -0
  208. package/dist/chunk-CvMHibbA.d.ts +427 -0
  209. package/dist/chunk-CwDeiN5U.js +870 -0
  210. package/dist/chunk-CwDeiN5U.js.map +1 -0
  211. package/dist/chunk-Cwdmx4tG.js +1 -0
  212. package/dist/chunk-D-4MxHTt.d.cts +105 -0
  213. package/dist/chunk-D-4MxHTt.d.ts +105 -0
  214. package/dist/chunk-D0LF-99V.js +1093 -0
  215. package/dist/chunk-D0LF-99V.js.map +1 -0
  216. package/dist/chunk-D1fe-0c_.js +367 -0
  217. package/dist/chunk-D1fe-0c_.js.map +1 -0
  218. package/dist/chunk-D21fEI6A.d.ts +1926 -0
  219. package/dist/chunk-D39gAxya.cjs +89 -0
  220. package/dist/chunk-D39gAxya.cjs.map +1 -0
  221. package/dist/chunk-D6KdIW5e.cjs +228 -0
  222. package/dist/chunk-D6KdIW5e.cjs.map +1 -0
  223. package/dist/chunk-D6qHYbgW.d.cts +36 -0
  224. package/dist/chunk-D89E-w70.d.ts +44 -0
  225. package/dist/chunk-D8bdTysL.js +552 -0
  226. package/dist/chunk-D8bdTysL.js.map +1 -0
  227. package/dist/chunk-D96QJT24.cjs +109 -0
  228. package/dist/chunk-D96QJT24.cjs.map +1 -0
  229. package/dist/chunk-DAmkQl-i.js +119 -0
  230. package/dist/chunk-DAmkQl-i.js.map +1 -0
  231. package/dist/chunk-DEfsb2lc.cjs +10 -0
  232. package/dist/chunk-DEfsb2lc.cjs.map +1 -0
  233. package/dist/chunk-DIFjT5-V.d.cts +66 -0
  234. package/dist/chunk-DJpUw8TN.d.ts +912 -0
  235. package/dist/chunk-DK6lm2IZ.cjs +11 -0
  236. package/dist/chunk-DK6lm2IZ.cjs.map +1 -0
  237. package/dist/chunk-DKqgr31j.cjs +61 -0
  238. package/dist/chunk-DKqgr31j.cjs.map +1 -0
  239. package/dist/chunk-DLZ0QYm9.js +37 -0
  240. package/dist/chunk-DLZ0QYm9.js.map +1 -0
  241. package/dist/chunk-DLjS0uaC.js +4 -0
  242. package/dist/chunk-DLjS0uaC.js.map +1 -0
  243. package/dist/chunk-DMokwmOV.cjs +49 -0
  244. package/dist/chunk-DMokwmOV.cjs.map +1 -0
  245. package/dist/chunk-DMvWgBZL.d.cts +1831 -0
  246. package/dist/chunk-DNfGfIF3.js +31 -0
  247. package/dist/chunk-DNfGfIF3.js.map +1 -0
  248. package/dist/chunk-DQbSRe8D.d.ts +245 -0
  249. package/dist/chunk-DSGkP8_y.js +45 -0
  250. package/dist/chunk-DSGkP8_y.js.map +1 -0
  251. package/dist/chunk-DTctvfSd.d.cts +197 -0
  252. package/dist/chunk-DWe7igyw.cjs +206 -0
  253. package/dist/chunk-DWe7igyw.cjs.map +1 -0
  254. package/dist/chunk-DWsMP5JR.d.ts +68 -0
  255. package/dist/chunk-DWsm3HIW.d.cts +120 -0
  256. package/dist/chunk-DWsm3HIW.d.ts +120 -0
  257. package/dist/chunk-DXABHjLa.cjs +3 -0
  258. package/dist/chunk-D_BeqSbc.cjs +42 -0
  259. package/dist/chunk-D_BeqSbc.cjs.map +1 -0
  260. package/dist/chunk-D_svQNdW.d.ts +66 -0
  261. package/dist/chunk-Dav4xWrp.js +330 -0
  262. package/dist/chunk-Dav4xWrp.js.map +1 -0
  263. package/dist/chunk-DbCPhepL.js +293 -0
  264. package/dist/chunk-DbCPhepL.js.map +1 -0
  265. package/dist/chunk-DcrTy-y2.cjs +43 -0
  266. package/dist/chunk-DcrTy-y2.cjs.map +1 -0
  267. package/dist/chunk-Ddv484ld.js +487 -0
  268. package/dist/chunk-Ddv484ld.js.map +1 -0
  269. package/dist/chunk-De0bjnhY.cjs +88 -0
  270. package/dist/chunk-De0bjnhY.cjs.map +1 -0
  271. package/dist/chunk-De2FmNPu.cjs +32 -0
  272. package/dist/chunk-De2FmNPu.cjs.map +1 -0
  273. package/dist/chunk-DeSjQXiI.d.ts +157 -0
  274. package/dist/chunk-Den0Ta6C.js +132 -0
  275. package/dist/chunk-Den0Ta6C.js.map +1 -0
  276. package/dist/chunk-DiDKEeEa.js +8 -0
  277. package/dist/chunk-DiDKEeEa.js.map +1 -0
  278. package/dist/chunk-Dj60k5PU.js +197 -0
  279. package/dist/chunk-Dj60k5PU.js.map +1 -0
  280. package/dist/chunk-DjnYQBCN.js +4705 -0
  281. package/dist/chunk-DjnYQBCN.js.map +1 -0
  282. package/dist/chunk-Dk9VKvyq.d.ts +1 -0
  283. package/dist/chunk-Dor1ERI9.cjs +85 -0
  284. package/dist/chunk-Dor1ERI9.cjs.map +1 -0
  285. package/dist/chunk-DpMouOoH.js +451 -0
  286. package/dist/chunk-DpMouOoH.js.map +1 -0
  287. package/dist/chunk-DposgdNL.cjs +52 -0
  288. package/dist/chunk-DposgdNL.cjs.map +1 -0
  289. package/dist/chunk-DqLTG_5Q.d.cts +3 -0
  290. package/dist/chunk-Dr5MCIpS.d.cts +63 -0
  291. package/dist/chunk-Dr5MCIpS.d.ts +63 -0
  292. package/dist/chunk-DrudttCC.cjs +4 -0
  293. package/dist/chunk-DsDYVJQC.js +173 -0
  294. package/dist/chunk-DsDYVJQC.js.map +1 -0
  295. package/dist/chunk-Dw8ur6FJ.js +27 -0
  296. package/dist/chunk-Dw8ur6FJ.js.map +1 -0
  297. package/dist/chunk-DwG6M_0v.js +64 -0
  298. package/dist/chunk-DwG6M_0v.js.map +1 -0
  299. package/dist/chunk-Dy9a5ibO.js +284 -0
  300. package/dist/chunk-Dy9a5ibO.js.map +1 -0
  301. package/dist/chunk-DyayZlQJ.js +157 -0
  302. package/dist/chunk-DyayZlQJ.js.map +1 -0
  303. package/dist/chunk-DyhJZC2i.js +126 -0
  304. package/dist/chunk-DyhJZC2i.js.map +1 -0
  305. package/dist/chunk-F9zBzmmG.cjs +45 -0
  306. package/dist/chunk-F9zBzmmG.cjs.map +1 -0
  307. package/dist/chunk-FyCYofv2.js +116 -0
  308. package/dist/chunk-FyCYofv2.js.map +1 -0
  309. package/dist/chunk-GHJRjAk2.js +1 -0
  310. package/dist/chunk-H14isiSf.d.ts +751 -0
  311. package/dist/chunk-HIJzXoN4.js +7 -0
  312. package/dist/chunk-HIJzXoN4.js.map +1 -0
  313. package/dist/chunk-Id_8kRtu.d.ts +36 -0
  314. package/dist/chunk-KN60yxBQ.js +5 -0
  315. package/dist/chunk-KN60yxBQ.js.map +1 -0
  316. package/dist/chunk-NM5yg6bh.cjs +82 -0
  317. package/dist/chunk-NM5yg6bh.cjs.map +1 -0
  318. package/dist/chunk-OXr3zJfM.cjs +119 -0
  319. package/dist/chunk-OXr3zJfM.cjs.map +1 -0
  320. package/dist/chunk-QGqgNC4z.d.ts +928 -0
  321. package/dist/chunk-QJBtJrZ0.js +36 -0
  322. package/dist/chunk-QJBtJrZ0.js.map +1 -0
  323. package/dist/chunk-QKWhxfPv.d.cts +361 -0
  324. package/dist/chunk-QKWhxfPv.d.ts +361 -0
  325. package/dist/chunk-QXW7b4Ev.d.cts +410 -0
  326. package/dist/chunk-RHZrxUrM.cjs +39 -0
  327. package/dist/chunk-RHZrxUrM.cjs.map +1 -0
  328. package/dist/chunk-RTxe2i66.js +91 -0
  329. package/dist/chunk-RTxe2i66.js.map +1 -0
  330. package/dist/chunk-RrKkJb6P.js +16 -0
  331. package/dist/chunk-RrKkJb6P.js.map +1 -0
  332. package/dist/chunk-VOJqpcnM.cjs +181 -0
  333. package/dist/chunk-VOJqpcnM.cjs.map +1 -0
  334. package/dist/chunk-VljGTrid.js +1 -0
  335. package/dist/chunk-X3UVwUEK.d.cts +513 -0
  336. package/dist/chunk-X9K2WChn.cjs +28 -0
  337. package/dist/chunk-X9K2WChn.cjs.map +1 -0
  338. package/dist/chunk-YrtOx6oy.js +251 -0
  339. package/dist/chunk-YrtOx6oy.js.map +1 -0
  340. package/dist/chunk-bY7ySujI.d.cts +928 -0
  341. package/dist/chunk-bYf1sBz5.d.cts +11 -0
  342. package/dist/chunk-bYf1sBz5.d.ts +11 -0
  343. package/dist/chunk-blfknWoM.d.cts +1926 -0
  344. package/dist/chunk-blqsohAb.js +113 -0
  345. package/dist/chunk-blqsohAb.js.map +1 -0
  346. package/dist/chunk-cDMCjodI.cjs +58 -0
  347. package/dist/chunk-cDMCjodI.cjs.map +1 -0
  348. package/dist/chunk-cWjE3qd6.cjs +10 -0
  349. package/dist/chunk-cWjE3qd6.cjs.map +1 -0
  350. package/dist/chunk-dfOgV3fu.js +26 -0
  351. package/dist/chunk-dfOgV3fu.js.map +1 -0
  352. package/dist/chunk-f9cTwUX1.cjs +125 -0
  353. package/dist/chunk-f9cTwUX1.cjs.map +1 -0
  354. package/dist/chunk-fHVYEZs4.cjs +28 -0
  355. package/dist/chunk-fHVYEZs4.cjs.map +1 -0
  356. package/dist/chunk-fWRUMgRI.js +22 -0
  357. package/dist/chunk-fWRUMgRI.js.map +1 -0
  358. package/dist/chunk-fozLXfHY.d.cts +55 -0
  359. package/dist/chunk-fozLXfHY.d.ts +55 -0
  360. package/dist/chunk-gWmB1l3A.cjs +3122 -0
  361. package/dist/chunk-gWmB1l3A.cjs.map +1 -0
  362. package/dist/chunk-gbj2R-_w.js +58 -0
  363. package/dist/chunk-gbj2R-_w.js.map +1 -0
  364. package/dist/chunk-iIWxsAXd.js +59 -0
  365. package/dist/chunk-iIWxsAXd.js.map +1 -0
  366. package/dist/chunk-lItIuOIS.cjs +137 -0
  367. package/dist/chunk-lItIuOIS.cjs.map +1 -0
  368. package/dist/chunk-m6Rh4PCe.cjs +798 -0
  369. package/dist/chunk-m6Rh4PCe.cjs.map +1 -0
  370. package/dist/chunk-o3IRANDf.cjs +99 -0
  371. package/dist/chunk-o3IRANDf.cjs.map +1 -0
  372. package/dist/chunk-obUcg3Sk.d.ts +808 -0
  373. package/dist/chunk-ohsf-6Rn.js +600 -0
  374. package/dist/chunk-ohsf-6Rn.js.map +1 -0
  375. package/dist/chunk-pBleU6Nv.js +3061 -0
  376. package/dist/chunk-pBleU6Nv.js.map +1 -0
  377. package/dist/chunk-px4e99cy.js +71 -0
  378. package/dist/chunk-px4e99cy.js.map +1 -0
  379. package/dist/chunk-qwYDLeXc.cjs +99 -0
  380. package/dist/chunk-qwYDLeXc.cjs.map +1 -0
  381. package/dist/chunk-rF_859Qk.cjs +101 -0
  382. package/dist/chunk-rF_859Qk.cjs.map +1 -0
  383. package/dist/chunk-rLJkqJ5j.d.ts +1475 -0
  384. package/dist/chunk-twQItIRg.cjs +338 -0
  385. package/dist/chunk-twQItIRg.cjs.map +1 -0
  386. package/dist/chunk-vnPrMVjY.js +10 -0
  387. package/dist/chunk-vnPrMVjY.js.map +1 -0
  388. package/dist/chunk-ws3bVwaS.d.ts +410 -0
  389. package/dist/chunk-xh3UkuVs.cjs +246 -0
  390. package/dist/chunk-xh3UkuVs.cjs.map +1 -0
  391. package/dist/chunk-yMzRr26E.js +153 -0
  392. package/dist/chunk-yMzRr26E.js.map +1 -0
  393. package/dist/collab/index.cjs +831 -0
  394. package/dist/collab/index.cjs.map +1 -0
  395. package/dist/collab/index.d.cts +824 -0
  396. package/dist/collab/index.d.ts +824 -0
  397. package/dist/collab/index.js +819 -0
  398. package/dist/collab/index.js.map +1 -0
  399. package/dist/data/index.cjs +39 -0
  400. package/dist/data/index.d.cts +6 -0
  401. package/dist/data/index.d.ts +6 -0
  402. package/dist/data/index.js +7 -0
  403. package/dist/editor/index.cjs +2713 -0
  404. package/dist/editor/index.cjs.map +1 -0
  405. package/dist/editor/index.d.cts +10 -0
  406. package/dist/editor/index.d.ts +10 -0
  407. package/dist/editor/index.js +2702 -0
  408. package/dist/editor/index.js.map +1 -0
  409. package/dist/errors/index.cjs +11 -0
  410. package/dist/errors/index.d.cts +2 -0
  411. package/dist/errors/index.d.ts +2 -0
  412. package/dist/errors/index.js +1 -0
  413. package/dist/geo/index.cjs +68 -0
  414. package/dist/geo/index.d.cts +6 -0
  415. package/dist/geo/index.d.ts +6 -0
  416. package/dist/geo/index.js +11 -0
  417. package/dist/i18n/fr/index.cjs +333 -0
  418. package/dist/i18n/fr/index.cjs.map +1 -0
  419. package/dist/i18n/fr/index.d.cts +18 -0
  420. package/dist/i18n/fr/index.d.ts +18 -0
  421. package/dist/i18n/fr/index.js +328 -0
  422. package/dist/i18n/fr/index.js.map +1 -0
  423. package/dist/i18n/index.cjs +451 -0
  424. package/dist/i18n/index.cjs.map +1 -0
  425. package/dist/i18n/index.d.cts +268 -0
  426. package/dist/i18n/index.d.ts +268 -0
  427. package/dist/i18n/index.js +430 -0
  428. package/dist/i18n/index.js.map +1 -0
  429. package/dist/icons/index.cjs +37 -0
  430. package/dist/icons/index.d.cts +4 -0
  431. package/dist/icons/index.d.ts +4 -0
  432. package/dist/icons/index.js +8 -0
  433. package/dist/index.cjs +517 -0
  434. package/dist/index.cjs.map +1 -0
  435. package/dist/index.d.cts +174 -0
  436. package/dist/index.d.ts +174 -0
  437. package/dist/index.js +54 -0
  438. package/dist/index.js.map +1 -0
  439. package/dist/layers/index.cjs +83 -0
  440. package/dist/layers/index.d.cts +3 -0
  441. package/dist/layers/index.d.ts +3 -0
  442. package/dist/layers/index.js +5 -0
  443. package/dist/map-client/index.cjs +5 -0
  444. package/dist/map-client/index.d.cts +6 -0
  445. package/dist/map-client/index.d.ts +6 -0
  446. package/dist/map-client/index.js +0 -0
  447. package/dist/maplibre-worker.mjs +12 -0
  448. package/dist/navigation/index.cjs +612 -0
  449. package/dist/navigation/index.cjs.map +1 -0
  450. package/dist/navigation/index.d.cts +551 -0
  451. package/dist/navigation/index.d.ts +551 -0
  452. package/dist/navigation/index.js +599 -0
  453. package/dist/navigation/index.js.map +1 -0
  454. package/dist/profile/index.cjs +177 -0
  455. package/dist/profile/index.d.cts +8 -0
  456. package/dist/profile/index.d.ts +8 -0
  457. package/dist/profile/index.js +10 -0
  458. package/dist/seams/index.cjs +15 -0
  459. package/dist/seams/index.d.cts +4 -0
  460. package/dist/seams/index.d.ts +4 -0
  461. package/dist/seams/index.js +4 -0
  462. package/dist/search/index.cjs +39 -0
  463. package/dist/search/index.d.cts +6 -0
  464. package/dist/search/index.d.ts +6 -0
  465. package/dist/search/index.js +3 -0
  466. package/dist/style/index.cjs +34 -0
  467. package/dist/style/index.d.cts +5 -0
  468. package/dist/style/index.d.ts +5 -0
  469. package/dist/style/index.js +5 -0
  470. package/dist/styles.css +11 -0
  471. package/dist/testing/index.cjs +444 -0
  472. package/dist/testing/index.cjs.map +1 -0
  473. package/dist/testing/index.d.cts +217 -0
  474. package/dist/testing/index.d.ts +217 -0
  475. package/dist/testing/index.js +435 -0
  476. package/dist/testing/index.js.map +1 -0
  477. package/dist/timezone/index.cjs +1953 -0
  478. package/dist/timezone/index.cjs.map +1 -0
  479. package/dist/timezone/index.d.cts +28 -0
  480. package/dist/timezone/index.d.ts +28 -0
  481. package/dist/timezone/index.js +1948 -0
  482. package/dist/timezone/index.js.map +1 -0
  483. package/dist/units/index.cjs +29 -0
  484. package/dist/units/index.d.cts +3 -0
  485. package/dist/units/index.d.ts +3 -0
  486. package/dist/units/index.js +3 -0
  487. package/dist/video/index.cjs +1713 -0
  488. package/dist/video/index.cjs.map +1 -0
  489. package/dist/video/index.d.cts +846 -0
  490. package/dist/video/index.d.ts +846 -0
  491. package/dist/video/index.js +1689 -0
  492. package/dist/video/index.js.map +1 -0
  493. package/dist/view/index.cjs +7 -0
  494. package/dist/view/index.d.cts +3 -0
  495. package/dist/view/index.d.ts +3 -0
  496. package/dist/view/index.js +1 -0
  497. package/package.json +433 -4
  498. package/src/agent/engines/session.ts +2255 -0
  499. package/src/agent/index.ts +109 -0
  500. package/src/agent/rules/agentError.ts +128 -0
  501. package/src/agent/rules/boundedInputJson.ts +53 -0
  502. package/src/agent/rules/conversation.ts +629 -0
  503. package/src/agent/rules/conversationFaults.ts +349 -0
  504. package/src/agent/rules/conversationHost.ts +390 -0
  505. package/src/agent/rules/dispatcher.ts +102 -0
  506. package/src/agent/rules/errorCodes.ts +78 -0
  507. package/src/agent/rules/errorStatus.ts +65 -0
  508. package/src/agent/rules/scriptedTransport.ts +390 -0
  509. package/src/agent/rules/stickToBottom.ts +38 -0
  510. package/src/agent/rules/toolResultPayload.ts +197 -0
  511. package/src/auth/rules/clientHeader.ts +22 -0
  512. package/src/auth/rules/sentCredential.ts +76 -0
  513. package/src/auth/rules/transformRequest.ts +803 -0
  514. package/src/camera/engines/videoFlight.ts +1758 -0
  515. package/src/camera/index.ts +157 -0
  516. package/src/camera/rules/clearance.ts +1099 -0
  517. package/src/camera/rules/fit.ts +132 -0
  518. package/src/camera/rules/modes.ts +1019 -0
  519. package/src/camera/rules/plan.ts +478 -0
  520. package/src/camera/rules/planner.ts +129 -0
  521. package/src/camera/rules/poseRanges.ts +38 -0
  522. package/src/camera/rules/presets.ts +185 -0
  523. package/src/camera/rules/profileSamples.ts +243 -0
  524. package/src/camera/rules/route.ts +596 -0
  525. package/src/camera/rules/routeContent.ts +105 -0
  526. package/src/camera/rules/spline.ts +765 -0
  527. package/src/camera/rules/sweptViewports.ts +39 -0
  528. package/src/camera/rules/track.ts +1412 -0
  529. package/src/camera/rules/vocabulary.ts +130 -0
  530. package/src/camera/rules/zoom.ts +216 -0
  531. package/src/collab/engines/session.ts +1902 -0
  532. package/src/collab/engines/trailingThrottle.ts +151 -0
  533. package/src/collab/index.ts +52 -0
  534. package/src/collab/rules/dispatch.ts +143 -0
  535. package/src/collab/rules/peerNames.ts +51 -0
  536. package/src/collab/rules/scriptedTransport.ts +244 -0
  537. package/src/compose/engines/baseMapSwitch.ts +1136 -0
  538. package/src/compose/engines/events.ts +962 -0
  539. package/src/compose/engines/mountayaMap.ts +5648 -0
  540. package/src/compose/engines/sentCredentials.ts +146 -0
  541. package/src/compose/engines/slotRequests.ts +413 -0
  542. package/src/compose/rules/accessRefusal.ts +109 -0
  543. package/src/compose/rules/accessStanding.ts +75 -0
  544. package/src/compose/rules/analysisKinds.ts +331 -0
  545. package/src/compose/rules/analysisLayers.ts +176 -0
  546. package/src/compose/rules/cameraMoves.ts +38 -0
  547. package/src/compose/rules/carriedLayers.ts +87 -0
  548. package/src/compose/rules/developmentWarnings.ts +167 -0
  549. package/src/compose/rules/fitBox.ts +67 -0
  550. package/src/compose/rules/fitCamera.ts +54 -0
  551. package/src/compose/rules/geoJsonSlot.ts +61 -0
  552. package/src/compose/rules/geometrySlots.ts +155 -0
  553. package/src/compose/rules/glyphNode.ts +62 -0
  554. package/src/compose/rules/layerKeys.ts +92 -0
  555. package/src/compose/rules/layerOrder.ts +85 -0
  556. package/src/compose/rules/layersManifest.ts +26 -0
  557. package/src/compose/rules/mapOptions.ts +300 -0
  558. package/src/compose/rules/maplibreWorkerVersion.gen.ts +8 -0
  559. package/src/compose/rules/markerPin.ts +122 -0
  560. package/src/compose/rules/markerRegistry.ts +85 -0
  561. package/src/compose/rules/markerSprite.ts +382 -0
  562. package/src/compose/rules/maxBounds.ts +120 -0
  563. package/src/compose/rules/overlayLookup.ts +49 -0
  564. package/src/compose/rules/paintDiff.ts +38 -0
  565. package/src/compose/rules/panLock.ts +77 -0
  566. package/src/compose/rules/patch.ts +124 -0
  567. package/src/compose/rules/queriedFeature.ts +55 -0
  568. package/src/compose/rules/queryLayers.ts +46 -0
  569. package/src/compose/rules/searchHighlight.ts +313 -0
  570. package/src/compose/rules/slotNames.ts +19 -0
  571. package/src/compose/rules/stripeImage.ts +253 -0
  572. package/src/compose/rules/swapMarker.ts +66 -0
  573. package/src/compose/rules/terrainVariant.ts +88 -0
  574. package/src/compose/rules/types.ts +559 -0
  575. package/src/compose/rules/urlHash.ts +19 -0
  576. package/src/compose/rules/viewOptions.ts +451 -0
  577. package/src/compose/rules/workerUrl.ts +131 -0
  578. package/src/data/engines/itineraryResource.ts +643 -0
  579. package/src/data/index.ts +78 -0
  580. package/src/data/rules/adapt.ts +473 -0
  581. package/src/data/rules/editModes.ts +51 -0
  582. package/src/data/rules/itinerary.ts +168 -0
  583. package/src/data/rules/nullable.ts +63 -0
  584. package/src/data/rules/roadAccess.ts +169 -0
  585. package/src/data/rules/segmentGroups.ts +309 -0
  586. package/src/data/rules/selectors.ts +95 -0
  587. package/src/data/rules/zones.ts +79 -0
  588. package/src/draw/engines/boundaryEngine.ts +1003 -0
  589. package/src/draw/engines/framedAdapter.ts +198 -0
  590. package/src/draw/engines/pointerCursor.ts +205 -0
  591. package/src/draw/engines/segmentEngine.ts +1405 -0
  592. package/src/draw/engines/snapIndex.ts +254 -0
  593. package/src/draw/engines/waypointEngine.ts +574 -0
  594. package/src/draw/engines/zoneEngine.ts +1137 -0
  595. package/src/draw/rules/drawFrame.ts +123 -0
  596. package/src/draw/rules/insertVertex.ts +226 -0
  597. package/src/draw/rules/screenSpace.ts +62 -0
  598. package/src/draw/rules/seeds.ts +185 -0
  599. package/src/draw/rules/snap.ts +115 -0
  600. package/src/draw/rules/snapCameraKey.ts +50 -0
  601. package/src/draw/rules/terraDrawShared.ts +214 -0
  602. package/src/draw/rules/zoneOutline.ts +213 -0
  603. package/src/editing/engines/cursor.ts +505 -0
  604. package/src/editing/engines/draftMarker.ts +149 -0
  605. package/src/editing/rules/accent.ts +11 -0
  606. package/src/editing/rules/engine.ts +288 -0
  607. package/src/editing/rules/placement.ts +22 -0
  608. package/src/editing/rules/positions.ts +89 -0
  609. package/src/editing/rules/sources.ts +9 -0
  610. package/src/editing/rules/types.ts +457 -0
  611. package/src/editing/rules/vocabulary.ts +10 -0
  612. package/src/editing/rules/waypointCursor.ts +228 -0
  613. package/src/editor/engines/directionArrows.ts +459 -0
  614. package/src/editor/engines/directions.ts +1383 -0
  615. package/src/editor/engines/editorClient.ts +134 -0
  616. package/src/editor/engines/eventScope.ts +59 -0
  617. package/src/editor/engines/frameLoop.ts +159 -0
  618. package/src/editor/engines/itineraryPreview.ts +272 -0
  619. package/src/editor/engines/mapLockGuard.ts +66 -0
  620. package/src/editor/engines/overlayRenderer.ts +2696 -0
  621. package/src/editor/engines/peerDraft.ts +760 -0
  622. package/src/editor/engines/poiPick.ts +305 -0
  623. package/src/editor/engines/pointPick.ts +84 -0
  624. package/src/editor/engines/roadAccessLine.ts +140 -0
  625. package/src/editor/engines/searchHighlight.ts +183 -0
  626. package/src/editor/engines/viewClient.ts +4091 -0
  627. package/src/editor/engines/zoneBadges.ts +503 -0
  628. package/src/editor/index.ts +97 -0
  629. package/src/editor/rules/accentColor.ts +116 -0
  630. package/src/editor/rules/camera.ts +121 -0
  631. package/src/editor/rules/contract.ts +120 -0
  632. package/src/editor/rules/icons.ts +825 -0
  633. package/src/editor/rules/markerElements.ts +244 -0
  634. package/src/editor/rules/style.ts +51 -0
  635. package/src/editor/rules/terrain.ts +98 -0
  636. package/src/editor/rules/tileWarm.ts +191 -0
  637. package/src/editor/rules/tilesReload.ts +158 -0
  638. package/src/editor/rules/zoneBadgePlacement.ts +1832 -0
  639. package/src/editor/rules/zoneTimeStyling.ts +119 -0
  640. package/src/errors/index.ts +25 -0
  641. package/src/errors/rules/errors.ts +158 -0
  642. package/src/errors/rules/print.ts +129 -0
  643. package/src/geo/index.ts +89 -0
  644. package/src/geo/rules/boundaries.ts +105 -0
  645. package/src/geo/rules/camera.ts +496 -0
  646. package/src/geo/rules/corridor.ts +242 -0
  647. package/src/geo/rules/elevationTiles.ts +269 -0
  648. package/src/geo/rules/formatLngLat.ts +63 -0
  649. package/src/geo/rules/geodesy.ts +125 -0
  650. package/src/geo/rules/geometry.ts +362 -0
  651. package/src/geo/rules/lineWalk.ts +77 -0
  652. package/src/geo/rules/longitude.ts +99 -0
  653. package/src/geo/rules/searchLimits.ts +22 -0
  654. package/src/geo/rules/segmentGeometry.ts +80 -0
  655. package/src/geo/rules/terrain.ts +107 -0
  656. package/src/geo/rules/tuples.ts +124 -0
  657. package/src/geo/rules/types.ts +54 -0
  658. package/src/geo/rules/webMercator.ts +57 -0
  659. package/src/i18n/fr/index.ts +17 -0
  660. package/src/i18n/fr/rules/fr.ts +85 -0
  661. package/src/i18n/fr/rules/words.gen.ts +277 -0
  662. package/src/i18n/index.ts +82 -0
  663. package/src/i18n/rules/bundle.ts +378 -0
  664. package/src/i18n/rules/config.ts +71 -0
  665. package/src/i18n/rules/dates.ts +165 -0
  666. package/src/i18n/rules/endonyms.gen.ts +19 -0
  667. package/src/i18n/rules/language.ts +92 -0
  668. package/src/i18n/rules/localizedName.ts +33 -0
  669. package/src/i18n/rules/merge.ts +106 -0
  670. package/src/i18n/rules/scope.ts +127 -0
  671. package/src/i18n/rules/strings.ts +632 -0
  672. package/src/i18n/rules/videoOverlay.ts +121 -0
  673. package/src/i18n/rules/wordForms.ts +95 -0
  674. package/src/i18n/rules/words.gen.ts +277 -0
  675. package/src/icons/index.ts +54 -0
  676. package/src/icons/rules/activities.ts +40 -0
  677. package/src/icons/rules/amenities.ts +250 -0
  678. package/src/icons/rules/artwork.gen.ts +83 -0
  679. package/src/icons/rules/artwork.ts +47 -0
  680. package/src/icons/rules/fallback.ts +21 -0
  681. package/src/icons/rules/lucideMarkers.gen.ts +112 -0
  682. package/src/icons/rules/lucideUi.gen.ts +197 -0
  683. package/src/icons/rules/paint.ts +107 -0
  684. package/src/icons/rules/parse.ts +475 -0
  685. package/src/icons/rules/provider.ts +373 -0
  686. package/src/icons/rules/sprites.ts +54 -0
  687. package/src/icons/rules/ui.ts +348 -0
  688. package/src/icons/rules/waypoints.ts +215 -0
  689. package/src/index.ts +993 -0
  690. package/src/layers/engines/layersSelection.ts +515 -0
  691. package/src/layers/engines/readoutEngine.ts +131 -0
  692. package/src/layers/index.ts +151 -0
  693. package/src/layers/rules/analysis.ts +135 -0
  694. package/src/layers/rules/enrichment.ts +30 -0
  695. package/src/layers/rules/geoJson.ts +270 -0
  696. package/src/layers/rules/hover.ts +67 -0
  697. package/src/layers/rules/itineraries.ts +182 -0
  698. package/src/layers/rules/layersPanel.ts +237 -0
  699. package/src/layers/rules/order.ts +194 -0
  700. package/src/layers/rules/overlayInstant.ts +49 -0
  701. package/src/layers/rules/overlays.ts +52 -0
  702. package/src/layers/rules/poiPanel.ts +119 -0
  703. package/src/layers/rules/pois.ts +114 -0
  704. package/src/layers/rules/readout.ts +340 -0
  705. package/src/layers/rules/streetView.ts +16 -0
  706. package/src/layers/rules/tileTimestamp.ts +146 -0
  707. package/src/layers/rules/timeSlider.ts +192 -0
  708. package/src/layers/rules/timeWindow.ts +123 -0
  709. package/src/layers/rules/zones.ts +43 -0
  710. package/src/layers/rules/zoom.ts +77 -0
  711. package/src/map-client/index.ts +71 -0
  712. package/src/map-client/rules/mapClient.ts +1945 -0
  713. package/src/navigation/engines/navigation.ts +493 -0
  714. package/src/navigation/index.ts +51 -0
  715. package/src/navigation/rules/followedRoute.ts +78 -0
  716. package/src/navigation/rules/instructions.ts +89 -0
  717. package/src/navigation/rules/itineraryRoute.ts +232 -0
  718. package/src/navigation/rules/offRoute.ts +41 -0
  719. package/src/navigation/rules/progress.ts +230 -0
  720. package/src/navigation/rules/prompts.ts +217 -0
  721. package/src/navigation/rules/routeRequest.ts +98 -0
  722. package/src/navigation/rules/status.ts +142 -0
  723. package/src/navigation/rules/steps.ts +234 -0
  724. package/src/navigation/rules/types.ts +83 -0
  725. package/src/profile/index.ts +307 -0
  726. package/src/profile/rules/amenityBadge.ts +35 -0
  727. package/src/profile/rules/amenityFilter.ts +74 -0
  728. package/src/profile/rules/amenityStacks.ts +66 -0
  729. package/src/profile/rules/axis.ts +89 -0
  730. package/src/profile/rules/axisCulling.ts +83 -0
  731. package/src/profile/rules/axisLookup.ts +180 -0
  732. package/src/profile/rules/climbs.ts +292 -0
  733. package/src/profile/rules/cursorMarker.ts +122 -0
  734. package/src/profile/rules/cursorReadout.ts +104 -0
  735. package/src/profile/rules/curvePlacement.ts +216 -0
  736. package/src/profile/rules/dock.ts +293 -0
  737. package/src/profile/rules/elevation.ts +1263 -0
  738. package/src/profile/rules/instant.ts +89 -0
  739. package/src/profile/rules/intl.ts +237 -0
  740. package/src/profile/rules/legEmphasis.ts +53 -0
  741. package/src/profile/rules/profileColors.ts +66 -0
  742. package/src/profile/rules/profileLayout.ts +59 -0
  743. package/src/profile/rules/profileSlices.ts +55 -0
  744. package/src/profile/rules/routeProfile.ts +475 -0
  745. package/src/profile/rules/rowMatch.ts +50 -0
  746. package/src/profile/rules/scale.ts +646 -0
  747. package/src/profile/rules/scaleFrame.ts +171 -0
  748. package/src/profile/rules/sectionChips.ts +83 -0
  749. package/src/profile/rules/sections.ts +923 -0
  750. package/src/profile/rules/slopeRamp.ts +160 -0
  751. package/src/profile/rules/statStrip.ts +103 -0
  752. package/src/profile/rules/steepness.ts +51 -0
  753. package/src/profile/rules/tableCells.ts +269 -0
  754. package/src/profile/rules/tableCursor.ts +87 -0
  755. package/src/profile/rules/unitPatterns.ts +335 -0
  756. package/src/profile/rules/units.ts +1025 -0
  757. package/src/profile/rules/waypointCard.ts +590 -0
  758. package/src/profile/rules/webAddress.ts +130 -0
  759. package/src/profile/rules/windowSpans.ts +65 -0
  760. package/src/rules/asciiFold.ts +17 -0
  761. package/src/rules/inDevelopment.ts +54 -0
  762. package/src/rules/listeners.ts +62 -0
  763. package/src/rules/timers.ts +9 -0
  764. package/src/rules/types.ts +22 -0
  765. package/src/rules/uuid.ts +87 -0
  766. package/src/seams/engines/geolocateControl.ts +286 -0
  767. package/src/seams/index.ts +50 -0
  768. package/src/seams/rules/clock.ts +169 -0
  769. package/src/seams/rules/geolocation.ts +165 -0
  770. package/src/seams/rules/segmentRoute.ts +187 -0
  771. package/src/search/engines/search.ts +1093 -0
  772. package/src/search/index.ts +99 -0
  773. package/src/search/rules/describe.ts +383 -0
  774. package/src/search/rules/filters.ts +195 -0
  775. package/src/search/rules/highlight.ts +270 -0
  776. package/src/search/rules/pick.ts +90 -0
  777. package/src/search/rules/rows.ts +258 -0
  778. package/src/search/rules/searchFocus.ts +27 -0
  779. package/src/search/rules/searchViewport.ts +44 -0
  780. package/src/search/rules/shown.ts +77 -0
  781. package/src/search/rules/types.ts +340 -0
  782. package/src/stream/rules/reconnectSchedule.ts +83 -0
  783. package/src/style/engines/organizationRead.ts +80 -0
  784. package/src/style/index.ts +63 -0
  785. package/src/style/rules/apply.ts +268 -0
  786. package/src/style/rules/attribution.ts +119 -0
  787. package/src/style/rules/itineraryLine.ts +142 -0
  788. package/src/style/rules/language.ts +668 -0
  789. package/src/style/rules/layout.gen.ts +27 -0
  790. package/src/style/rules/organization.ts +96 -0
  791. package/src/style/rules/paint.ts +143 -0
  792. package/src/style/rules/panelLayout.ts +51 -0
  793. package/src/style/rules/roadAccessColors.ts +29 -0
  794. package/src/style/rules/roadAccessLine.ts +267 -0
  795. package/src/style/rules/segmentColors.ts +207 -0
  796. package/src/testing/catalogs.ts +103 -0
  797. package/src/testing/index.ts +30 -0
  798. package/src/testing/mapClient.ts +241 -0
  799. package/src/testing/mountayaMap.ts +741 -0
  800. package/src/timezone/index.ts +14 -0
  801. package/src/timezone/rules/viewport.ts +875 -0
  802. package/src/units/index.ts +55 -0
  803. package/src/units/rules/conversions.ts +620 -0
  804. package/src/units/rules/preferenceChoices.ts +124 -0
  805. package/src/units/rules/preferences.ts +77 -0
  806. package/src/units/rules/rounding.ts +69 -0
  807. package/src/video/engines/videoRun.ts +654 -0
  808. package/src/video/engines/viewClient.ts +6 -0
  809. package/src/video/index.ts +83 -0
  810. package/src/video/profileOverlay/rules/contract.ts +210 -0
  811. package/src/video/profileOverlay/rules/curve.ts +216 -0
  812. package/src/video/profileOverlay/rules/draw.ts +410 -0
  813. package/src/video/profileOverlay/rules/fonts.ts +54 -0
  814. package/src/video/profileOverlay/rules/graphDesign.ts +690 -0
  815. package/src/video/profileOverlay/rules/minimalDesign.ts +144 -0
  816. package/src/video/profileOverlay/rules/registry.ts +23 -0
  817. package/src/video/profileOverlay/rules/staticLayer.ts +582 -0
  818. package/src/video/profileOverlay/rules/stripDesign.ts +327 -0
  819. package/src/video/profileOverlay/rules/types.ts +78 -0
  820. package/src/video/rules/videoConstants.ts +250 -0
  821. package/src/video/rules/videoEncoder.ts +277 -0
  822. package/src/video/rules/videoFrames.ts +99 -0
  823. package/src/video/rules/videoPreview.ts +185 -0
  824. package/src/video/rules/videoRecorder.ts +746 -0
  825. package/src/video/rules/videoWatermark.ts +155 -0
  826. package/src/video/rules/watermarkMark.ts +40 -0
  827. package/src/view/engines/viewClient.ts +6 -0
  828. package/src/view/index.ts +20 -0
@@ -0,0 +1,1966 @@
1
+ import { AgentClientToolManifest, AgentRunProfile, AgentRunReason, AgentToolErrorCode } from "@mountaya/client";
2
+ import { AgentEvent, AgentTransport } from "@mountaya/client/events";
3
+ /**
4
+ * What the agent loop needs from a tool layer, and nothing more.
5
+ *
6
+ * Typing the loop in `@mountaya/studio`'s own vocabulary (`ToolBus<StudioToolContext>`,
7
+ * `captureStudioState`, `recoveryFor`) would make an AGENT PROTOCOL a function of one product's
8
+ * store. It is not: the run lifecycle, the confirmation gate, the transcript and the wire shapes
9
+ * are the same for a studio, for a host driving their own tools, and for whatever the next
10
+ * surface turns out to be. Only the tools differ.
11
+ *
12
+ * So the loop asks for the two methods it calls and the two questions it asks, structurally.
13
+ * `@mountaya/studio`'s bus satisfies `ToolDispatcher` by having the right shape rather than by
14
+ * importing anything from here, which is what lets the studio depend on the elements and not the
15
+ * other way round. A host wiring their own tools implements these members and gets the same
16
+ * loop.
17
+ */
18
+ /**
19
+ * ToolManifestEntry is the model-facing description of one available tool.
20
+ *
21
+ * `inputSchema` is typed as the wire's own `parameters` rather than as a JSON Schema of our
22
+ * making, because that is the only place it goes: `AgentEngine` maps a manifest straight onto
23
+ * the gateway's client-tool list. A stricter type here would be a second opinion about a shape
24
+ * the API already states.
25
+ */
26
+ interface ToolManifestEntry {
27
+ capability: string;
28
+ description: string;
29
+ inputSchema: AgentClientToolManifest["parameters"];
30
+ name: string;
31
+ /**
32
+ * Whether the tool only reads state and changes nothing. Absent means unknown, which every
33
+ * consumer must treat as "may mutate": a run uses it to decide what its transcript may safely
34
+ * drop, and guessing wrong there erases the record of a real change.
35
+ */
36
+ readOnly?: boolean | undefined;
37
+ requiresConfirmation: boolean;
38
+ }
39
+ /**
40
+ * ToolDispatchResult is the outcome of one dispatched tool call, as the loop reads it.
41
+ *
42
+ * The structural half of `@mountaya/studio`'s `ToolResult`: a success carries the summary the
43
+ * transcript shows, a failure the technical `error` and, when the layer classified it, a stable
44
+ * `code`. The loop branches on `confirmation-denied` and forwards everything else verbatim.
45
+ */
46
+ type ToolDispatchResult = {
47
+ data?: unknown;
48
+ ok: true;
49
+ summary: string;
50
+ } | {
51
+ code?: string | undefined;
52
+ error: string;
53
+ ok: false;
54
+ };
55
+ /**
56
+ * ToolDispatcher is the tool layer the loop drives: what is on offer, and how to run one.
57
+ *
58
+ * Two members, because two is what the loop calls. `manifest` is asked for the tools a set of
59
+ * capabilities permits, narrowed to a routed surface when the host supplies one;
60
+ * `dispatchFromModel` runs one by name with the model's input and is the SOLE executor: the loop
61
+ * never touches a store, a map or a transport of its own.
62
+ */
63
+ interface ToolDispatcher<TContext> {
64
+ manifest(capabilities: ReadonlySet<string>, surface?: ReadonlySet<string>): ToolManifestEntry[];
65
+ dispatchFromModel(context: TContext, name: string, input: unknown): Promise<ToolDispatchResult>;
66
+ }
67
+ /**
68
+ * AgentToolContext is the part of a host's execution context the loop itself reads.
69
+ *
70
+ * One field. Everything else a tool needs (a client, a store, a map) the host put in the
71
+ * context and the host's own handlers read back out; the loop carries it from `dispatchFromModel`
72
+ * to the handler without looking inside. `capabilities` is the exception because the loop builds
73
+ * the manifest, and what is on offer is a function of what the reader may do.
74
+ */
75
+ interface AgentToolContext {
76
+ capabilities: ReadonlySet<string>;
77
+ }
78
+ /**
79
+ * StateDelta is how a host says what its own state did while a tool ran.
80
+ *
81
+ * A seam rather than a call, because "what moved" is a question only the host can answer: a
82
+ * studio compares a fingerprint of its stores, another surface might compare a route or a
83
+ * document revision. The loop captures before, captures after, and forwards whatever `diff`
84
+ * returns to the transcript. It never inspects the value, which is why `TSnapshot` is the
85
+ * host's to choose while the delta is a plain record: the snapshot is private and the delta is
86
+ * uploaded.
87
+ *
88
+ * Absent, a run simply reports no delta, which is the right answer for a host with no state to
89
+ * report rather than an error.
90
+ */
91
+ interface StateDelta<TContext, TSnapshot = unknown> {
92
+ capture(context: TContext): TSnapshot;
93
+ diff(before: TSnapshot, after: TSnapshot): Record<string, unknown> | undefined;
94
+ }
95
+ /**
96
+ * RecoveryLookup answers "a call to this tool failed with this code: what should the model try
97
+ * instead?".
98
+ *
99
+ * The studio's routing tables implement it; a host without a recovery policy omits it and the
100
+ * failure is reported bare.
101
+ */
102
+ type RecoveryLookup = (tool: string, code?: string) => string | undefined;
103
+ /**
104
+ * ServerToolConfirmation describes a destructive SERVER tool the gateway asks to
105
+ * run: the run identifies it by name alone (a server tool has no client-side
106
+ * schema, so there is no input to show, and the event carries no prose of its
107
+ * own). The host gate turns the name into its own localized approval prompt, which
108
+ * is why this stays decoupled from the bus's client-tool ConfirmationRequest.
109
+ */
110
+ interface ServerToolConfirmation {
111
+ name: string;
112
+ }
113
+ /**
114
+ * ToolActivityOutcome is how a tool call settled, delivered through
115
+ * {@link AgentObserver.onToolResult} so the host can settle the activity row it
116
+ * appended for the call: `ok` with an optional human `summary` of what the tool
117
+ * did, `error` with the failure text, or `abandoned` when the call was given up on
118
+ * (the user declined a client tool's confirmation, or the run moved on without an
119
+ * answer to the call). It mirrors both the bus result of a client tool and the
120
+ * stream's `tool-result` / `tool-abandoned` event, so one settle path covers a call
121
+ * the host recorded and one it never saw a call for.
122
+ */
123
+ interface ToolActivityOutcome {
124
+ error?: string | undefined;
125
+ /**
126
+ * Why an abandoned call was given up on: `timeout` when nothing came back within
127
+ * the await window, `closed` when the run was asked to finish while the call was
128
+ * still outstanding. Absent on any other status, and on a gateway that does not
129
+ * send one.
130
+ */
131
+ abandonedReason?: "timeout" | "closed" | undefined;
132
+ /**
133
+ * What the run will try about this failure, from the tool's playbook entry.
134
+ * Present only on a failure the playbook has guidance for. The run already sends
135
+ * this to the model; surfacing it to the host too is what stops a silent retry
136
+ * reading as a stall.
137
+ */
138
+ recovery?: string | undefined;
139
+ status: "abandoned" | "error" | "ok";
140
+ summary?: string | undefined;
141
+ }
142
+ /**
143
+ * AgentObserver is the host's window onto a running session. The engine pushes
144
+ * streamed text and lifecycle signals out through it; the host renders them,
145
+ * deferring the non-urgent text so input stays responsive. The engine itself
146
+ * renders nothing and touches no store: every UI effect goes through the bus.
147
+ *
148
+ * A callback answers nothing the run waits on, so one that throws stops neither the
149
+ * read nor the frame it was handed: its fault reaches the program as an uncaught error
150
+ * on a microtask. A throw from a seam that answers (the tool layer, the confirm gate,
151
+ * the tool surface, the state delta) ends the read instead.
152
+ */
153
+ interface AgentObserver {
154
+ /**
155
+ * onError surfaces an error or budget-exhausted event so the host can show it.
156
+ * `code` is the machine-readable reason every run error carries (e.g.
157
+ * `rate-limited`), or the literal `budget-exhausted` for a budget ceiling, in
158
+ * which case `message` carries the exhausted dimension (`turns` / `cost`) rather
159
+ * than a human string. It is absent only for a fault the engine raises itself,
160
+ * such as a tool result it could not post, whose message is empty. This lets the
161
+ * host map a known code to specific copy (a budget code to per-dimension
162
+ * usage-limit copy) and fall back to a generic message otherwise.
163
+ *
164
+ * It never ends the run. The gateway publishes an `error` or a `budget-exhausted` only
165
+ * as the run ends and always follows it with the terminal `done`, which is what ends the
166
+ * run and reaches {@link onRunEnd}.
167
+ */
168
+ onError?: ((message: string, code?: string) => void) | undefined;
169
+ /**
170
+ * onRunEnd reports how a run ended, read off its terminal `done` frame: `completed`,
171
+ * `closed`, `failed`, `budget-exhausted`, `rate-limited` or `looping`. It fires at most
172
+ * once per read of a run, which one {@link AgentEngine.start} or {@link AgentEngine.resume}
173
+ * makes, before `onStateChange("ended")`. A resume that reads the `done` of a run already
174
+ * read to its end reports it again: one by an engine that holds no position for the run,
175
+ * which is answered with the run's history, or one given a position before the `done`.
176
+ *
177
+ * Only `done` knows the reason, so a read that ends any other way reports none: a
178
+ * {@link AgentEngine.close} or {@link AgentEngine.dispose}, a start or a resume that
179
+ * replaces the run, and a stream the engine stopped reconnecting to without a `done`.
180
+ * Optional: a host that needs only the `ended`
181
+ * state omits it.
182
+ */
183
+ onRunEnd?: ((reason: AgentRunReason) => void) | undefined;
184
+ /**
185
+ * onChecksUnmet reports the success criteria a run's retrieved skills promised
186
+ * that the workspace does not back, published by the run right before it settles
187
+ * into awaiting_input. Informational, never terminal: the answer stands and the
188
+ * user decides. The sentences are the authored criteria, written for the user.
189
+ * Optional: a host that does not render the warning omits it.
190
+ */
191
+ onChecksUnmet?: ((unmet: readonly string[]) => void) | undefined;
192
+ /**
193
+ * onMessage delivers a complete assistant message (the turn's settled text) with
194
+ * the message's zero-based position among the run's assistant messages.
195
+ *
196
+ * The index is the number a rating on this message has to carry back, and it comes
197
+ * from the run because a host cannot work it out. A host counts the replies it is
198
+ * showing, and a reload mid-run leaves it showing none (the URL carries the thread
199
+ * and run ids, not the conversation), so a locally counted index restarts at zero
200
+ * while the run's is already higher, and every rating from then on names an earlier
201
+ * answer than the one that was rated.
202
+ *
203
+ * It is undefined for a message from a gateway that sends no index, in which case
204
+ * the host falls back to its own count for that message alone.
205
+ */
206
+ onMessage?: ((content: string, messageIndex?: number) => void) | undefined;
207
+ /** onMessageDelta delivers one streamed assistant token as it arrives. */
208
+ onMessageDelta?: ((text: string) => void) | undefined;
209
+ /**
210
+ * onRunId reports the run's id the moment start/resume sets it, so the host can
211
+ * persist it (e.g. into the URL) for a reload to reconnect.
212
+ */
213
+ onRunId?: ((runId: string) => void) | undefined;
214
+ /** onStateChange reports the session's lifecycle transitions to the host. */
215
+ onStateChange?: ((state: AgentEngineState) => void) | undefined;
216
+ /**
217
+ * onToolActivity surfaces what the run is doing right now so the host can show
218
+ * a live activity line. The session emits the dispatched CLIENT tool's name as
219
+ * it begins, then the tool's result summary (when the bus returns one) as it
220
+ * settles, so the line tracks the action from start to finish. Optional: a host
221
+ * that does not render activity omits it.
222
+ */
223
+ onToolActivity?: ((summary: string) => void) | undefined;
224
+ /**
225
+ * onToolCall delivers a client tool call's name, its raw unvalidated input, and
226
+ * the call's id the moment the run emits it: the structured twin of
227
+ * {@link onToolActivity}, which carries only the human display string. A host reads
228
+ * this to react to WHAT the tool will touch (deriving the workspace target an edit is
229
+ * about to lock from the input) and to record the call as a durable activity row
230
+ * keyed by its id, which {@link onToolResult} later settles. The display line
231
+ * cannot carry the structured input or the id. Fires before the bus dispatch,
232
+ * alongside onToolActivity. Optional: a host that renders only the activity line
233
+ * omits it.
234
+ */
235
+ onToolCall?: ((name: string, input: unknown, toolCallId: string) => void) | undefined;
236
+ /**
237
+ * onToolResult reports how a tool call settled, keyed by its call id, so a host
238
+ * that recorded the call through onToolCall can settle that activity row. A CLIENT
239
+ * tool call the engine ran is reported once, from the bus result as the dispatch
240
+ * returns. Every other call is reported from the `tool-result` or `tool-abandoned`
241
+ * event the stream carries for it: a SERVER tool's outcome, a call the run gave up
242
+ * on, and the outcome replayed behind a call the stream marks `settled`. Optional:
243
+ * a host that renders only the activity line omits it.
244
+ *
245
+ * The stream names a call the engine ran a second time: the gateway echoes the
246
+ * answer the engine posted as a `tool-result`, and a `tool-abandoned` can cross an
247
+ * answer that came late. For a call it reported, the engine drops both whole, in the
248
+ * read that ran the call and in every later read of the run, so the bus result is the
249
+ * one report. An echo says less than the bus did: it carries no summary, and it words
250
+ * a confirmation the user declined as an error. A call whose handling threw before the
251
+ * report (the tool layer, or one of the host's seams) has no report of the engine's,
252
+ * so what the stream says about it is delivered. What the stream says of a call while its
253
+ * tool still runs, in a read a {@link AgentEngine.resume} opened beside it, is held until
254
+ * the tool settles: the bus result is then the one report, and the first thing the stream
255
+ * said is delivered only when the handling throws.
256
+ *
257
+ * The id may be one the host never saw a call for, which the host settles by
258
+ * appending an already-settled row: a server tool's, which emits no call event, or
259
+ * a call the stream marks settled, whose `tool-call` frame the engine drops before
260
+ * it reports the outcome replayed behind it. The id may also be one already reported: a failed
261
+ * `tool-result` follows the `tool-abandoned` of a confirmation nobody decided, and
262
+ * a resumed stream replays an outcome. The first report is the one to keep, which
263
+ * is what `settleActivityEntry` does.
264
+ */
265
+ onToolResult?: ((toolCallId: string, outcome: ToolActivityOutcome) => void) | undefined;
266
+ }
267
+ /**
268
+ * AgentEngineState is the session lifecycle the host renders against: it is
269
+ * `running` from the message that opens a turn (a start or a send, at the call)
270
+ * until the turn settles, `awaiting_input` once the turn settles and the
271
+ * run is ready for the next user message (multi-turn), and `ended` after a
272
+ * terminal event. A message that does not reach its run (a start that fails, a send
273
+ * whose post fails with no other message on its way and no frame since) returns the
274
+ * engine to `awaiting_input`. Held as a string union (Zod is unnecessary: this value never
275
+ * crosses a runtime boundary). It is the engine's own vocabulary rather than the
276
+ * contract's, so `awaiting_input` keeps its spelling where the event that leads to it
277
+ * is `awaiting-input`.
278
+ */
279
+ type AgentEngineState = "running" | "awaiting_input" | "ended";
280
+ /**
281
+ * AgentStreamPosition is where an engine stands in the event stream of a run: the run, and the
282
+ * last position its stream named.
283
+ *
284
+ * {@link AgentEngine.streamPosition} answers it and {@link AgentEngine.resume} takes its two
285
+ * members, so a host that replaces an engine hands the run to the next one where the last one
286
+ * left it, and the gateway replays nothing the host already holds.
287
+ */
288
+ interface AgentStreamPosition {
289
+ /** The position, as the stream spelled it: what a reopen sends back as `Last-Event-ID`. */
290
+ readonly lastEventId: string;
291
+ /** The run the position belongs to. A position names nothing in another run. */
292
+ readonly runId: string;
293
+ }
294
+ /**
295
+ * AgentEngineConfig wires a session to the tool bus and its execution context, the
296
+ * injectable transport, and the host observer. `confirmServerTool` is the gate the
297
+ * session calls when the gateway asks to run a destructive SERVER tool
298
+ * ({@link ServerToolConfirmation}); the host wires it to the same confirm modal the
299
+ * bus uses for client tools. The engine changes no UI state of its own: it dispatches
300
+ * every UI-affecting client tool through the bus, the sole executor.
301
+ *
302
+ * `toolSurface` is the routing seam: it returns the tool names the model should be
303
+ * offered right now, or undefined for the whole permitted set. The session only
304
+ * reads it (which tools belong to a task is policy the host owns), and it is
305
+ * consulted both when a run opens and on every {@link AgentEngine.routeTools} call,
306
+ * so the run's opening turn is routed exactly like the ones after it. It shapes only
307
+ * what the model can SEE; the capability gate remains the sole authorization boundary.
308
+ */
309
+ interface AgentEngineConfig<TContext extends AgentToolContext = AgentToolContext> {
310
+ bus: ToolDispatcher<TContext>;
311
+ confirmServerTool: (confirmation: ServerToolConfirmation) => Promise<boolean>;
312
+ ctx: TContext;
313
+ observer: AgentObserver;
314
+ /**
315
+ * How the host reports what its own state did while a tool ran, and what to try after a
316
+ * failure. Both are OPTIONAL and both are the host's policy rather than the loop's:
317
+ * `@mountaya/studio` passes its store fingerprint and its routing tables, a host wiring their
318
+ * own tools passes neither and a run reports the tool result bare.
319
+ */
320
+ recoveryFor?: RecoveryLookup | undefined;
321
+ stateDelta?: StateDelta<TContext> | undefined;
322
+ /**
323
+ * Prompt profile the run opens with. Omitted means the full studio co-pilot.
324
+ * It belongs on the session rather than on start() because it is a property of
325
+ * the SURFACE, not of a message: a Video Director session is a director for its
326
+ * whole life.
327
+ */
328
+ profile?: AgentRunProfile | undefined;
329
+ /**
330
+ * Whether a run names the server tools the model sees, from the selection `toolSurface`
331
+ * answers: the routed set rides a start's `server_tools` and every routing update's.
332
+ *
333
+ * Off by default, and off under a publishable key, the credential a run is started with: a
334
+ * run under a key calls no server tool, and the API refuses a start or an update that names
335
+ * any. The engine then sends no `server_tools` at all, and routes the client tools alone.
336
+ * Turn it on only for a credential the API lets a run's model reach the server tools under:
337
+ * on under a publishable key, the transport `createAgentTransport` builds refuses the start
338
+ * before it is sent, with a `MountayaConfigurationError` naming this option, which the start
339
+ * rejects with.
340
+ *
341
+ * @default false
342
+ */
343
+ routesServerTools?: boolean | undefined;
344
+ toolSurface?: (() => ReadonlySet<string> | undefined) | undefined;
345
+ /**
346
+ * The run's reader and writer: usually `createAgentTransport` from `@mountaya/client/events`,
347
+ * which gives up an open that never answers and a stream gone silent as connection errors. A
348
+ * transport of your own bounds both waits the same way, since the engine waits as long as
349
+ * `subscribe` says nothing, and reports `onClose("terminal")` only after it has handed over a
350
+ * `done`.
351
+ */
352
+ transport: AgentTransport;
353
+ }
354
+ /**
355
+ * AgentEngine is a long-lived, multi-turn agent run over a single persistent
356
+ * event stream. start() opens the run with the bus's contextual client-tool
357
+ * manifest and then consumes the run's one events stream to completion; across
358
+ * the run that consumer streams assistant text to the observer, dispatches each
359
+ * CLIENT tool-call through the bus and posts the result back, drives a
360
+ * destructive SERVER tool's confirmation through the host gate, and rides each
361
+ * turn boundary (an `awaiting-input` event keeps the same stream open for the next
362
+ * message). send() only posts the follow-up message; the already-open consumer
363
+ * carries that turn's events. close() asks the run to finish. The bus is the
364
+ * sole executor of UI-affecting tools: the model only emits tool calls.
365
+ *
366
+ * A resumed stream replays the run's history, and the engine leaves alone every call the
367
+ * replay marks `settled`: it drops a `tool-call` or a `confirm-required` that carries the
368
+ * marker, and any `tool_call_id` it has already handled in the run, so one engine runs a
369
+ * call once and asks a confirmation once. A replayed frame with neither is handled as a
370
+ * live one: a call still waiting on its answer, or a confirmation approved while its tool
371
+ * is still running, which the stream holds no outcome for yet. For that confirmation an
372
+ * engine built after a page reload asks the host again, and the gateway ignores the second
373
+ * decision.
374
+ *
375
+ * One engine reads one run at a time. A start() or a resume() replaces whatever the
376
+ * engine reads when it is called, so two runs never share its cursor, its stream or
377
+ * its memory of handled calls.
378
+ *
379
+ * @example
380
+ * ```ts
381
+ * import type { Mountaya } from "@mountaya/client";
382
+ * import { createAgentTransport } from "@mountaya/client/events";
383
+ * import { AgentEngine, type ToolDispatcher } from "@mountaya/elements/agent";
384
+ *
385
+ * declare const mountaya: Mountaya;
386
+ *
387
+ * const tools: ToolDispatcher<{ capabilities: ReadonlySet<string> }> = {
388
+ * dispatchFromModel: async (_context, name) => ({ ok: true, summary: `Ran ${name}` }),
389
+ * manifest: () => [],
390
+ * };
391
+ *
392
+ * const engine = new AgentEngine({
393
+ * bus: tools,
394
+ * confirmServerTool: async ({ name }) => window.confirm(`Run ${name}?`),
395
+ * ctx: { capabilities: new Set<string>() },
396
+ * observer: {
397
+ * onMessage: (content) => console.log(content),
398
+ * onStateChange: (state) => console.log(state),
399
+ * },
400
+ * transport: createAgentTransport(mountaya.transport),
401
+ * });
402
+ *
403
+ * // A start rejects when the run fails for good, and a send when no run is open: both report.
404
+ * const report = (error: unknown): void => console.error(error);
405
+ *
406
+ * engine.start("Plan a loop around the lake", "org_123").catch(report);
407
+ * // Later, on the user's next message, and on the way out:
408
+ * engine.send("Make it shorter").catch(report);
409
+ * void engine.close().finally(() => engine.dispose());
410
+ * ```
411
+ */
412
+ export declare class AgentEngine {
413
+ private readonly config;
414
+ private currentRunId;
415
+ private unfinishedRunId;
416
+ private state;
417
+ /**
418
+ * The state the observer was told last. It is {@link state} but from the moment a start
419
+ * readies its run until that start reports: the engine rests for those statements, and the
420
+ * observer is told the state the start leaves it in, never the rest between two turns.
421
+ */
422
+ private reported;
423
+ private sendHold;
424
+ private sendReporting;
425
+ private lastEventId;
426
+ private streamAbort;
427
+ private unsubscribe;
428
+ private readGeneration;
429
+ private routedNames;
430
+ private routingUpdates;
431
+ private routedUpdate;
432
+ private disposed;
433
+ private pendingStart;
434
+ private readonly handledCalls;
435
+ private handledRunId;
436
+ private readonly dispatchedCalls;
437
+ private readonly runningCalls;
438
+ constructor(config: AgentEngineConfig);
439
+ /**
440
+ * start opens a fresh run with the user's first message, then consumes the
441
+ * run's single event stream to completion. The returned promise settles only
442
+ * when the engine stops reading the run, so the caller fire-and-forgets it and
443
+ * reacts to turns through the observer instead. It resolves on the terminal
444
+ * `done`, on {@link close} or {@link dispose}, when a later start or
445
+ * {@link resume} replaces the run, and when its reconnects stop being productive.
446
+ *
447
+ * It rejects when the start or the stream fails for good: a start whose post is
448
+ * refused, at once for most answers and, for a 429, a 502, a 503, a 504 or a dropped
449
+ * connection, once the transport has repeated it under the start's idempotency key
450
+ * as far as its retry policy goes, a stream open answered with anything but a 429,
451
+ * 503 or 504, a fault in one of the host's own seams, and a stream that is still
452
+ * failing when the reconnect ceiling is reached, whether its connection stays down
453
+ * or every open is answered 429 or 504; that one rejects with the last
454
+ * failure. A stream that fails leaves the state `ended`, reported through
455
+ * `onStateChange("ended")`, before the promise rejects; a start that fails leaves
456
+ * it `awaiting_input`.
457
+ *
458
+ * A stream open answered 503 is not counted against the reconnect ceiling. It says the
459
+ * run's events cannot be reached for a moment while the run goes on, so the engine opens
460
+ * the stream again, after the wait the answer names, for as long as two minutes of such
461
+ * answers with no turn read in between, and then rejects with the last of them.
462
+ *
463
+ * The state is `running` from the call, reported through `onStateChange("running")` before
464
+ * the run has an id, so a host shows the turn as under way from the message. A start that
465
+ * fails reports `awaiting_input` again before its promise rejects. The report is the last
466
+ * step ahead of the post: a start that fails before it, on a fault in the tool surface,
467
+ * never reports `running`.
468
+ *
469
+ * A start that replaces a run reports that one change and no rest ahead of it: `running`
470
+ * from an engine at rest or whose last run ended, and nothing from an engine whose run is
471
+ * under way, which reads `running` through the replacement. Where such a start fails, the
472
+ * one report is `awaiting_input`.
473
+ *
474
+ * One engine reads one run. A start while the engine still reads a run tears that
475
+ * run's stream down and posts a close for it before it opens its own, so none of
476
+ * that run's frames, its resume cursor or its `done` reach the run that replaces
477
+ * it. A start while another start still waits on its run id withdraws that start,
478
+ * as {@link close} does. A start on an engine whose last run ended opens the next
479
+ * run and reads it from its beginning, and posts a close for that last run first when
480
+ * the engine stopped reading it short of its `done` (see {@link close}). A start after
481
+ * {@link dispose} opens nothing and resolves at once.
482
+ *
483
+ * Every start carries an `Idempotency-Key` of its own, drawn once per call where the runtime
484
+ * has a cryptographic random source, and is posted once: the transport repeats a start whose
485
+ * answer was lost under that same key, and the API answers the repeat with the run the key
486
+ * already started, so a lost answer never opens a second run. A start the transport gives up
487
+ * on rejects with the transport's failure, which carries the key. A custom
488
+ * {@link AgentTransport} receives the key as the `idempotencyKey` of the options its `startRun`
489
+ * is handed, and none where the runtime offers no source to draw it from.
490
+ *
491
+ * A {@link close}, a {@link dispose} or a later start or {@link resume} while the start
492
+ * still waits on its run id withdraws it: no stream is opened, no run id and no frame of
493
+ * the run reaches the observer, and the returned promise resolves even when the start
494
+ * itself fails. The run it opens is closed as soon as its id arrives. A withdrawal made from
495
+ * inside a state report of the start itself, or from inside the tool surface it reads (the
496
+ * bus's `manifest`), comes ahead of the post: nothing is posted, no run is opened and no
497
+ * `running` follows the `ended` the withdrawal reported.
498
+ *
499
+ * @param message The user's first message, which opens the run's first turn.
500
+ * @param organizationId The organization that owns the resource the co-pilot is opened on
501
+ * (the itinerary or zone being edited). The run is scoped and access-gated to it, and the
502
+ * API resolves the AI provider credential through it. It is captured per start because it
503
+ * reflects the resource open at the moment the run opens, and the API requires it.
504
+ * @param context The caller's point-in-time studio snapshot, forwarded verbatim to the
505
+ * gateway's create body so the run starts knowing the current UI state. It is captured per
506
+ * start (not held on the session config) because it is a snapshot of the moment the run
507
+ * opens. It stays an opaque `Record<string, unknown>` here because its typed shape is the
508
+ * host's, which this package does not import: the host builds it and passes it through.
509
+ */
510
+ start(message: string, organizationId: string, context?: Record<string, unknown>): Promise<void>;
511
+ /**
512
+ * resume re-attaches to an already-started run (e.g. after a page reload) and consumes the
513
+ * run's single event stream to completion. It lets a reload reconnect to an
514
+ * in-flight conversation rather than starting over. Its promise settles as the
515
+ * read of a {@link start} does: it resolves when the engine stops reading the run,
516
+ * and rejects when the stream fails for good, the state already `ended`.
517
+ *
518
+ * `lastEventId` is the stream position to read on from: the gateway replays what follows
519
+ * it, then the live feed. Without one the read starts where the engine left the run when
520
+ * `runId` is the run it holds (the one it read last, still open or not), so a host that
521
+ * kept its transcript re-attaches and is handed nothing a second time. That place is after
522
+ * the last frame that reached the engine, the one an observer callback is being handed
523
+ * included: a resume made from inside the callback reads on after that frame. A frame whose
524
+ * handling threw (a seam that answers: the tool layer, the confirm gate, the tool surface or
525
+ * the state delta) is the exception. It is read again, and
526
+ * a call the run already claimed is dropped. For any other run the engine holds no position,
527
+ * and the gateway answers with the run's whole history: that is the read an engine built
528
+ * after a reload makes, and its host starts from an empty transcript. To read the held run
529
+ * from its first event again, resume it on a new engine.
530
+ *
531
+ * Like {@link start}, it reads the run on an engine whose last run ended, opens
532
+ * nothing after {@link dispose}, and replaces what the engine reads when it is
533
+ * called: another run is torn down and closed, and a start still waiting on its run
534
+ * id is withdrawn. A resume of the run the engine is reading tears that read down
535
+ * and reads the run again from `lastEventId`, or from where that read was when none is
536
+ * passed, and posts no close for it.
537
+ *
538
+ * The engine is at rest as the read begins, reported through `onStateChange("awaiting_input")`
539
+ * from an engine that was `running` or `ended`, and the stream says the rest. A call made
540
+ * from inside that report is read before the run is adopted, as one made from a report of a
541
+ * {@link start} is: a {@link dispose} ends the resume with no stream opened and no run to
542
+ * close, and a start or another resume is the one read the engine makes, so this resume
543
+ * resolves at once. A {@link close} made there finds no run held and posts nothing, and the
544
+ * resume reads its run.
545
+ */
546
+ resume(runId: string, lastEventId?: string): Promise<void>;
547
+ /**
548
+ * streamPosition reads where the engine stands in the run it read last, for a host that
549
+ * replaces the engine and has the next one read the run on.
550
+ *
551
+ * It is the position a {@link resume} of that run on this engine reads on from: after the last
552
+ * frame that reached the engine, or the position a resume was handed while no frame has
553
+ * followed it. It is kept through {@link dispose}, which is when a host reads it.
554
+ *
555
+ * @returns The run and the position, or `null` while the engine has read no run or the run's
556
+ * stream has named no position, which is the whole of a run whose frames carry no id.
557
+ *
558
+ * @example
559
+ * ```ts
560
+ * import type { AgentEngine } from "@mountaya/elements/agent";
561
+ *
562
+ * declare const parked: AgentEngine;
563
+ * declare const next: AgentEngine;
564
+ *
565
+ * const position = parked.streamPosition();
566
+ * parked.dispose();
567
+ * if (position !== null) {
568
+ * next.resume(position.runId, position.lastEventId).catch((error: unknown) => {
569
+ * console.error(error);
570
+ * });
571
+ * }
572
+ * ```
573
+ */
574
+ streamPosition(): AgentStreamPosition | null;
575
+ /**
576
+ * runId reads the id of the run the engine holds: the one a {@link start} opened, from the
577
+ * moment its post answers, or the one a {@link resume} reads, from the moment it begins. It is
578
+ * kept once the engine stops reading that run, whether the run ended, its stream failed, or the
579
+ * engine was disposed.
580
+ *
581
+ * It is what tells the two failures a start rejects with apart. A start whose post the gateway
582
+ * refused opened no run, and this reads null; a start whose run opened and whose stream was
583
+ * then refused reads that run. The same status says different things on each: a 404 on the post
584
+ * is an organization the reader does not reach, and a 404 on the stream is a run the gateway no
585
+ * longer holds.
586
+ *
587
+ * @returns The run's id, or null while the engine holds none: before its first run, and from
588
+ * the moment a start replaces a run until the post of that start answers, which a start that
589
+ * fails never does.
590
+ *
591
+ * @example
592
+ * ```ts
593
+ * import type { AgentEngine } from "@mountaya/elements/agent";
594
+ *
595
+ * declare const engine: AgentEngine;
596
+ * declare const report: (failure: unknown, openedRun: string | null) => void;
597
+ *
598
+ * engine.start("Plan a loop", "organization-id").catch((failure: unknown) => {
599
+ * report(failure, engine.runId());
600
+ * });
601
+ * ```
602
+ */
603
+ runId(): string | null;
604
+ /**
605
+ * send delivers a follow-up user message into the open run. It only posts the
606
+ * input (the persistent consumer opened by start/resume carries this turn's
607
+ * events), so it does NOT open a second stream.
608
+ *
609
+ * A message sent while a {@link start} still waits on its run id is held until the id
610
+ * arrives, then posted into that run, behind the opening of its stream and in the order the
611
+ * messages were sent. A start settles only when its run is over, so a caller has no promise
612
+ * to wait on before the next message. When that start opens no run (it fails, or a
613
+ * {@link close}, a {@link dispose} or a later start or {@link resume} withdraws it), the
614
+ * held message is dropped and the promise resolves: the start's rejection, or the call that
615
+ * withdrew it, already says the conversation did not open, and a second report of one
616
+ * failure is one too many.
617
+ *
618
+ * The state is `running` from the call the engine takes, reported through
619
+ * `onStateChange("running")` when the run was at rest, so the turn's settle is a change the
620
+ * observer hears even when the turn sends no frame of its own. A message the engine refuses
621
+ * changes nothing. When the post fails, the engine reports `awaiting_input` again before the
622
+ * promise rejects, unless another message is still being posted, one of them landed, or the
623
+ * stream has reported a state since: the turn is then the stream's to settle.
624
+ *
625
+ * The report is made ahead of the post, and the message goes into the run it found at the
626
+ * call. A {@link close}, a {@link dispose}, a {@link start} or a {@link resume} of another run
627
+ * made from inside that report takes the run from the message: nothing is posted and the
628
+ * promise resolves, as it does for a message held behind a start that opens no run. A
629
+ * {@link resume} of the same run keeps the message, and its turn is the stream's to settle.
630
+ * A send made from inside that report is posted after the message that reported, so two
631
+ * messages reach the run in the order they were sent.
632
+ *
633
+ * @throws {MountayaElementsError} when no run is being read and none is on its way: on an
634
+ * engine that never opened one, and once the run has ended, been closed or been disposed.
635
+ * A run that ended takes no more messages, and one the engine has stopped reading would
636
+ * answer to nobody, so the refusal is local rather than a request the gateway refuses. It
637
+ * is the package's own error and no stream fault, because it is a misuse of this package,
638
+ * which is what a consumer catching {@link MountayaElementsError} is catching. The next
639
+ * message goes into a run a new {@link start} opens, except on a disposed engine, which
640
+ * opens no more runs: the conversation continues on a new engine.
641
+ */
642
+ send(message: string): Promise<void>;
643
+ /**
644
+ * reads reports whether `runId` is still the run this engine reads: the engine is neither
645
+ * disposed nor ended, and no start or resume has put another run in its place.
646
+ */
647
+ private reads;
648
+ /**
649
+ * routedManifest renders the wire manifest for whatever the toolSurface seam
650
+ * currently selects, or the whole permitted set when no router is wired.
651
+ */
652
+ private routedManifest;
653
+ /**
654
+ * routedServerTools renders the server-tool allowlist for whatever the
655
+ * toolSurface seam currently selects: the routed name set verbatim, sorted so
656
+ * the wire body and the change key are stable across identical selections.
657
+ * The gateway ignores the client-tool names in it, so no registry knowledge
658
+ * is needed here. Undefined when no router is wired: the run then keeps
659
+ * every server tool. Undefined as well unless the session routes server tools
660
+ * ({@link AgentEngineConfig.routesServerTools}): under a publishable key a run
661
+ * calls none, and a list naming any is refused, so none is sent.
662
+ */
663
+ private routedServerTools;
664
+ /**
665
+ * routeTools re-reads the toolSurface seam and, when it has moved, replaces the
666
+ * tool set the run offers the model from its next turn on. The model then
667
+ * chooses among a coherent handful for the task at hand instead of the whole
668
+ * registry.
669
+ *
670
+ * It narrows only what the model can SEE. Every tool stays registered on the
671
+ * bus and dispatchable by a human click or an internal tool chain, and the
672
+ * capability gate remains the sole authorization boundary, exactly as
673
+ * `agentHidden` behaves.
674
+ *
675
+ * An unchanged selection sends nothing. That is not just a saved request: the
676
+ * tool array is the outermost part of the provider's cached prompt prefix, so a
677
+ * manifest re-sent on every turn would invalidate the cache every turn and cost
678
+ * far more than routing saves. "Unchanged" means changed since the run last
679
+ * ACCEPTED a set, so a selection whose POST failed is retried on the next call
680
+ * rather than treated as delivered.
681
+ *
682
+ * It is a no-op before a run exists, rather than a throw: routing is advisory,
683
+ * and a surface change while the panel is idle should cost nothing, since the
684
+ * next start() sends the current selection as the run's seed anyway.
685
+ *
686
+ * While a {@link start} still waits on its run id, the seed is already on its way, so the
687
+ * call waits for the run as {@link send} does and then routes it with the selection the
688
+ * surface holds by then. A routing update and a message held behind one start are released
689
+ * in the order they were called, neither waiting on the other's answer, so a caller that
690
+ * needs the selection in the run ahead of its message awaits routeTools() before it calls
691
+ * {@link send}. When that start opens no run, nothing is sent.
692
+ */
693
+ routeTools(): Promise<void>;
694
+ /**
695
+ * close asks the run to finish. It POSTs a close so the gateway finishes the
696
+ * run successfully (a terminal `done` event), AND aborts the open stream so a
697
+ * consumer parked between turns unwinds promptly rather than waiting on the
698
+ * gateway to close the connection. The terminal `done`, when it arrives first,
699
+ * ends the session.
700
+ *
701
+ * It closes a run the engine stopped reading on its own just the same: one it gave
702
+ * up on at the reconnect ceiling, after two minutes of opens answered 503 or on an
703
+ * open refused for good, which the gateway would otherwise hold open until its own
704
+ * timeout. A run is closed at most once, and a run that read its `done` is closed
705
+ * never: a second call, and a call after `done`, post nothing. So does a call after
706
+ * {@link dispose}, which leaves the run it was reading to the host.
707
+ *
708
+ * During a start that still waits on its run id, close withdraws the start and
709
+ * resolves at once, and the start finishes the run it opens (see {@link start}).
710
+ */
711
+ close(): Promise<void>;
712
+ /**
713
+ * dispose tears the session down without signalling the gateway: it aborts the
714
+ * open stream and marks the run ended, releasing the parked consumer. The host
715
+ * calls it on unmount AFTER close() has POSTed (a closed tab finishes the run),
716
+ * with the abort as the backstop when the consumer would otherwise leak.
717
+ *
718
+ * It is the engine's shutdown latch: {@link start} and {@link resume} open nothing
719
+ * afterwards. What it can still cause is what a start sends to finish the run whose id the
720
+ * host never received, when it was withdrawn or gave up at its ceiling: that run's close,
721
+ * and, when the start's answer was lost, the one last post of the start that names the run
722
+ * (see {@link start}).
723
+ *
724
+ * The run the engine was reading, or stopped reading on its own, is the host's from here:
725
+ * the host holds its id, so it can resume it or close it, and a later {@link close} on
726
+ * this engine posts nothing for it.
727
+ */
728
+ dispose(): void;
729
+ /**
730
+ * leaveRun stops the engine reading what it reads, before a {@link start} or a
731
+ * {@link resume} reads a run: one engine reads one run. A start still waiting on its run
732
+ * id is withdrawn. A run still being read has its stream torn down, so none of its frames,
733
+ * its resume cursor or its `done` reach the run read next. A close is posted for the run the
734
+ * engine still owes one (see `unfinishedRunId`): the run it was reading, and the run it
735
+ * stopped reading on its own, because in both cases the engine was the one party reading
736
+ * it. `next` names the run about to be read, and that run is spared the close when it is
737
+ * the one owed it: a resume of it reads it again.
738
+ */
739
+ private leaveRun;
740
+ /**
741
+ * withdrawStart withdraws the start still waiting on its run id, if one is: that start then
742
+ * finishes the run it opens instead of reading it (see {@link start}), and every message
743
+ * and routing update held behind it is dropped (see {@link send}).
744
+ */
745
+ private withdrawStart;
746
+ /**
747
+ * beginRun readies the engine to read a new run once {@link leaveRun} has stopped it
748
+ * reading the last one. The run id, the resume cursor and the stream handle belong to that
749
+ * run, so all three go, and the state returns to `awaiting_input`: `ended` would stop the
750
+ * read loop before it opened anything.
751
+ *
752
+ * The rest is the engine's own and is reported to nobody here. A {@link resume} reports it,
753
+ * since its run may rest for good. A {@link start} reports `running` next, or the rest once
754
+ * it fails, so a start that replaces a run under way is one turn after another to the
755
+ * observer and no rest between them ({@link reportState}).
756
+ *
757
+ * @returns The generation of the read being readied, which a later start or resume replaces.
758
+ */
759
+ private beginRun;
760
+ /**
761
+ * adoptRun makes `runId` the run this engine reads, and the run it owes a close until the
762
+ * run's `done` arrives or a close is posted. The memory of handled calls, and of the calls
763
+ * the engine reported among them, belongs to one run, because call ids are the run's own: it
764
+ * is kept when the run is the one already read (a resume of it) and emptied for any other.
765
+ */
766
+ private adoptRun;
767
+ /**
768
+ * claimCall records a call id as handled and reports whether the frame that names it is
769
+ * the engine's to act on. Two frames are not, and each is dropped whole:
770
+ *
771
+ * - one whose id the run already sighted, a replay of a call the engine ran or answered
772
+ * itself, whose result is already posted;
773
+ * - one the stream marks `settled`, a replay of a call whose outcome the stream already
774
+ * holds. An engine built after a page reload has no memory of the run, so the marker is
775
+ * all that tells it the call was answered.
776
+ *
777
+ * A settled id is recorded like any other, so a later frame that names it without the
778
+ * marker runs nothing either. A replayed frame with no marker and an id never sighted is
779
+ * one the stream holds no outcome for, and is the engine's.
780
+ */
781
+ private claimCall;
782
+ /**
783
+ * closeQuietly posts a close for a live run the engine leaves behind: one a withdrawn start
784
+ * opened and never read, whose id the host never received, and one a later start or resume
785
+ * replaced. A failed post is dropped: nobody is
786
+ * left to tell, and the gateway completes a run that goes quiet on its own.
787
+ */
788
+ private closeQuietly;
789
+ /**
790
+ * releaseSubscription stops callback delivery from the open stream, exactly
791
+ * once. It reads the handle out and clears it BEFORE invoking it, so a
792
+ * re-entrant settle (the abort listener firing synchronously inside
793
+ * teardownStream, or a transport calling back into onClose) finds nothing
794
+ * left to release rather than calling the same handle twice.
795
+ */
796
+ private releaseSubscription;
797
+ /**
798
+ * teardownStream releases the open events stream from both sides: the
799
+ * unsubscribe stops callback delivery (covering the scripted drain, which has
800
+ * no fetch to abort), and the abort closes the live fetch (and trips the resume
801
+ * detection in run()). Idempotent, so close() followed by dispose() is harmless.
802
+ *
803
+ * The unsubscribe runs FIRST because abort() dispatches its listener
804
+ * synchronously: that listener settles the read and clears the handle, so
805
+ * aborting first would leave nothing to unsubscribe and the scripted drain
806
+ * would stay parked for the life of the process.
807
+ */
808
+ private teardownStream;
809
+ /**
810
+ * run consumes the run's event stream to completion, reconnecting when the
811
+ * stream closes before a terminal event. The gateway may close an SSE
812
+ * connection between turns (e.g. after `awaiting-input`); rather than leave the
813
+ * run silently stuck, run re-opens the stream from the tracked Last-Event-ID so
814
+ * the conversation continues. It returns once a terminal event ends the run, an
815
+ * abort tears the stream down, or the reconnects stop being productive: an open that
816
+ * closes having said nothing or one frame waits on the reconnect schedule, and the
817
+ * attempt ceiling below bounds how many of them in a row the run is given.
818
+ *
819
+ * A read that FAILS is judged by {@link isTransientStreamFault}. A transient one (a
820
+ * dropped connection, a 429, 503 or 504 at open) reopens from the last id on the same
821
+ * schedule and under the same ceiling as a hangup, and when the ceiling is reached on a
822
+ * read that failed, that failure (the drop, or the 429 or 504) is what the caller
823
+ * receives. The client's own reader reports an open that never answers and a stream gone
824
+ * silent as dropped connections, so both reopen. Any other failure ends the read at once and
825
+ * rejects with it. Either way the state is `ended` before the rejection, because the engine
826
+ * has stopped reading the run, and the run is owed a close (see {@link close}).
827
+ *
828
+ * An open answered 503 reopens on that schedule and outside that ceiling: it is left out of
829
+ * the count, neither adding to it nor clearing it, and such opens are bounded by
830
+ * {@link RECONNECT_UNAVAILABLE_MAX_MS} from the first of them, past which the caller receives
831
+ * the 503. A turn that moves starts the count and that time again.
832
+ *
833
+ * A stream that ends with the credential it was opened with, or that the API could not keep
834
+ * delivering (`interrupted`), reopens at once from the last id, and clears the count of
835
+ * fruitless opens: the transport closes either as `reconnect`, and the reopen carries the
836
+ * session token the client holds by then. A 401 on that reopen is a failure like any other
837
+ * refusal, and ends the read.
838
+ *
839
+ * A teardown ends the read wherever it finds it, the backoff between two opens included:
840
+ * a close or a dispose, and a start or a resume that replaced this run (see
841
+ * {@link leaveRun}).
842
+ */
843
+ private run;
844
+ /**
845
+ * backoff waits out one reconnect delay, drawn by {@link reconnectDelayMs} on the run's
846
+ * {@link reconnectSchedule}: below a ceiling that doubles from AGENT_RECONNECT_BASE_MS to
847
+ * RECONNECT_MAX_MS, so the wait stays inside a person's patience and runs dropped together
848
+ * do not reopen together. Where the failure was a 429 or a 503 that named its wait (`namedMs`),
849
+ * that wait replaces the draw, with up to a second drawn above it and the timer's ceiling over
850
+ * it ({@link retryAfterDelayMs}), as SPEC §2 has `Retry-After` replace the schedule. It settles
851
+ * on whichever comes first, the timer or the stream teardown's abort, and drops both hooks
852
+ * either way: a run that reconnects many times must not accumulate listeners on the signal, nor
853
+ * leave a timer holding the loop after the session is gone.
854
+ */
855
+ private backoff;
856
+ /**
857
+ * consume opens one read of the run's events stream and settles when it
858
+ * finishes, bridging the transport's AgentStreamHandlers callbacks to a single
859
+ * promise run() can await. It reacts to each decoded frame and records its id as
860
+ * the resume position when the frame arrives, taking it back when the frame's handling
861
+ * throws; the transport has already validated every frame, so it trusts the typed
862
+ * event. Unlike a per-turn drive it does NOT stop on
863
+ * `awaiting-input` (the stream stays open for the next message). It resolves
864
+ * with whether a terminal event ended the run and how many frames the stream
865
+ * delivered, so the caller can decide between reconnecting and settling and
866
+ * tell a productive open from a fruitless one, and with the failure when the
867
+ * read failed. It never rejects, a transport that throws from the open included:
868
+ * whether a failure ends the run is run()'s call.
869
+ * A terminal the SESSION decides (handle returning true on `done`) tears the
870
+ * subscription down here so no further frame is processed after the run is
871
+ * over. A teardown's abort (a close, a dispose, or a start or resume that replaced
872
+ * the run) settles the promise on its own (the transport fires no callback on a
873
+ * deliberate abort), so run() unwinds without waiting on a dead stream.
874
+ *
875
+ * It is one closure on purpose. Every handler reads and writes this read's own settle
876
+ * latch and frame count, and held as fields they would be the next read's to reach.
877
+ */
878
+ private consume;
879
+ /**
880
+ * handle reacts to one event of the run `runId` names and reports whether the run
881
+ * ended (so consume can stop). An active-turn event (streamed text, a tool call, a
882
+ * confirm request) flips the lifecycle to `running`; a client tool-call is dispatched
883
+ * through the bus and its result posted back; a confirm-required is routed through
884
+ * the host gate and the decision posted back. Both answers go to `runId`, the run that
885
+ * asked, even when a later start or resume replaced it while the tool ran or the host
886
+ * decided. A tool-call or a confirm-required that {@link claimCall} refuses, one the
887
+ * stream marks `settled` or one the run already handled, is dropped whole: it reaches
888
+ * neither the bus, the gate nor the observer, and leaves the lifecycle as it is. An
889
+ * `awaiting-input` event settles the turn to the `awaiting_input` state but
890
+ * keeps the stream open (returns false); only a terminal `done` ends the run (returns
891
+ * true).
892
+ */
893
+ private handle;
894
+ /**
895
+ * handleToolCall runs one client tool call through the bus, reports it to the observer and
896
+ * posts its result back into the run that asked. It answers false: a tool call never ends
897
+ * the run.
898
+ *
899
+ * The call is running from its claim to its report. What the stream says of it meanwhile is
900
+ * held ({@link holdWhileRunning}), and released when the handling throws before the report:
901
+ * the engine has no report of its own then, and the stream's word settles the host's row.
902
+ */
903
+ private handleToolCall;
904
+ /**
905
+ * releaseHeldWord takes a call out of the running set and delivers what the stream said of it
906
+ * while it ran, when it said anything. A call the engine reported is out of the set already,
907
+ * and so is every call of a run the engine no longer holds the memory of: both release
908
+ * nothing.
909
+ */
910
+ private releaseHeldWord;
911
+ /**
912
+ * holdWhileRunning keeps what the stream says of a call the engine is still running, as the
913
+ * report it would have made, and answers whether it did. The first word is the one kept: a
914
+ * failed `tool-result` follows the `tool-abandoned` of a call the run gave up on.
915
+ */
916
+ private holdWhileRunning;
917
+ /** runToolCall is the handling of a claimed client tool call: see {@link handleToolCall}. */
918
+ private runToolCall;
919
+ /**
920
+ * handleConfirmRequired puts a server tool's confirmation to the host gate and posts the
921
+ * decision back into the run that asked. It answers false: a confirmation never ends the
922
+ * run.
923
+ */
924
+ private handleConfirmRequired;
925
+ /**
926
+ * handleDone reports how the run ended and ends the read, unless a start or a resume made
927
+ * from the callback has already replaced it. It answers true: `done` is the one terminal.
928
+ */
929
+ private handleDone;
930
+ /**
931
+ * handleToolResult reports a call's outcome as the stream states it, unless the call is one
932
+ * the engine ran and reported itself. It answers false.
933
+ */
934
+ private handleToolResult;
935
+ /**
936
+ * handleToolAbandoned reports a call the run gave up on, unless the call is one the engine
937
+ * ran and reported itself. It answers false.
938
+ */
939
+ private handleToolAbandoned;
940
+ /**
941
+ * setState records the lifecycle transition and notifies the observer only on
942
+ * an actual change, so the host does not re-render on a no-op.
943
+ *
944
+ * Every report, a no-op included, drops the hold the sends being posted have on `running`:
945
+ * whatever speaks here (a frame, a close, a new run) owns the state from then on. A send
946
+ * reports its own `running` through {@link reportState}, which keeps the hold.
947
+ */
948
+ private setState;
949
+ /**
950
+ * reportState is {@link setState} without the drop of the hold, for the one report that is
951
+ * the hold's own: the `running` of a send.
952
+ *
953
+ * The observer is told a state that differs from the one it was told last, which is the
954
+ * engine's own state but while a start readies its run ({@link beginRun}).
955
+ */
956
+ private reportState;
957
+ /**
958
+ * tell hands the observer one report. The observer answers nothing the run waits on, so a
959
+ * callback that throws is a defect of the host's own rendering and never the run's: its fault
960
+ * reaches the program through {@link surfaceFault}, and the read goes on.
961
+ */
962
+ private tell;
963
+ /**
964
+ * postInput sends one input frame back into the run `runId` names, the run that asked
965
+ * for it, and reports a failure as a fault in the conversation instead of throwing.
966
+ *
967
+ * The catch is the point. `start()` ends with `await this.run(runId)`, so the whole
968
+ * consume loop lives inside the start promise, and an unguarded rejection here would
969
+ * leave `handle()` as a fault of the engine's own: the read would end for good, and
970
+ * `start()` would reject into the host's START error path. A network blip on turn
971
+ * twelve would then render "could not start", clear the started guard and drop the run
972
+ * id, so the still-alive gateway run could never be resumed and the model's call would
973
+ * expire as `tool-abandoned` with the user told nothing true about why.
974
+ *
975
+ * Reporting and continuing is the right shape: the run is still open, the stream is
976
+ * still readable, and the gateway abandons the unanswered call on its own timeout so
977
+ * the model can replan. What is lost is one tool result, which is a turn-level fault,
978
+ * not a session-level one. A run a later start or resume replaced has nobody reading
979
+ * it, so a failure to answer it is dropped rather than reported into the run that
980
+ * replaced it. So is a failure to answer a run the engine has stopped reading, after a
981
+ * {@link close} or a {@link dispose}: the host ended that conversation, and an error line
982
+ * under it would report a fault in a run nobody is in.
983
+ *
984
+ * The message is deliberately empty. A fetch rejection carries an English,
985
+ * internal string, and the host resolves an empty message to its own localized
986
+ * generic line, the same rule the run's other self-raised terminals follow.
987
+ */
988
+ private postInput;
989
+ }
990
+ /**
991
+ * AgentBudgetCopy is the per-dimension usage-limit copy resolveAgentError chooses
992
+ * between when a run ends on a budget ceiling: one line for each exhausted
993
+ * dimension the gateway reports (`turns` / `cost`) plus a `generic` fallback for an
994
+ * unrecognized dimension. Every line explains the conversation reached its limit
995
+ * and that a new chat continues the work.
996
+ */
997
+ interface AgentBudgetCopy {
998
+ cost: string;
999
+ generic: string;
1000
+ turns: string;
1001
+ }
1002
+ /**
1003
+ * AgentDraftWarning is the unsaved-work annexe a budget line carries when, and
1004
+ * only when, the surface that ran actually owns a draft. `note` warns that
1005
+ * unsaved work is still on the map and is appended to whichever dimension line
1006
+ * applies, because every one of them tells the user to start a new chat, which is
1007
+ * the action that loses the draft; `open` is whether one is armed right now.
1008
+ *
1009
+ * It is a separate argument rather than a field on {@link AgentBudgetCopy} because it
1010
+ * is not per-surface phrasing of the same thing: a surface that can never arm an
1011
+ * edit session has no draft to warn about, and omitting the argument says so far
1012
+ * more honestly than supplying copy that can never be reached.
1013
+ */
1014
+ interface AgentDraftWarning {
1015
+ note: string;
1016
+ open: boolean;
1017
+ }
1018
+ /**
1019
+ * AgentErrorCopy is the localized copy resolveAgentError chooses between for a
1020
+ * terminal agent error. The caller passes the already-translated strings so the
1021
+ * resolver stays a pure, i18n-free mapping that is trivial to unit-test.
1022
+ */
1023
+ interface AgentErrorCopy {
1024
+ /**
1025
+ * The line for a run the gateway stopped because the member who started it may not run it in
1026
+ * its organization any more, for either of the two causes the code carries: they hold no write
1027
+ * role there (they left it, or their role reads only), or the organization's agreement does
1028
+ * not include Map Studio. One line answers both, so it names the loss of access and not a cause.
1029
+ */
1030
+ accessRevoked: string;
1031
+ budget: AgentBudgetCopy;
1032
+ generic: string;
1033
+ looping: string;
1034
+ notConfigured: string;
1035
+ rateLimited: string;
1036
+ }
1037
+ /**
1038
+ * resolveAgentError maps a terminal agent error onto the copy shown as the error
1039
+ * turn in the transcript.
1040
+ *
1041
+ * A known machine `code` wins localized copy (`rate-limited` → the busy message,
1042
+ * `ai-provider-not-configured` → the setup message, `looping` → the repeated-action message,
1043
+ * `access-revoked` → the lost-access message, `budget-exhausted` → per-dimension usage-limit copy
1044
+ * chosen from the reason carried in `message`). An unknown or absent code surfaces the provider's
1045
+ * own error message verbatim, trimmed, when the gateway forwarded a non-empty one, and the generic
1046
+ * fallback otherwise. The gateway sends the provider's error text in the SSE `error` event, so a
1047
+ * code the host does not localize still reads meaningfully instead of collapsing to the generic
1048
+ * line: the assistant "replies" with what actually went wrong.
1049
+ *
1050
+ * @param message The error's text, or the exhausted dimension (`turns` or `cost`) when
1051
+ * `code` is `budget-exhausted`.
1052
+ * @param code The machine-readable reason the run error carries, absent for a fault the
1053
+ * engine raised itself.
1054
+ * @param copy The already-translated lines to choose between.
1055
+ * @param draft The unsaved-work annexe of a surface that owns a draft; its `note` is
1056
+ * appended to a budget line while `open` is true. A surface that can never arm an edit
1057
+ * omits it.
1058
+ * @returns The line to show as the error turn.
1059
+ */
1060
+ export declare const resolveAgentError: (message: string, code: string | undefined, copy: AgentErrorCopy, draft?: AgentDraftWarning) => string;
1061
+ /**
1062
+ * MAX_TOOL_INPUT_CHARS bounds the pretty-printed tool input captured on an
1063
+ * activity row, so a large payload never bloats the transcript store or the
1064
+ * expanded details block. A run touches many tools; keeping each captured input
1065
+ * small keeps the whole conversation cheap to hold and render.
1066
+ */
1067
+ export declare const MAX_TOOL_INPUT_CHARS = 2000;
1068
+ /**
1069
+ * boundedInputJson pretty-prints a tool call's raw input for an activity row's
1070
+ * expandable details, bounded to {@link MAX_TOOL_INPUT_CHARS} with a trailing
1071
+ * ellipsis when it overflows. The bound counts UTF-16 units of the JSON, the ellipsis
1072
+ * follows it, and a character the bound would split in two is left out whole.
1073
+ *
1074
+ * The input arrives as `unknown` off the wire (the model's tool arguments), so this
1075
+ * stays defensive by design: the row omits the input block rather than throwing on a
1076
+ * pathological payload.
1077
+ *
1078
+ * @returns The bounded JSON, or null when the value cannot be serialized: a cyclic
1079
+ * object or a bigint throws, and a bare `undefined`, function or symbol serializes to
1080
+ * nothing.
1081
+ */
1082
+ export declare const boundedInputJson: (input: unknown) => string | null;
1083
+ /**
1084
+ * ConversationState is the reactive core an AI conversation renders against: its
1085
+ * run id (null until a run opens), the run lifecycle the surface renders against,
1086
+ * and the role-structured transcript. The transcript entry type is a parameter so
1087
+ * a surface can carry its own turn shape (a chat that records tool actions as
1088
+ * their own rows, or one that holds only spoken turns) while sharing the run id,
1089
+ * lifecycle and transcript spine and the streaming helpers that grow it.
1090
+ */
1091
+ interface ConversationState<E> {
1092
+ runId: string | null;
1093
+ state: AgentEngineState;
1094
+ transcript: E[];
1095
+ }
1096
+ /**
1097
+ * TranscriptRole tags a transcript entry as the user's message, the assistant's
1098
+ * reply, an assistant-side error, an agent tool action, or an assistant-side
1099
+ * warning, so a chat surface renders each turn with its own role styling rather
1100
+ * than one concatenated string. An error turn renders as an inline alert in the
1101
+ * assistant's lane: the failure reads as the reply to that turn and stays in the
1102
+ * conversation's history rather than a transient banner. An activity turn is a
1103
+ * permanent, collapsible row for one tool action, so nothing the run did flashes
1104
+ * and vanishes. A warning turn is informational and non-terminal: the run is
1105
+ * still healthy, but something about the reply above it deserves the user's
1106
+ * scepticism, and rendering it as an error would claim a failure that did not
1107
+ * happen. A question turn is the assistant asking the user to pick between
1108
+ * options, rendered as buttons instead of prose the user must answer by typing.
1109
+ * A suggestions turn is a generated route-candidate batch rendered as an
1110
+ * interactive list (the conversation's own suggestions panel), where hovering a
1111
+ * row previews its route on the map and picking one stages it for editing.
1112
+ */
1113
+ type TranscriptRole = "activity" | "assistant" | "error" | "question" | "suggestions" | "user" | "warning";
1114
+ /**
1115
+ * ActivityStatus is the lifecycle of a tool-action row: `running` from the moment
1116
+ * the call is emitted, then one of `ok` / `error` / `abandoned` once it settles.
1117
+ * The row's status icon reads off this.
1118
+ */
1119
+ type ActivityStatus = "abandoned" | "error" | "ok" | "running";
1120
+ /**
1121
+ * MessageEntry is a spoken turn (the user's message, the assistant's reply, or an
1122
+ * assistant-side error), carrying a stable id (a render key that survives token
1123
+ * accumulation, since the running assistant entry is rebuilt as tokens arrive) and
1124
+ * the text said in that turn. Assistant entries accumulate streamed tokens under
1125
+ * one id; user and error entries are appended whole.
1126
+ */
1127
+ interface MessageEntry {
1128
+ content: string;
1129
+ id: string;
1130
+ /**
1131
+ * The reply's zero-based position among the run's assistant messages, as the run
1132
+ * itself reported it, so a rating on this turn names the message the API will
1133
+ * see.
1134
+ *
1135
+ * Present on assistant turns the run numbered, absent on every other role and on a
1136
+ * reply from a gateway that sends no index: a reader falls back to counting the
1137
+ * replies it holds for those. That fallback is why the field is worth carrying at
1138
+ * all: counting locally is right until a reload mid-run, which rebuilds no
1139
+ * transcript, so the count restarts at zero while the conversation is already
1140
+ * several answers in.
1141
+ */
1142
+ messageIndex?: number | undefined;
1143
+ role: "assistant" | "error" | "user";
1144
+ }
1145
+ /**
1146
+ * ActivityEntry is a permanent transcript row for one agent tool action, keyed by
1147
+ * the tool call id (the stable render key), sitting at the action's chronological
1148
+ * position. It starts `running` and settles in place: `name` is the tool called,
1149
+ * `input` the bounded pretty-printed JSON captured at append (null when it could
1150
+ * not be serialized), `label` the settled human summary, and `error` the failure
1151
+ * text. A server tool the host saw no call for is appended already-settled, so its
1152
+ * `name`/`input` are null.
1153
+ */
1154
+ interface ActivityEntry {
1155
+ /**
1156
+ * Why an abandoned action was given up on. `timeout` means nothing came back
1157
+ * within the run's window, which usually means this browser went away or the tool
1158
+ * hung; `closed` means the run was stopped while the action was still outstanding,
1159
+ * which is the user's own doing and not a fault. Null on every other status.
1160
+ */
1161
+ abandonedReason: "timeout" | "closed" | null;
1162
+ error: string | null;
1163
+ id: string;
1164
+ /**
1165
+ * What the run will try about this failure, from the tool's playbook entry.
1166
+ * Null when the tool succeeded, or when the playbook has nothing for that
1167
+ * (tool, code) pair. It turns a silent retry into something the user can see the
1168
+ * shape of, which is the difference between the co-pilot looking stuck and
1169
+ * looking like it is working.
1170
+ */
1171
+ recovery: string | null;
1172
+ input: string | null;
1173
+ label: string | null;
1174
+ name: string | null;
1175
+ role: "activity";
1176
+ status: ActivityStatus;
1177
+ }
1178
+ /**
1179
+ * WarningEntry is an informational transcript row: the run answered, and the
1180
+ * workspace does not back part of what the answer claims. It carries the authored
1181
+ * criterion sentences verbatim: they were written for the user, and the row's
1182
+ * job is to hand them over, not to summarize them. Appended whole, never settled
1183
+ * or amended: the settle machinery is for tool actions, and a shortfall the run
1184
+ * publishes once is a fact about that moment.
1185
+ */
1186
+ interface WarningEntry {
1187
+ id: string;
1188
+ lines: readonly string[];
1189
+ role: "warning";
1190
+ }
1191
+ /**
1192
+ * QuestionOption is one selectable answer on a question card: the label the
1193
+ * user taps (which becomes their reply verbatim) and an optional one-line
1194
+ * description of what picking it means.
1195
+ *
1196
+ * A question answer is text, so an option stands for nothing the app can act on
1197
+ * beyond the words. Route candidates therefore belong to SuggestionsEntry, whose
1198
+ * options are real staged candidates the host reads off the live session: they
1199
+ * carry metrics that are true rather than retyped, and picking one stages the
1200
+ * route instead of only saying its name.
1201
+ */
1202
+ interface QuestionOption {
1203
+ description: string | null;
1204
+ label: string;
1205
+ }
1206
+ /**
1207
+ * QuestionEntry is a structured question the assistant asked: the question with
1208
+ * its options rendered as buttons, keyed by the asking tool call's id (the
1209
+ * stable render key, and what dedups a replayed frame). `selected` is null
1210
+ * while the question is open; it settles to the picked label when the user taps
1211
+ * an option, or stays null when they answer in their own words instead. Either
1212
+ * way the card goes inert, because an already-answered question that still
1213
+ * offers buttons invites a second answer the run is not waiting for.
1214
+ */
1215
+ interface QuestionEntry {
1216
+ id: string;
1217
+ options: readonly QuestionOption[];
1218
+ question: string;
1219
+ role: "question";
1220
+ selected: string | null;
1221
+ settled: boolean;
1222
+ }
1223
+ /**
1224
+ * SuggestionCardCandidate is one generated route option on a suggestions card:
1225
+ * the seed that names it in the live suggest session (the handle every dispatch,
1226
+ * preview and pick, uses), the distinct color its map line and row swatch share,
1227
+ * and the raw metrics the row renders in the reader's units. Snapshotted from the
1228
+ * session at append so the card keeps rendering after the session moves on; raw
1229
+ * meters/seconds, never formatted strings, because unit formatting is the
1230
+ * reader's preference.
1231
+ */
1232
+ interface SuggestionCardCandidate {
1233
+ ascentMeters: number;
1234
+ color: string;
1235
+ distanceMeters: number;
1236
+ durationSeconds: number;
1237
+ seed: number;
1238
+ }
1239
+ /**
1240
+ * SuggestionsEntry is a generated route-candidate batch rendered as an
1241
+ * interactive list in the conversation: the chat's own suggestions panel. It is
1242
+ * appended by the host when the run's generate settles (host-owned chat state,
1243
+ * like the message bubbles), keyed off the generating tool call's id so a
1244
+ * replayed frame dedups. `chosenSeed` is null while the card is open; it settles
1245
+ * to the picked candidate's seed when the user taps a row, or stays null when
1246
+ * the batch is superseded (a typed reply, a regenerate). Either way the card
1247
+ * goes inert, because an already-decided batch that still offers rows invites a
1248
+ * pick nothing is waiting for.
1249
+ */
1250
+ interface SuggestionsEntry {
1251
+ candidates: readonly SuggestionCardCandidate[];
1252
+ chosenSeed: number | null;
1253
+ id: string;
1254
+ role: "suggestions";
1255
+ settled: boolean;
1256
+ }
1257
+ /**
1258
+ * TranscriptEntry is one turn in a chat's conversation: a spoken message
1259
+ * ({@link MessageEntry}), an agent tool action ({@link ActivityEntry}), an
1260
+ * informational warning ({@link WarningEntry}), a structured question
1261
+ * ({@link QuestionEntry}), or a route-candidate batch
1262
+ * ({@link SuggestionsEntry}), discriminated on `role` so a surface renders each
1263
+ * in its own lane. The studio co-pilot's threads and the video wizard's director
1264
+ * both carry exactly this shape, so the shared transcript renders either
1265
+ * surface's turns.
1266
+ */
1267
+ type TranscriptEntry = ActivityEntry | MessageEntry | QuestionEntry | SuggestionsEntry | WarningEntry;
1268
+ /**
1269
+ * appendQuestionEntry appends one structured question as an open card keyed by
1270
+ * its tool call id. A re-render or a replayed frame can emit the same call
1271
+ * twice; the id keys the card, so a second append for a known id returns the
1272
+ * transcript unchanged. A question with no options appends nothing: it would
1273
+ * render a card the user cannot answer.
1274
+ */
1275
+ export declare const appendQuestionEntry: <T extends readonly TranscriptEntry[]>(transcript: T, question: {
1276
+ options: readonly QuestionOption[];
1277
+ question: string;
1278
+ toolCallId: string;
1279
+ }) => T | TranscriptEntry[];
1280
+ /**
1281
+ * answerQuestionEntry settles the question card carrying the entry id with the
1282
+ * label the user picked. A card that already settled is never re-settled: a
1283
+ * double click races the send, and the first answer is the one that was sent.
1284
+ */
1285
+ export declare const answerQuestionEntry: (transcript: readonly TranscriptEntry[], entryId: string, label: string) => TranscriptEntry[];
1286
+ /**
1287
+ * settleOpenQuestionEntries settles every still-open question card with no
1288
+ * pick. Called when the user answers in their own words: the reply supersedes
1289
+ * the buttons, so they go inert without any option marked as chosen.
1290
+ */
1291
+ export declare const settleOpenQuestionEntries: <T extends readonly TranscriptEntry[]>(transcript: T) => T | TranscriptEntry[];
1292
+ /**
1293
+ * appendSuggestionsEntry appends one route-candidate batch as an open card keyed
1294
+ * off the generating tool call's id. A re-render or a replayed frame can emit
1295
+ * the same settle twice; the id keys the card, so a second append for a known id
1296
+ * returns the transcript unchanged. A batch with no candidates appends nothing:
1297
+ * it would render a card with nothing to pick. A fresh batch supersedes any
1298
+ * still-open one (a regenerate replaced those candidates in the live session),
1299
+ * so prior open suggestions cards settle inert in the same write.
1300
+ */
1301
+ export declare const appendSuggestionsEntry: <T extends readonly TranscriptEntry[]>(transcript: T, suggestions: {
1302
+ candidates: readonly SuggestionCardCandidate[];
1303
+ entryId: string;
1304
+ }) => T | TranscriptEntry[];
1305
+ /**
1306
+ * chooseSuggestionEntry settles the suggestions card carrying the entry id with
1307
+ * the seed the user picked. A card that already settled is never re-settled: a
1308
+ * double click races the staging chain, and the first pick is the one that ran.
1309
+ */
1310
+ export declare const chooseSuggestionEntry: (transcript: readonly TranscriptEntry[], entryId: string, seed: number) => TranscriptEntry[];
1311
+ /**
1312
+ * settleOpenSuggestionEntries settles every still-open suggestions card with no
1313
+ * pick. Called when the user replies in their own words (the reply supersedes
1314
+ * the rows, and the run may be about to regenerate) and by a fresh batch's append:
1315
+ * both leave the old card inert without any candidate marked as chosen.
1316
+ */
1317
+ export declare const settleOpenSuggestionEntries: <T extends readonly TranscriptEntry[]>(transcript: T) => T | TranscriptEntry[];
1318
+ /**
1319
+ * appendWarningEntry appends one informational warning row. Empty lines append
1320
+ * nothing: a warning with nothing to say would render an empty orange box, which
1321
+ * reads as a rendering bug rather than information.
1322
+ */
1323
+ export declare const appendWarningEntry: <T extends readonly TranscriptEntry[]>(transcript: T, lines: readonly string[]) => T | TranscriptEntry[];
1324
+ /**
1325
+ * appendErrorEntry appends one error row carrying a message already resolved for
1326
+ * display. Resolving the copy is the caller's job (the same fault reads
1327
+ * differently depending on which surface it landed on), so this only owns the
1328
+ * entry's shape.
1329
+ *
1330
+ * It exists so every entry kind is minted in this module. The two spoken kinds
1331
+ * would otherwise be hand-rolled at each call site, which is how an entry ends up
1332
+ * with a subtly different shape depending on where it was built.
1333
+ */
1334
+ export declare const appendErrorEntry: <E extends {
1335
+ id: string;
1336
+ role: string;
1337
+ }>(transcript: readonly E[], message: string) => (E | {
1338
+ content: string;
1339
+ id: string;
1340
+ role: "error";
1341
+ })[];
1342
+ /**
1343
+ * appendUserEntry appends one turn the user spoke. It is the counterpart to
1344
+ * {@link appendErrorEntry} and exists for the same reason: the entry's shape is
1345
+ * minted in one place.
1346
+ *
1347
+ * Note it does NOT settle open question or suggestion cards. Whether a new user
1348
+ * turn closes what the run was still asking about is a per-surface product rule
1349
+ * (the co-pilot settles them, the video director has none), so it stays with the
1350
+ * caller rather than being buried in an append.
1351
+ */
1352
+ export declare const appendUserEntry: <E extends {
1353
+ id: string;
1354
+ role: string;
1355
+ }>(transcript: readonly E[], content: string) => (E | {
1356
+ content: string;
1357
+ id: string;
1358
+ role: "user";
1359
+ })[];
1360
+ /**
1361
+ * PendingConfirmation is a destructive tool a run is waiting on the user to
1362
+ * approve or deny, surfaced as an in-chat confirmation card instead of a modal so
1363
+ * a chat surface never raises a fullscreen dialog while it works. `name` is the
1364
+ * tool the gateway (a server tool) or the bus (a client tool) named; `summary` is
1365
+ * the human description of what it does when one was supplied, else null (the
1366
+ * card shows the title alone).
1367
+ */
1368
+ interface PendingConfirmation {
1369
+ name: string;
1370
+ summary: string | null;
1371
+ }
1372
+ /**
1373
+ * appendActivityEntry appends one tool action as a permanent running row keyed by
1374
+ * its call id. A re-render or a replayed frame can emit the same call twice; the
1375
+ * call id keys the row, so a second append for a known id returns the transcript
1376
+ * unchanged rather than a duplicate row. Shared by the co-pilot threads store and
1377
+ * the director store so both record actions with identical semantics.
1378
+ */
1379
+ export declare const appendActivityEntry: <T extends readonly TranscriptEntry[]>(transcript: T, activity: {
1380
+ input: string | null;
1381
+ name: string;
1382
+ toolCallId: string;
1383
+ }) => T | TranscriptEntry[];
1384
+ /**
1385
+ * settleActivityEntry settles the running activity row carrying the call id in
1386
+ * place with the tool's outcome. It searches from the end (the settling row is
1387
+ * the most recently appended one, so a run reusing an id across turns settles the
1388
+ * latest first); an id with no running row (a server tool's, which emits no call
1389
+ * event, or a call the stream marks settled, whose `tool-call` frame the engine
1390
+ * drops) is appended already settled carrying just the outcome; and a terminal row is
1391
+ * never re-settled: a stray second settle (a double result/close race, or a
1392
+ * replayed frame) returns the transcript unchanged rather than flipping an
1393
+ * already-settled row. Shared by both chat stores so the settle semantics never
1394
+ * drift.
1395
+ */
1396
+ export declare const settleActivityEntry: <T extends readonly TranscriptEntry[]>(transcript: T, toolCallId: string, outcome: ToolActivityOutcome) => T | TranscriptEntry[];
1397
+ /**
1398
+ * AssistantTurn is a freshly-minted assistant reply: a stable render key (which
1399
+ * survives token accumulation, since the running reply is rebuilt as tokens
1400
+ * arrive) and the text said so far. It is the turn {@link accumulateAssistant}
1401
+ * and {@link replaceAssistant} append when the last transcript entry was NOT the
1402
+ * assistant's, so both helpers return it alongside the caller's own entry type.
1403
+ */
1404
+ interface AssistantTurn {
1405
+ content: string;
1406
+ id: string;
1407
+ /**
1408
+ * The reply's zero-based position among the run's assistant messages, set from the
1409
+ * settled `message` event. Absent while the turn is still accumulating tokens (the
1410
+ * run numbers a message when it completes one, not per token), and absent for a
1411
+ * reply from a gateway that sends no index.
1412
+ */
1413
+ messageIndex?: number | undefined;
1414
+ role: "assistant";
1415
+ }
1416
+ /**
1417
+ * mintEntryId mints a stable render key for a new transcript entry, as {@link localId} mints
1418
+ * one: a version 4 UUID where the runtime draws one, outside a secure context too, and an id
1419
+ * counted in the page where it has no cryptographic source.
1420
+ */
1421
+ export declare const mintEntryId: () => string;
1422
+ /**
1423
+ * accumulateAssistant appends a streamed delta to the last assistant entry,
1424
+ * keeping its id so the running turn's render key is stable across tokens, or
1425
+ * starts a new assistant entry when the last turn was NOT the assistant's (a user
1426
+ * turn or an interleaved error/action). Keying on the last entry's role means a
1427
+ * non-assistant turn breaks the accumulation chain: a delta from a retry after an
1428
+ * error starts a fresh assistant entry rather than growing the reply that
1429
+ * preceded the error. This rebuilds the running assistant turn as tokens arrive
1430
+ * without concatenating across turns.
1431
+ *
1432
+ * A SETTLED assistant turn also breaks the chain. A turn carries a `messageIndex`
1433
+ * only once its `message` event has completed it, so an index on the last entry
1434
+ * means the next delta belongs to a different reply. Without that check, two
1435
+ * assistant turns with nothing between them (which the run produces when it
1436
+ * continues itself, e.g. after a response cut at the provider's length ceiling)
1437
+ * would grow the finished reply with the next one's tokens.
1438
+ */
1439
+ export declare const accumulateAssistant: <E extends {
1440
+ id: string;
1441
+ role: string;
1442
+ }>(transcript: readonly E[], delta: string) => (E | AssistantTurn)[];
1443
+ /**
1444
+ * replaceAssistant sets the last assistant turn's full text (a settled `message`
1445
+ * event), keeping its id, or starts a new assistant entry when the last turn was
1446
+ * NOT the assistant's (a user turn or an interleaved error/action), or was the
1447
+ * assistant's but is a different reply than the one arriving.
1448
+ *
1449
+ * `messageIndex` is the reply's position among the run's assistant messages, carried
1450
+ * onto the turn so a rating on it names the message the API will see. It is
1451
+ * omitted by a caller whose gateway sends no index, which leaves the field absent and
1452
+ * the reader counting its own replies for that turn.
1453
+ *
1454
+ * That same index is what keeps a REPLAY readable. Reconnecting to a run after a reload
1455
+ * replays its whole event history: the new session holds no stream position and the host
1456
+ * passes it none, deliberately so, because a position expires, bloats the per-thread URL
1457
+ * that carries the run, and even a valid one would deliver only the tail, leaving the
1458
+ * reader with a conversation that starts mid-sentence. (A session that re-attaches to the
1459
+ * run it was already reading keeps its own position and is handed nothing twice.) So a
1460
+ * reload hands this helper N settled messages back to back,
1461
+ * with nothing between them to break the chain, and replacing in place would collapse
1462
+ * every one of the run's replies into a single bubble showing only the last.
1463
+ *
1464
+ * What a replay still cannot rebuild is the USER's turns: they are appended by the
1465
+ * host as the message is submitted, not carried as stream frames, so a replayed
1466
+ * conversation reads as the assistant's side alone. Restoring both sides needs the
1467
+ * run's transcript read back from the API rather than reconstructed from its events.
1468
+ */
1469
+ export declare const replaceAssistant: <E extends {
1470
+ id: string;
1471
+ role: string;
1472
+ }>(transcript: readonly E[], content: string, messageIndex?: number) => (E | AssistantTurn)[];
1473
+ /**
1474
+ * ConversationWriter is the narrow store surface a fault writes through: the
1475
+ * error turn it appends, the run id it drops, and the lifecycle state it parks
1476
+ * the conversation on. Deliberately three methods and no key: a multi-chat
1477
+ * surface binds one writer per thread and a single-conversation surface binds an
1478
+ * unkeyed one, so which conversation is being written stays entirely with the
1479
+ * caller and never enters this module.
1480
+ */
1481
+ interface ConversationWriter {
1482
+ appendError(message: string): void;
1483
+ setRunId(runId: string | null): void;
1484
+ setSessionState(state: AgentEngineState): void;
1485
+ }
1486
+ /**
1487
+ * ConversationFaultCopy is the already-localized copy a fault surfaces, so this
1488
+ * module stays a pure, i18n-free mapping. generic covers a transport fault and
1489
+ * any unrecognized start failure; missingOrganization is the surface-specific
1490
+ * hint shown when no organization can scope the run (the co-pilot names the
1491
+ * resource to open, the director names the itinerary still loading); noAccess,
1492
+ * notConfigured and notEntitled are the gating failures the gateway reports by status;
1493
+ * rateLimited and tooLarge are the refusals of a request the gateway would not take as sent.
1494
+ */
1495
+ interface ConversationFaultCopy {
1496
+ generic: string;
1497
+ missingOrganization: string;
1498
+ /**
1499
+ * What a viewer reads when the run is refused for their role or their membership: a 403, or the
1500
+ * 404 a start answers for an organization the reader does not belong to. A 404 refusing the
1501
+ * stream of a run that opened is a run the gateway no longer holds, and reads `generic`.
1502
+ */
1503
+ noAccess: string;
1504
+ /** What a viewer reads when the organization has no AI provider configured (409). */
1505
+ notConfigured: string;
1506
+ /**
1507
+ * What a viewer reads when the organization's agreement does not include the product (402):
1508
+ * a fact a retry never changes.
1509
+ */
1510
+ notEntitled: string;
1511
+ /**
1512
+ * What a viewer reads when the gateway refused a start or a follow-up for its rate (429) after
1513
+ * the client's own waits ran out: a moment later, the same message goes through.
1514
+ */
1515
+ rateLimited: string;
1516
+ /**
1517
+ * What a viewer reads when the gateway refused a start or a follow-up as too large (413): the
1518
+ * body over its ceiling, or what the run would be handed, the tools the page provides included,
1519
+ * over the payload bound once encoded. The same request meets the same answer, so the line
1520
+ * says what changes it rather than asking for a retry.
1521
+ */
1522
+ tooLarge: string;
1523
+ }
1524
+ /**
1525
+ * ConversationFaultsConfig is what one conversation's fault handling writes through: the
1526
+ * localized `copy` it surfaces, the `writer` of the conversation's store, and the optional
1527
+ * seams the host answers.
1528
+ */
1529
+ interface ConversationFaultsConfig {
1530
+ copy: ConversationFaultCopy;
1531
+ /**
1532
+ * invalidateAiConfig refreshes the organization's AI-config read after the
1533
+ * gateway reports the credential is gone, so the surface flips to its setup
1534
+ * card instead of offering a conversation that cannot start.
1535
+ *
1536
+ * Optional, because its absence is a defined answer rather than a gap: a host with no
1537
+ * cache of its own has nothing to mark stale, and the config is re-read on the next
1538
+ * natural fetch. The fault still surfaces its message either way: the invalidation
1539
+ * only decides how soon the surface notices the credential is gone. It is called once the
1540
+ * fault is written, and one that throws reaches the program as an uncaught error on a
1541
+ * microtask, so the fault is written whatever it does.
1542
+ */
1543
+ invalidateAiConfig?(organizationId: string): void;
1544
+ /**
1545
+ * invalidateMemberships marks the viewer's memberships stale after the gateway refused or
1546
+ * ended a run for want of access, so the surface's notice follows the role the viewer holds
1547
+ * now: a start, or the stream of the run it opened, answered 402, 403 or 404, and a follow-up
1548
+ * the gateway answered 404 because its run is closed, which is what becomes of a run whose
1549
+ * member lost access to its organization.
1550
+ *
1551
+ * Optional, for the reason {@link ConversationFaultsConfig.invalidateAiConfig} is: a host with
1552
+ * no cache of its own re-reads the memberships on its next natural fetch, and the fault still
1553
+ * surfaces its message either way. Called as that one is, once the fault is written.
1554
+ */
1555
+ invalidateMemberships?(): void;
1556
+ /**
1557
+ * onSignInRefused tells the host the API refused the credential the conversation runs on: a
1558
+ * run's start, the stream of a run it opened or reconnected to, or a follow-up was answered 401.
1559
+ * Under the browser's own session that is a sign-in the API no longer accepts, so the host asks
1560
+ * whether the person is still signed in and, when nobody is, sends them to sign in.
1561
+ *
1562
+ * Called once per refusal, as the invalidations are, once the fault is written. A 401 says
1563
+ * nothing of the viewer's access, so the memberships are not read again for it. Optional, for
1564
+ * the reason {@link ConversationFaultsConfig.invalidateAiConfig} is: the fault still surfaces
1565
+ * its message either way.
1566
+ */
1567
+ onSignInRefused?: (() => void) | undefined;
1568
+ /**
1569
+ * onSettled runs after a fault is written, for a host that mirrors run ids into the URL, as
1570
+ * the co-pilot does.
1571
+ */
1572
+ onSettled?(): void;
1573
+ writer: ConversationWriter;
1574
+ }
1575
+ /**
1576
+ * ConversationFaults is the ways a conversation fails outside its own event
1577
+ * stream. recover recovers a conversation whose follow-up message failed to reach its
1578
+ * run, a fault that raises no `error` event and would otherwise leave the conversation
1579
+ * wedged on `running` with its composer disabled. missingOrganization handles a
1580
+ * submit that cannot be scoped to an organization. handleStartError maps a
1581
+ * rejection of the run's start or of its read onto the surface's copy. resumeFailed
1582
+ * settles a conversation whose reconnect to its run failed for good. Each re-enables
1583
+ * input, since a surface the user cannot type into is the one failure mode none of them
1584
+ * may leave behind.
1585
+ */
1586
+ interface ConversationFaults {
1587
+ /**
1588
+ * handleStartError maps a rejection of the run's start or of its read onto the surface's copy.
1589
+ *
1590
+ * @param organizationId The organization the run was started in.
1591
+ * @param error What the start rejected with.
1592
+ * @param runId The run the start opened, when it was the run's stream that failed, as
1593
+ * `ConversationHostConfig.onStartError` reports it. A 404 then says the gateway no longer
1594
+ * holds the run (it expired, or its member lost the write role it was started under), and
1595
+ * reads the generic copy rather than the no-access one a refused start reads.
1596
+ */
1597
+ handleStartError(organizationId: string, error: unknown, runId?: string | undefined): void;
1598
+ missingOrganization(): void;
1599
+ /**
1600
+ * recover surfaces the copy of a follow-up's failure and re-enables input: the too-large or the
1601
+ * rate-limited line for a 413 or a 429, and the generic one otherwise.
1602
+ *
1603
+ * @param runGone Whether the failure says the run is gone, as
1604
+ * `ConversationHostConfig.onSendFault` reports it. The run id is dropped only then, so a
1605
+ * reload resumes a run the conversation kept and never one it has left.
1606
+ * @param error What the follow-up failed with. The memberships are read again only when the
1607
+ * gateway answered it 404, which is what a run closed for want of access answers, and never
1608
+ * for the engine's own refusal of a run it already let go.
1609
+ */
1610
+ recover(runGone: boolean, error?: unknown): void;
1611
+ /**
1612
+ * resumeFailed settles a conversation whose reconnect to the run it held failed for good, as
1613
+ * `ConversationHost.resume` reports it: the run id is dropped, so a reload reconnects to no run
1614
+ * that is gone, and input is re-enabled. It writes no line: the transcript the reconnect would
1615
+ * have continued stands as it was, and the next message opens a run.
1616
+ *
1617
+ * @param error What the reconnect failed with. A 401 tells the host the API refused its
1618
+ * credential, as a start's does (see {@link ConversationFaultsConfig.onSignInRefused}).
1619
+ */
1620
+ resumeFailed(error: unknown): void;
1621
+ }
1622
+ /**
1623
+ * createConversationFaults binds the shared fault handling to one conversation's
1624
+ * writer. The co-pilot and the video director resolve identical failures (the
1625
+ * same 403, the same 409 `AI_PROVIDER_NOT_CONFIGURED` credential refresh), and
1626
+ * held apart they drift: a status the gateway starts returning, or a copy change,
1627
+ * has to land twice or the two surfaces disagree about the same failure.
1628
+ *
1629
+ * Dropping the run id keeps a reload from resuming a run the conversation has left: a
1630
+ * start that failed, or a run a follow-up found gone.
1631
+ */
1632
+ export declare const createConversationFaults: (config: ConversationFaultsConfig) => ConversationFaults;
1633
+ /**
1634
+ * ConversationHostConfig wires a host to one conversation's world: how it records
1635
+ * the user's turn, resolves the run's organization and point-in-time context,
1636
+ * builds the session it drives, and where each failure mode is surfaced. The host
1637
+ * owns the session and the started guard, and calls back into these seams so the
1638
+ * store writes, error mapping, and org resolution stay with the surface that knows
1639
+ * them: the host itself knows only the start/send/resume lifecycle.
1640
+ */
1641
+ interface ConversationHostConfig {
1642
+ /** appendUserMessage records the user's outgoing turn before the run is touched. */
1643
+ appendUserMessage(message: string): void;
1644
+ /**
1645
+ * buildContext resolves the point-in-time snapshot the run opens with, or
1646
+ * undefined for a contextless start. It must not reject (a snapshot failure
1647
+ * resolves undefined), so only a start rejection routes to onStartError.
1648
+ */
1649
+ buildContext(): Promise<Record<string, unknown> | undefined>;
1650
+ /** buildSession builds a fresh session wired to the surface's observer. */
1651
+ buildSession(): AgentEngine;
1652
+ /** onMissingOrganization surfaces that there is no resource to scope a run to. */
1653
+ onMissingOrganization(): void;
1654
+ /**
1655
+ * onSendFault reports a follow-up message that did not reach its run.
1656
+ *
1657
+ * @param error What the send rejected with.
1658
+ * @param runGone Whether the failure says the run is gone: the engine refused the message
1659
+ * (the run ended, or the engine was disposed) or the gateway answered 404. The host then
1660
+ * clears its guard and the next message opens a new run. Otherwise the run is kept, and
1661
+ * the next message is posted into it.
1662
+ */
1663
+ onSendFault(error: unknown, runGone: boolean): void;
1664
+ /**
1665
+ * onStartError maps a rejection of the run's start or of its read onto the surface's copy.
1666
+ *
1667
+ * @param organizationId The organization the run was started in.
1668
+ * @param error What the start rejected with.
1669
+ * @param runId The run the start opened, when its post answered and its stream then failed for
1670
+ * good. Absent when the start opened no run: the gateway refused it, or it never reached the
1671
+ * gateway. A status means something else on each: a 404 refusing the start is an
1672
+ * organization the reader does not reach, and a 404 refusing the stream of an opened run is
1673
+ * a run the gateway no longer holds.
1674
+ */
1675
+ onStartError(organizationId: string, error: unknown, runId?: string | undefined): void;
1676
+ /**
1677
+ * routeForMessage lets the surface pick the tool set this turn should offer
1678
+ * before the message reaches the run. It is called for every message, first
1679
+ * one included, so the run OPENS on the routed set rather than being narrowed
1680
+ * only from the second turn on. Optional: a surface with no router omits it and
1681
+ * the session offers every permitted tool.
1682
+ */
1683
+ routeForMessage?(message: string): void;
1684
+ /**
1685
+ * routeForState lets the surface re-pick the tool set from LIVE state, with no
1686
+ * new message. It is what makes a surface the run itself unlocks reachable: a
1687
+ * router keyed only on the user's words cannot know that the run just opened a
1688
+ * suggest session, so without this the tools it unlocked stay invisible until
1689
+ * the user happens to type again. Optional, exactly as routeForMessage.
1690
+ */
1691
+ routeForState?(): void;
1692
+ /** resolveOrganizationId reads the org that owns the resource the run acts on. */
1693
+ resolveOrganizationId(): string | null | undefined;
1694
+ }
1695
+ /**
1696
+ * ConversationHost is one AI conversation's session lifecycle: it opens a run on
1697
+ * the first message, sends follow-ups into the open run, reconnects a persisted
1698
+ * run, and tears down on stop/close/unmount. A single started guard distinguishes
1699
+ * "open a run" from "send into it". A run that ends (its `done`, or the session giving up
1700
+ * on it) clears that guard, and so does a follow-up refused because its run is gone, so the
1701
+ * next message opens a fresh run rather than posting into a run that takes no more input. A
1702
+ * follow-up that fails any other way (a dropped connection) keeps the run, and the next
1703
+ * message is posted into it. Only the open run speaks for the conversation: a start, a
1704
+ * resume or a send that settles after a later call or a restart replaced its run clears
1705
+ * nothing and reports nothing, and of several sends refused as gone from one run, the first
1706
+ * alone recovers the conversation.
1707
+ */
1708
+ interface ConversationHost {
1709
+ /**
1710
+ * dispose aborts the session's open stream and parked consumer; idempotent.
1711
+ *
1712
+ * It asks the gateway nothing, so the run goes on there, and the host keeps where the session
1713
+ * stood in it: a {@link ConversationHost.resume} of that run is read on from that position by
1714
+ * the session it builds, and hands the conversation nothing a second time.
1715
+ */
1716
+ dispose(): void;
1717
+ /** finish asks the run to close (POST close), then disposes the session. */
1718
+ finish(): void;
1719
+ /**
1720
+ * reroute re-reads the router from live state and carries the resulting tool
1721
+ * set into the open run. A no-op when no run is open, and free when the
1722
+ * selection has not moved: the session drops an unchanged manifest itself.
1723
+ */
1724
+ reroute(): void;
1725
+ /**
1726
+ * restart ends the conversation's run and eagerly swaps in a fresh session: it asks the run to
1727
+ * close (POST close), as {@link ConversationHost.finish} does, then disposes the live session
1728
+ * and builds the next one. The close covers a run the session gave up reading and still owes
1729
+ * one, so a stopped run spends no more of the gateway's model budget.
1730
+ */
1731
+ restart(): void;
1732
+ /**
1733
+ * resume builds the session so its observer is wired the moment the conversation
1734
+ * mounts, and reconnects a persisted run exactly once. A null run id primes the
1735
+ * session without reconnecting; a resume fault clears the guard then calls
1736
+ * onFault with what the reconnect failed with, and a resumed run that ends clears the
1737
+ * guard without calling it. A resume that a later start or a restart replaced does
1738
+ * neither.
1739
+ *
1740
+ * The run is read on from where the session a {@link ConversationHost.dispose} tore down
1741
+ * stood in it, when that session read this run and its stream named a position. With no such
1742
+ * position (a host built after a reload, another run, a run that a finish or a restart
1743
+ * closed) the gateway answers with the run's history from its first event.
1744
+ */
1745
+ resume(runId: string | null | undefined, onFault: (error: unknown) => void): void;
1746
+ /**
1747
+ * submit opens a run on the first message, and on the first message after a run ended,
1748
+ * or sends the follow-up into the open run.
1749
+ *
1750
+ * A follow-up submitted before that run has its id (while its context is captured, or while
1751
+ * its start is still being posted) is held and delivered once the run opens, the routed
1752
+ * tool set ahead of it. When the start fails, the held follow-up is dropped and
1753
+ * `onStartError` is the one report: `onSendFault` is for a message that failed on its way
1754
+ * into a run that was open. A follow-up that fails keeps the run unless the failure says the
1755
+ * run is gone (see {@link ConversationHostConfig.onSendFault}).
1756
+ */
1757
+ submit(message: string): void;
1758
+ }
1759
+ /**
1760
+ * createConversationHost builds the session lifecycle for one AI conversation over
1761
+ * the supplied seams. The session and the started guard live in this closure:
1762
+ * they survive across the surface's re-renders without being reactive state, and
1763
+ * the surface reads its conversation off the store the observer drives, never off
1764
+ * the session directly.
1765
+ *
1766
+ * It is one long closure on purpose. Each function in it is a few lines over the same
1767
+ * variables (the session, the guard, the open call, its hand-over to the session and the
1768
+ * position a teardown parked), and a split would pass that state between modules for no
1769
+ * reader's benefit.
1770
+ */
1771
+ export declare const createConversationHost: (config: ConversationHostConfig) => ConversationHost;
1772
+ /**
1773
+ * toWireErrorCode narrows a bus failure code to the vocabulary the wire carries.
1774
+ *
1775
+ * The bus's own set is the wider of the two by design. Some of its codes describe a POINTER
1776
+ * gesture that missed (a split point clicked off the line), and the tools that raise them are
1777
+ * hidden from the model. Others describe the STUDIO rather than the request: no map mounted, no
1778
+ * data seam, nothing open. Neither kind is something a model can act on, and neither is
1779
+ * something this package can enumerate: the bus's vocabulary belongs to `@mountaya/studio`, one
1780
+ * level up, and a table of its members here would be the dependency the split exists to refuse.
1781
+ *
1782
+ * So a code the wire does not know is reported as `internal`, which is what the contract says
1783
+ * `internal` is for: "failed for a reason with no more specific code". It is deliberately not
1784
+ * `invalid-input`: that one claims the ARGUMENTS were wrong, so a model reading it corrects
1785
+ * arguments that were already correct and retries into the same wall.
1786
+ *
1787
+ * Undefined stays undefined: an unclassified failure carries no code either way.
1788
+ *
1789
+ * @param code The bus's failure code, or undefined for an unclassified failure.
1790
+ * @returns The code when the wire carries it, `internal` for any other code, and undefined for
1791
+ * none.
1792
+ */
1793
+ export declare const toWireErrorCode: (code: string | undefined) => AgentToolErrorCode | undefined;
1794
+ /**
1795
+ * AgentScriptedTransport is an {@link AgentTransport} that reaches no server, with the two
1796
+ * controls a test or an offline demo drives a run's stream by. It is what
1797
+ * {@link createAgentScriptedTransport} answers, and it drops into an `AgentEngine` wherever the
1798
+ * live transport does.
1799
+ *
1800
+ * A run's stream keeps every event pushed into it, in order, and numbers each: a frame carries
1801
+ * an id of its own, the same on every delivery. A subscriber that names no position is handed
1802
+ * the history from its first event and then each event as it is pushed, so a second read of a
1803
+ * run replays it, as the gateway replays a run to such a reader. A subscriber that names one
1804
+ * (`lastEventId`, the id of a frame it holds) is handed what stands after that frame and then
1805
+ * the live feed, so a reader that kept its transcript reads on and is handed nothing a second
1806
+ * time. A position the run never named is read as none. A read that begins past the run's
1807
+ * terminal event has nothing left to read and closes with `onClose("ended")`.
1808
+ *
1809
+ * A replayed `tool-call` or `confirm-required` the run was answered for carries `settled: true`,
1810
+ * as the gateway marks one whose outcome its stream holds. The answer to a client tool call is
1811
+ * written to the stream as the `tool-result` the gateway echoes it as, so a reader with no
1812
+ * memory of the run is replayed the call and its outcome. The echo is written at the end of
1813
+ * the stream, or before the terminal `done` when the run ended in the turn that called, since
1814
+ * a read closes on that event. A call the stream already holds an outcome for takes no second
1815
+ * one. A confirmation's outcome is the tool's own, which a server
1816
+ * runs: it is in the replay only when the script pushed one.
1817
+ *
1818
+ * @example
1819
+ * ```ts
1820
+ * import { createAgentScriptedTransport, type AgentScriptedTransport } from "@mountaya/elements/agent";
1821
+ *
1822
+ * const transport: AgentScriptedTransport = createAgentScriptedTransport((message) => [
1823
+ * { text: `You said: ${message}`, type: "message-delta" },
1824
+ * { type: "awaiting-input" },
1825
+ * ]);
1826
+ * const { runId } = await transport.startRun({
1827
+ * client_tools: [],
1828
+ * message: "hello",
1829
+ * organization_id: "9b2f6c1e-5d7a-4e0b-8c3f-1a2b3c4d5e6f",
1830
+ * });
1831
+ *
1832
+ * transport.pushEvents(runId, [{ text: "One more thing.", type: "message-delta" }]);
1833
+ * transport.endRun(runId);
1834
+ * ```
1835
+ */
1836
+ interface AgentScriptedTransport extends AgentTransport {
1837
+ /**
1838
+ * endRun pushes the terminal `done`, with the reason `completed`, into the run's stream. Every
1839
+ * read of the run ends on it with `onClose("terminal")`. A run that was never started is
1840
+ * ignored.
1841
+ */
1842
+ endRun: (runId: string) => void;
1843
+ /**
1844
+ * pushEvents appends events to the run's stream, in order, as they would arrive off the wire.
1845
+ * A subscriber waiting on the stream receives them at once, and one that subscribes later
1846
+ * receives them in the replay. A run that was never started is ignored.
1847
+ */
1848
+ pushEvents: (runId: string, events: readonly AgentEvent[]) => void;
1849
+ }
1850
+ /**
1851
+ * createAgentScriptedTransport is the transport that reaches no server: each run owns a single
1852
+ * persistent stream, and a user message is resolved to that turn's AgentEvent[]
1853
+ * and pushed into the open stream, exercising the exact AgentEngine → bus path a
1854
+ * live SSE run drives. It is generic: the caller injects the message → events
1855
+ * resolver, so this package keeps no domain knowledge of any surface's tool set.
1856
+ *
1857
+ * Multi-turn rides one stream: the start message seeds turn one; each follow-up
1858
+ * `user-message` input pushes the next turn's events into the same open stream.
1859
+ * tool-result and confirm inputs are the session answering the run: the run remembers the call
1860
+ * each one answers, a later read replays that call as settled, and a tool-result is written to
1861
+ * the stream as its echo (see {@link AgentScriptedTransport}). A `close` input pushes a terminal
1862
+ * `done`. A turn that ends in `awaiting-input` keeps the stream open for the next message, and
1863
+ * the run ends when a terminal event is pushed, by a `close` input or by `endRun`.
1864
+ *
1865
+ * Each run's id is a version 4 UUID, minted on a page outside a secure context too.
1866
+ *
1867
+ * @param resolve Answers the events of the turn a user message opens, the start's message
1868
+ * included.
1869
+ */
1870
+ export declare const createAgentScriptedTransport: (resolve: (message: string) => AgentEvent[]) => AgentScriptedTransport;
1871
+ /**
1872
+ * STICK_TO_BOTTOM_THRESHOLD_PX is the slack, in pixels, within which a scroll
1873
+ * viewport still counts as sitting at its bottom. A few pixels absorb sub-pixel
1874
+ * layout rounding and the gap between a new row mounting and its height settling,
1875
+ * so a reader parked on the latest turn is never misread as having scrolled up.
1876
+ */
1877
+ export declare const STICK_TO_BOTTOM_THRESHOLD_PX = 24;
1878
+ /**
1879
+ * ScrollViewportGeometry is the three measurements of a scroll viewport that
1880
+ * {@link isPinnedToBottom} reads: how tall the viewport is, how tall its content is,
1881
+ * and how far it has scrolled, all in pixels.
1882
+ *
1883
+ * Structural rather than a pick of the DOM's `HTMLElement`, so
1884
+ * `@mountaya/elements/agent` type-checks without the DOM library, and a binding
1885
+ * supplies the numbers from whatever it scrolls. A DOM element passes as it is.
1886
+ */
1887
+ interface ScrollViewportGeometry {
1888
+ readonly clientHeight: number;
1889
+ readonly scrollHeight: number;
1890
+ readonly scrollTop: number;
1891
+ }
1892
+ /**
1893
+ * isPinnedToBottom reports whether a scroll viewport is at (or within
1894
+ * `threshold` of) its bottom. The transcript follows new content to the bottom
1895
+ * only while this holds, so a streamed reply keeps the latest turn in view without
1896
+ * yanking a reader who has scrolled up to revisit earlier turns. It reads only the
1897
+ * three geometry fields, so it unit-tests against a plain object.
1898
+ *
1899
+ * @param threshold The slack, in pixels, within which the viewport still counts as
1900
+ * at its bottom.
1901
+ * @default threshold {@link STICK_TO_BOTTOM_THRESHOLD_PX}
1902
+ */
1903
+ export declare const isPinnedToBottom: (viewport: ScrollViewportGeometry, threshold?: number) => boolean;
1904
+ /**
1905
+ * MAX_TOOL_RESULT_DATA_BYTES caps the structured payload one client tool result
1906
+ * puts into the run's transcript. The transcript is replayed in full on every
1907
+ * subsequent turn, so an uncapped grid or route list would be paid for again on
1908
+ * each one; the gateway applies its own, larger cap to the whole result envelope
1909
+ * behind this.
1910
+ */
1911
+ export declare const MAX_TOOL_RESULT_DATA_BYTES = 4096;
1912
+ /**
1913
+ * ToolResultPayload is the envelope a client tool's result rides in on a `tool-result` input:
1914
+ * the human summary the model reads, the data it acted on, and the truncation report when that
1915
+ * data did not fit.
1916
+ *
1917
+ * It is declared here rather than generated because it is not the wire's shape: the contract
1918
+ * types the field it lands in as an open JSON object, deliberately, since what a tool returns
1919
+ * is the tool's business. This is the shape the agent engine puts there, and the model's
1920
+ * prompt is written against it.
1921
+ */
1922
+ type ToolResultPayload = {
1923
+ data?: unknown;
1924
+ /** How many items of a truncated collection were sent. */
1925
+ returned?: number | undefined;
1926
+ /** The host's state delta the call produced, when the run asked for one. */
1927
+ state?: Record<string, unknown> | undefined;
1928
+ summary?: string | undefined;
1929
+ /** How many items the collection held before truncation. */
1930
+ total?: number | undefined;
1931
+ truncated?: boolean | undefined;
1932
+ /** Which field of a record was the one truncated, when it was a record rather than an array. */
1933
+ truncatedField?: string | undefined;
1934
+ };
1935
+ /**
1936
+ * buildToolResultPayload assembles the result a client tool posts back, trimming
1937
+ * the structured payload to {@link MAX_TOOL_RESULT_DATA_BYTES} when it does not
1938
+ * fit.
1939
+ *
1940
+ * Trimming is semantic, never a byte cut: the longest collection inside the
1941
+ * payload is shortened and the envelope reports how many of how many elements
1942
+ * survived, so what the model receives is always valid JSON it can reason about.
1943
+ * A byte-truncated payload is broken JSON the model has to guess at, and a count
1944
+ * it cannot see is a sampling density it will silently misread.
1945
+ *
1946
+ * A payload nothing can be trimmed OFF (a single oversized blob, or a record
1947
+ * whose non-collection keys already spend the whole budget) is dropped rather
1948
+ * than mangled, leaving the summary and a `truncated` marker so the model knows
1949
+ * to re-read something narrower instead of trusting a fragment. Dropping is what
1950
+ * keeps the cap a bound: every branch that returns `data` returns one that fits.
1951
+ *
1952
+ * Data JSON refuses to serialize (a bigint, a cycle, a `toJSON` that throws) is dropped the
1953
+ * same way, with the same marker, and never thrown: what a tool returns reaches here
1954
+ * unvalidated, and a throw here would end the run's whole read over one tool's result. Data
1955
+ * JSON has no text for (a function, a symbol) is sent as absent, as `undefined` and `null`
1956
+ * are.
1957
+ *
1958
+ * `state` is what the call MOVED in the workspace, and it rides the envelope
1959
+ * beside the summary rather than inside `data` for the same reason the truncation
1960
+ * fields do: it must survive trimming, and it must read the same whether `data` is
1961
+ * an object, an array, or absent. It is passed in rather than derived here because
1962
+ * only the caller holds the before and after readings.
1963
+ */
1964
+ export declare const buildToolResultPayload: (summary: string, data: unknown, state?: Record<string, unknown>) => ToolResultPayload;
1965
+ export type { ActivityEntry, ActivityStatus, AgentBudgetCopy, AgentDraftWarning, AgentEngineConfig, AgentEngineState, AgentErrorCopy, AgentObserver, AgentScriptedTransport, AgentStreamPosition, AgentToolContext, AssistantTurn, ConversationFaultCopy, ConversationFaults, ConversationFaultsConfig, ConversationHost, ConversationHostConfig, ConversationState, ConversationWriter, MessageEntry, PendingConfirmation, QuestionEntry, QuestionOption, RecoveryLookup, ScrollViewportGeometry, ServerToolConfirmation, StateDelta, SuggestionCardCandidate, SuggestionsEntry, ToolActivityOutcome, ToolDispatchResult, ToolDispatcher, ToolManifestEntry, ToolResultPayload, TranscriptEntry, TranscriptRole, WarningEntry };
1966
+ //# sourceMappingURL=index.d.ts.map