@mountaya/elements 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (862) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +4 -3
  3. package/THIRD-PARTY-NOTICES.txt +1 -1
  4. package/dist/agent/index.cjs +1152 -1905
  5. package/dist/agent/index.cjs.map +1 -1
  6. package/dist/agent/index.d.cts +1152 -1202
  7. package/dist/agent/index.d.ts +1152 -1202
  8. package/dist/agent/index.js +1147 -1903
  9. package/dist/agent/index.js.map +1 -1
  10. package/dist/camera/index.cjs +2470 -3435
  11. package/dist/camera/index.cjs.map +1 -1
  12. package/dist/camera/index.d.cts +716 -744
  13. package/dist/camera/index.d.ts +716 -744
  14. package/dist/camera/index.js +2438 -3323
  15. package/dist/camera/index.js.map +1 -1
  16. package/dist/{units-D9mBrusY.d.cts → chunk-5pTPpv4v.d.cts} +38 -41
  17. package/dist/{units-D9mBrusY.d.ts → chunk-5pTPpv4v.d.ts} +38 -41
  18. package/dist/{order-BLhsGsH8.d.ts → chunk-6JzFMFHh.d.ts} +15 -28
  19. package/dist/chunk-6qyuJVvt.d.ts +513 -0
  20. package/dist/chunk-9fp0lDic.cjs +583 -0
  21. package/dist/chunk-9fp0lDic.cjs.map +1 -0
  22. package/dist/{zones-B05QA8fy.d.ts → chunk-A48H1rDg.d.cts} +2 -4
  23. package/dist/{zones-B05QA8fy.d.cts → chunk-A48H1rDg.d.ts} +2 -4
  24. package/dist/chunk-B-m1AchR.cjs +57 -0
  25. package/dist/chunk-B-m1AchR.cjs.map +1 -0
  26. package/dist/{bundle-xYrrbJTH.d.ts → chunk-B-qFTf04.d.ts} +51 -57
  27. package/dist/chunk-B0YROiZh.d.cts +1475 -0
  28. package/dist/chunk-B14wgOvH.d.cts +68 -0
  29. package/dist/chunk-B19l3j9r.cjs +150 -0
  30. package/dist/chunk-B19l3j9r.cjs.map +1 -0
  31. package/dist/chunk-B2PtjVKg.cjs +86 -0
  32. package/dist/chunk-B2PtjVKg.cjs.map +1 -0
  33. package/dist/chunk-B56Oyb7W.cjs +70 -0
  34. package/dist/chunk-B56Oyb7W.cjs.map +1 -0
  35. package/dist/chunk-B5WGMQwK.cjs +113 -0
  36. package/dist/chunk-B5WGMQwK.cjs.map +1 -0
  37. package/dist/{types-nO2joeRk.d.ts → chunk-B98mKrdu.d.cts} +103 -122
  38. package/dist/{videoOverlay-Dh_D5_Zs.d.ts → chunk-BB0PmqIM.d.cts} +10 -10
  39. package/dist/chunk-BBikve0Z.cjs +269 -0
  40. package/dist/chunk-BBikve0Z.cjs.map +1 -0
  41. package/dist/chunk-BHeXmM0X.js +37 -0
  42. package/dist/chunk-BHeXmM0X.js.map +1 -0
  43. package/dist/chunk-BI8WZLpU.cjs +281 -0
  44. package/dist/chunk-BI8WZLpU.cjs.map +1 -0
  45. package/dist/chunk-BIEc_SkR.cjs +29 -0
  46. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  47. package/dist/chunk-BJ6L6_W9.cjs +553 -0
  48. package/dist/chunk-BJ6L6_W9.cjs.map +1 -0
  49. package/dist/chunk-BJ91UCbB.js +11 -0
  50. package/dist/chunk-BJ91UCbB.js.map +1 -0
  51. package/dist/chunk-BJEZWTKj.cjs +166 -0
  52. package/dist/chunk-BJEZWTKj.cjs.map +1 -0
  53. package/dist/chunk-BJz54mfg.cjs +10 -0
  54. package/dist/chunk-BJz54mfg.cjs.map +1 -0
  55. package/dist/{sections-CVlc2Inr.d.cts → chunk-BNX5LAfN.d.cts} +289 -330
  56. package/dist/chunk-BP6KgA86.js +35 -0
  57. package/dist/chunk-BP6KgA86.js.map +1 -0
  58. package/dist/{segmentRoute-C5UL_5bp.d.ts → chunk-BRnjQq6K.d.cts} +44 -59
  59. package/dist/chunk-BSiMEwPS.js +46 -0
  60. package/dist/chunk-BSiMEwPS.js.map +1 -0
  61. package/dist/chunk-BTPjDw_y.cjs +16 -0
  62. package/dist/chunk-BTPjDw_y.cjs.map +1 -0
  63. package/dist/chunk-BTUUABGI.js +17 -0
  64. package/dist/chunk-BTUUABGI.js.map +1 -0
  65. package/dist/chunk-BUeL9y7s.cjs +45 -0
  66. package/dist/chunk-BUeL9y7s.cjs.map +1 -0
  67. package/dist/chunk-BWMuCNc9.cjs +172 -0
  68. package/dist/chunk-BWMuCNc9.cjs.map +1 -0
  69. package/dist/chunk-BWjRfhpF.js +126 -0
  70. package/dist/chunk-BWjRfhpF.js.map +1 -0
  71. package/dist/{types-CTQwbSdA.d.cts → chunk-BZ5KyZXI.d.ts} +103 -122
  72. package/dist/chunk-B_4SVmvh.js +94 -0
  73. package/dist/chunk-B_4SVmvh.js.map +1 -0
  74. package/dist/chunk-BcTUuZQ3.js +95 -0
  75. package/dist/chunk-BcTUuZQ3.js.map +1 -0
  76. package/dist/chunk-BdkqSsJe.cjs +140 -0
  77. package/dist/chunk-BdkqSsJe.cjs.map +1 -0
  78. package/dist/chunk-BfktMVmI.js +70 -0
  79. package/dist/chunk-BfktMVmI.js.map +1 -0
  80. package/dist/chunk-BfzQb0EK.cjs +6 -0
  81. package/dist/chunk-BhWfT-22.d.cts +808 -0
  82. package/dist/chunk-BjJcqX5J.cjs +60 -0
  83. package/dist/chunk-BjJcqX5J.cjs.map +1 -0
  84. package/dist/{geodesy-543qXKtI.d.ts → chunk-Bk0L8g5J.d.cts} +3 -4
  85. package/dist/{geodesy-543qXKtI.d.cts → chunk-Bk0L8g5J.d.ts} +3 -4
  86. package/dist/chunk-Bl4_uVa6.cjs +11 -0
  87. package/dist/chunk-Bl4_uVa6.cjs.map +1 -0
  88. package/dist/chunk-BlKF4lrp.js +43 -0
  89. package/dist/chunk-BlKF4lrp.js.map +1 -0
  90. package/dist/chunk-Bm1FieGR.js +4 -0
  91. package/dist/chunk-Bm1FieGR.js.map +1 -0
  92. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  93. package/dist/chunk-BpN3hr6a.cjs +541 -0
  94. package/dist/chunk-BpN3hr6a.cjs.map +1 -0
  95. package/dist/{order-BZkUwMou.d.cts → chunk-Bq_WHTfd.d.cts} +15 -28
  96. package/dist/chunk-Bqt4LBBz.cjs +648 -0
  97. package/dist/chunk-Bqt4LBBz.cjs.map +1 -0
  98. package/dist/{language-CEWQ5uYw.d.cts → chunk-Bqt97zwf.d.cts} +3 -18
  99. package/dist/{language-CEWQ5uYw.d.ts → chunk-Bqt97zwf.d.ts} +3 -18
  100. package/dist/chunk-BsBiN4w6.d.cts +245 -0
  101. package/dist/chunk-BvTpOUoC.cjs +207 -0
  102. package/dist/chunk-BvTpOUoC.cjs.map +1 -0
  103. package/dist/chunk-BwK6Hl3q.cjs +446 -0
  104. package/dist/chunk-BwK6Hl3q.cjs.map +1 -0
  105. package/dist/{elevationTiles-pmsb9wnU.d.cts → chunk-BxDQZDXR.d.cts} +26 -27
  106. package/dist/{elevationTiles-pmsb9wnU.d.ts → chunk-BxDQZDXR.d.ts} +26 -27
  107. package/dist/chunk-BxUio8kX.js +20 -0
  108. package/dist/chunk-BxUio8kX.js.map +1 -0
  109. package/dist/chunk-BxaocpFi.d.cts +1 -0
  110. package/dist/chunk-Bywi0K1N.js +36 -0
  111. package/dist/chunk-Bywi0K1N.js.map +1 -0
  112. package/dist/chunk-C-IlmkDl.js +59 -0
  113. package/dist/chunk-C-IlmkDl.js.map +1 -0
  114. package/dist/chunk-C5PtVewq.d.ts +389 -0
  115. package/dist/chunk-C5dpC7mQ.js +19 -0
  116. package/dist/chunk-C5dpC7mQ.js.map +1 -0
  117. package/dist/chunk-C5q1sgSa.js +46 -0
  118. package/dist/chunk-C5q1sgSa.js.map +1 -0
  119. package/dist/chunk-C6fU9G5I.cjs +221 -0
  120. package/dist/chunk-C6fU9G5I.cjs.map +1 -0
  121. package/dist/chunk-C71dpWUK.js +5 -0
  122. package/dist/chunk-C71dpWUK.js.map +1 -0
  123. package/dist/chunk-C82N1gQX.d.ts +1831 -0
  124. package/dist/chunk-C8HdaHpu.js +118 -0
  125. package/dist/chunk-C8HdaHpu.js.map +1 -0
  126. package/dist/chunk-C8ZGryck.js +236 -0
  127. package/dist/chunk-C8ZGryck.js.map +1 -0
  128. package/dist/chunk-C95NG0oD.cjs +43 -0
  129. package/dist/chunk-C95NG0oD.cjs.map +1 -0
  130. package/dist/chunk-C9aR8DXb.js +9 -0
  131. package/dist/chunk-C9aR8DXb.js.map +1 -0
  132. package/dist/{camera-C48Ykaxv.d.ts → chunk-CAUZnoCs.d.ts} +135 -159
  133. package/dist/chunk-CBXWWuM9.cjs +82 -0
  134. package/dist/chunk-CBXWWuM9.cjs.map +1 -0
  135. package/dist/chunk-CC_Kquu7.d.cts +125 -0
  136. package/dist/chunk-CC_Kquu7.d.ts +125 -0
  137. package/dist/chunk-CCp85vXg.cjs +60 -0
  138. package/dist/chunk-CCp85vXg.cjs.map +1 -0
  139. package/dist/chunk-CEcB1_uK.js +39 -0
  140. package/dist/chunk-CEcB1_uK.js.map +1 -0
  141. package/dist/{bundle-Je5zsRFg.d.cts → chunk-CFIo021l.d.cts} +51 -57
  142. package/dist/chunk-CH_IZoJE.js +33 -0
  143. package/dist/chunk-CH_IZoJE.js.map +1 -0
  144. package/dist/chunk-CHrasH_g.cjs +25 -0
  145. package/dist/chunk-CHrasH_g.cjs.map +1 -0
  146. package/dist/chunk-CJVoSaAE.cjs +3 -0
  147. package/dist/chunk-CJp8nGcb.js +96 -0
  148. package/dist/chunk-CJp8nGcb.js.map +1 -0
  149. package/dist/chunk-CJwUtkOt.js +112 -0
  150. package/dist/chunk-CJwUtkOt.js.map +1 -0
  151. package/dist/chunk-CKhCOVIf.d.cts +751 -0
  152. package/dist/chunk-CKiVSRYg.js +50 -0
  153. package/dist/chunk-CKiVSRYg.js.map +1 -0
  154. package/dist/chunk-CKtd19eD.cjs +59 -0
  155. package/dist/chunk-CKtd19eD.cjs.map +1 -0
  156. package/dist/chunk-CL92KE3j.d.ts +3188 -0
  157. package/dist/chunk-CLqUlkAe.js +54 -0
  158. package/dist/chunk-CLqUlkAe.js.map +1 -0
  159. package/dist/chunk-CMG5OV0q.cjs +4741 -0
  160. package/dist/chunk-CMG5OV0q.cjs.map +1 -0
  161. package/dist/chunk-CN_TKSgm.js +10 -0
  162. package/dist/chunk-CN_TKSgm.js.map +1 -0
  163. package/dist/chunk-CNe6MtqV.cjs +29 -0
  164. package/dist/chunk-CNe6MtqV.cjs.map +1 -0
  165. package/dist/chunk-COQkDTC5.js +83 -0
  166. package/dist/chunk-COQkDTC5.js.map +1 -0
  167. package/dist/chunk-CPBl6K4M.cjs +168 -0
  168. package/dist/chunk-CPBl6K4M.cjs.map +1 -0
  169. package/dist/chunk-CPx0ZYFB.d.ts +3 -0
  170. package/dist/chunk-CQQhcP_C.d.ts +197 -0
  171. package/dist/chunk-CTNoajFh.d.cts +389 -0
  172. package/dist/chunk-CTd-qgJc.cjs +384 -0
  173. package/dist/chunk-CTd-qgJc.cjs.map +1 -0
  174. package/dist/chunk-CW80YYtU.cjs +1056 -0
  175. package/dist/chunk-CW80YYtU.cjs.map +1 -0
  176. package/dist/{searchLimits-j99-NTXR.d.ts → chunk-CWpqBgkF.d.cts} +2 -2
  177. package/dist/{searchLimits-j99-NTXR.d.cts → chunk-CWpqBgkF.d.ts} +2 -2
  178. package/dist/chunk-CXjRArgy.d.ts +3 -0
  179. package/dist/chunk-CXonfH3-.cjs +14 -0
  180. package/dist/chunk-CXonfH3-.cjs.map +1 -0
  181. package/dist/chunk-CYcouGXN.d.ts +825 -0
  182. package/dist/chunk-CZDAzEBw.cjs +1621 -0
  183. package/dist/chunk-CZDAzEBw.cjs.map +1 -0
  184. package/dist/{amenities-B3-qAjxu.d.cts → chunk-C_fQFr70.d.cts} +40 -41
  185. package/dist/{amenities-B3-qAjxu.d.ts → chunk-C_fQFr70.d.ts} +40 -41
  186. package/dist/chunk-CbOtHnnB.cjs +359 -0
  187. package/dist/chunk-CbOtHnnB.cjs.map +1 -0
  188. package/dist/chunk-CdA6ZMGk.d.cts +825 -0
  189. package/dist/chunk-Ce1_thm7.js +146 -0
  190. package/dist/chunk-Ce1_thm7.js.map +1 -0
  191. package/dist/chunk-CeD8Hw0j.d.cts +3188 -0
  192. package/dist/{camera-BrFLU1DH.d.cts → chunk-CeiTuMyt.d.cts} +135 -159
  193. package/dist/chunk-Ch1OLzLi.js +1 -0
  194. package/dist/chunk-Cizu_j1N.cjs +87 -0
  195. package/dist/chunk-Cizu_j1N.cjs.map +1 -0
  196. package/dist/chunk-CjDe9z6A.d.cts +427 -0
  197. package/dist/chunk-Cl1etdlu.js +63 -0
  198. package/dist/chunk-Cl1etdlu.js.map +1 -0
  199. package/dist/chunk-CmoVJDoz.js +4 -0
  200. package/dist/chunk-CmoVJDoz.js.map +1 -0
  201. package/dist/chunk-CnLucxjG.cjs +197 -0
  202. package/dist/chunk-CnLucxjG.cjs.map +1 -0
  203. package/dist/chunk-CsWjBmdi.cjs +56 -0
  204. package/dist/chunk-CsWjBmdi.cjs.map +1 -0
  205. package/dist/chunk-CuseO5MZ.d.cts +3 -0
  206. package/dist/chunk-CvMHibbA.d.ts +427 -0
  207. package/dist/chunk-CwDeiN5U.js +870 -0
  208. package/dist/chunk-CwDeiN5U.js.map +1 -0
  209. package/dist/chunk-Cwdmx4tG.js +1 -0
  210. package/dist/{geolocation-DDkQdWMN.d.cts → chunk-D-4MxHTt.d.cts} +33 -34
  211. package/dist/{geolocation-DDkQdWMN.d.ts → chunk-D-4MxHTt.d.ts} +33 -34
  212. package/dist/chunk-D0LF-99V.js +1093 -0
  213. package/dist/chunk-D0LF-99V.js.map +1 -0
  214. package/dist/chunk-D1fe-0c_.js +367 -0
  215. package/dist/chunk-D1fe-0c_.js.map +1 -0
  216. package/dist/chunk-D21fEI6A.d.ts +1926 -0
  217. package/dist/chunk-D39gAxya.cjs +89 -0
  218. package/dist/chunk-D39gAxya.cjs.map +1 -0
  219. package/dist/chunk-D6KdIW5e.cjs +228 -0
  220. package/dist/chunk-D6KdIW5e.cjs.map +1 -0
  221. package/dist/chunk-D6qHYbgW.d.cts +36 -0
  222. package/dist/{videoOverlay-Dh_D5_Zs.d.cts → chunk-D89E-w70.d.ts} +10 -10
  223. package/dist/chunk-D8bdTysL.js +552 -0
  224. package/dist/chunk-D8bdTysL.js.map +1 -0
  225. package/dist/chunk-D96QJT24.cjs +109 -0
  226. package/dist/chunk-D96QJT24.cjs.map +1 -0
  227. package/dist/chunk-DAmkQl-i.js +119 -0
  228. package/dist/chunk-DAmkQl-i.js.map +1 -0
  229. package/dist/chunk-DEfsb2lc.cjs +10 -0
  230. package/dist/chunk-DEfsb2lc.cjs.map +1 -0
  231. package/dist/chunk-DIFjT5-V.d.cts +66 -0
  232. package/dist/{sections-CmtaduLc.d.ts → chunk-DJpUw8TN.d.ts} +289 -330
  233. package/dist/chunk-DK6lm2IZ.cjs +11 -0
  234. package/dist/chunk-DK6lm2IZ.cjs.map +1 -0
  235. package/dist/chunk-DKqgr31j.cjs +61 -0
  236. package/dist/chunk-DKqgr31j.cjs.map +1 -0
  237. package/dist/chunk-DLZ0QYm9.js +37 -0
  238. package/dist/chunk-DLZ0QYm9.js.map +1 -0
  239. package/dist/chunk-DLjS0uaC.js +4 -0
  240. package/dist/chunk-DLjS0uaC.js.map +1 -0
  241. package/dist/chunk-DMokwmOV.cjs +49 -0
  242. package/dist/chunk-DMokwmOV.cjs.map +1 -0
  243. package/dist/chunk-DMvWgBZL.d.cts +1831 -0
  244. package/dist/chunk-DNfGfIF3.js +31 -0
  245. package/dist/chunk-DNfGfIF3.js.map +1 -0
  246. package/dist/chunk-DQbSRe8D.d.ts +245 -0
  247. package/dist/chunk-DSGkP8_y.js +45 -0
  248. package/dist/chunk-DSGkP8_y.js.map +1 -0
  249. package/dist/chunk-DTctvfSd.d.cts +197 -0
  250. package/dist/chunk-DWe7igyw.cjs +206 -0
  251. package/dist/chunk-DWe7igyw.cjs.map +1 -0
  252. package/dist/chunk-DWsMP5JR.d.ts +68 -0
  253. package/dist/{provider-DM71XnLX.d.cts → chunk-DWsm3HIW.d.cts} +37 -38
  254. package/dist/{provider-DM71XnLX.d.ts → chunk-DWsm3HIW.d.ts} +37 -38
  255. package/dist/chunk-DXABHjLa.cjs +3 -0
  256. package/dist/chunk-D_BeqSbc.cjs +42 -0
  257. package/dist/chunk-D_BeqSbc.cjs.map +1 -0
  258. package/dist/chunk-D_svQNdW.d.ts +66 -0
  259. package/dist/chunk-Dav4xWrp.js +330 -0
  260. package/dist/chunk-Dav4xWrp.js.map +1 -0
  261. package/dist/chunk-DbCPhepL.js +293 -0
  262. package/dist/chunk-DbCPhepL.js.map +1 -0
  263. package/dist/chunk-DcrTy-y2.cjs +43 -0
  264. package/dist/chunk-DcrTy-y2.cjs.map +1 -0
  265. package/dist/chunk-Ddv484ld.js +487 -0
  266. package/dist/chunk-Ddv484ld.js.map +1 -0
  267. package/dist/chunk-De0bjnhY.cjs +88 -0
  268. package/dist/chunk-De0bjnhY.cjs.map +1 -0
  269. package/dist/chunk-De2FmNPu.cjs +32 -0
  270. package/dist/chunk-De2FmNPu.cjs.map +1 -0
  271. package/dist/{segmentRoute-CIo6dR8Y.d.cts → chunk-DeSjQXiI.d.ts} +44 -59
  272. package/dist/chunk-Den0Ta6C.js +132 -0
  273. package/dist/chunk-Den0Ta6C.js.map +1 -0
  274. package/dist/chunk-DiDKEeEa.js +8 -0
  275. package/dist/chunk-DiDKEeEa.js.map +1 -0
  276. package/dist/chunk-Dj60k5PU.js +197 -0
  277. package/dist/chunk-Dj60k5PU.js.map +1 -0
  278. package/dist/chunk-DjnYQBCN.js +4705 -0
  279. package/dist/chunk-DjnYQBCN.js.map +1 -0
  280. package/dist/chunk-Dk9VKvyq.d.ts +1 -0
  281. package/dist/chunk-Dor1ERI9.cjs +85 -0
  282. package/dist/chunk-Dor1ERI9.cjs.map +1 -0
  283. package/dist/chunk-DpMouOoH.js +451 -0
  284. package/dist/chunk-DpMouOoH.js.map +1 -0
  285. package/dist/chunk-DposgdNL.cjs +52 -0
  286. package/dist/chunk-DposgdNL.cjs.map +1 -0
  287. package/dist/chunk-DqLTG_5Q.d.cts +3 -0
  288. package/dist/{roadAccess-D_rOE4xW.d.cts → chunk-Dr5MCIpS.d.cts} +5 -28
  289. package/dist/{roadAccess-D_rOE4xW.d.ts → chunk-Dr5MCIpS.d.ts} +5 -28
  290. package/dist/chunk-DrudttCC.cjs +4 -0
  291. package/dist/chunk-DsDYVJQC.js +173 -0
  292. package/dist/chunk-DsDYVJQC.js.map +1 -0
  293. package/dist/chunk-Dw8ur6FJ.js +27 -0
  294. package/dist/chunk-Dw8ur6FJ.js.map +1 -0
  295. package/dist/chunk-DwG6M_0v.js +64 -0
  296. package/dist/chunk-DwG6M_0v.js.map +1 -0
  297. package/dist/chunk-Dy9a5ibO.js +284 -0
  298. package/dist/chunk-Dy9a5ibO.js.map +1 -0
  299. package/dist/chunk-DyayZlQJ.js +157 -0
  300. package/dist/chunk-DyayZlQJ.js.map +1 -0
  301. package/dist/chunk-DyhJZC2i.js +126 -0
  302. package/dist/chunk-DyhJZC2i.js.map +1 -0
  303. package/dist/chunk-F9zBzmmG.cjs +45 -0
  304. package/dist/chunk-F9zBzmmG.cjs.map +1 -0
  305. package/dist/chunk-FyCYofv2.js +116 -0
  306. package/dist/chunk-FyCYofv2.js.map +1 -0
  307. package/dist/chunk-GHJRjAk2.js +1 -0
  308. package/dist/chunk-H14isiSf.d.ts +751 -0
  309. package/dist/chunk-HIJzXoN4.js +7 -0
  310. package/dist/chunk-HIJzXoN4.js.map +1 -0
  311. package/dist/chunk-Id_8kRtu.d.ts +36 -0
  312. package/dist/chunk-KN60yxBQ.js +5 -0
  313. package/dist/chunk-KN60yxBQ.js.map +1 -0
  314. package/dist/chunk-NM5yg6bh.cjs +82 -0
  315. package/dist/chunk-NM5yg6bh.cjs.map +1 -0
  316. package/dist/chunk-OXr3zJfM.cjs +119 -0
  317. package/dist/chunk-OXr3zJfM.cjs.map +1 -0
  318. package/dist/chunk-QGqgNC4z.d.ts +928 -0
  319. package/dist/chunk-QJBtJrZ0.js +36 -0
  320. package/dist/chunk-QJBtJrZ0.js.map +1 -0
  321. package/dist/{routeProfile-BsSUABXv.d.cts → chunk-QKWhxfPv.d.cts} +196 -45
  322. package/dist/{routeProfile-BKfSfxx6.d.ts → chunk-QKWhxfPv.d.ts} +196 -45
  323. package/dist/chunk-QXW7b4Ev.d.cts +410 -0
  324. package/dist/chunk-RHZrxUrM.cjs +39 -0
  325. package/dist/chunk-RHZrxUrM.cjs.map +1 -0
  326. package/dist/chunk-RTxe2i66.js +91 -0
  327. package/dist/chunk-RTxe2i66.js.map +1 -0
  328. package/dist/chunk-RrKkJb6P.js +16 -0
  329. package/dist/chunk-RrKkJb6P.js.map +1 -0
  330. package/dist/chunk-VOJqpcnM.cjs +181 -0
  331. package/dist/chunk-VOJqpcnM.cjs.map +1 -0
  332. package/dist/chunk-VljGTrid.js +1 -0
  333. package/dist/chunk-X3UVwUEK.d.cts +513 -0
  334. package/dist/chunk-X9K2WChn.cjs +28 -0
  335. package/dist/chunk-X9K2WChn.cjs.map +1 -0
  336. package/dist/chunk-YrtOx6oy.js +251 -0
  337. package/dist/chunk-YrtOx6oy.js.map +1 -0
  338. package/dist/chunk-bY7ySujI.d.cts +928 -0
  339. package/dist/chunk-bYf1sBz5.d.cts +11 -0
  340. package/dist/chunk-bYf1sBz5.d.ts +11 -0
  341. package/dist/chunk-blfknWoM.d.cts +1926 -0
  342. package/dist/chunk-blqsohAb.js +113 -0
  343. package/dist/chunk-blqsohAb.js.map +1 -0
  344. package/dist/chunk-cDMCjodI.cjs +58 -0
  345. package/dist/chunk-cDMCjodI.cjs.map +1 -0
  346. package/dist/chunk-cWjE3qd6.cjs +10 -0
  347. package/dist/chunk-cWjE3qd6.cjs.map +1 -0
  348. package/dist/chunk-dfOgV3fu.js +26 -0
  349. package/dist/chunk-dfOgV3fu.js.map +1 -0
  350. package/dist/chunk-f9cTwUX1.cjs +125 -0
  351. package/dist/chunk-f9cTwUX1.cjs.map +1 -0
  352. package/dist/chunk-fHVYEZs4.cjs +28 -0
  353. package/dist/chunk-fHVYEZs4.cjs.map +1 -0
  354. package/dist/chunk-fWRUMgRI.js +22 -0
  355. package/dist/chunk-fWRUMgRI.js.map +1 -0
  356. package/dist/{types-BEv8V_8V.d.cts → chunk-fozLXfHY.d.cts} +8 -8
  357. package/dist/{types-BEv8V_8V.d.ts → chunk-fozLXfHY.d.ts} +8 -8
  358. package/dist/chunk-gWmB1l3A.cjs +3122 -0
  359. package/dist/chunk-gWmB1l3A.cjs.map +1 -0
  360. package/dist/chunk-gbj2R-_w.js +58 -0
  361. package/dist/chunk-gbj2R-_w.js.map +1 -0
  362. package/dist/chunk-iIWxsAXd.js +59 -0
  363. package/dist/chunk-iIWxsAXd.js.map +1 -0
  364. package/dist/chunk-lItIuOIS.cjs +137 -0
  365. package/dist/chunk-lItIuOIS.cjs.map +1 -0
  366. package/dist/chunk-m6Rh4PCe.cjs +798 -0
  367. package/dist/chunk-m6Rh4PCe.cjs.map +1 -0
  368. package/dist/chunk-o3IRANDf.cjs +99 -0
  369. package/dist/chunk-o3IRANDf.cjs.map +1 -0
  370. package/dist/chunk-obUcg3Sk.d.ts +808 -0
  371. package/dist/chunk-ohsf-6Rn.js +600 -0
  372. package/dist/chunk-ohsf-6Rn.js.map +1 -0
  373. package/dist/chunk-pBleU6Nv.js +3061 -0
  374. package/dist/chunk-pBleU6Nv.js.map +1 -0
  375. package/dist/chunk-px4e99cy.js +71 -0
  376. package/dist/chunk-px4e99cy.js.map +1 -0
  377. package/dist/chunk-qwYDLeXc.cjs +99 -0
  378. package/dist/chunk-qwYDLeXc.cjs.map +1 -0
  379. package/dist/chunk-rF_859Qk.cjs +101 -0
  380. package/dist/chunk-rF_859Qk.cjs.map +1 -0
  381. package/dist/chunk-rLJkqJ5j.d.ts +1475 -0
  382. package/dist/chunk-twQItIRg.cjs +338 -0
  383. package/dist/chunk-twQItIRg.cjs.map +1 -0
  384. package/dist/chunk-vnPrMVjY.js +10 -0
  385. package/dist/chunk-vnPrMVjY.js.map +1 -0
  386. package/dist/chunk-ws3bVwaS.d.ts +410 -0
  387. package/dist/chunk-xh3UkuVs.cjs +246 -0
  388. package/dist/chunk-xh3UkuVs.cjs.map +1 -0
  389. package/dist/chunk-yMzRr26E.js +153 -0
  390. package/dist/chunk-yMzRr26E.js.map +1 -0
  391. package/dist/collab/index.cjs +802 -1254
  392. package/dist/collab/index.cjs.map +1 -1
  393. package/dist/collab/index.d.cts +518 -544
  394. package/dist/collab/index.d.ts +518 -544
  395. package/dist/collab/index.js +797 -1252
  396. package/dist/collab/index.js.map +1 -1
  397. package/dist/data/index.cjs +39 -132
  398. package/dist/data/index.d.cts +6 -468
  399. package/dist/data/index.d.ts +6 -468
  400. package/dist/data/index.js +7 -15
  401. package/dist/editor/index.cjs +2631 -4424
  402. package/dist/editor/index.cjs.map +1 -1
  403. package/dist/editor/index.d.cts +10 -59
  404. package/dist/editor/index.d.ts +10 -59
  405. package/dist/editor/index.js +2619 -4403
  406. package/dist/editor/index.js.map +1 -1
  407. package/dist/errors/index.cjs +11 -28
  408. package/dist/errors/index.d.cts +2 -125
  409. package/dist/errors/index.d.ts +2 -125
  410. package/dist/errors/index.js +1 -3
  411. package/dist/geo/index.cjs +68 -232
  412. package/dist/geo/index.d.cts +6 -821
  413. package/dist/geo/index.d.ts +6 -821
  414. package/dist/geo/index.js +11 -15
  415. package/dist/i18n/fr/index.cjs +329 -334
  416. package/dist/i18n/fr/index.cjs.map +1 -1
  417. package/dist/i18n/fr/index.d.cts +3 -10
  418. package/dist/i18n/fr/index.d.ts +3 -10
  419. package/dist/i18n/fr/index.js +324 -332
  420. package/dist/i18n/fr/index.js.map +1 -1
  421. package/dist/i18n/index.cjs +434 -447
  422. package/dist/i18n/index.cjs.map +1 -1
  423. package/dist/i18n/index.d.cts +152 -111
  424. package/dist/i18n/index.d.ts +152 -111
  425. package/dist/i18n/index.js +420 -420
  426. package/dist/i18n/index.js.map +1 -1
  427. package/dist/icons/index.cjs +37 -116
  428. package/dist/icons/index.d.cts +4 -457
  429. package/dist/icons/index.d.ts +4 -457
  430. package/dist/icons/index.js +8 -11
  431. package/dist/index.cjs +515 -1867
  432. package/dist/index.cjs.map +1 -1
  433. package/dist/index.d.cts +44 -121
  434. package/dist/index.d.ts +44 -121
  435. package/dist/index.js +52 -65
  436. package/dist/index.js.map +1 -1
  437. package/dist/layers/index.cjs +83 -318
  438. package/dist/layers/index.d.cts +3 -1555
  439. package/dist/layers/index.d.ts +3 -1555
  440. package/dist/layers/index.js +5 -17
  441. package/dist/map-client/index.cjs +5 -4
  442. package/dist/map-client/index.d.cts +6 -1856
  443. package/dist/map-client/index.d.ts +6 -1856
  444. package/dist/map-client/index.js +0 -3
  445. package/dist/maplibre-worker.mjs +4 -4
  446. package/dist/navigation/index.cjs +584 -671
  447. package/dist/navigation/index.cjs.map +1 -1
  448. package/dist/navigation/index.d.cts +191 -272
  449. package/dist/navigation/index.d.ts +191 -272
  450. package/dist/navigation/index.js +579 -669
  451. package/dist/navigation/index.js.map +1 -1
  452. package/dist/profile/index.cjs +177 -675
  453. package/dist/profile/index.d.cts +8 -2086
  454. package/dist/profile/index.d.ts +8 -2086
  455. package/dist/profile/index.js +10 -18
  456. package/dist/seams/index.cjs +15 -39
  457. package/dist/seams/index.d.cts +4 -254
  458. package/dist/seams/index.d.ts +4 -254
  459. package/dist/seams/index.js +4 -6
  460. package/dist/search/index.cjs +39 -147
  461. package/dist/search/index.d.cts +6 -888
  462. package/dist/search/index.d.ts +6 -888
  463. package/dist/search/index.js +3 -14
  464. package/dist/style/index.cjs +34 -116
  465. package/dist/style/index.d.cts +5 -538
  466. package/dist/style/index.d.ts +5 -538
  467. package/dist/style/index.js +5 -11
  468. package/dist/testing/index.cjs +432 -617
  469. package/dist/testing/index.cjs.map +1 -1
  470. package/dist/testing/index.d.cts +61 -109
  471. package/dist/testing/index.d.ts +61 -109
  472. package/dist/testing/index.js +427 -615
  473. package/dist/testing/index.js.map +1 -1
  474. package/dist/timezone/index.cjs +1946 -752
  475. package/dist/timezone/index.cjs.map +1 -1
  476. package/dist/timezone/index.d.cts +4 -29
  477. package/dist/timezone/index.d.ts +4 -29
  478. package/dist/timezone/index.js +1941 -750
  479. package/dist/timezone/index.js.map +1 -1
  480. package/dist/units/index.cjs +29 -99
  481. package/dist/units/index.d.cts +3 -75
  482. package/dist/units/index.d.ts +3 -75
  483. package/dist/units/index.js +3 -6
  484. package/dist/video/index.cjs +1684 -2169
  485. package/dist/video/index.cjs.map +1 -1
  486. package/dist/video/index.d.cts +386 -413
  487. package/dist/video/index.d.ts +386 -413
  488. package/dist/video/index.js +1678 -2162
  489. package/dist/video/index.js.map +1 -1
  490. package/dist/view/index.cjs +6 -42
  491. package/dist/view/index.d.cts +3 -836
  492. package/dist/view/index.d.ts +3 -836
  493. package/dist/view/index.js +1 -34
  494. package/package.json +12 -12
  495. package/src/auth/rules/clientHeader.ts +1 -1
  496. package/src/camera/rules/modes.ts +38 -42
  497. package/src/camera/rules/routeContent.ts +1 -0
  498. package/src/collab/index.ts +1 -5
  499. package/src/compose/engines/mountayaMap.ts +16 -42
  500. package/src/compose/rules/developmentWarnings.ts +4 -3
  501. package/src/compose/rules/fitBox.ts +67 -0
  502. package/src/compose/rules/maplibreWorkerVersion.gen.ts +1 -1
  503. package/src/compose/rules/maxBounds.ts +5 -5
  504. package/src/compose/rules/types.ts +4 -11
  505. package/src/compose/rules/workerUrl.ts +41 -6
  506. package/src/editing/rules/engine.ts +4 -2
  507. package/src/editor/engines/viewClient.ts +8 -0
  508. package/src/editor/rules/contract.ts +1 -6
  509. package/src/errors/rules/errors.ts +1 -0
  510. package/src/geo/index.ts +1 -6
  511. package/src/i18n/index.ts +1 -0
  512. package/src/i18n/rules/dates.ts +165 -0
  513. package/src/index.ts +5 -24
  514. package/src/map-client/rules/mapClient.ts +4 -2
  515. package/src/profile/rules/scale.ts +1 -5
  516. package/src/profile/rules/waypointCard.ts +8 -11
  517. package/src/search/index.ts +3 -18
  518. package/src/video/index.ts +1 -1
  519. package/src/video/profileOverlay/rules/contract.ts +1 -3
  520. package/src/video/rules/videoEncoder.ts +1 -1
  521. package/dist/accentColor-GNKBD2CW.js +0 -4
  522. package/dist/accentColor-GNKBD2CW.js.map +0 -1
  523. package/dist/accentColor-VX2JSMGE.cjs +0 -17
  524. package/dist/accentColor-VX2JSMGE.cjs.map +0 -1
  525. package/dist/chunk-23PFRRB6.js +0 -3
  526. package/dist/chunk-23PFRRB6.js.map +0 -1
  527. package/dist/chunk-2GI5SAH2.js +0 -71
  528. package/dist/chunk-2GI5SAH2.js.map +0 -1
  529. package/dist/chunk-2MQK6A74.js +0 -39
  530. package/dist/chunk-2MQK6A74.js.map +0 -1
  531. package/dist/chunk-2RE7R4LD.js +0 -73
  532. package/dist/chunk-2RE7R4LD.js.map +0 -1
  533. package/dist/chunk-3JZQKN4O.js +0 -6
  534. package/dist/chunk-3JZQKN4O.js.map +0 -1
  535. package/dist/chunk-3NDXVUUI.js +0 -50
  536. package/dist/chunk-3NDXVUUI.js.map +0 -1
  537. package/dist/chunk-3R4GFTUM.cjs +0 -59
  538. package/dist/chunk-3R4GFTUM.cjs.map +0 -1
  539. package/dist/chunk-3RVUQ6JN.cjs +0 -22
  540. package/dist/chunk-3RVUQ6JN.cjs.map +0 -1
  541. package/dist/chunk-4F6BJMJC.cjs +0 -49
  542. package/dist/chunk-4F6BJMJC.cjs.map +0 -1
  543. package/dist/chunk-4NWQD4BX.js +0 -132
  544. package/dist/chunk-4NWQD4BX.js.map +0 -1
  545. package/dist/chunk-5K2MH3R6.js +0 -10
  546. package/dist/chunk-5K2MH3R6.js.map +0 -1
  547. package/dist/chunk-6ACRNQQQ.cjs +0 -8
  548. package/dist/chunk-6ACRNQQQ.cjs.map +0 -1
  549. package/dist/chunk-6D26E3IA.js +0 -66
  550. package/dist/chunk-6D26E3IA.js.map +0 -1
  551. package/dist/chunk-6ESAW35P.cjs +0 -80
  552. package/dist/chunk-6ESAW35P.cjs.map +0 -1
  553. package/dist/chunk-6LIW2A5M.cjs +0 -1176
  554. package/dist/chunk-6LIW2A5M.cjs.map +0 -1
  555. package/dist/chunk-6OTTWVCA.js +0 -57
  556. package/dist/chunk-6OTTWVCA.js.map +0 -1
  557. package/dist/chunk-6VROJ4UG.js +0 -862
  558. package/dist/chunk-6VROJ4UG.js.map +0 -1
  559. package/dist/chunk-6Y7FTGO4.js +0 -23
  560. package/dist/chunk-6Y7FTGO4.js.map +0 -1
  561. package/dist/chunk-75I4CG64.js +0 -104
  562. package/dist/chunk-75I4CG64.js.map +0 -1
  563. package/dist/chunk-7CUBXHAH.cjs +0 -14
  564. package/dist/chunk-7CUBXHAH.cjs.map +0 -1
  565. package/dist/chunk-7GTCURVY.js +0 -52
  566. package/dist/chunk-7GTCURVY.js.map +0 -1
  567. package/dist/chunk-7IWOL6AM.cjs +0 -100
  568. package/dist/chunk-7IWOL6AM.cjs.map +0 -1
  569. package/dist/chunk-7QN7M667.cjs +0 -151
  570. package/dist/chunk-7QN7M667.cjs.map +0 -1
  571. package/dist/chunk-A6KQDKLM.cjs +0 -1197
  572. package/dist/chunk-A6KQDKLM.cjs.map +0 -1
  573. package/dist/chunk-A77EA67G.js +0 -354
  574. package/dist/chunk-A77EA67G.js.map +0 -1
  575. package/dist/chunk-AFKOABJ4.cjs +0 -7194
  576. package/dist/chunk-AFKOABJ4.cjs.map +0 -1
  577. package/dist/chunk-AG6JV5Z2.cjs +0 -183
  578. package/dist/chunk-AG6JV5Z2.cjs.map +0 -1
  579. package/dist/chunk-APBK7NMS.js +0 -30
  580. package/dist/chunk-APBK7NMS.js.map +0 -1
  581. package/dist/chunk-AWO5YA7A.cjs +0 -33
  582. package/dist/chunk-AWO5YA7A.cjs.map +0 -1
  583. package/dist/chunk-AZATU6QW.js +0 -108
  584. package/dist/chunk-AZATU6QW.js.map +0 -1
  585. package/dist/chunk-BD2U3WST.cjs +0 -623
  586. package/dist/chunk-BD2U3WST.cjs.map +0 -1
  587. package/dist/chunk-BHBEOU6L.cjs +0 -65
  588. package/dist/chunk-BHBEOU6L.cjs.map +0 -1
  589. package/dist/chunk-CNOSNYNE.js +0 -8
  590. package/dist/chunk-CNOSNYNE.js.map +0 -1
  591. package/dist/chunk-CW3EFR4O.js +0 -12
  592. package/dist/chunk-CW3EFR4O.js.map +0 -1
  593. package/dist/chunk-DASVRNBK.js +0 -7187
  594. package/dist/chunk-DASVRNBK.js.map +0 -1
  595. package/dist/chunk-DJ6LCKYP.js +0 -42
  596. package/dist/chunk-DJ6LCKYP.js.map +0 -1
  597. package/dist/chunk-E5FHQAIO.cjs +0 -45
  598. package/dist/chunk-E5FHQAIO.cjs.map +0 -1
  599. package/dist/chunk-EOML5OTY.cjs +0 -360
  600. package/dist/chunk-EOML5OTY.cjs.map +0 -1
  601. package/dist/chunk-EP5CASHL.js +0 -613
  602. package/dist/chunk-EP5CASHL.js.map +0 -1
  603. package/dist/chunk-EP5OEEVZ.cjs +0 -14
  604. package/dist/chunk-EP5OEEVZ.cjs.map +0 -1
  605. package/dist/chunk-EUXI3FGQ.js +0 -150
  606. package/dist/chunk-EUXI3FGQ.js.map +0 -1
  607. package/dist/chunk-EWFSHCOS.js +0 -40
  608. package/dist/chunk-EWFSHCOS.js.map +0 -1
  609. package/dist/chunk-EX2C5K2T.cjs +0 -25
  610. package/dist/chunk-EX2C5K2T.cjs.map +0 -1
  611. package/dist/chunk-FEXWDQIZ.cjs +0 -8
  612. package/dist/chunk-FEXWDQIZ.cjs.map +0 -1
  613. package/dist/chunk-FEYBFY7H.cjs +0 -358
  614. package/dist/chunk-FEYBFY7H.cjs.map +0 -1
  615. package/dist/chunk-FRGAV6N6.cjs +0 -34
  616. package/dist/chunk-FRGAV6N6.cjs.map +0 -1
  617. package/dist/chunk-G5DHP5VF.js +0 -6
  618. package/dist/chunk-G5DHP5VF.js.map +0 -1
  619. package/dist/chunk-G5W2UHV2.js +0 -99
  620. package/dist/chunk-G5W2UHV2.js.map +0 -1
  621. package/dist/chunk-G7OP7O2C.cjs +0 -39
  622. package/dist/chunk-G7OP7O2C.cjs.map +0 -1
  623. package/dist/chunk-GE6CFCAM.cjs +0 -25
  624. package/dist/chunk-GE6CFCAM.cjs.map +0 -1
  625. package/dist/chunk-GIFALLHI.cjs +0 -111
  626. package/dist/chunk-GIFALLHI.cjs.map +0 -1
  627. package/dist/chunk-GLFET5GM.js +0 -129
  628. package/dist/chunk-GLFET5GM.js.map +0 -1
  629. package/dist/chunk-GQ6UFPFM.js +0 -22
  630. package/dist/chunk-GQ6UFPFM.js.map +0 -1
  631. package/dist/chunk-GQJWVMXS.js +0 -129
  632. package/dist/chunk-GQJWVMXS.js.map +0 -1
  633. package/dist/chunk-GVVJPUKC.js +0 -80
  634. package/dist/chunk-GVVJPUKC.js.map +0 -1
  635. package/dist/chunk-GZ2HOCQ2.cjs +0 -134
  636. package/dist/chunk-GZ2HOCQ2.cjs.map +0 -1
  637. package/dist/chunk-HCBOHXWP.js +0 -37
  638. package/dist/chunk-HCBOHXWP.js.map +0 -1
  639. package/dist/chunk-IBQJDVHF.cjs +0 -281
  640. package/dist/chunk-IBQJDVHF.cjs.map +0 -1
  641. package/dist/chunk-ISLB6Y5Q.cjs +0 -106
  642. package/dist/chunk-ISLB6Y5Q.cjs.map +0 -1
  643. package/dist/chunk-J55CRR4F.js +0 -105
  644. package/dist/chunk-J55CRR4F.js.map +0 -1
  645. package/dist/chunk-JBG6Z6MQ.cjs +0 -28
  646. package/dist/chunk-JBG6Z6MQ.cjs.map +0 -1
  647. package/dist/chunk-K3RQOZRU.js +0 -61
  648. package/dist/chunk-K3RQOZRU.js.map +0 -1
  649. package/dist/chunk-KDJYS4GB.cjs +0 -703
  650. package/dist/chunk-KDJYS4GB.cjs.map +0 -1
  651. package/dist/chunk-KMCAHUZM.cjs +0 -4
  652. package/dist/chunk-KMCAHUZM.cjs.map +0 -1
  653. package/dist/chunk-KUCBNPC6.js +0 -87
  654. package/dist/chunk-KUCBNPC6.js.map +0 -1
  655. package/dist/chunk-KV6UE5A4.js +0 -50
  656. package/dist/chunk-KV6UE5A4.js.map +0 -1
  657. package/dist/chunk-L6TZ2HQR.cjs +0 -18
  658. package/dist/chunk-L6TZ2HQR.cjs.map +0 -1
  659. package/dist/chunk-L7QHHGG2.cjs +0 -141
  660. package/dist/chunk-L7QHHGG2.cjs.map +0 -1
  661. package/dist/chunk-LHK3Y2AL.js +0 -271
  662. package/dist/chunk-LHK3Y2AL.js.map +0 -1
  663. package/dist/chunk-LO5RYRBH.cjs +0 -6317
  664. package/dist/chunk-LO5RYRBH.cjs.map +0 -1
  665. package/dist/chunk-LS5SJMUO.cjs +0 -194
  666. package/dist/chunk-LS5SJMUO.cjs.map +0 -1
  667. package/dist/chunk-LUGTMZFN.cjs +0 -42
  668. package/dist/chunk-LUGTMZFN.cjs.map +0 -1
  669. package/dist/chunk-LVUQU6D5.js +0 -32
  670. package/dist/chunk-LVUQU6D5.js.map +0 -1
  671. package/dist/chunk-M2QRC2GZ.js +0 -166
  672. package/dist/chunk-M2QRC2GZ.js.map +0 -1
  673. package/dist/chunk-M6QJYQIM.cjs +0 -53
  674. package/dist/chunk-M6QJYQIM.cjs.map +0 -1
  675. package/dist/chunk-MGCPH5EO.js +0 -12
  676. package/dist/chunk-MGCPH5EO.js.map +0 -1
  677. package/dist/chunk-MLVUWEZR.cjs +0 -474
  678. package/dist/chunk-MLVUWEZR.cjs.map +0 -1
  679. package/dist/chunk-MTAMJMZL.cjs +0 -707
  680. package/dist/chunk-MTAMJMZL.cjs.map +0 -1
  681. package/dist/chunk-MXL5AT3N.js +0 -48
  682. package/dist/chunk-MXL5AT3N.js.map +0 -1
  683. package/dist/chunk-MYEQSESM.cjs +0 -75
  684. package/dist/chunk-MYEQSESM.cjs.map +0 -1
  685. package/dist/chunk-N3VPF6ZD.js +0 -427
  686. package/dist/chunk-N3VPF6ZD.js.map +0 -1
  687. package/dist/chunk-N6VUAIGI.js +0 -7
  688. package/dist/chunk-N6VUAIGI.js.map +0 -1
  689. package/dist/chunk-N6XRLUN6.js +0 -6286
  690. package/dist/chunk-N6XRLUN6.js.map +0 -1
  691. package/dist/chunk-NOGDOZIT.cjs +0 -114
  692. package/dist/chunk-NOGDOZIT.cjs.map +0 -1
  693. package/dist/chunk-NUWXEISH.cjs +0 -10
  694. package/dist/chunk-NUWXEISH.cjs.map +0 -1
  695. package/dist/chunk-NZCZHXYN.cjs +0 -161
  696. package/dist/chunk-NZCZHXYN.cjs.map +0 -1
  697. package/dist/chunk-ODROSWQX.cjs +0 -53
  698. package/dist/chunk-ODROSWQX.cjs.map +0 -1
  699. package/dist/chunk-OE36AYKG.cjs +0 -82
  700. package/dist/chunk-OE36AYKG.cjs.map +0 -1
  701. package/dist/chunk-OLON7MO6.cjs +0 -437
  702. package/dist/chunk-OLON7MO6.cjs.map +0 -1
  703. package/dist/chunk-PBUOR2IT.js +0 -277
  704. package/dist/chunk-PBUOR2IT.js.map +0 -1
  705. package/dist/chunk-PC2ELXFF.cjs +0 -225
  706. package/dist/chunk-PC2ELXFF.cjs.map +0 -1
  707. package/dist/chunk-PCSGXLOC.js +0 -71
  708. package/dist/chunk-PCSGXLOC.js.map +0 -1
  709. package/dist/chunk-PFNMP6FQ.js +0 -56
  710. package/dist/chunk-PFNMP6FQ.js.map +0 -1
  711. package/dist/chunk-PIWSZTIP.js +0 -690
  712. package/dist/chunk-PIWSZTIP.js.map +0 -1
  713. package/dist/chunk-PKWHJ2GI.js +0 -136
  714. package/dist/chunk-PKWHJ2GI.js.map +0 -1
  715. package/dist/chunk-PLMVBX2A.cjs +0 -76
  716. package/dist/chunk-PLMVBX2A.cjs.map +0 -1
  717. package/dist/chunk-PM3XCD2G.cjs +0 -113
  718. package/dist/chunk-PM3XCD2G.cjs.map +0 -1
  719. package/dist/chunk-QAL4GZO7.cjs +0 -143
  720. package/dist/chunk-QAL4GZO7.cjs.map +0 -1
  721. package/dist/chunk-QDB2SEA2.js +0 -74
  722. package/dist/chunk-QDB2SEA2.js.map +0 -1
  723. package/dist/chunk-QOV7UNUN.js +0 -25
  724. package/dist/chunk-QOV7UNUN.js.map +0 -1
  725. package/dist/chunk-QQUWYLSF.cjs +0 -50
  726. package/dist/chunk-QQUWYLSF.cjs.map +0 -1
  727. package/dist/chunk-QUMBH3U4.cjs +0 -9
  728. package/dist/chunk-QUMBH3U4.cjs.map +0 -1
  729. package/dist/chunk-R4KA7OFQ.js +0 -12
  730. package/dist/chunk-R4KA7OFQ.js.map +0 -1
  731. package/dist/chunk-RBSGAZQQ.js +0 -17
  732. package/dist/chunk-RBSGAZQQ.js.map +0 -1
  733. package/dist/chunk-RM5YJWZI.js +0 -46
  734. package/dist/chunk-RM5YJWZI.js.map +0 -1
  735. package/dist/chunk-ROKNKXA4.cjs +0 -8
  736. package/dist/chunk-ROKNKXA4.cjs.map +0 -1
  737. package/dist/chunk-RQG6D546.cjs +0 -75
  738. package/dist/chunk-RQG6D546.cjs.map +0 -1
  739. package/dist/chunk-SG4YDD5L.cjs +0 -74
  740. package/dist/chunk-SG4YDD5L.cjs.map +0 -1
  741. package/dist/chunk-SNRCA7EO.js +0 -56
  742. package/dist/chunk-SNRCA7EO.js.map +0 -1
  743. package/dist/chunk-SO75R4WW.cjs +0 -22
  744. package/dist/chunk-SO75R4WW.cjs.map +0 -1
  745. package/dist/chunk-SP34NHFI.js +0 -45
  746. package/dist/chunk-SP34NHFI.js.map +0 -1
  747. package/dist/chunk-SSKSSBWJ.cjs +0 -179
  748. package/dist/chunk-SSKSSBWJ.cjs.map +0 -1
  749. package/dist/chunk-TB5663C2.js +0 -1108
  750. package/dist/chunk-TB5663C2.js.map +0 -1
  751. package/dist/chunk-TGH4NRES.js +0 -220
  752. package/dist/chunk-TGH4NRES.js.map +0 -1
  753. package/dist/chunk-TJ6ZPNID.js +0 -189
  754. package/dist/chunk-TJ6ZPNID.js.map +0 -1
  755. package/dist/chunk-U45T35N2.cjs +0 -90
  756. package/dist/chunk-U45T35N2.cjs.map +0 -1
  757. package/dist/chunk-UKVOPEZ2.js +0 -442
  758. package/dist/chunk-UKVOPEZ2.js.map +0 -1
  759. package/dist/chunk-UTB4NROA.cjs +0 -887
  760. package/dist/chunk-UTB4NROA.cjs.map +0 -1
  761. package/dist/chunk-UTW33B5V.js +0 -6
  762. package/dist/chunk-UTW33B5V.js.map +0 -1
  763. package/dist/chunk-UYUBSD2V.cjs +0 -33
  764. package/dist/chunk-UYUBSD2V.cjs.map +0 -1
  765. package/dist/chunk-V3JEP5AG.cjs +0 -59
  766. package/dist/chunk-V3JEP5AG.cjs.map +0 -1
  767. package/dist/chunk-VFAGJXHR.js +0 -18
  768. package/dist/chunk-VFAGJXHR.js.map +0 -1
  769. package/dist/chunk-VMEE57E5.cjs +0 -58
  770. package/dist/chunk-VMEE57E5.cjs.map +0 -1
  771. package/dist/chunk-VQVBEX3Y.cjs +0 -113
  772. package/dist/chunk-VQVBEX3Y.cjs.map +0 -1
  773. package/dist/chunk-VZDXX7TT.cjs +0 -64
  774. package/dist/chunk-VZDXX7TT.cjs.map +0 -1
  775. package/dist/chunk-WE5ZTI4D.js +0 -346
  776. package/dist/chunk-WE5ZTI4D.js.map +0 -1
  777. package/dist/chunk-WEFUVABP.js +0 -19
  778. package/dist/chunk-WEFUVABP.js.map +0 -1
  779. package/dist/chunk-WMU4LRKC.js +0 -28
  780. package/dist/chunk-WMU4LRKC.js.map +0 -1
  781. package/dist/chunk-WQ24RRHL.cjs +0 -354
  782. package/dist/chunk-WQ24RRHL.cjs.map +0 -1
  783. package/dist/chunk-WW4CGS7G.cjs +0 -26
  784. package/dist/chunk-WW4CGS7G.cjs.map +0 -1
  785. package/dist/chunk-WXE5WCTM.js +0 -1144
  786. package/dist/chunk-WXE5WCTM.js.map +0 -1
  787. package/dist/chunk-X23BGIYA.cjs +0 -37
  788. package/dist/chunk-X23BGIYA.cjs.map +0 -1
  789. package/dist/chunk-XEW4FTR2.js +0 -98
  790. package/dist/chunk-XEW4FTR2.js.map +0 -1
  791. package/dist/chunk-XIOI4IYW.js +0 -167
  792. package/dist/chunk-XIOI4IYW.js.map +0 -1
  793. package/dist/chunk-XLVPJ37V.cjs +0 -44
  794. package/dist/chunk-XLVPJ37V.cjs.map +0 -1
  795. package/dist/chunk-XOHAXXZA.cjs +0 -51
  796. package/dist/chunk-XOHAXXZA.cjs.map +0 -1
  797. package/dist/chunk-Y4NRIHK6.cjs +0 -313
  798. package/dist/chunk-Y4NRIHK6.cjs.map +0 -1
  799. package/dist/chunk-Y4YMMKL3.js +0 -23
  800. package/dist/chunk-Y4YMMKL3.js.map +0 -1
  801. package/dist/chunk-YJNYBVE3.cjs +0 -14
  802. package/dist/chunk-YJNYBVE3.cjs.map +0 -1
  803. package/dist/chunk-Z762QNQP.cjs +0 -60
  804. package/dist/chunk-Z762QNQP.cjs.map +0 -1
  805. package/dist/chunk-ZG5KMBOF.js +0 -669
  806. package/dist/chunk-ZG5KMBOF.js.map +0 -1
  807. package/dist/chunk-ZKONQEFA.js +0 -344
  808. package/dist/chunk-ZKONQEFA.js.map +0 -1
  809. package/dist/chunk-ZR5X7QMH.js +0 -39
  810. package/dist/chunk-ZR5X7QMH.js.map +0 -1
  811. package/dist/chunk-ZW4BJQ26.js +0 -84
  812. package/dist/chunk-ZW4BJQ26.js.map +0 -1
  813. package/dist/climbs-BhlWuu0x.d.ts +0 -70
  814. package/dist/climbs-DgBFwySV.d.cts +0 -70
  815. package/dist/data/index.cjs.map +0 -1
  816. package/dist/data/index.js.map +0 -1
  817. package/dist/errors/index.cjs.map +0 -1
  818. package/dist/errors/index.js.map +0 -1
  819. package/dist/geo/index.cjs.map +0 -1
  820. package/dist/geo/index.js.map +0 -1
  821. package/dist/icons/index.cjs.map +0 -1
  822. package/dist/icons/index.js.map +0 -1
  823. package/dist/itinerary-Dp2ZnqgD.d.cts +0 -178
  824. package/dist/itinerary-Dp2ZnqgD.d.ts +0 -178
  825. package/dist/layers/index.cjs.map +0 -1
  826. package/dist/layers/index.js.map +0 -1
  827. package/dist/map-client/index.cjs.map +0 -1
  828. package/dist/map-client/index.js.map +0 -1
  829. package/dist/markerSprite-DGBQF6PO.cjs +0 -49
  830. package/dist/markerSprite-DGBQF6PO.cjs.map +0 -1
  831. package/dist/markerSprite-DZLTR6F6.js +0 -8
  832. package/dist/markerSprite-DZLTR6F6.js.map +0 -1
  833. package/dist/mountayaMap-C9mxRFib.d.cts +0 -3277
  834. package/dist/mountayaMap-DgnlQ2fE.d.ts +0 -3277
  835. package/dist/paint-BgUcj8l7.d.cts +0 -118
  836. package/dist/paint-Dx_qGNE_.d.ts +0 -118
  837. package/dist/profile/index.cjs.map +0 -1
  838. package/dist/profile/index.js.map +0 -1
  839. package/dist/seams/index.cjs.map +0 -1
  840. package/dist/seams/index.js.map +0 -1
  841. package/dist/search/index.cjs.map +0 -1
  842. package/dist/search/index.js.map +0 -1
  843. package/dist/searchHighlight-DFE7LVIL.cjs +0 -33
  844. package/dist/searchHighlight-DFE7LVIL.cjs.map +0 -1
  845. package/dist/searchHighlight-MHAQZVWG.js +0 -12
  846. package/dist/searchHighlight-MHAQZVWG.js.map +0 -1
  847. package/dist/strings-30RSdIat.d.cts +0 -552
  848. package/dist/strings-DPTIbzT5.d.ts +0 -552
  849. package/dist/stripeImage-CQUXM2YI.js +0 -14
  850. package/dist/stripeImage-CQUXM2YI.js.map +0 -1
  851. package/dist/stripeImage-R43OPA6U.cjs +0 -39
  852. package/dist/stripeImage-R43OPA6U.cjs.map +0 -1
  853. package/dist/style/index.cjs.map +0 -1
  854. package/dist/style/index.js.map +0 -1
  855. package/dist/types-B034JMjl.d.ts +0 -973
  856. package/dist/types-B2NDLxQA.d.cts +0 -21
  857. package/dist/types-B2NDLxQA.d.ts +0 -21
  858. package/dist/types-C8aX5KMU.d.cts +0 -973
  859. package/dist/units/index.cjs.map +0 -1
  860. package/dist/units/index.js.map +0 -1
  861. package/dist/view/index.cjs.map +0 -1
  862. package/dist/view/index.js.map +0 -1
