@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,1964 @@
1
+ 'use strict';
2
+
3
+ var chunkUYUBSD2V_cjs = require('../chunk-UYUBSD2V.cjs');
4
+ require('../chunk-6ACRNQQQ.cjs');
5
+ var chunk4F6BJMJC_cjs = require('../chunk-4F6BJMJC.cjs');
6
+ var chunkWW4CGS7G_cjs = require('../chunk-WW4CGS7G.cjs');
7
+ var chunkISLB6Y5Q_cjs = require('../chunk-ISLB6Y5Q.cjs');
8
+
9
+ // src/agent/rules/errorCodes.ts
10
+ var agentToolErrorCodes = {
11
+ canceled: "canceled",
12
+ "capability-denied": "capability-denied",
13
+ "collab-locked": "collab-locked",
14
+ "confirmation-denied": "confirmation-denied",
15
+ "confirmation-timeout": "confirmation-timeout",
16
+ conflict: "conflict",
17
+ "draft-open": "draft-open",
18
+ "edit-in-progress": "edit-in-progress",
19
+ forbidden: "forbidden",
20
+ internal: "internal",
21
+ "invalid-input": "invalid-input",
22
+ "limit-reached": "limit-reached",
23
+ "not-found": "not-found",
24
+ "rate-limited": "rate-limited",
25
+ timeout: "timeout",
26
+ unavailable: "unavailable",
27
+ "unknown-tool": "unknown-tool",
28
+ "upgrade-required": "upgrade-required"
29
+ };
30
+ var isWireErrorCode = (code) => Object.hasOwn(agentToolErrorCodes, code);
31
+ var toWireErrorCode = (code) => {
32
+ if (code === void 0) {
33
+ return void 0;
34
+ }
35
+ return isWireErrorCode(code) ? agentToolErrorCodes[code] : "internal";
36
+ };
37
+
38
+ // src/agent/rules/toolResultPayload.ts
39
+ var MAX_TOOL_RESULT_DATA_BYTES = 4096;
40
+ var byteLength = (value) => {
41
+ let json;
42
+ try {
43
+ json = JSON.stringify(value);
44
+ } catch {
45
+ return null;
46
+ }
47
+ return json === void 0 ? 0 : new TextEncoder().encode(json).length;
48
+ };
49
+ var longestCollection = (data) => {
50
+ let longest = null;
51
+ for (const [key, value] of Object.entries(data)) {
52
+ if (Array.isArray(value) && value.length > (longest?.items.length ?? -1)) {
53
+ longest = { items: value, key };
54
+ }
55
+ }
56
+ return longest;
57
+ };
58
+ var largestFittingSlice = (items, budget, render) => {
59
+ let low = 0;
60
+ let high = items.length;
61
+ while (low < high) {
62
+ const mid = Math.ceil((low + high) / 2);
63
+ const size = byteLength(render(mid));
64
+ if (size !== null && size <= budget) {
65
+ low = mid;
66
+ } else {
67
+ high = mid - 1;
68
+ }
69
+ }
70
+ return low;
71
+ };
72
+ var buildToolResultPayload = (summary, data, state) => {
73
+ const base = { summary, ...state ? { state } : {} };
74
+ if (data === void 0 || data === null) {
75
+ return base;
76
+ }
77
+ const size = byteLength(data);
78
+ if (size === null) {
79
+ return { ...base, truncated: true };
80
+ }
81
+ if (size === 0) {
82
+ return base;
83
+ }
84
+ if (size <= MAX_TOOL_RESULT_DATA_BYTES) {
85
+ return { ...base, data };
86
+ }
87
+ if (Array.isArray(data)) {
88
+ const items = data;
89
+ const returned = largestFittingSlice(
90
+ items,
91
+ MAX_TOOL_RESULT_DATA_BYTES,
92
+ (count) => items.slice(0, count)
93
+ );
94
+ return {
95
+ ...base,
96
+ data: items.slice(0, returned),
97
+ returned,
98
+ total: items.length,
99
+ truncated: true
100
+ };
101
+ }
102
+ if (typeof data === "object") {
103
+ const collection = longestCollection(data);
104
+ if (collection !== null) {
105
+ const { items, key } = collection;
106
+ const returned = largestFittingSlice(items, MAX_TOOL_RESULT_DATA_BYTES, (count) => ({
107
+ ...data,
108
+ [key]: items.slice(0, count)
109
+ }));
110
+ if (returned > 0) {
111
+ return {
112
+ ...base,
113
+ data: { ...data, [key]: items.slice(0, returned) },
114
+ returned,
115
+ total: items.length,
116
+ truncated: true,
117
+ truncatedField: key
118
+ };
119
+ }
120
+ }
121
+ }
122
+ return { ...base, truncated: true };
123
+ };
124
+
125
+ // src/agent/engines/session.ts
126
+ var toClientToolManifest = (entries) => entries.map((entry) => ({
127
+ ...entry.requiresConfirmation ? { confirms: true } : {},
128
+ ...entry.readOnly ? { read_only: true } : {},
129
+ description: entry.description,
130
+ name: entry.name,
131
+ parameters: entry.inputSchema
132
+ }));
133
+ var manifestKey = (manifest) => manifest.map((entry) => entry.name).sort().join("\n");
134
+ var routedKey = (manifest, serverTools) => `${manifestKey(manifest)}\0${serverTools?.join(",") ?? ""}`;
135
+ var AGENT_RECONNECT_BASE_MS = 500;
136
+ var RECONNECT_MAX_MS = 8e3;
137
+ var reconnectSchedule = {
138
+ baseMs: AGENT_RECONNECT_BASE_MS,
139
+ maxMs: RECONNECT_MAX_MS
140
+ };
141
+ var RECONNECT_MAX_ATTEMPTS = 6;
142
+ var RECONNECT_UNAVAILABLE_MAX_MS = 12e4;
143
+ var UNAVAILABLE_STATUS = 503;
144
+ var PRODUCTIVE_FRAME_COUNT = 1;
145
+ var REOPEN_STATUSES = [429, 503, 504];
146
+ var isConnectionFault = (error) => {
147
+ if (typeof error !== "object" || error === null || !("name" in error)) {
148
+ return false;
149
+ }
150
+ return error.name === "TypeError" || error.name === "MountayaConnectionError";
151
+ };
152
+ var isTransientStreamFault = (error) => {
153
+ const status = chunkUYUBSD2V_cjs.statusOf(error);
154
+ return status === void 0 ? isConnectionFault(error) : REOPEN_STATUSES.includes(status);
155
+ };
156
+ var createPendingStart = () => {
157
+ let settle = () => {
158
+ };
159
+ const opened = new Promise((resolve) => {
160
+ settle = resolve;
161
+ });
162
+ return { opened, settle, withdrawal: new AbortController() };
163
+ };
164
+ var AgentEngine = class {
165
+ constructor(config) {
166
+ this.config = config;
167
+ }
168
+ config;
169
+ currentRunId = null;
170
+ // The run this engine adopted and has neither read to its `done` nor closed: the one run it
171
+ // still owes a close. It outlives the read when the engine stops reading on its own (the
172
+ // reconnect ceiling, two minutes of opens answered 503, an open refused for good), because
173
+ // the gateway holds that run open until its own timeout and nobody else was reading it.
174
+ // leaveRun and close pay it.
175
+ unfinishedRunId = null;
176
+ state = "awaiting_input";
177
+ /**
178
+ * The state the observer was told last. It is {@link state} but from the moment a start
179
+ * readies its run until that start reports: the engine rests for those statements, and the
180
+ * observer is told the state the start leaves it in, never the rest between two turns.
181
+ */
182
+ reported = "awaiting_input";
183
+ // The claim the sends still being posted have on `running`, or null when the state is not
184
+ // theirs alone; see SendHold.
185
+ sendHold = null;
186
+ // True while the `running` report of a send is on the stack. A send made from inside it lets
187
+ // the one that reports make its post first; see send.
188
+ sendReporting = false;
189
+ // The last position the stream named, by a frame that reached the engine or by a record that
190
+ // carries none, sent back as Last-Event-ID so a reconnect resumes after it rather than
191
+ // replaying the whole durable history. A frame whose handling threw gives its position back.
192
+ lastEventId;
193
+ // Aborts the open events stream when the host tears the run down or it ends, so
194
+ // a parked consumer and its fetch are released rather than leaked. Replaced each
195
+ // time a new stream is opened (a reconnect), and tripped by close(), dispose(), and
196
+ // a start() or resume() that replaces the run.
197
+ streamAbort = null;
198
+ // Unsubscribes from the open events stream. The abort tears the live fetch down;
199
+ // this stops the callback delivery (and the scripted drain, which has no fetch).
200
+ // Whatever trips the abort trips both; a settle inside consume clears it while it is
201
+ // still that read's.
202
+ unsubscribe = null;
203
+ // Counts the reads beginRun readied, so a read can tell whether a start or a resume made
204
+ // from one of the observer's callbacks replaced it while it handled a frame.
205
+ readGeneration = 0;
206
+ // The tool names the run was last offered, so routeTools can skip a no-op
207
+ // update rather than busting the provider's cached prompt prefix for nothing.
208
+ routedNames = "";
209
+ // Counts the routing updates sent, so each one is numbered in the order the run was sent it.
210
+ routingUpdates = 0;
211
+ // The number of the update whose selection is recorded, so an answer can tell whether the
212
+ // run accepted a later one.
213
+ routedUpdate = 0;
214
+ // The shutdown latch. dispose() sets it, and from then on start() and resume() open
215
+ // nothing: a torn-down engine that started a run would start one nobody reads.
216
+ disposed = false;
217
+ // The start still waiting on its run id, if one is; see PendingStart.
218
+ pendingStart = null;
219
+ // The tool_call_ids of the client tool calls the engine ran, of the confirmations it
220
+ // answered and of the calls the stream marked settled, in the run named by handledRunId, so
221
+ // a frame the stream sends again runs nothing twice and asks nothing twice. A reopen that
222
+ // sends no cursor is answered with the run's whole history, the calls already handled
223
+ // included.
224
+ handledCalls = /* @__PURE__ */ new Set();
225
+ handledRunId = null;
226
+ // The tool_call_ids of the client tool calls the engine ran and reported itself in the run
227
+ // named by handledRunId. Each is reported from the bus result, so what the stream says about
228
+ // one afterwards (the gateway's echo of the answer, an abandonment that crossed it) is
229
+ // dropped. A call whose handling threw before its report is not among them: what the stream
230
+ // says about it is the one report it gets.
231
+ dispatchedCalls = /* @__PURE__ */ new Set();
232
+ // The client tool calls the engine is running in the run named by handledRunId: claimed, and
233
+ // not reported yet. Each maps to the first thing the stream said of the call meanwhile, held
234
+ // as the report it would have made, or to null while the stream has said nothing. A read a
235
+ // resume opened beside the handling is the one that can say something. The entry goes at
236
+ // the engine's own report, which drops the held word, and when the handling throws before
237
+ // it, which releases the word.
238
+ runningCalls = /* @__PURE__ */ new Map();
239
+ /**
240
+ * start opens a fresh run with the user's first message, then consumes the
241
+ * run's single event stream to completion. The returned promise settles only
242
+ * when the engine stops reading the run, so the caller fire-and-forgets it and
243
+ * reacts to turns through the observer instead. It resolves on the terminal
244
+ * `done`, on {@link close} or {@link dispose}, when a later start or
245
+ * {@link resume} replaces the run, and when its reconnects stop being productive.
246
+ *
247
+ * It rejects when the start or the stream fails for good: a start whose post is
248
+ * refused, at once for most answers and, for a 429, a 502, a 503, a 504 or a dropped
249
+ * connection, once the transport has repeated it under the start's idempotency key
250
+ * as far as its retry policy goes, a stream open answered with anything but a 429,
251
+ * 503 or 504, a fault in one of the host's own seams, and a stream that is still
252
+ * failing when the reconnect ceiling is reached, whether its connection stays down
253
+ * or every open is answered 429 or 504; that one rejects with the last
254
+ * failure. A stream that fails leaves the state `ended`, reported through
255
+ * `onStateChange("ended")`, before the promise rejects; a start that fails leaves
256
+ * it `awaiting_input`.
257
+ *
258
+ * A stream open answered 503 is not counted against the reconnect ceiling. It says the
259
+ * run's events cannot be reached for a moment while the run goes on, so the engine opens
260
+ * the stream again, after the wait the answer names, for as long as two minutes of such
261
+ * answers with no turn read in between, and then rejects with the last of them.
262
+ *
263
+ * The state is `running` from the call, reported through `onStateChange("running")` before
264
+ * the run has an id, so a host shows the turn as under way from the message. A start that
265
+ * fails reports `awaiting_input` again before its promise rejects. The report is the last
266
+ * step ahead of the post: a start that fails before it, on a fault in the tool surface,
267
+ * never reports `running`.
268
+ *
269
+ * A start that replaces a run reports that one change and no rest ahead of it: `running`
270
+ * from an engine at rest or whose last run ended, and nothing from an engine whose run is
271
+ * under way, which reads `running` through the replacement. Where such a start fails, the
272
+ * one report is `awaiting_input`.
273
+ *
274
+ * One engine reads one run. A start while the engine still reads a run tears that
275
+ * run's stream down and posts a close for it before it opens its own, so none of
276
+ * that run's frames, its resume cursor or its `done` reach the run that replaces
277
+ * it. A start while another start still waits on its run id withdraws that start,
278
+ * as {@link close} does. A start on an engine whose last run ended opens the next
279
+ * run and reads it from its beginning, and posts a close for that last run first when
280
+ * the engine stopped reading it short of its `done` (see {@link close}). A start after
281
+ * {@link dispose} opens nothing and resolves at once.
282
+ *
283
+ * Every start carries an `Idempotency-Key` of its own, drawn once per call where the runtime
284
+ * has a cryptographic random source, and is posted once: the transport repeats a start whose
285
+ * answer was lost under that same key, and the API answers the repeat with the run the key
286
+ * already started, so a lost answer never opens a second run. A start the transport gives up
287
+ * on rejects with the transport's failure, which carries the key. A custom
288
+ * {@link AgentTransport} receives the key as the `idempotencyKey` of the options its `startRun`
289
+ * is handed, and none where the runtime offers no source to draw it from.
290
+ *
291
+ * A {@link close}, a {@link dispose} or a later start or {@link resume} while the start
292
+ * still waits on its run id withdraws it: no stream is opened, no run id and no frame of
293
+ * the run reaches the observer, and the returned promise resolves even when the start
294
+ * itself fails. The run it opens is closed as soon as its id arrives. A withdrawal made from
295
+ * inside a state report of the start itself, or from inside the tool surface it reads (the
296
+ * bus's `manifest`), comes ahead of the post: nothing is posted, no run is opened and no
297
+ * `running` follows the `ended` the withdrawal reported.
298
+ *
299
+ * @param message The user's first message, which opens the run's first turn.
300
+ * @param organizationId The organization that owns the resource the co-pilot is opened on
301
+ * (the itinerary or zone being edited). The run is scoped and access-gated to it, and the
302
+ * API resolves the AI provider credential through it. It is captured per start because it
303
+ * reflects the resource open at the moment the run opens, and the API requires it.
304
+ * @param context The caller's point-in-time studio snapshot, forwarded verbatim to the
305
+ * gateway's create body so the run starts knowing the current UI state. It is captured per
306
+ * start (not held on the session config) because it is a snapshot of the moment the run
307
+ * opens. It stays an opaque `Record<string, unknown>` here because its typed shape is the
308
+ * host's, which this package does not import: the host builds it and passes it through.
309
+ */
310
+ async start(message, organizationId, context) {
311
+ if (this.disposed) {
312
+ return;
313
+ }
314
+ this.leaveRun();
315
+ const pending = createPendingStart();
316
+ this.pendingStart = pending;
317
+ let runId;
318
+ try {
319
+ this.beginRun();
320
+ const manifest = this.routedManifest();
321
+ const serverTools = this.routedServerTools();
322
+ if (pending.withdrawal.signal.aborted) {
323
+ return;
324
+ }
325
+ const params = {
326
+ client_tools: manifest,
327
+ context,
328
+ message,
329
+ organization_id: organizationId,
330
+ profile: this.config.profile,
331
+ // Left out rather than sent empty where the session routes no server tool: a key's run
332
+ // calls none, and the API refuses a start that names any.
333
+ ...serverTools === void 0 ? {} : { server_tools: serverTools }
334
+ };
335
+ const idempotencyKey = chunk4F6BJMJC_cjs.randomUuid();
336
+ this.setState("running");
337
+ if (pending.withdrawal.signal.aborted) {
338
+ return;
339
+ }
340
+ this.routedNames = routedKey(manifest, serverTools);
341
+ ({ runId } = await this.config.transport.startRun(params, { idempotencyKey }));
342
+ } catch (error) {
343
+ pending.settle(false);
344
+ if (!pending.withdrawal.signal.aborted) {
345
+ this.setState("awaiting_input");
346
+ throw error;
347
+ }
348
+ return;
349
+ } finally {
350
+ if (this.pendingStart === pending) {
351
+ this.pendingStart = null;
352
+ }
353
+ }
354
+ if (pending.withdrawal.signal.aborted) {
355
+ await this.closeQuietly(runId);
356
+ return;
357
+ }
358
+ this.adoptRun(runId);
359
+ pending.settle(true);
360
+ this.tell((observer) => observer.onRunId?.(runId));
361
+ await this.run(runId);
362
+ }
363
+ /**
364
+ * resume re-attaches to an already-started run (e.g. after a page reload) and consumes the
365
+ * run's single event stream to completion. It lets a reload reconnect to an
366
+ * in-flight conversation rather than starting over. Its promise settles as the
367
+ * read of a {@link start} does: it resolves when the engine stops reading the run,
368
+ * and rejects when the stream fails for good, the state already `ended`.
369
+ *
370
+ * `lastEventId` is the stream position to read on from: the gateway replays what follows
371
+ * it, then the live feed. Without one the read starts where the engine left the run when
372
+ * `runId` is the run it holds (the one it read last, still open or not), so a host that
373
+ * kept its transcript re-attaches and is handed nothing a second time. That place is after
374
+ * the last frame that reached the engine, the one an observer callback is being handed
375
+ * included: a resume made from inside the callback reads on after that frame. A frame whose
376
+ * handling threw (a seam that answers: the tool layer, the confirm gate, the tool surface or
377
+ * the state delta) is the exception. It is read again, and
378
+ * a call the run already claimed is dropped. For any other run the engine holds no position,
379
+ * and the gateway answers with the run's whole history: that is the read an engine built
380
+ * after a reload makes, and its host starts from an empty transcript. To read the held run
381
+ * from its first event again, resume it on a new engine.
382
+ *
383
+ * Like {@link start}, it reads the run on an engine whose last run ended, opens
384
+ * nothing after {@link dispose}, and replaces what the engine reads when it is
385
+ * called: another run is torn down and closed, and a start still waiting on its run
386
+ * id is withdrawn. A resume of the run the engine is reading tears that read down
387
+ * and reads the run again from `lastEventId`, or from where that read was when none is
388
+ * passed, and posts no close for it.
389
+ *
390
+ * The engine is at rest as the read begins, reported through `onStateChange("awaiting_input")`
391
+ * from an engine that was `running` or `ended`, and the stream says the rest. A call made
392
+ * from inside that report is read before the run is adopted, as one made from a report of a
393
+ * {@link start} is: a {@link dispose} ends the resume with no stream opened and no run to
394
+ * close, and a start or another resume is the one read the engine makes, so this resume
395
+ * resolves at once. A {@link close} made there finds no run held and posts nothing, and the
396
+ * resume reads its run.
397
+ */
398
+ async resume(runId, lastEventId) {
399
+ if (this.disposed) {
400
+ return;
401
+ }
402
+ const held = this.currentRunId === runId ? this.lastEventId : void 0;
403
+ this.leaveRun(runId);
404
+ const generation = this.beginRun();
405
+ this.setState("awaiting_input");
406
+ if (this.disposed || generation !== this.readGeneration) {
407
+ return;
408
+ }
409
+ this.adoptRun(runId);
410
+ this.lastEventId = lastEventId ?? held;
411
+ await this.run(runId);
412
+ }
413
+ /**
414
+ * streamPosition reads where the engine stands in the run it read last, for a host that
415
+ * replaces the engine and has the next one read the run on.
416
+ *
417
+ * It is the position a {@link resume} of that run on this engine reads on from: after the last
418
+ * frame that reached the engine, or the position a resume was handed while no frame has
419
+ * followed it. It is kept through {@link dispose}, which is when a host reads it.
420
+ *
421
+ * @returns The run and the position, or `null` while the engine has read no run or the run's
422
+ * stream has named no position, which is the whole of a run whose frames carry no id.
423
+ *
424
+ * @example
425
+ * ```ts
426
+ * import type { AgentEngine } from "@mountaya/elements/agent";
427
+ *
428
+ * declare const parked: AgentEngine;
429
+ * declare const next: AgentEngine;
430
+ *
431
+ * const position = parked.streamPosition();
432
+ * parked.dispose();
433
+ * if (position !== null) {
434
+ * next.resume(position.runId, position.lastEventId).catch((error: unknown) => {
435
+ * console.error(error);
436
+ * });
437
+ * }
438
+ * ```
439
+ */
440
+ streamPosition() {
441
+ return this.currentRunId === null || this.lastEventId === void 0 ? null : { lastEventId: this.lastEventId, runId: this.currentRunId };
442
+ }
443
+ /**
444
+ * runId reads the id of the run the engine holds: the one a {@link start} opened, from the
445
+ * moment its post answers, or the one a {@link resume} reads, from the moment it begins. It is
446
+ * kept once the engine stops reading that run, whether the run ended, its stream failed, or the
447
+ * engine was disposed.
448
+ *
449
+ * It is what tells the two failures a start rejects with apart. A start whose post the gateway
450
+ * refused opened no run, and this reads null; a start whose run opened and whose stream was
451
+ * then refused reads that run. The same status says different things on each: a 404 on the post
452
+ * is an organization the reader does not reach, and a 404 on the stream is a run the gateway no
453
+ * longer holds.
454
+ *
455
+ * @returns The run's id, or null while the engine holds none: before its first run, and from
456
+ * the moment a start replaces a run until the post of that start answers, which a start that
457
+ * fails never does.
458
+ *
459
+ * @example
460
+ * ```ts
461
+ * import type { AgentEngine } from "@mountaya/elements/agent";
462
+ *
463
+ * declare const engine: AgentEngine;
464
+ * declare const report: (failure: unknown, openedRun: string | null) => void;
465
+ *
466
+ * engine.start("Plan a loop", "organization-id").catch((failure: unknown) => {
467
+ * report(failure, engine.runId());
468
+ * });
469
+ * ```
470
+ */
471
+ runId() {
472
+ return this.currentRunId;
473
+ }
474
+ /**
475
+ * send delivers a follow-up user message into the open run. It only posts the
476
+ * input (the persistent consumer opened by start/resume carries this turn's
477
+ * events), so it does NOT open a second stream.
478
+ *
479
+ * A message sent while a {@link start} still waits on its run id is held until the id
480
+ * arrives, then posted into that run, behind the opening of its stream and in the order the
481
+ * messages were sent. A start settles only when its run is over, so a caller has no promise
482
+ * to wait on before the next message. When that start opens no run (it fails, or a
483
+ * {@link close}, a {@link dispose} or a later start or {@link resume} withdraws it), the
484
+ * held message is dropped and the promise resolves: the start's rejection, or the call that
485
+ * withdrew it, already says the conversation did not open, and a second report of one
486
+ * failure is one too many.
487
+ *
488
+ * The state is `running` from the call the engine takes, reported through
489
+ * `onStateChange("running")` when the run was at rest, so the turn's settle is a change the
490
+ * observer hears even when the turn sends no frame of its own. A message the engine refuses
491
+ * changes nothing. When the post fails, the engine reports `awaiting_input` again before the
492
+ * promise rejects, unless another message is still being posted, one of them landed, or the
493
+ * stream has reported a state since: the turn is then the stream's to settle.
494
+ *
495
+ * The report is made ahead of the post, and the message goes into the run it found at the
496
+ * call. A {@link close}, a {@link dispose}, a {@link start} or a {@link resume} of another run
497
+ * made from inside that report takes the run from the message: nothing is posted and the
498
+ * promise resolves, as it does for a message held behind a start that opens no run. A
499
+ * {@link resume} of the same run keeps the message, and its turn is the stream's to settle.
500
+ * A send made from inside that report is posted after the message that reported, so two
501
+ * messages reach the run in the order they were sent.
502
+ *
503
+ * @throws {MountayaElementsError} when no run is being read and none is on its way: on an
504
+ * engine that never opened one, and once the run has ended, been closed or been disposed.
505
+ * A run that ended takes no more messages, and one the engine has stopped reading would
506
+ * answer to nobody, so the refusal is local rather than a request the gateway refuses. It
507
+ * is the package's own error and no stream fault, because it is a misuse of this package,
508
+ * which is what a consumer catching {@link MountayaElementsError} is catching. The next
509
+ * message goes into a run a new {@link start} opens, except on a disposed engine, which
510
+ * opens no more runs: the conversation continues on a new engine.
511
+ */
512
+ async send(message) {
513
+ if (this.sendReporting) {
514
+ await Promise.resolve();
515
+ }
516
+ const pending = this.pendingStart;
517
+ if (pending !== null && !await pending.opened) {
518
+ return;
519
+ }
520
+ if (this.disposed) {
521
+ throw new chunkISLB6Y5Q_cjs.MountayaElementsError(
522
+ "send: the engine is disposed and opens no more runs. Build a new engine to continue the conversation."
523
+ );
524
+ }
525
+ if (this.state === "ended") {
526
+ throw new chunkISLB6Y5Q_cjs.MountayaElementsError(
527
+ "send: the run has ended, and a run that ended takes no more messages. Open the next run with start()."
528
+ );
529
+ }
530
+ const runId = this.currentRunId;
531
+ if (runId === null) {
532
+ throw new chunkISLB6Y5Q_cjs.MountayaElementsError(
533
+ "send: no run is open. Open one with start(), or re-attach to one with resume(), before sending into it."
534
+ );
535
+ }
536
+ const hold = this.sendHold ?? { found: this.state, posting: 0 };
537
+ hold.posting += 1;
538
+ this.sendHold = hold;
539
+ try {
540
+ this.sendReporting = true;
541
+ try {
542
+ this.reportState("running");
543
+ } finally {
544
+ this.sendReporting = false;
545
+ }
546
+ if (!this.reads(runId)) {
547
+ return;
548
+ }
549
+ await this.config.transport.sendInput(runId, { content: message, type: "user-message" });
550
+ hold.found = null;
551
+ } catch (error) {
552
+ if (this.sendHold === hold && hold.posting === 1 && hold.found === "awaiting_input") {
553
+ this.setState("awaiting_input");
554
+ }
555
+ throw error;
556
+ } finally {
557
+ hold.posting -= 1;
558
+ if (this.sendHold === hold && hold.posting === 0) {
559
+ this.sendHold = null;
560
+ }
561
+ }
562
+ }
563
+ /**
564
+ * reads reports whether `runId` is still the run this engine reads: the engine is neither
565
+ * disposed nor ended, and no start or resume has put another run in its place.
566
+ */
567
+ reads(runId) {
568
+ return !this.disposed && this.state !== "ended" && this.currentRunId === runId;
569
+ }
570
+ /**
571
+ * routedManifest renders the wire manifest for whatever the toolSurface seam
572
+ * currently selects, or the whole permitted set when no router is wired.
573
+ */
574
+ routedManifest() {
575
+ const { bus, ctx, toolSurface } = this.config;
576
+ return toClientToolManifest(bus.manifest(ctx.capabilities, toolSurface?.()));
577
+ }
578
+ /**
579
+ * routedServerTools renders the server-tool allowlist for whatever the
580
+ * toolSurface seam currently selects: the routed name set verbatim, sorted so
581
+ * the wire body and the change key are stable across identical selections.
582
+ * The gateway ignores the client-tool names in it, so no registry knowledge
583
+ * is needed here. Undefined when no router is wired: the run then keeps
584
+ * every server tool. Undefined as well unless the session routes server tools
585
+ * ({@link AgentEngineConfig.routesServerTools}): under a publishable key a run
586
+ * calls none, and a list naming any is refused, so none is sent.
587
+ */
588
+ routedServerTools() {
589
+ if (this.config.routesServerTools !== true) {
590
+ return void 0;
591
+ }
592
+ const surface = this.config.toolSurface?.();
593
+ return surface ? [...surface].sort() : void 0;
594
+ }
595
+ /**
596
+ * routeTools re-reads the toolSurface seam and, when it has moved, replaces the
597
+ * tool set the run offers the model from its next turn on. The model then
598
+ * chooses among a coherent handful for the task at hand instead of the whole
599
+ * registry.
600
+ *
601
+ * It narrows only what the model can SEE. Every tool stays registered on the
602
+ * bus and dispatchable by a human click or an internal tool chain, and the
603
+ * capability gate remains the sole authorization boundary, exactly as
604
+ * `agentHidden` behaves.
605
+ *
606
+ * An unchanged selection sends nothing. That is not just a saved request: the
607
+ * tool array is the outermost part of the provider's cached prompt prefix, so a
608
+ * manifest re-sent on every turn would invalidate the cache every turn and cost
609
+ * far more than routing saves. "Unchanged" means changed since the run last
610
+ * ACCEPTED a set, so a selection whose POST failed is retried on the next call
611
+ * rather than treated as delivered.
612
+ *
613
+ * It is a no-op before a run exists, rather than a throw: routing is advisory,
614
+ * and a surface change while the panel is idle should cost nothing, since the
615
+ * next start() sends the current selection as the run's seed anyway.
616
+ *
617
+ * While a {@link start} still waits on its run id, the seed is already on its way, so the
618
+ * call waits for the run as {@link send} does and then routes it with the selection the
619
+ * surface holds by then. A routing update and a message held behind one start are released
620
+ * in the order they were called, neither waiting on the other's answer, so a caller that
621
+ * needs the selection in the run ahead of its message awaits routeTools() before it calls
622
+ * {@link send}. When that start opens no run, nothing is sent.
623
+ */
624
+ async routeTools() {
625
+ const pending = this.pendingStart;
626
+ if (pending !== null && !await pending.opened) {
627
+ return;
628
+ }
629
+ if (!this.currentRunId || this.state === "ended") {
630
+ return;
631
+ }
632
+ const manifest = this.routedManifest();
633
+ const serverTools = this.routedServerTools();
634
+ const key = routedKey(manifest, serverTools);
635
+ if (key === this.routedNames) {
636
+ return;
637
+ }
638
+ const runId = this.currentRunId;
639
+ this.routingUpdates += 1;
640
+ const update = this.routingUpdates;
641
+ await this.config.transport.sendInput(runId, {
642
+ client_tools: manifest,
643
+ ...serverTools === void 0 ? {} : { server_tools: serverTools },
644
+ type: "manifest-update"
645
+ });
646
+ if (this.currentRunId === runId && update > this.routedUpdate) {
647
+ this.routedNames = key;
648
+ this.routedUpdate = update;
649
+ }
650
+ }
651
+ /**
652
+ * close asks the run to finish. It POSTs a close so the gateway finishes the
653
+ * run successfully (a terminal `done` event), AND aborts the open stream so a
654
+ * consumer parked between turns unwinds promptly rather than waiting on the
655
+ * gateway to close the connection. The terminal `done`, when it arrives first,
656
+ * ends the session.
657
+ *
658
+ * It closes a run the engine stopped reading on its own just the same: one it gave
659
+ * up on at the reconnect ceiling, after two minutes of opens answered 503 or on an
660
+ * open refused for good, which the gateway would otherwise hold open until its own
661
+ * timeout. A run is closed at most once, and a run that read its `done` is closed
662
+ * never: a second call, and a call after `done`, post nothing. So does a call after
663
+ * {@link dispose}, which leaves the run it was reading to the host.
664
+ *
665
+ * During a start that still waits on its run id, close withdraws the start and
666
+ * resolves at once, and the start finishes the run it opens (see {@link start}).
667
+ */
668
+ async close() {
669
+ if (this.pendingStart !== null) {
670
+ this.withdrawStart();
671
+ this.setState("ended");
672
+ return;
673
+ }
674
+ const runId = this.unfinishedRunId;
675
+ if (runId === null) {
676
+ return;
677
+ }
678
+ this.unfinishedRunId = null;
679
+ this.setState("ended");
680
+ this.teardownStream();
681
+ await this.config.transport.sendInput(runId, { type: "close" });
682
+ }
683
+ /**
684
+ * dispose tears the session down without signalling the gateway: it aborts the
685
+ * open stream and marks the run ended, releasing the parked consumer. The host
686
+ * calls it on unmount AFTER close() has POSTed (a closed tab finishes the run),
687
+ * with the abort as the backstop when the consumer would otherwise leak.
688
+ *
689
+ * It is the engine's shutdown latch: {@link start} and {@link resume} open nothing
690
+ * afterwards. What it can still cause is what a start sends to finish the run whose id the
691
+ * host never received, when it was withdrawn or gave up at its ceiling: that run's close,
692
+ * and, when the start's answer was lost, the one last post of the start that names the run
693
+ * (see {@link start}).
694
+ *
695
+ * The run the engine was reading, or stopped reading on its own, is the host's from here:
696
+ * the host holds its id, so it can resume it or close it, and a later {@link close} on
697
+ * this engine posts nothing for it.
698
+ */
699
+ dispose() {
700
+ this.disposed = true;
701
+ this.unfinishedRunId = null;
702
+ this.withdrawStart();
703
+ this.setState("ended");
704
+ this.teardownStream();
705
+ }
706
+ /**
707
+ * leaveRun stops the engine reading what it reads, before a {@link start} or a
708
+ * {@link resume} reads a run: one engine reads one run. A start still waiting on its run
709
+ * id is withdrawn. A run still being read has its stream torn down, so none of its frames,
710
+ * its resume cursor or its `done` reach the run read next. A close is posted for the run the
711
+ * engine still owes one (see `unfinishedRunId`): the run it was reading, and the run it
712
+ * stopped reading on its own, because in both cases the engine was the one party reading
713
+ * it. `next` names the run about to be read, and that run is spared the close when it is
714
+ * the one owed it: a resume of it reads it again.
715
+ */
716
+ leaveRun(next) {
717
+ this.withdrawStart();
718
+ if (this.currentRunId !== null && this.state !== "ended") {
719
+ this.teardownStream();
720
+ }
721
+ const owed = this.unfinishedRunId;
722
+ this.unfinishedRunId = null;
723
+ if (owed !== null && owed !== next) {
724
+ void this.closeQuietly(owed);
725
+ }
726
+ }
727
+ /**
728
+ * withdrawStart withdraws the start still waiting on its run id, if one is: that start then
729
+ * finishes the run it opens instead of reading it (see {@link start}), and every message
730
+ * and routing update held behind it is dropped (see {@link send}).
731
+ */
732
+ withdrawStart() {
733
+ const pending = this.pendingStart;
734
+ this.pendingStart = null;
735
+ pending?.settle(false);
736
+ pending?.withdrawal.abort();
737
+ }
738
+ /**
739
+ * beginRun readies the engine to read a new run once {@link leaveRun} has stopped it
740
+ * reading the last one. The run id, the resume cursor and the stream handle belong to that
741
+ * run, so all three go, and the state returns to `awaiting_input`: `ended` would stop the
742
+ * read loop before it opened anything.
743
+ *
744
+ * The rest is the engine's own and is reported to nobody here. A {@link resume} reports it,
745
+ * since its run may rest for good. A {@link start} reports `running` next, or the rest once
746
+ * it fails, so a start that replaces a run under way is one turn after another to the
747
+ * observer and no rest between them ({@link reportState}).
748
+ *
749
+ * @returns The generation of the read being readied, which a later start or resume replaces.
750
+ */
751
+ beginRun() {
752
+ this.readGeneration += 1;
753
+ this.currentRunId = null;
754
+ this.lastEventId = void 0;
755
+ this.streamAbort = null;
756
+ this.sendHold = null;
757
+ this.state = "awaiting_input";
758
+ return this.readGeneration;
759
+ }
760
+ /**
761
+ * adoptRun makes `runId` the run this engine reads, and the run it owes a close until the
762
+ * run's `done` arrives or a close is posted. The memory of handled calls, and of the calls
763
+ * the engine reported among them, belongs to one run, because call ids are the run's own: it
764
+ * is kept when the run is the one already read (a resume of it) and emptied for any other.
765
+ */
766
+ adoptRun(runId) {
767
+ this.currentRunId = runId;
768
+ this.unfinishedRunId = runId;
769
+ if (this.handledRunId !== runId) {
770
+ this.handledRunId = runId;
771
+ this.handledCalls.clear();
772
+ this.dispatchedCalls.clear();
773
+ this.runningCalls.clear();
774
+ }
775
+ }
776
+ /**
777
+ * claimCall records a call id as handled and reports whether the frame that names it is
778
+ * the engine's to act on. Two frames are not, and each is dropped whole:
779
+ *
780
+ * - one whose id the run already sighted, a replay of a call the engine ran or answered
781
+ * itself, whose result is already posted;
782
+ * - one the stream marks `settled`, a replay of a call whose outcome the stream already
783
+ * holds. An engine built after a page reload has no memory of the run, so the marker is
784
+ * all that tells it the call was answered.
785
+ *
786
+ * A settled id is recorded like any other, so a later frame that names it without the
787
+ * marker runs nothing either. A replayed frame with no marker and an id never sighted is
788
+ * one the stream holds no outcome for, and is the engine's.
789
+ */
790
+ claimCall(toolCallId, settled) {
791
+ const sighted = this.handledCalls.has(toolCallId);
792
+ this.handledCalls.add(toolCallId);
793
+ return !sighted && settled !== true;
794
+ }
795
+ /**
796
+ * closeQuietly posts a close for a live run the engine leaves behind: one a withdrawn start
797
+ * opened and never read, whose id the host never received, and one a later start or resume
798
+ * replaced. A failed post is dropped: nobody is
799
+ * left to tell, and the gateway completes a run that goes quiet on its own.
800
+ */
801
+ async closeQuietly(runId) {
802
+ try {
803
+ await this.config.transport.sendInput(runId, { type: "close" });
804
+ } catch {
805
+ }
806
+ }
807
+ /**
808
+ * releaseSubscription stops callback delivery from the open stream, exactly
809
+ * once. It reads the handle out and clears it BEFORE invoking it, so a
810
+ * re-entrant settle (the abort listener firing synchronously inside
811
+ * teardownStream, or a transport calling back into onClose) finds nothing
812
+ * left to release rather than calling the same handle twice.
813
+ */
814
+ releaseSubscription() {
815
+ const unsubscribe = this.unsubscribe;
816
+ this.unsubscribe = null;
817
+ unsubscribe?.();
818
+ }
819
+ /**
820
+ * teardownStream releases the open events stream from both sides: the
821
+ * unsubscribe stops callback delivery (covering the scripted drain, which has
822
+ * no fetch to abort), and the abort closes the live fetch (and trips the resume
823
+ * detection in run()). Idempotent, so close() followed by dispose() is harmless.
824
+ *
825
+ * The unsubscribe runs FIRST because abort() dispatches its listener
826
+ * synchronously: that listener settles the read and clears the handle, so
827
+ * aborting first would leave nothing to unsubscribe and the scripted drain
828
+ * would stay parked for the life of the process.
829
+ */
830
+ teardownStream() {
831
+ this.releaseSubscription();
832
+ this.streamAbort?.abort();
833
+ }
834
+ /**
835
+ * run consumes the run's event stream to completion, reconnecting when the
836
+ * stream closes before a terminal event. The gateway may close an SSE
837
+ * connection between turns (e.g. after `awaiting-input`); rather than leave the
838
+ * run silently stuck, run re-opens the stream from the tracked Last-Event-ID so
839
+ * the conversation continues. It returns once a terminal event ends the run, an
840
+ * abort tears the stream down, or the reconnects stop being productive: an open that
841
+ * closes having said nothing or one frame waits on the reconnect schedule, and the
842
+ * attempt ceiling below bounds how many of them in a row the run is given.
843
+ *
844
+ * A read that FAILS is judged by {@link isTransientStreamFault}. A transient one (a
845
+ * dropped connection, a 429, 503 or 504 at open) reopens from the last id on the same
846
+ * schedule and under the same ceiling as a hangup, and when the ceiling is reached on a
847
+ * read that failed, that failure (the drop, or the 429 or 504) is what the caller
848
+ * receives. The client's own reader reports an open that never answers and a stream gone
849
+ * silent as dropped connections, so both reopen. Any other failure ends the read at once and
850
+ * rejects with it. Either way the state is `ended` before the rejection, because the engine
851
+ * has stopped reading the run, and the run is owed a close (see {@link close}).
852
+ *
853
+ * An open answered 503 reopens on that schedule and outside that ceiling: it is left out of
854
+ * the count, neither adding to it nor clearing it, and such opens are bounded by
855
+ * {@link RECONNECT_UNAVAILABLE_MAX_MS} from the first of them, past which the caller receives
856
+ * the 503. A turn that moves starts the count and that time again.
857
+ *
858
+ * A stream that ends with the credential it was opened with, or that the API could not keep
859
+ * delivering (`interrupted`), reopens at once from the last id, and clears the count of
860
+ * fruitless opens: the transport closes either as `reconnect`, and the reopen carries the
861
+ * session token the client holds by then. A 401 on that reopen is a failure like any other
862
+ * refusal, and ends the read.
863
+ *
864
+ * A teardown ends the read wherever it finds it, the backoff between two opens included:
865
+ * a close or a dispose, and a start or a resume that replaced this run (see
866
+ * {@link leaveRun}).
867
+ */
868
+ async run(runId) {
869
+ let attempts = 0;
870
+ let unavailable = null;
871
+ while (this.state !== "ended") {
872
+ const abort = new AbortController();
873
+ this.streamAbort = abort;
874
+ const result = await this.consume(runId, abort.signal);
875
+ if (result.ended || abort.signal.aborted) {
876
+ return;
877
+ }
878
+ const { failure } = result;
879
+ if (failure !== void 0 && !failure.transient) {
880
+ this.setState("ended");
881
+ throw failure.error;
882
+ }
883
+ if (result.reconnect === true) {
884
+ attempts = 0;
885
+ unavailable = null;
886
+ continue;
887
+ }
888
+ if (result.frames > PRODUCTIVE_FRAME_COUNT) {
889
+ attempts = 0;
890
+ unavailable = null;
891
+ continue;
892
+ }
893
+ attempts += 1;
894
+ if (failure !== void 0 && chunkUYUBSD2V_cjs.statusOf(failure.error) === UNAVAILABLE_STATUS) {
895
+ unavailable ??= { count: 0, since: Date.now() };
896
+ unavailable.count += 1;
897
+ if (Date.now() - unavailable.since >= RECONNECT_UNAVAILABLE_MAX_MS) {
898
+ this.setState("ended");
899
+ throw failure.error;
900
+ }
901
+ } else if (attempts - (unavailable?.count ?? 0) > RECONNECT_MAX_ATTEMPTS) {
902
+ this.setState("ended");
903
+ if (failure !== void 0) {
904
+ throw failure.error;
905
+ }
906
+ return;
907
+ }
908
+ await this.backoff(attempts, abort.signal, chunkUYUBSD2V_cjs.retryAfterMsOf(failure?.error));
909
+ if (abort.signal.aborted) {
910
+ return;
911
+ }
912
+ }
913
+ }
914
+ /**
915
+ * backoff waits out one reconnect delay, drawn by {@link reconnectDelayMs} on the run's
916
+ * {@link reconnectSchedule}: below a ceiling that doubles from AGENT_RECONNECT_BASE_MS to
917
+ * RECONNECT_MAX_MS, so the wait stays inside a person's patience and runs dropped together
918
+ * do not reopen together. Where the failure was a 429 or a 503 that named its wait (`namedMs`),
919
+ * that wait replaces the draw, with up to a second drawn above it and the timer's ceiling over
920
+ * it ({@link retryAfterDelayMs}), as SPEC §2 has `Retry-After` replace the schedule. It settles
921
+ * on whichever comes first, the timer or the stream teardown's abort, and drops both hooks
922
+ * either way: a run that reconnects many times must not accumulate listeners on the signal, nor
923
+ * leave a timer holding the loop after the session is gone.
924
+ */
925
+ backoff(attempts, signal, namedMs) {
926
+ const delay = namedMs === void 0 ? chunkUYUBSD2V_cjs.reconnectDelayMs(attempts, reconnectSchedule) : chunkUYUBSD2V_cjs.retryAfterDelayMs(namedMs);
927
+ return new Promise((resolve) => {
928
+ const settle = () => {
929
+ clearTimeout(timer);
930
+ signal.removeEventListener("abort", settle);
931
+ resolve();
932
+ };
933
+ const timer = setTimeout(settle, delay);
934
+ signal.addEventListener("abort", settle, { once: true });
935
+ });
936
+ }
937
+ /**
938
+ * consume opens one read of the run's events stream and settles when it
939
+ * finishes, bridging the transport's AgentStreamHandlers callbacks to a single
940
+ * promise run() can await. It reacts to each decoded frame and records its id as
941
+ * the resume position when the frame arrives, taking it back when the frame's handling
942
+ * throws; the transport has already validated every frame, so it trusts the typed
943
+ * event. Unlike a per-turn drive it does NOT stop on
944
+ * `awaiting-input` (the stream stays open for the next message). It resolves
945
+ * with whether a terminal event ended the run and how many frames the stream
946
+ * delivered, so the caller can decide between reconnecting and settling and
947
+ * tell a productive open from a fruitless one, and with the failure when the
948
+ * read failed. It never rejects, a transport that throws from the open included:
949
+ * whether a failure ends the run is run()'s call.
950
+ * A terminal the SESSION decides (handle returning true on `done`) tears the
951
+ * subscription down here so no further frame is processed after the run is
952
+ * over. A teardown's abort (a close, a dispose, or a start or resume that replaced
953
+ * the run) settles the promise on its own (the transport fires no callback on a
954
+ * deliberate abort), so run() unwinds without waiting on a dead stream.
955
+ *
956
+ * It is one closure on purpose. Every handler reads and writes this read's own settle
957
+ * latch and frame count, and held as fields they would be the next read's to reach.
958
+ */
959
+ consume(runId, signal) {
960
+ return new Promise((resolve) => {
961
+ let frames = 0;
962
+ let settled = false;
963
+ let unsubscribe;
964
+ let released = false;
965
+ const release = () => {
966
+ if (released) {
967
+ return;
968
+ }
969
+ released = true;
970
+ unsubscribe?.();
971
+ };
972
+ const settle = () => {
973
+ if (settled) {
974
+ return false;
975
+ }
976
+ settled = true;
977
+ signal.removeEventListener("abort", onAbort);
978
+ if (this.unsubscribe === release) {
979
+ this.unsubscribe = null;
980
+ }
981
+ release();
982
+ return true;
983
+ };
984
+ const finish = (ended, reconnect = false) => {
985
+ if (!settle()) {
986
+ return;
987
+ }
988
+ resolve({ ended, frames, reconnect });
989
+ };
990
+ const fail = (error, transient) => {
991
+ if (!settle()) {
992
+ return;
993
+ }
994
+ resolve({ ended: false, failure: { error, transient }, frames });
995
+ };
996
+ const onAbort = () => finish(false);
997
+ if (signal.aborted) {
998
+ finish(false);
999
+ return;
1000
+ }
1001
+ signal.addEventListener("abort", onAbort, { once: true });
1002
+ const handlers = {
1003
+ onClose: (reason) => finish(reason === "terminal", reason === "reconnect"),
1004
+ onError: (error) => fail(error, isTransientStreamFault(error)),
1005
+ onFrame: async (frame) => {
1006
+ if (settled) {
1007
+ return;
1008
+ }
1009
+ frames += 1;
1010
+ const before = this.lastEventId;
1011
+ if (frame.id !== void 0) {
1012
+ this.lastEventId = frame.id;
1013
+ }
1014
+ let ended;
1015
+ try {
1016
+ ended = await this.handle(runId, frame.event);
1017
+ } catch (error) {
1018
+ if (frame.id !== void 0 && !settled && this.lastEventId === frame.id) {
1019
+ this.lastEventId = before;
1020
+ }
1021
+ fail(error, false);
1022
+ return;
1023
+ }
1024
+ if (ended) {
1025
+ finish(true);
1026
+ if (this.streamAbort?.signal === signal) {
1027
+ this.teardownStream();
1028
+ }
1029
+ }
1030
+ },
1031
+ // A record that names a position and carries no frame moves the cursor too, so a
1032
+ // reopen resumes from the last position the stream named. A settled read's report is
1033
+ // stale, like its frames.
1034
+ onLastEventId: (lastEventId) => {
1035
+ if (!settled) {
1036
+ this.lastEventId = lastEventId;
1037
+ }
1038
+ },
1039
+ // A frame the transport skips, an event this build does not know or data it cannot read,
1040
+ // hands the run nothing and moves no position, and it is still a frame the stream
1041
+ // delivered: a stream saying one thing and then one this build skips has said two.
1042
+ onSkippedFrame: () => {
1043
+ if (!settled) {
1044
+ frames += 1;
1045
+ }
1046
+ }
1047
+ };
1048
+ try {
1049
+ unsubscribe = this.config.transport.subscribe(runId, handlers, {
1050
+ lastEventId: this.lastEventId,
1051
+ signal
1052
+ });
1053
+ } catch (error) {
1054
+ fail(error, false);
1055
+ return;
1056
+ }
1057
+ if (released) {
1058
+ unsubscribe();
1059
+ } else {
1060
+ this.unsubscribe = release;
1061
+ }
1062
+ });
1063
+ }
1064
+ /**
1065
+ * handle reacts to one event of the run `runId` names and reports whether the run
1066
+ * ended (so consume can stop). An active-turn event (streamed text, a tool call, a
1067
+ * confirm request) flips the lifecycle to `running`; a client tool-call is dispatched
1068
+ * through the bus and its result posted back; a confirm-required is routed through
1069
+ * the host gate and the decision posted back. Both answers go to `runId`, the run that
1070
+ * asked, even when a later start or resume replaced it while the tool ran or the host
1071
+ * decided. A tool-call or a confirm-required that {@link claimCall} refuses, one the
1072
+ * stream marks `settled` or one the run already handled, is dropped whole: it reaches
1073
+ * neither the bus, the gate nor the observer, and leaves the lifecycle as it is. An
1074
+ * `awaiting-input` event settles the turn to the `awaiting_input` state but
1075
+ * keeps the stream open (returns false); only a terminal `done` ends the run (returns
1076
+ * true).
1077
+ */
1078
+ async handle(runId, event) {
1079
+ switch (event.type) {
1080
+ case "message-delta":
1081
+ this.setState("running");
1082
+ this.tell((observer) => observer.onMessageDelta?.(event.text));
1083
+ return false;
1084
+ case "message":
1085
+ this.setState("running");
1086
+ this.tell((observer) => observer.onMessage?.(event.content, event.message_index));
1087
+ return false;
1088
+ case "tool-call":
1089
+ return this.handleToolCall(runId, event);
1090
+ case "confirm-required":
1091
+ return this.handleConfirmRequired(runId, event);
1092
+ case "budget-exhausted":
1093
+ this.tell((observer) => observer.onError?.(event.reason, "budget-exhausted"));
1094
+ return false;
1095
+ case "error":
1096
+ this.tell((observer) => observer.onError?.(event.message, event.code));
1097
+ return false;
1098
+ case "checks-unmet":
1099
+ this.tell((observer) => observer.onChecksUnmet?.(event.unmet));
1100
+ return false;
1101
+ case "awaiting-input":
1102
+ this.setState("awaiting_input");
1103
+ return false;
1104
+ case "done":
1105
+ return this.handleDone(runId, event);
1106
+ case "tool-result":
1107
+ return this.handleToolResult(event);
1108
+ case "tool-abandoned":
1109
+ return this.handleToolAbandoned(event);
1110
+ case "reconnect":
1111
+ return false;
1112
+ }
1113
+ }
1114
+ /**
1115
+ * handleToolCall runs one client tool call through the bus, reports it to the observer and
1116
+ * posts its result back into the run that asked. It answers false: a tool call never ends
1117
+ * the run.
1118
+ *
1119
+ * The call is running from its claim to its report. What the stream says of it meanwhile is
1120
+ * held ({@link holdWhileRunning}), and released when the handling throws before the report:
1121
+ * the engine has no report of its own then, and the stream's word settles the host's row.
1122
+ */
1123
+ async handleToolCall(runId, event) {
1124
+ if (!this.claimCall(event.tool_call_id, event.settled)) {
1125
+ return false;
1126
+ }
1127
+ this.runningCalls.set(event.tool_call_id, null);
1128
+ try {
1129
+ return await this.runToolCall(runId, event);
1130
+ } catch (error) {
1131
+ this.releaseHeldWord(runId, event.tool_call_id);
1132
+ throw error;
1133
+ }
1134
+ }
1135
+ /**
1136
+ * releaseHeldWord takes a call out of the running set and delivers what the stream said of it
1137
+ * while it ran, when it said anything. A call the engine reported is out of the set already,
1138
+ * and so is every call of a run the engine no longer holds the memory of: both release
1139
+ * nothing.
1140
+ */
1141
+ releaseHeldWord(runId, toolCallId) {
1142
+ if (this.handledRunId !== runId) {
1143
+ return;
1144
+ }
1145
+ const held = this.runningCalls.get(toolCallId);
1146
+ this.runningCalls.delete(toolCallId);
1147
+ held?.();
1148
+ }
1149
+ /**
1150
+ * holdWhileRunning keeps what the stream says of a call the engine is still running, as the
1151
+ * report it would have made, and answers whether it did. The first word is the one kept: a
1152
+ * failed `tool-result` follows the `tool-abandoned` of a call the run gave up on.
1153
+ */
1154
+ holdWhileRunning(toolCallId, report) {
1155
+ if (!this.runningCalls.has(toolCallId)) {
1156
+ return false;
1157
+ }
1158
+ if (this.runningCalls.get(toolCallId) === null) {
1159
+ this.runningCalls.set(toolCallId, report);
1160
+ }
1161
+ return true;
1162
+ }
1163
+ /** runToolCall is the handling of a claimed client tool call: see {@link handleToolCall}. */
1164
+ async runToolCall(runId, event) {
1165
+ const { bus, ctx, recoveryFor, stateDelta } = this.config;
1166
+ this.setState("running");
1167
+ this.tell((observer) => observer.onToolActivity?.(event.name));
1168
+ this.tell((observer) => observer.onToolCall?.(event.name, event.input, event.tool_call_id));
1169
+ const before = stateDelta?.capture(ctx);
1170
+ const result = await bus.dispatchFromModel(ctx, event.name, event.input);
1171
+ const moved = stateDelta && before !== void 0 ? stateDelta.diff(before, stateDelta.capture(ctx)) : void 0;
1172
+ if (result.ok && result.summary) {
1173
+ this.tell((observer) => observer.onToolActivity?.(result.summary));
1174
+ }
1175
+ const recovery = result.ok ? void 0 : recoveryFor?.(event.name, result.code);
1176
+ if (this.handledRunId === runId) {
1177
+ this.dispatchedCalls.add(event.tool_call_id);
1178
+ this.runningCalls.delete(event.tool_call_id);
1179
+ }
1180
+ this.tell(
1181
+ (observer) => observer.onToolResult?.(
1182
+ event.tool_call_id,
1183
+ result.ok ? { status: "ok", summary: result.summary } : result.code === "confirmation-denied" ? { status: "abandoned" } : { error: result.error, recovery, status: "error" }
1184
+ )
1185
+ );
1186
+ await this.postInput(runId, {
1187
+ ok: result.ok,
1188
+ tool_call_id: event.tool_call_id,
1189
+ type: "tool-result",
1190
+ ...result.ok ? { result: buildToolResultPayload(result.summary, result.data, moved) } : {
1191
+ code: toWireErrorCode(result.code),
1192
+ error: result.error,
1193
+ // What to do about THIS failure of THIS tool, when the playbook
1194
+ // says. It rides the failing result rather than the prompt so it
1195
+ // costs nothing for the codes that never fire.
1196
+ ...recovery ? { recovery } : {}
1197
+ }
1198
+ });
1199
+ return false;
1200
+ }
1201
+ /**
1202
+ * handleConfirmRequired puts a server tool's confirmation to the host gate and posts the
1203
+ * decision back into the run that asked. It answers false: a confirmation never ends the
1204
+ * run.
1205
+ */
1206
+ async handleConfirmRequired(runId, event) {
1207
+ if (!this.claimCall(event.tool_call_id, event.settled)) {
1208
+ return false;
1209
+ }
1210
+ this.setState("running");
1211
+ const approved = await this.config.confirmServerTool({ name: event.name });
1212
+ await this.postInput(runId, {
1213
+ approved,
1214
+ tool_call_id: event.tool_call_id,
1215
+ type: "confirm"
1216
+ });
1217
+ return false;
1218
+ }
1219
+ /**
1220
+ * handleDone reports how the run ended and ends the read, unless a start or a resume made
1221
+ * from the callback has already replaced it. It answers true: `done` is the one terminal.
1222
+ */
1223
+ handleDone(runId, event) {
1224
+ if (this.unfinishedRunId === runId) {
1225
+ this.unfinishedRunId = null;
1226
+ }
1227
+ const generation = this.readGeneration;
1228
+ this.tell((observer) => observer.onRunEnd?.(event.reason));
1229
+ if (generation === this.readGeneration) {
1230
+ this.setState("ended");
1231
+ }
1232
+ return true;
1233
+ }
1234
+ /**
1235
+ * handleToolResult reports a call's outcome as the stream states it, unless the call is one
1236
+ * the engine ran and reported itself. It answers false.
1237
+ */
1238
+ handleToolResult(event) {
1239
+ if (this.dispatchedCalls.has(event.tool_call_id)) {
1240
+ return false;
1241
+ }
1242
+ const report = () => {
1243
+ const { summary } = event;
1244
+ if (summary) {
1245
+ this.tell((observer) => observer.onToolActivity?.(summary));
1246
+ }
1247
+ this.tell(
1248
+ (observer) => observer.onToolResult?.(
1249
+ event.tool_call_id,
1250
+ event.ok ? { status: "ok", summary: event.summary } : { error: event.error, status: "error" }
1251
+ )
1252
+ );
1253
+ };
1254
+ if (!this.holdWhileRunning(event.tool_call_id, report)) {
1255
+ report();
1256
+ }
1257
+ return false;
1258
+ }
1259
+ /**
1260
+ * handleToolAbandoned reports a call the run gave up on, unless the call is one the engine
1261
+ * ran and reported itself. It answers false.
1262
+ */
1263
+ handleToolAbandoned(event) {
1264
+ if (this.dispatchedCalls.has(event.tool_call_id)) {
1265
+ return false;
1266
+ }
1267
+ const report = () => {
1268
+ this.tell(
1269
+ (observer) => observer.onToolResult?.(event.tool_call_id, {
1270
+ abandonedReason: event.reason,
1271
+ status: "abandoned"
1272
+ })
1273
+ );
1274
+ };
1275
+ if (!this.holdWhileRunning(event.tool_call_id, report)) {
1276
+ report();
1277
+ }
1278
+ return false;
1279
+ }
1280
+ /**
1281
+ * setState records the lifecycle transition and notifies the observer only on
1282
+ * an actual change, so the host does not re-render on a no-op.
1283
+ *
1284
+ * Every report, a no-op included, drops the hold the sends being posted have on `running`:
1285
+ * whatever speaks here (a frame, a close, a new run) owns the state from then on. A send
1286
+ * reports its own `running` through {@link reportState}, which keeps the hold.
1287
+ */
1288
+ setState(next) {
1289
+ this.sendHold = null;
1290
+ this.reportState(next);
1291
+ }
1292
+ /**
1293
+ * reportState is {@link setState} without the drop of the hold, for the one report that is
1294
+ * the hold's own: the `running` of a send.
1295
+ *
1296
+ * The observer is told a state that differs from the one it was told last, which is the
1297
+ * engine's own state but while a start readies its run ({@link beginRun}).
1298
+ */
1299
+ reportState(next) {
1300
+ this.state = next;
1301
+ if (this.reported === next) {
1302
+ return;
1303
+ }
1304
+ this.reported = next;
1305
+ this.tell((observer) => observer.onStateChange?.(next));
1306
+ }
1307
+ /**
1308
+ * tell hands the observer one report. The observer answers nothing the run waits on, so a
1309
+ * callback that throws is a defect of the host's own rendering and never the run's: its fault
1310
+ * reaches the program through {@link surfaceFault}, and the read goes on.
1311
+ */
1312
+ tell(report) {
1313
+ try {
1314
+ report(this.config.observer);
1315
+ } catch (fault) {
1316
+ chunkWW4CGS7G_cjs.surfaceFault(fault);
1317
+ }
1318
+ }
1319
+ /**
1320
+ * postInput sends one input frame back into the run `runId` names, the run that asked
1321
+ * for it, and reports a failure as a fault in the conversation instead of throwing.
1322
+ *
1323
+ * The catch is the point. `start()` ends with `await this.run(runId)`, so the whole
1324
+ * consume loop lives inside the start promise, and an unguarded rejection here would
1325
+ * leave `handle()` as a fault of the engine's own: the read would end for good, and
1326
+ * `start()` would reject into the host's START error path. A network blip on turn
1327
+ * twelve would then render "could not start", clear the started guard and drop the run
1328
+ * id, so the still-alive gateway run could never be resumed and the model's call would
1329
+ * expire as `tool-abandoned` with the user told nothing true about why.
1330
+ *
1331
+ * Reporting and continuing is the right shape: the run is still open, the stream is
1332
+ * still readable, and the gateway abandons the unanswered call on its own timeout so
1333
+ * the model can replan. What is lost is one tool result, which is a turn-level fault,
1334
+ * not a session-level one. A run a later start or resume replaced has nobody reading
1335
+ * it, so a failure to answer it is dropped rather than reported into the run that
1336
+ * replaced it. So is a failure to answer a run the engine has stopped reading, after a
1337
+ * {@link close} or a {@link dispose}: the host ended that conversation, and an error line
1338
+ * under it would report a fault in a run nobody is in.
1339
+ *
1340
+ * The message is deliberately empty. A fetch rejection carries an English,
1341
+ * internal string, and the host resolves an empty message to its own localized
1342
+ * generic line, the same rule the run's other self-raised terminals follow.
1343
+ */
1344
+ async postInput(runId, input) {
1345
+ try {
1346
+ await this.config.transport.sendInput(runId, input);
1347
+ } catch {
1348
+ if (this.currentRunId === runId && this.state !== "ended") {
1349
+ this.tell((observer) => observer.onError?.(""));
1350
+ }
1351
+ }
1352
+ }
1353
+ };
1354
+
1355
+ // src/agent/rules/agentError.ts
1356
+ var resolveAgentError = (message, code, copy, draft) => {
1357
+ if (code === "rate-limited") {
1358
+ return copy.rateLimited;
1359
+ }
1360
+ if (code === "ai-provider-not-configured") {
1361
+ return copy.notConfigured;
1362
+ }
1363
+ if (code === "looping") {
1364
+ return copy.looping;
1365
+ }
1366
+ if (code === "access-revoked") {
1367
+ return copy.accessRevoked;
1368
+ }
1369
+ if (code === "budget-exhausted") {
1370
+ const line = (() => {
1371
+ switch (message.trim()) {
1372
+ case "turns":
1373
+ return copy.budget.turns;
1374
+ case "cost":
1375
+ return copy.budget.cost;
1376
+ default:
1377
+ return copy.budget.generic;
1378
+ }
1379
+ })();
1380
+ return draft?.open ? `${line} ${draft.note}` : line;
1381
+ }
1382
+ const trimmed = message.trim();
1383
+ return trimmed.length > 0 ? trimmed : copy.generic;
1384
+ };
1385
+
1386
+ // src/agent/rules/boundedInputJson.ts
1387
+ var MAX_TOOL_INPUT_CHARS = 2e3;
1388
+ var HIGH_SURROGATE_FIRST = 55296;
1389
+ var HIGH_SURROGATE_LAST = 56319;
1390
+ var boundedInputJson = (input) => {
1391
+ let json;
1392
+ try {
1393
+ json = JSON.stringify(input, null, 2);
1394
+ } catch {
1395
+ return null;
1396
+ }
1397
+ if (json === void 0) {
1398
+ return null;
1399
+ }
1400
+ if (json.length <= MAX_TOOL_INPUT_CHARS) {
1401
+ return json;
1402
+ }
1403
+ const last = json.charCodeAt(MAX_TOOL_INPUT_CHARS - 1);
1404
+ const splitsPair = last >= HIGH_SURROGATE_FIRST && last <= HIGH_SURROGATE_LAST;
1405
+ return `${json.slice(0, splitsPair ? MAX_TOOL_INPUT_CHARS - 1 : MAX_TOOL_INPUT_CHARS)}\u2026`;
1406
+ };
1407
+
1408
+ // src/agent/rules/conversation.ts
1409
+ var appendQuestionEntry = (transcript, question) => {
1410
+ if (question.options.length === 0) {
1411
+ return transcript;
1412
+ }
1413
+ if (transcript.some((entry) => entry.id === question.toolCallId)) {
1414
+ return transcript;
1415
+ }
1416
+ return [
1417
+ ...transcript,
1418
+ {
1419
+ id: question.toolCallId,
1420
+ options: question.options,
1421
+ question: question.question,
1422
+ role: "question",
1423
+ selected: null,
1424
+ settled: false
1425
+ }
1426
+ ];
1427
+ };
1428
+ var answerQuestionEntry = (transcript, entryId, label) => transcript.map(
1429
+ (entry) => entry.role === "question" && entry.id === entryId && !entry.settled ? { ...entry, selected: label, settled: true } : entry
1430
+ );
1431
+ var settleOpenQuestionEntries = (transcript) => {
1432
+ if (!transcript.some((entry) => entry.role === "question" && !entry.settled)) {
1433
+ return transcript;
1434
+ }
1435
+ return transcript.map(
1436
+ (entry) => entry.role === "question" && !entry.settled ? { ...entry, settled: true } : entry
1437
+ );
1438
+ };
1439
+ var appendSuggestionsEntry = (transcript, suggestions) => {
1440
+ if (suggestions.candidates.length === 0) {
1441
+ return transcript;
1442
+ }
1443
+ if (transcript.some((entry) => entry.id === suggestions.entryId)) {
1444
+ return transcript;
1445
+ }
1446
+ return [
1447
+ ...settleOpenSuggestionEntries(transcript),
1448
+ {
1449
+ candidates: suggestions.candidates,
1450
+ chosenSeed: null,
1451
+ id: suggestions.entryId,
1452
+ role: "suggestions",
1453
+ settled: false
1454
+ }
1455
+ ];
1456
+ };
1457
+ var chooseSuggestionEntry = (transcript, entryId, seed) => transcript.map(
1458
+ (entry) => entry.role === "suggestions" && entry.id === entryId && !entry.settled ? { ...entry, chosenSeed: seed, settled: true } : entry
1459
+ );
1460
+ var settleOpenSuggestionEntries = (transcript) => {
1461
+ if (!transcript.some((entry) => entry.role === "suggestions" && !entry.settled)) {
1462
+ return transcript;
1463
+ }
1464
+ return transcript.map(
1465
+ (entry) => entry.role === "suggestions" && !entry.settled ? { ...entry, settled: true } : entry
1466
+ );
1467
+ };
1468
+ var appendWarningEntry = (transcript, lines) => {
1469
+ if (lines.length === 0) {
1470
+ return transcript;
1471
+ }
1472
+ return [...transcript, { id: mintEntryId(), lines, role: "warning" }];
1473
+ };
1474
+ var appendErrorEntry = (transcript, message) => [
1475
+ ...transcript,
1476
+ { content: message, id: mintEntryId(), role: "error" }
1477
+ ];
1478
+ var appendUserEntry = (transcript, content) => [
1479
+ ...transcript,
1480
+ { content, id: mintEntryId(), role: "user" }
1481
+ ];
1482
+ var appendActivityEntry = (transcript, activity) => {
1483
+ if (transcript.some((entry) => entry.id === activity.toolCallId)) {
1484
+ return transcript;
1485
+ }
1486
+ return [
1487
+ ...transcript,
1488
+ {
1489
+ abandonedReason: null,
1490
+ error: null,
1491
+ id: activity.toolCallId,
1492
+ input: activity.input,
1493
+ label: null,
1494
+ name: activity.name,
1495
+ recovery: null,
1496
+ role: "activity",
1497
+ status: "running"
1498
+ }
1499
+ ];
1500
+ };
1501
+ var settleActivityEntry = (transcript, toolCallId, outcome) => {
1502
+ if (transcript.some((entry) => entry.role === "question" && entry.id === toolCallId)) {
1503
+ return transcript;
1504
+ }
1505
+ const index = transcript.findLastIndex(
1506
+ (entry) => entry.role === "activity" && entry.id === toolCallId
1507
+ );
1508
+ if (index === -1) {
1509
+ return [
1510
+ ...transcript,
1511
+ {
1512
+ abandonedReason: outcome.abandonedReason ?? null,
1513
+ error: outcome.error ?? null,
1514
+ id: toolCallId,
1515
+ input: null,
1516
+ label: outcome.summary ?? null,
1517
+ name: null,
1518
+ recovery: outcome.recovery ?? null,
1519
+ role: "activity",
1520
+ status: outcome.status
1521
+ }
1522
+ ];
1523
+ }
1524
+ const found = transcript[index];
1525
+ if (found?.role === "activity" && found.status !== "running") {
1526
+ return transcript;
1527
+ }
1528
+ return transcript.map(
1529
+ (entry, i) => i === index && entry.role === "activity" ? {
1530
+ ...entry,
1531
+ abandonedReason: outcome.abandonedReason ?? null,
1532
+ error: outcome.error ?? null,
1533
+ label: outcome.summary ?? null,
1534
+ recovery: outcome.recovery ?? null,
1535
+ status: outcome.status
1536
+ } : entry
1537
+ );
1538
+ };
1539
+ var mintEntryId = () => chunk4F6BJMJC_cjs.localId();
1540
+ var isAssistantTurn = (entry) => entry.role === "assistant";
1541
+ var accumulateAssistant = (transcript, delta) => {
1542
+ const last = transcript.at(-1);
1543
+ if (last && isAssistantTurn(last) && last.messageIndex === void 0) {
1544
+ return [...transcript.slice(0, -1), { ...last, content: last.content + delta }];
1545
+ }
1546
+ return [...transcript, { content: delta, id: mintEntryId(), role: "assistant" }];
1547
+ };
1548
+ var settlesLastTurn = (last, messageIndex) => messageIndex === void 0 || last.messageIndex === void 0 || last.messageIndex === messageIndex;
1549
+ var replaceAssistant = (transcript, content, messageIndex) => {
1550
+ const last = transcript.at(-1);
1551
+ if (last && isAssistantTurn(last) && settlesLastTurn(last, messageIndex)) {
1552
+ return [...transcript.slice(0, -1), { ...last, content, messageIndex }];
1553
+ }
1554
+ return [...transcript, { content, id: mintEntryId(), messageIndex, role: "assistant" }];
1555
+ };
1556
+
1557
+ // src/agent/rules/conversationFaults.ts
1558
+ var startRefusal = (error) => {
1559
+ const status = chunkUYUBSD2V_cjs.statusOf(error);
1560
+ if (status === void 0 || typeof error !== "object" || error === null) {
1561
+ return null;
1562
+ }
1563
+ const code = "code" in error && typeof error.code === "string" ? error.code : void 0;
1564
+ return { code, status };
1565
+ };
1566
+ var TOO_LARGE_STATUS = 413;
1567
+ var RATE_LIMITED_STATUS = 429;
1568
+ var refusedAsSent = (status, copy) => {
1569
+ if (status === TOO_LARGE_STATUS) {
1570
+ return copy.tooLarge;
1571
+ }
1572
+ if (status === RATE_LIMITED_STATUS) {
1573
+ return copy.rateLimited;
1574
+ }
1575
+ return void 0;
1576
+ };
1577
+ var ACCESS_STATUSES = [402, 403, 404];
1578
+ var SIGN_IN_REFUSED_STATUS = 401;
1579
+ var createConversationFaults = (config) => {
1580
+ const { copy, invalidateAiConfig, invalidateMemberships, onSettled, onSignInRefused, writer } = config;
1581
+ const tellHost = (tell) => {
1582
+ try {
1583
+ tell();
1584
+ } catch (fault) {
1585
+ chunkWW4CGS7G_cjs.surfaceFault(fault);
1586
+ }
1587
+ };
1588
+ const tellSignInRefused = (status) => {
1589
+ if (status === SIGN_IN_REFUSED_STATUS) {
1590
+ tellHost(() => onSignInRefused?.());
1591
+ }
1592
+ };
1593
+ return {
1594
+ handleStartError: (organizationId, error, runId) => {
1595
+ writer.setRunId(null);
1596
+ writer.setSessionState("awaiting_input");
1597
+ const refusal = startRefusal(error);
1598
+ const credentialGone = refusal?.status === 409 && refusal.code === "AI_PROVIDER_NOT_CONFIGURED";
1599
+ const startNotReached = refusal?.status === 404 && runId === void 0;
1600
+ if (refusal?.status === 402) {
1601
+ writer.appendError(copy.notEntitled);
1602
+ } else if (refusal?.status === 403 || startNotReached) {
1603
+ writer.appendError(copy.noAccess);
1604
+ } else if (credentialGone) {
1605
+ writer.appendError(copy.notConfigured);
1606
+ } else {
1607
+ writer.appendError(refusedAsSent(refusal?.status, copy) ?? copy.generic);
1608
+ }
1609
+ onSettled?.();
1610
+ if (credentialGone) {
1611
+ tellHost(() => invalidateAiConfig?.(organizationId));
1612
+ }
1613
+ if (refusal !== null && ACCESS_STATUSES.includes(refusal.status)) {
1614
+ tellHost(() => invalidateMemberships?.());
1615
+ }
1616
+ tellSignInRefused(refusal?.status);
1617
+ },
1618
+ // No onSettled here: no run opened, so there is no run id for a surface to
1619
+ // mirror anywhere, only the hint and the re-enabled input.
1620
+ missingOrganization: () => {
1621
+ writer.appendError(copy.missingOrganization);
1622
+ writer.setSessionState("awaiting_input");
1623
+ },
1624
+ recover: (runGone, error) => {
1625
+ if (runGone) {
1626
+ writer.setRunId(null);
1627
+ }
1628
+ writer.appendError(refusedAsSent(chunkUYUBSD2V_cjs.statusOf(error), copy) ?? copy.generic);
1629
+ writer.setSessionState("awaiting_input");
1630
+ onSettled?.();
1631
+ if (runGone && chunkUYUBSD2V_cjs.statusOf(error) === 404) {
1632
+ tellHost(() => invalidateMemberships?.());
1633
+ }
1634
+ tellSignInRefused(chunkUYUBSD2V_cjs.statusOf(error));
1635
+ },
1636
+ resumeFailed: (error) => {
1637
+ writer.setRunId(null);
1638
+ writer.setSessionState("awaiting_input");
1639
+ onSettled?.();
1640
+ tellSignInRefused(chunkUYUBSD2V_cjs.statusOf(error));
1641
+ }
1642
+ };
1643
+ };
1644
+
1645
+ // src/agent/rules/conversationHost.ts
1646
+ var isRunGone = (error) => error instanceof chunkISLB6Y5Q_cjs.MountayaElementsError || chunkUYUBSD2V_cjs.statusOf(error) === 404;
1647
+ var createConversationHost = (config) => {
1648
+ let session = null;
1649
+ let started = false;
1650
+ let latestCall = null;
1651
+ let callMade = Promise.resolve();
1652
+ let parkedAt = null;
1653
+ const ensureSession = () => {
1654
+ if (!session) {
1655
+ session = config.buildSession();
1656
+ }
1657
+ return session;
1658
+ };
1659
+ const dispose = () => {
1660
+ parkedAt = session?.streamPosition?.() ?? parkedAt;
1661
+ session?.dispose();
1662
+ session = null;
1663
+ started = false;
1664
+ latestCall = null;
1665
+ };
1666
+ const beginCall = () => {
1667
+ const call = /* @__PURE__ */ Symbol("run");
1668
+ latestCall = call;
1669
+ return call;
1670
+ };
1671
+ const callSettled = (call) => {
1672
+ if (latestCall !== call) {
1673
+ return false;
1674
+ }
1675
+ latestCall = null;
1676
+ started = false;
1677
+ return true;
1678
+ };
1679
+ const closeRun = () => {
1680
+ void session?.close().catch(() => void 0);
1681
+ };
1682
+ const finish = () => {
1683
+ closeRun();
1684
+ dispose();
1685
+ parkedAt = null;
1686
+ };
1687
+ const reroute = () => {
1688
+ if (!started || !session) {
1689
+ return;
1690
+ }
1691
+ config.routeForState?.();
1692
+ void session.routeTools().catch(() => void 0);
1693
+ };
1694
+ const restart = () => {
1695
+ closeRun();
1696
+ session?.dispose();
1697
+ session = config.buildSession();
1698
+ started = false;
1699
+ latestCall = null;
1700
+ parkedAt = null;
1701
+ };
1702
+ const resume = (runId, onFault) => {
1703
+ const active = ensureSession();
1704
+ if (!runId || started) {
1705
+ return;
1706
+ }
1707
+ started = true;
1708
+ const call = beginCall();
1709
+ callMade = Promise.resolve();
1710
+ const position = parkedAt?.runId === runId ? parkedAt.lastEventId : void 0;
1711
+ parkedAt = null;
1712
+ const reading = position === void 0 ? active.resume(runId) : active.resume(runId, position);
1713
+ reading.then(
1714
+ () => {
1715
+ callSettled(call);
1716
+ },
1717
+ (error) => {
1718
+ if (callSettled(call)) {
1719
+ onFault(error);
1720
+ }
1721
+ }
1722
+ );
1723
+ };
1724
+ const submit = (message) => {
1725
+ const active = ensureSession();
1726
+ config.appendUserMessage(message);
1727
+ config.routeForMessage?.(message);
1728
+ if (started) {
1729
+ const call2 = latestCall;
1730
+ void callMade.then(() => active.routeTools()).catch(() => void 0).then(() => active.send(message)).catch((error) => {
1731
+ if (session !== active || latestCall !== call2) {
1732
+ return;
1733
+ }
1734
+ const runGone = isRunGone(error);
1735
+ if (runGone) {
1736
+ latestCall = null;
1737
+ started = false;
1738
+ }
1739
+ config.onSendFault(error, runGone);
1740
+ });
1741
+ return;
1742
+ }
1743
+ const organizationId = config.resolveOrganizationId();
1744
+ if (!organizationId) {
1745
+ config.onMissingOrganization();
1746
+ return;
1747
+ }
1748
+ started = true;
1749
+ parkedAt = null;
1750
+ const call = beginCall();
1751
+ const context = config.buildContext();
1752
+ const running = context.then((captured) => active.start(message, organizationId, captured));
1753
+ callMade = context.then(
1754
+ () => void 0,
1755
+ () => void 0
1756
+ );
1757
+ running.then(
1758
+ () => {
1759
+ callSettled(call);
1760
+ },
1761
+ (error) => {
1762
+ if (!callSettled(call)) {
1763
+ return;
1764
+ }
1765
+ const openedRun = active.runId?.() ?? null;
1766
+ if (openedRun === null) {
1767
+ config.onStartError(organizationId, error);
1768
+ } else {
1769
+ config.onStartError(organizationId, error, openedRun);
1770
+ }
1771
+ }
1772
+ );
1773
+ };
1774
+ return { dispose, finish, reroute, restart, resume, submit };
1775
+ };
1776
+
1777
+ // src/agent/rules/scriptedTransport.ts
1778
+ var terminalTypes = /* @__PURE__ */ new Set(["done"]);
1779
+ var readRun = (run, handlers, options) => {
1780
+ const signal = options?.signal;
1781
+ if (signal?.aborted) {
1782
+ return () => {
1783
+ };
1784
+ }
1785
+ let active = true;
1786
+ const named = options?.lastEventId;
1787
+ let position = named === void 0 ? 0 : run.history.findIndex((entry) => entry.id === named) + 1;
1788
+ const beginsPastTheEnd = run.history.slice(0, position).some(({ event }) => terminalTypes.has(event.type));
1789
+ let wake = null;
1790
+ const release = () => {
1791
+ signal?.removeEventListener("abort", teardown);
1792
+ };
1793
+ const teardown = () => {
1794
+ active = false;
1795
+ release();
1796
+ const resume = wake;
1797
+ wake = null;
1798
+ if (resume !== null) {
1799
+ run.waiting.delete(resume);
1800
+ resume();
1801
+ }
1802
+ };
1803
+ signal?.addEventListener("abort", teardown, { once: true });
1804
+ void (async () => {
1805
+ if (beginsPastTheEnd) {
1806
+ await Promise.resolve();
1807
+ if (active) {
1808
+ active = false;
1809
+ release();
1810
+ handlers.onClose("ended");
1811
+ }
1812
+ return;
1813
+ }
1814
+ while (active) {
1815
+ const entry = run.history[position];
1816
+ if (entry === void 0) {
1817
+ await new Promise((resolve) => {
1818
+ wake = resolve;
1819
+ run.waiting.add(resolve);
1820
+ });
1821
+ wake = null;
1822
+ continue;
1823
+ }
1824
+ position += 1;
1825
+ try {
1826
+ await handlers.onFrame({ event: run.delivered(entry.event), id: entry.id });
1827
+ } catch (error) {
1828
+ if (active) {
1829
+ active = false;
1830
+ release();
1831
+ handlers.onError(error);
1832
+ }
1833
+ return;
1834
+ }
1835
+ if (active && terminalTypes.has(entry.event.type)) {
1836
+ active = false;
1837
+ release();
1838
+ handlers.onClose("terminal");
1839
+ return;
1840
+ }
1841
+ }
1842
+ })();
1843
+ return teardown;
1844
+ };
1845
+ var createRunStream = () => {
1846
+ const history = [];
1847
+ let recorded = 0;
1848
+ const record = (event) => {
1849
+ recorded += 1;
1850
+ return { event, id: String(recorded) };
1851
+ };
1852
+ const answered = /* @__PURE__ */ new Set();
1853
+ const waiting = /* @__PURE__ */ new Set();
1854
+ const delivered = (event) => (event.type === "tool-call" || event.type === "confirm-required") && answered.has(event.tool_call_id) ? { ...event, settled: true } : event;
1855
+ const stream = {
1856
+ answer: (toolCallId, outcome) => {
1857
+ answered.add(toolCallId);
1858
+ const isSettled = history.some(
1859
+ ({ event }) => (event.type === "tool-result" || event.type === "tool-abandoned") && event.tool_call_id === toolCallId
1860
+ );
1861
+ if (outcome === void 0 || isSettled) {
1862
+ return;
1863
+ }
1864
+ const terminal = history.findIndex(({ event }) => terminalTypes.has(event.type));
1865
+ if (terminal === -1) {
1866
+ stream.push([outcome]);
1867
+ } else {
1868
+ history.splice(terminal, 0, record(outcome));
1869
+ }
1870
+ },
1871
+ push: (events) => {
1872
+ history.push(...events.map(record));
1873
+ const resumes = [...waiting];
1874
+ waiting.clear();
1875
+ for (const resume of resumes) {
1876
+ resume();
1877
+ }
1878
+ },
1879
+ subscribe: (handlers, options) => readRun({ delivered, history, waiting }, handlers, options)
1880
+ };
1881
+ return stream;
1882
+ };
1883
+ var echoOf = (answer) => ({
1884
+ ok: answer.ok,
1885
+ tool_call_id: answer.tool_call_id,
1886
+ type: "tool-result",
1887
+ ...answer.result === void 0 ? {} : { data: answer.result },
1888
+ ...answer.error === void 0 ? {} : { error: answer.error }
1889
+ });
1890
+ var createAgentScriptedTransport = (resolve) => {
1891
+ const streams = /* @__PURE__ */ new Map();
1892
+ const streamFor = (runId) => streams.get(runId);
1893
+ const startRun = async (params) => {
1894
+ const runId = chunk4F6BJMJC_cjs.localId();
1895
+ const stream = createRunStream();
1896
+ streams.set(runId, stream);
1897
+ stream.push(resolve(params.message));
1898
+ return { runId };
1899
+ };
1900
+ const sendInput = async (runId, input) => {
1901
+ const stream = streamFor(runId);
1902
+ if (!stream) {
1903
+ return;
1904
+ }
1905
+ if (input.type === "user-message") {
1906
+ stream.push(resolve(input.content));
1907
+ } else if (input.type === "close") {
1908
+ stream.push([{ reason: "completed", type: "done" }]);
1909
+ } else if (input.type === "tool-result") {
1910
+ stream.answer(input.tool_call_id, echoOf(input));
1911
+ } else if (input.type === "confirm") {
1912
+ stream.answer(input.tool_call_id);
1913
+ }
1914
+ };
1915
+ const subscribe = (runId, handlers, options) => {
1916
+ const stream = streamFor(runId);
1917
+ if (!stream) {
1918
+ queueMicrotask(() => handlers.onClose("ended"));
1919
+ return () => {
1920
+ };
1921
+ }
1922
+ return stream.subscribe(handlers, options);
1923
+ };
1924
+ const pushEvents = (runId, turnEvents) => {
1925
+ streamFor(runId)?.push(turnEvents);
1926
+ };
1927
+ const endRun = (runId) => {
1928
+ streamFor(runId)?.push([{ reason: "completed", type: "done" }]);
1929
+ };
1930
+ return { endRun, pushEvents, sendInput, startRun, subscribe };
1931
+ };
1932
+
1933
+ // src/agent/rules/stickToBottom.ts
1934
+ var STICK_TO_BOTTOM_THRESHOLD_PX = 24;
1935
+ var isPinnedToBottom = (viewport, threshold = STICK_TO_BOTTOM_THRESHOLD_PX) => viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight <= threshold;
1936
+
1937
+ exports.AgentEngine = AgentEngine;
1938
+ exports.MAX_TOOL_INPUT_CHARS = MAX_TOOL_INPUT_CHARS;
1939
+ exports.MAX_TOOL_RESULT_DATA_BYTES = MAX_TOOL_RESULT_DATA_BYTES;
1940
+ exports.STICK_TO_BOTTOM_THRESHOLD_PX = STICK_TO_BOTTOM_THRESHOLD_PX;
1941
+ exports.accumulateAssistant = accumulateAssistant;
1942
+ exports.answerQuestionEntry = answerQuestionEntry;
1943
+ exports.appendActivityEntry = appendActivityEntry;
1944
+ exports.appendErrorEntry = appendErrorEntry;
1945
+ exports.appendQuestionEntry = appendQuestionEntry;
1946
+ exports.appendSuggestionsEntry = appendSuggestionsEntry;
1947
+ exports.appendUserEntry = appendUserEntry;
1948
+ exports.appendWarningEntry = appendWarningEntry;
1949
+ exports.boundedInputJson = boundedInputJson;
1950
+ exports.buildToolResultPayload = buildToolResultPayload;
1951
+ exports.chooseSuggestionEntry = chooseSuggestionEntry;
1952
+ exports.createAgentScriptedTransport = createAgentScriptedTransport;
1953
+ exports.createConversationFaults = createConversationFaults;
1954
+ exports.createConversationHost = createConversationHost;
1955
+ exports.isPinnedToBottom = isPinnedToBottom;
1956
+ exports.mintEntryId = mintEntryId;
1957
+ exports.replaceAssistant = replaceAssistant;
1958
+ exports.resolveAgentError = resolveAgentError;
1959
+ exports.settleActivityEntry = settleActivityEntry;
1960
+ exports.settleOpenQuestionEntries = settleOpenQuestionEntries;
1961
+ exports.settleOpenSuggestionEntries = settleOpenSuggestionEntries;
1962
+ exports.toWireErrorCode = toWireErrorCode;
1963
+ //# sourceMappingURL=index.cjs.map
1964
+ //# sourceMappingURL=index.cjs.map