@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.
- package/CHANGELOG.md +38 -0
- package/README.md +4 -3
- package/THIRD-PARTY-NOTICES.txt +1 -1
- package/dist/agent/index.cjs +1152 -1905
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +1152 -1202
- package/dist/agent/index.d.ts +1152 -1202
- package/dist/agent/index.js +1147 -1903
- package/dist/agent/index.js.map +1 -1
- package/dist/camera/index.cjs +2470 -3435
- package/dist/camera/index.cjs.map +1 -1
- package/dist/camera/index.d.cts +716 -744
- package/dist/camera/index.d.ts +716 -744
- package/dist/camera/index.js +2438 -3323
- package/dist/camera/index.js.map +1 -1
- package/dist/{units-D9mBrusY.d.cts → chunk-5pTPpv4v.d.cts} +38 -41
- package/dist/{units-D9mBrusY.d.ts → chunk-5pTPpv4v.d.ts} +38 -41
- package/dist/{order-BLhsGsH8.d.ts → chunk-6JzFMFHh.d.ts} +15 -28
- package/dist/chunk-6qyuJVvt.d.ts +513 -0
- package/dist/chunk-9fp0lDic.cjs +583 -0
- package/dist/chunk-9fp0lDic.cjs.map +1 -0
- package/dist/{zones-B05QA8fy.d.ts → chunk-A48H1rDg.d.cts} +2 -4
- package/dist/{zones-B05QA8fy.d.cts → chunk-A48H1rDg.d.ts} +2 -4
- package/dist/chunk-B-m1AchR.cjs +57 -0
- package/dist/chunk-B-m1AchR.cjs.map +1 -0
- package/dist/{bundle-xYrrbJTH.d.ts → chunk-B-qFTf04.d.ts} +51 -57
- package/dist/chunk-B0YROiZh.d.cts +1475 -0
- package/dist/chunk-B14wgOvH.d.cts +68 -0
- package/dist/chunk-B19l3j9r.cjs +150 -0
- package/dist/chunk-B19l3j9r.cjs.map +1 -0
- package/dist/chunk-B2PtjVKg.cjs +86 -0
- package/dist/chunk-B2PtjVKg.cjs.map +1 -0
- package/dist/chunk-B56Oyb7W.cjs +70 -0
- package/dist/chunk-B56Oyb7W.cjs.map +1 -0
- package/dist/chunk-B5WGMQwK.cjs +113 -0
- package/dist/chunk-B5WGMQwK.cjs.map +1 -0
- package/dist/{types-nO2joeRk.d.ts → chunk-B98mKrdu.d.cts} +103 -122
- package/dist/{videoOverlay-Dh_D5_Zs.d.ts → chunk-BB0PmqIM.d.cts} +10 -10
- package/dist/chunk-BBikve0Z.cjs +269 -0
- package/dist/chunk-BBikve0Z.cjs.map +1 -0
- package/dist/chunk-BHeXmM0X.js +37 -0
- package/dist/chunk-BHeXmM0X.js.map +1 -0
- package/dist/chunk-BI8WZLpU.cjs +281 -0
- package/dist/chunk-BI8WZLpU.cjs.map +1 -0
- package/dist/chunk-BIEc_SkR.cjs +29 -0
- package/dist/chunk-BIEc_SkR.cjs.map +1 -0
- package/dist/chunk-BJ6L6_W9.cjs +553 -0
- package/dist/chunk-BJ6L6_W9.cjs.map +1 -0
- package/dist/chunk-BJ91UCbB.js +11 -0
- package/dist/chunk-BJ91UCbB.js.map +1 -0
- package/dist/chunk-BJEZWTKj.cjs +166 -0
- package/dist/chunk-BJEZWTKj.cjs.map +1 -0
- package/dist/chunk-BJz54mfg.cjs +10 -0
- package/dist/chunk-BJz54mfg.cjs.map +1 -0
- package/dist/{sections-CVlc2Inr.d.cts → chunk-BNX5LAfN.d.cts} +289 -330
- package/dist/chunk-BP6KgA86.js +35 -0
- package/dist/chunk-BP6KgA86.js.map +1 -0
- package/dist/{segmentRoute-C5UL_5bp.d.ts → chunk-BRnjQq6K.d.cts} +44 -59
- package/dist/chunk-BSiMEwPS.js +46 -0
- package/dist/chunk-BSiMEwPS.js.map +1 -0
- package/dist/chunk-BTPjDw_y.cjs +16 -0
- package/dist/chunk-BTPjDw_y.cjs.map +1 -0
- package/dist/chunk-BTUUABGI.js +17 -0
- package/dist/chunk-BTUUABGI.js.map +1 -0
- package/dist/chunk-BUeL9y7s.cjs +45 -0
- package/dist/chunk-BUeL9y7s.cjs.map +1 -0
- package/dist/chunk-BWMuCNc9.cjs +172 -0
- package/dist/chunk-BWMuCNc9.cjs.map +1 -0
- package/dist/chunk-BWjRfhpF.js +126 -0
- package/dist/chunk-BWjRfhpF.js.map +1 -0
- package/dist/{types-CTQwbSdA.d.cts → chunk-BZ5KyZXI.d.ts} +103 -122
- package/dist/chunk-B_4SVmvh.js +94 -0
- package/dist/chunk-B_4SVmvh.js.map +1 -0
- package/dist/chunk-BcTUuZQ3.js +95 -0
- package/dist/chunk-BcTUuZQ3.js.map +1 -0
- package/dist/chunk-BdkqSsJe.cjs +140 -0
- package/dist/chunk-BdkqSsJe.cjs.map +1 -0
- package/dist/chunk-BfktMVmI.js +70 -0
- package/dist/chunk-BfktMVmI.js.map +1 -0
- package/dist/chunk-BfzQb0EK.cjs +6 -0
- package/dist/chunk-BhWfT-22.d.cts +808 -0
- package/dist/chunk-BjJcqX5J.cjs +60 -0
- package/dist/chunk-BjJcqX5J.cjs.map +1 -0
- package/dist/{geodesy-543qXKtI.d.ts → chunk-Bk0L8g5J.d.cts} +3 -4
- package/dist/{geodesy-543qXKtI.d.cts → chunk-Bk0L8g5J.d.ts} +3 -4
- package/dist/chunk-Bl4_uVa6.cjs +11 -0
- package/dist/chunk-Bl4_uVa6.cjs.map +1 -0
- package/dist/chunk-BlKF4lrp.js +43 -0
- package/dist/chunk-BlKF4lrp.js.map +1 -0
- package/dist/chunk-Bm1FieGR.js +4 -0
- package/dist/chunk-Bm1FieGR.js.map +1 -0
- package/dist/chunk-Bn6ZbxkS.cjs +27 -0
- package/dist/chunk-BpN3hr6a.cjs +541 -0
- package/dist/chunk-BpN3hr6a.cjs.map +1 -0
- package/dist/{order-BZkUwMou.d.cts → chunk-Bq_WHTfd.d.cts} +15 -28
- package/dist/chunk-Bqt4LBBz.cjs +648 -0
- package/dist/chunk-Bqt4LBBz.cjs.map +1 -0
- package/dist/{language-CEWQ5uYw.d.cts → chunk-Bqt97zwf.d.cts} +3 -18
- package/dist/{language-CEWQ5uYw.d.ts → chunk-Bqt97zwf.d.ts} +3 -18
- package/dist/chunk-BsBiN4w6.d.cts +245 -0
- package/dist/chunk-BvTpOUoC.cjs +207 -0
- package/dist/chunk-BvTpOUoC.cjs.map +1 -0
- package/dist/chunk-BwK6Hl3q.cjs +446 -0
- package/dist/chunk-BwK6Hl3q.cjs.map +1 -0
- package/dist/{elevationTiles-pmsb9wnU.d.cts → chunk-BxDQZDXR.d.cts} +26 -27
- package/dist/{elevationTiles-pmsb9wnU.d.ts → chunk-BxDQZDXR.d.ts} +26 -27
- package/dist/chunk-BxUio8kX.js +20 -0
- package/dist/chunk-BxUio8kX.js.map +1 -0
- package/dist/chunk-BxaocpFi.d.cts +1 -0
- package/dist/chunk-Bywi0K1N.js +36 -0
- package/dist/chunk-Bywi0K1N.js.map +1 -0
- package/dist/chunk-C-IlmkDl.js +59 -0
- package/dist/chunk-C-IlmkDl.js.map +1 -0
- package/dist/chunk-C5PtVewq.d.ts +389 -0
- package/dist/chunk-C5dpC7mQ.js +19 -0
- package/dist/chunk-C5dpC7mQ.js.map +1 -0
- package/dist/chunk-C5q1sgSa.js +46 -0
- package/dist/chunk-C5q1sgSa.js.map +1 -0
- package/dist/chunk-C6fU9G5I.cjs +221 -0
- package/dist/chunk-C6fU9G5I.cjs.map +1 -0
- package/dist/chunk-C71dpWUK.js +5 -0
- package/dist/chunk-C71dpWUK.js.map +1 -0
- package/dist/chunk-C82N1gQX.d.ts +1831 -0
- package/dist/chunk-C8HdaHpu.js +118 -0
- package/dist/chunk-C8HdaHpu.js.map +1 -0
- package/dist/chunk-C8ZGryck.js +236 -0
- package/dist/chunk-C8ZGryck.js.map +1 -0
- package/dist/chunk-C95NG0oD.cjs +43 -0
- package/dist/chunk-C95NG0oD.cjs.map +1 -0
- package/dist/chunk-C9aR8DXb.js +9 -0
- package/dist/chunk-C9aR8DXb.js.map +1 -0
- package/dist/{camera-C48Ykaxv.d.ts → chunk-CAUZnoCs.d.ts} +135 -159
- package/dist/chunk-CBXWWuM9.cjs +82 -0
- package/dist/chunk-CBXWWuM9.cjs.map +1 -0
- package/dist/chunk-CC_Kquu7.d.cts +125 -0
- package/dist/chunk-CC_Kquu7.d.ts +125 -0
- package/dist/chunk-CCp85vXg.cjs +60 -0
- package/dist/chunk-CCp85vXg.cjs.map +1 -0
- package/dist/chunk-CEcB1_uK.js +39 -0
- package/dist/chunk-CEcB1_uK.js.map +1 -0
- package/dist/{bundle-Je5zsRFg.d.cts → chunk-CFIo021l.d.cts} +51 -57
- package/dist/chunk-CH_IZoJE.js +33 -0
- package/dist/chunk-CH_IZoJE.js.map +1 -0
- package/dist/chunk-CHrasH_g.cjs +25 -0
- package/dist/chunk-CHrasH_g.cjs.map +1 -0
- package/dist/chunk-CJVoSaAE.cjs +3 -0
- package/dist/chunk-CJp8nGcb.js +96 -0
- package/dist/chunk-CJp8nGcb.js.map +1 -0
- package/dist/chunk-CJwUtkOt.js +112 -0
- package/dist/chunk-CJwUtkOt.js.map +1 -0
- package/dist/chunk-CKhCOVIf.d.cts +751 -0
- package/dist/chunk-CKiVSRYg.js +50 -0
- package/dist/chunk-CKiVSRYg.js.map +1 -0
- package/dist/chunk-CKtd19eD.cjs +59 -0
- package/dist/chunk-CKtd19eD.cjs.map +1 -0
- package/dist/chunk-CL92KE3j.d.ts +3188 -0
- package/dist/chunk-CLqUlkAe.js +54 -0
- package/dist/chunk-CLqUlkAe.js.map +1 -0
- package/dist/chunk-CMG5OV0q.cjs +4741 -0
- package/dist/chunk-CMG5OV0q.cjs.map +1 -0
- package/dist/chunk-CN_TKSgm.js +10 -0
- package/dist/chunk-CN_TKSgm.js.map +1 -0
- package/dist/chunk-CNe6MtqV.cjs +29 -0
- package/dist/chunk-CNe6MtqV.cjs.map +1 -0
- package/dist/chunk-COQkDTC5.js +83 -0
- package/dist/chunk-COQkDTC5.js.map +1 -0
- package/dist/chunk-CPBl6K4M.cjs +168 -0
- package/dist/chunk-CPBl6K4M.cjs.map +1 -0
- package/dist/chunk-CPx0ZYFB.d.ts +3 -0
- package/dist/chunk-CQQhcP_C.d.ts +197 -0
- package/dist/chunk-CTNoajFh.d.cts +389 -0
- package/dist/chunk-CTd-qgJc.cjs +384 -0
- package/dist/chunk-CTd-qgJc.cjs.map +1 -0
- package/dist/chunk-CW80YYtU.cjs +1056 -0
- package/dist/chunk-CW80YYtU.cjs.map +1 -0
- package/dist/{searchLimits-j99-NTXR.d.ts → chunk-CWpqBgkF.d.cts} +2 -2
- package/dist/{searchLimits-j99-NTXR.d.cts → chunk-CWpqBgkF.d.ts} +2 -2
- package/dist/chunk-CXjRArgy.d.ts +3 -0
- package/dist/chunk-CXonfH3-.cjs +14 -0
- package/dist/chunk-CXonfH3-.cjs.map +1 -0
- package/dist/chunk-CYcouGXN.d.ts +825 -0
- package/dist/chunk-CZDAzEBw.cjs +1621 -0
- package/dist/chunk-CZDAzEBw.cjs.map +1 -0
- package/dist/{amenities-B3-qAjxu.d.cts → chunk-C_fQFr70.d.cts} +40 -41
- package/dist/{amenities-B3-qAjxu.d.ts → chunk-C_fQFr70.d.ts} +40 -41
- package/dist/chunk-CbOtHnnB.cjs +359 -0
- package/dist/chunk-CbOtHnnB.cjs.map +1 -0
- package/dist/chunk-CdA6ZMGk.d.cts +825 -0
- package/dist/chunk-Ce1_thm7.js +146 -0
- package/dist/chunk-Ce1_thm7.js.map +1 -0
- package/dist/chunk-CeD8Hw0j.d.cts +3188 -0
- package/dist/{camera-BrFLU1DH.d.cts → chunk-CeiTuMyt.d.cts} +135 -159
- package/dist/chunk-Ch1OLzLi.js +1 -0
- package/dist/chunk-Cizu_j1N.cjs +87 -0
- package/dist/chunk-Cizu_j1N.cjs.map +1 -0
- package/dist/chunk-CjDe9z6A.d.cts +427 -0
- package/dist/chunk-Cl1etdlu.js +63 -0
- package/dist/chunk-Cl1etdlu.js.map +1 -0
- package/dist/chunk-CmoVJDoz.js +4 -0
- package/dist/chunk-CmoVJDoz.js.map +1 -0
- package/dist/chunk-CnLucxjG.cjs +197 -0
- package/dist/chunk-CnLucxjG.cjs.map +1 -0
- package/dist/chunk-CsWjBmdi.cjs +56 -0
- package/dist/chunk-CsWjBmdi.cjs.map +1 -0
- package/dist/chunk-CuseO5MZ.d.cts +3 -0
- package/dist/chunk-CvMHibbA.d.ts +427 -0
- package/dist/chunk-CwDeiN5U.js +870 -0
- package/dist/chunk-CwDeiN5U.js.map +1 -0
- package/dist/chunk-Cwdmx4tG.js +1 -0
- package/dist/{geolocation-DDkQdWMN.d.cts → chunk-D-4MxHTt.d.cts} +33 -34
- package/dist/{geolocation-DDkQdWMN.d.ts → chunk-D-4MxHTt.d.ts} +33 -34
- package/dist/chunk-D0LF-99V.js +1093 -0
- package/dist/chunk-D0LF-99V.js.map +1 -0
- package/dist/chunk-D1fe-0c_.js +367 -0
- package/dist/chunk-D1fe-0c_.js.map +1 -0
- package/dist/chunk-D21fEI6A.d.ts +1926 -0
- package/dist/chunk-D39gAxya.cjs +89 -0
- package/dist/chunk-D39gAxya.cjs.map +1 -0
- package/dist/chunk-D6KdIW5e.cjs +228 -0
- package/dist/chunk-D6KdIW5e.cjs.map +1 -0
- package/dist/chunk-D6qHYbgW.d.cts +36 -0
- package/dist/{videoOverlay-Dh_D5_Zs.d.cts → chunk-D89E-w70.d.ts} +10 -10
- package/dist/chunk-D8bdTysL.js +552 -0
- package/dist/chunk-D8bdTysL.js.map +1 -0
- package/dist/chunk-D96QJT24.cjs +109 -0
- package/dist/chunk-D96QJT24.cjs.map +1 -0
- package/dist/chunk-DAmkQl-i.js +119 -0
- package/dist/chunk-DAmkQl-i.js.map +1 -0
- package/dist/chunk-DEfsb2lc.cjs +10 -0
- package/dist/chunk-DEfsb2lc.cjs.map +1 -0
- package/dist/chunk-DIFjT5-V.d.cts +66 -0
- package/dist/{sections-CmtaduLc.d.ts → chunk-DJpUw8TN.d.ts} +289 -330
- package/dist/chunk-DK6lm2IZ.cjs +11 -0
- package/dist/chunk-DK6lm2IZ.cjs.map +1 -0
- package/dist/chunk-DKqgr31j.cjs +61 -0
- package/dist/chunk-DKqgr31j.cjs.map +1 -0
- package/dist/chunk-DLZ0QYm9.js +37 -0
- package/dist/chunk-DLZ0QYm9.js.map +1 -0
- package/dist/chunk-DLjS0uaC.js +4 -0
- package/dist/chunk-DLjS0uaC.js.map +1 -0
- package/dist/chunk-DMokwmOV.cjs +49 -0
- package/dist/chunk-DMokwmOV.cjs.map +1 -0
- package/dist/chunk-DMvWgBZL.d.cts +1831 -0
- package/dist/chunk-DNfGfIF3.js +31 -0
- package/dist/chunk-DNfGfIF3.js.map +1 -0
- package/dist/chunk-DQbSRe8D.d.ts +245 -0
- package/dist/chunk-DSGkP8_y.js +45 -0
- package/dist/chunk-DSGkP8_y.js.map +1 -0
- package/dist/chunk-DTctvfSd.d.cts +197 -0
- package/dist/chunk-DWe7igyw.cjs +206 -0
- package/dist/chunk-DWe7igyw.cjs.map +1 -0
- package/dist/chunk-DWsMP5JR.d.ts +68 -0
- package/dist/{provider-DM71XnLX.d.cts → chunk-DWsm3HIW.d.cts} +37 -38
- package/dist/{provider-DM71XnLX.d.ts → chunk-DWsm3HIW.d.ts} +37 -38
- package/dist/chunk-DXABHjLa.cjs +3 -0
- package/dist/chunk-D_BeqSbc.cjs +42 -0
- package/dist/chunk-D_BeqSbc.cjs.map +1 -0
- package/dist/chunk-D_svQNdW.d.ts +66 -0
- package/dist/chunk-Dav4xWrp.js +330 -0
- package/dist/chunk-Dav4xWrp.js.map +1 -0
- package/dist/chunk-DbCPhepL.js +293 -0
- package/dist/chunk-DbCPhepL.js.map +1 -0
- package/dist/chunk-DcrTy-y2.cjs +43 -0
- package/dist/chunk-DcrTy-y2.cjs.map +1 -0
- package/dist/chunk-Ddv484ld.js +487 -0
- package/dist/chunk-Ddv484ld.js.map +1 -0
- package/dist/chunk-De0bjnhY.cjs +88 -0
- package/dist/chunk-De0bjnhY.cjs.map +1 -0
- package/dist/chunk-De2FmNPu.cjs +32 -0
- package/dist/chunk-De2FmNPu.cjs.map +1 -0
- package/dist/{segmentRoute-CIo6dR8Y.d.cts → chunk-DeSjQXiI.d.ts} +44 -59
- package/dist/chunk-Den0Ta6C.js +132 -0
- package/dist/chunk-Den0Ta6C.js.map +1 -0
- package/dist/chunk-DiDKEeEa.js +8 -0
- package/dist/chunk-DiDKEeEa.js.map +1 -0
- package/dist/chunk-Dj60k5PU.js +197 -0
- package/dist/chunk-Dj60k5PU.js.map +1 -0
- package/dist/chunk-DjnYQBCN.js +4705 -0
- package/dist/chunk-DjnYQBCN.js.map +1 -0
- package/dist/chunk-Dk9VKvyq.d.ts +1 -0
- package/dist/chunk-Dor1ERI9.cjs +85 -0
- package/dist/chunk-Dor1ERI9.cjs.map +1 -0
- package/dist/chunk-DpMouOoH.js +451 -0
- package/dist/chunk-DpMouOoH.js.map +1 -0
- package/dist/chunk-DposgdNL.cjs +52 -0
- package/dist/chunk-DposgdNL.cjs.map +1 -0
- package/dist/chunk-DqLTG_5Q.d.cts +3 -0
- package/dist/{roadAccess-D_rOE4xW.d.cts → chunk-Dr5MCIpS.d.cts} +5 -28
- package/dist/{roadAccess-D_rOE4xW.d.ts → chunk-Dr5MCIpS.d.ts} +5 -28
- package/dist/chunk-DrudttCC.cjs +4 -0
- package/dist/chunk-DsDYVJQC.js +173 -0
- package/dist/chunk-DsDYVJQC.js.map +1 -0
- package/dist/chunk-Dw8ur6FJ.js +27 -0
- package/dist/chunk-Dw8ur6FJ.js.map +1 -0
- package/dist/chunk-DwG6M_0v.js +64 -0
- package/dist/chunk-DwG6M_0v.js.map +1 -0
- package/dist/chunk-Dy9a5ibO.js +284 -0
- package/dist/chunk-Dy9a5ibO.js.map +1 -0
- package/dist/chunk-DyayZlQJ.js +157 -0
- package/dist/chunk-DyayZlQJ.js.map +1 -0
- package/dist/chunk-DyhJZC2i.js +126 -0
- package/dist/chunk-DyhJZC2i.js.map +1 -0
- package/dist/chunk-F9zBzmmG.cjs +45 -0
- package/dist/chunk-F9zBzmmG.cjs.map +1 -0
- package/dist/chunk-FyCYofv2.js +116 -0
- package/dist/chunk-FyCYofv2.js.map +1 -0
- package/dist/chunk-GHJRjAk2.js +1 -0
- package/dist/chunk-H14isiSf.d.ts +751 -0
- package/dist/chunk-HIJzXoN4.js +7 -0
- package/dist/chunk-HIJzXoN4.js.map +1 -0
- package/dist/chunk-Id_8kRtu.d.ts +36 -0
- package/dist/chunk-KN60yxBQ.js +5 -0
- package/dist/chunk-KN60yxBQ.js.map +1 -0
- package/dist/chunk-NM5yg6bh.cjs +82 -0
- package/dist/chunk-NM5yg6bh.cjs.map +1 -0
- package/dist/chunk-OXr3zJfM.cjs +119 -0
- package/dist/chunk-OXr3zJfM.cjs.map +1 -0
- package/dist/chunk-QGqgNC4z.d.ts +928 -0
- package/dist/chunk-QJBtJrZ0.js +36 -0
- package/dist/chunk-QJBtJrZ0.js.map +1 -0
- package/dist/{routeProfile-BsSUABXv.d.cts → chunk-QKWhxfPv.d.cts} +196 -45
- package/dist/{routeProfile-BKfSfxx6.d.ts → chunk-QKWhxfPv.d.ts} +196 -45
- package/dist/chunk-QXW7b4Ev.d.cts +410 -0
- package/dist/chunk-RHZrxUrM.cjs +39 -0
- package/dist/chunk-RHZrxUrM.cjs.map +1 -0
- package/dist/chunk-RTxe2i66.js +91 -0
- package/dist/chunk-RTxe2i66.js.map +1 -0
- package/dist/chunk-RrKkJb6P.js +16 -0
- package/dist/chunk-RrKkJb6P.js.map +1 -0
- package/dist/chunk-VOJqpcnM.cjs +181 -0
- package/dist/chunk-VOJqpcnM.cjs.map +1 -0
- package/dist/chunk-VljGTrid.js +1 -0
- package/dist/chunk-X3UVwUEK.d.cts +513 -0
- package/dist/chunk-X9K2WChn.cjs +28 -0
- package/dist/chunk-X9K2WChn.cjs.map +1 -0
- package/dist/chunk-YrtOx6oy.js +251 -0
- package/dist/chunk-YrtOx6oy.js.map +1 -0
- package/dist/chunk-bY7ySujI.d.cts +928 -0
- package/dist/chunk-bYf1sBz5.d.cts +11 -0
- package/dist/chunk-bYf1sBz5.d.ts +11 -0
- package/dist/chunk-blfknWoM.d.cts +1926 -0
- package/dist/chunk-blqsohAb.js +113 -0
- package/dist/chunk-blqsohAb.js.map +1 -0
- package/dist/chunk-cDMCjodI.cjs +58 -0
- package/dist/chunk-cDMCjodI.cjs.map +1 -0
- package/dist/chunk-cWjE3qd6.cjs +10 -0
- package/dist/chunk-cWjE3qd6.cjs.map +1 -0
- package/dist/chunk-dfOgV3fu.js +26 -0
- package/dist/chunk-dfOgV3fu.js.map +1 -0
- package/dist/chunk-f9cTwUX1.cjs +125 -0
- package/dist/chunk-f9cTwUX1.cjs.map +1 -0
- package/dist/chunk-fHVYEZs4.cjs +28 -0
- package/dist/chunk-fHVYEZs4.cjs.map +1 -0
- package/dist/chunk-fWRUMgRI.js +22 -0
- package/dist/chunk-fWRUMgRI.js.map +1 -0
- package/dist/{types-BEv8V_8V.d.cts → chunk-fozLXfHY.d.cts} +8 -8
- package/dist/{types-BEv8V_8V.d.ts → chunk-fozLXfHY.d.ts} +8 -8
- package/dist/chunk-gWmB1l3A.cjs +3122 -0
- package/dist/chunk-gWmB1l3A.cjs.map +1 -0
- package/dist/chunk-gbj2R-_w.js +58 -0
- package/dist/chunk-gbj2R-_w.js.map +1 -0
- package/dist/chunk-iIWxsAXd.js +59 -0
- package/dist/chunk-iIWxsAXd.js.map +1 -0
- package/dist/chunk-lItIuOIS.cjs +137 -0
- package/dist/chunk-lItIuOIS.cjs.map +1 -0
- package/dist/chunk-m6Rh4PCe.cjs +798 -0
- package/dist/chunk-m6Rh4PCe.cjs.map +1 -0
- package/dist/chunk-o3IRANDf.cjs +99 -0
- package/dist/chunk-o3IRANDf.cjs.map +1 -0
- package/dist/chunk-obUcg3Sk.d.ts +808 -0
- package/dist/chunk-ohsf-6Rn.js +600 -0
- package/dist/chunk-ohsf-6Rn.js.map +1 -0
- package/dist/chunk-pBleU6Nv.js +3061 -0
- package/dist/chunk-pBleU6Nv.js.map +1 -0
- package/dist/chunk-px4e99cy.js +71 -0
- package/dist/chunk-px4e99cy.js.map +1 -0
- package/dist/chunk-qwYDLeXc.cjs +99 -0
- package/dist/chunk-qwYDLeXc.cjs.map +1 -0
- package/dist/chunk-rF_859Qk.cjs +101 -0
- package/dist/chunk-rF_859Qk.cjs.map +1 -0
- package/dist/chunk-rLJkqJ5j.d.ts +1475 -0
- package/dist/chunk-twQItIRg.cjs +338 -0
- package/dist/chunk-twQItIRg.cjs.map +1 -0
- package/dist/chunk-vnPrMVjY.js +10 -0
- package/dist/chunk-vnPrMVjY.js.map +1 -0
- package/dist/chunk-ws3bVwaS.d.ts +410 -0
- package/dist/chunk-xh3UkuVs.cjs +246 -0
- package/dist/chunk-xh3UkuVs.cjs.map +1 -0
- package/dist/chunk-yMzRr26E.js +153 -0
- package/dist/chunk-yMzRr26E.js.map +1 -0
- package/dist/collab/index.cjs +802 -1254
- package/dist/collab/index.cjs.map +1 -1
- package/dist/collab/index.d.cts +518 -544
- package/dist/collab/index.d.ts +518 -544
- package/dist/collab/index.js +797 -1252
- package/dist/collab/index.js.map +1 -1
- package/dist/data/index.cjs +39 -132
- package/dist/data/index.d.cts +6 -468
- package/dist/data/index.d.ts +6 -468
- package/dist/data/index.js +7 -15
- package/dist/editor/index.cjs +2631 -4424
- package/dist/editor/index.cjs.map +1 -1
- package/dist/editor/index.d.cts +10 -59
- package/dist/editor/index.d.ts +10 -59
- package/dist/editor/index.js +2619 -4403
- package/dist/editor/index.js.map +1 -1
- package/dist/errors/index.cjs +11 -28
- package/dist/errors/index.d.cts +2 -125
- package/dist/errors/index.d.ts +2 -125
- package/dist/errors/index.js +1 -3
- package/dist/geo/index.cjs +68 -232
- package/dist/geo/index.d.cts +6 -821
- package/dist/geo/index.d.ts +6 -821
- package/dist/geo/index.js +11 -15
- package/dist/i18n/fr/index.cjs +329 -334
- package/dist/i18n/fr/index.cjs.map +1 -1
- package/dist/i18n/fr/index.d.cts +3 -10
- package/dist/i18n/fr/index.d.ts +3 -10
- package/dist/i18n/fr/index.js +324 -332
- package/dist/i18n/fr/index.js.map +1 -1
- package/dist/i18n/index.cjs +434 -447
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +152 -111
- package/dist/i18n/index.d.ts +152 -111
- package/dist/i18n/index.js +420 -420
- package/dist/i18n/index.js.map +1 -1
- package/dist/icons/index.cjs +37 -116
- package/dist/icons/index.d.cts +4 -457
- package/dist/icons/index.d.ts +4 -457
- package/dist/icons/index.js +8 -11
- package/dist/index.cjs +515 -1867
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -121
- package/dist/index.d.ts +44 -121
- package/dist/index.js +52 -65
- package/dist/index.js.map +1 -1
- package/dist/layers/index.cjs +83 -318
- package/dist/layers/index.d.cts +3 -1555
- package/dist/layers/index.d.ts +3 -1555
- package/dist/layers/index.js +5 -17
- package/dist/map-client/index.cjs +5 -4
- package/dist/map-client/index.d.cts +6 -1856
- package/dist/map-client/index.d.ts +6 -1856
- package/dist/map-client/index.js +0 -3
- package/dist/maplibre-worker.mjs +4 -4
- package/dist/navigation/index.cjs +584 -671
- package/dist/navigation/index.cjs.map +1 -1
- package/dist/navigation/index.d.cts +191 -272
- package/dist/navigation/index.d.ts +191 -272
- package/dist/navigation/index.js +579 -669
- package/dist/navigation/index.js.map +1 -1
- package/dist/profile/index.cjs +177 -675
- package/dist/profile/index.d.cts +8 -2086
- package/dist/profile/index.d.ts +8 -2086
- package/dist/profile/index.js +10 -18
- package/dist/seams/index.cjs +15 -39
- package/dist/seams/index.d.cts +4 -254
- package/dist/seams/index.d.ts +4 -254
- package/dist/seams/index.js +4 -6
- package/dist/search/index.cjs +39 -147
- package/dist/search/index.d.cts +6 -888
- package/dist/search/index.d.ts +6 -888
- package/dist/search/index.js +3 -14
- package/dist/style/index.cjs +34 -116
- package/dist/style/index.d.cts +5 -538
- package/dist/style/index.d.ts +5 -538
- package/dist/style/index.js +5 -11
- package/dist/testing/index.cjs +432 -617
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +61 -109
- package/dist/testing/index.d.ts +61 -109
- package/dist/testing/index.js +427 -615
- package/dist/testing/index.js.map +1 -1
- package/dist/timezone/index.cjs +1946 -752
- package/dist/timezone/index.cjs.map +1 -1
- package/dist/timezone/index.d.cts +4 -29
- package/dist/timezone/index.d.ts +4 -29
- package/dist/timezone/index.js +1941 -750
- package/dist/timezone/index.js.map +1 -1
- package/dist/units/index.cjs +29 -99
- package/dist/units/index.d.cts +3 -75
- package/dist/units/index.d.ts +3 -75
- package/dist/units/index.js +3 -6
- package/dist/video/index.cjs +1684 -2169
- package/dist/video/index.cjs.map +1 -1
- package/dist/video/index.d.cts +386 -413
- package/dist/video/index.d.ts +386 -413
- package/dist/video/index.js +1678 -2162
- package/dist/video/index.js.map +1 -1
- package/dist/view/index.cjs +6 -42
- package/dist/view/index.d.cts +3 -836
- package/dist/view/index.d.ts +3 -836
- package/dist/view/index.js +1 -34
- package/package.json +12 -12
- package/src/auth/rules/clientHeader.ts +1 -1
- package/src/camera/rules/modes.ts +38 -42
- package/src/camera/rules/routeContent.ts +1 -0
- package/src/collab/index.ts +1 -5
- package/src/compose/engines/mountayaMap.ts +16 -42
- package/src/compose/rules/developmentWarnings.ts +4 -3
- package/src/compose/rules/fitBox.ts +67 -0
- package/src/compose/rules/maplibreWorkerVersion.gen.ts +1 -1
- package/src/compose/rules/maxBounds.ts +5 -5
- package/src/compose/rules/types.ts +4 -11
- package/src/compose/rules/workerUrl.ts +41 -6
- package/src/editing/rules/engine.ts +4 -2
- package/src/editor/engines/viewClient.ts +8 -0
- package/src/editor/rules/contract.ts +1 -6
- package/src/errors/rules/errors.ts +1 -0
- package/src/geo/index.ts +1 -6
- package/src/i18n/index.ts +1 -0
- package/src/i18n/rules/dates.ts +165 -0
- package/src/index.ts +5 -24
- package/src/map-client/rules/mapClient.ts +4 -2
- package/src/profile/rules/scale.ts +1 -5
- package/src/profile/rules/waypointCard.ts +8 -11
- package/src/search/index.ts +3 -18
- package/src/video/index.ts +1 -1
- package/src/video/profileOverlay/rules/contract.ts +1 -3
- package/src/video/rules/videoEncoder.ts +1 -1
- package/dist/accentColor-GNKBD2CW.js +0 -4
- package/dist/accentColor-GNKBD2CW.js.map +0 -1
- package/dist/accentColor-VX2JSMGE.cjs +0 -17
- package/dist/accentColor-VX2JSMGE.cjs.map +0 -1
- package/dist/chunk-23PFRRB6.js +0 -3
- package/dist/chunk-23PFRRB6.js.map +0 -1
- package/dist/chunk-2GI5SAH2.js +0 -71
- package/dist/chunk-2GI5SAH2.js.map +0 -1
- package/dist/chunk-2MQK6A74.js +0 -39
- package/dist/chunk-2MQK6A74.js.map +0 -1
- package/dist/chunk-2RE7R4LD.js +0 -73
- package/dist/chunk-2RE7R4LD.js.map +0 -1
- package/dist/chunk-3JZQKN4O.js +0 -6
- package/dist/chunk-3JZQKN4O.js.map +0 -1
- package/dist/chunk-3NDXVUUI.js +0 -50
- package/dist/chunk-3NDXVUUI.js.map +0 -1
- package/dist/chunk-3R4GFTUM.cjs +0 -59
- package/dist/chunk-3R4GFTUM.cjs.map +0 -1
- package/dist/chunk-3RVUQ6JN.cjs +0 -22
- package/dist/chunk-3RVUQ6JN.cjs.map +0 -1
- package/dist/chunk-4F6BJMJC.cjs +0 -49
- package/dist/chunk-4F6BJMJC.cjs.map +0 -1
- package/dist/chunk-4NWQD4BX.js +0 -132
- package/dist/chunk-4NWQD4BX.js.map +0 -1
- package/dist/chunk-5K2MH3R6.js +0 -10
- package/dist/chunk-5K2MH3R6.js.map +0 -1
- package/dist/chunk-6ACRNQQQ.cjs +0 -8
- package/dist/chunk-6ACRNQQQ.cjs.map +0 -1
- package/dist/chunk-6D26E3IA.js +0 -66
- package/dist/chunk-6D26E3IA.js.map +0 -1
- package/dist/chunk-6ESAW35P.cjs +0 -80
- package/dist/chunk-6ESAW35P.cjs.map +0 -1
- package/dist/chunk-6LIW2A5M.cjs +0 -1176
- package/dist/chunk-6LIW2A5M.cjs.map +0 -1
- package/dist/chunk-6OTTWVCA.js +0 -57
- package/dist/chunk-6OTTWVCA.js.map +0 -1
- package/dist/chunk-6VROJ4UG.js +0 -862
- package/dist/chunk-6VROJ4UG.js.map +0 -1
- package/dist/chunk-6Y7FTGO4.js +0 -23
- package/dist/chunk-6Y7FTGO4.js.map +0 -1
- package/dist/chunk-75I4CG64.js +0 -104
- package/dist/chunk-75I4CG64.js.map +0 -1
- package/dist/chunk-7CUBXHAH.cjs +0 -14
- package/dist/chunk-7CUBXHAH.cjs.map +0 -1
- package/dist/chunk-7GTCURVY.js +0 -52
- package/dist/chunk-7GTCURVY.js.map +0 -1
- package/dist/chunk-7IWOL6AM.cjs +0 -100
- package/dist/chunk-7IWOL6AM.cjs.map +0 -1
- package/dist/chunk-7QN7M667.cjs +0 -151
- package/dist/chunk-7QN7M667.cjs.map +0 -1
- package/dist/chunk-A6KQDKLM.cjs +0 -1197
- package/dist/chunk-A6KQDKLM.cjs.map +0 -1
- package/dist/chunk-A77EA67G.js +0 -354
- package/dist/chunk-A77EA67G.js.map +0 -1
- package/dist/chunk-AFKOABJ4.cjs +0 -7194
- package/dist/chunk-AFKOABJ4.cjs.map +0 -1
- package/dist/chunk-AG6JV5Z2.cjs +0 -183
- package/dist/chunk-AG6JV5Z2.cjs.map +0 -1
- package/dist/chunk-APBK7NMS.js +0 -30
- package/dist/chunk-APBK7NMS.js.map +0 -1
- package/dist/chunk-AWO5YA7A.cjs +0 -33
- package/dist/chunk-AWO5YA7A.cjs.map +0 -1
- package/dist/chunk-AZATU6QW.js +0 -108
- package/dist/chunk-AZATU6QW.js.map +0 -1
- package/dist/chunk-BD2U3WST.cjs +0 -623
- package/dist/chunk-BD2U3WST.cjs.map +0 -1
- package/dist/chunk-BHBEOU6L.cjs +0 -65
- package/dist/chunk-BHBEOU6L.cjs.map +0 -1
- package/dist/chunk-CNOSNYNE.js +0 -8
- package/dist/chunk-CNOSNYNE.js.map +0 -1
- package/dist/chunk-CW3EFR4O.js +0 -12
- package/dist/chunk-CW3EFR4O.js.map +0 -1
- package/dist/chunk-DASVRNBK.js +0 -7187
- package/dist/chunk-DASVRNBK.js.map +0 -1
- package/dist/chunk-DJ6LCKYP.js +0 -42
- package/dist/chunk-DJ6LCKYP.js.map +0 -1
- package/dist/chunk-E5FHQAIO.cjs +0 -45
- package/dist/chunk-E5FHQAIO.cjs.map +0 -1
- package/dist/chunk-EOML5OTY.cjs +0 -360
- package/dist/chunk-EOML5OTY.cjs.map +0 -1
- package/dist/chunk-EP5CASHL.js +0 -613
- package/dist/chunk-EP5CASHL.js.map +0 -1
- package/dist/chunk-EP5OEEVZ.cjs +0 -14
- package/dist/chunk-EP5OEEVZ.cjs.map +0 -1
- package/dist/chunk-EUXI3FGQ.js +0 -150
- package/dist/chunk-EUXI3FGQ.js.map +0 -1
- package/dist/chunk-EWFSHCOS.js +0 -40
- package/dist/chunk-EWFSHCOS.js.map +0 -1
- package/dist/chunk-EX2C5K2T.cjs +0 -25
- package/dist/chunk-EX2C5K2T.cjs.map +0 -1
- package/dist/chunk-FEXWDQIZ.cjs +0 -8
- package/dist/chunk-FEXWDQIZ.cjs.map +0 -1
- package/dist/chunk-FEYBFY7H.cjs +0 -358
- package/dist/chunk-FEYBFY7H.cjs.map +0 -1
- package/dist/chunk-FRGAV6N6.cjs +0 -34
- package/dist/chunk-FRGAV6N6.cjs.map +0 -1
- package/dist/chunk-G5DHP5VF.js +0 -6
- package/dist/chunk-G5DHP5VF.js.map +0 -1
- package/dist/chunk-G5W2UHV2.js +0 -99
- package/dist/chunk-G5W2UHV2.js.map +0 -1
- package/dist/chunk-G7OP7O2C.cjs +0 -39
- package/dist/chunk-G7OP7O2C.cjs.map +0 -1
- package/dist/chunk-GE6CFCAM.cjs +0 -25
- package/dist/chunk-GE6CFCAM.cjs.map +0 -1
- package/dist/chunk-GIFALLHI.cjs +0 -111
- package/dist/chunk-GIFALLHI.cjs.map +0 -1
- package/dist/chunk-GLFET5GM.js +0 -129
- package/dist/chunk-GLFET5GM.js.map +0 -1
- package/dist/chunk-GQ6UFPFM.js +0 -22
- package/dist/chunk-GQ6UFPFM.js.map +0 -1
- package/dist/chunk-GQJWVMXS.js +0 -129
- package/dist/chunk-GQJWVMXS.js.map +0 -1
- package/dist/chunk-GVVJPUKC.js +0 -80
- package/dist/chunk-GVVJPUKC.js.map +0 -1
- package/dist/chunk-GZ2HOCQ2.cjs +0 -134
- package/dist/chunk-GZ2HOCQ2.cjs.map +0 -1
- package/dist/chunk-HCBOHXWP.js +0 -37
- package/dist/chunk-HCBOHXWP.js.map +0 -1
- package/dist/chunk-IBQJDVHF.cjs +0 -281
- package/dist/chunk-IBQJDVHF.cjs.map +0 -1
- package/dist/chunk-ISLB6Y5Q.cjs +0 -106
- package/dist/chunk-ISLB6Y5Q.cjs.map +0 -1
- package/dist/chunk-J55CRR4F.js +0 -105
- package/dist/chunk-J55CRR4F.js.map +0 -1
- package/dist/chunk-JBG6Z6MQ.cjs +0 -28
- package/dist/chunk-JBG6Z6MQ.cjs.map +0 -1
- package/dist/chunk-K3RQOZRU.js +0 -61
- package/dist/chunk-K3RQOZRU.js.map +0 -1
- package/dist/chunk-KDJYS4GB.cjs +0 -703
- package/dist/chunk-KDJYS4GB.cjs.map +0 -1
- package/dist/chunk-KMCAHUZM.cjs +0 -4
- package/dist/chunk-KMCAHUZM.cjs.map +0 -1
- package/dist/chunk-KUCBNPC6.js +0 -87
- package/dist/chunk-KUCBNPC6.js.map +0 -1
- package/dist/chunk-KV6UE5A4.js +0 -50
- package/dist/chunk-KV6UE5A4.js.map +0 -1
- package/dist/chunk-L6TZ2HQR.cjs +0 -18
- package/dist/chunk-L6TZ2HQR.cjs.map +0 -1
- package/dist/chunk-L7QHHGG2.cjs +0 -141
- package/dist/chunk-L7QHHGG2.cjs.map +0 -1
- package/dist/chunk-LHK3Y2AL.js +0 -271
- package/dist/chunk-LHK3Y2AL.js.map +0 -1
- package/dist/chunk-LO5RYRBH.cjs +0 -6317
- package/dist/chunk-LO5RYRBH.cjs.map +0 -1
- package/dist/chunk-LS5SJMUO.cjs +0 -194
- package/dist/chunk-LS5SJMUO.cjs.map +0 -1
- package/dist/chunk-LUGTMZFN.cjs +0 -42
- package/dist/chunk-LUGTMZFN.cjs.map +0 -1
- package/dist/chunk-LVUQU6D5.js +0 -32
- package/dist/chunk-LVUQU6D5.js.map +0 -1
- package/dist/chunk-M2QRC2GZ.js +0 -166
- package/dist/chunk-M2QRC2GZ.js.map +0 -1
- package/dist/chunk-M6QJYQIM.cjs +0 -53
- package/dist/chunk-M6QJYQIM.cjs.map +0 -1
- package/dist/chunk-MGCPH5EO.js +0 -12
- package/dist/chunk-MGCPH5EO.js.map +0 -1
- package/dist/chunk-MLVUWEZR.cjs +0 -474
- package/dist/chunk-MLVUWEZR.cjs.map +0 -1
- package/dist/chunk-MTAMJMZL.cjs +0 -707
- package/dist/chunk-MTAMJMZL.cjs.map +0 -1
- package/dist/chunk-MXL5AT3N.js +0 -48
- package/dist/chunk-MXL5AT3N.js.map +0 -1
- package/dist/chunk-MYEQSESM.cjs +0 -75
- package/dist/chunk-MYEQSESM.cjs.map +0 -1
- package/dist/chunk-N3VPF6ZD.js +0 -427
- package/dist/chunk-N3VPF6ZD.js.map +0 -1
- package/dist/chunk-N6VUAIGI.js +0 -7
- package/dist/chunk-N6VUAIGI.js.map +0 -1
- package/dist/chunk-N6XRLUN6.js +0 -6286
- package/dist/chunk-N6XRLUN6.js.map +0 -1
- package/dist/chunk-NOGDOZIT.cjs +0 -114
- package/dist/chunk-NOGDOZIT.cjs.map +0 -1
- package/dist/chunk-NUWXEISH.cjs +0 -10
- package/dist/chunk-NUWXEISH.cjs.map +0 -1
- package/dist/chunk-NZCZHXYN.cjs +0 -161
- package/dist/chunk-NZCZHXYN.cjs.map +0 -1
- package/dist/chunk-ODROSWQX.cjs +0 -53
- package/dist/chunk-ODROSWQX.cjs.map +0 -1
- package/dist/chunk-OE36AYKG.cjs +0 -82
- package/dist/chunk-OE36AYKG.cjs.map +0 -1
- package/dist/chunk-OLON7MO6.cjs +0 -437
- package/dist/chunk-OLON7MO6.cjs.map +0 -1
- package/dist/chunk-PBUOR2IT.js +0 -277
- package/dist/chunk-PBUOR2IT.js.map +0 -1
- package/dist/chunk-PC2ELXFF.cjs +0 -225
- package/dist/chunk-PC2ELXFF.cjs.map +0 -1
- package/dist/chunk-PCSGXLOC.js +0 -71
- package/dist/chunk-PCSGXLOC.js.map +0 -1
- package/dist/chunk-PFNMP6FQ.js +0 -56
- package/dist/chunk-PFNMP6FQ.js.map +0 -1
- package/dist/chunk-PIWSZTIP.js +0 -690
- package/dist/chunk-PIWSZTIP.js.map +0 -1
- package/dist/chunk-PKWHJ2GI.js +0 -136
- package/dist/chunk-PKWHJ2GI.js.map +0 -1
- package/dist/chunk-PLMVBX2A.cjs +0 -76
- package/dist/chunk-PLMVBX2A.cjs.map +0 -1
- package/dist/chunk-PM3XCD2G.cjs +0 -113
- package/dist/chunk-PM3XCD2G.cjs.map +0 -1
- package/dist/chunk-QAL4GZO7.cjs +0 -143
- package/dist/chunk-QAL4GZO7.cjs.map +0 -1
- package/dist/chunk-QDB2SEA2.js +0 -74
- package/dist/chunk-QDB2SEA2.js.map +0 -1
- package/dist/chunk-QOV7UNUN.js +0 -25
- package/dist/chunk-QOV7UNUN.js.map +0 -1
- package/dist/chunk-QQUWYLSF.cjs +0 -50
- package/dist/chunk-QQUWYLSF.cjs.map +0 -1
- package/dist/chunk-QUMBH3U4.cjs +0 -9
- package/dist/chunk-QUMBH3U4.cjs.map +0 -1
- package/dist/chunk-R4KA7OFQ.js +0 -12
- package/dist/chunk-R4KA7OFQ.js.map +0 -1
- package/dist/chunk-RBSGAZQQ.js +0 -17
- package/dist/chunk-RBSGAZQQ.js.map +0 -1
- package/dist/chunk-RM5YJWZI.js +0 -46
- package/dist/chunk-RM5YJWZI.js.map +0 -1
- package/dist/chunk-ROKNKXA4.cjs +0 -8
- package/dist/chunk-ROKNKXA4.cjs.map +0 -1
- package/dist/chunk-RQG6D546.cjs +0 -75
- package/dist/chunk-RQG6D546.cjs.map +0 -1
- package/dist/chunk-SG4YDD5L.cjs +0 -74
- package/dist/chunk-SG4YDD5L.cjs.map +0 -1
- package/dist/chunk-SNRCA7EO.js +0 -56
- package/dist/chunk-SNRCA7EO.js.map +0 -1
- package/dist/chunk-SO75R4WW.cjs +0 -22
- package/dist/chunk-SO75R4WW.cjs.map +0 -1
- package/dist/chunk-SP34NHFI.js +0 -45
- package/dist/chunk-SP34NHFI.js.map +0 -1
- package/dist/chunk-SSKSSBWJ.cjs +0 -179
- package/dist/chunk-SSKSSBWJ.cjs.map +0 -1
- package/dist/chunk-TB5663C2.js +0 -1108
- package/dist/chunk-TB5663C2.js.map +0 -1
- package/dist/chunk-TGH4NRES.js +0 -220
- package/dist/chunk-TGH4NRES.js.map +0 -1
- package/dist/chunk-TJ6ZPNID.js +0 -189
- package/dist/chunk-TJ6ZPNID.js.map +0 -1
- package/dist/chunk-U45T35N2.cjs +0 -90
- package/dist/chunk-U45T35N2.cjs.map +0 -1
- package/dist/chunk-UKVOPEZ2.js +0 -442
- package/dist/chunk-UKVOPEZ2.js.map +0 -1
- package/dist/chunk-UTB4NROA.cjs +0 -887
- package/dist/chunk-UTB4NROA.cjs.map +0 -1
- package/dist/chunk-UTW33B5V.js +0 -6
- package/dist/chunk-UTW33B5V.js.map +0 -1
- package/dist/chunk-UYUBSD2V.cjs +0 -33
- package/dist/chunk-UYUBSD2V.cjs.map +0 -1
- package/dist/chunk-V3JEP5AG.cjs +0 -59
- package/dist/chunk-V3JEP5AG.cjs.map +0 -1
- package/dist/chunk-VFAGJXHR.js +0 -18
- package/dist/chunk-VFAGJXHR.js.map +0 -1
- package/dist/chunk-VMEE57E5.cjs +0 -58
- package/dist/chunk-VMEE57E5.cjs.map +0 -1
- package/dist/chunk-VQVBEX3Y.cjs +0 -113
- package/dist/chunk-VQVBEX3Y.cjs.map +0 -1
- package/dist/chunk-VZDXX7TT.cjs +0 -64
- package/dist/chunk-VZDXX7TT.cjs.map +0 -1
- package/dist/chunk-WE5ZTI4D.js +0 -346
- package/dist/chunk-WE5ZTI4D.js.map +0 -1
- package/dist/chunk-WEFUVABP.js +0 -19
- package/dist/chunk-WEFUVABP.js.map +0 -1
- package/dist/chunk-WMU4LRKC.js +0 -28
- package/dist/chunk-WMU4LRKC.js.map +0 -1
- package/dist/chunk-WQ24RRHL.cjs +0 -354
- package/dist/chunk-WQ24RRHL.cjs.map +0 -1
- package/dist/chunk-WW4CGS7G.cjs +0 -26
- package/dist/chunk-WW4CGS7G.cjs.map +0 -1
- package/dist/chunk-WXE5WCTM.js +0 -1144
- package/dist/chunk-WXE5WCTM.js.map +0 -1
- package/dist/chunk-X23BGIYA.cjs +0 -37
- package/dist/chunk-X23BGIYA.cjs.map +0 -1
- package/dist/chunk-XEW4FTR2.js +0 -98
- package/dist/chunk-XEW4FTR2.js.map +0 -1
- package/dist/chunk-XIOI4IYW.js +0 -167
- package/dist/chunk-XIOI4IYW.js.map +0 -1
- package/dist/chunk-XLVPJ37V.cjs +0 -44
- package/dist/chunk-XLVPJ37V.cjs.map +0 -1
- package/dist/chunk-XOHAXXZA.cjs +0 -51
- package/dist/chunk-XOHAXXZA.cjs.map +0 -1
- package/dist/chunk-Y4NRIHK6.cjs +0 -313
- package/dist/chunk-Y4NRIHK6.cjs.map +0 -1
- package/dist/chunk-Y4YMMKL3.js +0 -23
- package/dist/chunk-Y4YMMKL3.js.map +0 -1
- package/dist/chunk-YJNYBVE3.cjs +0 -14
- package/dist/chunk-YJNYBVE3.cjs.map +0 -1
- package/dist/chunk-Z762QNQP.cjs +0 -60
- package/dist/chunk-Z762QNQP.cjs.map +0 -1
- package/dist/chunk-ZG5KMBOF.js +0 -669
- package/dist/chunk-ZG5KMBOF.js.map +0 -1
- package/dist/chunk-ZKONQEFA.js +0 -344
- package/dist/chunk-ZKONQEFA.js.map +0 -1
- package/dist/chunk-ZR5X7QMH.js +0 -39
- package/dist/chunk-ZR5X7QMH.js.map +0 -1
- package/dist/chunk-ZW4BJQ26.js +0 -84
- package/dist/chunk-ZW4BJQ26.js.map +0 -1
- package/dist/climbs-BhlWuu0x.d.ts +0 -70
- package/dist/climbs-DgBFwySV.d.cts +0 -70
- package/dist/data/index.cjs.map +0 -1
- package/dist/data/index.js.map +0 -1
- package/dist/errors/index.cjs.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/geo/index.cjs.map +0 -1
- package/dist/geo/index.js.map +0 -1
- package/dist/icons/index.cjs.map +0 -1
- package/dist/icons/index.js.map +0 -1
- package/dist/itinerary-Dp2ZnqgD.d.cts +0 -178
- package/dist/itinerary-Dp2ZnqgD.d.ts +0 -178
- package/dist/layers/index.cjs.map +0 -1
- package/dist/layers/index.js.map +0 -1
- package/dist/map-client/index.cjs.map +0 -1
- package/dist/map-client/index.js.map +0 -1
- package/dist/markerSprite-DGBQF6PO.cjs +0 -49
- package/dist/markerSprite-DGBQF6PO.cjs.map +0 -1
- package/dist/markerSprite-DZLTR6F6.js +0 -8
- package/dist/markerSprite-DZLTR6F6.js.map +0 -1
- package/dist/mountayaMap-C9mxRFib.d.cts +0 -3277
- package/dist/mountayaMap-DgnlQ2fE.d.ts +0 -3277
- package/dist/paint-BgUcj8l7.d.cts +0 -118
- package/dist/paint-Dx_qGNE_.d.ts +0 -118
- package/dist/profile/index.cjs.map +0 -1
- package/dist/profile/index.js.map +0 -1
- package/dist/seams/index.cjs.map +0 -1
- package/dist/seams/index.js.map +0 -1
- package/dist/search/index.cjs.map +0 -1
- package/dist/search/index.js.map +0 -1
- package/dist/searchHighlight-DFE7LVIL.cjs +0 -33
- package/dist/searchHighlight-DFE7LVIL.cjs.map +0 -1
- package/dist/searchHighlight-MHAQZVWG.js +0 -12
- package/dist/searchHighlight-MHAQZVWG.js.map +0 -1
- package/dist/strings-30RSdIat.d.cts +0 -552
- package/dist/strings-DPTIbzT5.d.ts +0 -552
- package/dist/stripeImage-CQUXM2YI.js +0 -14
- package/dist/stripeImage-CQUXM2YI.js.map +0 -1
- package/dist/stripeImage-R43OPA6U.cjs +0 -39
- package/dist/stripeImage-R43OPA6U.cjs.map +0 -1
- package/dist/style/index.cjs.map +0 -1
- package/dist/style/index.js.map +0 -1
- package/dist/types-B034JMjl.d.ts +0 -973
- package/dist/types-B2NDLxQA.d.cts +0 -21
- package/dist/types-B2NDLxQA.d.ts +0 -21
- package/dist/types-C8aX5KMU.d.cts +0 -973
- package/dist/units/index.cjs.map +0 -1
- package/dist/units/index.js.map +0 -1
- package/dist/view/index.cjs.map +0 -1
- package/dist/view/index.js.map +0 -1
package/dist/agent/index.cjs
CHANGED
|
@@ -1,1939 +1,1186 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
const require_errors = require("../chunk-o3IRANDf.cjs");
|
|
7
|
+
const require_listeners = require("../chunk-BIEc_SkR.cjs");
|
|
8
|
+
const require_uuid = require("../chunk-C95NG0oD.cjs");
|
|
9
|
+
const require_errorStatus = require("../chunk-DcrTy-y2.cjs");
|
|
10
|
+
const agentToolErrorCodes = {
|
|
11
|
+
canceled: "canceled",
|
|
12
|
+
"capability-denied": "capability-denied",
|
|
13
|
+
"collab-locked": "collab-locked",
|
|
14
|
+
"confirmation-denied": "confirmation-denied",
|
|
15
|
+
"confirmation-timeout": "confirmation-timeout",
|
|
16
|
+
conflict: "conflict",
|
|
17
|
+
"draft-open": "draft-open",
|
|
18
|
+
"edit-in-progress": "edit-in-progress",
|
|
19
|
+
forbidden: "forbidden",
|
|
20
|
+
internal: "internal",
|
|
21
|
+
"invalid-input": "invalid-input",
|
|
22
|
+
"limit-reached": "limit-reached",
|
|
23
|
+
"not-found": "not-found",
|
|
24
|
+
"rate-limited": "rate-limited",
|
|
25
|
+
timeout: "timeout",
|
|
26
|
+
unavailable: "unavailable",
|
|
27
|
+
"unknown-tool": "unknown-tool",
|
|
28
|
+
"upgrade-required": "upgrade-required"
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
return isWireErrorCode(code) ? agentToolErrorCodes[code] : "internal";
|
|
30
|
+
const isWireErrorCode = (code) => Object.hasOwn(agentToolErrorCodes, code);
|
|
31
|
+
const toWireErrorCode = (code) => {
|
|
32
|
+
if (code === void 0) return;
|
|
33
|
+
return isWireErrorCode(code) ? agentToolErrorCodes[code] : "internal";
|
|
36
34
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
return json === void 0 ? 0 : new TextEncoder().encode(json).length;
|
|
35
|
+
const MAX_TOOL_RESULT_DATA_BYTES = 4096;
|
|
36
|
+
const byteLength = (value) => {
|
|
37
|
+
let json;
|
|
38
|
+
try {
|
|
39
|
+
json = JSON.stringify(value);
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return json === void 0 ? 0 : new TextEncoder().encode(json).length;
|
|
48
44
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return longest;
|
|
45
|
+
const longestCollection = (data) => {
|
|
46
|
+
let longest = null;
|
|
47
|
+
for (const [key, value] of Object.entries(data)) if (Array.isArray(value) && value.length > (longest?.items.length ?? -1)) longest = {
|
|
48
|
+
items: value,
|
|
49
|
+
key
|
|
50
|
+
};
|
|
51
|
+
return longest;
|
|
57
52
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return low;
|
|
53
|
+
const largestFittingSlice = (items, budget, render) => {
|
|
54
|
+
let low = 0;
|
|
55
|
+
let high = items.length;
|
|
56
|
+
while (low < high) {
|
|
57
|
+
const mid = Math.ceil((low + high) / 2);
|
|
58
|
+
const size = byteLength(render(mid));
|
|
59
|
+
if (size !== null && size <= budget) low = mid;
|
|
60
|
+
else high = mid - 1;
|
|
61
|
+
}
|
|
62
|
+
return low;
|
|
71
63
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
64
|
+
const buildToolResultPayload = (summary, data, state) => {
|
|
65
|
+
const base = {
|
|
66
|
+
summary,
|
|
67
|
+
...state ? { state } : {}
|
|
68
|
+
};
|
|
69
|
+
if (data === void 0 || data === null) return base;
|
|
70
|
+
const size = byteLength(data);
|
|
71
|
+
if (size === null) return {
|
|
72
|
+
...base,
|
|
73
|
+
truncated: true
|
|
74
|
+
};
|
|
75
|
+
if (size === 0) return base;
|
|
76
|
+
if (size <= 4096) return {
|
|
77
|
+
...base,
|
|
78
|
+
data
|
|
79
|
+
};
|
|
80
|
+
if (Array.isArray(data)) {
|
|
81
|
+
const items = data;
|
|
82
|
+
const returned = largestFittingSlice(items, MAX_TOOL_RESULT_DATA_BYTES, (count) => items.slice(0, count));
|
|
83
|
+
return {
|
|
84
|
+
...base,
|
|
85
|
+
data: items.slice(0, returned),
|
|
86
|
+
returned,
|
|
87
|
+
total: items.length,
|
|
88
|
+
truncated: true
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (typeof data === "object") {
|
|
92
|
+
const collection = longestCollection(data);
|
|
93
|
+
if (collection !== null) {
|
|
94
|
+
const { items, key } = collection;
|
|
95
|
+
const returned = largestFittingSlice(items, MAX_TOOL_RESULT_DATA_BYTES, (count) => ({
|
|
96
|
+
...data,
|
|
97
|
+
[key]: items.slice(0, count)
|
|
98
|
+
}));
|
|
99
|
+
if (returned > 0) return {
|
|
100
|
+
...base,
|
|
101
|
+
data: {
|
|
102
|
+
...data,
|
|
103
|
+
[key]: items.slice(0, returned)
|
|
104
|
+
},
|
|
105
|
+
returned,
|
|
106
|
+
total: items.length,
|
|
107
|
+
truncated: true,
|
|
108
|
+
truncatedField: key
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
...base,
|
|
114
|
+
truncated: true
|
|
115
|
+
};
|
|
123
116
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
name: entry.name,
|
|
131
|
-
parameters: entry.inputSchema
|
|
117
|
+
const toClientToolManifest = (entries) => entries.map((entry) => ({
|
|
118
|
+
...entry.requiresConfirmation ? { confirms: true } : {},
|
|
119
|
+
...entry.readOnly ? { read_only: true } : {},
|
|
120
|
+
description: entry.description,
|
|
121
|
+
name: entry.name,
|
|
122
|
+
parameters: entry.inputSchema
|
|
132
123
|
}));
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
baseMs: AGENT_RECONNECT_BASE_MS,
|
|
139
|
-
maxMs: RECONNECT_MAX_MS
|
|
124
|
+
const manifestKey = (manifest) => manifest.map((entry) => entry.name).sort().join("\n");
|
|
125
|
+
const routedKey = (manifest, serverTools) => `${manifestKey(manifest)}\0${serverTools?.join(",") ?? ""}`;
|
|
126
|
+
const reconnectSchedule = {
|
|
127
|
+
baseMs: 500,
|
|
128
|
+
maxMs: 8e3
|
|
140
129
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
130
|
+
const RECONNECT_MAX_ATTEMPTS = 6;
|
|
131
|
+
const RECONNECT_UNAVAILABLE_MAX_MS = 12e4;
|
|
132
|
+
const UNAVAILABLE_STATUS = 503;
|
|
133
|
+
const PRODUCTIVE_FRAME_COUNT = 1;
|
|
134
|
+
const REOPEN_STATUSES = [
|
|
135
|
+
429,
|
|
136
|
+
503,
|
|
137
|
+
504
|
|
138
|
+
];
|
|
139
|
+
const isConnectionFault = (error) => {
|
|
140
|
+
if (typeof error !== "object" || error === null || !("name" in error)) return false;
|
|
141
|
+
return error.name === "TypeError" || error.name === "MountayaConnectionError";
|
|
151
142
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
143
|
+
const isTransientStreamFault = (error) => {
|
|
144
|
+
const status = require_errorStatus.statusOf(error);
|
|
145
|
+
return status === void 0 ? isConnectionFault(error) : REOPEN_STATUSES.includes(status);
|
|
155
146
|
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
147
|
+
const createPendingStart = () => {
|
|
148
|
+
let settle = () => {};
|
|
149
|
+
return {
|
|
150
|
+
opened: new Promise((resolve) => {
|
|
151
|
+
settle = resolve;
|
|
152
|
+
}),
|
|
153
|
+
settle,
|
|
154
|
+
withdrawal: new AbortController()
|
|
155
|
+
};
|
|
163
156
|
};
|
|
164
157
|
var AgentEngine = class {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
* dispose tears the session down without signalling the gateway: it aborts the
|
|
685
|
-
* open stream and marks the run ended, releasing the parked consumer. The host
|
|
686
|
-
* calls it on unmount AFTER close() has POSTed (a closed tab finishes the run),
|
|
687
|
-
* with the abort as the backstop when the consumer would otherwise leak.
|
|
688
|
-
*
|
|
689
|
-
* It is the engine's shutdown latch: {@link start} and {@link resume} open nothing
|
|
690
|
-
* afterwards. What it can still cause is what a start sends to finish the run whose id the
|
|
691
|
-
* host never received, when it was withdrawn or gave up at its ceiling: that run's close,
|
|
692
|
-
* and, when the start's answer was lost, the one last post of the start that names the run
|
|
693
|
-
* (see {@link start}).
|
|
694
|
-
*
|
|
695
|
-
* The run the engine was reading, or stopped reading on its own, is the host's from here:
|
|
696
|
-
* the host holds its id, so it can resume it or close it, and a later {@link close} on
|
|
697
|
-
* this engine posts nothing for it.
|
|
698
|
-
*/
|
|
699
|
-
dispose() {
|
|
700
|
-
this.disposed = true;
|
|
701
|
-
this.unfinishedRunId = null;
|
|
702
|
-
this.withdrawStart();
|
|
703
|
-
this.setState("ended");
|
|
704
|
-
this.teardownStream();
|
|
705
|
-
}
|
|
706
|
-
/**
|
|
707
|
-
* leaveRun stops the engine reading what it reads, before a {@link start} or a
|
|
708
|
-
* {@link resume} reads a run: one engine reads one run. A start still waiting on its run
|
|
709
|
-
* id is withdrawn. A run still being read has its stream torn down, so none of its frames,
|
|
710
|
-
* its resume cursor or its `done` reach the run read next. A close is posted for the run the
|
|
711
|
-
* engine still owes one (see `unfinishedRunId`): the run it was reading, and the run it
|
|
712
|
-
* stopped reading on its own, because in both cases the engine was the one party reading
|
|
713
|
-
* it. `next` names the run about to be read, and that run is spared the close when it is
|
|
714
|
-
* the one owed it: a resume of it reads it again.
|
|
715
|
-
*/
|
|
716
|
-
leaveRun(next) {
|
|
717
|
-
this.withdrawStart();
|
|
718
|
-
if (this.currentRunId !== null && this.state !== "ended") {
|
|
719
|
-
this.teardownStream();
|
|
720
|
-
}
|
|
721
|
-
const owed = this.unfinishedRunId;
|
|
722
|
-
this.unfinishedRunId = null;
|
|
723
|
-
if (owed !== null && owed !== next) {
|
|
724
|
-
void this.closeQuietly(owed);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
/**
|
|
728
|
-
* withdrawStart withdraws the start still waiting on its run id, if one is: that start then
|
|
729
|
-
* finishes the run it opens instead of reading it (see {@link start}), and every message
|
|
730
|
-
* and routing update held behind it is dropped (see {@link send}).
|
|
731
|
-
*/
|
|
732
|
-
withdrawStart() {
|
|
733
|
-
const pending = this.pendingStart;
|
|
734
|
-
this.pendingStart = null;
|
|
735
|
-
pending?.settle(false);
|
|
736
|
-
pending?.withdrawal.abort();
|
|
737
|
-
}
|
|
738
|
-
/**
|
|
739
|
-
* beginRun readies the engine to read a new run once {@link leaveRun} has stopped it
|
|
740
|
-
* reading the last one. The run id, the resume cursor and the stream handle belong to that
|
|
741
|
-
* run, so all three go, and the state returns to `awaiting_input`: `ended` would stop the
|
|
742
|
-
* read loop before it opened anything.
|
|
743
|
-
*
|
|
744
|
-
* The rest is the engine's own and is reported to nobody here. A {@link resume} reports it,
|
|
745
|
-
* since its run may rest for good. A {@link start} reports `running` next, or the rest once
|
|
746
|
-
* it fails, so a start that replaces a run under way is one turn after another to the
|
|
747
|
-
* observer and no rest between them ({@link reportState}).
|
|
748
|
-
*
|
|
749
|
-
* @returns The generation of the read being readied, which a later start or resume replaces.
|
|
750
|
-
*/
|
|
751
|
-
beginRun() {
|
|
752
|
-
this.readGeneration += 1;
|
|
753
|
-
this.currentRunId = null;
|
|
754
|
-
this.lastEventId = void 0;
|
|
755
|
-
this.streamAbort = null;
|
|
756
|
-
this.sendHold = null;
|
|
757
|
-
this.state = "awaiting_input";
|
|
758
|
-
return this.readGeneration;
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* adoptRun makes `runId` the run this engine reads, and the run it owes a close until the
|
|
762
|
-
* run's `done` arrives or a close is posted. The memory of handled calls, and of the calls
|
|
763
|
-
* the engine reported among them, belongs to one run, because call ids are the run's own: it
|
|
764
|
-
* is kept when the run is the one already read (a resume of it) and emptied for any other.
|
|
765
|
-
*/
|
|
766
|
-
adoptRun(runId) {
|
|
767
|
-
this.currentRunId = runId;
|
|
768
|
-
this.unfinishedRunId = runId;
|
|
769
|
-
if (this.handledRunId !== runId) {
|
|
770
|
-
this.handledRunId = runId;
|
|
771
|
-
this.handledCalls.clear();
|
|
772
|
-
this.dispatchedCalls.clear();
|
|
773
|
-
this.runningCalls.clear();
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
/**
|
|
777
|
-
* claimCall records a call id as handled and reports whether the frame that names it is
|
|
778
|
-
* the engine's to act on. Two frames are not, and each is dropped whole:
|
|
779
|
-
*
|
|
780
|
-
* - one whose id the run already sighted, a replay of a call the engine ran or answered
|
|
781
|
-
* itself, whose result is already posted;
|
|
782
|
-
* - one the stream marks `settled`, a replay of a call whose outcome the stream already
|
|
783
|
-
* holds. An engine built after a page reload has no memory of the run, so the marker is
|
|
784
|
-
* all that tells it the call was answered.
|
|
785
|
-
*
|
|
786
|
-
* A settled id is recorded like any other, so a later frame that names it without the
|
|
787
|
-
* marker runs nothing either. A replayed frame with no marker and an id never sighted is
|
|
788
|
-
* one the stream holds no outcome for, and is the engine's.
|
|
789
|
-
*/
|
|
790
|
-
claimCall(toolCallId, settled) {
|
|
791
|
-
const sighted = this.handledCalls.has(toolCallId);
|
|
792
|
-
this.handledCalls.add(toolCallId);
|
|
793
|
-
return !sighted && settled !== true;
|
|
794
|
-
}
|
|
795
|
-
/**
|
|
796
|
-
* closeQuietly posts a close for a live run the engine leaves behind: one a withdrawn start
|
|
797
|
-
* opened and never read, whose id the host never received, and one a later start or resume
|
|
798
|
-
* replaced. A failed post is dropped: nobody is
|
|
799
|
-
* left to tell, and the gateway completes a run that goes quiet on its own.
|
|
800
|
-
*/
|
|
801
|
-
async closeQuietly(runId) {
|
|
802
|
-
try {
|
|
803
|
-
await this.config.transport.sendInput(runId, { type: "close" });
|
|
804
|
-
} catch {
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
/**
|
|
808
|
-
* releaseSubscription stops callback delivery from the open stream, exactly
|
|
809
|
-
* once. It reads the handle out and clears it BEFORE invoking it, so a
|
|
810
|
-
* re-entrant settle (the abort listener firing synchronously inside
|
|
811
|
-
* teardownStream, or a transport calling back into onClose) finds nothing
|
|
812
|
-
* left to release rather than calling the same handle twice.
|
|
813
|
-
*/
|
|
814
|
-
releaseSubscription() {
|
|
815
|
-
const unsubscribe = this.unsubscribe;
|
|
816
|
-
this.unsubscribe = null;
|
|
817
|
-
unsubscribe?.();
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* teardownStream releases the open events stream from both sides: the
|
|
821
|
-
* unsubscribe stops callback delivery (covering the scripted drain, which has
|
|
822
|
-
* no fetch to abort), and the abort closes the live fetch (and trips the resume
|
|
823
|
-
* detection in run()). Idempotent, so close() followed by dispose() is harmless.
|
|
824
|
-
*
|
|
825
|
-
* The unsubscribe runs FIRST because abort() dispatches its listener
|
|
826
|
-
* synchronously: that listener settles the read and clears the handle, so
|
|
827
|
-
* aborting first would leave nothing to unsubscribe and the scripted drain
|
|
828
|
-
* would stay parked for the life of the process.
|
|
829
|
-
*/
|
|
830
|
-
teardownStream() {
|
|
831
|
-
this.releaseSubscription();
|
|
832
|
-
this.streamAbort?.abort();
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* run consumes the run's event stream to completion, reconnecting when the
|
|
836
|
-
* stream closes before a terminal event. The gateway may close an SSE
|
|
837
|
-
* connection between turns (e.g. after `awaiting-input`); rather than leave the
|
|
838
|
-
* run silently stuck, run re-opens the stream from the tracked Last-Event-ID so
|
|
839
|
-
* the conversation continues. It returns once a terminal event ends the run, an
|
|
840
|
-
* abort tears the stream down, or the reconnects stop being productive: an open that
|
|
841
|
-
* closes having said nothing or one frame waits on the reconnect schedule, and the
|
|
842
|
-
* attempt ceiling below bounds how many of them in a row the run is given.
|
|
843
|
-
*
|
|
844
|
-
* A read that FAILS is judged by {@link isTransientStreamFault}. A transient one (a
|
|
845
|
-
* dropped connection, a 429, 503 or 504 at open) reopens from the last id on the same
|
|
846
|
-
* schedule and under the same ceiling as a hangup, and when the ceiling is reached on a
|
|
847
|
-
* read that failed, that failure (the drop, or the 429 or 504) is what the caller
|
|
848
|
-
* receives. The client's own reader reports an open that never answers and a stream gone
|
|
849
|
-
* silent as dropped connections, so both reopen. Any other failure ends the read at once and
|
|
850
|
-
* rejects with it. Either way the state is `ended` before the rejection, because the engine
|
|
851
|
-
* has stopped reading the run, and the run is owed a close (see {@link close}).
|
|
852
|
-
*
|
|
853
|
-
* An open answered 503 reopens on that schedule and outside that ceiling: it is left out of
|
|
854
|
-
* the count, neither adding to it nor clearing it, and such opens are bounded by
|
|
855
|
-
* {@link RECONNECT_UNAVAILABLE_MAX_MS} from the first of them, past which the caller receives
|
|
856
|
-
* the 503. A turn that moves starts the count and that time again.
|
|
857
|
-
*
|
|
858
|
-
* A stream that ends with the credential it was opened with, or that the API could not keep
|
|
859
|
-
* delivering (`interrupted`), reopens at once from the last id, and clears the count of
|
|
860
|
-
* fruitless opens: the transport closes either as `reconnect`, and the reopen carries the
|
|
861
|
-
* session token the client holds by then. A 401 on that reopen is a failure like any other
|
|
862
|
-
* refusal, and ends the read.
|
|
863
|
-
*
|
|
864
|
-
* A teardown ends the read wherever it finds it, the backoff between two opens included:
|
|
865
|
-
* a close or a dispose, and a start or a resume that replaced this run (see
|
|
866
|
-
* {@link leaveRun}).
|
|
867
|
-
*/
|
|
868
|
-
async run(runId) {
|
|
869
|
-
let attempts = 0;
|
|
870
|
-
let unavailable = null;
|
|
871
|
-
while (this.state !== "ended") {
|
|
872
|
-
const abort = new AbortController();
|
|
873
|
-
this.streamAbort = abort;
|
|
874
|
-
const result = await this.consume(runId, abort.signal);
|
|
875
|
-
if (result.ended || abort.signal.aborted) {
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
const { failure } = result;
|
|
879
|
-
if (failure !== void 0 && !failure.transient) {
|
|
880
|
-
this.setState("ended");
|
|
881
|
-
throw failure.error;
|
|
882
|
-
}
|
|
883
|
-
if (result.reconnect === true) {
|
|
884
|
-
attempts = 0;
|
|
885
|
-
unavailable = null;
|
|
886
|
-
continue;
|
|
887
|
-
}
|
|
888
|
-
if (result.frames > PRODUCTIVE_FRAME_COUNT) {
|
|
889
|
-
attempts = 0;
|
|
890
|
-
unavailable = null;
|
|
891
|
-
continue;
|
|
892
|
-
}
|
|
893
|
-
attempts += 1;
|
|
894
|
-
if (failure !== void 0 && chunkUYUBSD2V_cjs.statusOf(failure.error) === UNAVAILABLE_STATUS) {
|
|
895
|
-
unavailable ??= { count: 0, since: Date.now() };
|
|
896
|
-
unavailable.count += 1;
|
|
897
|
-
if (Date.now() - unavailable.since >= RECONNECT_UNAVAILABLE_MAX_MS) {
|
|
898
|
-
this.setState("ended");
|
|
899
|
-
throw failure.error;
|
|
900
|
-
}
|
|
901
|
-
} else if (attempts - (unavailable?.count ?? 0) > RECONNECT_MAX_ATTEMPTS) {
|
|
902
|
-
this.setState("ended");
|
|
903
|
-
if (failure !== void 0) {
|
|
904
|
-
throw failure.error;
|
|
905
|
-
}
|
|
906
|
-
return;
|
|
907
|
-
}
|
|
908
|
-
await this.backoff(attempts, abort.signal, chunkUYUBSD2V_cjs.retryAfterMsOf(failure?.error));
|
|
909
|
-
if (abort.signal.aborted) {
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* backoff waits out one reconnect delay, drawn by {@link reconnectDelayMs} on the run's
|
|
916
|
-
* {@link reconnectSchedule}: below a ceiling that doubles from AGENT_RECONNECT_BASE_MS to
|
|
917
|
-
* RECONNECT_MAX_MS, so the wait stays inside a person's patience and runs dropped together
|
|
918
|
-
* do not reopen together. Where the failure was a 429 or a 503 that named its wait (`namedMs`),
|
|
919
|
-
* that wait replaces the draw, with up to a second drawn above it and the timer's ceiling over
|
|
920
|
-
* it ({@link retryAfterDelayMs}), as SPEC §2 has `Retry-After` replace the schedule. It settles
|
|
921
|
-
* on whichever comes first, the timer or the stream teardown's abort, and drops both hooks
|
|
922
|
-
* either way: a run that reconnects many times must not accumulate listeners on the signal, nor
|
|
923
|
-
* leave a timer holding the loop after the session is gone.
|
|
924
|
-
*/
|
|
925
|
-
backoff(attempts, signal, namedMs) {
|
|
926
|
-
const delay = namedMs === void 0 ? chunkUYUBSD2V_cjs.reconnectDelayMs(attempts, reconnectSchedule) : chunkUYUBSD2V_cjs.retryAfterDelayMs(namedMs);
|
|
927
|
-
return new Promise((resolve) => {
|
|
928
|
-
const settle = () => {
|
|
929
|
-
clearTimeout(timer);
|
|
930
|
-
signal.removeEventListener("abort", settle);
|
|
931
|
-
resolve();
|
|
932
|
-
};
|
|
933
|
-
const timer = setTimeout(settle, delay);
|
|
934
|
-
signal.addEventListener("abort", settle, { once: true });
|
|
935
|
-
});
|
|
936
|
-
}
|
|
937
|
-
/**
|
|
938
|
-
* consume opens one read of the run's events stream and settles when it
|
|
939
|
-
* finishes, bridging the transport's AgentStreamHandlers callbacks to a single
|
|
940
|
-
* promise run() can await. It reacts to each decoded frame and records its id as
|
|
941
|
-
* the resume position when the frame arrives, taking it back when the frame's handling
|
|
942
|
-
* throws; the transport has already validated every frame, so it trusts the typed
|
|
943
|
-
* event. Unlike a per-turn drive it does NOT stop on
|
|
944
|
-
* `awaiting-input` (the stream stays open for the next message). It resolves
|
|
945
|
-
* with whether a terminal event ended the run and how many frames the stream
|
|
946
|
-
* delivered, so the caller can decide between reconnecting and settling and
|
|
947
|
-
* tell a productive open from a fruitless one, and with the failure when the
|
|
948
|
-
* read failed. It never rejects, a transport that throws from the open included:
|
|
949
|
-
* whether a failure ends the run is run()'s call.
|
|
950
|
-
* A terminal the SESSION decides (handle returning true on `done`) tears the
|
|
951
|
-
* subscription down here so no further frame is processed after the run is
|
|
952
|
-
* over. A teardown's abort (a close, a dispose, or a start or resume that replaced
|
|
953
|
-
* the run) settles the promise on its own (the transport fires no callback on a
|
|
954
|
-
* deliberate abort), so run() unwinds without waiting on a dead stream.
|
|
955
|
-
*
|
|
956
|
-
* It is one closure on purpose. Every handler reads and writes this read's own settle
|
|
957
|
-
* latch and frame count, and held as fields they would be the next read's to reach.
|
|
958
|
-
*/
|
|
959
|
-
consume(runId, signal) {
|
|
960
|
-
return new Promise((resolve) => {
|
|
961
|
-
let frames = 0;
|
|
962
|
-
let settled = false;
|
|
963
|
-
let unsubscribe;
|
|
964
|
-
let released = false;
|
|
965
|
-
const release = () => {
|
|
966
|
-
if (released) {
|
|
967
|
-
return;
|
|
968
|
-
}
|
|
969
|
-
released = true;
|
|
970
|
-
unsubscribe?.();
|
|
971
|
-
};
|
|
972
|
-
const settle = () => {
|
|
973
|
-
if (settled) {
|
|
974
|
-
return false;
|
|
975
|
-
}
|
|
976
|
-
settled = true;
|
|
977
|
-
signal.removeEventListener("abort", onAbort);
|
|
978
|
-
if (this.unsubscribe === release) {
|
|
979
|
-
this.unsubscribe = null;
|
|
980
|
-
}
|
|
981
|
-
release();
|
|
982
|
-
return true;
|
|
983
|
-
};
|
|
984
|
-
const finish = (ended, reconnect = false) => {
|
|
985
|
-
if (!settle()) {
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
resolve({ ended, frames, reconnect });
|
|
989
|
-
};
|
|
990
|
-
const fail = (error, transient) => {
|
|
991
|
-
if (!settle()) {
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
994
|
-
resolve({ ended: false, failure: { error, transient }, frames });
|
|
995
|
-
};
|
|
996
|
-
const onAbort = () => finish(false);
|
|
997
|
-
if (signal.aborted) {
|
|
998
|
-
finish(false);
|
|
999
|
-
return;
|
|
1000
|
-
}
|
|
1001
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
1002
|
-
const handlers = {
|
|
1003
|
-
onClose: (reason) => finish(reason === "terminal", reason === "reconnect"),
|
|
1004
|
-
onError: (error) => fail(error, isTransientStreamFault(error)),
|
|
1005
|
-
onFrame: async (frame) => {
|
|
1006
|
-
if (settled) {
|
|
1007
|
-
return;
|
|
1008
|
-
}
|
|
1009
|
-
frames += 1;
|
|
1010
|
-
const before = this.lastEventId;
|
|
1011
|
-
if (frame.id !== void 0) {
|
|
1012
|
-
this.lastEventId = frame.id;
|
|
1013
|
-
}
|
|
1014
|
-
let ended;
|
|
1015
|
-
try {
|
|
1016
|
-
ended = await this.handle(runId, frame.event);
|
|
1017
|
-
} catch (error) {
|
|
1018
|
-
if (frame.id !== void 0 && !settled && this.lastEventId === frame.id) {
|
|
1019
|
-
this.lastEventId = before;
|
|
1020
|
-
}
|
|
1021
|
-
fail(error, false);
|
|
1022
|
-
return;
|
|
1023
|
-
}
|
|
1024
|
-
if (ended) {
|
|
1025
|
-
finish(true);
|
|
1026
|
-
if (this.streamAbort?.signal === signal) {
|
|
1027
|
-
this.teardownStream();
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
},
|
|
1031
|
-
// A record that names a position and carries no frame moves the cursor too, so a
|
|
1032
|
-
// reopen resumes from the last position the stream named. A settled read's report is
|
|
1033
|
-
// stale, like its frames.
|
|
1034
|
-
onLastEventId: (lastEventId) => {
|
|
1035
|
-
if (!settled) {
|
|
1036
|
-
this.lastEventId = lastEventId;
|
|
1037
|
-
}
|
|
1038
|
-
},
|
|
1039
|
-
// A frame the transport skips, an event this build does not know or data it cannot read,
|
|
1040
|
-
// hands the run nothing and moves no position, and it is still a frame the stream
|
|
1041
|
-
// delivered: a stream saying one thing and then one this build skips has said two.
|
|
1042
|
-
onSkippedFrame: () => {
|
|
1043
|
-
if (!settled) {
|
|
1044
|
-
frames += 1;
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
};
|
|
1048
|
-
try {
|
|
1049
|
-
unsubscribe = this.config.transport.subscribe(runId, handlers, {
|
|
1050
|
-
lastEventId: this.lastEventId,
|
|
1051
|
-
signal
|
|
1052
|
-
});
|
|
1053
|
-
} catch (error) {
|
|
1054
|
-
fail(error, false);
|
|
1055
|
-
return;
|
|
1056
|
-
}
|
|
1057
|
-
if (released) {
|
|
1058
|
-
unsubscribe();
|
|
1059
|
-
} else {
|
|
1060
|
-
this.unsubscribe = release;
|
|
1061
|
-
}
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
/**
|
|
1065
|
-
* handle reacts to one event of the run `runId` names and reports whether the run
|
|
1066
|
-
* ended (so consume can stop). An active-turn event (streamed text, a tool call, a
|
|
1067
|
-
* confirm request) flips the lifecycle to `running`; a client tool-call is dispatched
|
|
1068
|
-
* through the bus and its result posted back; a confirm-required is routed through
|
|
1069
|
-
* the host gate and the decision posted back. Both answers go to `runId`, the run that
|
|
1070
|
-
* asked, even when a later start or resume replaced it while the tool ran or the host
|
|
1071
|
-
* decided. A tool-call or a confirm-required that {@link claimCall} refuses, one the
|
|
1072
|
-
* stream marks `settled` or one the run already handled, is dropped whole: it reaches
|
|
1073
|
-
* neither the bus, the gate nor the observer, and leaves the lifecycle as it is. An
|
|
1074
|
-
* `awaiting-input` event settles the turn to the `awaiting_input` state but
|
|
1075
|
-
* keeps the stream open (returns false); only a terminal `done` ends the run (returns
|
|
1076
|
-
* true).
|
|
1077
|
-
*/
|
|
1078
|
-
async handle(runId, event) {
|
|
1079
|
-
switch (event.type) {
|
|
1080
|
-
case "message-delta":
|
|
1081
|
-
this.setState("running");
|
|
1082
|
-
this.tell((observer) => observer.onMessageDelta?.(event.text));
|
|
1083
|
-
return false;
|
|
1084
|
-
case "message":
|
|
1085
|
-
this.setState("running");
|
|
1086
|
-
this.tell((observer) => observer.onMessage?.(event.content, event.message_index));
|
|
1087
|
-
return false;
|
|
1088
|
-
case "tool-call":
|
|
1089
|
-
return this.handleToolCall(runId, event);
|
|
1090
|
-
case "confirm-required":
|
|
1091
|
-
return this.handleConfirmRequired(runId, event);
|
|
1092
|
-
case "budget-exhausted":
|
|
1093
|
-
this.tell((observer) => observer.onError?.(event.reason, "budget-exhausted"));
|
|
1094
|
-
return false;
|
|
1095
|
-
case "error":
|
|
1096
|
-
this.tell((observer) => observer.onError?.(event.message, event.code));
|
|
1097
|
-
return false;
|
|
1098
|
-
case "checks-unmet":
|
|
1099
|
-
this.tell((observer) => observer.onChecksUnmet?.(event.unmet));
|
|
1100
|
-
return false;
|
|
1101
|
-
case "awaiting-input":
|
|
1102
|
-
this.setState("awaiting_input");
|
|
1103
|
-
return false;
|
|
1104
|
-
case "done":
|
|
1105
|
-
return this.handleDone(runId, event);
|
|
1106
|
-
case "tool-result":
|
|
1107
|
-
return this.handleToolResult(event);
|
|
1108
|
-
case "tool-abandoned":
|
|
1109
|
-
return this.handleToolAbandoned(event);
|
|
1110
|
-
case "reconnect":
|
|
1111
|
-
return false;
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
/**
|
|
1115
|
-
* handleToolCall runs one client tool call through the bus, reports it to the observer and
|
|
1116
|
-
* posts its result back into the run that asked. It answers false: a tool call never ends
|
|
1117
|
-
* the run.
|
|
1118
|
-
*
|
|
1119
|
-
* The call is running from its claim to its report. What the stream says of it meanwhile is
|
|
1120
|
-
* held ({@link holdWhileRunning}), and released when the handling throws before the report:
|
|
1121
|
-
* the engine has no report of its own then, and the stream's word settles the host's row.
|
|
1122
|
-
*/
|
|
1123
|
-
async handleToolCall(runId, event) {
|
|
1124
|
-
if (!this.claimCall(event.tool_call_id, event.settled)) {
|
|
1125
|
-
return false;
|
|
1126
|
-
}
|
|
1127
|
-
this.runningCalls.set(event.tool_call_id, null);
|
|
1128
|
-
try {
|
|
1129
|
-
return await this.runToolCall(runId, event);
|
|
1130
|
-
} catch (error) {
|
|
1131
|
-
this.releaseHeldWord(runId, event.tool_call_id);
|
|
1132
|
-
throw error;
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
/**
|
|
1136
|
-
* releaseHeldWord takes a call out of the running set and delivers what the stream said of it
|
|
1137
|
-
* while it ran, when it said anything. A call the engine reported is out of the set already,
|
|
1138
|
-
* and so is every call of a run the engine no longer holds the memory of: both release
|
|
1139
|
-
* nothing.
|
|
1140
|
-
*/
|
|
1141
|
-
releaseHeldWord(runId, toolCallId) {
|
|
1142
|
-
if (this.handledRunId !== runId) {
|
|
1143
|
-
return;
|
|
1144
|
-
}
|
|
1145
|
-
const held = this.runningCalls.get(toolCallId);
|
|
1146
|
-
this.runningCalls.delete(toolCallId);
|
|
1147
|
-
held?.();
|
|
1148
|
-
}
|
|
1149
|
-
/**
|
|
1150
|
-
* holdWhileRunning keeps what the stream says of a call the engine is still running, as the
|
|
1151
|
-
* report it would have made, and answers whether it did. The first word is the one kept: a
|
|
1152
|
-
* failed `tool-result` follows the `tool-abandoned` of a call the run gave up on.
|
|
1153
|
-
*/
|
|
1154
|
-
holdWhileRunning(toolCallId, report) {
|
|
1155
|
-
if (!this.runningCalls.has(toolCallId)) {
|
|
1156
|
-
return false;
|
|
1157
|
-
}
|
|
1158
|
-
if (this.runningCalls.get(toolCallId) === null) {
|
|
1159
|
-
this.runningCalls.set(toolCallId, report);
|
|
1160
|
-
}
|
|
1161
|
-
return true;
|
|
1162
|
-
}
|
|
1163
|
-
/** runToolCall is the handling of a claimed client tool call: see {@link handleToolCall}. */
|
|
1164
|
-
async runToolCall(runId, event) {
|
|
1165
|
-
const { bus, ctx, recoveryFor, stateDelta } = this.config;
|
|
1166
|
-
this.setState("running");
|
|
1167
|
-
this.tell((observer) => observer.onToolActivity?.(event.name));
|
|
1168
|
-
this.tell((observer) => observer.onToolCall?.(event.name, event.input, event.tool_call_id));
|
|
1169
|
-
const before = stateDelta?.capture(ctx);
|
|
1170
|
-
const result = await bus.dispatchFromModel(ctx, event.name, event.input);
|
|
1171
|
-
const moved = stateDelta && before !== void 0 ? stateDelta.diff(before, stateDelta.capture(ctx)) : void 0;
|
|
1172
|
-
if (result.ok && result.summary) {
|
|
1173
|
-
this.tell((observer) => observer.onToolActivity?.(result.summary));
|
|
1174
|
-
}
|
|
1175
|
-
const recovery = result.ok ? void 0 : recoveryFor?.(event.name, result.code);
|
|
1176
|
-
if (this.handledRunId === runId) {
|
|
1177
|
-
this.dispatchedCalls.add(event.tool_call_id);
|
|
1178
|
-
this.runningCalls.delete(event.tool_call_id);
|
|
1179
|
-
}
|
|
1180
|
-
this.tell(
|
|
1181
|
-
(observer) => observer.onToolResult?.(
|
|
1182
|
-
event.tool_call_id,
|
|
1183
|
-
result.ok ? { status: "ok", summary: result.summary } : result.code === "confirmation-denied" ? { status: "abandoned" } : { error: result.error, recovery, status: "error" }
|
|
1184
|
-
)
|
|
1185
|
-
);
|
|
1186
|
-
await this.postInput(runId, {
|
|
1187
|
-
ok: result.ok,
|
|
1188
|
-
tool_call_id: event.tool_call_id,
|
|
1189
|
-
type: "tool-result",
|
|
1190
|
-
...result.ok ? { result: buildToolResultPayload(result.summary, result.data, moved) } : {
|
|
1191
|
-
code: toWireErrorCode(result.code),
|
|
1192
|
-
error: result.error,
|
|
1193
|
-
// What to do about THIS failure of THIS tool, when the playbook
|
|
1194
|
-
// says. It rides the failing result rather than the prompt so it
|
|
1195
|
-
// costs nothing for the codes that never fire.
|
|
1196
|
-
...recovery ? { recovery } : {}
|
|
1197
|
-
}
|
|
1198
|
-
});
|
|
1199
|
-
return false;
|
|
1200
|
-
}
|
|
1201
|
-
/**
|
|
1202
|
-
* handleConfirmRequired puts a server tool's confirmation to the host gate and posts the
|
|
1203
|
-
* decision back into the run that asked. It answers false: a confirmation never ends the
|
|
1204
|
-
* run.
|
|
1205
|
-
*/
|
|
1206
|
-
async handleConfirmRequired(runId, event) {
|
|
1207
|
-
if (!this.claimCall(event.tool_call_id, event.settled)) {
|
|
1208
|
-
return false;
|
|
1209
|
-
}
|
|
1210
|
-
this.setState("running");
|
|
1211
|
-
const approved = await this.config.confirmServerTool({ name: event.name });
|
|
1212
|
-
await this.postInput(runId, {
|
|
1213
|
-
approved,
|
|
1214
|
-
tool_call_id: event.tool_call_id,
|
|
1215
|
-
type: "confirm"
|
|
1216
|
-
});
|
|
1217
|
-
return false;
|
|
1218
|
-
}
|
|
1219
|
-
/**
|
|
1220
|
-
* handleDone reports how the run ended and ends the read, unless a start or a resume made
|
|
1221
|
-
* from the callback has already replaced it. It answers true: `done` is the one terminal.
|
|
1222
|
-
*/
|
|
1223
|
-
handleDone(runId, event) {
|
|
1224
|
-
if (this.unfinishedRunId === runId) {
|
|
1225
|
-
this.unfinishedRunId = null;
|
|
1226
|
-
}
|
|
1227
|
-
const generation = this.readGeneration;
|
|
1228
|
-
this.tell((observer) => observer.onRunEnd?.(event.reason));
|
|
1229
|
-
if (generation === this.readGeneration) {
|
|
1230
|
-
this.setState("ended");
|
|
1231
|
-
}
|
|
1232
|
-
return true;
|
|
1233
|
-
}
|
|
1234
|
-
/**
|
|
1235
|
-
* handleToolResult reports a call's outcome as the stream states it, unless the call is one
|
|
1236
|
-
* the engine ran and reported itself. It answers false.
|
|
1237
|
-
*/
|
|
1238
|
-
handleToolResult(event) {
|
|
1239
|
-
if (this.dispatchedCalls.has(event.tool_call_id)) {
|
|
1240
|
-
return false;
|
|
1241
|
-
}
|
|
1242
|
-
const report = () => {
|
|
1243
|
-
const { summary } = event;
|
|
1244
|
-
if (summary) {
|
|
1245
|
-
this.tell((observer) => observer.onToolActivity?.(summary));
|
|
1246
|
-
}
|
|
1247
|
-
this.tell(
|
|
1248
|
-
(observer) => observer.onToolResult?.(
|
|
1249
|
-
event.tool_call_id,
|
|
1250
|
-
event.ok ? { status: "ok", summary: event.summary } : { error: event.error, status: "error" }
|
|
1251
|
-
)
|
|
1252
|
-
);
|
|
1253
|
-
};
|
|
1254
|
-
if (!this.holdWhileRunning(event.tool_call_id, report)) {
|
|
1255
|
-
report();
|
|
1256
|
-
}
|
|
1257
|
-
return false;
|
|
1258
|
-
}
|
|
1259
|
-
/**
|
|
1260
|
-
* handleToolAbandoned reports a call the run gave up on, unless the call is one the engine
|
|
1261
|
-
* ran and reported itself. It answers false.
|
|
1262
|
-
*/
|
|
1263
|
-
handleToolAbandoned(event) {
|
|
1264
|
-
if (this.dispatchedCalls.has(event.tool_call_id)) {
|
|
1265
|
-
return false;
|
|
1266
|
-
}
|
|
1267
|
-
const report = () => {
|
|
1268
|
-
this.tell(
|
|
1269
|
-
(observer) => observer.onToolResult?.(event.tool_call_id, {
|
|
1270
|
-
abandonedReason: event.reason,
|
|
1271
|
-
status: "abandoned"
|
|
1272
|
-
})
|
|
1273
|
-
);
|
|
1274
|
-
};
|
|
1275
|
-
if (!this.holdWhileRunning(event.tool_call_id, report)) {
|
|
1276
|
-
report();
|
|
1277
|
-
}
|
|
1278
|
-
return false;
|
|
1279
|
-
}
|
|
1280
|
-
/**
|
|
1281
|
-
* setState records the lifecycle transition and notifies the observer only on
|
|
1282
|
-
* an actual change, so the host does not re-render on a no-op.
|
|
1283
|
-
*
|
|
1284
|
-
* Every report, a no-op included, drops the hold the sends being posted have on `running`:
|
|
1285
|
-
* whatever speaks here (a frame, a close, a new run) owns the state from then on. A send
|
|
1286
|
-
* reports its own `running` through {@link reportState}, which keeps the hold.
|
|
1287
|
-
*/
|
|
1288
|
-
setState(next) {
|
|
1289
|
-
this.sendHold = null;
|
|
1290
|
-
this.reportState(next);
|
|
1291
|
-
}
|
|
1292
|
-
/**
|
|
1293
|
-
* reportState is {@link setState} without the drop of the hold, for the one report that is
|
|
1294
|
-
* the hold's own: the `running` of a send.
|
|
1295
|
-
*
|
|
1296
|
-
* The observer is told a state that differs from the one it was told last, which is the
|
|
1297
|
-
* engine's own state but while a start readies its run ({@link beginRun}).
|
|
1298
|
-
*/
|
|
1299
|
-
reportState(next) {
|
|
1300
|
-
this.state = next;
|
|
1301
|
-
if (this.reported === next) {
|
|
1302
|
-
return;
|
|
1303
|
-
}
|
|
1304
|
-
this.reported = next;
|
|
1305
|
-
this.tell((observer) => observer.onStateChange?.(next));
|
|
1306
|
-
}
|
|
1307
|
-
/**
|
|
1308
|
-
* tell hands the observer one report. The observer answers nothing the run waits on, so a
|
|
1309
|
-
* callback that throws is a defect of the host's own rendering and never the run's: its fault
|
|
1310
|
-
* reaches the program through {@link surfaceFault}, and the read goes on.
|
|
1311
|
-
*/
|
|
1312
|
-
tell(report) {
|
|
1313
|
-
try {
|
|
1314
|
-
report(this.config.observer);
|
|
1315
|
-
} catch (fault) {
|
|
1316
|
-
chunkWW4CGS7G_cjs.surfaceFault(fault);
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
/**
|
|
1320
|
-
* postInput sends one input frame back into the run `runId` names, the run that asked
|
|
1321
|
-
* for it, and reports a failure as a fault in the conversation instead of throwing.
|
|
1322
|
-
*
|
|
1323
|
-
* The catch is the point. `start()` ends with `await this.run(runId)`, so the whole
|
|
1324
|
-
* consume loop lives inside the start promise, and an unguarded rejection here would
|
|
1325
|
-
* leave `handle()` as a fault of the engine's own: the read would end for good, and
|
|
1326
|
-
* `start()` would reject into the host's START error path. A network blip on turn
|
|
1327
|
-
* twelve would then render "could not start", clear the started guard and drop the run
|
|
1328
|
-
* id, so the still-alive gateway run could never be resumed and the model's call would
|
|
1329
|
-
* expire as `tool-abandoned` with the user told nothing true about why.
|
|
1330
|
-
*
|
|
1331
|
-
* Reporting and continuing is the right shape: the run is still open, the stream is
|
|
1332
|
-
* still readable, and the gateway abandons the unanswered call on its own timeout so
|
|
1333
|
-
* the model can replan. What is lost is one tool result, which is a turn-level fault,
|
|
1334
|
-
* not a session-level one. A run a later start or resume replaced has nobody reading
|
|
1335
|
-
* it, so a failure to answer it is dropped rather than reported into the run that
|
|
1336
|
-
* replaced it. So is a failure to answer a run the engine has stopped reading, after a
|
|
1337
|
-
* {@link close} or a {@link dispose}: the host ended that conversation, and an error line
|
|
1338
|
-
* under it would report a fault in a run nobody is in.
|
|
1339
|
-
*
|
|
1340
|
-
* The message is deliberately empty. A fetch rejection carries an English,
|
|
1341
|
-
* internal string, and the host resolves an empty message to its own localized
|
|
1342
|
-
* generic line, the same rule the run's other self-raised terminals follow.
|
|
1343
|
-
*/
|
|
1344
|
-
async postInput(runId, input) {
|
|
1345
|
-
try {
|
|
1346
|
-
await this.config.transport.sendInput(runId, input);
|
|
1347
|
-
} catch {
|
|
1348
|
-
if (this.currentRunId === runId && this.state !== "ended") {
|
|
1349
|
-
this.tell((observer) => observer.onError?.(""));
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
158
|
+
config;
|
|
159
|
+
currentRunId = null;
|
|
160
|
+
unfinishedRunId = null;
|
|
161
|
+
state = "awaiting_input";
|
|
162
|
+
reported = "awaiting_input";
|
|
163
|
+
sendHold = null;
|
|
164
|
+
sendReporting = false;
|
|
165
|
+
lastEventId;
|
|
166
|
+
streamAbort = null;
|
|
167
|
+
unsubscribe = null;
|
|
168
|
+
readGeneration = 0;
|
|
169
|
+
routedNames = "";
|
|
170
|
+
routingUpdates = 0;
|
|
171
|
+
routedUpdate = 0;
|
|
172
|
+
disposed = false;
|
|
173
|
+
pendingStart = null;
|
|
174
|
+
handledCalls = /* @__PURE__ */ new Set();
|
|
175
|
+
handledRunId = null;
|
|
176
|
+
dispatchedCalls = /* @__PURE__ */ new Set();
|
|
177
|
+
runningCalls = /* @__PURE__ */ new Map();
|
|
178
|
+
constructor(config) {
|
|
179
|
+
this.config = config;
|
|
180
|
+
}
|
|
181
|
+
async start(message, organizationId, context) {
|
|
182
|
+
if (this.disposed) return;
|
|
183
|
+
this.leaveRun();
|
|
184
|
+
const pending = createPendingStart();
|
|
185
|
+
this.pendingStart = pending;
|
|
186
|
+
let runId;
|
|
187
|
+
try {
|
|
188
|
+
this.beginRun();
|
|
189
|
+
const manifest = this.routedManifest();
|
|
190
|
+
const serverTools = this.routedServerTools();
|
|
191
|
+
if (pending.withdrawal.signal.aborted) return;
|
|
192
|
+
const params = {
|
|
193
|
+
client_tools: manifest,
|
|
194
|
+
context,
|
|
195
|
+
message,
|
|
196
|
+
organization_id: organizationId,
|
|
197
|
+
profile: this.config.profile,
|
|
198
|
+
...serverTools === void 0 ? {} : { server_tools: serverTools }
|
|
199
|
+
};
|
|
200
|
+
const idempotencyKey = require_uuid.randomUuid();
|
|
201
|
+
this.setState("running");
|
|
202
|
+
if (pending.withdrawal.signal.aborted) return;
|
|
203
|
+
this.routedNames = routedKey(manifest, serverTools);
|
|
204
|
+
({runId} = await this.config.transport.startRun(params, { idempotencyKey }));
|
|
205
|
+
} catch (error) {
|
|
206
|
+
pending.settle(false);
|
|
207
|
+
if (!pending.withdrawal.signal.aborted) {
|
|
208
|
+
this.setState("awaiting_input");
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
return;
|
|
212
|
+
} finally {
|
|
213
|
+
if (this.pendingStart === pending) this.pendingStart = null;
|
|
214
|
+
}
|
|
215
|
+
if (pending.withdrawal.signal.aborted) {
|
|
216
|
+
await this.closeQuietly(runId);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.adoptRun(runId);
|
|
220
|
+
pending.settle(true);
|
|
221
|
+
this.tell((observer) => observer.onRunId?.(runId));
|
|
222
|
+
await this.run(runId);
|
|
223
|
+
}
|
|
224
|
+
async resume(runId, lastEventId) {
|
|
225
|
+
if (this.disposed) return;
|
|
226
|
+
const held = this.currentRunId === runId ? this.lastEventId : void 0;
|
|
227
|
+
this.leaveRun(runId);
|
|
228
|
+
const generation = this.beginRun();
|
|
229
|
+
this.setState("awaiting_input");
|
|
230
|
+
if (this.disposed || generation !== this.readGeneration) return;
|
|
231
|
+
this.adoptRun(runId);
|
|
232
|
+
this.lastEventId = lastEventId ?? held;
|
|
233
|
+
await this.run(runId);
|
|
234
|
+
}
|
|
235
|
+
streamPosition() {
|
|
236
|
+
return this.currentRunId === null || this.lastEventId === void 0 ? null : {
|
|
237
|
+
lastEventId: this.lastEventId,
|
|
238
|
+
runId: this.currentRunId
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
runId() {
|
|
242
|
+
return this.currentRunId;
|
|
243
|
+
}
|
|
244
|
+
async send(message) {
|
|
245
|
+
if (this.sendReporting) await Promise.resolve();
|
|
246
|
+
const pending = this.pendingStart;
|
|
247
|
+
if (pending !== null && !await pending.opened) return;
|
|
248
|
+
if (this.disposed) throw new require_errors.MountayaElementsError("send: the engine is disposed and opens no more runs. Build a new engine to continue the conversation.");
|
|
249
|
+
if (this.state === "ended") throw new require_errors.MountayaElementsError("send: the run has ended, and a run that ended takes no more messages. Open the next run with start().");
|
|
250
|
+
const runId = this.currentRunId;
|
|
251
|
+
if (runId === null) throw new require_errors.MountayaElementsError("send: no run is open. Open one with start(), or re-attach to one with resume(), before sending into it.");
|
|
252
|
+
const hold = this.sendHold ?? {
|
|
253
|
+
found: this.state,
|
|
254
|
+
posting: 0
|
|
255
|
+
};
|
|
256
|
+
hold.posting += 1;
|
|
257
|
+
this.sendHold = hold;
|
|
258
|
+
try {
|
|
259
|
+
this.sendReporting = true;
|
|
260
|
+
try {
|
|
261
|
+
this.reportState("running");
|
|
262
|
+
} finally {
|
|
263
|
+
this.sendReporting = false;
|
|
264
|
+
}
|
|
265
|
+
if (!this.reads(runId)) return;
|
|
266
|
+
await this.config.transport.sendInput(runId, {
|
|
267
|
+
content: message,
|
|
268
|
+
type: "user-message"
|
|
269
|
+
});
|
|
270
|
+
hold.found = null;
|
|
271
|
+
} catch (error) {
|
|
272
|
+
if (this.sendHold === hold && hold.posting === 1 && hold.found === "awaiting_input") this.setState("awaiting_input");
|
|
273
|
+
throw error;
|
|
274
|
+
} finally {
|
|
275
|
+
hold.posting -= 1;
|
|
276
|
+
if (this.sendHold === hold && hold.posting === 0) this.sendHold = null;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
reads(runId) {
|
|
280
|
+
return !this.disposed && this.state !== "ended" && this.currentRunId === runId;
|
|
281
|
+
}
|
|
282
|
+
routedManifest() {
|
|
283
|
+
const { bus, ctx, toolSurface } = this.config;
|
|
284
|
+
return toClientToolManifest(bus.manifest(ctx.capabilities, toolSurface?.()));
|
|
285
|
+
}
|
|
286
|
+
routedServerTools() {
|
|
287
|
+
if (this.config.routesServerTools !== true) return;
|
|
288
|
+
const surface = this.config.toolSurface?.();
|
|
289
|
+
return surface ? [...surface].sort() : void 0;
|
|
290
|
+
}
|
|
291
|
+
async routeTools() {
|
|
292
|
+
const pending = this.pendingStart;
|
|
293
|
+
if (pending !== null && !await pending.opened) return;
|
|
294
|
+
if (!this.currentRunId || this.state === "ended") return;
|
|
295
|
+
const manifest = this.routedManifest();
|
|
296
|
+
const serverTools = this.routedServerTools();
|
|
297
|
+
const key = routedKey(manifest, serverTools);
|
|
298
|
+
if (key === this.routedNames) return;
|
|
299
|
+
const runId = this.currentRunId;
|
|
300
|
+
this.routingUpdates += 1;
|
|
301
|
+
const update = this.routingUpdates;
|
|
302
|
+
await this.config.transport.sendInput(runId, {
|
|
303
|
+
client_tools: manifest,
|
|
304
|
+
...serverTools === void 0 ? {} : { server_tools: serverTools },
|
|
305
|
+
type: "manifest-update"
|
|
306
|
+
});
|
|
307
|
+
if (this.currentRunId === runId && update > this.routedUpdate) {
|
|
308
|
+
this.routedNames = key;
|
|
309
|
+
this.routedUpdate = update;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async close() {
|
|
313
|
+
if (this.pendingStart !== null) {
|
|
314
|
+
this.withdrawStart();
|
|
315
|
+
this.setState("ended");
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const runId = this.unfinishedRunId;
|
|
319
|
+
if (runId === null) return;
|
|
320
|
+
this.unfinishedRunId = null;
|
|
321
|
+
this.setState("ended");
|
|
322
|
+
this.teardownStream();
|
|
323
|
+
await this.config.transport.sendInput(runId, { type: "close" });
|
|
324
|
+
}
|
|
325
|
+
dispose() {
|
|
326
|
+
this.disposed = true;
|
|
327
|
+
this.unfinishedRunId = null;
|
|
328
|
+
this.withdrawStart();
|
|
329
|
+
this.setState("ended");
|
|
330
|
+
this.teardownStream();
|
|
331
|
+
}
|
|
332
|
+
leaveRun(next) {
|
|
333
|
+
this.withdrawStart();
|
|
334
|
+
if (this.currentRunId !== null && this.state !== "ended") this.teardownStream();
|
|
335
|
+
const owed = this.unfinishedRunId;
|
|
336
|
+
this.unfinishedRunId = null;
|
|
337
|
+
if (owed !== null && owed !== next) this.closeQuietly(owed);
|
|
338
|
+
}
|
|
339
|
+
withdrawStart() {
|
|
340
|
+
const pending = this.pendingStart;
|
|
341
|
+
this.pendingStart = null;
|
|
342
|
+
pending?.settle(false);
|
|
343
|
+
pending?.withdrawal.abort();
|
|
344
|
+
}
|
|
345
|
+
beginRun() {
|
|
346
|
+
this.readGeneration += 1;
|
|
347
|
+
this.currentRunId = null;
|
|
348
|
+
this.lastEventId = void 0;
|
|
349
|
+
this.streamAbort = null;
|
|
350
|
+
this.sendHold = null;
|
|
351
|
+
this.state = "awaiting_input";
|
|
352
|
+
return this.readGeneration;
|
|
353
|
+
}
|
|
354
|
+
adoptRun(runId) {
|
|
355
|
+
this.currentRunId = runId;
|
|
356
|
+
this.unfinishedRunId = runId;
|
|
357
|
+
if (this.handledRunId !== runId) {
|
|
358
|
+
this.handledRunId = runId;
|
|
359
|
+
this.handledCalls.clear();
|
|
360
|
+
this.dispatchedCalls.clear();
|
|
361
|
+
this.runningCalls.clear();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
claimCall(toolCallId, settled) {
|
|
365
|
+
const sighted = this.handledCalls.has(toolCallId);
|
|
366
|
+
this.handledCalls.add(toolCallId);
|
|
367
|
+
return !sighted && settled !== true;
|
|
368
|
+
}
|
|
369
|
+
async closeQuietly(runId) {
|
|
370
|
+
try {
|
|
371
|
+
await this.config.transport.sendInput(runId, { type: "close" });
|
|
372
|
+
} catch {}
|
|
373
|
+
}
|
|
374
|
+
releaseSubscription() {
|
|
375
|
+
const unsubscribe = this.unsubscribe;
|
|
376
|
+
this.unsubscribe = null;
|
|
377
|
+
unsubscribe?.();
|
|
378
|
+
}
|
|
379
|
+
teardownStream() {
|
|
380
|
+
this.releaseSubscription();
|
|
381
|
+
this.streamAbort?.abort();
|
|
382
|
+
}
|
|
383
|
+
async run(runId) {
|
|
384
|
+
let attempts = 0;
|
|
385
|
+
let unavailable = null;
|
|
386
|
+
while (this.state !== "ended") {
|
|
387
|
+
const abort = new AbortController();
|
|
388
|
+
this.streamAbort = abort;
|
|
389
|
+
const result = await this.consume(runId, abort.signal);
|
|
390
|
+
if (result.ended || abort.signal.aborted) return;
|
|
391
|
+
const { failure } = result;
|
|
392
|
+
if (failure !== void 0 && !failure.transient) {
|
|
393
|
+
this.setState("ended");
|
|
394
|
+
throw failure.error;
|
|
395
|
+
}
|
|
396
|
+
if (result.reconnect === true) {
|
|
397
|
+
attempts = 0;
|
|
398
|
+
unavailable = null;
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
if (result.frames > PRODUCTIVE_FRAME_COUNT) {
|
|
402
|
+
attempts = 0;
|
|
403
|
+
unavailable = null;
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
attempts += 1;
|
|
407
|
+
if (failure !== void 0 && require_errorStatus.statusOf(failure.error) === UNAVAILABLE_STATUS) {
|
|
408
|
+
unavailable ??= {
|
|
409
|
+
count: 0,
|
|
410
|
+
since: Date.now()
|
|
411
|
+
};
|
|
412
|
+
unavailable.count += 1;
|
|
413
|
+
if (Date.now() - unavailable.since >= RECONNECT_UNAVAILABLE_MAX_MS) {
|
|
414
|
+
this.setState("ended");
|
|
415
|
+
throw failure.error;
|
|
416
|
+
}
|
|
417
|
+
} else if (attempts - (unavailable?.count ?? 0) > RECONNECT_MAX_ATTEMPTS) {
|
|
418
|
+
this.setState("ended");
|
|
419
|
+
if (failure !== void 0) throw failure.error;
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
await this.backoff(attempts, abort.signal, require_errorStatus.retryAfterMsOf(failure?.error));
|
|
423
|
+
if (abort.signal.aborted) return;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
backoff(attempts, signal, namedMs) {
|
|
427
|
+
const delay = namedMs === void 0 ? require_errorStatus.reconnectDelayMs(attempts, reconnectSchedule) : require_errorStatus.retryAfterDelayMs(namedMs);
|
|
428
|
+
return new Promise((resolve) => {
|
|
429
|
+
const settle = () => {
|
|
430
|
+
clearTimeout(timer);
|
|
431
|
+
signal.removeEventListener("abort", settle);
|
|
432
|
+
resolve();
|
|
433
|
+
};
|
|
434
|
+
const timer = setTimeout(settle, delay);
|
|
435
|
+
signal.addEventListener("abort", settle, { once: true });
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
consume(runId, signal) {
|
|
439
|
+
return new Promise((resolve) => {
|
|
440
|
+
let frames = 0;
|
|
441
|
+
let settled = false;
|
|
442
|
+
let unsubscribe;
|
|
443
|
+
let released = false;
|
|
444
|
+
const release = () => {
|
|
445
|
+
if (released) return;
|
|
446
|
+
released = true;
|
|
447
|
+
unsubscribe?.();
|
|
448
|
+
};
|
|
449
|
+
const settle = () => {
|
|
450
|
+
if (settled) return false;
|
|
451
|
+
settled = true;
|
|
452
|
+
signal.removeEventListener("abort", onAbort);
|
|
453
|
+
if (this.unsubscribe === release) this.unsubscribe = null;
|
|
454
|
+
release();
|
|
455
|
+
return true;
|
|
456
|
+
};
|
|
457
|
+
const finish = (ended, reconnect = false) => {
|
|
458
|
+
if (!settle()) return;
|
|
459
|
+
resolve({
|
|
460
|
+
ended,
|
|
461
|
+
frames,
|
|
462
|
+
reconnect
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
const fail = (error, transient) => {
|
|
466
|
+
if (!settle()) return;
|
|
467
|
+
resolve({
|
|
468
|
+
ended: false,
|
|
469
|
+
failure: {
|
|
470
|
+
error,
|
|
471
|
+
transient
|
|
472
|
+
},
|
|
473
|
+
frames
|
|
474
|
+
});
|
|
475
|
+
};
|
|
476
|
+
const onAbort = () => finish(false);
|
|
477
|
+
if (signal.aborted) {
|
|
478
|
+
finish(false);
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
482
|
+
const handlers = {
|
|
483
|
+
onClose: (reason) => finish(reason === "terminal", reason === "reconnect"),
|
|
484
|
+
onError: (error) => fail(error, isTransientStreamFault(error)),
|
|
485
|
+
onFrame: async (frame) => {
|
|
486
|
+
if (settled) return;
|
|
487
|
+
frames += 1;
|
|
488
|
+
const before = this.lastEventId;
|
|
489
|
+
if (frame.id !== void 0) this.lastEventId = frame.id;
|
|
490
|
+
let ended;
|
|
491
|
+
try {
|
|
492
|
+
ended = await this.handle(runId, frame.event);
|
|
493
|
+
} catch (error) {
|
|
494
|
+
if (frame.id !== void 0 && !settled && this.lastEventId === frame.id) this.lastEventId = before;
|
|
495
|
+
fail(error, false);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
if (ended) {
|
|
499
|
+
finish(true);
|
|
500
|
+
if (this.streamAbort?.signal === signal) this.teardownStream();
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
onLastEventId: (lastEventId) => {
|
|
504
|
+
if (!settled) this.lastEventId = lastEventId;
|
|
505
|
+
},
|
|
506
|
+
onSkippedFrame: () => {
|
|
507
|
+
if (!settled) frames += 1;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
try {
|
|
511
|
+
unsubscribe = this.config.transport.subscribe(runId, handlers, {
|
|
512
|
+
lastEventId: this.lastEventId,
|
|
513
|
+
signal
|
|
514
|
+
});
|
|
515
|
+
} catch (error) {
|
|
516
|
+
fail(error, false);
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
if (released) unsubscribe();
|
|
520
|
+
else this.unsubscribe = release;
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
async handle(runId, event) {
|
|
524
|
+
switch (event.type) {
|
|
525
|
+
case "message-delta":
|
|
526
|
+
this.setState("running");
|
|
527
|
+
this.tell((observer) => observer.onMessageDelta?.(event.text));
|
|
528
|
+
return false;
|
|
529
|
+
case "message":
|
|
530
|
+
this.setState("running");
|
|
531
|
+
this.tell((observer) => observer.onMessage?.(event.content, event.message_index));
|
|
532
|
+
return false;
|
|
533
|
+
case "tool-call": return this.handleToolCall(runId, event);
|
|
534
|
+
case "confirm-required": return this.handleConfirmRequired(runId, event);
|
|
535
|
+
case "budget-exhausted":
|
|
536
|
+
this.tell((observer) => observer.onError?.(event.reason, "budget-exhausted"));
|
|
537
|
+
return false;
|
|
538
|
+
case "error":
|
|
539
|
+
this.tell((observer) => observer.onError?.(event.message, event.code));
|
|
540
|
+
return false;
|
|
541
|
+
case "checks-unmet":
|
|
542
|
+
this.tell((observer) => observer.onChecksUnmet?.(event.unmet));
|
|
543
|
+
return false;
|
|
544
|
+
case "awaiting-input":
|
|
545
|
+
this.setState("awaiting_input");
|
|
546
|
+
return false;
|
|
547
|
+
case "done": return this.handleDone(runId, event);
|
|
548
|
+
case "tool-result": return this.handleToolResult(event);
|
|
549
|
+
case "tool-abandoned": return this.handleToolAbandoned(event);
|
|
550
|
+
case "reconnect": return false;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
async handleToolCall(runId, event) {
|
|
554
|
+
if (!this.claimCall(event.tool_call_id, event.settled)) return false;
|
|
555
|
+
this.runningCalls.set(event.tool_call_id, null);
|
|
556
|
+
try {
|
|
557
|
+
return await this.runToolCall(runId, event);
|
|
558
|
+
} catch (error) {
|
|
559
|
+
this.releaseHeldWord(runId, event.tool_call_id);
|
|
560
|
+
throw error;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
releaseHeldWord(runId, toolCallId) {
|
|
564
|
+
if (this.handledRunId !== runId) return;
|
|
565
|
+
const held = this.runningCalls.get(toolCallId);
|
|
566
|
+
this.runningCalls.delete(toolCallId);
|
|
567
|
+
held?.();
|
|
568
|
+
}
|
|
569
|
+
holdWhileRunning(toolCallId, report) {
|
|
570
|
+
if (!this.runningCalls.has(toolCallId)) return false;
|
|
571
|
+
if (this.runningCalls.get(toolCallId) === null) this.runningCalls.set(toolCallId, report);
|
|
572
|
+
return true;
|
|
573
|
+
}
|
|
574
|
+
async runToolCall(runId, event) {
|
|
575
|
+
const { bus, ctx, recoveryFor, stateDelta } = this.config;
|
|
576
|
+
this.setState("running");
|
|
577
|
+
this.tell((observer) => observer.onToolActivity?.(event.name));
|
|
578
|
+
this.tell((observer) => observer.onToolCall?.(event.name, event.input, event.tool_call_id));
|
|
579
|
+
const before = stateDelta?.capture(ctx);
|
|
580
|
+
const result = await bus.dispatchFromModel(ctx, event.name, event.input);
|
|
581
|
+
const moved = stateDelta && before !== void 0 ? stateDelta.diff(before, stateDelta.capture(ctx)) : void 0;
|
|
582
|
+
if (result.ok && result.summary) this.tell((observer) => observer.onToolActivity?.(result.summary));
|
|
583
|
+
const recovery = result.ok ? void 0 : recoveryFor?.(event.name, result.code);
|
|
584
|
+
if (this.handledRunId === runId) {
|
|
585
|
+
this.dispatchedCalls.add(event.tool_call_id);
|
|
586
|
+
this.runningCalls.delete(event.tool_call_id);
|
|
587
|
+
}
|
|
588
|
+
this.tell((observer) => observer.onToolResult?.(event.tool_call_id, result.ok ? {
|
|
589
|
+
status: "ok",
|
|
590
|
+
summary: result.summary
|
|
591
|
+
} : result.code === "confirmation-denied" ? { status: "abandoned" } : {
|
|
592
|
+
error: result.error,
|
|
593
|
+
recovery,
|
|
594
|
+
status: "error"
|
|
595
|
+
}));
|
|
596
|
+
await this.postInput(runId, {
|
|
597
|
+
ok: result.ok,
|
|
598
|
+
tool_call_id: event.tool_call_id,
|
|
599
|
+
type: "tool-result",
|
|
600
|
+
...result.ok ? { result: buildToolResultPayload(result.summary, result.data, moved) } : {
|
|
601
|
+
code: toWireErrorCode(result.code),
|
|
602
|
+
error: result.error,
|
|
603
|
+
...recovery ? { recovery } : {}
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
return false;
|
|
607
|
+
}
|
|
608
|
+
async handleConfirmRequired(runId, event) {
|
|
609
|
+
if (!this.claimCall(event.tool_call_id, event.settled)) return false;
|
|
610
|
+
this.setState("running");
|
|
611
|
+
const approved = await this.config.confirmServerTool({ name: event.name });
|
|
612
|
+
await this.postInput(runId, {
|
|
613
|
+
approved,
|
|
614
|
+
tool_call_id: event.tool_call_id,
|
|
615
|
+
type: "confirm"
|
|
616
|
+
});
|
|
617
|
+
return false;
|
|
618
|
+
}
|
|
619
|
+
handleDone(runId, event) {
|
|
620
|
+
if (this.unfinishedRunId === runId) this.unfinishedRunId = null;
|
|
621
|
+
const generation = this.readGeneration;
|
|
622
|
+
this.tell((observer) => observer.onRunEnd?.(event.reason));
|
|
623
|
+
if (generation === this.readGeneration) this.setState("ended");
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
626
|
+
handleToolResult(event) {
|
|
627
|
+
if (this.dispatchedCalls.has(event.tool_call_id)) return false;
|
|
628
|
+
const report = () => {
|
|
629
|
+
const { summary } = event;
|
|
630
|
+
if (summary) this.tell((observer) => observer.onToolActivity?.(summary));
|
|
631
|
+
this.tell((observer) => observer.onToolResult?.(event.tool_call_id, event.ok ? {
|
|
632
|
+
status: "ok",
|
|
633
|
+
summary: event.summary
|
|
634
|
+
} : {
|
|
635
|
+
error: event.error,
|
|
636
|
+
status: "error"
|
|
637
|
+
}));
|
|
638
|
+
};
|
|
639
|
+
if (!this.holdWhileRunning(event.tool_call_id, report)) report();
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
642
|
+
handleToolAbandoned(event) {
|
|
643
|
+
if (this.dispatchedCalls.has(event.tool_call_id)) return false;
|
|
644
|
+
const report = () => {
|
|
645
|
+
this.tell((observer) => observer.onToolResult?.(event.tool_call_id, {
|
|
646
|
+
abandonedReason: event.reason,
|
|
647
|
+
status: "abandoned"
|
|
648
|
+
}));
|
|
649
|
+
};
|
|
650
|
+
if (!this.holdWhileRunning(event.tool_call_id, report)) report();
|
|
651
|
+
return false;
|
|
652
|
+
}
|
|
653
|
+
setState(next) {
|
|
654
|
+
this.sendHold = null;
|
|
655
|
+
this.reportState(next);
|
|
656
|
+
}
|
|
657
|
+
reportState(next) {
|
|
658
|
+
this.state = next;
|
|
659
|
+
if (this.reported === next) return;
|
|
660
|
+
this.reported = next;
|
|
661
|
+
this.tell((observer) => observer.onStateChange?.(next));
|
|
662
|
+
}
|
|
663
|
+
tell(report) {
|
|
664
|
+
try {
|
|
665
|
+
report(this.config.observer);
|
|
666
|
+
} catch (fault) {
|
|
667
|
+
require_listeners.surfaceFault(fault);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
async postInput(runId, input) {
|
|
671
|
+
try {
|
|
672
|
+
await this.config.transport.sendInput(runId, input);
|
|
673
|
+
} catch {
|
|
674
|
+
if (this.currentRunId === runId && this.state !== "ended") this.tell((observer) => observer.onError?.(""));
|
|
675
|
+
}
|
|
676
|
+
}
|
|
1353
677
|
};
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
switch (message.trim()) {
|
|
1372
|
-
case "turns":
|
|
1373
|
-
return copy.budget.turns;
|
|
1374
|
-
case "cost":
|
|
1375
|
-
return copy.budget.cost;
|
|
1376
|
-
default:
|
|
1377
|
-
return copy.budget.generic;
|
|
1378
|
-
}
|
|
1379
|
-
})();
|
|
1380
|
-
return draft?.open ? `${line} ${draft.note}` : line;
|
|
1381
|
-
}
|
|
1382
|
-
const trimmed = message.trim();
|
|
1383
|
-
return trimmed.length > 0 ? trimmed : copy.generic;
|
|
678
|
+
const resolveAgentError = (message, code, copy, draft) => {
|
|
679
|
+
if (code === "rate-limited") return copy.rateLimited;
|
|
680
|
+
if (code === "ai-provider-not-configured") return copy.notConfigured;
|
|
681
|
+
if (code === "looping") return copy.looping;
|
|
682
|
+
if (code === "access-revoked") return copy.accessRevoked;
|
|
683
|
+
if (code === "budget-exhausted") {
|
|
684
|
+
const line = (() => {
|
|
685
|
+
switch (message.trim()) {
|
|
686
|
+
case "turns": return copy.budget.turns;
|
|
687
|
+
case "cost": return copy.budget.cost;
|
|
688
|
+
default: return copy.budget.generic;
|
|
689
|
+
}
|
|
690
|
+
})();
|
|
691
|
+
return draft?.open ? `${line} ${draft.note}` : line;
|
|
692
|
+
}
|
|
693
|
+
const trimmed = message.trim();
|
|
694
|
+
return trimmed.length > 0 ? trimmed : copy.generic;
|
|
1384
695
|
};
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
if (json.length <= MAX_TOOL_INPUT_CHARS) {
|
|
1401
|
-
return json;
|
|
1402
|
-
}
|
|
1403
|
-
const last = json.charCodeAt(MAX_TOOL_INPUT_CHARS - 1);
|
|
1404
|
-
const splitsPair = last >= HIGH_SURROGATE_FIRST && last <= HIGH_SURROGATE_LAST;
|
|
1405
|
-
return `${json.slice(0, splitsPair ? MAX_TOOL_INPUT_CHARS - 1 : MAX_TOOL_INPUT_CHARS)}\u2026`;
|
|
696
|
+
const MAX_TOOL_INPUT_CHARS = 2e3;
|
|
697
|
+
const HIGH_SURROGATE_FIRST = 55296;
|
|
698
|
+
const HIGH_SURROGATE_LAST = 56319;
|
|
699
|
+
const boundedInputJson = (input) => {
|
|
700
|
+
let json;
|
|
701
|
+
try {
|
|
702
|
+
json = JSON.stringify(input, null, 2);
|
|
703
|
+
} catch {
|
|
704
|
+
return null;
|
|
705
|
+
}
|
|
706
|
+
if (json === void 0) return null;
|
|
707
|
+
if (json.length <= 2e3) return json;
|
|
708
|
+
const last = json.charCodeAt(1999);
|
|
709
|
+
const splitsPair = last >= HIGH_SURROGATE_FIRST && last <= HIGH_SURROGATE_LAST;
|
|
710
|
+
return `${json.slice(0, splitsPair ? 1999 : MAX_TOOL_INPUT_CHARS)}…`;
|
|
1406
711
|
};
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
{
|
|
1419
|
-
id: question.toolCallId,
|
|
1420
|
-
options: question.options,
|
|
1421
|
-
question: question.question,
|
|
1422
|
-
role: "question",
|
|
1423
|
-
selected: null,
|
|
1424
|
-
settled: false
|
|
1425
|
-
}
|
|
1426
|
-
];
|
|
712
|
+
const appendQuestionEntry = (transcript, question) => {
|
|
713
|
+
if (question.options.length === 0) return transcript;
|
|
714
|
+
if (transcript.some((entry) => entry.id === question.toolCallId)) return transcript;
|
|
715
|
+
return [...transcript, {
|
|
716
|
+
id: question.toolCallId,
|
|
717
|
+
options: question.options,
|
|
718
|
+
question: question.question,
|
|
719
|
+
role: "question",
|
|
720
|
+
selected: null,
|
|
721
|
+
settled: false
|
|
722
|
+
}];
|
|
1427
723
|
};
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
724
|
+
const answerQuestionEntry = (transcript, entryId, label) => transcript.map((entry) => entry.role === "question" && entry.id === entryId && !entry.settled ? {
|
|
725
|
+
...entry,
|
|
726
|
+
selected: label,
|
|
727
|
+
settled: true
|
|
728
|
+
} : entry);
|
|
729
|
+
const settleOpenQuestionEntries = (transcript) => {
|
|
730
|
+
if (!transcript.some((entry) => entry.role === "question" && !entry.settled)) return transcript;
|
|
731
|
+
return transcript.map((entry) => entry.role === "question" && !entry.settled ? {
|
|
732
|
+
...entry,
|
|
733
|
+
settled: true
|
|
734
|
+
} : entry);
|
|
1438
735
|
};
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
candidates: suggestions.candidates,
|
|
1450
|
-
chosenSeed: null,
|
|
1451
|
-
id: suggestions.entryId,
|
|
1452
|
-
role: "suggestions",
|
|
1453
|
-
settled: false
|
|
1454
|
-
}
|
|
1455
|
-
];
|
|
736
|
+
const appendSuggestionsEntry = (transcript, suggestions) => {
|
|
737
|
+
if (suggestions.candidates.length === 0) return transcript;
|
|
738
|
+
if (transcript.some((entry) => entry.id === suggestions.entryId)) return transcript;
|
|
739
|
+
return [...settleOpenSuggestionEntries(transcript), {
|
|
740
|
+
candidates: suggestions.candidates,
|
|
741
|
+
chosenSeed: null,
|
|
742
|
+
id: suggestions.entryId,
|
|
743
|
+
role: "suggestions",
|
|
744
|
+
settled: false
|
|
745
|
+
}];
|
|
1456
746
|
};
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
747
|
+
const chooseSuggestionEntry = (transcript, entryId, seed) => transcript.map((entry) => entry.role === "suggestions" && entry.id === entryId && !entry.settled ? {
|
|
748
|
+
...entry,
|
|
749
|
+
chosenSeed: seed,
|
|
750
|
+
settled: true
|
|
751
|
+
} : entry);
|
|
752
|
+
const settleOpenSuggestionEntries = (transcript) => {
|
|
753
|
+
if (!transcript.some((entry) => entry.role === "suggestions" && !entry.settled)) return transcript;
|
|
754
|
+
return transcript.map((entry) => entry.role === "suggestions" && !entry.settled ? {
|
|
755
|
+
...entry,
|
|
756
|
+
settled: true
|
|
757
|
+
} : entry);
|
|
1467
758
|
};
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
759
|
+
const appendWarningEntry = (transcript, lines) => {
|
|
760
|
+
if (lines.length === 0) return transcript;
|
|
761
|
+
return [...transcript, {
|
|
762
|
+
id: mintEntryId(),
|
|
763
|
+
lines,
|
|
764
|
+
role: "warning"
|
|
765
|
+
}];
|
|
1473
766
|
};
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
status: "running"
|
|
1498
|
-
}
|
|
1499
|
-
];
|
|
767
|
+
const appendErrorEntry = (transcript, message) => [...transcript, {
|
|
768
|
+
content: message,
|
|
769
|
+
id: mintEntryId(),
|
|
770
|
+
role: "error"
|
|
771
|
+
}];
|
|
772
|
+
const appendUserEntry = (transcript, content) => [...transcript, {
|
|
773
|
+
content,
|
|
774
|
+
id: mintEntryId(),
|
|
775
|
+
role: "user"
|
|
776
|
+
}];
|
|
777
|
+
const appendActivityEntry = (transcript, activity) => {
|
|
778
|
+
if (transcript.some((entry) => entry.id === activity.toolCallId)) return transcript;
|
|
779
|
+
return [...transcript, {
|
|
780
|
+
abandonedReason: null,
|
|
781
|
+
error: null,
|
|
782
|
+
id: activity.toolCallId,
|
|
783
|
+
input: activity.input,
|
|
784
|
+
label: null,
|
|
785
|
+
name: activity.name,
|
|
786
|
+
recovery: null,
|
|
787
|
+
role: "activity",
|
|
788
|
+
status: "running"
|
|
789
|
+
}];
|
|
1500
790
|
};
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
if (found?.role === "activity" && found.status !== "running") {
|
|
1526
|
-
return transcript;
|
|
1527
|
-
}
|
|
1528
|
-
return transcript.map(
|
|
1529
|
-
(entry, i) => i === index && entry.role === "activity" ? {
|
|
1530
|
-
...entry,
|
|
1531
|
-
abandonedReason: outcome.abandonedReason ?? null,
|
|
1532
|
-
error: outcome.error ?? null,
|
|
1533
|
-
label: outcome.summary ?? null,
|
|
1534
|
-
recovery: outcome.recovery ?? null,
|
|
1535
|
-
status: outcome.status
|
|
1536
|
-
} : entry
|
|
1537
|
-
);
|
|
791
|
+
const settleActivityEntry = (transcript, toolCallId, outcome) => {
|
|
792
|
+
if (transcript.some((entry) => entry.role === "question" && entry.id === toolCallId)) return transcript;
|
|
793
|
+
const index = transcript.findLastIndex((entry) => entry.role === "activity" && entry.id === toolCallId);
|
|
794
|
+
if (index === -1) return [...transcript, {
|
|
795
|
+
abandonedReason: outcome.abandonedReason ?? null,
|
|
796
|
+
error: outcome.error ?? null,
|
|
797
|
+
id: toolCallId,
|
|
798
|
+
input: null,
|
|
799
|
+
label: outcome.summary ?? null,
|
|
800
|
+
name: null,
|
|
801
|
+
recovery: outcome.recovery ?? null,
|
|
802
|
+
role: "activity",
|
|
803
|
+
status: outcome.status
|
|
804
|
+
}];
|
|
805
|
+
const found = transcript[index];
|
|
806
|
+
if (found?.role === "activity" && found.status !== "running") return transcript;
|
|
807
|
+
return transcript.map((entry, i) => i === index && entry.role === "activity" ? {
|
|
808
|
+
...entry,
|
|
809
|
+
abandonedReason: outcome.abandonedReason ?? null,
|
|
810
|
+
error: outcome.error ?? null,
|
|
811
|
+
label: outcome.summary ?? null,
|
|
812
|
+
recovery: outcome.recovery ?? null,
|
|
813
|
+
status: outcome.status
|
|
814
|
+
} : entry);
|
|
1538
815
|
};
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
816
|
+
const mintEntryId = () => require_uuid.localId();
|
|
817
|
+
const isAssistantTurn = (entry) => entry.role === "assistant";
|
|
818
|
+
const accumulateAssistant = (transcript, delta) => {
|
|
819
|
+
const last = transcript.at(-1);
|
|
820
|
+
if (last && isAssistantTurn(last) && last.messageIndex === void 0) return [...transcript.slice(0, -1), {
|
|
821
|
+
...last,
|
|
822
|
+
content: last.content + delta
|
|
823
|
+
}];
|
|
824
|
+
return [...transcript, {
|
|
825
|
+
content: delta,
|
|
826
|
+
id: mintEntryId(),
|
|
827
|
+
role: "assistant"
|
|
828
|
+
}];
|
|
1547
829
|
};
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
830
|
+
const settlesLastTurn = (last, messageIndex) => messageIndex === void 0 || last.messageIndex === void 0 || last.messageIndex === messageIndex;
|
|
831
|
+
const replaceAssistant = (transcript, content, messageIndex) => {
|
|
832
|
+
const last = transcript.at(-1);
|
|
833
|
+
if (last && isAssistantTurn(last) && settlesLastTurn(last, messageIndex)) return [...transcript.slice(0, -1), {
|
|
834
|
+
...last,
|
|
835
|
+
content,
|
|
836
|
+
messageIndex
|
|
837
|
+
}];
|
|
838
|
+
return [...transcript, {
|
|
839
|
+
content,
|
|
840
|
+
id: mintEntryId(),
|
|
841
|
+
messageIndex,
|
|
842
|
+
role: "assistant"
|
|
843
|
+
}];
|
|
1555
844
|
};
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
const code = "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
1564
|
-
return { code, status };
|
|
845
|
+
const startRefusal = (error) => {
|
|
846
|
+
const status = require_errorStatus.statusOf(error);
|
|
847
|
+
if (status === void 0 || typeof error !== "object" || error === null) return null;
|
|
848
|
+
return {
|
|
849
|
+
code: "code" in error && typeof error.code === "string" ? error.code : void 0,
|
|
850
|
+
status
|
|
851
|
+
};
|
|
1565
852
|
};
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
}
|
|
1572
|
-
if (status === RATE_LIMITED_STATUS) {
|
|
1573
|
-
return copy.rateLimited;
|
|
1574
|
-
}
|
|
1575
|
-
return void 0;
|
|
853
|
+
const TOO_LARGE_STATUS = 413;
|
|
854
|
+
const RATE_LIMITED_STATUS = 429;
|
|
855
|
+
const refusedAsSent = (status, copy) => {
|
|
856
|
+
if (status === TOO_LARGE_STATUS) return copy.tooLarge;
|
|
857
|
+
if (status === RATE_LIMITED_STATUS) return copy.rateLimited;
|
|
1576
858
|
};
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
onSettled?.();
|
|
1631
|
-
if (runGone && chunkUYUBSD2V_cjs.statusOf(error) === 404) {
|
|
1632
|
-
tellHost(() => invalidateMemberships?.());
|
|
1633
|
-
}
|
|
1634
|
-
tellSignInRefused(chunkUYUBSD2V_cjs.statusOf(error));
|
|
1635
|
-
},
|
|
1636
|
-
resumeFailed: (error) => {
|
|
1637
|
-
writer.setRunId(null);
|
|
1638
|
-
writer.setSessionState("awaiting_input");
|
|
1639
|
-
onSettled?.();
|
|
1640
|
-
tellSignInRefused(chunkUYUBSD2V_cjs.statusOf(error));
|
|
1641
|
-
}
|
|
1642
|
-
};
|
|
859
|
+
const ACCESS_STATUSES = [
|
|
860
|
+
402,
|
|
861
|
+
403,
|
|
862
|
+
404
|
|
863
|
+
];
|
|
864
|
+
const SIGN_IN_REFUSED_STATUS = 401;
|
|
865
|
+
const createConversationFaults = (config) => {
|
|
866
|
+
const { copy, invalidateAiConfig, invalidateMemberships, onSettled, onSignInRefused, writer } = config;
|
|
867
|
+
const tellHost = (tell) => {
|
|
868
|
+
try {
|
|
869
|
+
tell();
|
|
870
|
+
} catch (fault) {
|
|
871
|
+
require_listeners.surfaceFault(fault);
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
const tellSignInRefused = (status) => {
|
|
875
|
+
if (status === SIGN_IN_REFUSED_STATUS) tellHost(() => onSignInRefused?.());
|
|
876
|
+
};
|
|
877
|
+
return {
|
|
878
|
+
handleStartError: (organizationId, error, runId) => {
|
|
879
|
+
writer.setRunId(null);
|
|
880
|
+
writer.setSessionState("awaiting_input");
|
|
881
|
+
const refusal = startRefusal(error);
|
|
882
|
+
const credentialGone = refusal?.status === 409 && refusal.code === "AI_PROVIDER_NOT_CONFIGURED";
|
|
883
|
+
const startNotReached = refusal?.status === 404 && runId === void 0;
|
|
884
|
+
if (refusal?.status === 402) writer.appendError(copy.notEntitled);
|
|
885
|
+
else if (refusal?.status === 403 || startNotReached) writer.appendError(copy.noAccess);
|
|
886
|
+
else if (credentialGone) writer.appendError(copy.notConfigured);
|
|
887
|
+
else writer.appendError(refusedAsSent(refusal?.status, copy) ?? copy.generic);
|
|
888
|
+
onSettled?.();
|
|
889
|
+
if (credentialGone) tellHost(() => invalidateAiConfig?.(organizationId));
|
|
890
|
+
if (refusal !== null && ACCESS_STATUSES.includes(refusal.status)) tellHost(() => invalidateMemberships?.());
|
|
891
|
+
tellSignInRefused(refusal?.status);
|
|
892
|
+
},
|
|
893
|
+
missingOrganization: () => {
|
|
894
|
+
writer.appendError(copy.missingOrganization);
|
|
895
|
+
writer.setSessionState("awaiting_input");
|
|
896
|
+
},
|
|
897
|
+
recover: (runGone, error) => {
|
|
898
|
+
if (runGone) writer.setRunId(null);
|
|
899
|
+
writer.appendError(refusedAsSent(require_errorStatus.statusOf(error), copy) ?? copy.generic);
|
|
900
|
+
writer.setSessionState("awaiting_input");
|
|
901
|
+
onSettled?.();
|
|
902
|
+
if (runGone && require_errorStatus.statusOf(error) === 404) tellHost(() => invalidateMemberships?.());
|
|
903
|
+
tellSignInRefused(require_errorStatus.statusOf(error));
|
|
904
|
+
},
|
|
905
|
+
resumeFailed: (error) => {
|
|
906
|
+
writer.setRunId(null);
|
|
907
|
+
writer.setSessionState("awaiting_input");
|
|
908
|
+
onSettled?.();
|
|
909
|
+
tellSignInRefused(require_errorStatus.statusOf(error));
|
|
910
|
+
}
|
|
911
|
+
};
|
|
1643
912
|
};
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
callMade = context.then(
|
|
1754
|
-
() => void 0,
|
|
1755
|
-
() => void 0
|
|
1756
|
-
);
|
|
1757
|
-
running.then(
|
|
1758
|
-
() => {
|
|
1759
|
-
callSettled(call);
|
|
1760
|
-
},
|
|
1761
|
-
(error) => {
|
|
1762
|
-
if (!callSettled(call)) {
|
|
1763
|
-
return;
|
|
1764
|
-
}
|
|
1765
|
-
const openedRun = active.runId?.() ?? null;
|
|
1766
|
-
if (openedRun === null) {
|
|
1767
|
-
config.onStartError(organizationId, error);
|
|
1768
|
-
} else {
|
|
1769
|
-
config.onStartError(organizationId, error, openedRun);
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
);
|
|
1773
|
-
};
|
|
1774
|
-
return { dispose, finish, reroute, restart, resume, submit };
|
|
913
|
+
const isRunGone = (error) => error instanceof require_errors.MountayaElementsError || require_errorStatus.statusOf(error) === 404;
|
|
914
|
+
const createConversationHost = (config) => {
|
|
915
|
+
let session = null;
|
|
916
|
+
let started = false;
|
|
917
|
+
let latestCall = null;
|
|
918
|
+
let callMade = Promise.resolve();
|
|
919
|
+
let parkedAt = null;
|
|
920
|
+
const ensureSession = () => {
|
|
921
|
+
if (!session) session = config.buildSession();
|
|
922
|
+
return session;
|
|
923
|
+
};
|
|
924
|
+
const dispose = () => {
|
|
925
|
+
parkedAt = session?.streamPosition?.() ?? parkedAt;
|
|
926
|
+
session?.dispose();
|
|
927
|
+
session = null;
|
|
928
|
+
started = false;
|
|
929
|
+
latestCall = null;
|
|
930
|
+
};
|
|
931
|
+
const beginCall = () => {
|
|
932
|
+
const call = Symbol("run");
|
|
933
|
+
latestCall = call;
|
|
934
|
+
return call;
|
|
935
|
+
};
|
|
936
|
+
const callSettled = (call) => {
|
|
937
|
+
if (latestCall !== call) return false;
|
|
938
|
+
latestCall = null;
|
|
939
|
+
started = false;
|
|
940
|
+
return true;
|
|
941
|
+
};
|
|
942
|
+
const closeRun = () => {
|
|
943
|
+
session?.close().catch(() => void 0);
|
|
944
|
+
};
|
|
945
|
+
const finish = () => {
|
|
946
|
+
closeRun();
|
|
947
|
+
dispose();
|
|
948
|
+
parkedAt = null;
|
|
949
|
+
};
|
|
950
|
+
const reroute = () => {
|
|
951
|
+
if (!started || !session) return;
|
|
952
|
+
config.routeForState?.();
|
|
953
|
+
session.routeTools().catch(() => void 0);
|
|
954
|
+
};
|
|
955
|
+
const restart = () => {
|
|
956
|
+
closeRun();
|
|
957
|
+
session?.dispose();
|
|
958
|
+
session = config.buildSession();
|
|
959
|
+
started = false;
|
|
960
|
+
latestCall = null;
|
|
961
|
+
parkedAt = null;
|
|
962
|
+
};
|
|
963
|
+
const resume = (runId, onFault) => {
|
|
964
|
+
const active = ensureSession();
|
|
965
|
+
if (!runId || started) return;
|
|
966
|
+
started = true;
|
|
967
|
+
const call = beginCall();
|
|
968
|
+
callMade = Promise.resolve();
|
|
969
|
+
const position = parkedAt?.runId === runId ? parkedAt.lastEventId : void 0;
|
|
970
|
+
parkedAt = null;
|
|
971
|
+
(position === void 0 ? active.resume(runId) : active.resume(runId, position)).then(() => {
|
|
972
|
+
callSettled(call);
|
|
973
|
+
}, (error) => {
|
|
974
|
+
if (callSettled(call)) onFault(error);
|
|
975
|
+
});
|
|
976
|
+
};
|
|
977
|
+
const submit = (message) => {
|
|
978
|
+
const active = ensureSession();
|
|
979
|
+
config.appendUserMessage(message);
|
|
980
|
+
config.routeForMessage?.(message);
|
|
981
|
+
if (started) {
|
|
982
|
+
const call = latestCall;
|
|
983
|
+
callMade.then(() => active.routeTools()).catch(() => void 0).then(() => active.send(message)).catch((error) => {
|
|
984
|
+
if (session !== active || latestCall !== call) return;
|
|
985
|
+
const runGone = isRunGone(error);
|
|
986
|
+
if (runGone) {
|
|
987
|
+
latestCall = null;
|
|
988
|
+
started = false;
|
|
989
|
+
}
|
|
990
|
+
config.onSendFault(error, runGone);
|
|
991
|
+
});
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
const organizationId = config.resolveOrganizationId();
|
|
995
|
+
if (!organizationId) {
|
|
996
|
+
config.onMissingOrganization();
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
started = true;
|
|
1000
|
+
parkedAt = null;
|
|
1001
|
+
const call = beginCall();
|
|
1002
|
+
const context = config.buildContext();
|
|
1003
|
+
const running = context.then((captured) => active.start(message, organizationId, captured));
|
|
1004
|
+
callMade = context.then(() => void 0, () => void 0);
|
|
1005
|
+
running.then(() => {
|
|
1006
|
+
callSettled(call);
|
|
1007
|
+
}, (error) => {
|
|
1008
|
+
if (!callSettled(call)) return;
|
|
1009
|
+
const openedRun = active.runId?.() ?? null;
|
|
1010
|
+
if (openedRun === null) config.onStartError(organizationId, error);
|
|
1011
|
+
else config.onStartError(organizationId, error, openedRun);
|
|
1012
|
+
});
|
|
1013
|
+
};
|
|
1014
|
+
return {
|
|
1015
|
+
dispose,
|
|
1016
|
+
finish,
|
|
1017
|
+
reroute,
|
|
1018
|
+
restart,
|
|
1019
|
+
resume,
|
|
1020
|
+
submit
|
|
1021
|
+
};
|
|
1775
1022
|
};
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
})();
|
|
1843
|
-
return teardown;
|
|
1023
|
+
const terminalTypes = /* @__PURE__ */ new Set(["done"]);
|
|
1024
|
+
const readRun = (run, handlers, options) => {
|
|
1025
|
+
const signal = options?.signal;
|
|
1026
|
+
if (signal?.aborted) return () => {};
|
|
1027
|
+
let active = true;
|
|
1028
|
+
const named = options?.lastEventId;
|
|
1029
|
+
let position = named === void 0 ? 0 : run.history.findIndex((entry) => entry.id === named) + 1;
|
|
1030
|
+
const beginsPastTheEnd = run.history.slice(0, position).some(({ event }) => terminalTypes.has(event.type));
|
|
1031
|
+
let wake = null;
|
|
1032
|
+
const release = () => {
|
|
1033
|
+
signal?.removeEventListener("abort", teardown);
|
|
1034
|
+
};
|
|
1035
|
+
const teardown = () => {
|
|
1036
|
+
active = false;
|
|
1037
|
+
release();
|
|
1038
|
+
const resume = wake;
|
|
1039
|
+
wake = null;
|
|
1040
|
+
if (resume !== null) {
|
|
1041
|
+
run.waiting.delete(resume);
|
|
1042
|
+
resume();
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
signal?.addEventListener("abort", teardown, { once: true });
|
|
1046
|
+
(async () => {
|
|
1047
|
+
if (beginsPastTheEnd) {
|
|
1048
|
+
await Promise.resolve();
|
|
1049
|
+
if (active) {
|
|
1050
|
+
active = false;
|
|
1051
|
+
release();
|
|
1052
|
+
handlers.onClose("ended");
|
|
1053
|
+
}
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
while (active) {
|
|
1057
|
+
const entry = run.history[position];
|
|
1058
|
+
if (entry === void 0) {
|
|
1059
|
+
await new Promise((resolve) => {
|
|
1060
|
+
wake = resolve;
|
|
1061
|
+
run.waiting.add(resolve);
|
|
1062
|
+
});
|
|
1063
|
+
wake = null;
|
|
1064
|
+
continue;
|
|
1065
|
+
}
|
|
1066
|
+
position += 1;
|
|
1067
|
+
try {
|
|
1068
|
+
await handlers.onFrame({
|
|
1069
|
+
event: run.delivered(entry.event),
|
|
1070
|
+
id: entry.id
|
|
1071
|
+
});
|
|
1072
|
+
} catch (error) {
|
|
1073
|
+
if (active) {
|
|
1074
|
+
active = false;
|
|
1075
|
+
release();
|
|
1076
|
+
handlers.onError(error);
|
|
1077
|
+
}
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
if (active && terminalTypes.has(entry.event.type)) {
|
|
1081
|
+
active = false;
|
|
1082
|
+
release();
|
|
1083
|
+
handlers.onClose("terminal");
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
})();
|
|
1088
|
+
return teardown;
|
|
1844
1089
|
};
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1090
|
+
const createRunStream = () => {
|
|
1091
|
+
const history = [];
|
|
1092
|
+
let recorded = 0;
|
|
1093
|
+
const record = (event) => {
|
|
1094
|
+
recorded += 1;
|
|
1095
|
+
return {
|
|
1096
|
+
event,
|
|
1097
|
+
id: String(recorded)
|
|
1098
|
+
};
|
|
1099
|
+
};
|
|
1100
|
+
const answered = /* @__PURE__ */ new Set();
|
|
1101
|
+
const waiting = /* @__PURE__ */ new Set();
|
|
1102
|
+
const delivered = (event) => (event.type === "tool-call" || event.type === "confirm-required") && answered.has(event.tool_call_id) ? {
|
|
1103
|
+
...event,
|
|
1104
|
+
settled: true
|
|
1105
|
+
} : event;
|
|
1106
|
+
const stream = {
|
|
1107
|
+
answer: (toolCallId, outcome) => {
|
|
1108
|
+
answered.add(toolCallId);
|
|
1109
|
+
const isSettled = history.some(({ event }) => (event.type === "tool-result" || event.type === "tool-abandoned") && event.tool_call_id === toolCallId);
|
|
1110
|
+
if (outcome === void 0 || isSettled) return;
|
|
1111
|
+
const terminal = history.findIndex(({ event }) => terminalTypes.has(event.type));
|
|
1112
|
+
if (terminal === -1) stream.push([outcome]);
|
|
1113
|
+
else history.splice(terminal, 0, record(outcome));
|
|
1114
|
+
},
|
|
1115
|
+
push: (events) => {
|
|
1116
|
+
history.push(...events.map(record));
|
|
1117
|
+
const resumes = [...waiting];
|
|
1118
|
+
waiting.clear();
|
|
1119
|
+
for (const resume of resumes) resume();
|
|
1120
|
+
},
|
|
1121
|
+
subscribe: (handlers, options) => readRun({
|
|
1122
|
+
delivered,
|
|
1123
|
+
history,
|
|
1124
|
+
waiting
|
|
1125
|
+
}, handlers, options)
|
|
1126
|
+
};
|
|
1127
|
+
return stream;
|
|
1882
1128
|
};
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1129
|
+
const echoOf = (answer) => ({
|
|
1130
|
+
ok: answer.ok,
|
|
1131
|
+
tool_call_id: answer.tool_call_id,
|
|
1132
|
+
type: "tool-result",
|
|
1133
|
+
...answer.result === void 0 ? {} : { data: answer.result },
|
|
1134
|
+
...answer.error === void 0 ? {} : { error: answer.error }
|
|
1889
1135
|
});
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1136
|
+
const createAgentScriptedTransport = (resolve) => {
|
|
1137
|
+
const streams = /* @__PURE__ */ new Map();
|
|
1138
|
+
const streamFor = (runId) => streams.get(runId);
|
|
1139
|
+
const startRun = async (params) => {
|
|
1140
|
+
const runId = require_uuid.localId();
|
|
1141
|
+
const stream = createRunStream();
|
|
1142
|
+
streams.set(runId, stream);
|
|
1143
|
+
stream.push(resolve(params.message));
|
|
1144
|
+
return { runId };
|
|
1145
|
+
};
|
|
1146
|
+
const sendInput = async (runId, input) => {
|
|
1147
|
+
const stream = streamFor(runId);
|
|
1148
|
+
if (!stream) return;
|
|
1149
|
+
if (input.type === "user-message") stream.push(resolve(input.content));
|
|
1150
|
+
else if (input.type === "close") stream.push([{
|
|
1151
|
+
reason: "completed",
|
|
1152
|
+
type: "done"
|
|
1153
|
+
}]);
|
|
1154
|
+
else if (input.type === "tool-result") stream.answer(input.tool_call_id, echoOf(input));
|
|
1155
|
+
else if (input.type === "confirm") stream.answer(input.tool_call_id);
|
|
1156
|
+
};
|
|
1157
|
+
const subscribe = (runId, handlers, options) => {
|
|
1158
|
+
const stream = streamFor(runId);
|
|
1159
|
+
if (!stream) {
|
|
1160
|
+
queueMicrotask(() => handlers.onClose("ended"));
|
|
1161
|
+
return () => {};
|
|
1162
|
+
}
|
|
1163
|
+
return stream.subscribe(handlers, options);
|
|
1164
|
+
};
|
|
1165
|
+
const pushEvents = (runId, turnEvents) => {
|
|
1166
|
+
streamFor(runId)?.push(turnEvents);
|
|
1167
|
+
};
|
|
1168
|
+
const endRun = (runId) => {
|
|
1169
|
+
streamFor(runId)?.push([{
|
|
1170
|
+
reason: "completed",
|
|
1171
|
+
type: "done"
|
|
1172
|
+
}]);
|
|
1173
|
+
};
|
|
1174
|
+
return {
|
|
1175
|
+
endRun,
|
|
1176
|
+
pushEvents,
|
|
1177
|
+
sendInput,
|
|
1178
|
+
startRun,
|
|
1179
|
+
subscribe
|
|
1180
|
+
};
|
|
1931
1181
|
};
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
var STICK_TO_BOTTOM_THRESHOLD_PX = 24;
|
|
1935
|
-
var isPinnedToBottom = (viewport, threshold = STICK_TO_BOTTOM_THRESHOLD_PX) => viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight <= threshold;
|
|
1936
|
-
|
|
1182
|
+
const STICK_TO_BOTTOM_THRESHOLD_PX = 24;
|
|
1183
|
+
const isPinnedToBottom = (viewport, threshold = 24) => viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight <= threshold;
|
|
1937
1184
|
exports.AgentEngine = AgentEngine;
|
|
1938
1185
|
exports.MAX_TOOL_INPUT_CHARS = MAX_TOOL_INPUT_CHARS;
|
|
1939
1186
|
exports.MAX_TOOL_RESULT_DATA_BYTES = MAX_TOOL_RESULT_DATA_BYTES;
|
|
@@ -1960,5 +1207,5 @@ exports.settleActivityEntry = settleActivityEntry;
|
|
|
1960
1207
|
exports.settleOpenQuestionEntries = settleOpenQuestionEntries;
|
|
1961
1208
|
exports.settleOpenSuggestionEntries = settleOpenSuggestionEntries;
|
|
1962
1209
|
exports.toWireErrorCode = toWireErrorCode;
|
|
1963
|
-
|
|
1210
|
+
|
|
1964
1211
|
//# sourceMappingURL=index.cjs.map
|