@@ -1,6 +1,5 @@
1
- import { AgentClientToolManifest, AgentRunReason, AgentRunProfile, AgentToolErrorCode } from '@mountaya/client';
2
- import { AgentTransport, AgentEvent } from '@mountaya/client/events';
3
-
1
+ import { AgentClientToolManifest, AgentRunProfile, AgentRunReason, AgentToolErrorCode } from "@mountaya/client";
2
+ import { AgentEvent, AgentTransport } from "@mountaya/client/events";
4
3
  /**
5
4
  * What the agent loop needs from a tool layer, and nothing more.
6
5
  *
@@ -25,17 +24,17 @@ import { AgentTransport, AgentEvent } from '@mountaya/client/events';
25
24
  * the API already states.
26
25
  */
27
26
  interface ToolManifestEntry {
28
- capability: string;
29
- description: string;
30
- inputSchema: AgentClientToolManifest["parameters"];
31
- name: string;
32
- /**
33
- * Whether the tool only reads state and changes nothing. Absent means unknown, which every
34
- * consumer must treat as "may mutate": a run uses it to decide what its transcript may safely
35
- * drop, and guessing wrong there erases the record of a real change.
36
- */
37
- readOnly?: boolean | undefined;
38
- requiresConfirmation: boolean;
27
+ capability: string;
28
+ description: string;
29
+ inputSchema: AgentClientToolManifest["parameters"];
30
+ name: string;
31
+ /**
32
+ * Whether the tool only reads state and changes nothing. Absent means unknown, which every
33
+ * consumer must treat as "may mutate": a run uses it to decide what its transcript may safely
34
+ * drop, and guessing wrong there erases the record of a real change.
35
+ */
36
+ readOnly?: boolean | undefined;
37
+ requiresConfirmation: boolean;
39
38
  }
