@poncho-ai/cli 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (516) hide show
  1. package/.turbo/turbo-build.log +19 -0
  2. package/.turbo/turbo-test.log +389 -0
  3. package/CHANGELOG.md +17 -0
  4. package/LICENSE +21 -0
  5. package/dist/chunk-22OMLQUR.js +1249 -0
  6. package/dist/chunk-24JFN5RM.js +1887 -0
  7. package/dist/chunk-24TAT3US.js +2137 -0
  8. package/dist/chunk-26YBLT7G.js +997 -0
  9. package/dist/chunk-2EJIC6UW.js +1893 -0
  10. package/dist/chunk-2JNCF37R.js +1156 -0
  11. package/dist/chunk-2LVMUHJX.js +1874 -0
  12. package/dist/chunk-2OVSD65B.js +1269 -0
  13. package/dist/chunk-2RQ45LI6.js +1251 -0
  14. package/dist/chunk-2SMIRDLI.js +1854 -0
  15. package/dist/chunk-2UXPHBFI.js +1862 -0
  16. package/dist/chunk-2VFM7SSZ.js +1135 -0
  17. package/dist/chunk-2ZAUADNG.js +1456 -0
  18. package/dist/chunk-2ZNUT5WA.js +1862 -0
  19. package/dist/chunk-33ZQ7WTP.js +1834 -0
  20. package/dist/chunk-34ARQX3O.js +1156 -0
  21. package/dist/chunk-3BEWSRFW.js +1893 -0
  22. package/dist/chunk-3DVE5AG6.js +1862 -0
  23. package/dist/chunk-3KE6MHO6.js +1608 -0
  24. package/dist/chunk-3MOLPB7Z.js +997 -0
  25. package/dist/chunk-3OZZOYAZ.js +1884 -0
  26. package/dist/chunk-3VJYNZEF.js +2181 -0
  27. package/dist/chunk-3W27LOUH.js +997 -0
  28. package/dist/chunk-3WMAW74D.js +1163 -0
  29. package/dist/chunk-3Z4AHBPF.js +1569 -0
  30. package/dist/chunk-43NK6MB4.js +1977 -0
  31. package/dist/chunk-4E5M2IGA.js +1300 -0
  32. package/dist/chunk-4FVI4LVI.js +1862 -0
  33. package/dist/chunk-4GNQQJUP.js +1156 -0
  34. package/dist/chunk-4PGZFTVC.js +1234 -0
  35. package/dist/chunk-4QE2HDNC.js +1355 -0
  36. package/dist/chunk-4S2EL4ED.js +1135 -0
  37. package/dist/chunk-536SSOJ3.js +1797 -0
  38. package/dist/chunk-5CNEGIC5.js +997 -0
  39. package/dist/chunk-5CWN43YL.js +1147 -0
  40. package/dist/chunk-5HZCYTUZ.js +997 -0
  41. package/dist/chunk-5ICNG6RX.js +1885 -0
  42. package/dist/chunk-5OUIRXMN.js +997 -0
  43. package/dist/chunk-5T34JOWH.js +1460 -0
  44. package/dist/chunk-5XBAIQX3.js +1862 -0
  45. package/dist/chunk-65AIX3CS.js +1441 -0
  46. package/dist/chunk-67NBW4NG.js +1355 -0
  47. package/dist/chunk-6AFIL35M.js +1414 -0
  48. package/dist/chunk-6B3XMBKA.js +1716 -0
  49. package/dist/chunk-6CEJO4OM.js +1242 -0
  50. package/dist/chunk-6DQZUP3B.js +1460 -0
  51. package/dist/chunk-6ET624OE.js +1441 -0
  52. package/dist/chunk-6I7WFMAU.js +1862 -0
  53. package/dist/chunk-6MOKAYCL.js +1449 -0
  54. package/dist/chunk-6RFUALWB.js +1845 -0
  55. package/dist/chunk-73E57JUS.js +1231 -0
  56. package/dist/chunk-73SU7GT4.js +816 -0
  57. package/dist/chunk-74IRETUF.js +997 -0
  58. package/dist/chunk-77BYFMUN.js +1924 -0
  59. package/dist/chunk-7DAC2XE5.js +1460 -0
  60. package/dist/chunk-7GBQ4YSB.js +1024 -0
  61. package/dist/chunk-7TOJGUQ5.js +1803 -0
  62. package/dist/chunk-7W7KPLEG.js +1163 -0
  63. package/dist/chunk-7Y7ZXEN2.js +817 -0
  64. package/dist/chunk-A5WKH7H2.js +852 -0
  65. package/dist/chunk-A775UYQB.js +1886 -0
  66. package/dist/chunk-AC4OGTSK.js +1313 -0
  67. package/dist/chunk-ACCRUQ6J.js +1271 -0
  68. package/dist/chunk-AEAZZFTT.js +1886 -0
  69. package/dist/chunk-AIAC5Z55.js +1147 -0
  70. package/dist/chunk-AN34PI2R.js +1238 -0
  71. package/dist/chunk-APIA7MHJ.js +1355 -0
  72. package/dist/chunk-AQGIIT7R.js +1347 -0
  73. package/dist/chunk-ATXKV2NH.js +2111 -0
  74. package/dist/chunk-AVBKQZYR.js +1010 -0
  75. package/dist/chunk-AWIXDCZF.js +1329 -0
  76. package/dist/chunk-AXFHQBKT.js +2128 -0
  77. package/dist/chunk-AYDSTU4P.js +1156 -0
  78. package/dist/chunk-AZ35PK7E.js +1271 -0
  79. package/dist/chunk-BE6HB4IO.js +2155 -0
  80. package/dist/chunk-BIX2FI3S.js +1625 -0
  81. package/dist/chunk-BPPM5YPG.js +997 -0
  82. package/dist/chunk-BRCIVYKE.js +1420 -0
  83. package/dist/chunk-BRK2KKTF.js +1236 -0
  84. package/dist/chunk-BU7R2TVT.js +1862 -0
  85. package/dist/chunk-BXJQ4G5F.js +1901 -0
  86. package/dist/chunk-C3KTCROR.js +1128 -0
  87. package/dist/chunk-C42IGDJW.js +1032 -0
  88. package/dist/chunk-CBRPO2FE.js +1886 -0
  89. package/dist/chunk-CDNITKC6.js +1163 -0
  90. package/dist/chunk-CDVWUDFM.js +1389 -0
  91. package/dist/chunk-CH2IE453.js +1147 -0
  92. package/dist/chunk-CIHC46FS.js +1010 -0
  93. package/dist/chunk-CIYO754K.js +1687 -0
  94. package/dist/chunk-CJFNJ7U3.js +918 -0
  95. package/dist/chunk-CJN66CJY.js +1024 -0
  96. package/dist/chunk-CLJFTDJQ.js +1667 -0
  97. package/dist/chunk-CLNCOQNI.js +997 -0
  98. package/dist/chunk-CN4AUQL4.js +1460 -0
  99. package/dist/chunk-CQYGUBY6.js +1854 -0
  100. package/dist/chunk-CRJUMKVB.js +1862 -0
  101. package/dist/chunk-CZHUYI2J.js +997 -0
  102. package/dist/chunk-DIBSIWSR.js +1256 -0
  103. package/dist/chunk-DJGC3R4O.js +1836 -0
  104. package/dist/chunk-DJR2PEAQ.js +1884 -0
  105. package/dist/chunk-DKE7NWBK.js +1862 -0
  106. package/dist/chunk-DXYDN2OS.js +1147 -0
  107. package/dist/chunk-DZ3FEUJ7.js +1147 -0
  108. package/dist/chunk-EC47SFY3.js +1113 -0
  109. package/dist/chunk-ECAALEAK.js +1239 -0
  110. package/dist/chunk-ECEYIAQZ.js +997 -0
  111. package/dist/chunk-EKX7AV7O.js +1024 -0
  112. package/dist/chunk-EN6CTYUN.js +634 -0
  113. package/dist/chunk-EXCH47WX.js +1460 -0
  114. package/dist/chunk-EY2JOCTM.js +1862 -0
  115. package/dist/chunk-EYHB3LTH.js +1818 -0
  116. package/dist/chunk-F2AC5PKU.js +1446 -0
  117. package/dist/chunk-F5RCUJ62.js +1156 -0
  118. package/dist/chunk-F6OM65VA.js +1460 -0
  119. package/dist/chunk-FAEJ5CQU.js +997 -0
  120. package/dist/chunk-FB7X4KBF.js +1460 -0
  121. package/dist/chunk-FBSEEW3H.js +1862 -0
  122. package/dist/chunk-FBYY3TE5.js +1862 -0
  123. package/dist/chunk-FEA3GBGG.js +997 -0
  124. package/dist/chunk-FHPRGTOJ.js +1131 -0
  125. package/dist/chunk-FLAY6YWY.js +1389 -0
  126. package/dist/chunk-FNXIVJ3B.js +997 -0
  127. package/dist/chunk-FWRVG7RM.js +2160 -0
  128. package/dist/chunk-G47UW452.js +916 -0
  129. package/dist/chunk-G6V5O5AV.js +997 -0
  130. package/dist/chunk-GACQBIOO.js +1613 -0
  131. package/dist/chunk-GBFHLBWT.js +881 -0
  132. package/dist/chunk-GLJLTQMZ.js +997 -0
  133. package/dist/chunk-GN7DDBAT.js +1872 -0
  134. package/dist/chunk-GPTI42MM.js +1355 -0
  135. package/dist/chunk-GPXGCPVY.js +1834 -0
  136. package/dist/chunk-GRASQSCU.js +1886 -0
  137. package/dist/chunk-GU2WWG5C.js +1314 -0
  138. package/dist/chunk-GW3SAYT3.js +1679 -0
  139. package/dist/chunk-GZ4F2VI5.js +1447 -0
  140. package/dist/chunk-GZYXND4U.js +1322 -0
  141. package/dist/chunk-H27BRPVI.js +1862 -0
  142. package/dist/chunk-H4JRTOW7.js +1862 -0
  143. package/dist/chunk-HDS72SRU.js +1138 -0
  144. package/dist/chunk-HEUGSUL5.js +757 -0
  145. package/dist/chunk-HMZN5GPS.js +1024 -0
  146. package/dist/chunk-HN5SVGQO.js +1163 -0
  147. package/dist/chunk-HN6VQ5FI.js +242 -0
  148. package/dist/chunk-HNTQ66EL.js +2054 -0
  149. package/dist/chunk-HSDL3YK5.js +1134 -0
  150. package/dist/chunk-HVMIMERW.js +997 -0
  151. package/dist/chunk-HVWCQS2B.js +1834 -0
  152. package/dist/chunk-HVYMSOXQ.js +2156 -0
  153. package/dist/chunk-HYQITTK3.js +1862 -0
  154. package/dist/chunk-I4CCYPAI.js +1239 -0
  155. package/dist/chunk-IDG3X4UL.js +1229 -0
  156. package/dist/chunk-IDVRTQJ3.js +1514 -0
  157. package/dist/chunk-IEER23NN.js +1862 -0
  158. package/dist/chunk-IKLRYA4W.js +785 -0
  159. package/dist/chunk-IQBUSFBY.js +1270 -0
  160. package/dist/chunk-IUXQDZIR.js +1862 -0
  161. package/dist/chunk-IV74RJFV.js +1862 -0
  162. package/dist/chunk-IVEMIXXO.js +1854 -0
  163. package/dist/chunk-J4PNCGSP.js +1460 -0
  164. package/dist/chunk-J7ULLJUI.js +1862 -0
  165. package/dist/chunk-J7WHTBOM.js +983 -0
  166. package/dist/chunk-JBN6D7EG.js +1757 -0
  167. package/dist/chunk-JDKSD54C.js +1366 -0
  168. package/dist/chunk-JGWTOS7A.js +1507 -0
  169. package/dist/chunk-JHJ6FMSI.js +1804 -0
  170. package/dist/chunk-JJSHCP32.js +1282 -0
  171. package/dist/chunk-JLMAMC3V.js +1625 -0
  172. package/dist/chunk-JMTF7VV5.js +1919 -0
  173. package/dist/chunk-JO56GKTV.js +1133 -0
  174. package/dist/chunk-JRN3P6CS.js +1441 -0
  175. package/dist/chunk-JTKPRRSM.js +1024 -0
  176. package/dist/chunk-JVTFCTGO.js +1868 -0
  177. package/dist/chunk-JXH452LK.js +956 -0
  178. package/dist/chunk-K4SW5SP4.js +1147 -0
  179. package/dist/chunk-KANVHOQK.js +1880 -0
  180. package/dist/chunk-KBJZJWPZ.js +1143 -0
  181. package/dist/chunk-KFC4ZVRH.js +1798 -0
  182. package/dist/chunk-KHG6MSLS.js +1885 -0
  183. package/dist/chunk-KJJE6V5N.js +1886 -0
  184. package/dist/chunk-KKLEILZP.js +1868 -0
  185. package/dist/chunk-KW5QXXEN.js +1641 -0
  186. package/dist/chunk-KWMTK4N7.js +1147 -0
  187. package/dist/chunk-KYOW6LIV.js +1231 -0
  188. package/dist/chunk-KYWIUH3M.js +1355 -0
  189. package/dist/chunk-KZEA3HJL.js +1833 -0
  190. package/dist/chunk-L3KONBJE.js +1355 -0
  191. package/dist/chunk-L47B3OMM.js +1156 -0
  192. package/dist/chunk-LCQFWI6S.js +997 -0
  193. package/dist/chunk-LFIUZUI5.js +1138 -0
  194. package/dist/chunk-LHSLPQR4.js +1854 -0
  195. package/dist/chunk-LJGVAOFP.js +647 -0
  196. package/dist/chunk-LKJDYQPA.js +1687 -0
  197. package/dist/chunk-LOY6PWTR.js +1336 -0
  198. package/dist/chunk-LPFN3GNV.js +1147 -0
  199. package/dist/chunk-LPM7AN7S.js +1147 -0
  200. package/dist/chunk-LU6ES63L.js +1249 -0
  201. package/dist/chunk-M73DE7AU.js +1389 -0
  202. package/dist/chunk-M7OJ52WK.js +1448 -0
  203. package/dist/chunk-MCSM3DAE.js +1024 -0
  204. package/dist/chunk-MEP7OYUL.js +1417 -0
  205. package/dist/chunk-MFH6MVWX.js +1441 -0
  206. package/dist/chunk-MIHU3TFJ.js +1156 -0
  207. package/dist/chunk-MIU5FMSV.js +1329 -0
  208. package/dist/chunk-MJQMHH7Z.js +1976 -0
  209. package/dist/chunk-MLR2HUUY.js +1255 -0
  210. package/dist/chunk-MSBZHMUV.js +997 -0
  211. package/dist/chunk-MV4DZQRB.js +1163 -0
  212. package/dist/chunk-MWBLZDYK.js +1854 -0
  213. package/dist/chunk-N2MEPDSA.js +675 -0
  214. package/dist/chunk-N36ATUZM.js +1863 -0
  215. package/dist/chunk-NEHLM4WN.js +1610 -0
  216. package/dist/chunk-NHOJZ7FZ.js +1138 -0
  217. package/dist/chunk-NLPQBHHH.js +1282 -0
  218. package/dist/chunk-NMY3FWV7.js +1236 -0
  219. package/dist/chunk-NN2WDNCO.js +1138 -0
  220. package/dist/chunk-NNC7LH2Y.js +1258 -0
  221. package/dist/chunk-NQRWXPJ5.js +1275 -0
  222. package/dist/chunk-NR3G3D6Q.js +1238 -0
  223. package/dist/chunk-NRUAFOL3.js +2121 -0
  224. package/dist/chunk-NSCG7F6H.js +1862 -0
  225. package/dist/chunk-NXHVG7ZI.js +1113 -0
  226. package/dist/chunk-NYKPTBXA.js +1258 -0
  227. package/dist/chunk-O4AE4MFX.js +920 -0
  228. package/dist/chunk-O7GTMG3C.js +1467 -0
  229. package/dist/chunk-OBUP5UIM.js +997 -0
  230. package/dist/chunk-ONI2DTTL.js +1156 -0
  231. package/dist/chunk-OQHLTSVD.js +1776 -0
  232. package/dist/chunk-OVV6SHTA.js +997 -0
  233. package/dist/chunk-PAPAMVNI.js +1156 -0
  234. package/dist/chunk-PH7OXFMJ.js +997 -0
  235. package/dist/chunk-PHFLPSZU.js +1608 -0
  236. package/dist/chunk-PTVSK5DV.js +1854 -0
  237. package/dist/chunk-PUHWX6PD.js +1156 -0
  238. package/dist/chunk-PYDU2HN2.js +1803 -0
  239. package/dist/chunk-Q2AMIXBY.js +1250 -0
  240. package/dist/chunk-Q2EARVB7.js +1414 -0
  241. package/dist/chunk-Q4HFSYSN.js +1024 -0
  242. package/dist/chunk-Q65PNALY.js +1024 -0
  243. package/dist/chunk-QBQNHCYH.js +1791 -0
  244. package/dist/chunk-QGI55HK3.js +1433 -0
  245. package/dist/chunk-QIAODEAT.js +1862 -0
  246. package/dist/chunk-QLRJ2X3B.js +1800 -0
  247. package/dist/chunk-QTLVBIBL.js +1147 -0
  248. package/dist/chunk-QUPLQ7O4.js +1862 -0
  249. package/dist/chunk-QZGUSWLN.js +1415 -0
  250. package/dist/chunk-R7N3T7YR.js +1130 -0
  251. package/dist/chunk-RFS3GC46.js +239 -0
  252. package/dist/chunk-RJA7HIQO.js +1823 -0
  253. package/dist/chunk-RJLU3F7G.js +1156 -0
  254. package/dist/chunk-RLBXW5AY.js +1156 -0
  255. package/dist/chunk-RMKHLIMU.js +1147 -0
  256. package/dist/chunk-RS7F3BLO.js +1255 -0
  257. package/dist/chunk-RYLDHQQT.js +997 -0
  258. package/dist/chunk-RYYTEAQ7.js +1147 -0
  259. package/dist/chunk-S2KNKYQJ.js +1815 -0
  260. package/dist/chunk-S5R5IZJH.js +2056 -0
  261. package/dist/chunk-S5S7OBDZ.js +1355 -0
  262. package/dist/chunk-S6YKNJQG.js +1868 -0
  263. package/dist/chunk-SBDVWSWM.js +1251 -0
  264. package/dist/chunk-SBXSREFV.js +1237 -0
  265. package/dist/chunk-SDZJV47M.js +1238 -0
  266. package/dist/chunk-SMBILO75.js +1024 -0
  267. package/dist/chunk-SUSLSP3P.js +1456 -0
  268. package/dist/chunk-T4GPZ2AG.js +1128 -0
  269. package/dist/chunk-TA7EDJXT.js +1460 -0
  270. package/dist/chunk-TAW2ISST.js +1024 -0
  271. package/dist/chunk-TB6KKWS2.js +1138 -0
  272. package/dist/chunk-TBZCEX5O.js +1355 -0
  273. package/dist/chunk-TDOPKFNW.js +756 -0
  274. package/dist/chunk-TGY3JSDQ.js +1460 -0
  275. package/dist/chunk-THOIGUSY.js +666 -0
  276. package/dist/chunk-TLSGQKLO.js +1836 -0
  277. package/dist/chunk-TQ2QEU3G.js +1460 -0
  278. package/dist/chunk-TRJODOZM.js +1232 -0
  279. package/dist/chunk-TSBMRYLQ.js +1717 -0
  280. package/dist/chunk-TUL3R6KB.js +1024 -0
  281. package/dist/chunk-TWCD6YPP.js +2129 -0
  282. package/dist/chunk-TWQDGVLI.js +1323 -0
  283. package/dist/chunk-TZQLWQTW.js +769 -0
  284. package/dist/chunk-U22K555L.js +1803 -0
  285. package/dist/chunk-U3VXLQTW.js +1707 -0
  286. package/dist/chunk-U5QM4SRB.js +2054 -0
  287. package/dist/chunk-UCZLOOAW.js +997 -0
  288. package/dist/chunk-UDA2OZLK.js +1242 -0
  289. package/dist/chunk-UDASJ4IC.js +1355 -0
  290. package/dist/chunk-UGU2KSOQ.js +1113 -0
  291. package/dist/chunk-UJHB3CLA.js +1130 -0
  292. package/dist/chunk-UNUTAECX.js +1238 -0
  293. package/dist/chunk-UUUJVWXA.js +1806 -0
  294. package/dist/chunk-UV4WM7Q5.js +2039 -0
  295. package/dist/chunk-UXPGPOQ3.js +2113 -0
  296. package/dist/chunk-UYVWNYFB.js +1434 -0
  297. package/dist/chunk-UYWI4MPU.js +1460 -0
  298. package/dist/chunk-V2FNBN3P.js +997 -0
  299. package/dist/chunk-V6CF5XXG.js +1862 -0
  300. package/dist/chunk-V6UUV2SZ.js +1156 -0
  301. package/dist/chunk-VARTDMWQ.js +1862 -0
  302. package/dist/chunk-VC7ZYKMP.js +1156 -0
  303. package/dist/chunk-VCJNX77B.js +2038 -0
  304. package/dist/chunk-VDE2I72J.js +650 -0
  305. package/dist/chunk-VEO7FKEL.js +1156 -0
  306. package/dist/chunk-VIJYIU7E.js +2124 -0
  307. package/dist/chunk-VJX4WETG.js +1136 -0
  308. package/dist/chunk-VO3QDFU2.js +1276 -0
  309. package/dist/chunk-VOX2Q2V2.js +1933 -0
  310. package/dist/chunk-W7J5XM2X.js +1862 -0
  311. package/dist/chunk-WONM6P4N.js +1862 -0
  312. package/dist/chunk-WW576PYD.js +1862 -0
  313. package/dist/chunk-XCZCCA2D.js +997 -0
  314. package/dist/chunk-XHQOG4X6.js +1871 -0
  315. package/dist/chunk-XIYLHBWA.js +1163 -0
  316. package/dist/chunk-XKZ6XWSE.js +1907 -0
  317. package/dist/chunk-XLHKOBSF.js +1815 -0
  318. package/dist/chunk-XMMFUBB5.js +1270 -0
  319. package/dist/chunk-XQLK777K.js +1442 -0
  320. package/dist/chunk-XRN47M65.js +997 -0
  321. package/dist/chunk-XVBKUEXA.js +1441 -0
  322. package/dist/chunk-XY4ISIAV.js +1639 -0
  323. package/dist/chunk-Y2SOII6F.js +1156 -0
  324. package/dist/chunk-Y5TJU6YZ.js +1163 -0
  325. package/dist/chunk-YBPCMSUU.js +1147 -0
  326. package/dist/chunk-YDAZ3YZT.js +1004 -0
  327. package/dist/chunk-YH2QPUWO.js +1621 -0
  328. package/dist/chunk-YJX4O5CY.js +1355 -0
  329. package/dist/chunk-YNJMS3VK.js +997 -0
  330. package/dist/chunk-YNRZMOC3.js +997 -0
  331. package/dist/chunk-YNUF5JNP.js +1163 -0
  332. package/dist/chunk-YO7TJ6SG.js +2135 -0
  333. package/dist/chunk-YTUUFYVS.js +1842 -0
  334. package/dist/chunk-YXCOG54V.js +997 -0
  335. package/dist/chunk-Z7V254BA.js +1432 -0
  336. package/dist/chunk-ZBHRR3RS.js +1256 -0
  337. package/dist/chunk-ZM47X5PT.js +1236 -0
  338. package/dist/chunk-ZO6JUCLC.js +917 -0
  339. package/dist/chunk-ZOF4ERNI.js +2039 -0
  340. package/dist/chunk-ZOTRZN3T.js +1238 -0
  341. package/dist/chunk-ZPBA4JGE.js +1234 -0
  342. package/dist/chunk-ZTKGRHNV.js +1138 -0
  343. package/dist/chunk-ZW2JM2OY.js +997 -0
  344. package/dist/chunk-ZXYHUC7C.js +1722 -0
  345. package/dist/cli.d.ts +1 -0
  346. package/dist/cli.js +8 -0
  347. package/dist/index.d.ts +47 -0
  348. package/dist/index.js +37 -0
  349. package/dist/run-interactive-ink-2CDKFV6C.js +783 -0
  350. package/dist/run-interactive-ink-2JULLCIS.js +461 -0
  351. package/dist/run-interactive-ink-2KIHEGXT.js +451 -0
  352. package/dist/run-interactive-ink-2LX2NZRL.js +737 -0
  353. package/dist/run-interactive-ink-2OH6AV3C.js +756 -0
  354. package/dist/run-interactive-ink-2PLJ5XST.js +423 -0
  355. package/dist/run-interactive-ink-2ZI75VMK.js +462 -0
  356. package/dist/run-interactive-ink-3BHGPZ4B.js +423 -0
  357. package/dist/run-interactive-ink-3IUV3456.js +777 -0
  358. package/dist/run-interactive-ink-3QZK5PWY.js +168 -0
  359. package/dist/run-interactive-ink-3VLL4FNN.js +423 -0
  360. package/dist/run-interactive-ink-47Y2KAFZ.js +668 -0
  361. package/dist/run-interactive-ink-4CBTS636.js +423 -0
  362. package/dist/run-interactive-ink-4CHDJRAK.js +423 -0
  363. package/dist/run-interactive-ink-4E6GM5ST.js +423 -0
  364. package/dist/run-interactive-ink-4EKHIHGU.js +462 -0
  365. package/dist/run-interactive-ink-4NO7O233.js +744 -0
  366. package/dist/run-interactive-ink-55IZU2EZ.js +741 -0
  367. package/dist/run-interactive-ink-5A7BER6J.js +423 -0
  368. package/dist/run-interactive-ink-5NEFKF3R.js +423 -0
  369. package/dist/run-interactive-ink-5TCBH3Z4.js +462 -0
  370. package/dist/run-interactive-ink-5WOLWMGH.js +747 -0
  371. package/dist/run-interactive-ink-66JFIG2P.js +462 -0
  372. package/dist/run-interactive-ink-6R77DKEV.js +744 -0
  373. package/dist/run-interactive-ink-7B6HI7XT.js +679 -0
  374. package/dist/run-interactive-ink-7ICZH4E3.js +423 -0
  375. package/dist/run-interactive-ink-7LWBJYQE.js +423 -0
  376. package/dist/run-interactive-ink-7Y7MVKPA.js +438 -0
  377. package/dist/run-interactive-ink-A264MR35.js +423 -0
  378. package/dist/run-interactive-ink-A3NCKFFM.js +423 -0
  379. package/dist/run-interactive-ink-A4FBMTZ5.js +563 -0
  380. package/dist/run-interactive-ink-A7YPXRXR.js +462 -0
  381. package/dist/run-interactive-ink-AAER2EXR.js +451 -0
  382. package/dist/run-interactive-ink-ADVQJ2GF.js +423 -0
  383. package/dist/run-interactive-ink-ALV34HZF.js +451 -0
  384. package/dist/run-interactive-ink-ARDK3CO6.js +462 -0
  385. package/dist/run-interactive-ink-AVMVDBQK.js +462 -0
  386. package/dist/run-interactive-ink-AWV7ZOTC.js +423 -0
  387. package/dist/run-interactive-ink-AWZLJJLH.js +423 -0
  388. package/dist/run-interactive-ink-B25V52JO.js +462 -0
  389. package/dist/run-interactive-ink-BC6RGDCH.js +451 -0
  390. package/dist/run-interactive-ink-BMWLPUEU.js +451 -0
  391. package/dist/run-interactive-ink-BRT2MMN6.js +423 -0
  392. package/dist/run-interactive-ink-CB42OWV4.js +572 -0
  393. package/dist/run-interactive-ink-COZSBQND.js +777 -0
  394. package/dist/run-interactive-ink-CQFV44HM.js +451 -0
  395. package/dist/run-interactive-ink-CQMG45KQ.js +462 -0
  396. package/dist/run-interactive-ink-CQP3B7JM.js +669 -0
  397. package/dist/run-interactive-ink-CUCLNJCF.js +451 -0
  398. package/dist/run-interactive-ink-DEEZYQK5.js +423 -0
  399. package/dist/run-interactive-ink-DF5P6WZX.js +423 -0
  400. package/dist/run-interactive-ink-DFITKRY4.js +423 -0
  401. package/dist/run-interactive-ink-DG6TTEQQ.js +462 -0
  402. package/dist/run-interactive-ink-DH7ECECB.js +438 -0
  403. package/dist/run-interactive-ink-DMTUJHP6.js +423 -0
  404. package/dist/run-interactive-ink-DNSBSWLT.js +451 -0
  405. package/dist/run-interactive-ink-DV3TZEM3.js +742 -0
  406. package/dist/run-interactive-ink-E4AYCUDK.js +451 -0
  407. package/dist/run-interactive-ink-E4GPBTSL.js +462 -0
  408. package/dist/run-interactive-ink-ECVTPOIE.js +462 -0
  409. package/dist/run-interactive-ink-ELPCCGT3.js +423 -0
  410. package/dist/run-interactive-ink-ELWVRJZS.js +451 -0
  411. package/dist/run-interactive-ink-ENBMPAV7.js +462 -0
  412. package/dist/run-interactive-ink-EOVWUC3C.js +451 -0
  413. package/dist/run-interactive-ink-EVHWEXM4.js +451 -0
  414. package/dist/run-interactive-ink-F7SBCWE3.js +423 -0
  415. package/dist/run-interactive-ink-FCHXZ3JW.js +423 -0
  416. package/dist/run-interactive-ink-G27WWB5V.js +423 -0
  417. package/dist/run-interactive-ink-GDFTNYRC.js +462 -0
  418. package/dist/run-interactive-ink-GHGZAYSM.js +533 -0
  419. package/dist/run-interactive-ink-GK4IVHVT.js +684 -0
  420. package/dist/run-interactive-ink-GNCZNR6W.js +423 -0
  421. package/dist/run-interactive-ink-GQ53M5SW.js +605 -0
  422. package/dist/run-interactive-ink-GT7R7X2P.js +762 -0
  423. package/dist/run-interactive-ink-GWZTEIEZ.js +462 -0
  424. package/dist/run-interactive-ink-HA45VNUD.js +703 -0
  425. package/dist/run-interactive-ink-HB44RGFJ.js +423 -0
  426. package/dist/run-interactive-ink-HCVGKG23.js +462 -0
  427. package/dist/run-interactive-ink-HYKJ4PZ3.js +462 -0
  428. package/dist/run-interactive-ink-IGEBXARA.js +423 -0
  429. package/dist/run-interactive-ink-IGU7UVL5.js +462 -0
  430. package/dist/run-interactive-ink-JNVKOJRV.js +462 -0
  431. package/dist/run-interactive-ink-JYON5JQQ.js +461 -0
  432. package/dist/run-interactive-ink-K47CRELE.js +423 -0
  433. package/dist/run-interactive-ink-KCHMEHVH.js +547 -0
  434. package/dist/run-interactive-ink-KEB6ENSZ.js +423 -0
  435. package/dist/run-interactive-ink-KEWSKPTE.js +451 -0
  436. package/dist/run-interactive-ink-KJUHMADH.js +423 -0
  437. package/dist/run-interactive-ink-KW5NPJ32.js +423 -0
  438. package/dist/run-interactive-ink-L3EDWKF6.js +687 -0
  439. package/dist/run-interactive-ink-L4BCC6WG.js +462 -0
  440. package/dist/run-interactive-ink-LQPEZ6PR.js +520 -0
  441. package/dist/run-interactive-ink-LQXS5GMO.js +253 -0
  442. package/dist/run-interactive-ink-M4SOBC5E.js +817 -0
  443. package/dist/run-interactive-ink-MJGAQA2R.js +423 -0
  444. package/dist/run-interactive-ink-MPJB6PCJ.js +451 -0
  445. package/dist/run-interactive-ink-MXWZBG3F.js +461 -0
  446. package/dist/run-interactive-ink-N4XIVCWV.js +562 -0
  447. package/dist/run-interactive-ink-ND3PWHDU.js +462 -0
  448. package/dist/run-interactive-ink-NJTAWS3L.js +462 -0
  449. package/dist/run-interactive-ink-OBWWSIZ5.js +423 -0
  450. package/dist/run-interactive-ink-OD7YJBYI.js +423 -0
  451. package/dist/run-interactive-ink-OE23JGIN.js +451 -0
  452. package/dist/run-interactive-ink-OJ4EUMR5.js +462 -0
  453. package/dist/run-interactive-ink-OOC74RCY.js +423 -0
  454. package/dist/run-interactive-ink-P2PHTOX6.js +462 -0
  455. package/dist/run-interactive-ink-PE3XWCVU.js +423 -0
  456. package/dist/run-interactive-ink-PJBWWQF3.js +423 -0
  457. package/dist/run-interactive-ink-PLLZW6BV.js +678 -0
  458. package/dist/run-interactive-ink-PTXNQZ57.js +451 -0
  459. package/dist/run-interactive-ink-PWN5Q6T6.js +423 -0
  460. package/dist/run-interactive-ink-PZK4RD77.js +423 -0
  461. package/dist/run-interactive-ink-QBSXVTCG.js +462 -0
  462. package/dist/run-interactive-ink-QHOQB55Q.js +727 -0
  463. package/dist/run-interactive-ink-QIAC6ZMT.js +451 -0
  464. package/dist/run-interactive-ink-QLLGPIUL.js +462 -0
  465. package/dist/run-interactive-ink-R5W3ZEMY.js +818 -0
  466. package/dist/run-interactive-ink-RHDW3EHS.js +462 -0
  467. package/dist/run-interactive-ink-RLRKPNTS.js +668 -0
  468. package/dist/run-interactive-ink-RORQKBWV.js +425 -0
  469. package/dist/run-interactive-ink-RS6OZ66I.js +423 -0
  470. package/dist/run-interactive-ink-RVGRYBNQ.js +684 -0
  471. package/dist/run-interactive-ink-S35BKUZB.js +423 -0
  472. package/dist/run-interactive-ink-SS6RAQDE.js +423 -0
  473. package/dist/run-interactive-ink-SVP37E33.js +451 -0
  474. package/dist/run-interactive-ink-T53KH7FU.js +423 -0
  475. package/dist/run-interactive-ink-TCQUCJVS.js +423 -0
  476. package/dist/run-interactive-ink-TLUBKTTN.js +423 -0
  477. package/dist/run-interactive-ink-U2BAAHUU.js +438 -0
  478. package/dist/run-interactive-ink-U2KXGJ5S.js +451 -0
  479. package/dist/run-interactive-ink-U73PEMAO.js +423 -0
  480. package/dist/run-interactive-ink-UFTOTXIX.js +669 -0
  481. package/dist/run-interactive-ink-UJNQ54ZU.js +451 -0
  482. package/dist/run-interactive-ink-V63D5IV5.js +423 -0
  483. package/dist/run-interactive-ink-VLBITT4H.js +451 -0
  484. package/dist/run-interactive-ink-VSAX3XFR.js +462 -0
  485. package/dist/run-interactive-ink-WBJOY622.js +729 -0
  486. package/dist/run-interactive-ink-WERR64KP.js +451 -0
  487. package/dist/run-interactive-ink-WHTQ5OV6.js +732 -0
  488. package/dist/run-interactive-ink-WJBK4XIO.js +423 -0
  489. package/dist/run-interactive-ink-WQLCJ34D.js +462 -0
  490. package/dist/run-interactive-ink-WRKQJIAG.js +733 -0
  491. package/dist/run-interactive-ink-XG3P25DM.js +423 -0
  492. package/dist/run-interactive-ink-XPVJ22HP.js +462 -0
  493. package/dist/run-interactive-ink-XS5I2CGI.js +423 -0
  494. package/dist/run-interactive-ink-XVK7DXPB.js +785 -0
  495. package/dist/run-interactive-ink-YB3USTSB.js +706 -0
  496. package/dist/run-interactive-ink-YCBRQCG2.js +423 -0
  497. package/dist/run-interactive-ink-YOPSMTYJ.js +423 -0
  498. package/dist/run-interactive-ink-YYPCL65X.js +665 -0
  499. package/dist/run-interactive-ink-YYZT5L4Z.js +462 -0
  500. package/dist/run-interactive-ink-ZBPYRTJK.js +462 -0
  501. package/dist/run-interactive-ink-ZCCKFR2A.js +451 -0
  502. package/dist/run-interactive-ink-ZKYQ4CJW.js +423 -0
  503. package/dist/run-interactive-ink-ZMO2352Q.js +685 -0
  504. package/dist/run-interactive-ink-ZTDQ773P.js +423 -0
  505. package/dist/run-interactive-ink-ZWH74XDY.js +674 -0
  506. package/package.json +50 -0
  507. package/src/cli.ts +4 -0
  508. package/src/index.ts +1800 -0
  509. package/src/init-feature-context.ts +153 -0
  510. package/src/init-onboarding.ts +529 -0
  511. package/src/interactive-ink.tsx +5 -0
  512. package/src/run-interactive-ink.ts +618 -0
  513. package/src/web-ui.ts +1975 -0
  514. package/test/cli.test.ts +587 -0
  515. package/test/init-onboarding.contract.test.ts +48 -0
  516. package/tsconfig.json +9 -0
