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