40
39
  /**
41
40
  * ToolDispatchResult is the outcome of one dispatched tool call, as the loop reads it.
@@ -45,13 +44,13 @@ interface ToolManifestEntry {
45
44
  * `code`. The loop branches on `confirmation-denied` and forwards everything else verbatim.
46
45
  */
47
46
  type ToolDispatchResult = {
48
- data?: unknown;
49
- ok: true;
50
- summary: string;
47
+ data?: unknown;
48
+ ok: true;
49
+ summary: string;
51
50
  } | {
52
- code?: string | undefined;
53
- error: string;
54
- ok: false;
51
+ code?: string | undefined;
52
+ error: string;
53
+ ok: false;
55
54
  };
56
55
  /**
57
56
  * ToolDispatcher is the tool layer the loop drives: what is on offer, and how to run one.
@@ -62,8 +61,8 @@ type ToolDispatchResult = {
62
61
  * never touches a store, a map or a transport of its own.
63
62
  */
64
63
  interface ToolDispatcher<TContext> {
65
- manifest(capabilities: ReadonlySet<string>, surface?: ReadonlySet<string>): ToolManifestEntry[];
66
- dispatchFromModel(context: TContext, name: string, input: unknown): Promise<ToolDispatchResult>;
64
+ manifest(capabilities: ReadonlySet<string>, surface?: ReadonlySet<string>): ToolManifestEntry[];
65
+ dispatchFromModel(context: TContext, name: string, input: unknown): Promise<ToolDispatchResult>;
67
66
  }
68
67
  /**
69
68
  * AgentToolContext is the part of a host's execution context the loop itself reads.
@@ -74,7 +73,7 @@ interface ToolDispatcher<TContext> {
74
73
  * the manifest, and what is on offer is a function of what the reader may do.
75
74
  */
76
75
  interface AgentToolContext {
77
- capabilities: ReadonlySet<string>;
76
+ capabilities: ReadonlySet<string>;
78
77
  }
79
78
  /**
80
79
  * StateDelta is how a host says what its own state did while a tool ran.
@@ -90,8 +89,8 @@ interface AgentToolContext {
90
89
  * report rather than an error.
91
90
  */
92
91
  interface StateDelta<TContext, TSnapshot = unknown> {
93
- capture(context: TContext): TSnapshot;
94
- diff(before: TSnapshot, after: TSnapshot): Record<string, unknown> | undefined;
92
+ capture(context: TContext): TSnapshot;
93
+ diff(before: TSnapshot, after: TSnapshot): Record<string, unknown> | undefined;
95
94
  }
96
95
  /**
97
96
  * RecoveryLookup answers "a call to this tool failed with this code: what should the model try
@@ -101,45 +100,6 @@ interface StateDelta<TContext, TSnapshot = unknown> {
101
100
  * failure is reported bare.
102
101
  */
103
102
  type RecoveryLookup = (tool: string, code?: string) => string | undefined;
104
-
105
- /**
106
- * Driving one co-pilot run from open to settled.
107
- *
108
- * The engine owns the stream and nothing else owns any of it: it opens the run's event stream,
109
- * folds every frame into the conversation, dispatches the client tools that arrive on it,
110
- * resumes after a drop from the last event id, backs off when an open is unproductive, and
111
- * tears down exactly what it stood up.
112
- *
113
- * **It is not the collaboration session wearing a different name, and the two are deliberately
114
- * not one engine.** They look alike from a distance (both open a stream, resume it, back off
115
- * and dispose), and the halves that genuinely ARE shared already are: `@mountaya/client/events`
116
- * publishes the reader, the frame decoding and the event types, which both sides import rather
117
- * than restate, and both draw the wait before a reopen through `reconnectDelayMs`
118
- * (`stream/rules/reconnectSchedule.ts`), full jitter below a ceiling that doubles. What is left is
119
- * POLICY, and the policies disagree on every number and on the rule behind each one, because one
120
- * has a person waiting on it and the other does not.
121
- *
122
- * Here: a ceiling that doubles to 8 seconds, and six attempts, because someone is sitting in
123
- * front of the run: it must never spend a minute asleep, and it must stop rather than re-open a
124
- * stream nothing can revive for as long as the tab is open. A reconnect is judged by whether the
125
- * open was PRODUCTIVE, since a gateway that says one thing and hangs up delivers a frame every
126
- * time. A read that fails reopens only when the next open can outlive the failure: a dropped
127
- * connection, a 429, a 503 or a 504. A run the provider's rate limit already ended is answered
128
- * 409, which every reopen would meet again, and a 502 is never reopened either. The 503 is the
129
- * one failure the six attempts do not count: it says the run's events cannot be reached for a
130
- * moment while the run goes on, so its opens are held to two minutes, which is still a bound.
131
- *
132
- * There: a ceiling that doubles from half a second to 15 seconds, and no attempt limit, because a
133
- * collaboration feed is background and a persistently-unreachable endpoint should keep trying at
134
- * a steady rate; and a stream that delivered more than the frames every open begins with
135
- * reconnects with NO delay, so a healthy feed the API cycles between windows resumes promptly.
136
- *
137
- * A shared core beyond the draw would have to be parameterised by the ceiling, the growth seed,
138
- * the attempt limit, the productivity rule and the resume key, which is every line that differs,
139
- * and would leave behind two configuration objects and one indirection for the few lines of a read
140
- * loop the two files have in common.
141
- */
142
-
143
103
  /**
144
104
  * ServerToolConfirmation describes a destructive SERVER tool the gateway asks to
145
105
  * run: the run identifies it by name alone (a server tool has no client-side
@@ -148,7 +108,7 @@ type RecoveryLookup = (tool: string, code?: string) => string | undefined;
148
108
  * is why this stays decoupled from the bus's client-tool ConfirmationRequest.
149
109
  */
150
110
  interface ServerToolConfirmation {
151
- name: string;
111
+ name: string;
152
112
  }
153
113
  /**
154
114
  * ToolActivityOutcome is how a tool call settled, delivered through
@@ -161,23 +121,23 @@ interface ServerToolConfirmation {
161
121
  * the host recorded and one it never saw a call for.
162
122
  */
163
123
  interface ToolActivityOutcome {
164
- error?: string | undefined;
165
- /**
166
- * Why an abandoned call was given up on: `timeout` when nothing came back within
167
- * the await window, `closed` when the run was asked to finish while the call was
168
- * still outstanding. Absent on any other status, and on a gateway that does not
169
- * send one.
170
- */
171
- abandonedReason?: "timeout" | "closed" | undefined;
172
- /**
173
- * What the run will try about this failure, from the tool's playbook entry.
174
- * Present only on a failure the playbook has guidance for. The run already sends
175
- * this to the model; surfacing it to the host too is what stops a silent retry
176
- * reading as a stall.
177
- */
178
- recovery?: string | undefined;
179
- status: "abandoned" | "error" | "ok";
180
- summary?: string | undefined;
124
+ error?: string | undefined;
125
+ /**
126
+ * Why an abandoned call was given up on: `timeout` when nothing came back within
127
+ * the await window, `closed` when the run was asked to finish while the call was
128
+ * still outstanding. Absent on any other status, and on a gateway that does not
129
+ * send one.
130
+ */
131
+ abandonedReason?: "timeout" | "closed" | undefined;
132
+ /**
133
+ * What the run will try about this failure, from the tool's playbook entry.
134
+ * Present only on a failure the playbook has guidance for. The run already sends
135
+ * this to the model; surfacing it to the host too is what stops a silent retry
136
+ * reading as a stall.
137
+ */
138
+ recovery?: string | undefined;
139
+ status: "abandoned" | "error" | "ok";
140
+ summary?: string | undefined;
181
141
  }
182
142
  /**
183
143
  * AgentObserver is the host's window onto a running session. The engine pushes
@@ -191,118 +151,118 @@ interface ToolActivityOutcome {
191
151
  * the tool surface, the state delta) ends the read instead.
192
152
  */
193
153
  interface AgentObserver {
194
- /**
195
- * onError surfaces an error or budget-exhausted event so the host can show it.
196
- * `code` is the machine-readable reason every run error carries (e.g.
197
- * `rate-limited`), or the literal `budget-exhausted` for a budget ceiling, in
198
- * which case `message` carries the exhausted dimension (`turns` / `cost`) rather
199
- * than a human string. It is absent only for a fault the engine raises itself,
200
- * such as a tool result it could not post, whose message is empty. This lets the
201
- * host map a known code to specific copy (a budget code to per-dimension
202
- * usage-limit copy) and fall back to a generic message otherwise.
203
- *
204
- * It never ends the run. The gateway publishes an `error` or a `budget-exhausted` only
205
- * as the run ends and always follows it with the terminal `done`, which is what ends the
206
- * run and reaches {@link onRunEnd}.
207
- */
208
- onError?: ((message: string, code?: string) => void) | undefined;
209
- /**
210
- * onRunEnd reports how a run ended, read off its terminal `done` frame: `completed`,
211
- * `closed`, `failed`, `budget-exhausted`, `rate-limited` or `looping`. It fires at most
212
- * once per read of a run, which one {@link AgentEngine.start} or {@link AgentEngine.resume}
213
- * makes, before `onStateChange("ended")`. A resume that reads the `done` of a run already
214
- * read to its end reports it again: one by an engine that holds no position for the run,
215
- * which is answered with the run's history, or one given a position before the `done`.
216
- *
217
- * Only `done` knows the reason, so a read that ends any other way reports none: a
218
- * {@link AgentEngine.close} or {@link AgentEngine.dispose}, a start or a resume that
219
- * replaces the run, and a stream the engine stopped reconnecting to without a `done`.
220
- * Optional: a host that needs only the `ended`
221
- * state omits it.
222
- */
223
- onRunEnd?: ((reason: AgentRunReason) => void) | undefined;
224
- /**
225
- * onChecksUnmet reports the success criteria a run's retrieved skills promised
226
- * that the workspace does not back, published by the run right before it settles
227
- * into awaiting_input. Informational, never terminal: the answer stands and the
228
- * user decides. The sentences are the authored criteria, written for the user.
229
- * Optional: a host that does not render the warning omits it.
230
- */
231
- onChecksUnmet?: ((unmet: readonly string[]) => void) | undefined;
232
- /**
233
- * onMessage delivers a complete assistant message (the turn's settled text) with
234
- * the message's zero-based position among the run's assistant messages.
235
- *
236
- * The index is the number a rating on this message has to carry back, and it comes
237
- * from the run because a host cannot work it out. A host counts the replies it is
238
- * showing, and a reload mid-run leaves it showing none (the URL carries the thread
239
- * and run ids, not the conversation), so a locally counted index restarts at zero
240
- * while the run's is already higher, and every rating from then on names an earlier
241
- * answer than the one that was rated.
242
- *
243
- * It is undefined for a message from a gateway that sends no index, in which case
244
- * the host falls back to its own count for that message alone.
245
- */
246
- onMessage?: ((content: string, messageIndex?: number) => void) | undefined;
247
- /** onMessageDelta delivers one streamed assistant token as it arrives. */
248
- onMessageDelta?: ((text: string) => void) | undefined;
249
- /**
250
- * onRunId reports the run's id the moment start/resume sets it, so the host can
251
- * persist it (e.g. into the URL) for a reload to reconnect.
252
- */
253
- onRunId?: ((runId: string) => void) | undefined;
254
- /** onStateChange reports the session's lifecycle transitions to the host. */
255
- onStateChange?: ((state: AgentEngineState) => void) | undefined;
256
- /**
257
- * onToolActivity surfaces what the run is doing right now so the host can show
258
- * a live activity line. The session emits the dispatched CLIENT tool's name as
259
- * it begins, then the tool's result summary (when the bus returns one) as it
260
- * settles, so the line tracks the action from start to finish. Optional: a host
261
- * that does not render activity omits it.
262
- */
263
- onToolActivity?: ((summary: string) => void) | undefined;
264
- /**
265
- * onToolCall delivers a client tool call's name, its raw unvalidated input, and
266
- * the call's id the moment the run emits it: the structured twin of
267
- * {@link onToolActivity}, which carries only the human display string. A host reads
268
- * this to react to WHAT the tool will touch (deriving the workspace target an edit is
269
- * about to lock from the input) and to record the call as a durable activity row
270
- * keyed by its id, which {@link onToolResult} later settles. The display line
271
- * cannot carry the structured input or the id. Fires before the bus dispatch,
272
- * alongside onToolActivity. Optional: a host that renders only the activity line
273
- * omits it.
274
- */
275
- onToolCall?: ((name: string, input: unknown, toolCallId: string) => void) | undefined;
276
- /**
277
- * onToolResult reports how a tool call settled, keyed by its call id, so a host
278
- * that recorded the call through onToolCall can settle that activity row. A CLIENT
279
- * tool call the engine ran is reported once, from the bus result as the dispatch
280
- * returns. Every other call is reported from the `tool-result` or `tool-abandoned`
281
- * event the stream carries for it: a SERVER tool's outcome, a call the run gave up
282
- * on, and the outcome replayed behind a call the stream marks `settled`. Optional:
283
- * a host that renders only the activity line omits it.
284
- *
285
- * The stream names a call the engine ran a second time: the gateway echoes the
286
- * answer the engine posted as a `tool-result`, and a `tool-abandoned` can cross an
287
- * answer that came late. For a call it reported, the engine drops both whole, in the
288
- * read that ran the call and in every later read of the run, so the bus result is the
289
- * one report. An echo says less than the bus did: it carries no summary, and it words
290
- * a confirmation the user declined as an error. A call whose handling threw before the
291
- * report (the tool layer, or one of the host's seams) has no report of the engine's,
292
- * so what the stream says about it is delivered. What the stream says of a call while its
293
- * tool still runs, in a read a {@link AgentEngine.resume} opened beside it, is held until
294
- * the tool settles: the bus result is then the one report, and the first thing the stream
295
- * said is delivered only when the handling throws.
296
- *
297
- * The id may be one the host never saw a call for, which the host settles by
298
- * appending an already-settled row: a server tool's, which emits no call event, or
299
- * a call the stream marks settled, whose `tool-call` frame the engine drops before
300
- * it reports the outcome replayed behind it. The id may also be one already reported: a failed
301
- * `tool-result` follows the `tool-abandoned` of a confirmation nobody decided, and
302
- * a resumed stream replays an outcome. The first report is the one to keep, which
303
- * is what `settleActivityEntry` does.
304
- */
305
- onToolResult?: ((toolCallId: string, outcome: ToolActivityOutcome) => void) | undefined;
154
+ /**
155
+ * onError surfaces an error or budget-exhausted event so the host can show it.
156
+ * `code` is the machine-readable reason every run error carries (e.g.
157
+ * `rate-limited`), or the literal `budget-exhausted` for a budget ceiling, in
158
+ * which case `message` carries the exhausted dimension (`turns` / `cost`) rather
159
+ * than a human string. It is absent only for a fault the engine raises itself,
160
+ * such as a tool result it could not post, whose message is empty. This lets the
161
+ * host map a known code to specific copy (a budget code to per-dimension
162
+ * usage-limit copy) and fall back to a generic message otherwise.
163
+ *
164
+ * It never ends the run. The gateway publishes an `error` or a `budget-exhausted` only
165
+ * as the run ends and always follows it with the terminal `done`, which is what ends the
166
+ * run and reaches {@link onRunEnd}.
167
+ */
168
+ onError?: ((message: string, code?: string) => void) | undefined;
169
+ /**
170
+ * onRunEnd reports how a run ended, read off its terminal `done` frame: `completed`,
171
+ * `closed`, `failed`, `budget-exhausted`, `rate-limited` or `looping`. It fires at most
172
+ * once per read of a run, which one {@link AgentEngine.start} or {@link AgentEngine.resume}
173
+ * makes, before `onStateChange("ended")`. A resume that reads the `done` of a run already
174
+ * read to its end reports it again: one by an engine that holds no position for the run,
175
+ * which is answered with the run's history, or one given a position before the `done`.
176
+ *
177
+ * Only `done` knows the reason, so a read that ends any other way reports none: a
178
+ * {@link AgentEngine.close} or {@link AgentEngine.dispose}, a start or a resume that
179
+ * replaces the run, and a stream the engine stopped reconnecting to without a `done`.
180
+ * Optional: a host that needs only the `ended`
181
+ * state omits it.
182
+ */
183
+ onRunEnd?: ((reason: AgentRunReason) => void) | undefined;
184
+ /**
185
+ * onChecksUnmet reports the success criteria a run's retrieved skills promised
186
+ * that the workspace does not back, published by the run right before it settles
187
+ * into awaiting_input. Informational, never terminal: the answer stands and the
188
+ * user decides. The sentences are the authored criteria, written for the user.
189
+ * Optional: a host that does not render the warning omits it.
190
+ */
191
+ onChecksUnmet?: ((unmet: readonly string[]) => void) | undefined;
192
+ /**
193
+ * onMessage delivers a complete assistant message (the turn's settled text) with
194
+ * the message's zero-based position among the run's assistant messages.
195
+ *
196
+ * The index is the number a rating on this message has to carry back, and it comes
197
+ * from the run because a host cannot work it out. A host counts the replies it is
198
+ * showing, and a reload mid-run leaves it showing none (the URL carries the thread
199
+ * and run ids, not the conversation), so a locally counted index restarts at zero
200
+ * while the run's is already higher, and every rating from then on names an earlier
201
+ * answer than the one that was rated.
202
+ *
203
+ * It is undefined for a message from a gateway that sends no index, in which case
204
+ * the host falls back to its own count for that message alone.
205
+ */
206
+ onMessage?: ((content: string, messageIndex?: number) => void) | undefined;
207
+ /** onMessageDelta delivers one streamed assistant token as it arrives. */
208
+ onMessageDelta?: ((text: string) => void) | undefined;
209
+ /**
210
+ * onRunId reports the run's id the moment start/resume sets it, so the host can
211
+ * persist it (e.g. into the URL) for a reload to reconnect.
212
+ */
213
+ onRunId?: ((runId: string) => void) | undefined;
214
+ /** onStateChange reports the session's lifecycle transitions to the host. */
215
+ onStateChange?: ((state: AgentEngineState) => void) | undefined;
216
+ /**
217
+ * onToolActivity surfaces what the run is doing right now so the host can show
218
+ * a live activity line. The session emits the dispatched CLIENT tool's name as
219
+ * it begins, then the tool's result summary (when the bus returns one) as it
220
+ * settles, so the line tracks the action from start to finish. Optional: a host
221
+ * that does not render activity omits it.
222
+ */
223
+ onToolActivity?: ((summary: string) => void) | undefined;
224
+ /**
225
+ * onToolCall delivers a client tool call's name, its raw unvalidated input, and
226
+ * the call's id the moment the run emits it: the structured twin of
227
+ * {@link onToolActivity}, which carries only the human display string. A host reads
228
+ * this to react to WHAT the tool will touch (deriving the workspace target an edit is
229
+ * about to lock from the input) and to record the call as a durable activity row
230
+ * keyed by its id, which {@link onToolResult} later settles. The display line
231
+ * cannot carry the structured input or the id. Fires before the bus dispatch,
232
+ * alongside onToolActivity. Optional: a host that renders only the activity line
233
+ * omits it.
234
+ */
235
+ onToolCall?: ((name: string, input: unknown, toolCallId: string) => void) | undefined;
236
+ /**
237
+ * onToolResult reports how a tool call settled, keyed by its call id, so a host
238
+ * that recorded the call through onToolCall can settle that activity row. A CLIENT
239
+ * tool call the engine ran is reported once, from the bus result as the dispatch
240
+ * returns. Every other call is reported from the `tool-result` or `tool-abandoned`
241
+ * event the stream carries for it: a SERVER tool's outcome, a call the run gave up
242
+ * on, and the outcome replayed behind a call the stream marks `settled`. Optional:
243
+ * a host that renders only the activity line omits it.
244
+ *
245
+ * The stream names a call the engine ran a second time: the gateway echoes the
246
+ * answer the engine posted as a `tool-result`, and a `tool-abandoned` can cross an
247
+ * answer that came late. For a call it reported, the engine drops both whole, in the
248
+ * read that ran the call and in every later read of the run, so the bus result is the
249
+ * one report. An echo says less than the bus did: it carries no summary, and it words
250
+ * a confirmation the user declined as an error. A call whose handling threw before the
251
+ * report (the tool layer, or one of the host's seams) has no report of the engine's,
252
+ * so what the stream says about it is delivered. What the stream says of a call while its
253
+ * tool still runs, in a read a {@link AgentEngine.resume} opened beside it, is held until
254
+ * the tool settles: the bus result is then the one report, and the first thing the stream
255
+ * said is delivered only when the handling throws.
256
+ *
257
+ * The id may be one the host never saw a call for, which the host settles by
258
+ * appending an already-settled row: a server tool's, which emits no call event, or
259
+ * a call the stream marks settled, whose `tool-call` frame the engine drops before
260
+ * it reports the outcome replayed behind it. The id may also be one already reported: a failed
261
+ * `tool-result` follows the `tool-abandoned` of a confirmation nobody decided, and
262
+ * a resumed stream replays an outcome. The first report is the one to keep, which
263
+ * is what `settleActivityEntry` does.
264
+ */
265
+ onToolResult?: ((toolCallId: string, outcome: ToolActivityOutcome) => void) | undefined;
306
266
  }