@@ -0,0 +1,1833 @@
1
+ // src/web-ui.ts
2
+ import { createHash, randomUUID, timingSafeEqual } from "crypto";
3
+ import { mkdir, readFile, writeFile } from "fs/promises";
4
+ import { basename, dirname, resolve } from "path";
5
+ import { homedir } from "os";
6
+ var DEFAULT_OWNER = "local-owner";
7
+ var SessionStore = class {
8
+ sessions = /* @__PURE__ */ new Map();
9
+ ttlMs;
10
+ constructor(ttlMs = 1e3 * 60 * 60 * 8) {
11
+ this.ttlMs = ttlMs;
12
+ }
13
+ create(ownerId = DEFAULT_OWNER) {
14
+ const now = Date.now();
15
+ const session = {
16
+ sessionId: randomUUID(),
17
+ ownerId,
18
+ csrfToken: randomUUID(),
19
+ createdAt: now,
20
+ expiresAt: now + this.ttlMs,
21
+ lastSeenAt: now
22
+ };
23
+ this.sessions.set(session.sessionId, session);
24
+ return session;
25
+ }
26
+ get(sessionId) {
27
+ const session = this.sessions.get(sessionId);
28
+ if (!session) {
29
+ return void 0;
30
+ }
31
+ if (Date.now() > session.expiresAt) {
32
+ this.sessions.delete(sessionId);
33
+ return void 0;
34
+ }
35
+ session.lastSeenAt = Date.now();
36
+ return session;
37
+ }
38
+ delete(sessionId) {
39
+ this.sessions.delete(sessionId);
40
+ }
41
+ };
42
+ var LoginRateLimiter = class {
43
+ constructor(maxAttempts = 5, windowMs = 1e3 * 60 * 5, lockoutMs = 1e3 * 60 * 10) {
44
+ this.maxAttempts = maxAttempts;
45
+ this.windowMs = windowMs;
46
+ this.lockoutMs = lockoutMs;
47
+ }
48
+ attempts = /* @__PURE__ */ new Map();
49
+ canAttempt(key) {
50
+ const current = this.attempts.get(key);
51
+ if (!current) {
52
+ return { allowed: true };
53
+ }
54
+ if (current.lockedUntil && Date.now() < current.lockedUntil) {
55
+ return {
56
+ allowed: false,
57
+ retryAfterSeconds: Math.ceil((current.lockedUntil - Date.now()) / 1e3)
58
+ };
59
+ }
60
+ return { allowed: true };
61
+ }
62
+ registerFailure(key) {
63
+ const now = Date.now();
64
+ const current = this.attempts.get(key);
65
+ if (!current || now - current.firstFailureAt > this.windowMs) {
66
+ this.attempts.set(key, { count: 1, firstFailureAt: now });
67
+ return { locked: false };
68
+ }
69
+ const count = current.count + 1;
70
+ const next = {
71
+ ...current,
72
+ count
73
+ };
74
+ if (count >= this.maxAttempts) {
75
+ next.lockedUntil = now + this.lockoutMs;
76
+ this.attempts.set(key, next);
77
+ return { locked: true, retryAfterSeconds: Math.ceil(this.lockoutMs / 1e3) };
78
+ }
79
+ this.attempts.set(key, next);
80
+ return { locked: false };
81
+ }
82
+ registerSuccess(key) {
83
+ this.attempts.delete(key);
84
+ }
85
+ };
86
+ var parseCookies = (request) => {
87
+ const cookieHeader = request.headers.cookie ?? "";
88
+ const pairs = cookieHeader.split(";").map((part) => part.trim()).filter(Boolean);
89
+ const cookies = {};
90
+ for (const pair of pairs) {
91
+ const index = pair.indexOf("=");
92
+ if (index <= 0) {
93
+ continue;
94
+ }
95
+ const key = pair.slice(0, index);
96
+ const value = pair.slice(index + 1);
97
+ try {
98
+ cookies[key] = decodeURIComponent(value);
99
+ } catch {
100
+ cookies[key] = value;
101
+ }
102
+ }
103
+ return cookies;
104
+ };
105
+ var setCookie = (response, name, value, options) => {
106
+ const segments = [`${name}=${encodeURIComponent(value)}`];
107
+ segments.push(`Path=${options.path ?? "/"}`);
108
+ if (typeof options.maxAge === "number") {
109
+ segments.push(`Max-Age=${Math.max(0, Math.floor(options.maxAge))}`);
110
+ }
111
+ if (options.httpOnly) {
112
+ segments.push("HttpOnly");
113
+ }
114
+ if (options.secure) {
115
+ segments.push("Secure");
116
+ }
117
+ if (options.sameSite) {
118
+ segments.push(`SameSite=${options.sameSite}`);
119
+ }
120
+ const previous = response.getHeader("Set-Cookie");
121
+ const serialized = segments.join("; ");
122
+ if (!previous) {
123
+ response.setHeader("Set-Cookie", serialized);
124
+ return;
125
+ }
126
+ if (Array.isArray(previous)) {
127
+ response.setHeader("Set-Cookie", [...previous, serialized]);
128
+ return;
129
+ }
130
+ response.setHeader("Set-Cookie", [String(previous), serialized]);
131
+ };
132
+ var verifyPassphrase = (provided, expected) => {
133
+ const providedBuffer = Buffer.from(provided);
134
+ const expectedBuffer = Buffer.from(expected);
135
+ if (providedBuffer.length !== expectedBuffer.length) {
136
+ const zero = Buffer.alloc(expectedBuffer.length);
137
+ return timingSafeEqual(expectedBuffer, zero) && false;
138
+ }
139
+ return timingSafeEqual(providedBuffer, expectedBuffer);
140
+ };
141
+ var getRequestIp = (request) => {
142
+ return request.socket.remoteAddress ?? "unknown";
143
+ };
144
+ var inferConversationTitle = (text) => {
145
+ const normalized = text.trim().replace(/\s+/g, " ");
146
+ if (!normalized) {
147
+ return "New conversation";
148
+ }
149
+ return normalized.length <= 48 ? normalized : `${normalized.slice(0, 48)}...`;
150
+ };
151
+ var renderManifest = (options) => {
152
+ const name = options?.agentName ?? "Agent";
153
+ return JSON.stringify({
154
+ name,
155
+ short_name: name,
156
+ description: `${name} \u2014 AI agent powered by AgentL`,
157
+ start_url: "/",
158
+ display: "standalone",
159
+ background_color: "#000000",
160
+ theme_color: "#000000",
161
+ icons: [
162
+ { src: "/icon.svg", sizes: "any", type: "image/svg+xml" },
163
+ { src: "/icon-192.png", sizes: "192x192", type: "image/png" },
164
+ { src: "/icon-512.png", sizes: "512x512", type: "image/png" }
165
+ ]
166
+ });
167
+ };
168
+ var renderIconSvg = (options) => {
169
+ const letter = (options?.agentName ?? "A").charAt(0).toUpperCase();
170
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
171
+ <rect width="512" height="512" rx="96" fill="#000"/>
172
+ <text x="256" y="256" dy=".35em" text-anchor="middle"
173
+ font-family="-apple-system,BlinkMacSystemFont,sans-serif"
174
+ font-size="280" font-weight="700" fill="#fff">${letter}</text>
175
+ </svg>`;
176
+ };
177
+ var renderServiceWorker = () => `
178
+ const CACHE_NAME = "agentl-shell-v1";
179
+ const SHELL_URLS = ["/"];
180
+
181
+ self.addEventListener("install", (event) => {
182
+ event.waitUntil(
183
+ caches.open(CACHE_NAME).then((cache) => cache.addAll(SHELL_URLS))
184
+ );
185
+ self.skipWaiting();
186
+ });
187
+
188
+ self.addEventListener("activate", (event) => {
189
+ event.waitUntil(
190
+ caches.keys().then((keys) =>
191
+ Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
192
+ )
193
+ );
194
+ self.clients.claim();
195
+ });
196
+
197
+ self.addEventListener("fetch", (event) => {
198
+ const url = new URL(event.request.url);
199
+ // Only cache GET requests for the app shell; let API calls pass through
200
+ if (event.request.method !== "GET" || url.pathname.startsWith("/api/")) {
201
+ return;
202
+ }
203
+ event.respondWith(
204
+ fetch(event.request)
205
+ .then((response) => {
206
+ const clone = response.clone();
207
+ caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone));
208
+ return response;
209
+ })
210
+ .catch(() => caches.match(event.request))
211
+ );
212
+ });
213
+ `;
214
+ var renderWebUiHtml = (options) => {
215
+ const agentInitial = (options?.agentName ?? "A").charAt(0).toUpperCase();
216
+ const agentName = options?.agentName ?? "Agent";
217
+ return `<!doctype html>
218
+ <html lang="en">
219
+ <head>
220
+ <meta charset="utf-8">
221
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
222
+ <meta name="theme-color" content="#000000">
223
+ <meta name="apple-mobile-web-app-capable" content="yes">
224
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
225
+ <meta name="apple-mobile-web-app-title" content="${agentName}">
226
+ <link rel="manifest" href="/manifest.json">
227
+ <link rel="icon" href="/icon.svg" type="image/svg+xml">
228
+ <link rel="apple-touch-icon" href="/icon-192.png">
229
+ <title>${agentName}</title>
230
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inconsolata:400,700">
231
+ <style>
232
+ * { box-sizing: border-box; margin: 0; padding: 0; }
233
+ html, body { height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: pan-y; }
234
+ body {
235
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;
236
+ background: #000;
237
+ color: #ededed;
238
+ font-size: 14px;
239
+ line-height: 1.5;
240
+ -webkit-font-smoothing: antialiased;
241
+ -moz-osx-font-smoothing: grayscale;
242
+ }
243
+ button, input, textarea { font: inherit; color: inherit; }
244
+ .hidden { display: none !important; }
245
+ a { color: #ededed; }
246
+
247
+ /* Auth */
248
+ .auth {
249
+ min-height: 100vh;
250
+ display: grid;
251
+ place-items: center;
252
+ padding: 20px;
253
+ background: #000;
254
+ }
255
+ .auth-card {
256
+ width: min(380px, 90vw);
257
+ background: #0a0a0a;
258
+ border: 1px solid rgba(255,255,255,0.08);
259
+ border-radius: 12px;
260
+ padding: 32px;
261
+ display: grid;
262
+ gap: 20px;
263
+ }
264
+ .auth-brand {
265
+ display: flex;
266
+ align-items: center;
267
+ gap: 8px;
268
+ }
269
+ .auth-brand svg { width: 20px; height: 20px; }
270
+ .auth-title {
271
+ font-size: 16px;
272
+ font-weight: 500;
273
+ letter-spacing: -0.01em;
274
+ }
275
+ .auth-text { color: #666; font-size: 13px; line-height: 1.5; }
276
+ .auth-input {
277
+ width: 100%;
278
+ background: #000;
279
+ border: 1px solid rgba(255,255,255,0.12);
280
+ border-radius: 6px;
281
+ color: #ededed;
282
+ padding: 10px 12px;
283
+ font-size: 14px;
284
+ outline: none;
285
+ transition: border-color 0.15s;
286
+ }
287
+ .auth-input:focus { border-color: rgba(255,255,255,0.3); }
288
+ .auth-input::placeholder { color: #555; }
289
+ .auth-submit {
290
+ background: #ededed;
291
+ color: #000;
292
+ border: 0;
293
+ border-radius: 6px;
294
+ padding: 10px 16px;
295
+ font-size: 14px;
296
+ font-weight: 500;
297
+ cursor: pointer;
298
+ transition: background 0.15s;
299
+ }
300
+ .auth-submit:hover { background: #fff; }
301
+ .error { color: #ff4444; font-size: 13px; min-height: 16px; }
302
+ .message-error {
303
+ background: rgba(255,68,68,0.08);
304
+ border: 1px solid rgba(255,68,68,0.25);
305
+ border-radius: 10px;
306
+ color: #ff6b6b;
307
+ padding: 12px 16px;
308
+ font-size: 13px;
309
+ line-height: 1.5;
310
+ max-width: 600px;
311
+ }
312
+ .message-error strong { color: #ff4444; }
313
+
314
+ /* Layout */
315
+ .shell {
316
+ position: fixed;
317
+ top: 0;
318
+ left: 0;
319
+ right: 0;
320
+ bottom: 0;
321
+ display: flex;
322
+ overflow: hidden;
323
+ /* Apply safe areas to the shell container */
324
+ padding-bottom: env(safe-area-inset-bottom, 0px);
325
+ }
326
+
327
+ /* Edge swipe blocker - invisible touch target to intercept right edge gestures */
328
+ .edge-blocker-right {
329
+ position: fixed;
330
+ top: 0;
331
+ bottom: 0;
332
+ right: 0;
333
+ width: 20px;
334
+ z-index: 9999;
335
+ touch-action: none;
336
+ }
337
+ .sidebar {
338
+ width: 260px;
339
+ background: #000;
340
+ border-right: 1px solid rgba(255,255,255,0.06);
341
+ display: flex;
342
+ flex-direction: column;
343
+ padding: 12px 8px;
344
+ }
345
+ .new-chat-btn {
346
+ background: transparent;
347
+ border: 0;
348
+ color: #888;
349
+ border-radius: 12px;
350
+ height: 36px;
351
+ padding: 0 10px;
352
+ display: flex;
353
+ align-items: center;
354
+ gap: 8px;
355
+ font-size: 13px;
356
+ cursor: pointer;
357
+ transition: background 0.15s, color 0.15s;
358
+ }
359
+ .new-chat-btn:hover { color: #ededed; }
360
+ .new-chat-btn svg { width: 16px; height: 16px; }
361
+ .conversation-list {
362
+ flex: 1;
363
+ overflow-y: auto;
364
+ margin-top: 12px;
365
+ display: flex;
366
+ flex-direction: column;
367
+ gap: 2px;
368
+ }
369
+ .conversation-item {
370
+ padding: 7px 28px 7px 10px;
371
+ border-radius: 12px;
372
+ cursor: pointer;
373
+ font-size: 13px;
374
+ color: #555;
375
+ white-space: nowrap;
376
+ overflow: hidden;
377
+ text-overflow: ellipsis;
378
+ position: relative;
379
+ transition: color 0.15s;
380
+ }
381
+ .conversation-item:hover { color: #999; }
382
+ .conversation-item.active {
383
+ color: #ededed;
384
+ }
385
+ .conversation-item .delete-btn {
386
+ position: absolute;
387
+ right: 0;
388
+ top: 0;
389
+ bottom: 0;
390
+ opacity: 0;
391
+ background: #000;
392
+ border: 0;
393
+ color: #444;
394
+ padding: 0 8px;
395
+ border-radius: 0 4px 4px 0;
396
+ cursor: pointer;
397
+ font-size: 16px;
398
+ line-height: 1;
399
+ display: grid;
400
+ place-items: center;
401
+ transition: opacity 0.15s, color 0.15s;
402
+ }
403
+ .conversation-item:hover .delete-btn { opacity: 1; }
404
+ .conversation-item.active .delete-btn { background: rgba(0,0,0,1); }
405
+ .conversation-item .delete-btn::before {
406
+ content: "";
407
+ position: absolute;
408
+ right: 100%;
409
+ top: 0;
410
+ bottom: 0;
411
+ width: 24px;
412
+ background: linear-gradient(to right, transparent, #000);
413
+ pointer-events: none;
414
+ }
415
+ .conversation-item.active .delete-btn::before {
416
+ background: linear-gradient(to right, transparent, rgba(0,0,0,1));
417
+ }
418
+ .conversation-item .delete-btn:hover { color: #888; }
419
+ .conversation-item .delete-btn.confirming {
420
+ opacity: 1;
421
+ width: auto;
422
+ padding: 0 8px;
423
+ font-size: 11px;
424
+ color: #ff4444;
425
+ border-radius: 3px;
426
+ }
427
+ .conversation-item .delete-btn.confirming:hover {
428
+ color: #ff6666;
429
+ }
430
+ .sidebar-footer {
431
+ margin-top: auto;
432
+ padding-top: 8px;
433
+ }
434
+ .logout-btn {
435
+ background: transparent;
436
+ border: 0;
437
+ color: #555;
438
+ width: 100%;
439
+ padding: 8px 10px;
440
+ text-align: left;
441
+ border-radius: 6px;
442
+ cursor: pointer;
443
+ font-size: 13px;
444
+ transition: color 0.15s, background 0.15s;
445
+ }
446
+ .logout-btn:hover { color: #888; }
447
+
448
+ /* Main */
449
+ .main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #000; }
450
+ .topbar {
451
+ height: calc(52px + env(safe-area-inset-top, 0px));
452
+ padding-top: env(safe-area-inset-top, 0px);
453
+ display: flex;
454
+ align-items: center;
455
+ justify-content: center;
456
+ font-size: 13px;
457
+ font-weight: 500;
458
+ color: #888;
459
+ border-bottom: 1px solid rgba(255,255,255,0.06);
460
+ position: relative;
461
+ flex-shrink: 0;
462
+ }
463
+ .topbar-title {
464
+ max-width: 400px;
465
+ overflow: hidden;
466
+ text-overflow: ellipsis;
467
+ white-space: nowrap;
468
+ letter-spacing: -0.01em;
469
+ }
470
+ .sidebar-toggle {
471
+ display: none;
472
+ position: absolute;
473
+ left: 12px;
474
+ top: calc(env(safe-area-inset-top, 0px) + 10px);
475
+ background: transparent;
476
+ border: 0;
477
+ color: #666;
478
+ width: 32px;
479
+ height: 32px;
480
+ border-radius: 6px;
481
+ cursor: pointer;
482
+ transition: color 0.15s, background 0.15s;
483
+ font-size: 18px;
484
+ }
485
+ .sidebar-toggle:hover { color: #ededed; }
486
+
487
+ /* Messages */
488
+ .messages { flex: 1; overflow-y: auto; padding: 24px 24px; }
489
+ .messages-column { max-width: 680px; margin: 0 auto; }
490
+ .message-row { margin-bottom: 24px; display: flex; }
491
+ .message-row.user { justify-content: flex-end; }
492
+ .assistant-wrap { display: flex; gap: 12px; max-width: 100%; }
493
+ .assistant-avatar {
494
+ width: 24px;
495
+ height: 24px;
496
+ background: #ededed;
497
+ color: #000;
498
+ border-radius: 6px;
499
+ display: grid;
500
+ place-items: center;
501
+ font-size: 11px;
502
+ font-weight: 600;
503
+ flex-shrink: 0;
504
+ margin-top: 2px;
505
+ }
506
+ .assistant-content {
507
+ line-height: 1.65;
508
+ color: #ededed;
509
+ font-size: 14px;
510
+ min-width: 0;
511
+ margin-top: 2px;
512
+ }
513
+ .assistant-content p { margin: 0 0 12px; }
514
+ .assistant-content p:last-child { margin-bottom: 0; }
515
+ .assistant-content ul, .assistant-content ol { margin: 8px 0; padding-left: 20px; }
516
+ .assistant-content li { margin: 4px 0; }
517
+ .assistant-content strong { font-weight: 600; color: #fff; }
518
+ .assistant-content h2 {
519
+ font-size: 16px;
520
+ font-weight: 600;
521
+ letter-spacing: -0.02em;
522
+ margin: 20px 0 8px;
523
+ color: #fff;
524
+ }
525
+ .assistant-content h3 {
526
+ font-size: 14px;
527
+ font-weight: 600;
528
+ letter-spacing: -0.01em;
529
+ margin: 16px 0 6px;
530
+ color: #fff;
531
+ }
532
+ .assistant-content code {
533
+ background: rgba(255,255,255,0.06);
534
+ border: 1px solid rgba(255,255,255,0.06);
535
+ padding: 2px 5px;
536
+ border-radius: 4px;
537
+ font-family: ui-monospace, "SF Mono", "Fira Code", monospace;
538
+ font-size: 0.88em;
539
+ }
540
+ .assistant-content pre {
541
+ background: #0a0a0a;
542
+ border: 1px solid rgba(255,255,255,0.06);
543
+ padding: 14px 16px;
544
+ border-radius: 8px;
545
+ overflow-x: auto;
546
+ margin: 14px 0;
547
+ }
548
+ .assistant-content pre code {
549
+ background: none;
550
+ border: 0;
551
+ padding: 0;
552
+ font-size: 13px;
553
+ line-height: 1.5;
554
+ }
555
+ .tool-activity {
556
+ margin-top: 12px;
557
+ border: 1px solid rgba(255,255,255,0.08);
558
+ background: rgba(255,255,255,0.03);
559
+ border-radius: 10px;
560
+ font-size: 12px;
561
+ line-height: 1.45;
562
+ color: #bcbcbc;
563
+ max-width: 300px;
564
+ }
565
+ .tool-activity-disclosure {
566
+ display: block;
567
+ }
568
+ .tool-activity-summary {
569
+ list-style: none;
570
+ display: flex;
571
+ align-items: center;
572
+ gap: 8px;
573
+ cursor: pointer;
574
+ padding: 10px 12px;
575
+ user-select: none;
576
+ }
577
+ .tool-activity-summary::-webkit-details-marker {
578
+ display: none;
579
+ }
580
+ .tool-activity-label {
581
+ font-size: 11px;
582
+ text-transform: uppercase;
583
+ letter-spacing: 0.06em;
584
+ color: #8a8a8a;
585
+ font-weight: 600;
586
+ }
587
+ .tool-activity-caret {
588
+ margin-left: auto;
589
+ color: #8a8a8a;
590
+ display: inline-flex;
591
+ align-items: center;
592
+ justify-content: center;
593
+ transition: transform 120ms ease;
594
+ transform: rotate(0deg);
595
+ }
596
+ .tool-activity-caret svg {
597
+ width: 14px;
598
+ height: 14px;
599
+ display: block;
600
+ }
601
+ .tool-activity-disclosure[open] .tool-activity-caret {
602
+ transform: rotate(90deg);
603
+ }
604
+ .tool-activity-list {
605
+ display: grid;
606
+ gap: 6px;
607
+ padding: 0 12px 10px;
608
+ }
609
+ .tool-activity-item {
610
+ font-family: ui-monospace, "SF Mono", "Fira Code", monospace;
611
+ background: rgba(255,255,255,0.04);
612
+ border-radius: 6px;
613
+ padding: 4px 7px;
614
+ color: #d6d6d6;
615
+ }
616
+ .user-bubble {
617
+ background: #111;
618
+ border: 1px solid rgba(255,255,255,0.08);
619
+ padding: 10px 16px;
620
+ border-radius: 18px;
621
+ max-width: 70%;
622
+ font-size: 14px;
623
+ line-height: 1.5;
624
+ }
625
+ .empty-state {
626
+ display: flex;
627
+ flex-direction: column;
628
+ align-items: center;
629
+ justify-content: center;
630
+ height: 100%;
631
+ gap: 16px;
632
+ color: #555;
633
+ }
634
+ .empty-state .assistant-avatar {
635
+ width: 36px;
636
+ height: 36px;
637
+ font-size: 14px;
638
+ border-radius: 8px;
639
+ }
640
+ .empty-state-text {
641
+ font-size: 14px;
642
+ color: #555;
643
+ }
644
+ .thinking-indicator {
645
+ display: inline-block;
646
+ font-family: Inconsolata, monospace;
647
+ font-size: 20px;
648
+ line-height: 1;
649
+ vertical-align: middle;
650
+ color: #ededed;
651
+ opacity: 0.5;
652
+ }
653
+
654
+ /* Composer */
655
+ .composer {
656
+ padding: 12px 24px 24px;
657
+ position: relative;
658
+ }
659
+ .composer::before {
660
+ content: "";
661
+ position: absolute;
662
+ left: 0;
663
+ right: 0;
664
+ bottom: 100%;
665
+ height: 48px;
666
+ background: linear-gradient(to top, #000 0%, transparent 100%);
667
+ pointer-events: none;
668
+ }
669
+ .composer-inner { max-width: 680px; margin: 0 auto; }
670
+ .composer-shell {
671
+ background: #0a0a0a;
672
+ border: 1px solid rgba(255,255,255,0.1);
673
+ border-radius: 9999px;
674
+ display: flex;
675
+ align-items: center;
676
+ padding: 4px 6px 4px 18px;
677
+ transition: border-color 0.15s;
678
+ }
679
+ .composer-shell:focus-within { border-color: rgba(255,255,255,0.2); }
680
+ .composer-input {
681
+ flex: 1;
682
+ background: transparent;
683
+ border: 0;
684
+ outline: none;
685
+ color: #ededed;
686
+ min-height: 40px;
687
+ max-height: 200px;
688
+ resize: none;
689
+ padding: 10px 0 8px;
690
+ font-size: 14px;
691
+ line-height: 1.5;
692
+ }
693
+ .composer-input::placeholder { color: #444; }
694
+ .send-btn {
695
+ width: 32px;
696
+ height: 32px;
697
+ background: #ededed;
698
+ border: 0;
699
+ border-radius: 50%;
700
+ color: #000;
701
+ cursor: pointer;
702
+ display: grid;
703
+ place-items: center;
704
+ flex-shrink: 0;
705
+ margin-bottom: 2px;
706
+ transition: background 0.15s, opacity 0.15s;
707
+ }
708
+ .send-btn:hover { background: #fff; }
709
+ .send-btn:disabled { opacity: 0.2; cursor: default; }
710
+ .send-btn:disabled:hover { background: #ededed; }
711
+ .disclaimer {
712
+ text-align: center;
713
+ color: #333;
714
+ font-size: 12px;
715
+ margin-top: 10px;
716
+ }
717
+
718
+ /* Scrollbar */
719
+ ::-webkit-scrollbar { width: 6px; }
720
+ ::-webkit-scrollbar-track { background: transparent; }
721
+ ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
722
+ ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }
723
+
724
+ /* Mobile */
725
+ @media (max-width: 768px) {
726
+ .sidebar {
727
+ position: fixed;
728
+ inset: 0 auto 0 0;
729
+ z-index: 100;
730
+ transform: translateX(-100%);
731
+ padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
732
+ will-change: transform;
733
+ }
734
+ .sidebar.dragging { transition: none; }
735
+ .sidebar:not(.dragging) { transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
736
+ .shell.sidebar-open .sidebar { transform: translateX(0); }
737
+ .sidebar-toggle { display: grid; place-items: center; }
738
+ .sidebar-backdrop {
739
+ position: fixed;
740
+ inset: 0;
741
+ background: rgba(0,0,0,0.6);
742
+ z-index: 50;
743
+ backdrop-filter: blur(2px);
744
+ -webkit-backdrop-filter: blur(2px);
745
+ opacity: 0;
746
+ pointer-events: none;
747
+ will-change: opacity;
748
+ }
749
+ .sidebar-backdrop:not(.dragging) { transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
750
+ .sidebar-backdrop.dragging { transition: none; }
751
+ .shell.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
752
+ .messages { padding: 16px; }
753
+ .composer { padding: 8px 16px 16px; }
754
+ }
755
+
756
+ /* Reduced motion */
757
+ @media (prefers-reduced-motion: reduce) {
758
+ *, *::before, *::after {
759
+ animation-duration: 0.01ms !important;
760
+ transition-duration: 0.01ms !important;
761
+ }
762
+ }
763
+ </style>
764
+ </head>
765
+ <body data-agent-initial="${agentInitial}" data-agent-name="${agentName}">
766
+ <div class="edge-blocker-right"></div>
767
+ <div id="auth" class="auth hidden">
768
+ <form id="login-form" class="auth-card">
769
+ <div class="auth-brand">
770
+ <svg viewBox="0 0 24 24" fill="none"><path d="M12 2L2 19.5h20L12 2z" fill="currentColor"/></svg>
771
+ <h2 class="auth-title">AgentL</h2>
772
+ </div>
773
+ <p class="auth-text">Enter the passphrase to continue.</p>
774
+ <input id="passphrase" class="auth-input" type="password" placeholder="Passphrase" required>
775
+ <button class="auth-submit" type="submit">Continue</button>
776
+ <div id="login-error" class="error"></div>
777
+ </form>
778
+ </div>
779
+
780
+ <div id="app" class="shell hidden">
781
+ <aside class="sidebar">
782
+ <button id="new-chat" class="new-chat-btn">
783
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14M5 12h14"/></svg>
784
+ </button>
785
+ <div id="conversation-list" class="conversation-list"></div>
786
+ <div class="sidebar-footer">
787
+ <button id="logout" class="logout-btn">Log out</button>
788
+ </div>
789
+ </aside>
790
+ <div id="sidebar-backdrop" class="sidebar-backdrop"></div>
791
+ <main class="main">
792
+ <div class="topbar">
793
+ <button id="sidebar-toggle" class="sidebar-toggle">&#9776;</button>
794
+ <div id="chat-title" class="topbar-title"></div>
795
+ </div>
796
+ <div id="messages" class="messages">
797
+ <div class="empty-state">
798
+ <div class="assistant-avatar">${agentInitial}</div>
799
+ <div class="empty-state-text">How can I help you today?</div>
800
+ </div>
801
+ </div>
802
+ <form id="composer" class="composer">
803
+ <div class="composer-inner">
804
+ <div class="composer-shell">
805
+ <textarea id="prompt" class="composer-input" placeholder="Send a message..." rows="1"></textarea>
806
+ <button id="send" class="send-btn" type="submit">
807
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M8 12V4M4 7l4-4 4 4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
808
+ </button>
809
+ </div>
810
+ </div>
811
+ </form>
812
+ </main>
813
+ </div>
814
+
815
+ <script>
816
+ const state = {
817
+ csrfToken: "",
818
+ conversations: [],
819
+ activeConversationId: null,
820
+ activeMessages: [],
821
+ isStreaming: false,
822
+ confirmDeleteId: null
823
+ };
824
+
825
+ const agentInitial = document.body.dataset.agentInitial || "A";
826
+ const $ = (id) => document.getElementById(id);
827
+ const elements = {
828
+ auth: $("auth"),
829
+ app: $("app"),
830
+ loginForm: $("login-form"),
831
+ passphrase: $("passphrase"),
832
+ loginError: $("login-error"),
833
+ list: $("conversation-list"),
834
+ newChat: $("new-chat"),
835
+ messages: $("messages"),
836
+ chatTitle: $("chat-title"),
837
+ logout: $("logout"),
838
+ composer: $("composer"),
839
+ prompt: $("prompt"),
840
+ send: $("send"),
841
+ shell: $("app"),
842
+ sidebarToggle: $("sidebar-toggle"),
843
+ sidebarBackdrop: $("sidebar-backdrop")
844
+ };
845
+
846
+ const pushConversationUrl = (conversationId) => {
847
+ const target = conversationId ? "/c/" + encodeURIComponent(conversationId) : "/";
848
+ if (window.location.pathname !== target) {
849
+ history.pushState({ conversationId: conversationId || null }, "", target);
850
+ }
851
+ };
852
+
853
+ const replaceConversationUrl = (conversationId) => {
854
+ const target = conversationId ? "/c/" + encodeURIComponent(conversationId) : "/";
855
+ if (window.location.pathname !== target) {
856
+ history.replaceState({ conversationId: conversationId || null }, "", target);
857
+ }
858
+ };
859
+
860
+ const getConversationIdFromUrl = () => {
861
+ const match = window.location.pathname.match(/^\\/c\\/([^\\/]+)/);
862
+ return match ? decodeURIComponent(match[1]) : null;
863
+ };
864
+
865
+ const mutatingMethods = new Set(["POST", "PATCH", "PUT", "DELETE"]);
866
+
867
+ const api = async (path, options = {}) => {
868
+ const method = (options.method || "GET").toUpperCase();
869
+ const headers = { ...(options.headers || {}) };
870
+ if (mutatingMethods.has(method) && state.csrfToken) {
871
+ headers["x-csrf-token"] = state.csrfToken;
872
+ }
873
+ if (options.body && !headers["Content-Type"]) {
874
+ headers["Content-Type"] = "application/json";
875
+ }
876
+ const response = await fetch(path, { credentials: "include", ...options, method, headers });
877
+ if (!response.ok) {
878
+ let payload = {};
879
+ try { payload = await response.json(); } catch {}
880
+ const error = new Error(payload.message || ("Request failed: " + response.status));
881
+ error.status = response.status;
882
+ error.payload = payload;
883
+ throw error;
884
+ }
885
+ const contentType = response.headers.get("content-type") || "";
886
+ if (contentType.includes("application/json")) {
887
+ return await response.json();
888
+ }
889
+ return await response.text();
890
+ };
891
+
892
+ const escapeHtml = (value) =>
893
+ String(value || "")
894
+ .replace(/&/g, "&amp;")
895
+ .replace(/</g, "&lt;")
896
+ .replace(/>/g, "&gt;")
897
+ .replace(/"/g, "&quot;")
898
+ .replace(/'/g, "&#39;");
899
+
900
+ const renderInlineMarkdown = (value) => {
901
+ let html = escapeHtml(value);
902
+ html = html.replace(/\\*\\*([^*]+)\\*\\*/g, "<strong>$1</strong>");
903
+ html = html.replace(/\\x60([^\\x60]+)\\x60/g, "<code>$1</code>");
904
+ return html;
905
+ };
906
+
907
+ const renderMarkdownBlock = (value) => {
908
+ const lines = String(value || "").split("\\n");
909
+ let html = "";
910
+ let inList = false;
911
+
912
+ for (const rawLine of lines) {
913
+ const line = rawLine.trimEnd();
914
+ const trimmed = line.trim();
915
+ const headingMatch = trimmed.match(/^(#{1,3})\\s+(.+)$/);
916
+
917
+ if (headingMatch) {
918
+ if (inList) {
919
+ html += "</ul>";
920
+ inList = false;
921
+ }
922
+ const level = Math.min(3, headingMatch[1].length);
923
+ const tag = level === 1 ? "h2" : level === 2 ? "h3" : "p";
924
+ html += "<" + tag + ">" + renderInlineMarkdown(headingMatch[2]) + "</" + tag + ">";
925
+ continue;
926
+ }
927
+
928
+ if (/^\\s*-\\s+/.test(line)) {
929
+ if (!inList) {
930
+ html += "<ul>";
931
+ inList = true;
932
+ }
933
+ html += "<li>" + renderInlineMarkdown(line.replace(/^\\s*-\\s+/, "")) + "</li>";
934
+ continue;
935
+ }
936
+ if (inList) {
937
+ html += "</ul>";
938
+ inList = false;
939
+ }
940
+ if (trimmed.length === 0) {
941
+ continue;
942
+ }
943
+ html += "<p>" + renderInlineMarkdown(line) + "</p>";
944
+ }
945
+
946
+ if (inList) {
947
+ html += "</ul>";
948
+ }
949
+ return html;
950
+ };
951
+
952
+ const renderAssistantMarkdown = (value) => {
953
+ const source = String(value || "");
954
+ const fenceRegex = /\\x60\\x60\\x60([\\s\\S]*?)\\x60\\x60\\x60/g;
955
+ let html = "";
956
+ let lastIndex = 0;
957
+ let match;
958
+
959
+ while ((match = fenceRegex.exec(source))) {
960
+ const before = source.slice(lastIndex, match.index);
961
+ html += renderMarkdownBlock(before);
962
+ const codeText = String(match[1] || "").replace(/^\\n+|\\n+$/g, "");
963
+ html += "<pre><code>" + escapeHtml(codeText) + "</code></pre>";
964
+ lastIndex = match.index + match[0].length;
965
+ }
966
+
967
+ html += renderMarkdownBlock(source.slice(lastIndex));
968
+ return html || "<p></p>";
969
+ };
970
+
971
+ const extractToolActivity = (value) => {
972
+ const source = String(value || "");
973
+ let markerIndex = source.lastIndexOf("\\n### Tool activity\\n");
974
+ if (markerIndex < 0 && source.startsWith("### Tool activity\\n")) {
975
+ markerIndex = 0;
976
+ }
977
+ if (markerIndex < 0) {
978
+ return { content: source, activities: [] };
979
+ }
980
+ const content = markerIndex === 0 ? "" : source.slice(0, markerIndex).trimEnd();
981
+ const rawSection = markerIndex === 0 ? source : source.slice(markerIndex + 1);
982
+ const afterHeading = rawSection.replace(/^### Tool activity\\s*\\n?/, "");
983
+ const activities = afterHeading
984
+ .split("\\n")
985
+ .map((line) => line.trim())
986
+ .filter((line) => line.startsWith("- "))
987
+ .map((line) => line.slice(2).trim())
988
+ .filter(Boolean);
989
+ return { content, activities };
990
+ };
991
+
992
+ const renderToolActivity = (items) => {
993
+ if (!items || !items.length) {
994
+ return "";
995
+ }
996
+ const chips = items
997
+ .map((item) => '<div class="tool-activity-item">' + escapeHtml(item) + "</div>")
998
+ .join("");
999
+ return (
1000
+ '<div class="tool-activity">' +
1001
+ '<details class="tool-activity-disclosure">' +
1002
+ '<summary class="tool-activity-summary">' +
1003
+ '<span class="tool-activity-label">Tool activity</span>' +
1004
+ '<span class="tool-activity-caret" aria-hidden="true"><svg viewBox="0 0 12 12" fill="none"><path d="M4.5 2.75L8 6L4.5 9.25" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg></span>' +
1005
+ "</summary>" +
1006
+ '<div class="tool-activity-list">' +
1007
+ chips +
1008
+ "</div>" +
1009
+ "</details>" +
1010
+ "</div>"
1011
+ );
1012
+ };
1013
+
1014
+ const formatDate = (epoch) => {
1015
+ try {
1016
+ const date = new Date(epoch);
1017
+ const now = new Date();
1018
+ const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
1019
+ const startOfDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
1020
+ const dayDiff = Math.floor((startOfToday - startOfDate) / 86400000);
1021
+ if (dayDiff === 0) {
1022
+ return "Today";
1023
+ }
1024
+ if (dayDiff === 1) {
1025
+ return "Yesterday";
1026
+ }
1027
+ if (dayDiff < 7 && dayDiff > 1) {
1028
+ return date.toLocaleDateString(undefined, { weekday: "short" });
1029
+ }
1030
+ return date.toLocaleDateString(undefined, { month: "short", day: "numeric" });
1031
+ } catch {
1032
+ return "";
1033
+ }
1034
+ };
1035
+
1036
+ const isMobile = () => window.matchMedia("(max-width: 900px)").matches;
1037
+
1038
+ const setSidebarOpen = (open) => {
1039
+ if (!isMobile()) {
1040
+ elements.shell.classList.remove("sidebar-open");
1041
+ return;
1042
+ }
1043
+ elements.shell.classList.toggle("sidebar-open", open);
1044
+ };
1045
+
1046
+ const renderConversationList = () => {
1047
+ elements.list.innerHTML = "";
1048
+ for (const c of state.conversations) {
1049
+ const item = document.createElement("div");
1050
+ item.className = "conversation-item" + (c.conversationId === state.activeConversationId ? " active" : "");
1051
+ item.textContent = c.title;
1052
+
1053
+ const isConfirming = state.confirmDeleteId === c.conversationId;
1054
+ const deleteBtn = document.createElement("button");
1055
+ deleteBtn.className = "delete-btn" + (isConfirming ? " confirming" : "");
1056
+ deleteBtn.textContent = isConfirming ? "sure?" : "\\u00d7";
1057
+ deleteBtn.onclick = async (e) => {
1058
+ e.stopPropagation();
1059
+ if (!isConfirming) {
1060
+ state.confirmDeleteId = c.conversationId;
1061
+ renderConversationList();
1062
+ return;
1063
+ }
1064
+ await api("/api/conversations/" + c.conversationId, { method: "DELETE" });
1065
+ if (state.activeConversationId === c.conversationId) {
1066
+ state.activeConversationId = null;
1067
+ state.activeMessages = [];
1068
+ pushConversationUrl(null);
1069
+ elements.chatTitle.textContent = "";
1070
+ renderMessages([]);
1071
+ }
1072
+ state.confirmDeleteId = null;
1073
+ await loadConversations();
1074
+ };
1075
+ item.appendChild(deleteBtn);
1076
+
1077
+ item.onclick = async () => {
1078
+ if (state.confirmDeleteId) {
1079
+ state.confirmDeleteId = null;
1080
+ renderConversationList();
1081
+ return;
1082
+ }
1083
+ state.activeConversationId = c.conversationId;
1084
+ pushConversationUrl(c.conversationId);
1085
+ renderConversationList();
1086
+ await loadConversation(c.conversationId);
1087
+ if (isMobile()) setSidebarOpen(false);
1088
+ };
1089
+
1090
+ elements.list.appendChild(item);
1091
+ }
1092
+ };
1093
+
1094
+ const renderMessages = (messages, isStreaming = false) => {
1095
+ elements.messages.innerHTML = "";
1096
+ if (!messages || !messages.length) {
1097
+ elements.messages.innerHTML = '<div class="empty-state"><div class="assistant-avatar">' + agentInitial + '</div><div>How can I help you today?</div></div>';
1098
+ return;
1099
+ }
1100
+ const col = document.createElement("div");
1101
+ col.className = "messages-column";
1102
+ messages.forEach((m, i) => {
1103
+ const row = document.createElement("div");
1104
+ row.className = "message-row " + m.role;
1105
+ if (m.role === "assistant") {
1106
+ const wrap = document.createElement("div");
1107
+ wrap.className = "assistant-wrap";
1108
+ wrap.innerHTML = '<div class="assistant-avatar">' + agentInitial + '</div>';
1109
+ const content = document.createElement("div");
1110
+ content.className = "assistant-content";
1111
+ const text = String(m.content || "");
1112
+ const parsed = extractToolActivity(text);
1113
+ const metadataToolActivity =
1114
+ m.metadata && Array.isArray(m.metadata.toolActivity)
1115
+ ? m.metadata.toolActivity
1116
+ : [];
1117
+ const toolActivity =
1118
+ Array.isArray(m._toolActivity) && m._toolActivity.length > 0
1119
+ ? m._toolActivity
1120
+ : metadataToolActivity.length > 0
1121
+ ? metadataToolActivity
1122
+ : parsed.activities;
1123
+ if (m._error) {
1124
+ const errorEl = document.createElement("div");
1125
+ errorEl.className = "message-error";
1126
+ errorEl.innerHTML = "<strong>Error</strong><br>" + escapeHtml(m._error);
1127
+ content.appendChild(errorEl);
1128
+ } else if (isStreaming && i === messages.length - 1 && !parsed.content) {
1129
+ const spinner = document.createElement("span");
1130
+ spinner.className = "thinking-indicator";
1131
+ const starFrames = ["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"];
1132
+ let frame = 0;
1133
+ spinner.textContent = starFrames[0];
1134
+ spinner._interval = setInterval(() => { frame = (frame + 1) % starFrames.length; spinner.textContent = starFrames[frame]; }, 70);
1135
+ content.appendChild(spinner);
1136
+ } else {
1137
+ content.innerHTML = renderAssistantMarkdown(parsed.content);
1138
+ }
1139
+ if (toolActivity.length > 0) {
1140
+ content.insertAdjacentHTML("beforeend", renderToolActivity(toolActivity));
1141
+ }
1142
+ wrap.appendChild(content);
1143
+ row.appendChild(wrap);
1144
+ } else {
1145
+ row.innerHTML = '<div class="user-bubble">' + escapeHtml(m.content) + '</div>';
1146
+ }
1147
+ col.appendChild(row);
1148
+ });
1149
+ elements.messages.appendChild(col);
1150
+ elements.messages.scrollTop = elements.messages.scrollHeight;
1151
+ };
1152
+
1153
+ const loadConversations = async () => {
1154
+ const payload = await api("/api/conversations");
1155
+ state.conversations = payload.conversations || [];
1156
+ renderConversationList();
1157
+ };
1158
+
1159
+ const loadConversation = async (conversationId) => {
1160
+ const payload = await api("/api/conversations/" + encodeURIComponent(conversationId));
1161
+ elements.chatTitle.textContent = payload.conversation.title;
1162
+ state.activeMessages = payload.conversation.messages || [];
1163
+ renderMessages(state.activeMessages);
1164
+ elements.prompt.focus();
1165
+ };
1166
+
1167
+ const createConversation = async (title, options = {}) => {
1168
+ const shouldLoadConversation = options.loadConversation !== false;
1169
+ const payload = await api("/api/conversations", {
1170
+ method: "POST",
1171
+ body: JSON.stringify(title ? { title } : {})
1172
+ });
1173
+ state.activeConversationId = payload.conversation.conversationId;
1174
+ state.confirmDeleteId = null;
1175
+ pushConversationUrl(state.activeConversationId);
1176
+ await loadConversations();
1177
+ if (shouldLoadConversation) {
1178
+ await loadConversation(state.activeConversationId);
1179
+ } else {
1180
+ elements.chatTitle.textContent = payload.conversation.title || "New conversation";
1181
+ }
1182
+ return state.activeConversationId;
1183
+ };
1184
+
1185
+ const parseSseChunk = (buffer, onEvent) => {
1186
+ let rest = buffer;
1187
+ while (true) {
1188
+ const index = rest.indexOf("\\n\\n");
1189
+ if (index < 0) {
1190
+ return rest;
1191
+ }
1192
+ const raw = rest.slice(0, index);
1193
+ rest = rest.slice(index + 2);
1194
+ const lines = raw.split("\\n");
1195
+ let eventName = "message";
1196
+ let data = "";
1197
+ for (const line of lines) {
1198
+ if (line.startsWith("event:")) {
1199
+ eventName = line.slice(6).trim();
1200
+ } else if (line.startsWith("data:")) {
1201
+ data += line.slice(5).trim();
1202
+ }
1203
+ }
1204
+ if (data) {
1205
+ try {
1206
+ onEvent(eventName, JSON.parse(data));
1207
+ } catch {}
1208
+ }
1209
+ }
1210
+ };
1211
+
1212
+ const setStreaming = (value) => {
1213
+ state.isStreaming = value;
1214
+ elements.send.disabled = value;
1215
+ };
1216
+
1217
+ const pushToolActivity = (assistantMessage, line) => {
1218
+ if (!line) {
1219
+ return;
1220
+ }
1221
+ if (
1222
+ !assistantMessage.metadata ||
1223
+ !Array.isArray(assistantMessage.metadata.toolActivity)
1224
+ ) {
1225
+ assistantMessage.metadata = {
1226
+ ...(assistantMessage.metadata || {}),
1227
+ toolActivity: [],
1228
+ };
1229
+ }
1230
+ assistantMessage.metadata.toolActivity.push(line);
1231
+ };
1232
+
1233
+ const autoResizePrompt = () => {
1234
+ const el = elements.prompt;
1235
+ el.style.height = "auto";
1236
+ const scrollHeight = el.scrollHeight;
1237
+ const nextHeight = Math.min(scrollHeight, 200);
1238
+ el.style.height = nextHeight + "px";
1239
+ el.style.overflowY = scrollHeight > 200 ? "auto" : "hidden";
1240
+ };
1241
+
1242
+ const sendMessage = async (text) => {
1243
+ const messageText = (text || "").trim();
1244
+ if (!messageText || state.isStreaming) {
1245
+ return;
1246
+ }
1247
+ const localMessages = [...(state.activeMessages || []), { role: "user", content: messageText }];
1248
+ let assistantMessage = { role: "assistant", content: "", metadata: { toolActivity: [] } };
1249
+ localMessages.push(assistantMessage);
1250
+ state.activeMessages = localMessages;
1251
+ renderMessages(localMessages, true);
1252
+ setStreaming(true);
1253
+ let conversationId = state.activeConversationId;
1254
+ try {
1255
+ if (!conversationId) {
1256
+ conversationId = await createConversation(messageText, { loadConversation: false });
1257
+ }
1258
+ const response = await fetch("/api/conversations/" + encodeURIComponent(conversationId) + "/messages", {
1259
+ method: "POST",
1260
+ credentials: "include",
1261
+ headers: { "Content-Type": "application/json", "x-csrf-token": state.csrfToken },
1262
+ body: JSON.stringify({ message: messageText })
1263
+ });
1264
+ if (!response.ok || !response.body) {
1265
+ throw new Error("Failed to stream response");
1266
+ }
1267
+ const reader = response.body.getReader();
1268
+ const decoder = new TextDecoder();
1269
+ let buffer = "";
1270
+ while (true) {
1271
+ const { value, done } = await reader.read();
1272
+ if (done) {
1273
+ break;
1274
+ }
1275
+ buffer += decoder.decode(value, { stream: true });
1276
+ buffer = parseSseChunk(buffer, (eventName, payload) => {
1277
+ if (eventName === "model:chunk") {
1278
+ assistantMessage.content += String(payload.content || "");
1279
+ renderMessages(localMessages, true);
1280
+ }
1281
+ if (eventName === "tool:started") {
1282
+ pushToolActivity(assistantMessage, "start " + (payload.tool || "tool"));
1283
+ renderMessages(localMessages, true);
1284
+ }
1285
+ if (eventName === "tool:completed") {
1286
+ const duration = typeof payload.duration === "number" ? payload.duration : null;
1287
+ pushToolActivity(
1288
+ assistantMessage,
1289
+ "done " +
1290
+ (payload.tool || "tool") +
1291
+ (duration !== null ? " (" + duration + "ms)" : ""),
1292
+ );
1293
+ renderMessages(localMessages, true);
1294
+ }
1295
+ if (eventName === "tool:error") {
1296
+ pushToolActivity(
1297
+ assistantMessage,
1298
+ "error " + (payload.tool || "tool") + ": " + (payload.error || "unknown error"),
1299
+ );
1300
+ renderMessages(localMessages, true);
1301
+ }
1302
+ if (eventName === "tool:approval:required") {
1303
+ pushToolActivity(assistantMessage, "approval required for " + (payload.tool || "tool"));
1304
+ renderMessages(localMessages, true);
1305
+ }
1306
+ if (eventName === "tool:approval:granted") {
1307
+ pushToolActivity(assistantMessage, "approval granted");
1308
+ renderMessages(localMessages, true);
1309
+ }
1310
+ if (eventName === "tool:approval:denied") {
1311
+ pushToolActivity(assistantMessage, "approval denied");
1312
+ renderMessages(localMessages, true);
1313
+ }
1314
+ if (eventName === "run:completed" && (!assistantMessage.content || assistantMessage.content.length === 0)) {
1315
+ assistantMessage.content = String(payload.result?.response || "");
1316
+ renderMessages(localMessages, false);
1317
+ }
1318
+ if (eventName === "run:error") {
1319
+ const errMsg = payload.error?.message || "Something went wrong";
1320
+ assistantMessage.content = "";
1321
+ assistantMessage._error = errMsg;
1322
+ renderMessages(localMessages, false);
1323
+ }
1324
+ });
1325
+ }
1326
+ await loadConversations();
1327
+ await loadConversation(conversationId);
1328
+ } finally {
1329
+ setStreaming(false);
1330
+ elements.prompt.focus();
1331
+ }
1332
+ };
1333
+
1334
+ const requireAuth = async () => {
1335
+ try {
1336
+ const session = await api("/api/auth/session");
1337
+ if (!session.authenticated) {
1338
+ elements.auth.classList.remove("hidden");
1339
+ elements.app.classList.add("hidden");
1340
+ return false;
1341
+ }
1342
+ state.csrfToken = session.csrfToken || "";
1343
+ elements.auth.classList.add("hidden");
1344
+ elements.app.classList.remove("hidden");
1345
+ return true;
1346
+ } catch {
1347
+ elements.auth.classList.remove("hidden");
1348
+ elements.app.classList.add("hidden");
1349
+ return false;
1350
+ }
1351
+ };
1352
+
1353
+ elements.loginForm.addEventListener("submit", async (event) => {
1354
+ event.preventDefault();
1355
+ elements.loginError.textContent = "";
1356
+ try {
1357
+ const result = await api("/api/auth/login", {
1358
+ method: "POST",
1359
+ body: JSON.stringify({ passphrase: elements.passphrase.value || "" })
1360
+ });
1361
+ state.csrfToken = result.csrfToken || "";
1362
+ elements.passphrase.value = "";
1363
+ elements.auth.classList.add("hidden");
1364
+ elements.app.classList.remove("hidden");
1365
+ await loadConversations();
1366
+ const urlConversationId = getConversationIdFromUrl();
1367
+ if (urlConversationId) {
1368
+ state.activeConversationId = urlConversationId;
1369
+ renderConversationList();
1370
+ try {
1371
+ await loadConversation(urlConversationId);
1372
+ } catch {
1373
+ state.activeConversationId = null;
1374
+ state.activeMessages = [];
1375
+ replaceConversationUrl(null);
1376
+ renderMessages([]);
1377
+ renderConversationList();
1378
+ }
1379
+ }
1380
+ } catch (error) {
1381
+ elements.loginError.textContent = error.message || "Login failed";
1382
+ }
1383
+ });
1384
+
1385
+ elements.newChat.addEventListener("click", () => {
1386
+ state.activeConversationId = null;
1387
+ state.activeMessages = [];
1388
+ state.confirmDeleteId = null;
1389
+ pushConversationUrl(null);
1390
+ elements.chatTitle.textContent = "";
1391
+ renderMessages([]);
1392
+ renderConversationList();
1393
+ elements.prompt.focus();
1394
+ if (isMobile()) {
1395
+ setSidebarOpen(false);
1396
+ }
1397
+ });
1398
+
1399
+ elements.prompt.addEventListener("input", () => {
1400
+ autoResizePrompt();
1401
+ });
1402
+
1403
+ elements.prompt.addEventListener("keydown", (event) => {
1404
+ if (event.key === "Enter" && !event.shiftKey) {
1405
+ event.preventDefault();
1406
+ elements.composer.requestSubmit();
1407
+ }
1408
+ });
1409
+
1410
+ elements.sidebarToggle.addEventListener("click", () => {
1411
+ if (isMobile()) setSidebarOpen(!elements.shell.classList.contains("sidebar-open"));
1412
+ });
1413
+
1414
+ elements.sidebarBackdrop.addEventListener("click", () => setSidebarOpen(false));
1415
+
1416
+ elements.logout.addEventListener("click", async () => {
1417
+ await api("/api/auth/logout", { method: "POST" });
1418
+ state.activeConversationId = null;
1419
+ state.activeMessages = [];
1420
+ state.confirmDeleteId = null;
1421
+ state.conversations = [];
1422
+ state.csrfToken = "";
1423
+ await requireAuth();
1424
+ });
1425
+
1426
+ elements.composer.addEventListener("submit", async (event) => {
1427
+ event.preventDefault();
1428
+ const value = elements.prompt.value;
1429
+ elements.prompt.value = "";
1430
+ autoResizePrompt();
1431
+ await sendMessage(value);
1432
+ });
1433
+
1434
+ document.addEventListener("click", (event) => {
1435
+ if (!(event.target instanceof Node)) {
1436
+ return;
1437
+ }
1438
+ if (!event.target.closest(".conversation-item") && state.confirmDeleteId) {
1439
+ state.confirmDeleteId = null;
1440
+ renderConversationList();
1441
+ }
1442
+ });
1443
+
1444
+ window.addEventListener("resize", () => {
1445
+ setSidebarOpen(false);
1446
+ });
1447
+
1448
+ const navigateToConversation = async (conversationId) => {
1449
+ if (conversationId) {
1450
+ state.activeConversationId = conversationId;
1451
+ renderConversationList();
1452
+ try {
1453
+ await loadConversation(conversationId);
1454
+ } catch {
1455
+ // Conversation not found \u2013 fall back to empty state
1456
+ state.activeConversationId = null;
1457
+ state.activeMessages = [];
1458
+ replaceConversationUrl(null);
1459
+ elements.chatTitle.textContent = "";
1460
+ renderMessages([]);
1461
+ renderConversationList();
1462
+ }
1463
+ } else {
1464
+ state.activeConversationId = null;
1465
+ state.activeMessages = [];
1466
+ elements.chatTitle.textContent = "";
1467
+ renderMessages([]);
1468
+ renderConversationList();
1469
+ }
1470
+ };
1471
+
1472
+ window.addEventListener("popstate", async () => {
1473
+ if (state.isStreaming) return;
1474
+ const conversationId = getConversationIdFromUrl();
1475
+ await navigateToConversation(conversationId);
1476
+ });
1477
+
1478
+ (async () => {
1479
+ const authenticated = await requireAuth();
1480
+ if (!authenticated) {
1481
+ return;
1482
+ }
1483
+ await loadConversations();
1484
+ const urlConversationId = getConversationIdFromUrl();
1485
+ if (urlConversationId) {
1486
+ state.activeConversationId = urlConversationId;
1487
+ replaceConversationUrl(urlConversationId);
1488
+ renderConversationList();
1489
+ try {
1490
+ await loadConversation(urlConversationId);
1491
+ } catch {
1492
+ // URL pointed to a conversation that no longer exists
1493
+ state.activeConversationId = null;
1494
+ state.activeMessages = [];
1495
+ replaceConversationUrl(null);
1496
+ elements.chatTitle.textContent = "";
1497
+ renderMessages([]);
1498
+ renderConversationList();
1499
+ if (state.conversations.length === 0) {
1500
+ await createConversation();
1501
+ }
1502
+ }
1503
+ } else if (state.conversations.length === 0) {
1504
+ await createConversation();
1505
+ }
1506
+ autoResizePrompt();
1507
+ elements.prompt.focus();
1508
+ })();
1509
+
1510
+ if ("serviceWorker" in navigator) {
1511
+ navigator.serviceWorker.register("/sw.js").catch(() => {});
1512
+ }
1513
+
1514
+ // iOS keyboard handling: resize shell when keyboard opens
1515
+ // and prevent page scrolling behind the keyboard.
1516
+ (function() {
1517
+ var shell = document.querySelector(".shell");
1518
+ var inputFocused = false;
1519
+
1520
+ const setHeight = () => {
1521
+ if (!shell) return;
1522
+ // When keyboard is open, visualViewport.height shrinks. Use it to resize the shell.
1523
+ if (window.visualViewport && inputFocused) {
1524
+ shell.style.height = window.visualViewport.height + "px";
1525
+ } else {
1526
+ shell.style.height = "";
1527
+ }
1528
+ };
1529
+
1530
+ if (window.visualViewport) {
1531
+ window.visualViewport.addEventListener("resize", setHeight);
1532
+ }
1533
+
1534
+ // Prevent iOS from scrolling the page when the keyboard opens.
1535
+ var pinScroll = function() { if (inputFocused && window.scrollY !== 0) window.scrollTo(0, 0); };
1536
+ document.addEventListener("focusin", function(e) {
1537
+ if (e.target && (e.target.tagName === "TEXTAREA" || e.target.tagName === "INPUT")) {
1538
+ inputFocused = true;
1539
+ setHeight();
1540
+ }
1541
+ });
1542
+ document.addEventListener("focusout", function() {
1543
+ inputFocused = false;
1544
+ setHeight();
1545
+ window.scrollTo(0, 0);
1546
+ });
1547
+ if (window.visualViewport) {
1548
+ window.visualViewport.addEventListener("scroll", pinScroll);
1549
+ window.visualViewport.addEventListener("resize", pinScroll);
1550
+ }
1551
+ document.addEventListener("scroll", pinScroll);
1552
+
1553
+ // Draggable sidebar from left edge (mobile only)
1554
+ (function() {
1555
+ var sidebar = document.querySelector(".sidebar");
1556
+ var backdrop = document.querySelector(".sidebar-backdrop");
1557
+ var shell = document.querySelector(".shell");
1558
+ if (!sidebar || !backdrop || !shell) return;
1559
+
1560
+ var sidebarWidth = 260;
1561
+ var edgeThreshold = 50; // px from left edge to start drag
1562
+ var velocityThreshold = 0.3; // px/ms to trigger open/close
1563
+
1564
+ var dragging = false;
1565
+ var startX = 0;
1566
+ var startY = 0;
1567
+ var currentX = 0;
1568
+ var startTime = 0;
1569
+ var isOpen = false;
1570
+ var directionLocked = false;
1571
+ var isHorizontal = false;
1572
+
1573
+ function getProgress() {
1574
+ // Returns 0 (closed) to 1 (open)
1575
+ if (isOpen) {
1576
+ return Math.max(0, Math.min(1, 1 + currentX / sidebarWidth));
1577
+ } else {
1578
+ return Math.max(0, Math.min(1, currentX / sidebarWidth));
1579
+ }
1580
+ }
1581
+
1582
+ function updatePosition(progress) {
1583
+ var offset = (progress - 1) * sidebarWidth;
1584
+ sidebar.style.transform = "translateX(" + offset + "px)";
1585
+ backdrop.style.opacity = progress;
1586
+ if (progress > 0) {
1587
+ backdrop.style.pointerEvents = "auto";
1588
+ } else {
1589
+ backdrop.style.pointerEvents = "none";
1590
+ }
1591
+ }
1592
+
1593
+ function onTouchStart(e) {
1594
+ if (window.innerWidth > 768) return;
1595
+ var touch = e.touches[0];
1596
+ isOpen = shell.classList.contains("sidebar-open");
1597
+
1598
+ // Allow drag from edge when closed, or anywhere on sidebar/backdrop when open
1599
+ var fromEdge = touch.clientX < edgeThreshold;
1600
+ var onSidebar = sidebar.contains(e.target);
1601
+ var onBackdrop = e.target === backdrop;
1602
+
1603
+ if (!fromEdge && !isOpen) return;
1604
+ if (isOpen && !onSidebar && !onBackdrop) return;
1605
+
1606
+ // Prevent Safari back gesture when starting from edge
1607
+ if (fromEdge) {
1608
+ e.preventDefault();
1609
+ }
1610
+
1611
+ startX = touch.clientX;
1612
+ startY = touch.clientY;
1613
+ currentX = 0;
1614
+ startTime = Date.now();
1615
+ directionLocked = false;
1616
+ isHorizontal = false;
1617
+ dragging = true;
1618
+ sidebar.classList.add("dragging");
1619
+ backdrop.classList.add("dragging");
1620
+ }
1621
+
1622
+ function onTouchMove(e) {
1623
+ if (!dragging) return;
1624
+ var touch = e.touches[0];
1625
+ var dx = touch.clientX - startX;
1626
+ var dy = touch.clientY - startY;
1627
+
1628
+ // Lock direction after some movement
1629
+ if (!directionLocked && (Math.abs(dx) > 10 || Math.abs(dy) > 10)) {
1630
+ directionLocked = true;
1631
+ isHorizontal = Math.abs(dx) > Math.abs(dy);
1632
+ if (!isHorizontal) {
1633
+ // Vertical scroll, cancel drag
1634
+ dragging = false;
1635
+ sidebar.classList.remove("dragging");
1636
+ backdrop.classList.remove("dragging");
1637
+ return;
1638
+ }
1639
+ }
1640
+
1641
+ if (!directionLocked) return;
1642
+
1643
+ // Prevent scrolling while dragging sidebar
1644
+ e.preventDefault();
1645
+
1646
+ currentX = dx;
1647
+ updatePosition(getProgress());
1648
+ }
1649
+
1650
+ function onTouchEnd(e) {
1651
+ if (!dragging) return;
1652
+ dragging = false;
1653
+ sidebar.classList.remove("dragging");
1654
+ backdrop.classList.remove("dragging");
1655
+
1656
+ var touch = e.changedTouches[0];
1657
+ var dx = touch.clientX - startX;
1658
+ var dt = Date.now() - startTime;
1659
+ var velocity = dx / dt; // px/ms
1660
+
1661
+ var progress = getProgress();
1662
+ var shouldOpen;
1663
+
1664
+ // Use velocity if fast enough, otherwise use position threshold
1665
+ if (Math.abs(velocity) > velocityThreshold) {
1666
+ shouldOpen = velocity > 0;
1667
+ } else {
1668
+ shouldOpen = progress > 0.5;
1669
+ }
1670
+
1671
+ // Reset inline styles and let CSS handle the animation
1672
+ sidebar.style.transform = "";
1673
+ backdrop.style.opacity = "";
1674
+ backdrop.style.pointerEvents = "";
1675
+
1676
+ if (shouldOpen) {
1677
+ shell.classList.add("sidebar-open");
1678
+ } else {
1679
+ shell.classList.remove("sidebar-open");
1680
+ }
1681
+ }
1682
+
1683
+ document.addEventListener("touchstart", onTouchStart, { passive: false });
1684
+ document.addEventListener("touchmove", onTouchMove, { passive: false });
1685
+ document.addEventListener("touchend", onTouchEnd, { passive: true });
1686
+ document.addEventListener("touchcancel", onTouchEnd, { passive: true });
1687
+ })();
1688
+
1689
+ // Prevent Safari back/forward navigation by manipulating history
1690
+ // This doesn't stop the gesture animation but prevents actual navigation
1691
+ if (window.navigator.standalone || window.matchMedia("(display-mode: standalone)").matches) {
1692
+ history.pushState(null, "", location.href);
1693
+ window.addEventListener("popstate", function() {
1694
+ history.pushState(null, "", location.href);
1695
+ });
1696
+ }
1697
+
1698
+ // Right edge blocker - intercept touch events to prevent forward navigation
1699
+ var rightBlocker = document.querySelector(".edge-blocker-right");
1700
+ if (rightBlocker) {
1701
+ rightBlocker.addEventListener("touchstart", function(e) {
1702
+ e.preventDefault();
1703
+ }, { passive: false });
1704
+ rightBlocker.addEventListener("touchmove", function(e) {
1705
+ e.preventDefault();
1706
+ }, { passive: false });
1707
+ }
1708
+ })();
1709
+
1710
+ </script>
1711
+ </body>
1712
+ </html>`;
1713
+ };
1714
+
1715
+ // src/init-feature-context.ts
1716
+ import { createHash as createHash2 } from "crypto";
1717
+ import { access, mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
1718
+ import { basename as basename2, dirname as dirname2, resolve as resolve2 } from "path";
1719
+ import { homedir as homedir2 } from "os";
1720
+ var ONBOARDING_VERSION = 1;
1721
+ var getStateDirectory = () => {
1722
+ const cwd = process.cwd();
1723
+ const home = homedir2();
1724
+ const isServerless = process.env.VERCEL === "1" || process.env.VERCEL_ENV !== void 0 || process.env.VERCEL_URL !== void 0 || process.env.AWS_LAMBDA_FUNCTION_NAME !== void 0 || process.env.AWS_EXECUTION_ENV?.includes("AWS_Lambda") === true || process.env.LAMBDA_TASK_ROOT !== void 0 || process.env.NOW_REGION !== void 0 || cwd.startsWith("/var/task") || home.startsWith("/var/task") || process.env.SERVERLESS === "1";
1725
+ if (isServerless) {
1726
+ return "/tmp/.agentl/state";
1727
+ }
1728
+ return resolve2(homedir2(), ".agentl", "state");
1729
+ };
1730
+ var summarizeConfig = (config) => {
1731
+ const provider = config?.storage?.provider ?? config?.state?.provider ?? "local";
1732
+ const memoryEnabled = config?.storage?.memory?.enabled ?? config?.memory?.enabled ?? false;
1733
+ const authRequired = config?.auth?.required ?? false;
1734
+ const telemetryEnabled = config?.telemetry?.enabled ?? true;
1735
+ return [
1736
+ `storage: ${provider}`,
1737
+ `memory tools: ${memoryEnabled ? "enabled" : "disabled"}`,
1738
+ `auth: ${authRequired ? "required" : "not required"}`,
1739
+ `telemetry: ${telemetryEnabled ? "enabled" : "disabled"}`
1740
+ ];
1741
+ };
1742
+ var getOnboardingMarkerPath = (workingDir) => resolve2(
1743
+ getStateDirectory(),
1744
+ `${basename2(workingDir).replace(/[^a-zA-Z0-9_-]+/g, "-") || "project"}-${createHash2("sha256").update(workingDir).digest("hex").slice(0, 12)}-onboarding.json`
1745
+ );
1746
+ var readMarker = async (workingDir) => {
1747
+ const markerPath = getOnboardingMarkerPath(workingDir);
1748
+ try {
1749
+ await access(markerPath);
1750
+ } catch {
1751
+ return void 0;
1752
+ }
1753
+ try {
1754
+ const raw = await readFile2(markerPath, "utf8");
1755
+ return JSON.parse(raw);
1756
+ } catch {
1757
+ return void 0;
1758
+ }
1759
+ };
1760
+ var writeMarker = async (workingDir, state) => {
1761
+ const markerPath = getOnboardingMarkerPath(workingDir);
1762
+ await mkdir2(dirname2(markerPath), { recursive: true });
1763
+ await writeFile2(markerPath, JSON.stringify(state, null, 2), "utf8");
1764
+ };
1765
+ var initializeOnboardingMarker = async (workingDir, options) => {
1766
+ const current = await readMarker(workingDir);
1767
+ if (current) {
1768
+ return;
1769
+ }
1770
+ const allowIntro = options?.allowIntro ?? true;
1771
+ await writeMarker(workingDir, {
1772
+ introduced: allowIntro ? false : true,
1773
+ allowIntro,
1774
+ onboardingVersion: ONBOARDING_VERSION,
1775
+ createdAt: Date.now()
1776
+ });
1777
+ };
1778
+ var consumeFirstRunIntro = async (workingDir, input) => {
1779
+ const runtimeEnv = (process.env.AGENTL_ENV ?? process.env.NODE_ENV ?? "").toLowerCase();
1780
+ if (runtimeEnv === "production") {
1781
+ return void 0;
1782
+ }
1783
+ const marker = await readMarker(workingDir);
1784
+ if (marker?.allowIntro === false) {
1785
+ return void 0;
1786
+ }
1787
+ const shouldShow = !marker || marker.introduced === false;
1788
+ if (!shouldShow) {
1789
+ return void 0;
1790
+ }
1791
+ await writeMarker(workingDir, {
1792
+ introduced: true,
1793
+ allowIntro: true,
1794
+ onboardingVersion: ONBOARDING_VERSION,
1795
+ createdAt: marker?.createdAt ?? Date.now(),
1796
+ introducedAt: Date.now()
1797
+ });
1798
+ const summary = summarizeConfig(input.config);
1799
+ return [
1800
+ `Hi! I'm **${input.agentName}**. I can configure myself directly by chat.
1801
+ `,
1802
+ `**Current config**`,
1803
+ ` Model: ${input.provider}/${input.model}`,
1804
+ ` \`\`\`${summary.join(" \xB7 ")}\`\`\``,
1805
+ "",
1806
+ "Feel free to ask me anything when you're ready. I can help you:",
1807
+ "",
1808
+ "- **Build skills**: Create custom tools and capabilities for this agent",
1809
+ "- **Configure the model**: Switch providers (OpenAI, Anthropic, etc.) or models",
1810
+ "- **Set up storage**: Use local files, Upstash, or other backends",
1811
+ "- **Enable auth**: Add bearer tokens or custom authentication",
1812
+ "- **Turn on telemetry**: Track usage with OpenTelemetry/OTLP",
1813
+ "- **Add MCP servers**: Connect external tool servers",
1814
+ "",
1815
+ "Just let me know what you'd like to work on!\n"
1816
+ ].join("\n");
1817
+ };
1818
+
1819
+ export {
1820
+ SessionStore,
1821
+ LoginRateLimiter,
1822
+ parseCookies,
1823
+ setCookie,
1824
+ verifyPassphrase,
1825
+ getRequestIp,
1826
+ inferConversationTitle,
1827
+ renderManifest,
1828
+ renderIconSvg,
1829
+ renderServiceWorker,
1830
+ renderWebUiHtml,
1831
+ initializeOnboardingMarker,
1832
+ consumeFirstRunIntro
1833
+ };