307
267
  /**
308
268
  * AgentEngineState is the session lifecycle the host renders against: it is
@@ -326,10 +286,10 @@ type AgentEngineState = "running" | "awaiting_input" | "ended";
326
286
  * left it, and the gateway replays nothing the host already holds.
327
287
  */
328
288
  interface AgentStreamPosition {
329
- /** The position, as the stream spelled it: what a reopen sends back as `Last-Event-ID`. */
330
- readonly lastEventId: string;
331
- /** The run the position belongs to. A position names nothing in another run. */
332
- readonly runId: string;
289
+ /** The position, as the stream spelled it: what a reopen sends back as `Last-Event-ID`. */
290
+ readonly lastEventId: string;
291
+ /** The run the position belongs to. A position names nothing in another run. */
292
+ readonly runId: string;
333
293
  }
334
294
  /**
335
295
  * AgentEngineConfig wires a session to the tool bus and its execution context, the
@@ -347,49 +307,49 @@ interface AgentStreamPosition {
347
307
  * what the model can SEE; the capability gate remains the sole authorization boundary.
348
308
  */
349
309
  interface AgentEngineConfig<TContext extends AgentToolContext = AgentToolContext> {
350
- bus: ToolDispatcher<TContext>;
351
- confirmServerTool: (confirmation: ServerToolConfirmation) => Promise<boolean>;
352
- ctx: TContext;
353
- observer: AgentObserver;
354
- /**
355
- * How the host reports what its own state did while a tool ran, and what to try after a
356
- * failure. Both are OPTIONAL and both are the host's policy rather than the loop's:
357
- * `@mountaya/studio` passes its store fingerprint and its routing tables, a host wiring their
358
- * own tools passes neither and a run reports the tool result bare.
359
- */
360
- recoveryFor?: RecoveryLookup | undefined;
361
- stateDelta?: StateDelta<TContext> | undefined;
362
- /**
363
- * Prompt profile the run opens with. Omitted means the full studio co-pilot.
364
- * It belongs on the session rather than on start() because it is a property of
365
- * the SURFACE, not of a message: a Video Director session is a director for its
366
- * whole life.
367
- */
368
- profile?: AgentRunProfile | undefined;
369
- /**
370
- * Whether a run names the server tools the model sees, from the selection `toolSurface`
371
- * answers: the routed set rides a start's `server_tools` and every routing update's.
372
- *
373
- * Off by default, and off under a publishable key, the credential a run is started with: a
374
- * run under a key calls no server tool, and the API refuses a start or an update that names
375
- * any. The engine then sends no `server_tools` at all, and routes the client tools alone.
376
- * Turn it on only for a credential the API lets a run's model reach the server tools under:
377
- * on under a publishable key, the transport `createAgentTransport` builds refuses the start
378
- * before it is sent, with a `MountayaConfigurationError` naming this option, which the start
379
- * rejects with.
380
- *
381
- * @default false
382
- */
383
- routesServerTools?: boolean | undefined;
384
- toolSurface?: (() => ReadonlySet<string> | undefined) | undefined;
385
- /**
386
- * The run's reader and writer: usually `createAgentTransport` from `@mountaya/client/events`,
387
- * which gives up an open that never answers and a stream gone silent as connection errors. A
388
- * transport of your own bounds both waits the same way, since the engine waits as long as
389
- * `subscribe` says nothing, and reports `onClose("terminal")` only after it has handed over a
390
- * `done`.
391
- */
392
- transport: AgentTransport;
310
+ bus: ToolDispatcher<TContext>;
311
+ confirmServerTool: (confirmation: ServerToolConfirmation) => Promise<boolean>;
312
+ ctx: TContext;
313
+ observer: AgentObserver;
314
+ /**
315
+ * How the host reports what its own state did while a tool ran, and what to try after a
316
+ * failure. Both are OPTIONAL and both are the host's policy rather than the loop's:
317
+ * `@mountaya/studio` passes its store fingerprint and its routing tables, a host wiring their
318
+ * own tools passes neither and a run reports the tool result bare.
319
+ */
320
+ recoveryFor?: RecoveryLookup | undefined;
321
+ stateDelta?: StateDelta<TContext> | undefined;
322
+ /**
323
+ * Prompt profile the run opens with. Omitted means the full studio co-pilot.
324
+ * It belongs on the session rather than on start() because it is a property of
325
+ * the SURFACE, not of a message: a Video Director session is a director for its
326
+ * whole life.
327
+ */
328
+ profile?: AgentRunProfile | undefined;
329
+ /**
330
+ * Whether a run names the server tools the model sees, from the selection `toolSurface`
331
+ * answers: the routed set rides a start's `server_tools` and every routing update's.
332
+ *
333
+ * Off by default, and off under a publishable key, the credential a run is started with: a
334
+ * run under a key calls no server tool, and the API refuses a start or an update that names
335
+ * any. The engine then sends no `server_tools` at all, and routes the client tools alone.
336
+ * Turn it on only for a credential the API lets a run's model reach the server tools under:
337
+ * on under a publishable key, the transport `createAgentTransport` builds refuses the start
338
+ * before it is sent, with a `MountayaConfigurationError` naming this option, which the start
339
+ * rejects with.
340
+ *
341
+ * @default false
342
+ */
343
+ routesServerTools?: boolean | undefined;
344
+ toolSurface?: (() => ReadonlySet<string> | undefined) | undefined;
345
+ /**
346
+ * The run's reader and writer: usually `createAgentTransport` from `@mountaya/client/events`,
347
+ * which gives up an open that never answers and a stream gone silent as connection errors. A
348
+ * transport of your own bounds both waits the same way, since the engine waits as long as
349
+ * `subscribe` says nothing, and reports `onClose("terminal")` only after it has handed over a
350
+ * `done`.
351
+ */
352
+ transport: AgentTransport;
393
353
  }
394
354
  /**
395
355
  * AgentEngine is a long-lived, multi-turn agent run over a single persistent
@@ -449,585 +409,584 @@ interface AgentEngineConfig<TContext extends AgentToolContext = AgentToolContext
449
409
  * void engine.close().finally(() => engine.dispose());
450
410
  * ```
451
411
  */
452
- declare class AgentEngine {
453
- private readonly config;
454
- private currentRunId;
455
- private unfinishedRunId;
456
- private state;
457
- /**
458
- * The state the observer was told last. It is {@link state} but from the moment a start
459
- * readies its run until that start reports: the engine rests for those statements, and the
460
- * observer is told the state the start leaves it in, never the rest between two turns.
461
- */
462
- private reported;
463
- private sendHold;
464
- private sendReporting;
465
- private lastEventId;
466
- private streamAbort;
467
- private unsubscribe;
468
- private readGeneration;
469
- private routedNames;
470
- private routingUpdates;
471
- private routedUpdate;
472
- private disposed;
473
- private pendingStart;
474
- private readonly handledCalls;
475
- private handledRunId;
476
- private readonly dispatchedCalls;
477
- private readonly runningCalls;
478
- constructor(config: AgentEngineConfig);
479
- /**
480
- * start opens a fresh run with the user's first message, then consumes the
481
- * run's single event stream to completion. The returned promise settles only
482
- * when the engine stops reading the run, so the caller fire-and-forgets it and
483
- * reacts to turns through the observer instead. It resolves on the terminal
484
- * `done`, on {@link close} or {@link dispose}, when a later start or
485
- * {@link resume} replaces the run, and when its reconnects stop being productive.
486
- *
487
- * It rejects when the start or the stream fails for good: a start whose post is
488
- * refused, at once for most answers and, for a 429, a 502, a 503, a 504 or a dropped
489
- * connection, once the transport has repeated it under the start's idempotency key
490
- * as far as its retry policy goes, a stream open answered with anything but a 429,
491
- * 503 or 504, a fault in one of the host's own seams, and a stream that is still
492
- * failing when the reconnect ceiling is reached, whether its connection stays down
493
- * or every open is answered 429 or 504; that one rejects with the last
494
- * failure. A stream that fails leaves the state `ended`, reported through
495
- * `onStateChange("ended")`, before the promise rejects; a start that fails leaves
496
- * it `awaiting_input`.
497
- *
498
- * A stream open answered 503 is not counted against the reconnect ceiling. It says the
499
- * run's events cannot be reached for a moment while the run goes on, so the engine opens
500
- * the stream again, after the wait the answer names, for as long as two minutes of such
501
- * answers with no turn read in between, and then rejects with the last of them.
502
- *
503
- * The state is `running` from the call, reported through `onStateChange("running")` before
504
- * the run has an id, so a host shows the turn as under way from the message. A start that
505
- * fails reports `awaiting_input` again before its promise rejects. The report is the last
506
- * step ahead of the post: a start that fails before it, on a fault in the tool surface,
507
- * never reports `running`.
508
- *
509
- * A start that replaces a run reports that one change and no rest ahead of it: `running`
510
- * from an engine at rest or whose last run ended, and nothing from an engine whose run is
511
- * under way, which reads `running` through the replacement. Where such a start fails, the
512
- * one report is `awaiting_input`.
513
- *
514
- * One engine reads one run. A start while the engine still reads a run tears that
515
- * run's stream down and posts a close for it before it opens its own, so none of
516
- * that run's frames, its resume cursor or its `done` reach the run that replaces
517
- * it. A start while another start still waits on its run id withdraws that start,
518
- * as {@link close} does. A start on an engine whose last run ended opens the next
519
- * run and reads it from its beginning, and posts a close for that last run first when
520
- * the engine stopped reading it short of its `done` (see {@link close}). A start after
521
- * {@link dispose} opens nothing and resolves at once.
522
- *
523
- * Every start carries an `Idempotency-Key` of its own, drawn once per call where the runtime
524
- * has a cryptographic random source, and is posted once: the transport repeats a start whose
525
- * answer was lost under that same key, and the API answers the repeat with the run the key
526
- * already started, so a lost answer never opens a second run. A start the transport gives up
527
- * on rejects with the transport's failure, which carries the key. A custom
528
- * {@link AgentTransport} receives the key as the `idempotencyKey` of the options its `startRun`
529
- * is handed, and none where the runtime offers no source to draw it from.
530
- *
531
- * A {@link close}, a {@link dispose} or a later start or {@link resume} while the start
532
- * still waits on its run id withdraws it: no stream is opened, no run id and no frame of
533
- * the run reaches the observer, and the returned promise resolves even when the start
534
- * itself fails. The run it opens is closed as soon as its id arrives. A withdrawal made from
535
- * inside a state report of the start itself, or from inside the tool surface it reads (the
536
- * bus's `manifest`), comes ahead of the post: nothing is posted, no run is opened and no
537
- * `running` follows the `ended` the withdrawal reported.
538
- *
539
- * @param message The user's first message, which opens the run's first turn.
540
- * @param organizationId The organization that owns the resource the co-pilot is opened on
541
- * (the itinerary or zone being edited). The run is scoped and access-gated to it, and the
542
- * API resolves the AI provider credential through it. It is captured per start because it
543
- * reflects the resource open at the moment the run opens, and the API requires it.
544
- * @param context The caller's point-in-time studio snapshot, forwarded verbatim to the
545
- * gateway's create body so the run starts knowing the current UI state. It is captured per
546
- * start (not held on the session config) because it is a snapshot of the moment the run
547
- * opens. It stays an opaque `Record<string, unknown>` here because its typed shape is the
548
- * host's, which this package does not import: the host builds it and passes it through.
549
- */
550
- start(message: string, organizationId: string, context?: Record<string, unknown>): Promise<void>;
551
- /**
552
- * resume re-attaches to an already-started run (e.g. after a page reload) and consumes the
553
- * run's single event stream to completion. It lets a reload reconnect to an
554
- * in-flight conversation rather than starting over. Its promise settles as the
555
- * read of a {@link start} does: it resolves when the engine stops reading the run,
556
- * and rejects when the stream fails for good, the state already `ended`.
557
- *
558
- * `lastEventId` is the stream position to read on from: the gateway replays what follows
559
- * it, then the live feed. Without one the read starts where the engine left the run when
560
- * `runId` is the run it holds (the one it read last, still open or not), so a host that
561
- * kept its transcript re-attaches and is handed nothing a second time. That place is after
562
- * the last frame that reached the engine, the one an observer callback is being handed
563
- * included: a resume made from inside the callback reads on after that frame. A frame whose
564
- * handling threw (a seam that answers: the tool layer, the confirm gate, the tool surface or
565
- * the state delta) is the exception. It is read again, and
566
- * a call the run already claimed is dropped. For any other run the engine holds no position,
567
- * and the gateway answers with the run's whole history: that is the read an engine built
568
- * after a reload makes, and its host starts from an empty transcript. To read the held run
569
- * from its first event again, resume it on a new engine.
570
- *
571
- * Like {@link start}, it reads the run on an engine whose last run ended, opens
572
- * nothing after {@link dispose}, and replaces what the engine reads when it is
573
- * called: another run is torn down and closed, and a start still waiting on its run
574
- * id is withdrawn. A resume of the run the engine is reading tears that read down
575
- * and reads the run again from `lastEventId`, or from where that read was when none is
576
- * passed, and posts no close for it.
577
- *
578
- * The engine is at rest as the read begins, reported through `onStateChange("awaiting_input")`
579
- * from an engine that was `running` or `ended`, and the stream says the rest. A call made
580
- * from inside that report is read before the run is adopted, as one made from a report of a
581
- * {@link start} is: a {@link dispose} ends the resume with no stream opened and no run to
582
- * close, and a start or another resume is the one read the engine makes, so this resume
583
- * resolves at once. A {@link close} made there finds no run held and posts nothing, and the
584
- * resume reads its run.
585
- */
586
- resume(runId: string, lastEventId?: string): Promise<void>;
587
- /**
588
- * streamPosition reads where the engine stands in the run it read last, for a host that
589
- * replaces the engine and has the next one read the run on.
590
- *
591
- * It is the position a {@link resume} of that run on this engine reads on from: after the last
592
- * frame that reached the engine, or the position a resume was handed while no frame has
593
- * followed it. It is kept through {@link dispose}, which is when a host reads it.
594
- *
595
- * @returns The run and the position, or `null` while the engine has read no run or the run's
596
- * stream has named no position, which is the whole of a run whose frames carry no id.
597
- *
598
- * @example
599
- * ```ts
600
- * import type { AgentEngine } from "@mountaya/elements/agent";
601
- *
602
- * declare const parked: AgentEngine;
603
- * declare const next: AgentEngine;
604
- *
605
- * const position = parked.streamPosition();
606
- * parked.dispose();
607
- * if (position !== null) {
608
- * next.resume(position.runId, position.lastEventId).catch((error: unknown) => {
609
- * console.error(error);
610
- * });
611
- * }
612
- * ```
613
- */
614
- streamPosition(): AgentStreamPosition | null;
615
- /**
616
- * runId reads the id of the run the engine holds: the one a {@link start} opened, from the
617
- * moment its post answers, or the one a {@link resume} reads, from the moment it begins. It is
618
- * kept once the engine stops reading that run, whether the run ended, its stream failed, or the
619
- * engine was disposed.
620
- *
621
- * It is what tells the two failures a start rejects with apart. A start whose post the gateway
622
- * refused opened no run, and this reads null; a start whose run opened and whose stream was
623
- * then refused reads that run. The same status says different things on each: a 404 on the post
624
- * is an organization the reader does not reach, and a 404 on the stream is a run the gateway no
625
- * longer holds.
626
- *
627
- * @returns The run's id, or null while the engine holds none: before its first run, and from
628
- * the moment a start replaces a run until the post of that start answers, which a start that
629
- * fails never does.
630
- *
631
- * @example
632
- * ```ts
633
- * import type { AgentEngine } from "@mountaya/elements/agent";
634
- *
635
- * declare const engine: AgentEngine;
636
- * declare const report: (failure: unknown, openedRun: string | null) => void;
637
- *
638
- * engine.start("Plan a loop", "organization-id").catch((failure: unknown) => {
639
- * report(failure, engine.runId());
640
- * });
641
- * ```
642
- */
643
- runId(): string | null;
644
- /**
645
- * send delivers a follow-up user message into the open run. It only posts the
646
- * input (the persistent consumer opened by start/resume carries this turn's
647
- * events), so it does NOT open a second stream.
648
- *
649
- * A message sent while a {@link start} still waits on its run id is held until the id
650
- * arrives, then posted into that run, behind the opening of its stream and in the order the
651
- * messages were sent. A start settles only when its run is over, so a caller has no promise
652
- * to wait on before the next message. When that start opens no run (it fails, or a
653
- * {@link close}, a {@link dispose} or a later start or {@link resume} withdraws it), the
654
- * held message is dropped and the promise resolves: the start's rejection, or the call that
655
- * withdrew it, already says the conversation did not open, and a second report of one
656
- * failure is one too many.
657
- *
658
- * The state is `running` from the call the engine takes, reported through
659
- * `onStateChange("running")` when the run was at rest, so the turn's settle is a change the
660
- * observer hears even when the turn sends no frame of its own. A message the engine refuses
661
- * changes nothing. When the post fails, the engine reports `awaiting_input` again before the
662
- * promise rejects, unless another message is still being posted, one of them landed, or the
663
- * stream has reported a state since: the turn is then the stream's to settle.
664
- *
665
- * The report is made ahead of the post, and the message goes into the run it found at the
666
- * call. A {@link close}, a {@link dispose}, a {@link start} or a {@link resume} of another run
667
- * made from inside that report takes the run from the message: nothing is posted and the
668
- * promise resolves, as it does for a message held behind a start that opens no run. A
669
- * {@link resume} of the same run keeps the message, and its turn is the stream's to settle.
670
- * A send made from inside that report is posted after the message that reported, so two
671
- * messages reach the run in the order they were sent.
672
- *
673
- * @throws {MountayaElementsError} when no run is being read and none is on its way: on an
674
- * engine that never opened one, and once the run has ended, been closed or been disposed.
675
- * A run that ended takes no more messages, and one the engine has stopped reading would
676
- * answer to nobody, so the refusal is local rather than a request the gateway refuses. It
677
- * is the package's own error and no stream fault, because it is a misuse of this package,
678
- * which is what a consumer catching {@link MountayaElementsError} is catching. The next
679
- * message goes into a run a new {@link start} opens, except on a disposed engine, which
680
- * opens no more runs: the conversation continues on a new engine.
681
- */
682
- send(message: string): Promise<void>;
683
- /**
684
- * reads reports whether `runId` is still the run this engine reads: the engine is neither
685
- * disposed nor ended, and no start or resume has put another run in its place.
686
- */
687
- private reads;
688
- /**
689
- * routedManifest renders the wire manifest for whatever the toolSurface seam
690
- * currently selects, or the whole permitted set when no router is wired.
691
- */
692
- private routedManifest;
693
- /**
694
- * routedServerTools renders the server-tool allowlist for whatever the
695
- * toolSurface seam currently selects: the routed name set verbatim, sorted so
696
- * the wire body and the change key are stable across identical selections.
697
- * The gateway ignores the client-tool names in it, so no registry knowledge
698
- * is needed here. Undefined when no router is wired: the run then keeps
699
- * every server tool. Undefined as well unless the session routes server tools
700
- * ({@link AgentEngineConfig.routesServerTools}): under a publishable key a run
701
- * calls none, and a list naming any is refused, so none is sent.
702
- */
703
- private routedServerTools;
704
- /**
705
- * routeTools re-reads the toolSurface seam and, when it has moved, replaces the
706
- * tool set the run offers the model from its next turn on. The model then
707
- * chooses among a coherent handful for the task at hand instead of the whole
708
- * registry.
709
- *
710
- * It narrows only what the model can SEE. Every tool stays registered on the
711
- * bus and dispatchable by a human click or an internal tool chain, and the
712
- * capability gate remains the sole authorization boundary, exactly as
713
- * `agentHidden` behaves.
714
- *
715
- * An unchanged selection sends nothing. That is not just a saved request: the
716
- * tool array is the outermost part of the provider's cached prompt prefix, so a
717
- * manifest re-sent on every turn would invalidate the cache every turn and cost
718
- * far more than routing saves. "Unchanged" means changed since the run last
719
- * ACCEPTED a set, so a selection whose POST failed is retried on the next call
720
- * rather than treated as delivered.
721
- *
722
- * It is a no-op before a run exists, rather than a throw: routing is advisory,
723
- * and a surface change while the panel is idle should cost nothing, since the
724
- * next start() sends the current selection as the run's seed anyway.
725
- *
726
- * While a {@link start} still waits on its run id, the seed is already on its way, so the
727
- * call waits for the run as {@link send} does and then routes it with the selection the
728
- * surface holds by then. A routing update and a message held behind one start are released
729
- * in the order they were called, neither waiting on the other's answer, so a caller that
730
- * needs the selection in the run ahead of its message awaits routeTools() before it calls
731
- * {@link send}. When that start opens no run, nothing is sent.
732
- */
733
- routeTools(): Promise<void>;
734
- /**
735
- * close asks the run to finish. It POSTs a close so the gateway finishes the
736
- * run successfully (a terminal `done` event), AND aborts the open stream so a
737
- * consumer parked between turns unwinds promptly rather than waiting on the
738
- * gateway to close the connection. The terminal `done`, when it arrives first,
739
- * ends the session.
740
- *
741
- * It closes a run the engine stopped reading on its own just the same: one it gave
742
- * up on at the reconnect ceiling, after two minutes of opens answered 503 or on an
743
- * open refused for good, which the gateway would otherwise hold open until its own
744
- * timeout. A run is closed at most once, and a run that read its `done` is closed
745
- * never: a second call, and a call after `done`, post nothing. So does a call after
746
- * {@link dispose}, which leaves the run it was reading to the host.
747
- *
748
- * During a start that still waits on its run id, close withdraws the start and
749
- * resolves at once, and the start finishes the run it opens (see {@link start}).
750
- */
751
- close(): Promise<void>;
752
- /**
753
- * dispose tears the session down without signalling the gateway: it aborts the
754
- * open stream and marks the run ended, releasing the parked consumer. The host
755
- * calls it on unmount AFTER close() has POSTed (a closed tab finishes the run),
756
- * with the abort as the backstop when the consumer would otherwise leak.
757
- *
758
- * It is the engine's shutdown latch: {@link start} and {@link resume} open nothing
759
- * afterwards. What it can still cause is what a start sends to finish the run whose id the
760
- * host never received, when it was withdrawn or gave up at its ceiling: that run's close,
761
- * and, when the start's answer was lost, the one last post of the start that names the run
762
- * (see {@link start}).
763
- *
764
- * The run the engine was reading, or stopped reading on its own, is the host's from here:
765
- * the host holds its id, so it can resume it or close it, and a later {@link close} on
766
- * this engine posts nothing for it.
767
- */
768
- dispose(): void;
769
- /**
770
- * leaveRun stops the engine reading what it reads, before a {@link start} or a
771
- * {@link resume} reads a run: one engine reads one run. A start still waiting on its run
772
- * id is withdrawn. A run still being read has its stream torn down, so none of its frames,
773
- * its resume cursor or its `done` reach the run read next. A close is posted for the run the
774
- * engine still owes one (see `unfinishedRunId`): the run it was reading, and the run it
775
- * stopped reading on its own, because in both cases the engine was the one party reading
776
- * it. `next` names the run about to be read, and that run is spared the close when it is
777
- * the one owed it: a resume of it reads it again.
778
- */
779
- private leaveRun;
780
- /**
781
- * withdrawStart withdraws the start still waiting on its run id, if one is: that start then
782
- * finishes the run it opens instead of reading it (see {@link start}), and every message
783
- * and routing update held behind it is dropped (see {@link send}).
784
- */
785
- private withdrawStart;
786
- /**
787
- * beginRun readies the engine to read a new run once {@link leaveRun} has stopped it
788
- * reading the last one. The run id, the resume cursor and the stream handle belong to that
789
- * run, so all three go, and the state returns to `awaiting_input`: `ended` would stop the
790
- * read loop before it opened anything.
791
- *
792
- * The rest is the engine's own and is reported to nobody here. A {@link resume} reports it,
793
- * since its run may rest for good. A {@link start} reports `running` next, or the rest once
794
- * it fails, so a start that replaces a run under way is one turn after another to the
795
- * observer and no rest between them ({@link reportState}).
796
- *
797
- * @returns The generation of the read being readied, which a later start or resume replaces.
798
- */
799
- private beginRun;
800
- /**
801
- * adoptRun makes `runId` the run this engine reads, and the run it owes a close until the
802
- * run's `done` arrives or a close is posted. The memory of handled calls, and of the calls
803
- * the engine reported among them, belongs to one run, because call ids are the run's own: it
804
- * is kept when the run is the one already read (a resume of it) and emptied for any other.
805
- */
806
- private adoptRun;
807
- /**
808
- * claimCall records a call id as handled and reports whether the frame that names it is
809
- * the engine's to act on. Two frames are not, and each is dropped whole:
810
- *
811
- * - one whose id the run already sighted, a replay of a call the engine ran or answered
812
- * itself, whose result is already posted;
813
- * - one the stream marks `settled`, a replay of a call whose outcome the stream already
814
- * holds. An engine built after a page reload has no memory of the run, so the marker is
815
- * all that tells it the call was answered.
816
- *
817
- * A settled id is recorded like any other, so a later frame that names it without the
818
- * marker runs nothing either. A replayed frame with no marker and an id never sighted is
819
- * one the stream holds no outcome for, and is the engine's.
820
- */
821
- private claimCall;
822
- /**
823
- * closeQuietly posts a close for a live run the engine leaves behind: one a withdrawn start
824
- * opened and never read, whose id the host never received, and one a later start or resume
825
- * replaced. A failed post is dropped: nobody is
826
- * left to tell, and the gateway completes a run that goes quiet on its own.
827
- */
828
- private closeQuietly;
829
- /**
830
- * releaseSubscription stops callback delivery from the open stream, exactly
831
- * once. It reads the handle out and clears it BEFORE invoking it, so a
832
- * re-entrant settle (the abort listener firing synchronously inside
833
- * teardownStream, or a transport calling back into onClose) finds nothing
834
- * left to release rather than calling the same handle twice.
835
- */
836
- private releaseSubscription;
837
- /**
838
- * teardownStream releases the open events stream from both sides: the
839
- * unsubscribe stops callback delivery (covering the scripted drain, which has
840
- * no fetch to abort), and the abort closes the live fetch (and trips the resume
841
- * detection in run()). Idempotent, so close() followed by dispose() is harmless.
842
- *
843
- * The unsubscribe runs FIRST because abort() dispatches its listener
844
- * synchronously: that listener settles the read and clears the handle, so
845
- * aborting first would leave nothing to unsubscribe and the scripted drain
846
- * would stay parked for the life of the process.
847
- */
848
- private teardownStream;
849
- /**
850
- * run consumes the run's event stream to completion, reconnecting when the
851
- * stream closes before a terminal event. The gateway may close an SSE
852
- * connection between turns (e.g. after `awaiting-input`); rather than leave the
853
- * run silently stuck, run re-opens the stream from the tracked Last-Event-ID so
854
- * the conversation continues. It returns once a terminal event ends the run, an
855
- * abort tears the stream down, or the reconnects stop being productive: an open that
856
- * closes having said nothing or one frame waits on the reconnect schedule, and the
857
- * attempt ceiling below bounds how many of them in a row the run is given.
858
- *
859
- * A read that FAILS is judged by {@link isTransientStreamFault}. A transient one (a
860
- * dropped connection, a 429, 503 or 504 at open) reopens from the last id on the same
861
- * schedule and under the same ceiling as a hangup, and when the ceiling is reached on a
862
- * read that failed, that failure (the drop, or the 429 or 504) is what the caller
863
- * receives. The client's own reader reports an open that never answers and a stream gone
864
- * silent as dropped connections, so both reopen. Any other failure ends the read at once and
865
- * rejects with it. Either way the state is `ended` before the rejection, because the engine
866
- * has stopped reading the run, and the run is owed a close (see {@link close}).
867
- *
868
- * An open answered 503 reopens on that schedule and outside that ceiling: it is left out of
869
- * the count, neither adding to it nor clearing it, and such opens are bounded by
870
- * {@link RECONNECT_UNAVAILABLE_MAX_MS} from the first of them, past which the caller receives
871
- * the 503. A turn that moves starts the count and that time again.
872
- *
873
- * A stream that ends with the credential it was opened with, or that the API could not keep
874
- * delivering (`interrupted`), reopens at once from the last id, and clears the count of
875
- * fruitless opens: the transport closes either as `reconnect`, and the reopen carries the
876
- * session token the client holds by then. A 401 on that reopen is a failure like any other
877
- * refusal, and ends the read.
878
- *
879
- * A teardown ends the read wherever it finds it, the backoff between two opens included:
880
- * a close or a dispose, and a start or a resume that replaced this run (see
881
- * {@link leaveRun}).
882
- */
883
- private run;
884
- /**
885
- * backoff waits out one reconnect delay, drawn by {@link reconnectDelayMs} on the run's
886
- * {@link reconnectSchedule}: below a ceiling that doubles from AGENT_RECONNECT_BASE_MS to
887
- * RECONNECT_MAX_MS, so the wait stays inside a person's patience and runs dropped together
888
- * do not reopen together. Where the failure was a 429 or a 503 that named its wait (`namedMs`),
889
- * that wait replaces the draw, with up to a second drawn above it and the timer's ceiling over
890
- * it ({@link retryAfterDelayMs}), as SPEC §2 has `Retry-After` replace the schedule. It settles
891
- * on whichever comes first, the timer or the stream teardown's abort, and drops both hooks
892
- * either way: a run that reconnects many times must not accumulate listeners on the signal, nor
893
- * leave a timer holding the loop after the session is gone.
894
- */
895
- private backoff;
896
- /**
897
- * consume opens one read of the run's events stream and settles when it
898
- * finishes, bridging the transport's AgentStreamHandlers callbacks to a single
899
- * promise run() can await. It reacts to each decoded frame and records its id as
900
- * the resume position when the frame arrives, taking it back when the frame's handling
901
- * throws; the transport has already validated every frame, so it trusts the typed
902
- * event. Unlike a per-turn drive it does NOT stop on
903
- * `awaiting-input` (the stream stays open for the next message). It resolves
904
- * with whether a terminal event ended the run and how many frames the stream
905
- * delivered, so the caller can decide between reconnecting and settling and
906
- * tell a productive open from a fruitless one, and with the failure when the
907
- * read failed. It never rejects, a transport that throws from the open included:
908
- * whether a failure ends the run is run()'s call.
909
- * A terminal the SESSION decides (handle returning true on `done`) tears the
910
- * subscription down here so no further frame is processed after the run is
911
- * over. A teardown's abort (a close, a dispose, or a start or resume that replaced
912
- * the run) settles the promise on its own (the transport fires no callback on a
913
- * deliberate abort), so run() unwinds without waiting on a dead stream.
914
- *
915
- * It is one closure on purpose. Every handler reads and writes this read's own settle
916
- * latch and frame count, and held as fields they would be the next read's to reach.
917
- */
918
- private consume;
919
- /**
920
- * handle reacts to one event of the run `runId` names and reports whether the run
921
- * ended (so consume can stop). An active-turn event (streamed text, a tool call, a
922
- * confirm request) flips the lifecycle to `running`; a client tool-call is dispatched
923
- * through the bus and its result posted back; a confirm-required is routed through
924
- * the host gate and the decision posted back. Both answers go to `runId`, the run that
925
- * asked, even when a later start or resume replaced it while the tool ran or the host
926
- * decided. A tool-call or a confirm-required that {@link claimCall} refuses, one the
927
- * stream marks `settled` or one the run already handled, is dropped whole: it reaches
928
- * neither the bus, the gate nor the observer, and leaves the lifecycle as it is. An
929
- * `awaiting-input` event settles the turn to the `awaiting_input` state but
930
- * keeps the stream open (returns false); only a terminal `done` ends the run (returns
931
- * true).
932
- */
933
- private handle;
934
- /**
935
- * handleToolCall runs one client tool call through the bus, reports it to the observer and
936
- * posts its result back into the run that asked. It answers false: a tool call never ends
937
- * the run.
938
- *
939
- * The call is running from its claim to its report. What the stream says of it meanwhile is
940
- * held ({@link holdWhileRunning}), and released when the handling throws before the report:
941
- * the engine has no report of its own then, and the stream's word settles the host's row.
942
- */
943
- private handleToolCall;
944
- /**
945
- * releaseHeldWord takes a call out of the running set and delivers what the stream said of it
946
- * while it ran, when it said anything. A call the engine reported is out of the set already,
947
- * and so is every call of a run the engine no longer holds the memory of: both release
948
- * nothing.
949
- */
950
- private releaseHeldWord;
951
- /**
952
- * holdWhileRunning keeps what the stream says of a call the engine is still running, as the
953
- * report it would have made, and answers whether it did. The first word is the one kept: a
954
- * failed `tool-result` follows the `tool-abandoned` of a call the run gave up on.
955
- */
956
- private holdWhileRunning;
957
- /** runToolCall is the handling of a claimed client tool call: see {@link handleToolCall}. */
958
- private runToolCall;
959
- /**
960
- * handleConfirmRequired puts a server tool's confirmation to the host gate and posts the
961
- * decision back into the run that asked. It answers false: a confirmation never ends the
962
- * run.
963
- */
964
- private handleConfirmRequired;
965
- /**
966
- * handleDone reports how the run ended and ends the read, unless a start or a resume made
967
- * from the callback has already replaced it. It answers true: `done` is the one terminal.
968
- */
969
- private handleDone;
970
- /**
971
- * handleToolResult reports a call's outcome as the stream states it, unless the call is one
972
- * the engine ran and reported itself. It answers false.
973
- */
974
- private handleToolResult;
975
- /**
976
- * handleToolAbandoned reports a call the run gave up on, unless the call is one the engine
977
- * ran and reported itself. It answers false.
978
- */
979
- private handleToolAbandoned;
980
- /**
981
- * setState records the lifecycle transition and notifies the observer only on
982
- * an actual change, so the host does not re-render on a no-op.
983
- *
984
- * Every report, a no-op included, drops the hold the sends being posted have on `running`:
985
- * whatever speaks here (a frame, a close, a new run) owns the state from then on. A send
986
- * reports its own `running` through {@link reportState}, which keeps the hold.
987
- */
988
- private setState;
989
- /**
990
- * reportState is {@link setState} without the drop of the hold, for the one report that is
991
- * the hold's own: the `running` of a send.
992
- *
993
- * The observer is told a state that differs from the one it was told last, which is the
994
- * engine's own state but while a start readies its run ({@link beginRun}).
995
- */
996
- private reportState;
997
- /**
998
- * tell hands the observer one report. The observer answers nothing the run waits on, so a
999
- * callback that throws is a defect of the host's own rendering and never the run's: its fault
1000
- * reaches the program through {@link surfaceFault}, and the read goes on.
1001
- */
1002
- private tell;
1003
- /**
1004
- * postInput sends one input frame back into the run `runId` names, the run that asked
1005
- * for it, and reports a failure as a fault in the conversation instead of throwing.
1006
- *
1007
- * The catch is the point. `start()` ends with `await this.run(runId)`, so the whole
1008
- * consume loop lives inside the start promise, and an unguarded rejection here would
1009
- * leave `handle()` as a fault of the engine's own: the read would end for good, and
1010
- * `start()` would reject into the host's START error path. A network blip on turn
1011
- * twelve would then render "could not start", clear the started guard and drop the run
1012
- * id, so the still-alive gateway run could never be resumed and the model's call would
1013
- * expire as `tool-abandoned` with the user told nothing true about why.
1014
- *
1015
- * Reporting and continuing is the right shape: the run is still open, the stream is
1016
- * still readable, and the gateway abandons the unanswered call on its own timeout so
1017
- * the model can replan. What is lost is one tool result, which is a turn-level fault,
1018
- * not a session-level one. A run a later start or resume replaced has nobody reading
1019
- * it, so a failure to answer it is dropped rather than reported into the run that
1020
- * replaced it. So is a failure to answer a run the engine has stopped reading, after a
1021
- * {@link close} or a {@link dispose}: the host ended that conversation, and an error line
1022
- * under it would report a fault in a run nobody is in.
1023
- *
1024
- * The message is deliberately empty. A fetch rejection carries an English,
1025
- * internal string, and the host resolves an empty message to its own localized
1026
- * generic line, the same rule the run's other self-raised terminals follow.
1027
- */
1028
- private postInput;
412
+ export declare class AgentEngine {
413
+ private readonly config;
414
+ private currentRunId;
415
+ private unfinishedRunId;
416
+ private state;
417
+ /**
418
+ * The state the observer was told last. It is {@link state} but from the moment a start
419
+ * readies its run until that start reports: the engine rests for those statements, and the
420
+ * observer is told the state the start leaves it in, never the rest between two turns.
421
+ */
422
+ private reported;
423
+ private sendHold;
424
+ private sendReporting;
425
+ private lastEventId;
426
+ private streamAbort;
427
+ private unsubscribe;
428
+ private readGeneration;
429
+ private routedNames;
430
+ private routingUpdates;
431
+ private routedUpdate;
432
+ private disposed;
433
+ private pendingStart;
434
+ private readonly handledCalls;
435
+ private handledRunId;
436
+ private readonly dispatchedCalls;
437
+ private readonly runningCalls;
438
+ constructor(config: AgentEngineConfig);
439
+ /**
440
+ * start opens a fresh run with the user's first message, then consumes the
441
+ * run's single event stream to completion. The returned promise settles only
442
+ * when the engine stops reading the run, so the caller fire-and-forgets it and
443
+ * reacts to turns through the observer instead. It resolves on the terminal
444
+ * `done`, on {@link close} or {@link dispose}, when a later start or
445
+ * {@link resume} replaces the run, and when its reconnects stop being productive.
446
+ *
447
+ * It rejects when the start or the stream fails for good: a start whose post is
448
+ * refused, at once for most answers and, for a 429, a 502, a 503, a 504 or a dropped
449
+ * connection, once the transport has repeated it under the start's idempotency key
450
+ * as far as its retry policy goes, a stream open answered with anything but a 429,
451
+ * 503 or 504, a fault in one of the host's own seams, and a stream that is still
452
+ * failing when the reconnect ceiling is reached, whether its connection stays down
453
+ * or every open is answered 429 or 504; that one rejects with the last
454
+ * failure. A stream that fails leaves the state `ended`, reported through
455
+ * `onStateChange("ended")`, before the promise rejects; a start that fails leaves
456
+ * it `awaiting_input`.
457
+ *
458
+ * A stream open answered 503 is not counted against the reconnect ceiling. It says the
459
+ * run's events cannot be reached for a moment while the run goes on, so the engine opens
460
+ * the stream again, after the wait the answer names, for as long as two minutes of such
461
+ * answers with no turn read in between, and then rejects with the last of them.
462
+ *
463
+ * The state is `running` from the call, reported through `onStateChange("running")` before
464
+ * the run has an id, so a host shows the turn as under way from the message. A start that
465
+ * fails reports `awaiting_input` again before its promise rejects. The report is the last
466
+ * step ahead of the post: a start that fails before it, on a fault in the tool surface,
467
+ * never reports `running`.
468
+ *
469
+ * A start that replaces a run reports that one change and no rest ahead of it: `running`
470
+ * from an engine at rest or whose last run ended, and nothing from an engine whose run is
471
+ * under way, which reads `running` through the replacement. Where such a start fails, the
472
+ * one report is `awaiting_input`.
473
+ *
474
+ * One engine reads one run. A start while the engine still reads a run tears that
475
+ * run's stream down and posts a close for it before it opens its own, so none of
476
+ * that run's frames, its resume cursor or its `done` reach the run that replaces
477
+ * it. A start while another start still waits on its run id withdraws that start,
478
+ * as {@link close} does. A start on an engine whose last run ended opens the next
479
+ * run and reads it from its beginning, and posts a close for that last run first when
480
+ * the engine stopped reading it short of its `done` (see {@link close}). A start after
481
+ * {@link dispose} opens nothing and resolves at once.
482
+ *
483
+ * Every start carries an `Idempotency-Key` of its own, drawn once per call where the runtime
484
+ * has a cryptographic random source, and is posted once: the transport repeats a start whose
485
+ * answer was lost under that same key, and the API answers the repeat with the run the key
486
+ * already started, so a lost answer never opens a second run. A start the transport gives up
487
+ * on rejects with the transport's failure, which carries the key. A custom
488
+ * {@link AgentTransport} receives the key as the `idempotencyKey` of the options its `startRun`
489
+ * is handed, and none where the runtime offers no source to draw it from.
490
+ *
491
+ * A {@link close}, a {@link dispose} or a later start or {@link resume} while the start
492
+ * still waits on its run id withdraws it: no stream is opened, no run id and no frame of
493
+ * the run reaches the observer, and the returned promise resolves even when the start
494
+ * itself fails. The run it opens is closed as soon as its id arrives. A withdrawal made from
495
+ * inside a state report of the start itself, or from inside the tool surface it reads (the
496
+ * bus's `manifest`), comes ahead of the post: nothing is posted, no run is opened and no
497
+ * `running` follows the `ended` the withdrawal reported.
498
+ *
499
+ * @param message The user's first message, which opens the run's first turn.
500
+ * @param organizationId The organization that owns the resource the co-pilot is opened on
501
+ * (the itinerary or zone being edited). The run is scoped and access-gated to it, and the
502
+ * API resolves the AI provider credential through it. It is captured per start because it
503
+ * reflects the resource open at the moment the run opens, and the API requires it.
504
+ * @param context The caller's point-in-time studio snapshot, forwarded verbatim to the
505
+ * gateway's create body so the run starts knowing the current UI state. It is captured per
506
+ * start (not held on the session config) because it is a snapshot of the moment the run
507
+ * opens. It stays an opaque `Record<string, unknown>` here because its typed shape is the
508
+ * host's, which this package does not import: the host builds it and passes it through.
509
+ */
510
+ start(message: string, organizationId: string, context?: Record<string, unknown>): Promise<void>;
511
+ /**
512
+ * resume re-attaches to an already-started run (e.g. after a page reload) and consumes the
513
+ * run's single event stream to completion. It lets a reload reconnect to an
514
+ * in-flight conversation rather than starting over. Its promise settles as the
515
+ * read of a {@link start} does: it resolves when the engine stops reading the run,
516
+ * and rejects when the stream fails for good, the state already `ended`.
517
+ *
518
+ * `lastEventId` is the stream position to read on from: the gateway replays what follows
519
+ * it, then the live feed. Without one the read starts where the engine left the run when
520
+ * `runId` is the run it holds (the one it read last, still open or not), so a host that
521
+ * kept its transcript re-attaches and is handed nothing a second time. That place is after
522
+ * the last frame that reached the engine, the one an observer callback is being handed
523
+ * included: a resume made from inside the callback reads on after that frame. A frame whose
524
+ * handling threw (a seam that answers: the tool layer, the confirm gate, the tool surface or
525
+ * the state delta) is the exception. It is read again, and
526
+ * a call the run already claimed is dropped. For any other run the engine holds no position,
527
+ * and the gateway answers with the run's whole history: that is the read an engine built
528
+ * after a reload makes, and its host starts from an empty transcript. To read the held run
529
+ * from its first event again, resume it on a new engine.
530
+ *
531
+ * Like {@link start}, it reads the run on an engine whose last run ended, opens
532
+ * nothing after {@link dispose}, and replaces what the engine reads when it is
533
+ * called: another run is torn down and closed, and a start still waiting on its run
534
+ * id is withdrawn. A resume of the run the engine is reading tears that read down
535
+ * and reads the run again from `lastEventId`, or from where that read was when none is
536
+ * passed, and posts no close for it.
537
+ *
538
+ * The engine is at rest as the read begins, reported through `onStateChange("awaiting_input")`
539
+ * from an engine that was `running` or `ended`, and the stream says the rest. A call made
540
+ * from inside that report is read before the run is adopted, as one made from a report of a
541
+ * {@link start} is: a {@link dispose} ends the resume with no stream opened and no run to
542
+ * close, and a start or another resume is the one read the engine makes, so this resume
543
+ * resolves at once. A {@link close} made there finds no run held and posts nothing, and the
544
+ * resume reads its run.
545
+ */
546
+ resume(runId: string, lastEventId?: string): Promise<void>;
547
+ /**
548
+ * streamPosition reads where the engine stands in the run it read last, for a host that
549
+ * replaces the engine and has the next one read the run on.
550
+ *
551
+ * It is the position a {@link resume} of that run on this engine reads on from: after the last
552
+ * frame that reached the engine, or the position a resume was handed while no frame has
553
+ * followed it. It is kept through {@link dispose}, which is when a host reads it.
554
+ *
555
+ * @returns The run and the position, or `null` while the engine has read no run or the run's
556
+ * stream has named no position, which is the whole of a run whose frames carry no id.
557
+ *
558
+ * @example
559
+ * ```ts
560
+ * import type { AgentEngine } from "@mountaya/elements/agent";
561
+ *
562
+ * declare const parked: AgentEngine;
563
+ * declare const next: AgentEngine;
564
+ *
565
+ * const position = parked.streamPosition();
566
+ * parked.dispose();
567
+ * if (position !== null) {
568
+ * next.resume(position.runId, position.lastEventId).catch((error: unknown) => {
569
+ * console.error(error);
570
+ * });
571
+ * }
572
+ * ```
573
+ */
574
+ streamPosition(): AgentStreamPosition | null;
575
+ /**
576
+ * runId reads the id of the run the engine holds: the one a {@link start} opened, from the
577
+ * moment its post answers, or the one a {@link resume} reads, from the moment it begins. It is
578
+ * kept once the engine stops reading that run, whether the run ended, its stream failed, or the
579
+ * engine was disposed.
580
+ *
581
+ * It is what tells the two failures a start rejects with apart. A start whose post the gateway
582
+ * refused opened no run, and this reads null; a start whose run opened and whose stream was
583
+ * then refused reads that run. The same status says different things on each: a 404 on the post
584
+ * is an organization the reader does not reach, and a 404 on the stream is a run the gateway no
585
+ * longer holds.
586
+ *
587
+ * @returns The run's id, or null while the engine holds none: before its first run, and from
588
+ * the moment a start replaces a run until the post of that start answers, which a start that
589
+ * fails never does.
590
+ *
591
+ * @example
592
+ * ```ts
593
+ * import type { AgentEngine } from "@mountaya/elements/agent";
594
+ *
595
+ * declare const engine: AgentEngine;
596
+ * declare const report: (failure: unknown, openedRun: string | null) => void;
597
+ *
598
+ * engine.start("Plan a loop", "organization-id").catch((failure: unknown) => {
599
+ * report(failure, engine.runId());
600
+ * });
601
+ * ```
602
+ */
603
+ runId(): string | null;
604
+ /**
605
+ * send delivers a follow-up user message into the open run. It only posts the
606
+ * input (the persistent consumer opened by start/resume carries this turn's
607
+ * events), so it does NOT open a second stream.
608
+ *
609
+ * A message sent while a {@link start} still waits on its run id is held until the id
610
+ * arrives, then posted into that run, behind the opening of its stream and in the order the
611
+ * messages were sent. A start settles only when its run is over, so a caller has no promise
612
+ * to wait on before the next message. When that start opens no run (it fails, or a
613
+ * {@link close}, a {@link dispose} or a later start or {@link resume} withdraws it), the
614
+ * held message is dropped and the promise resolves: the start's rejection, or the call that
615
+ * withdrew it, already says the conversation did not open, and a second report of one
616
+ * failure is one too many.
617
+ *
618
+ * The state is `running` from the call the engine takes, reported through
619
+ * `onStateChange("running")` when the run was at rest, so the turn's settle is a change the
620
+ * observer hears even when the turn sends no frame of its own. A message the engine refuses
621
+ * changes nothing. When the post fails, the engine reports `awaiting_input` again before the
622
+ * promise rejects, unless another message is still being posted, one of them landed, or the
623
+ * stream has reported a state since: the turn is then the stream's to settle.
624
+ *
625
+ * The report is made ahead of the post, and the message goes into the run it found at the
626
+ * call. A {@link close}, a {@link dispose}, a {@link start} or a {@link resume} of another run
627
+ * made from inside that report takes the run from the message: nothing is posted and the
628
+ * promise resolves, as it does for a message held behind a start that opens no run. A
629
+ * {@link resume} of the same run keeps the message, and its turn is the stream's to settle.
630
+ * A send made from inside that report is posted after the message that reported, so two
631
+ * messages reach the run in the order they were sent.
632
+ *
633
+ * @throws {MountayaElementsError} when no run is being read and none is on its way: on an
634
+ * engine that never opened one, and once the run has ended, been closed or been disposed.
635
+ * A run that ended takes no more messages, and one the engine has stopped reading would
636
+ * answer to nobody, so the refusal is local rather than a request the gateway refuses. It
637
+ * is the package's own error and no stream fault, because it is a misuse of this package,
638
+ * which is what a consumer catching {@link MountayaElementsError} is catching. The next
639
+ * message goes into a run a new {@link start} opens, except on a disposed engine, which
640
+ * opens no more runs: the conversation continues on a new engine.
641
+ */
642
+ send(message: string): Promise<void>;
643
+ /**
644
+ * reads reports whether `runId` is still the run this engine reads: the engine is neither
645
+ * disposed nor ended, and no start or resume has put another run in its place.
646
+ */
647
+ private reads;
648
+ /**
649
+ * routedManifest renders the wire manifest for whatever the toolSurface seam
650
+ * currently selects, or the whole permitted set when no router is wired.
651
+ */
652
+ private routedManifest;
653
+ /**
654
+ * routedServerTools renders the server-tool allowlist for whatever the
655
+ * toolSurface seam currently selects: the routed name set verbatim, sorted so
656
+ * the wire body and the change key are stable across identical selections.
657
+ * The gateway ignores the client-tool names in it, so no registry knowledge
658
+ * is needed here. Undefined when no router is wired: the run then keeps
659
+ * every server tool. Undefined as well unless the session routes server tools
660
+ * ({@link AgentEngineConfig.routesServerTools}): under a publishable key a run
661
+ * calls none, and a list naming any is refused, so none is sent.
662
+ */
663
+ private routedServerTools;
664
+ /**
665
+ * routeTools re-reads the toolSurface seam and, when it has moved, replaces the
666
+ * tool set the run offers the model from its next turn on. The model then
667
+ * chooses among a coherent handful for the task at hand instead of the whole
668
+ * registry.
669
+ *
670
+ * It narrows only what the model can SEE. Every tool stays registered on the
671
+ * bus and dispatchable by a human click or an internal tool chain, and the
672
+ * capability gate remains the sole authorization boundary, exactly as
673
+ * `agentHidden` behaves.
674
+ *
675
+ * An unchanged selection sends nothing. That is not just a saved request: the
676
+ * tool array is the outermost part of the provider's cached prompt prefix, so a
677
+ * manifest re-sent on every turn would invalidate the cache every turn and cost
678
+ * far more than routing saves. "Unchanged" means changed since the run last
679
+ * ACCEPTED a set, so a selection whose POST failed is retried on the next call
680
+ * rather than treated as delivered.
681
+ *
682
+ * It is a no-op before a run exists, rather than a throw: routing is advisory,
683
+ * and a surface change while the panel is idle should cost nothing, since the
684
+ * next start() sends the current selection as the run's seed anyway.
685
+ *
686
+ * While a {@link start} still waits on its run id, the seed is already on its way, so the
687
+ * call waits for the run as {@link send} does and then routes it with the selection the
688
+ * surface holds by then. A routing update and a message held behind one start are released
689
+ * in the order they were called, neither waiting on the other's answer, so a caller that
690
+ * needs the selection in the run ahead of its message awaits routeTools() before it calls
691
+ * {@link send}. When that start opens no run, nothing is sent.
692
+ */
693
+ routeTools(): Promise<void>;
694
+ /**
695
+ * close asks the run to finish. It POSTs a close so the gateway finishes the
696
+ * run successfully (a terminal `done` event), AND aborts the open stream so a
697
+ * consumer parked between turns unwinds promptly rather than waiting on the
698
+ * gateway to close the connection. The terminal `done`, when it arrives first,
699
+ * ends the session.
700
+ *
701
+ * It closes a run the engine stopped reading on its own just the same: one it gave
702
+ * up on at the reconnect ceiling, after two minutes of opens answered 503 or on an
703
+ * open refused for good, which the gateway would otherwise hold open until its own
704
+ * timeout. A run is closed at most once, and a run that read its `done` is closed
705
+ * never: a second call, and a call after `done`, post nothing. So does a call after
706
+ * {@link dispose}, which leaves the run it was reading to the host.
707
+ *
708
+ * During a start that still waits on its run id, close withdraws the start and
709
+ * resolves at once, and the start finishes the run it opens (see {@link start}).
710
+ */
711
+ close(): Promise<void>;
712
+ /**
713
+ * dispose tears the session down without signalling the gateway: it aborts the
714
+ * open stream and marks the run ended, releasing the parked consumer. The host
715
+ * calls it on unmount AFTER close() has POSTed (a closed tab finishes the run),
716
+ * with the abort as the backstop when the consumer would otherwise leak.
717
+ *
718
+ * It is the engine's shutdown latch: {@link start} and {@link resume} open nothing
719
+ * afterwards. What it can still cause is what a start sends to finish the run whose id the
720
+ * host never received, when it was withdrawn or gave up at its ceiling: that run's close,
721
+ * and, when the start's answer was lost, the one last post of the start that names the run
722
+ * (see {@link start}).
723
+ *
724
+ * The run the engine was reading, or stopped reading on its own, is the host's from here:
725
+ * the host holds its id, so it can resume it or close it, and a later {@link close} on
726
+ * this engine posts nothing for it.
727
+ */
728
+ dispose(): void;
729
+ /**
730
+ * leaveRun stops the engine reading what it reads, before a {@link start} or a
731
+ * {@link resume} reads a run: one engine reads one run. A start still waiting on its run
732
+ * id is withdrawn. A run still being read has its stream torn down, so none of its frames,
733
+ * its resume cursor or its `done` reach the run read next. A close is posted for the run the
734
+ * engine still owes one (see `unfinishedRunId`): the run it was reading, and the run it
735
+ * stopped reading on its own, because in both cases the engine was the one party reading
736
+ * it. `next` names the run about to be read, and that run is spared the close when it is
737
+ * the one owed it: a resume of it reads it again.
738
+ */
739
+ private leaveRun;
740
+ /**
741
+ * withdrawStart withdraws the start still waiting on its run id, if one is: that start then
742
+ * finishes the run it opens instead of reading it (see {@link start}), and every message
743
+ * and routing update held behind it is dropped (see {@link send}).
744
+ */
745
+ private withdrawStart;
746
+ /**
747
+ * beginRun readies the engine to read a new run once {@link leaveRun} has stopped it
748
+ * reading the last one. The run id, the resume cursor and the stream handle belong to that
749
+ * run, so all three go, and the state returns to `awaiting_input`: `ended` would stop the
750
+ * read loop before it opened anything.
751
+ *
752
+ * The rest is the engine's own and is reported to nobody here. A {@link resume} reports it,
753
+ * since its run may rest for good. A {@link start} reports `running` next, or the rest once
754
+ * it fails, so a start that replaces a run under way is one turn after another to the
755
+ * observer and no rest between them ({@link reportState}).
756
+ *
757
+ * @returns The generation of the read being readied, which a later start or resume replaces.
758
+ */
759
+ private beginRun;
760
+ /**
761
+ * adoptRun makes `runId` the run this engine reads, and the run it owes a close until the
762
+ * run's `done` arrives or a close is posted. The memory of handled calls, and of the calls
763
+ * the engine reported among them, belongs to one run, because call ids are the run's own: it
764
+ * is kept when the run is the one already read (a resume of it) and emptied for any other.
765
+ */
766
+ private adoptRun;
767
+ /**
768
+ * claimCall records a call id as handled and reports whether the frame that names it is
769
+ * the engine's to act on. Two frames are not, and each is dropped whole:
770
+ *
771
+ * - one whose id the run already sighted, a replay of a call the engine ran or answered
772
+ * itself, whose result is already posted;
773
+ * - one the stream marks `settled`, a replay of a call whose outcome the stream already
774
+ * holds. An engine built after a page reload has no memory of the run, so the marker is
775
+ * all that tells it the call was answered.
776
+ *
777
+ * A settled id is recorded like any other, so a later frame that names it without the
778
+ * marker runs nothing either. A replayed frame with no marker and an id never sighted is
779
+ * one the stream holds no outcome for, and is the engine's.
780
+ */
781
+ private claimCall;
782
+ /**
783
+ * closeQuietly posts a close for a live run the engine leaves behind: one a withdrawn start
784
+ * opened and never read, whose id the host never received, and one a later start or resume
785
+ * replaced. A failed post is dropped: nobody is
786
+ * left to tell, and the gateway completes a run that goes quiet on its own.
787
+ */
788
+ private closeQuietly;
789
+ /**
790
+ * releaseSubscription stops callback delivery from the open stream, exactly
791
+ * once. It reads the handle out and clears it BEFORE invoking it, so a
792
+ * re-entrant settle (the abort listener firing synchronously inside
793
+ * teardownStream, or a transport calling back into onClose) finds nothing
794
+ * left to release rather than calling the same handle twice.
795
+ */
796
+ private releaseSubscription;
797
+ /**
798
+ * teardownStream releases the open events stream from both sides: the
799
+ * unsubscribe stops callback delivery (covering the scripted drain, which has
800
+ * no fetch to abort), and the abort closes the live fetch (and trips the resume
801
+ * detection in run()). Idempotent, so close() followed by dispose() is harmless.
802
+ *
803
+ * The unsubscribe runs FIRST because abort() dispatches its listener
804
+ * synchronously: that listener settles the read and clears the handle, so
805
+ * aborting first would leave nothing to unsubscribe and the scripted drain
806
+ * would stay parked for the life of the process.
807
+ */
808
+ private teardownStream;
809
+ /**
810
+ * run consumes the run's event stream to completion, reconnecting when the
811
+ * stream closes before a terminal event. The gateway may close an SSE
812
+ * connection between turns (e.g. after `awaiting-input`); rather than leave the
813
+ * run silently stuck, run re-opens the stream from the tracked Last-Event-ID so
814
+ * the conversation continues. It returns once a terminal event ends the run, an
815
+ * abort tears the stream down, or the reconnects stop being productive: an open that
816
+ * closes having said nothing or one frame waits on the reconnect schedule, and the
817
+ * attempt ceiling below bounds how many of them in a row the run is given.
818
+ *
819
+ * A read that FAILS is judged by {@link isTransientStreamFault}. A transient one (a
820
+ * dropped connection, a 429, 503 or 504 at open) reopens from the last id on the same
821
+ * schedule and under the same ceiling as a hangup, and when the ceiling is reached on a
822
+ * read that failed, that failure (the drop, or the 429 or 504) is what the caller
823
+ * receives. The client's own reader reports an open that never answers and a stream gone
824
+ * silent as dropped connections, so both reopen. Any other failure ends the read at once and
825
+ * rejects with it. Either way the state is `ended` before the rejection, because the engine
826
+ * has stopped reading the run, and the run is owed a close (see {@link close}).
827
+ *
828
+ * An open answered 503 reopens on that schedule and outside that ceiling: it is left out of
829
+ * the count, neither adding to it nor clearing it, and such opens are bounded by
830
+ * {@link RECONNECT_UNAVAILABLE_MAX_MS} from the first of them, past which the caller receives
831
+ * the 503. A turn that moves starts the count and that time again.
832
+ *
833
+ * A stream that ends with the credential it was opened with, or that the API could not keep
834
+ * delivering (`interrupted`), reopens at once from the last id, and clears the count of
835
+ * fruitless opens: the transport closes either as `reconnect`, and the reopen carries the
836
+ * session token the client holds by then. A 401 on that reopen is a failure like any other
837
+ * refusal, and ends the read.
838
+ *
839
+ * A teardown ends the read wherever it finds it, the backoff between two opens included:
840
+ * a close or a dispose, and a start or a resume that replaced this run (see
841
+ * {@link leaveRun}).
842
+ */
843
+ private run;
844
+ /**
845
+ * backoff waits out one reconnect delay, drawn by {@link reconnectDelayMs} on the run's
846
+ * {@link reconnectSchedule}: below a ceiling that doubles from AGENT_RECONNECT_BASE_MS to
847
+ * RECONNECT_MAX_MS, so the wait stays inside a person's patience and runs dropped together
848
+ * do not reopen together. Where the failure was a 429 or a 503 that named its wait (`namedMs`),
849
+ * that wait replaces the draw, with up to a second drawn above it and the timer's ceiling over
850
+ * it ({@link retryAfterDelayMs}), as SPEC §2 has `Retry-After` replace the schedule. It settles
851
+ * on whichever comes first, the timer or the stream teardown's abort, and drops both hooks
852
+ * either way: a run that reconnects many times must not accumulate listeners on the signal, nor
853
+ * leave a timer holding the loop after the session is gone.
854
+ */
855
+ private backoff;
856
+ /**
857
+ * consume opens one read of the run's events stream and settles when it
858
+ * finishes, bridging the transport's AgentStreamHandlers callbacks to a single
859
+ * promise run() can await. It reacts to each decoded frame and records its id as
860
+ * the resume position when the frame arrives, taking it back when the frame's handling
861
+ * throws; the transport has already validated every frame, so it trusts the typed
862
+ * event. Unlike a per-turn drive it does NOT stop on
863
+ * `awaiting-input` (the stream stays open for the next message). It resolves
864
+ * with whether a terminal event ended the run and how many frames the stream
865
+ * delivered, so the caller can decide between reconnecting and settling and
866
+ * tell a productive open from a fruitless one, and with the failure when the
867
+ * read failed. It never rejects, a transport that throws from the open included:
868
+ * whether a failure ends the run is run()'s call.
869
+ * A terminal the SESSION decides (handle returning true on `done`) tears the
870
+ * subscription down here so no further frame is processed after the run is
871
+ * over. A teardown's abort (a close, a dispose, or a start or resume that replaced
872
+ * the run) settles the promise on its own (the transport fires no callback on a
873
+ * deliberate abort), so run() unwinds without waiting on a dead stream.
874
+ *
875
+ * It is one closure on purpose. Every handler reads and writes this read's own settle
876
+ * latch and frame count, and held as fields they would be the next read's to reach.
877
+ */
878
+ private consume;
879
+ /**
880
+ * handle reacts to one event of the run `runId` names and reports whether the run
881
+ * ended (so consume can stop). An active-turn event (streamed text, a tool call, a
882
+ * confirm request) flips the lifecycle to `running`; a client tool-call is dispatched
883
+ * through the bus and its result posted back; a confirm-required is routed through
884
+ * the host gate and the decision posted back. Both answers go to `runId`, the run that
885
+ * asked, even when a later start or resume replaced it while the tool ran or the host
886
+ * decided. A tool-call or a confirm-required that {@link claimCall} refuses, one the
887
+ * stream marks `settled` or one the run already handled, is dropped whole: it reaches
888
+ * neither the bus, the gate nor the observer, and leaves the lifecycle as it is. An
889
+ * `awaiting-input` event settles the turn to the `awaiting_input` state but
890
+ * keeps the stream open (returns false); only a terminal `done` ends the run (returns
891
+ * true).
892
+ */
893
+ private handle;
894
+ /**
895
+ * handleToolCall runs one client tool call through the bus, reports it to the observer and
896
+ * posts its result back into the run that asked. It answers false: a tool call never ends
897
+ * the run.
898
+ *
899
+ * The call is running from its claim to its report. What the stream says of it meanwhile is
900
+ * held ({@link holdWhileRunning}), and released when the handling throws before the report:
901
+ * the engine has no report of its own then, and the stream's word settles the host's row.
902
+ */
903
+ private handleToolCall;
904
+ /**
905
+ * releaseHeldWord takes a call out of the running set and delivers what the stream said of it
906
+ * while it ran, when it said anything. A call the engine reported is out of the set already,
907
+ * and so is every call of a run the engine no longer holds the memory of: both release
908
+ * nothing.
909
+ */
910
+ private releaseHeldWord;
911
+ /**
912
+ * holdWhileRunning keeps what the stream says of a call the engine is still running, as the
913
+ * report it would have made, and answers whether it did. The first word is the one kept: a
914
+ * failed `tool-result` follows the `tool-abandoned` of a call the run gave up on.
915
+ */
916
+ private holdWhileRunning;
917
+ /** runToolCall is the handling of a claimed client tool call: see {@link handleToolCall}. */
918
+ private runToolCall;
919
+ /**
920
+ * handleConfirmRequired puts a server tool's confirmation to the host gate and posts the
921
+ * decision back into the run that asked. It answers false: a confirmation never ends the
922
+ * run.
923
+ */
924
+ private handleConfirmRequired;
925
+ /**
926
+ * handleDone reports how the run ended and ends the read, unless a start or a resume made
927
+ * from the callback has already replaced it. It answers true: `done` is the one terminal.
928
+ */
929
+ private handleDone;
930
+ /**
931
+ * handleToolResult reports a call's outcome as the stream states it, unless the call is one
932
+ * the engine ran and reported itself. It answers false.
933
+ */
934
+ private handleToolResult;
935
+ /**
936
+ * handleToolAbandoned reports a call the run gave up on, unless the call is one the engine
937
+ * ran and reported itself. It answers false.
938
+ */
939
+ private handleToolAbandoned;
940
+ /**
941
+ * setState records the lifecycle transition and notifies the observer only on
942
+ * an actual change, so the host does not re-render on a no-op.
943
+ *
944
+ * Every report, a no-op included, drops the hold the sends being posted have on `running`:
945
+ * whatever speaks here (a frame, a close, a new run) owns the state from then on. A send
946
+ * reports its own `running` through {@link reportState}, which keeps the hold.
947
+ */
948
+ private setState;
949
+ /**
950
+ * reportState is {@link setState} without the drop of the hold, for the one report that is
951
+ * the hold's own: the `running` of a send.
952
+ *
953
+ * The observer is told a state that differs from the one it was told last, which is the
954
+ * engine's own state but while a start readies its run ({@link beginRun}).
955
+ */
956
+ private reportState;
957
+ /**
958
+ * tell hands the observer one report. The observer answers nothing the run waits on, so a
959
+ * callback that throws is a defect of the host's own rendering and never the run's: its fault
960
+ * reaches the program through {@link surfaceFault}, and the read goes on.
961
+ */
962
+ private tell;
963
+ /**
964
+ * postInput sends one input frame back into the run `runId` names, the run that asked
965
+ * for it, and reports a failure as a fault in the conversation instead of throwing.
966
+ *
967
+ * The catch is the point. `start()` ends with `await this.run(runId)`, so the whole
968
+ * consume loop lives inside the start promise, and an unguarded rejection here would
969
+ * leave `handle()` as a fault of the engine's own: the read would end for good, and
970
+ * `start()` would reject into the host's START error path. A network blip on turn
971
+ * twelve would then render "could not start", clear the started guard and drop the run
972
+ * id, so the still-alive gateway run could never be resumed and the model's call would
973
+ * expire as `tool-abandoned` with the user told nothing true about why.
974
+ *
975
+ * Reporting and continuing is the right shape: the run is still open, the stream is
976
+ * still readable, and the gateway abandons the unanswered call on its own timeout so
977
+ * the model can replan. What is lost is one tool result, which is a turn-level fault,
978
+ * not a session-level one. A run a later start or resume replaced has nobody reading
979
+ * it, so a failure to answer it is dropped rather than reported into the run that
980
+ * replaced it. So is a failure to answer a run the engine has stopped reading, after a
981
+ * {@link close} or a {@link dispose}: the host ended that conversation, and an error line
982
+ * under it would report a fault in a run nobody is in.
983
+ *
984
+ * The message is deliberately empty. A fetch rejection carries an English,
985
+ * internal string, and the host resolves an empty message to its own localized
986
+ * generic line, the same rule the run's other self-raised terminals follow.
987
+ */
988
+ private postInput;
1029
989
  }
1030
-
1031
990
  /**
1032
991
  * AgentBudgetCopy is the per-dimension usage-limit copy resolveAgentError chooses
1033
992
  * between when a run ends on a budget ceiling: one line for each exhausted
@@ -1036,9 +995,9 @@ declare class AgentEngine {
1036
995
  * and that a new chat continues the work.
1037
996
  */
1038
997
  interface AgentBudgetCopy {
1039
- cost: string;
1040
- generic: string;
1041
- turns: string;
998
+ cost: string;
999
+ generic: string;
1000
+ turns: string;
1042
1001
  }
1043
1002
  /**
1044
1003
  * AgentDraftWarning is the unsaved-work annexe a budget line carries when, and
@@ -1053,8 +1012,8 @@ interface AgentBudgetCopy {
1053
1012
  * more honestly than supplying copy that can never be reached.
1054
1013
  */
1055
1014
  interface AgentDraftWarning {
1056
- note: string;
1057
- open: boolean;
1015
+ note: string;
1016
+ open: boolean;
1058
1017
  }
1059
1018
  /**
1060
1019
  * AgentErrorCopy is the localized copy resolveAgentError chooses between for a
@@ -1062,18 +1021,18 @@ interface AgentDraftWarning {
1062
1021
  * resolver stays a pure, i18n-free mapping that is trivial to unit-test.
1063
1022
  */
1064
1023
  interface AgentErrorCopy {
1065
- /**
1066
- * The line for a run the gateway stopped because the member who started it may not run it in
1067
- * its organization any more, for either of the two causes the code carries: they hold no write
1068
- * role there (they left it, or their role reads only), or the organization's agreement does
1069
- * not include Map Studio. One line answers both, so it names the loss of access and not a cause.
1070
- */
1071
- accessRevoked: string;
1072
- budget: AgentBudgetCopy;
1073
- generic: string;
1074
- looping: string;
1075
- notConfigured: string;
1076
- rateLimited: string;
1024
+ /**
1025
+ * The line for a run the gateway stopped because the member who started it may not run it in
1026
+ * its organization any more, for either of the two causes the code carries: they hold no write
1027
+ * role there (they left it, or their role reads only), or the organization's agreement does
1028
+ * not include Map Studio. One line answers both, so it names the loss of access and not a cause.
1029
+ */
1030
+ accessRevoked: string;
1031
+ budget: AgentBudgetCopy;
1032
+ generic: string;
1033
+ looping: string;
1034
+ notConfigured: string;
1035
+ rateLimited: string;
1077
1036
  }
1078
1037
  /**
1079
1038
  * resolveAgentError maps a terminal agent error onto the copy shown as the error
@@ -1098,15 +1057,14 @@ interface AgentErrorCopy {
1098
1057
  * omits it.
1099
1058
  * @returns The line to show as the error turn.
1100
1059
  */
1101
- declare const resolveAgentError: (message: string, code: string | undefined, copy: AgentErrorCopy, draft?: AgentDraftWarning) => string;
1102
-
1060
+ export declare const resolveAgentError: (message: string, code: string | undefined, copy: AgentErrorCopy, draft?: AgentDraftWarning) => string;
1103
1061
  /**
1104
1062
  * MAX_TOOL_INPUT_CHARS bounds the pretty-printed tool input captured on an
1105
1063
  * activity row, so a large payload never bloats the transcript store or the
1106
1064
  * expanded details block. A run touches many tools; keeping each captured input
1107
1065
  * small keeps the whole conversation cheap to hold and render.
1108
1066
  */
1109
- declare const MAX_TOOL_INPUT_CHARS = 2000;
1067
+ export declare const MAX_TOOL_INPUT_CHARS = 2000;
1110
1068
  /**
1111
1069
  * boundedInputJson pretty-prints a tool call's raw input for an activity row's
1112
1070
  * expandable details, bounded to {@link MAX_TOOL_INPUT_CHARS} with a trailing
@@ -1121,8 +1079,7 @@ declare const MAX_TOOL_INPUT_CHARS = 2000;
1121
1079
  * object or a bigint throws, and a bare `undefined`, function or symbol serializes to
1122
1080
  * nothing.
1123
1081
  */
1124
- declare const boundedInputJson: (input: unknown) => string | null;
1125
-
1082
+ export declare const boundedInputJson: (input: unknown) => string | null;
1126
1083
  /**
1127
1084
  * ConversationState is the reactive core an AI conversation renders against: its
1128
1085
  * run id (null until a run opens), the run lifecycle the surface renders against,
@@ -1132,9 +1089,9 @@ declare const boundedInputJson: (input: unknown) => string | null;
1132
1089
  * lifecycle and transcript spine and the streaming helpers that grow it.
1133
1090
  */
1134
1091
  interface ConversationState<E> {
1135
- runId: string | null;
1136
- state: AgentEngineState;
1137
- transcript: E[];
1092
+ runId: string | null;
1093
+ state: AgentEngineState;
1094
+ transcript: E[];
1138
1095
  }
1139
1096
  /**
1140
1097
  * TranscriptRole tags a transcript entry as the user's message, the assistant's
@@ -1168,22 +1125,22 @@ type ActivityStatus = "abandoned" | "error" | "ok" | "running";
1168
1125
  * one id; user and error entries are appended whole.
1169
1126
  */
1170
1127
  interface MessageEntry {
1171
- content: string;
1172
- id: string;
1173
- /**
1174
- * The reply's zero-based position among the run's assistant messages, as the run
1175
- * itself reported it, so a rating on this turn names the message the API will
1176
- * see.
1177
- *
1178
- * Present on assistant turns the run numbered, absent on every other role and on a
1179
- * reply from a gateway that sends no index: a reader falls back to counting the
1180
- * replies it holds for those. That fallback is why the field is worth carrying at
1181
- * all: counting locally is right until a reload mid-run, which rebuilds no
1182
- * transcript, so the count restarts at zero while the conversation is already
1183
- * several answers in.
1184
- */
1185
- messageIndex?: number | undefined;
1186
- role: "assistant" | "error" | "user";
1128
+ content: string;
1129
+ id: string;
1130
+ /**
1131
+ * The reply's zero-based position among the run's assistant messages, as the run
1132
+ * itself reported it, so a rating on this turn names the message the API will
1133
+ * see.
1134
+ *
1135
+ * Present on assistant turns the run numbered, absent on every other role and on a
1136
+ * reply from a gateway that sends no index: a reader falls back to counting the
1137
+ * replies it holds for those. That fallback is why the field is worth carrying at
1138
+ * all: counting locally is right until a reload mid-run, which rebuilds no
1139
+ * transcript, so the count restarts at zero while the conversation is already
1140
+ * several answers in.
1141
+ */
1142
+ messageIndex?: number | undefined;
1143
+ role: "assistant" | "error" | "user";
1187
1144
  }
1188
1145
  /**
1189
1146
  * ActivityEntry is a permanent transcript row for one agent tool action, keyed by
@@ -1195,28 +1152,28 @@ interface MessageEntry {
1195
1152
  * `name`/`input` are null.
1196
1153
  */
1197
1154
  interface ActivityEntry {
1198
- /**
1199
- * Why an abandoned action was given up on. `timeout` means nothing came back
1200
- * within the run's window, which usually means this browser went away or the tool
1201
- * hung; `closed` means the run was stopped while the action was still outstanding,
1202
- * which is the user's own doing and not a fault. Null on every other status.
1203
- */
1204
- abandonedReason: "timeout" | "closed" | null;
1205
- error: string | null;
1206
- id: string;
1207
- /**
1208
- * What the run will try about this failure, from the tool's playbook entry.
1209
- * Null when the tool succeeded, or when the playbook has nothing for that
1210
- * (tool, code) pair. It turns a silent retry into something the user can see the
1211
- * shape of, which is the difference between the co-pilot looking stuck and
1212
- * looking like it is working.
1213
- */
1214
- recovery: string | null;
1215
- input: string | null;
1216
- label: string | null;
1217
- name: string | null;
1218
- role: "activity";
1219
- status: ActivityStatus;
1155
+ /**
1156
+ * Why an abandoned action was given up on. `timeout` means nothing came back
1157
+ * within the run's window, which usually means this browser went away or the tool
1158
+ * hung; `closed` means the run was stopped while the action was still outstanding,
1159
+ * which is the user's own doing and not a fault. Null on every other status.
1160
+ */
1161
+ abandonedReason: "timeout" | "closed" | null;
1162
+ error: string | null;
1163
+ id: string;
1164
+ /**
1165
+ * What the run will try about this failure, from the tool's playbook entry.
1166
+ * Null when the tool succeeded, or when the playbook has nothing for that
1167
+ * (tool, code) pair. It turns a silent retry into something the user can see the
1168
+ * shape of, which is the difference between the co-pilot looking stuck and
1169
+ * looking like it is working.
1170
+ */
1171
+ recovery: string | null;
1172
+ input: string | null;
1173
+ label: string | null;
1174
+ name: string | null;
1175
+ role: "activity";
1176
+ status: ActivityStatus;
1220
1177
  }
1221
1178
  /**
1222
1179
  * WarningEntry is an informational transcript row: the run answered, and the
@@ -1227,9 +1184,9 @@ interface ActivityEntry {
1227
1184
  * publishes once is a fact about that moment.
1228
1185
  */
1229
1186
  interface WarningEntry {
1230
- id: string;
1231
- lines: readonly string[];
1232
- role: "warning";
1187
+ id: string;
1188
+ lines: readonly string[];
1189
+ role: "warning";
1233
1190
  }
1234
1191
  /**
1235
1192
  * QuestionOption is one selectable answer on a question card: the label the
@@ -1243,8 +1200,8 @@ interface WarningEntry {
1243
1200
  * route instead of only saying its name.
1244
1201
  */
1245
1202
  interface QuestionOption {
1246
- description: string | null;
1247
- label: string;
1203
+ description: string | null;
1204
+ label: string;
1248
1205
  }
1249
1206
  /**
1250
1207
  * QuestionEntry is a structured question the assistant asked: the question with
@@ -1256,12 +1213,12 @@ interface QuestionOption {
1256
1213
  * offers buttons invites a second answer the run is not waiting for.
1257
1214
  */
1258
1215
  interface QuestionEntry {
1259
- id: string;
1260
- options: readonly QuestionOption[];
1261
- question: string;
1262
- role: "question";
1263
- selected: string | null;
1264
- settled: boolean;
1216
+ id: string;
1217
+ options: readonly QuestionOption[];
1218
+ question: string;
1219
+ role: "question";
1220
+ selected: string | null;
1221
+ settled: boolean;
1265
1222
  }
1266
1223
  /**
1267
1224
  * SuggestionCardCandidate is one generated route option on a suggestions card:
@@ -1273,11 +1230,11 @@ interface QuestionEntry {
1273
1230
  * reader's preference.
1274
1231
  */
1275
1232
  interface SuggestionCardCandidate {
1276
- ascentMeters: number;
1277
- color: string;
1278
- distanceMeters: number;
1279
- durationSeconds: number;
1280
- seed: number;
1233
+ ascentMeters: number;
1234
+ color: string;
1235
+ distanceMeters: number;
1236
+ durationSeconds: number;
1237
+ seed: number;
1281
1238
  }
1282
1239
  /**
1283
1240
  * SuggestionsEntry is a generated route-candidate batch rendered as an
@@ -1291,11 +1248,11 @@ interface SuggestionCardCandidate {
1291
1248
  * pick nothing is waiting for.
1292
1249
  */
1293
1250
  interface SuggestionsEntry {
1294
- candidates: readonly SuggestionCardCandidate[];
1295
- chosenSeed: number | null;
1296
- id: string;
1297
- role: "suggestions";
1298
- settled: boolean;
1251
+ candidates: readonly SuggestionCardCandidate[];
1252
+ chosenSeed: number | null;
1253
+ id: string;
1254
+ role: "suggestions";
1255
+ settled: boolean;
1299
1256
  }
1300
1257
  /**
1301
1258
  * TranscriptEntry is one turn in a chat's conversation: a spoken message
@@ -1315,23 +1272,23 @@ type TranscriptEntry = ActivityEntry | MessageEntry | QuestionEntry | Suggestion
1315
1272
  * transcript unchanged. A question with no options appends nothing: it would
1316
1273
  * render a card the user cannot answer.
1317
1274
  */
1318
- declare const appendQuestionEntry: <T extends readonly TranscriptEntry[]>(transcript: T, question: {
1319
- options: readonly QuestionOption[];
1320
- question: string;
1321
- toolCallId: string;
1275
+ export declare const appendQuestionEntry: <T extends readonly TranscriptEntry[]>(transcript: T, question: {
1276
+ options: readonly QuestionOption[];
1277
+ question: string;
1278
+ toolCallId: string;
1322
1279
  }) => T | TranscriptEntry[];
1323
1280
  /**
1324
1281
  * answerQuestionEntry settles the question card carrying the entry id with the
1325
1282
  * label the user picked. A card that already settled is never re-settled: a
1326
1283
  * double click races the send, and the first answer is the one that was sent.
1327
1284
  */
1328
- declare const answerQuestionEntry: (transcript: readonly TranscriptEntry[], entryId: string, label: string) => TranscriptEntry[];
1285
+ export declare const answerQuestionEntry: (transcript: readonly TranscriptEntry[], entryId: string, label: string) => TranscriptEntry[];
1329
1286
  /**
1330
1287
  * settleOpenQuestionEntries settles every still-open question card with no
1331
1288
  * pick. Called when the user answers in their own words: the reply supersedes
1332
1289
  * the buttons, so they go inert without any option marked as chosen.
1333
1290
  */
1334
- declare const settleOpenQuestionEntries: <T extends readonly TranscriptEntry[]>(transcript: T) => T | TranscriptEntry[];
1291
+ export declare const settleOpenQuestionEntries: <T extends readonly TranscriptEntry[]>(transcript: T) => T | TranscriptEntry[];
1335
1292
  /**
1336
1293
  * appendSuggestionsEntry appends one route-candidate batch as an open card keyed
1337
1294
  * off the generating tool call's id. A re-render or a replayed frame can emit
@@ -1341,29 +1298,29 @@ declare const settleOpenQuestionEntries: <T extends readonly TranscriptEntry[]>(
1341
1298
  * still-open one (a regenerate replaced those candidates in the live session),
1342
1299
  * so prior open suggestions cards settle inert in the same write.
1343
1300
  */
1344
- declare const appendSuggestionsEntry: <T extends readonly TranscriptEntry[]>(transcript: T, suggestions: {
1345
- candidates: readonly SuggestionCardCandidate[];
1346
- entryId: string;
1301
+ export declare const appendSuggestionsEntry: <T extends readonly TranscriptEntry[]>(transcript: T, suggestions: {
1302
+ candidates: readonly SuggestionCardCandidate[];
1303
+ entryId: string;
1347
1304
  }) => T | TranscriptEntry[];
1348
1305
  /**
1349
1306
  * chooseSuggestionEntry settles the suggestions card carrying the entry id with
1350
1307
  * the seed the user picked. A card that already settled is never re-settled: a
1351
1308
  * double click races the staging chain, and the first pick is the one that ran.
1352
1309
  */
1353
- declare const chooseSuggestionEntry: (transcript: readonly TranscriptEntry[], entryId: string, seed: number) => TranscriptEntry[];
1310
+ export declare const chooseSuggestionEntry: (transcript: readonly TranscriptEntry[], entryId: string, seed: number) => TranscriptEntry[];
1354
1311
  /**
1355
1312
  * settleOpenSuggestionEntries settles every still-open suggestions card with no
1356
1313
  * pick. Called when the user replies in their own words (the reply supersedes
1357
1314
  * the rows, and the run may be about to regenerate) and by a fresh batch's append:
1358
1315
  * both leave the old card inert without any candidate marked as chosen.
1359
1316
  */
1360
- declare const settleOpenSuggestionEntries: <T extends readonly TranscriptEntry[]>(transcript: T) => T | TranscriptEntry[];
1317
+ export declare const settleOpenSuggestionEntries: <T extends readonly TranscriptEntry[]>(transcript: T) => T | TranscriptEntry[];
1361
1318
  /**
1362
1319
  * appendWarningEntry appends one informational warning row. Empty lines append
1363
1320
  * nothing: a warning with nothing to say would render an empty orange box, which
1364
1321
  * reads as a rendering bug rather than information.
1365
1322
  */
1366
- declare const appendWarningEntry: <T extends readonly TranscriptEntry[]>(transcript: T, lines: readonly string[]) => T | TranscriptEntry[];
1323
+ export declare const appendWarningEntry: <T extends readonly TranscriptEntry[]>(transcript: T, lines: readonly string[]) => T | TranscriptEntry[];
1367
1324
  /**
1368
1325
  * appendErrorEntry appends one error row carrying a message already resolved for
1369
1326
  * display. Resolving the copy is the caller's job (the same fault reads
@@ -1374,13 +1331,13 @@ declare const appendWarningEntry: <T extends readonly TranscriptEntry[]>(transcr
1374
1331
  * would otherwise be hand-rolled at each call site, which is how an entry ends up
1375
1332
  * with a subtly different shape depending on where it was built.
1376
1333
  */
1377
- declare const appendErrorEntry: <E extends {
1378
- id: string;
1379
- role: string;
1334
+ export declare const appendErrorEntry: <E extends {
1335
+ id: string;
1336
+ role: string;
1380
1337
  }>(transcript: readonly E[], message: string) => (E | {
1381
- content: string;
1382
- id: string;
1383
- role: "error";
1338
+ content: string;
1339
+ id: string;
1340
+ role: "error";
1384
1341
  })[];
1385
1342
  /**
1386
1343
  * appendUserEntry appends one turn the user spoke. It is the counterpart to
@@ -1392,13 +1349,13 @@ declare const appendErrorEntry: <E extends {
1392
1349
  * (the co-pilot settles them, the video director has none), so it stays with the
1393
1350
  * caller rather than being buried in an append.
1394
1351
  */
1395
- declare const appendUserEntry: <E extends {
1396
- id: string;
1397
- role: string;
1352
+ export declare const appendUserEntry: <E extends {
1353
+ id: string;
1354
+ role: string;
1398
1355
  }>(transcript: readonly E[], content: string) => (E | {
1399
- content: string;
1400
- id: string;
1401
- role: "user";
1356
+ content: string;
1357
+ id: string;
1358
+ role: "user";
1402
1359
  })[];
1403
1360
  /**
1404
1361
  * PendingConfirmation is a destructive tool a run is waiting on the user to
@@ -1409,8 +1366,8 @@ declare const appendUserEntry: <E extends {
1409
1366
  * card shows the title alone).
1410
1367
  */
1411
1368
  interface PendingConfirmation {
1412
- name: string;
1413
- summary: string | null;
1369
+ name: string;
1370
+ summary: string | null;
1414
1371
  }
1415
1372
  /**
1416
1373
  * appendActivityEntry appends one tool action as a permanent running row keyed by
@@ -1419,10 +1376,10 @@ interface PendingConfirmation {
1419
1376
  * unchanged rather than a duplicate row. Shared by the co-pilot threads store and
1420
1377
  * the director store so both record actions with identical semantics.
1421
1378
  */
1422
- declare const appendActivityEntry: <T extends readonly TranscriptEntry[]>(transcript: T, activity: {
1423
- input: string | null;
1424
- name: string;
1425
- toolCallId: string;
1379
+ export declare const appendActivityEntry: <T extends readonly TranscriptEntry[]>(transcript: T, activity: {
1380
+ input: string | null;
1381
+ name: string;
1382
+ toolCallId: string;
1426
1383
  }) => T | TranscriptEntry[];
1427
1384
  /**
1428
1385
  * settleActivityEntry settles the running activity row carrying the call id in
@@ -1436,7 +1393,7 @@ declare const appendActivityEntry: <T extends readonly TranscriptEntry[]>(transc
1436
1393
  * already-settled row. Shared by both chat stores so the settle semantics never
1437
1394
  * drift.
1438
1395
  */
1439
- declare const settleActivityEntry: <T extends readonly TranscriptEntry[]>(transcript: T, toolCallId: string, outcome: ToolActivityOutcome) => T | TranscriptEntry[];
1396
+ export declare const settleActivityEntry: <T extends readonly TranscriptEntry[]>(transcript: T, toolCallId: string, outcome: ToolActivityOutcome) => T | TranscriptEntry[];
1440
1397
  /**
1441
1398
  * AssistantTurn is a freshly-minted assistant reply: a stable render key (which
1442
1399
  * survives token accumulation, since the running reply is rebuilt as tokens
@@ -1445,23 +1402,23 @@ declare const settleActivityEntry: <T extends readonly TranscriptEntry[]>(transc
1445
1402
  * assistant's, so both helpers return it alongside the caller's own entry type.
1446
1403
  */
1447
1404
  interface AssistantTurn {
1448
- content: string;
1449
- id: string;
1450
- /**
1451
- * The reply's zero-based position among the run's assistant messages, set from the
1452
- * settled `message` event. Absent while the turn is still accumulating tokens (the
1453
- * run numbers a message when it completes one, not per token), and absent for a
1454
- * reply from a gateway that sends no index.
1455
- */
1456
- messageIndex?: number | undefined;
1457
- role: "assistant";
1405
+ content: string;
1406
+ id: string;
1407
+ /**
1408
+ * The reply's zero-based position among the run's assistant messages, set from the
1409
+ * settled `message` event. Absent while the turn is still accumulating tokens (the
1410
+ * run numbers a message when it completes one, not per token), and absent for a
1411
+ * reply from a gateway that sends no index.
1412
+ */
1413
+ messageIndex?: number | undefined;
1414
+ role: "assistant";
1458
1415
  }
1459
1416
  /**
1460
1417
  * mintEntryId mints a stable render key for a new transcript entry, as {@link localId} mints
1461
1418
  * one: a version 4 UUID where the runtime draws one, outside a secure context too, and an id
1462
1419
  * counted in the page where it has no cryptographic source.
1463
1420
  */
1464
- declare const mintEntryId: () => string;
1421
+ export declare const mintEntryId: () => string;
1465
1422
  /**
1466
1423
  * accumulateAssistant appends a streamed delta to the last assistant entry,
1467
1424
  * keeping its id so the running turn's render key is stable across tokens, or
@@ -1479,9 +1436,9 @@ declare const mintEntryId: () => string;
1479
1436
  * continues itself, e.g. after a response cut at the provider's length ceiling)
1480
1437
  * would grow the finished reply with the next one's tokens.
1481
1438
  */
1482
- declare const accumulateAssistant: <E extends {
1483
- id: string;
1484
- role: string;
1439
+ export declare const accumulateAssistant: <E extends {
1440
+ id: string;
1441
+ role: string;
1485
1442
  }>(transcript: readonly E[], delta: string) => (E | AssistantTurn)[];
1486
1443
  /**
1487
1444
  * replaceAssistant sets the last assistant turn's full text (a settled `message`
@@ -1509,11 +1466,10 @@ declare const accumulateAssistant: <E extends {
1509
1466
  * conversation reads as the assistant's side alone. Restoring both sides needs the
1510
1467
  * run's transcript read back from the API rather than reconstructed from its events.
1511
1468
  */
1512
- declare const replaceAssistant: <E extends {
1513
- id: string;
1514
- role: string;
1469
+ export declare const replaceAssistant: <E extends {
1470
+ id: string;
1471
+ role: string;
1515
1472
  }>(transcript: readonly E[], content: string, messageIndex?: number) => (E | AssistantTurn)[];
1516
-
1517
1473
  /**
1518
1474
  * ConversationWriter is the narrow store surface a fault writes through: the
1519
1475
  * error turn it appends, the run id it drops, and the lifecycle state it parks
@@ -1523,9 +1479,9 @@ declare const replaceAssistant: <E extends {
1523
1479
  * caller and never enters this module.
1524
1480
  */
1525
1481
  interface ConversationWriter {
1526
- appendError(message: string): void;
1527
- setRunId(runId: string | null): void;
1528
- setSessionState(state: AgentEngineState): void;
1482
+ appendError(message: string): void;
1483
+ setRunId(runId: string | null): void;
1484
+ setSessionState(state: AgentEngineState): void;
1529
1485
  }
1530
1486
  /**
1531
1487
  * ConversationFaultCopy is the already-localized copy a fault surfaces, so this
@@ -1537,33 +1493,33 @@ interface ConversationWriter {
1537
1493
  * rateLimited and tooLarge are the refusals of a request the gateway would not take as sent.
1538
1494
  */
1539
1495
  interface ConversationFaultCopy {
1540
- generic: string;
1541
- missingOrganization: string;
1542
- /**
1543
- * What a viewer reads when the run is refused for their role or their membership: a 403, or the
1544
- * 404 a start answers for an organization the reader does not belong to. A 404 refusing the
1545
- * stream of a run that opened is a run the gateway no longer holds, and reads `generic`.
1546
- */
1547
- noAccess: string;
1548
- /** What a viewer reads when the organization has no AI provider configured (409). */
1549
- notConfigured: string;
1550
- /**
1551
- * What a viewer reads when the organization's agreement does not include the product (402):
1552
- * a fact a retry never changes.
1553
- */
1554
- notEntitled: string;
1555
- /**
1556
- * What a viewer reads when the gateway refused a start or a follow-up for its rate (429) after
1557
- * the client's own waits ran out: a moment later, the same message goes through.
1558
- */
1559
- rateLimited: string;
1560
- /**
1561
- * What a viewer reads when the gateway refused a start or a follow-up as too large (413): the
1562
- * body over its ceiling, or what the run would be handed, the tools the page provides included,
1563
- * over the payload bound once encoded. The same request meets the same answer, so the line
1564
- * says what changes it rather than asking for a retry.
1565
- */
1566
- tooLarge: string;
1496
+ generic: string;
1497
+ missingOrganization: string;
1498
+ /**
1499
+ * What a viewer reads when the run is refused for their role or their membership: a 403, or the
1500
+ * 404 a start answers for an organization the reader does not belong to. A 404 refusing the
1501
+ * stream of a run that opened is a run the gateway no longer holds, and reads `generic`.
1502
+ */
1503
+ noAccess: string;
1504
+ /** What a viewer reads when the organization has no AI provider configured (409). */
1505
+ notConfigured: string;
1506
+ /**
1507
+ * What a viewer reads when the organization's agreement does not include the product (402):
1508
+ * a fact a retry never changes.
1509
+ */
1510
+ notEntitled: string;
1511
+ /**
1512
+ * What a viewer reads when the gateway refused a start or a follow-up for its rate (429) after
1513
+ * the client's own waits ran out: a moment later, the same message goes through.
1514
+ */
1515
+ rateLimited: string;
1516
+ /**
1517
+ * What a viewer reads when the gateway refused a start or a follow-up as too large (413): the
1518
+ * body over its ceiling, or what the run would be handed, the tools the page provides included,
1519
+ * over the payload bound once encoded. The same request meets the same answer, so the line
1520
+ * says what changes it rather than asking for a retry.
1521
+ */
1522
+ tooLarge: string;
1567
1523
  }
1568
1524
  /**
1569
1525
  * ConversationFaultsConfig is what one conversation's fault handling writes through: the
@@ -1571,50 +1527,50 @@ interface ConversationFaultCopy {
1571
1527
  * seams the host answers.
1572
1528
  */
1573
1529
  interface ConversationFaultsConfig {
1574
- copy: ConversationFaultCopy;
1575
- /**
1576
- * invalidateAiConfig refreshes the organization's AI-config read after the
1577
- * gateway reports the credential is gone, so the surface flips to its setup
1578
- * card instead of offering a conversation that cannot start.
1579
- *
1580
- * Optional, because its absence is a defined answer rather than a gap: a host with no
1581
- * cache of its own has nothing to mark stale, and the config is re-read on the next
1582
- * natural fetch. The fault still surfaces its message either way: the invalidation
1583
- * only decides how soon the surface notices the credential is gone. It is called once the
1584
- * fault is written, and one that throws reaches the program as an uncaught error on a
1585
- * microtask, so the fault is written whatever it does.
1586
- */
1587
- invalidateAiConfig?(organizationId: string): void;
1588
- /**
1589
- * invalidateMemberships marks the viewer's memberships stale after the gateway refused or
1590
- * ended a run for want of access, so the surface's notice follows the role the viewer holds
1591
- * now: a start, or the stream of the run it opened, answered 402, 403 or 404, and a follow-up
1592
- * the gateway answered 404 because its run is closed, which is what becomes of a run whose
1593
- * member lost access to its organization.
1594
- *
1595
- * Optional, for the reason {@link ConversationFaultsConfig.invalidateAiConfig} is: a host with
1596
- * no cache of its own re-reads the memberships on its next natural fetch, and the fault still
1597
- * surfaces its message either way. Called as that one is, once the fault is written.
1598
- */
1599
- invalidateMemberships?(): void;
1600
- /**
1601
- * onSignInRefused tells the host the API refused the credential the conversation runs on: a
1602
- * run's start, the stream of a run it opened or reconnected to, or a follow-up was answered 401.
1603
- * Under the browser's own session that is a sign-in the API no longer accepts, so the host asks
1604
- * whether the person is still signed in and, when nobody is, sends them to sign in.
1605
- *
1606
- * Called once per refusal, as the invalidations are, once the fault is written. A 401 says
1607
- * nothing of the viewer's access, so the memberships are not read again for it. Optional, for
1608
- * the reason {@link ConversationFaultsConfig.invalidateAiConfig} is: the fault still surfaces
1609
- * its message either way.
1610
- */
1611
- onSignInRefused?: (() => void) | undefined;
1612
- /**
1613
- * onSettled runs after a fault is written, for a host that mirrors run ids into the URL, as
1614
- * the co-pilot does.
1615
- */
1616
- onSettled?(): void;
1617
- writer: ConversationWriter;
1530
+ copy: ConversationFaultCopy;
1531
+ /**
1532
+ * invalidateAiConfig refreshes the organization's AI-config read after the
1533
+ * gateway reports the credential is gone, so the surface flips to its setup
1534
+ * card instead of offering a conversation that cannot start.
1535
+ *
1536
+ * Optional, because its absence is a defined answer rather than a gap: a host with no
1537
+ * cache of its own has nothing to mark stale, and the config is re-read on the next
1538
+ * natural fetch. The fault still surfaces its message either way: the invalidation
1539
+ * only decides how soon the surface notices the credential is gone. It is called once the
1540
+ * fault is written, and one that throws reaches the program as an uncaught error on a
1541
+ * microtask, so the fault is written whatever it does.
1542
+ */
1543
+ invalidateAiConfig?(organizationId: string): void;
1544
+ /**
1545
+ * invalidateMemberships marks the viewer's memberships stale after the gateway refused or
1546
+ * ended a run for want of access, so the surface's notice follows the role the viewer holds
1547
+ * now: a start, or the stream of the run it opened, answered 402, 403 or 404, and a follow-up
1548
+ * the gateway answered 404 because its run is closed, which is what becomes of a run whose
1549
+ * member lost access to its organization.
1550
+ *
1551
+ * Optional, for the reason {@link ConversationFaultsConfig.invalidateAiConfig} is: a host with
1552
+ * no cache of its own re-reads the memberships on its next natural fetch, and the fault still
1553
+ * surfaces its message either way. Called as that one is, once the fault is written.
1554
+ */
1555
+ invalidateMemberships?(): void;
1556
+ /**
1557
+ * onSignInRefused tells the host the API refused the credential the conversation runs on: a
1558
+ * run's start, the stream of a run it opened or reconnected to, or a follow-up was answered 401.
1559
+ * Under the browser's own session that is a sign-in the API no longer accepts, so the host asks
1560
+ * whether the person is still signed in and, when nobody is, sends them to sign in.
1561
+ *
1562
+ * Called once per refusal, as the invalidations are, once the fault is written. A 401 says
1563
+ * nothing of the viewer's access, so the memberships are not read again for it. Optional, for
1564
+ * the reason {@link ConversationFaultsConfig.invalidateAiConfig} is: the fault still surfaces
1565
+ * its message either way.
1566
+ */
1567
+ onSignInRefused?: (() => void) | undefined;
1568
+ /**
1569
+ * onSettled runs after a fault is written, for a host that mirrors run ids into the URL, as
1570
+ * the co-pilot does.
1571
+ */
1572
+ onSettled?(): void;
1573
+ writer: ConversationWriter;
1618
1574
  }
1619
1575
  /**
1620
1576
  * ConversationFaults is the ways a conversation fails outside its own event
@@ -1628,40 +1584,40 @@ interface ConversationFaultsConfig {
1628
1584
  * may leave behind.
1629
1585
  */
1630
1586
  interface ConversationFaults {
1631
- /**
1632
- * handleStartError maps a rejection of the run's start or of its read onto the surface's copy.
1633
- *
1634
- * @param organizationId The organization the run was started in.
1635
- * @param error What the start rejected with.
1636
- * @param runId The run the start opened, when it was the run's stream that failed, as
1637
- * `ConversationHostConfig.onStartError` reports it. A 404 then says the gateway no longer
1638
- * holds the run (it expired, or its member lost the write role it was started under), and
1639
- * reads the generic copy rather than the no-access one a refused start reads.
1640
- */
1641
- handleStartError(organizationId: string, error: unknown, runId?: string | undefined): void;
1642
- missingOrganization(): void;
1643
- /**
1644
- * recover surfaces the copy of a follow-up's failure and re-enables input: the too-large or the
1645
- * rate-limited line for a 413 or a 429, and the generic one otherwise.
1646
- *
1647
- * @param runGone Whether the failure says the run is gone, as
1648
- * `ConversationHostConfig.onSendFault` reports it. The run id is dropped only then, so a
1649
- * reload resumes a run the conversation kept and never one it has left.
1650
- * @param error What the follow-up failed with. The memberships are read again only when the
1651
- * gateway answered it 404, which is what a run closed for want of access answers, and never
1652
- * for the engine's own refusal of a run it already let go.
1653
- */
1654
- recover(runGone: boolean, error?: unknown): void;
1655
- /**
1656
- * resumeFailed settles a conversation whose reconnect to the run it held failed for good, as
1657
- * `ConversationHost.resume` reports it: the run id is dropped, so a reload reconnects to no run
1658
- * that is gone, and input is re-enabled. It writes no line: the transcript the reconnect would
1659
- * have continued stands as it was, and the next message opens a run.
1660
- *
1661
- * @param error What the reconnect failed with. A 401 tells the host the API refused its
1662
- * credential, as a start's does (see {@link ConversationFaultsConfig.onSignInRefused}).
1663
- */
1664
- resumeFailed(error: unknown): void;
1587
+ /**
1588
+ * handleStartError maps a rejection of the run's start or of its read onto the surface's copy.
1589
+ *
1590
+ * @param organizationId The organization the run was started in.
1591
+ * @param error What the start rejected with.
1592
+ * @param runId The run the start opened, when it was the run's stream that failed, as
1593
+ * `ConversationHostConfig.onStartError` reports it. A 404 then says the gateway no longer
1594
+ * holds the run (it expired, or its member lost the write role it was started under), and
1595
+ * reads the generic copy rather than the no-access one a refused start reads.
1596
+ */
1597
+ handleStartError(organizationId: string, error: unknown, runId?: string | undefined): void;
1598
+ missingOrganization(): void;
1599
+ /**
1600
+ * recover surfaces the copy of a follow-up's failure and re-enables input: the too-large or the
1601
+ * rate-limited line for a 413 or a 429, and the generic one otherwise.
1602
+ *
1603
+ * @param runGone Whether the failure says the run is gone, as
1604
+ * `ConversationHostConfig.onSendFault` reports it. The run id is dropped only then, so a
1605
+ * reload resumes a run the conversation kept and never one it has left.
1606
+ * @param error What the follow-up failed with. The memberships are read again only when the
1607
+ * gateway answered it 404, which is what a run closed for want of access answers, and never
1608
+ * for the engine's own refusal of a run it already let go.
1609
+ */
1610
+ recover(runGone: boolean, error?: unknown): void;
1611
+ /**
1612
+ * resumeFailed settles a conversation whose reconnect to the run it held failed for good, as
1613
+ * `ConversationHost.resume` reports it: the run id is dropped, so a reload reconnects to no run
1614
+ * that is gone, and input is re-enabled. It writes no line: the transcript the reconnect would
1615
+ * have continued stands as it was, and the next message opens a run.
1616
+ *
1617
+ * @param error What the reconnect failed with. A 401 tells the host the API refused its
1618
+ * credential, as a start's does (see {@link ConversationFaultsConfig.onSignInRefused}).
1619
+ */
1620
+ resumeFailed(error: unknown): void;
1665
1621
  }
1666
1622
  /**
1667
1623
  * createConversationFaults binds the shared fault handling to one conversation's
@@ -1673,8 +1629,7 @@ interface ConversationFaults {
1673
1629
  * Dropping the run id keeps a reload from resuming a run the conversation has left: a
1674
1630
  * start that failed, or a run a follow-up found gone.
1675
1631
  */
1676
- declare const createConversationFaults: (config: ConversationFaultsConfig) => ConversationFaults;
1677
-
1632
+ export declare const createConversationFaults: (config: ConversationFaultsConfig) => ConversationFaults;
1678
1633
  /**
1679
1634
  * ConversationHostConfig wires a host to one conversation's world: how it records
1680
1635
  * the user's turn, resolves the run's organization and point-in-time context,
@@ -1684,58 +1639,58 @@ declare const createConversationFaults: (config: ConversationFaultsConfig) => Co
1684
1639
  * them: the host itself knows only the start/send/resume lifecycle.
1685
1640
  */
1686
1641
  interface ConversationHostConfig {
1687
- /** appendUserMessage records the user's outgoing turn before the run is touched. */
1688
- appendUserMessage(message: string): void;
1689
- /**
1690
- * buildContext resolves the point-in-time snapshot the run opens with, or
1691
- * undefined for a contextless start. It must not reject (a snapshot failure
1692
- * resolves undefined), so only a start rejection routes to onStartError.
1693
- */
1694
- buildContext(): Promise<Record<string, unknown> | undefined>;
1695
- /** buildSession builds a fresh session wired to the surface's observer. */
1696
- buildSession(): AgentEngine;
1697
- /** onMissingOrganization surfaces that there is no resource to scope a run to. */
1698
- onMissingOrganization(): void;
1699
- /**
1700
- * onSendFault reports a follow-up message that did not reach its run.
1701
- *
1702
- * @param error What the send rejected with.
1703
- * @param runGone Whether the failure says the run is gone: the engine refused the message
1704
- * (the run ended, or the engine was disposed) or the gateway answered 404. The host then
1705
- * clears its guard and the next message opens a new run. Otherwise the run is kept, and
1706
- * the next message is posted into it.
1707
- */
1708
- onSendFault(error: unknown, runGone: boolean): void;
1709
- /**
1710
- * onStartError maps a rejection of the run's start or of its read onto the surface's copy.
1711
- *
1712
- * @param organizationId The organization the run was started in.
1713
- * @param error What the start rejected with.
1714
- * @param runId The run the start opened, when its post answered and its stream then failed for
1715
- * good. Absent when the start opened no run: the gateway refused it, or it never reached the
1716
- * gateway. A status means something else on each: a 404 refusing the start is an
1717
- * organization the reader does not reach, and a 404 refusing the stream of an opened run is
1718
- * a run the gateway no longer holds.
1719
- */
1720
- onStartError(organizationId: string, error: unknown, runId?: string | undefined): void;
1721
- /**
1722
- * routeForMessage lets the surface pick the tool set this turn should offer
1723
- * before the message reaches the run. It is called for every message, first
1724
- * one included, so the run OPENS on the routed set rather than being narrowed
1725
- * only from the second turn on. Optional: a surface with no router omits it and
1726
- * the session offers every permitted tool.
1727
- */
1728
- routeForMessage?(message: string): void;
1729
- /**
1730
- * routeForState lets the surface re-pick the tool set from LIVE state, with no
1731
- * new message. It is what makes a surface the run itself unlocks reachable: a
1732
- * router keyed only on the user's words cannot know that the run just opened a
1733
- * suggest session, so without this the tools it unlocked stay invisible until
1734
- * the user happens to type again. Optional, exactly as routeForMessage.
1735
- */
1736
- routeForState?(): void;
1737
- /** resolveOrganizationId reads the org that owns the resource the run acts on. */
1738
- resolveOrganizationId(): string | null | undefined;
1642
+ /** appendUserMessage records the user's outgoing turn before the run is touched. */
1643
+ appendUserMessage(message: string): void;
1644
+ /**
1645
+ * buildContext resolves the point-in-time snapshot the run opens with, or
1646
+ * undefined for a contextless start. It must not reject (a snapshot failure
1647
+ * resolves undefined), so only a start rejection routes to onStartError.
1648
+ */
1649
+ buildContext(): Promise<Record<string, unknown> | undefined>;
1650
+ /** buildSession builds a fresh session wired to the surface's observer. */
1651
+ buildSession(): AgentEngine;
1652
+ /** onMissingOrganization surfaces that there is no resource to scope a run to. */
1653
+ onMissingOrganization(): void;
1654
+ /**
1655
+ * onSendFault reports a follow-up message that did not reach its run.
1656
+ *
1657
+ * @param error What the send rejected with.
1658
+ * @param runGone Whether the failure says the run is gone: the engine refused the message
1659
+ * (the run ended, or the engine was disposed) or the gateway answered 404. The host then
1660
+ * clears its guard and the next message opens a new run. Otherwise the run is kept, and
1661
+ * the next message is posted into it.
1662
+ */
1663
+ onSendFault(error: unknown, runGone: boolean): void;
1664
+ /**
1665
+ * onStartError maps a rejection of the run's start or of its read onto the surface's copy.
1666
+ *
1667
+ * @param organizationId The organization the run was started in.
1668
+ * @param error What the start rejected with.
1669
+ * @param runId The run the start opened, when its post answered and its stream then failed for
1670
+ * good. Absent when the start opened no run: the gateway refused it, or it never reached the
1671
+ * gateway. A status means something else on each: a 404 refusing the start is an
1672
+ * organization the reader does not reach, and a 404 refusing the stream of an opened run is
1673
+ * a run the gateway no longer holds.
1674
+ */
1675
+ onStartError(organizationId: string, error: unknown, runId?: string | undefined): void;
1676
+ /**
1677
+ * routeForMessage lets the surface pick the tool set this turn should offer
1678
+ * before the message reaches the run. It is called for every message, first
1679
+ * one included, so the run OPENS on the routed set rather than being narrowed
1680
+ * only from the second turn on. Optional: a surface with no router omits it and
1681
+ * the session offers every permitted tool.
1682
+ */
1683
+ routeForMessage?(message: string): void;
1684
+ /**
1685
+ * routeForState lets the surface re-pick the tool set from LIVE state, with no
1686
+ * new message. It is what makes a surface the run itself unlocks reachable: a
1687
+ * router keyed only on the user's words cannot know that the run just opened a
1688
+ * suggest session, so without this the tools it unlocked stay invisible until
1689
+ * the user happens to type again. Optional, exactly as routeForMessage.
1690
+ */
1691
+ routeForState?(): void;
1692
+ /** resolveOrganizationId reads the org that owns the resource the run acts on. */
1693
+ resolveOrganizationId(): string | null | undefined;
1739
1694
  }
1740
1695
  /**
1741
1696
  * ConversationHost is one AI conversation's session lifecycle: it opens a run on
@@ -1751,55 +1706,55 @@ interface ConversationHostConfig {
1751
1706
  * alone recovers the conversation.
1752
1707
  */
1753
1708
  interface ConversationHost {
1754
- /**
1755
- * dispose aborts the session's open stream and parked consumer; idempotent.
1756
- *
1757
- * It asks the gateway nothing, so the run goes on there, and the host keeps where the session
1758
- * stood in it: a {@link ConversationHost.resume} of that run is read on from that position by
1759
- * the session it builds, and hands the conversation nothing a second time.
1760
- */
1761
- dispose(): void;
1762
- /** finish asks the run to close (POST close), then disposes the session. */
1763
- finish(): void;
1764
- /**
1765
- * reroute re-reads the router from live state and carries the resulting tool
1766
- * set into the open run. A no-op when no run is open, and free when the
1767
- * selection has not moved: the session drops an unchanged manifest itself.
1768
- */
1769
- reroute(): void;
1770
- /**
1771
- * restart ends the conversation's run and eagerly swaps in a fresh session: it asks the run to
1772
- * close (POST close), as {@link ConversationHost.finish} does, then disposes the live session
1773
- * and builds the next one. The close covers a run the session gave up reading and still owes
1774
- * one, so a stopped run spends no more of the gateway's model budget.
1775
- */
1776
- restart(): void;
1777
- /**
1778
- * resume builds the session so its observer is wired the moment the conversation
1779
- * mounts, and reconnects a persisted run exactly once. A null run id primes the
1780
- * session without reconnecting; a resume fault clears the guard then calls
1781
- * onFault with what the reconnect failed with, and a resumed run that ends clears the
1782
- * guard without calling it. A resume that a later start or a restart replaced does
1783
- * neither.
1784
- *
1785
- * The run is read on from where the session a {@link ConversationHost.dispose} tore down
1786
- * stood in it, when that session read this run and its stream named a position. With no such
1787
- * position (a host built after a reload, another run, a run that a finish or a restart
1788
- * closed) the gateway answers with the run's history from its first event.
1789
- */
1790
- resume(runId: string | null | undefined, onFault: (error: unknown) => void): void;
1791
- /**
1792
- * submit opens a run on the first message, and on the first message after a run ended,
1793
- * or sends the follow-up into the open run.
1794
- *
1795
- * A follow-up submitted before that run has its id (while its context is captured, or while
1796
- * its start is still being posted) is held and delivered once the run opens, the routed
1797
- * tool set ahead of it. When the start fails, the held follow-up is dropped and
1798
- * `onStartError` is the one report: `onSendFault` is for a message that failed on its way
1799
- * into a run that was open. A follow-up that fails keeps the run unless the failure says the
1800
- * run is gone (see {@link ConversationHostConfig.onSendFault}).
1801
- */
1802
- submit(message: string): void;
1709
+ /**
1710
+ * dispose aborts the session's open stream and parked consumer; idempotent.
1711
+ *
1712
+ * It asks the gateway nothing, so the run goes on there, and the host keeps where the session
1713
+ * stood in it: a {@link ConversationHost.resume} of that run is read on from that position by
1714
+ * the session it builds, and hands the conversation nothing a second time.
1715
+ */
1716
+ dispose(): void;
1717
+ /** finish asks the run to close (POST close), then disposes the session. */
1718
+ finish(): void;
1719
+ /**
1720
+ * reroute re-reads the router from live state and carries the resulting tool
1721
+ * set into the open run. A no-op when no run is open, and free when the
1722
+ * selection has not moved: the session drops an unchanged manifest itself.
1723
+ */
1724
+ reroute(): void;
1725
+ /**
1726
+ * restart ends the conversation's run and eagerly swaps in a fresh session: it asks the run to
1727
+ * close (POST close), as {@link ConversationHost.finish} does, then disposes the live session
1728
+ * and builds the next one. The close covers a run the session gave up reading and still owes
1729
+ * one, so a stopped run spends no more of the gateway's model budget.
1730
+ */
1731
+ restart(): void;
1732
+ /**
1733
+ * resume builds the session so its observer is wired the moment the conversation
1734
+ * mounts, and reconnects a persisted run exactly once. A null run id primes the
1735
+ * session without reconnecting; a resume fault clears the guard then calls
1736
+ * onFault with what the reconnect failed with, and a resumed run that ends clears the
1737
+ * guard without calling it. A resume that a later start or a restart replaced does
1738
+ * neither.
1739
+ *
1740
+ * The run is read on from where the session a {@link ConversationHost.dispose} tore down
1741
+ * stood in it, when that session read this run and its stream named a position. With no such
1742
+ * position (a host built after a reload, another run, a run that a finish or a restart
1743
+ * closed) the gateway answers with the run's history from its first event.
1744
+ */
1745
+ resume(runId: string | null | undefined, onFault: (error: unknown) => void): void;
1746
+ /**
1747
+ * submit opens a run on the first message, and on the first message after a run ended,
1748
+ * or sends the follow-up into the open run.
1749
+ *
1750
+ * A follow-up submitted before that run has its id (while its context is captured, or while
1751
+ * its start is still being posted) is held and delivered once the run opens, the routed
1752
+ * tool set ahead of it. When the start fails, the held follow-up is dropped and
1753
+ * `onStartError` is the one report: `onSendFault` is for a message that failed on its way
1754
+ * into a run that was open. A follow-up that fails keeps the run unless the failure says the
1755
+ * run is gone (see {@link ConversationHostConfig.onSendFault}).
1756
+ */
1757
+ submit(message: string): void;
1803
1758
  }
1804
1759
  /**
1805
1760
  * createConversationHost builds the session lifecycle for one AI conversation over
@@ -1813,8 +1768,7 @@ interface ConversationHost {
1813
1768
  * position a teardown parked), and a split would pass that state between modules for no
1814
1769
  * reader's benefit.
1815
1770
  */
1816
- declare const createConversationHost: (config: ConversationHostConfig) => ConversationHost;
1817
-
1771
+ export declare const createConversationHost: (config: ConversationHostConfig) => ConversationHost;
1818
1772
  /**
1819
1773
  * toWireErrorCode narrows a bus failure code to the vocabulary the wire carries.
1820
1774
  *
@@ -1836,8 +1790,7 @@ declare const createConversationHost: (config: ConversationHostConfig) => Conver
1836
1790
  * @returns The code when the wire carries it, `internal` for any other code, and undefined for
1837
1791
  * none.
1838
1792
  */
1839
- declare const toWireErrorCode: (code: string | undefined) => AgentToolErrorCode | undefined;
1840
-
1793
+ export declare const toWireErrorCode: (code: string | undefined) => AgentToolErrorCode | undefined;
1841
1794
  /**
1842
1795
  * AgentScriptedTransport is an {@link AgentTransport} that reaches no server, with the two
1843
1796
  * controls a test or an offline demo drives a run's stream by. It is what
@@ -1881,18 +1834,18 @@ declare const toWireErrorCode: (code: string | undefined) => AgentToolErrorCode
1881
1834
  * ```
1882
1835
  */
1883
1836
  interface AgentScriptedTransport extends AgentTransport {
1884
- /**
1885
- * endRun pushes the terminal `done`, with the reason `completed`, into the run's stream. Every
1886
- * read of the run ends on it with `onClose("terminal")`. A run that was never started is
1887
- * ignored.
1888
- */
1889
- endRun: (runId: string) => void;
1890
- /**
1891
- * pushEvents appends events to the run's stream, in order, as they would arrive off the wire.
1892
- * A subscriber waiting on the stream receives them at once, and one that subscribes later
1893
- * receives them in the replay. A run that was never started is ignored.
1894
- */
1895
- pushEvents: (runId: string, events: readonly AgentEvent[]) => void;
1837
+ /**
1838
+ * endRun pushes the terminal `done`, with the reason `completed`, into the run's stream. Every
1839
+ * read of the run ends on it with `onClose("terminal")`. A run that was never started is
1840
+ * ignored.
1841
+ */
1842
+ endRun: (runId: string) => void;
1843
+ /**
1844
+ * pushEvents appends events to the run's stream, in order, as they would arrive off the wire.
1845
+ * A subscriber waiting on the stream receives them at once, and one that subscribes later
1846
+ * receives them in the replay. A run that was never started is ignored.
1847
+ */
1848
+ pushEvents: (runId: string, events: readonly AgentEvent[]) => void;
1896
1849
  }
1897
1850
  /**
1898
1851
  * createAgentScriptedTransport is the transport that reaches no server: each run owns a single
@@ -1914,15 +1867,14 @@ interface AgentScriptedTransport extends AgentTransport {
1914
1867
  * @param resolve Answers the events of the turn a user message opens, the start's message
1915
1868
  * included.
1916
1869
  */
1917
- declare const createAgentScriptedTransport: (resolve: (message: string) => AgentEvent[]) => AgentScriptedTransport;
1918
-
1870
+ export declare const createAgentScriptedTransport: (resolve: (message: string) => AgentEvent[]) => AgentScriptedTransport;
1919
1871
  /**
1920
1872
  * STICK_TO_BOTTOM_THRESHOLD_PX is the slack, in pixels, within which a scroll
1921
1873
  * viewport still counts as sitting at its bottom. A few pixels absorb sub-pixel
1922
1874
  * layout rounding and the gap between a new row mounting and its height settling,
1923
1875
  * so a reader parked on the latest turn is never misread as having scrolled up.
1924
1876
  */
1925
- declare const STICK_TO_BOTTOM_THRESHOLD_PX = 24;
1877
+ export declare const STICK_TO_BOTTOM_THRESHOLD_PX = 24;
1926
1878
  /**
1927
1879
  * ScrollViewportGeometry is the three measurements of a scroll viewport that
1928
1880
  * {@link isPinnedToBottom} reads: how tall the viewport is, how tall its content is,
@@ -1933,9 +1885,9 @@ declare const STICK_TO_BOTTOM_THRESHOLD_PX = 24;
1933
1885
  * supplies the numbers from whatever it scrolls. A DOM element passes as it is.
1934
1886
  */
1935
1887
  interface ScrollViewportGeometry {
1936
- readonly clientHeight: number;
1937
- readonly scrollHeight: number;
1938
- readonly scrollTop: number;
1888
+ readonly clientHeight: number;
1889
+ readonly scrollHeight: number;
1890
+ readonly scrollTop: number;
1939
1891
  }
1940
1892
  /**
1941
1893
  * isPinnedToBottom reports whether a scroll viewport is at (or within
@@ -1948,8 +1900,7 @@ interface ScrollViewportGeometry {
1948
1900
  * at its bottom.
1949
1901
  * @default threshold {@link STICK_TO_BOTTOM_THRESHOLD_PX}
1950
1902
  */
1951
- declare const isPinnedToBottom: (viewport: ScrollViewportGeometry, threshold?: number) => boolean;
1952
-
1903
+ export declare const isPinnedToBottom: (viewport: ScrollViewportGeometry, threshold?: number) => boolean;
1953
1904
  /**
1954
1905
  * MAX_TOOL_RESULT_DATA_BYTES caps the structured payload one client tool result
1955
1906
  * puts into the run's transcript. The transcript is replayed in full on every
@@ -1957,7 +1908,7 @@ declare const isPinnedToBottom: (viewport: ScrollViewportGeometry, threshold?: n
1957
1908
  * each one; the gateway applies its own, larger cap to the whole result envelope
1958
1909
  * behind this.
1959
1910
  */
1960
- declare const MAX_TOOL_RESULT_DATA_BYTES = 4096;
1911
+ export declare const MAX_TOOL_RESULT_DATA_BYTES = 4096;
1961
1912
  /**
1962
1913
  * ToolResultPayload is the envelope a client tool's result rides in on a `tool-result` input:
1963
1914
  * the human summary the model reads, the data it acted on, and the truncation report when that
@@ -1969,17 +1920,17 @@ declare const MAX_TOOL_RESULT_DATA_BYTES = 4096;
1969
1920
  * prompt is written against it.
1970
1921
  */
1971
1922
  type ToolResultPayload = {
1972
- data?: unknown;
1973
- /** How many items of a truncated collection were sent. */
1974
- returned?: number | undefined;
1975
- /** The host's state delta the call produced, when the run asked for one. */
1976
- state?: Record<string, unknown> | undefined;
1977
- summary?: string | undefined;
1978
- /** How many items the collection held before truncation. */
1979
- total?: number | undefined;
1980
- truncated?: boolean | undefined;
1981
- /** Which field of a record was the one truncated, when it was a record rather than an array. */
1982
- truncatedField?: string | undefined;
1923
+ data?: unknown;
1924
+ /** How many items of a truncated collection were sent. */
1925
+ returned?: number | undefined;
1926
+ /** The host's state delta the call produced, when the run asked for one. */
1927
+ state?: Record<string, unknown> | undefined;
1928
+ summary?: string | undefined;
1929
+ /** How many items the collection held before truncation. */
1930
+ total?: number | undefined;
1931
+ truncated?: boolean | undefined;
1932
+ /** Which field of a record was the one truncated, when it was a record rather than an array. */
1933
+ truncatedField?: string | undefined;
1983
1934
  };
1984
1935
  /**
1985
1936
  * buildToolResultPayload assembles the result a client tool posts back, trimming
@@ -2010,7 +1961,6 @@ type ToolResultPayload = {
2010
1961
  * an object, an array, or absent. It is passed in rather than derived here because
2011
1962
  * only the caller holds the before and after readings.
2012
1963
  */
2013
- declare const buildToolResultPayload: (summary: string, data: unknown, state?: Record<string, unknown>) => ToolResultPayload;
2014
-
2015
- export { AgentEngine, MAX_TOOL_INPUT_CHARS, MAX_TOOL_RESULT_DATA_BYTES, STICK_TO_BOTTOM_THRESHOLD_PX, accumulateAssistant, answerQuestionEntry, appendActivityEntry, appendErrorEntry, appendQuestionEntry, appendSuggestionsEntry, appendUserEntry, appendWarningEntry, boundedInputJson, buildToolResultPayload, chooseSuggestionEntry, createAgentScriptedTransport, createConversationFaults, createConversationHost, isPinnedToBottom, mintEntryId, replaceAssistant, resolveAgentError, settleActivityEntry, settleOpenQuestionEntries, settleOpenSuggestionEntries, toWireErrorCode };
1964
+ export declare const buildToolResultPayload: (summary: string, data: unknown, state?: Record<string, unknown>) => ToolResultPayload;
2016
1965
  export type { ActivityEntry, ActivityStatus, AgentBudgetCopy, AgentDraftWarning, AgentEngineConfig, AgentEngineState, AgentErrorCopy, AgentObserver, AgentScriptedTransport, AgentStreamPosition, AgentToolContext, AssistantTurn, ConversationFaultCopy, ConversationFaults, ConversationFaultsConfig, ConversationHost, ConversationHostConfig, ConversationState, ConversationWriter, MessageEntry, PendingConfirmation, QuestionEntry, QuestionOption, RecoveryLookup, ScrollViewportGeometry, ServerToolConfirmation, StateDelta, SuggestionCardCandidate, SuggestionsEntry, ToolActivityOutcome, ToolDispatchResult, ToolDispatcher, ToolManifestEntry, ToolResultPayload, TranscriptEntry, TranscriptRole, WarningEntry };
1966
+ //# sourceMappingURL=index.d.cts.map