@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,1818 @@
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%; height: -webkit-fill-available; 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
+ /* Fallbacks for iOS PWA */
322
+ height: 100vh;
323
+ height: 100dvh;
324
+ height: -webkit-fill-available;
325
+ display: flex;
326
+ overflow: hidden;
327
+ }
328
+ @supports (-webkit-touch-callout: none) {
329
+ /* iOS specific: ensure shell fills the viewport */
330
+ .shell {
331
+ min-height: -webkit-fill-available;
332
+ }
333
+ }
334
+
335
+ /* Edge swipe blocker - invisible touch target to intercept right edge gestures */
336
+ .edge-blocker-right {
337
+ position: fixed;
338
+ top: 0;
339
+ bottom: 0;
340
+ right: 0;
341
+ width: 20px;
342
+ z-index: 9999;
343
+ touch-action: none;
344
+ }
345
+ .sidebar {
346
+ width: 260px;
347
+ background: #000;
348
+ border-right: 1px solid rgba(255,255,255,0.06);
349
+ display: flex;
350
+ flex-direction: column;
351
+ padding: 12px 8px;
352
+ }
353
+ .new-chat-btn {
354
+ background: transparent;
355
+ border: 0;
356
+ color: #888;
357
+ border-radius: 12px;
358
+ height: 36px;
359
+ padding: 0 10px;
360
+ display: flex;
361
+ align-items: center;
362
+ gap: 8px;
363
+ font-size: 13px;
364
+ cursor: pointer;
365
+ transition: background 0.15s, color 0.15s;
366
+ }
367
+ .new-chat-btn:hover { color: #ededed; }
368
+ .new-chat-btn svg { width: 16px; height: 16px; }
369
+ .conversation-list {
370
+ flex: 1;
371
+ overflow-y: auto;
372
+ margin-top: 12px;
373
+ display: flex;
374
+ flex-direction: column;
375
+ gap: 2px;
376
+ }
377
+ .conversation-item {
378
+ padding: 7px 28px 7px 10px;
379
+ border-radius: 12px;
380
+ cursor: pointer;
381
+ font-size: 13px;
382
+ color: #555;
383
+ white-space: nowrap;
384
+ overflow: hidden;
385
+ text-overflow: ellipsis;
386
+ position: relative;
387
+ transition: color 0.15s;
388
+ }
389
+ .conversation-item:hover { color: #999; }
390
+ .conversation-item.active {
391
+ color: #ededed;
392
+ }
393
+ .conversation-item .delete-btn {
394
+ position: absolute;
395
+ right: 0;
396
+ top: 0;
397
+ bottom: 0;
398
+ opacity: 0;
399
+ background: #000;
400
+ border: 0;
401
+ color: #444;
402
+ padding: 0 8px;
403
+ border-radius: 0 4px 4px 0;
404
+ cursor: pointer;
405
+ font-size: 16px;
406
+ line-height: 1;
407
+ display: grid;
408
+ place-items: center;
409
+ transition: opacity 0.15s, color 0.15s;
410
+ }
411
+ .conversation-item:hover .delete-btn { opacity: 1; }
412
+ .conversation-item.active .delete-btn { background: rgba(0,0,0,1); }
413
+ .conversation-item .delete-btn::before {
414
+ content: "";
415
+ position: absolute;
416
+ right: 100%;
417
+ top: 0;
418
+ bottom: 0;
419
+ width: 24px;
420
+ background: linear-gradient(to right, transparent, #000);
421
+ pointer-events: none;
422
+ }
423
+ .conversation-item.active .delete-btn::before {
424
+ background: linear-gradient(to right, transparent, rgba(0,0,0,1));
425
+ }
426
+ .conversation-item .delete-btn:hover { color: #888; }
427
+ .conversation-item .delete-btn.confirming {
428
+ opacity: 1;
429
+ width: auto;
430
+ padding: 0 8px;
431
+ font-size: 11px;
432
+ color: #ff4444;
433
+ border-radius: 3px;
434
+ }
435
+ .conversation-item .delete-btn.confirming:hover {
436
+ color: #ff6666;
437
+ }
438
+ .sidebar-footer {
439
+ margin-top: auto;
440
+ padding-top: 8px;
441
+ }
442
+ .logout-btn {
443
+ background: transparent;
444
+ border: 0;
445
+ color: #555;
446
+ width: 100%;
447
+ padding: 8px 10px;
448
+ text-align: left;
449
+ border-radius: 6px;
450
+ cursor: pointer;
451
+ font-size: 13px;
452
+ transition: color 0.15s, background 0.15s;
453
+ }
454
+ .logout-btn:hover { color: #888; }
455
+
456
+ /* Main */
457
+ .main { flex: 1; display: flex; flex-direction: column; min-width: 0; max-width: 100%; background: #000; overflow: hidden; }
458
+ .topbar {
459
+ height: calc(52px + env(safe-area-inset-top, 0px));
460
+ padding-top: env(safe-area-inset-top, 0px);
461
+ display: flex;
462
+ align-items: center;
463
+ justify-content: center;
464
+ font-size: 13px;
465
+ font-weight: 500;
466
+ color: #888;
467
+ border-bottom: 1px solid rgba(255,255,255,0.06);
468
+ position: relative;
469
+ flex-shrink: 0;
470
+ }
471
+ .topbar-title {
472
+ max-width: calc(100% - 100px);
473
+ overflow: hidden;
474
+ text-overflow: ellipsis;
475
+ white-space: nowrap;
476
+ letter-spacing: -0.01em;
477
+ padding: 0 50px;
478
+ }
479
+ .sidebar-toggle {
480
+ display: none;
481
+ position: absolute;
482
+ left: 12px;
483
+ bottom: 4px; /* Position from bottom of topbar content area */
484
+ background: transparent;
485
+ border: 0;
486
+ color: #666;
487
+ width: 44px;
488
+ height: 44px;
489
+ border-radius: 6px;
490
+ cursor: pointer;
491
+ transition: color 0.15s, background 0.15s;
492
+ font-size: 18px;
493
+ z-index: 10;
494
+ -webkit-tap-highlight-color: transparent;
495
+ }
496
+ .sidebar-toggle:hover { color: #ededed; }
497
+
498
+ /* Messages */
499
+ .messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 24px 24px; }
500
+ .messages-column { max-width: 680px; margin: 0 auto; }
501
+ .message-row { margin-bottom: 24px; display: flex; max-width: 100%; }
502
+ .message-row.user { justify-content: flex-end; }
503
+ .assistant-wrap { display: flex; gap: 12px; max-width: 100%; min-width: 0; }
504
+ .assistant-avatar {
505
+ width: 24px;
506
+ height: 24px;
507
+ background: #ededed;
508
+ color: #000;
509
+ border-radius: 6px;
510
+ display: grid;
511
+ place-items: center;
512
+ font-size: 11px;
513
+ font-weight: 600;
514
+ flex-shrink: 0;
515
+ margin-top: 2px;
516
+ }
517
+ .assistant-content {
518
+ line-height: 1.65;
519
+ color: #ededed;
520
+ font-size: 14px;
521
+ min-width: 0;
522
+ max-width: 100%;
523
+ overflow-wrap: break-word;
524
+ word-break: break-word;
525
+ margin-top: 2px;
526
+ }
527
+ .assistant-content p { margin: 0 0 12px; }
528
+ .assistant-content p:last-child { margin-bottom: 0; }
529
+ .assistant-content ul, .assistant-content ol { margin: 8px 0; padding-left: 20px; }
530
+ .assistant-content li { margin: 4px 0; }
531
+ .assistant-content strong { font-weight: 600; color: #fff; }
532
+ .assistant-content h2 {
533
+ font-size: 16px;
534
+ font-weight: 600;
535
+ letter-spacing: -0.02em;
536
+ margin: 20px 0 8px;
537
+ color: #fff;
538
+ }
539
+ .assistant-content h3 {
540
+ font-size: 14px;
541
+ font-weight: 600;
542
+ letter-spacing: -0.01em;
543
+ margin: 16px 0 6px;
544
+ color: #fff;
545
+ }
546
+ .assistant-content code {
547
+ background: rgba(255,255,255,0.06);
548
+ border: 1px solid rgba(255,255,255,0.06);
549
+ padding: 2px 5px;
550
+ border-radius: 4px;
551
+ font-family: ui-monospace, "SF Mono", "Fira Code", monospace;
552
+ font-size: 0.88em;
553
+ }
554
+ .assistant-content pre {
555
+ background: #0a0a0a;
556
+ border: 1px solid rgba(255,255,255,0.06);
557
+ padding: 14px 16px;
558
+ border-radius: 8px;
559
+ overflow-x: auto;
560
+ margin: 14px 0;
561
+ }
562
+ .assistant-content pre code {
563
+ background: none;
564
+ border: 0;
565
+ padding: 0;
566
+ font-size: 13px;
567
+ line-height: 1.5;
568
+ }
569
+ .tool-activity {
570
+ margin-top: 12px;
571
+ border: 1px solid rgba(255,255,255,0.08);
572
+ background: rgba(255,255,255,0.03);
573
+ border-radius: 10px;
574
+ font-size: 12px;
575
+ line-height: 1.45;
576
+ color: #bcbcbc;
577
+ max-width: 300px;
578
+ }
579
+ .tool-activity-disclosure {
580
+ display: block;
581
+ }
582
+ .tool-activity-summary {
583
+ list-style: none;
584
+ display: flex;
585
+ align-items: center;
586
+ gap: 8px;
587
+ cursor: pointer;
588
+ padding: 10px 12px;
589
+ user-select: none;
590
+ }
591
+ .tool-activity-summary::-webkit-details-marker {
592
+ display: none;
593
+ }
594
+ .tool-activity-label {
595
+ font-size: 11px;
596
+ text-transform: uppercase;
597
+ letter-spacing: 0.06em;
598
+ color: #8a8a8a;
599
+ font-weight: 600;
600
+ }
601
+ .tool-activity-caret {
602
+ margin-left: auto;
603
+ color: #8a8a8a;
604
+ display: inline-flex;
605
+ align-items: center;
606
+ justify-content: center;
607
+ transition: transform 120ms ease;
608
+ transform: rotate(0deg);
609
+ }
610
+ .tool-activity-caret svg {
611
+ width: 14px;
612
+ height: 14px;
613
+ display: block;
614
+ }
615
+ .tool-activity-disclosure[open] .tool-activity-caret {
616
+ transform: rotate(90deg);
617
+ }
618
+ .tool-activity-list {
619
+ display: grid;
620
+ gap: 6px;
621
+ padding: 0 12px 10px;
622
+ }
623
+ .tool-activity-item {
624
+ font-family: ui-monospace, "SF Mono", "Fira Code", monospace;
625
+ background: rgba(255,255,255,0.04);
626
+ border-radius: 6px;
627
+ padding: 4px 7px;
628
+ color: #d6d6d6;
629
+ }
630
+ .user-bubble {
631
+ background: #111;
632
+ border: 1px solid rgba(255,255,255,0.08);
633
+ padding: 10px 16px;
634
+ border-radius: 18px;
635
+ max-width: 70%;
636
+ font-size: 14px;
637
+ line-height: 1.5;
638
+ overflow-wrap: break-word;
639
+ word-break: break-word;
640
+ }
641
+ .empty-state {
642
+ display: flex;
643
+ flex-direction: column;
644
+ align-items: center;
645
+ justify-content: center;
646
+ height: 100%;
647
+ gap: 16px;
648
+ color: #555;
649
+ }
650
+ .empty-state .assistant-avatar {
651
+ width: 36px;
652
+ height: 36px;
653
+ font-size: 14px;
654
+ border-radius: 8px;
655
+ }
656
+ .empty-state-text {
657
+ font-size: 14px;
658
+ color: #555;
659
+ }
660
+ .thinking-indicator {
661
+ display: inline-block;
662
+ font-family: Inconsolata, monospace;
663
+ font-size: 20px;
664
+ line-height: 1;
665
+ vertical-align: middle;
666
+ color: #ededed;
667
+ opacity: 0.5;
668
+ }
669
+
670
+ /* Composer */
671
+ .composer {
672
+ padding: 12px 24px 24px;
673
+ position: relative;
674
+ }
675
+ .composer::before {
676
+ content: "";
677
+ position: absolute;
678
+ left: 0;
679
+ right: 0;
680
+ bottom: 100%;
681
+ height: 48px;
682
+ background: linear-gradient(to top, #000 0%, transparent 100%);
683
+ pointer-events: none;
684
+ }
685
+ .composer-inner { max-width: 680px; margin: 0 auto; }
686
+ .composer-shell {
687
+ background: #0a0a0a;
688
+ border: 1px solid rgba(255,255,255,0.1);
689
+ border-radius: 9999px;
690
+ display: flex;
691
+ align-items: center;
692
+ padding: 4px 6px 4px 18px;
693
+ transition: border-color 0.15s;
694
+ }
695
+ .composer-shell:focus-within { border-color: rgba(255,255,255,0.2); }
696
+ .composer-input {
697
+ flex: 1;
698
+ background: transparent;
699
+ border: 0;
700
+ outline: none;
701
+ color: #ededed;
702
+ min-height: 40px;
703
+ max-height: 200px;
704
+ resize: none;
705
+ padding: 10px 0 8px;
706
+ font-size: 14px;
707
+ line-height: 1.5;
708
+ }
709
+ .composer-input::placeholder { color: #444; }
710
+ .send-btn {
711
+ width: 32px;
712
+ height: 32px;
713
+ background: #ededed;
714
+ border: 0;
715
+ border-radius: 50%;
716
+ color: #000;
717
+ cursor: pointer;
718
+ display: grid;
719
+ place-items: center;
720
+ flex-shrink: 0;
721
+ margin-bottom: 2px;
722
+ transition: background 0.15s, opacity 0.15s;
723
+ }
724
+ .send-btn:hover { background: #fff; }
725
+ .send-btn:disabled { opacity: 0.2; cursor: default; }
726
+ .send-btn:disabled:hover { background: #ededed; }
727
+ .disclaimer {
728
+ text-align: center;
729
+ color: #333;
730
+ font-size: 12px;
731
+ margin-top: 10px;
732
+ }
733
+
734
+ /* Scrollbar */
735
+ ::-webkit-scrollbar { width: 6px; }
736
+ ::-webkit-scrollbar-track { background: transparent; }
737
+ ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
738
+ ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }
739
+
740
+ /* Mobile */
741
+ @media (max-width: 768px) {
742
+ .sidebar {
743
+ position: fixed;
744
+ inset: 0 auto 0 0;
745
+ z-index: 100;
746
+ transform: translateX(-100%);
747
+ padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
748
+ will-change: transform;
749
+ }
750
+ .sidebar.dragging { transition: none; }
751
+ .sidebar:not(.dragging) { transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
752
+ .shell.sidebar-open .sidebar { transform: translateX(0); }
753
+ .sidebar-toggle { display: grid; place-items: center; }
754
+ .sidebar-backdrop {
755
+ position: fixed;
756
+ inset: 0;
757
+ background: rgba(0,0,0,0.6);
758
+ z-index: 50;
759
+ backdrop-filter: blur(2px);
760
+ -webkit-backdrop-filter: blur(2px);
761
+ opacity: 0;
762
+ pointer-events: none;
763
+ will-change: opacity;
764
+ }
765
+ .sidebar-backdrop:not(.dragging) { transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
766
+ .sidebar-backdrop.dragging { transition: none; }
767
+ .shell.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
768
+ .messages { padding: 16px; }
769
+ .composer { padding: 8px 16px 16px; }
770
+ }
771
+
772
+ /* Reduced motion */
773
+ @media (prefers-reduced-motion: reduce) {
774
+ *, *::before, *::after {
775
+ animation-duration: 0.01ms !important;
776
+ transition-duration: 0.01ms !important;
777
+ }
778
+ }
779
+ </style>
780
+ </head>
781
+ <body data-agent-initial="${agentInitial}" data-agent-name="${agentName}">
782
+ <div class="edge-blocker-right"></div>
783
+ <div id="auth" class="auth hidden">
784
+ <form id="login-form" class="auth-card">
785
+ <div class="auth-brand">
786
+ <svg viewBox="0 0 24 24" fill="none"><path d="M12 2L2 19.5h20L12 2z" fill="currentColor"/></svg>
787
+ <h2 class="auth-title">AgentL</h2>
788
+ </div>
789
+ <p class="auth-text">Enter the passphrase to continue.</p>
790
+ <input id="passphrase" class="auth-input" type="password" placeholder="Passphrase" required>
791
+ <button class="auth-submit" type="submit">Continue</button>
792
+ <div id="login-error" class="error"></div>
793
+ </form>
794
+ </div>
795
+
796
+ <div id="app" class="shell hidden">
797
+ <aside class="sidebar">
798
+ <button id="new-chat" class="new-chat-btn">
799
+ <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>
800
+ </button>
801
+ <div id="conversation-list" class="conversation-list"></div>
802
+ <div class="sidebar-footer">
803
+ <button id="logout" class="logout-btn">Log out</button>
804
+ </div>
805
+ </aside>
806
+ <div id="sidebar-backdrop" class="sidebar-backdrop"></div>
807
+ <main class="main">
808
+ <div class="topbar">
809
+ <button id="sidebar-toggle" class="sidebar-toggle">&#9776;</button>
810
+ <div id="chat-title" class="topbar-title"></div>
811
+ </div>
812
+ <div id="messages" class="messages">
813
+ <div class="empty-state">
814
+ <div class="assistant-avatar">${agentInitial}</div>
815
+ <div class="empty-state-text">How can I help you today?</div>
816
+ </div>
817
+ </div>
818
+ <form id="composer" class="composer">
819
+ <div class="composer-inner">
820
+ <div class="composer-shell">
821
+ <textarea id="prompt" class="composer-input" placeholder="Send a message..." rows="1"></textarea>
822
+ <button id="send" class="send-btn" type="submit">
823
+ <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>
824
+ </button>
825
+ </div>
826
+ </div>
827
+ </form>
828
+ </main>
829
+ </div>
830
+
831
+ <script>
832
+ const state = {
833
+ csrfToken: "",
834
+ conversations: [],
835
+ activeConversationId: null,
836
+ activeMessages: [],
837
+ isStreaming: false,
838
+ confirmDeleteId: null
839
+ };
840
+
841
+ const agentInitial = document.body.dataset.agentInitial || "A";
842
+ const $ = (id) => document.getElementById(id);
843
+ const elements = {
844
+ auth: $("auth"),
845
+ app: $("app"),
846
+ loginForm: $("login-form"),
847
+ passphrase: $("passphrase"),
848
+ loginError: $("login-error"),
849
+ list: $("conversation-list"),
850
+ newChat: $("new-chat"),
851
+ messages: $("messages"),
852
+ chatTitle: $("chat-title"),
853
+ logout: $("logout"),
854
+ composer: $("composer"),
855
+ prompt: $("prompt"),
856
+ send: $("send"),
857
+ shell: $("app"),
858
+ sidebarToggle: $("sidebar-toggle"),
859
+ sidebarBackdrop: $("sidebar-backdrop")
860
+ };
861
+
862
+ const pushConversationUrl = (conversationId) => {
863
+ const target = conversationId ? "/c/" + encodeURIComponent(conversationId) : "/";
864
+ if (window.location.pathname !== target) {
865
+ history.pushState({ conversationId: conversationId || null }, "", target);
866
+ }
867
+ };
868
+
869
+ const replaceConversationUrl = (conversationId) => {
870
+ const target = conversationId ? "/c/" + encodeURIComponent(conversationId) : "/";
871
+ if (window.location.pathname !== target) {
872
+ history.replaceState({ conversationId: conversationId || null }, "", target);
873
+ }
874
+ };
875
+
876
+ const getConversationIdFromUrl = () => {
877
+ const match = window.location.pathname.match(/^\\/c\\/([^\\/]+)/);
878
+ return match ? decodeURIComponent(match[1]) : null;
879
+ };
880
+
881
+ const mutatingMethods = new Set(["POST", "PATCH", "PUT", "DELETE"]);
882
+
883
+ const api = async (path, options = {}) => {
884
+ const method = (options.method || "GET").toUpperCase();
885
+ const headers = { ...(options.headers || {}) };
886
+ if (mutatingMethods.has(method) && state.csrfToken) {
887
+ headers["x-csrf-token"] = state.csrfToken;
888
+ }
889
+ if (options.body && !headers["Content-Type"]) {
890
+ headers["Content-Type"] = "application/json";
891
+ }
892
+ const response = await fetch(path, { credentials: "include", ...options, method, headers });
893
+ if (!response.ok) {
894
+ let payload = {};
895
+ try { payload = await response.json(); } catch {}
896
+ const error = new Error(payload.message || ("Request failed: " + response.status));
897
+ error.status = response.status;
898
+ error.payload = payload;
899
+ throw error;
900
+ }
901
+ const contentType = response.headers.get("content-type") || "";
902
+ if (contentType.includes("application/json")) {
903
+ return await response.json();
904
+ }
905
+ return await response.text();
906
+ };
907
+
908
+ const escapeHtml = (value) =>
909
+ String(value || "")
910
+ .replace(/&/g, "&amp;")
911
+ .replace(/</g, "&lt;")
912
+ .replace(/>/g, "&gt;")
913
+ .replace(/"/g, "&quot;")
914
+ .replace(/'/g, "&#39;");
915
+
916
+ const renderInlineMarkdown = (value) => {
917
+ let html = escapeHtml(value);
918
+ html = html.replace(/\\*\\*([^*]+)\\*\\*/g, "<strong>$1</strong>");
919
+ html = html.replace(/\\x60([^\\x60]+)\\x60/g, "<code>$1</code>");
920
+ return html;
921
+ };
922
+
923
+ const renderMarkdownBlock = (value) => {
924
+ const lines = String(value || "").split("\\n");
925
+ let html = "";
926
+ let inList = false;
927
+
928
+ for (const rawLine of lines) {
929
+ const line = rawLine.trimEnd();
930
+ const trimmed = line.trim();
931
+ const headingMatch = trimmed.match(/^(#{1,3})\\s+(.+)$/);
932
+
933
+ if (headingMatch) {
934
+ if (inList) {
935
+ html += "</ul>";
936
+ inList = false;
937
+ }
938
+ const level = Math.min(3, headingMatch[1].length);
939
+ const tag = level === 1 ? "h2" : level === 2 ? "h3" : "p";
940
+ html += "<" + tag + ">" + renderInlineMarkdown(headingMatch[2]) + "</" + tag + ">";
941
+ continue;
942
+ }
943
+
944
+ if (/^\\s*-\\s+/.test(line)) {
945
+ if (!inList) {
946
+ html += "<ul>";
947
+ inList = true;
948
+ }
949
+ html += "<li>" + renderInlineMarkdown(line.replace(/^\\s*-\\s+/, "")) + "</li>";
950
+ continue;
951
+ }
952
+ if (inList) {
953
+ html += "</ul>";
954
+ inList = false;
955
+ }
956
+ if (trimmed.length === 0) {
957
+ continue;
958
+ }
959
+ html += "<p>" + renderInlineMarkdown(line) + "</p>";
960
+ }
961
+
962
+ if (inList) {
963
+ html += "</ul>";
964
+ }
965
+ return html;
966
+ };
967
+
968
+ const renderAssistantMarkdown = (value) => {
969
+ const source = String(value || "");
970
+ const fenceRegex = /\\x60\\x60\\x60([\\s\\S]*?)\\x60\\x60\\x60/g;
971
+ let html = "";
972
+ let lastIndex = 0;
973
+ let match;
974
+
975
+ while ((match = fenceRegex.exec(source))) {
976
+ const before = source.slice(lastIndex, match.index);
977
+ html += renderMarkdownBlock(before);
978
+ const codeText = String(match[1] || "").replace(/^\\n+|\\n+$/g, "");
979
+ html += "<pre><code>" + escapeHtml(codeText) + "</code></pre>";
980
+ lastIndex = match.index + match[0].length;
981
+ }
982
+
983
+ html += renderMarkdownBlock(source.slice(lastIndex));
984
+ return html || "<p></p>";
985
+ };
986
+
987
+ const extractToolActivity = (value) => {
988
+ const source = String(value || "");
989
+ let markerIndex = source.lastIndexOf("\\n### Tool activity\\n");
990
+ if (markerIndex < 0 && source.startsWith("### Tool activity\\n")) {
991
+ markerIndex = 0;
992
+ }
993
+ if (markerIndex < 0) {
994
+ return { content: source, activities: [] };
995
+ }
996
+ const content = markerIndex === 0 ? "" : source.slice(0, markerIndex).trimEnd();
997
+ const rawSection = markerIndex === 0 ? source : source.slice(markerIndex + 1);
998
+ const afterHeading = rawSection.replace(/^### Tool activity\\s*\\n?/, "");
999
+ const activities = afterHeading
1000
+ .split("\\n")
1001
+ .map((line) => line.trim())
1002
+ .filter((line) => line.startsWith("- "))
1003
+ .map((line) => line.slice(2).trim())
1004
+ .filter(Boolean);
1005
+ return { content, activities };
1006
+ };
1007
+
1008
+ const renderToolActivity = (items) => {
1009
+ if (!items || !items.length) {
1010
+ return "";
1011
+ }
1012
+ const chips = items
1013
+ .map((item) => '<div class="tool-activity-item">' + escapeHtml(item) + "</div>")
1014
+ .join("");
1015
+ return (
1016
+ '<div class="tool-activity">' +
1017
+ '<details class="tool-activity-disclosure">' +
1018
+ '<summary class="tool-activity-summary">' +
1019
+ '<span class="tool-activity-label">Tool activity</span>' +
1020
+ '<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>' +
1021
+ "</summary>" +
1022
+ '<div class="tool-activity-list">' +
1023
+ chips +
1024
+ "</div>" +
1025
+ "</details>" +
1026
+ "</div>"
1027
+ );
1028
+ };
1029
+
1030
+ const formatDate = (epoch) => {
1031
+ try {
1032
+ const date = new Date(epoch);
1033
+ const now = new Date();
1034
+ const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
1035
+ const startOfDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
1036
+ const dayDiff = Math.floor((startOfToday - startOfDate) / 86400000);
1037
+ if (dayDiff === 0) {
1038
+ return "Today";
1039
+ }
1040
+ if (dayDiff === 1) {
1041
+ return "Yesterday";
1042
+ }
1043
+ if (dayDiff < 7 && dayDiff > 1) {
1044
+ return date.toLocaleDateString(undefined, { weekday: "short" });
1045
+ }
1046
+ return date.toLocaleDateString(undefined, { month: "short", day: "numeric" });
1047
+ } catch {
1048
+ return "";
1049
+ }
1050
+ };
1051
+
1052
+ const isMobile = () => window.matchMedia("(max-width: 900px)").matches;
1053
+
1054
+ const setSidebarOpen = (open) => {
1055
+ if (!isMobile()) {
1056
+ elements.shell.classList.remove("sidebar-open");
1057
+ return;
1058
+ }
1059
+ elements.shell.classList.toggle("sidebar-open", open);
1060
+ };
1061
+
1062
+ const renderConversationList = () => {
1063
+ elements.list.innerHTML = "";
1064
+ for (const c of state.conversations) {
1065
+ const item = document.createElement("div");
1066
+ item.className = "conversation-item" + (c.conversationId === state.activeConversationId ? " active" : "");
1067
+ item.textContent = c.title;
1068
+
1069
+ const isConfirming = state.confirmDeleteId === c.conversationId;
1070
+ const deleteBtn = document.createElement("button");
1071
+ deleteBtn.className = "delete-btn" + (isConfirming ? " confirming" : "");
1072
+ deleteBtn.textContent = isConfirming ? "sure?" : "\\u00d7";
1073
+ deleteBtn.onclick = async (e) => {
1074
+ e.stopPropagation();
1075
+ if (!isConfirming) {
1076
+ state.confirmDeleteId = c.conversationId;
1077
+ renderConversationList();
1078
+ return;
1079
+ }
1080
+ await api("/api/conversations/" + c.conversationId, { method: "DELETE" });
1081
+ if (state.activeConversationId === c.conversationId) {
1082
+ state.activeConversationId = null;
1083
+ state.activeMessages = [];
1084
+ pushConversationUrl(null);
1085
+ elements.chatTitle.textContent = "";
1086
+ renderMessages([]);
1087
+ }
1088
+ state.confirmDeleteId = null;
1089
+ await loadConversations();
1090
+ };
1091
+ item.appendChild(deleteBtn);
1092
+
1093
+ item.onclick = async () => {
1094
+ if (state.confirmDeleteId) {
1095
+ state.confirmDeleteId = null;
1096
+ renderConversationList();
1097
+ return;
1098
+ }
1099
+ state.activeConversationId = c.conversationId;
1100
+ pushConversationUrl(c.conversationId);
1101
+ renderConversationList();
1102
+ await loadConversation(c.conversationId);
1103
+ if (isMobile()) setSidebarOpen(false);
1104
+ };
1105
+
1106
+ elements.list.appendChild(item);
1107
+ }
1108
+ };
1109
+
1110
+ const renderMessages = (messages, isStreaming = false) => {
1111
+ elements.messages.innerHTML = "";
1112
+ if (!messages || !messages.length) {
1113
+ elements.messages.innerHTML = '<div class="empty-state"><div class="assistant-avatar">' + agentInitial + '</div><div>How can I help you today?</div></div>';
1114
+ return;
1115
+ }
1116
+ const col = document.createElement("div");
1117
+ col.className = "messages-column";
1118
+ messages.forEach((m, i) => {
1119
+ const row = document.createElement("div");
1120
+ row.className = "message-row " + m.role;
1121
+ if (m.role === "assistant") {
1122
+ const wrap = document.createElement("div");
1123
+ wrap.className = "assistant-wrap";
1124
+ wrap.innerHTML = '<div class="assistant-avatar">' + agentInitial + '</div>';
1125
+ const content = document.createElement("div");
1126
+ content.className = "assistant-content";
1127
+ const text = String(m.content || "");
1128
+ const parsed = extractToolActivity(text);
1129
+ const metadataToolActivity =
1130
+ m.metadata && Array.isArray(m.metadata.toolActivity)
1131
+ ? m.metadata.toolActivity
1132
+ : [];
1133
+ const toolActivity =
1134
+ Array.isArray(m._toolActivity) && m._toolActivity.length > 0
1135
+ ? m._toolActivity
1136
+ : metadataToolActivity.length > 0
1137
+ ? metadataToolActivity
1138
+ : parsed.activities;
1139
+ if (m._error) {
1140
+ const errorEl = document.createElement("div");
1141
+ errorEl.className = "message-error";
1142
+ errorEl.innerHTML = "<strong>Error</strong><br>" + escapeHtml(m._error);
1143
+ content.appendChild(errorEl);
1144
+ } else if (isStreaming && i === messages.length - 1 && !parsed.content) {
1145
+ const spinner = document.createElement("span");
1146
+ spinner.className = "thinking-indicator";
1147
+ const starFrames = ["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"];
1148
+ let frame = 0;
1149
+ spinner.textContent = starFrames[0];
1150
+ spinner._interval = setInterval(() => { frame = (frame + 1) % starFrames.length; spinner.textContent = starFrames[frame]; }, 70);
1151
+ content.appendChild(spinner);
1152
+ } else {
1153
+ content.innerHTML = renderAssistantMarkdown(parsed.content);
1154
+ }
1155
+ if (toolActivity.length > 0) {
1156
+ content.insertAdjacentHTML("beforeend", renderToolActivity(toolActivity));
1157
+ }
1158
+ wrap.appendChild(content);
1159
+ row.appendChild(wrap);
1160
+ } else {
1161
+ row.innerHTML = '<div class="user-bubble">' + escapeHtml(m.content) + '</div>';
1162
+ }
1163
+ col.appendChild(row);
1164
+ });
1165
+ elements.messages.appendChild(col);
1166
+ elements.messages.scrollTop = elements.messages.scrollHeight;
1167
+ };
1168
+
1169
+ const loadConversations = async () => {
1170
+ const payload = await api("/api/conversations");
1171
+ state.conversations = payload.conversations || [];
1172
+ renderConversationList();
1173
+ };
1174
+
1175
+ const loadConversation = async (conversationId) => {
1176
+ const payload = await api("/api/conversations/" + encodeURIComponent(conversationId));
1177
+ elements.chatTitle.textContent = payload.conversation.title;
1178
+ state.activeMessages = payload.conversation.messages || [];
1179
+ renderMessages(state.activeMessages);
1180
+ elements.prompt.focus();
1181
+ };
1182
+
1183
+ const createConversation = async (title, options = {}) => {
1184
+ const shouldLoadConversation = options.loadConversation !== false;
1185
+ const payload = await api("/api/conversations", {
1186
+ method: "POST",
1187
+ body: JSON.stringify(title ? { title } : {})
1188
+ });
1189
+ state.activeConversationId = payload.conversation.conversationId;
1190
+ state.confirmDeleteId = null;
1191
+ pushConversationUrl(state.activeConversationId);
1192
+ await loadConversations();
1193
+ if (shouldLoadConversation) {
1194
+ await loadConversation(state.activeConversationId);
1195
+ } else {
1196
+ elements.chatTitle.textContent = payload.conversation.title || "New conversation";
1197
+ }
1198
+ return state.activeConversationId;
1199
+ };
1200
+
1201
+ const parseSseChunk = (buffer, onEvent) => {
1202
+ let rest = buffer;
1203
+ while (true) {
1204
+ const index = rest.indexOf("\\n\\n");
1205
+ if (index < 0) {
1206
+ return rest;
1207
+ }
1208
+ const raw = rest.slice(0, index);
1209
+ rest = rest.slice(index + 2);
1210
+ const lines = raw.split("\\n");
1211
+ let eventName = "message";
1212
+ let data = "";
1213
+ for (const line of lines) {
1214
+ if (line.startsWith("event:")) {
1215
+ eventName = line.slice(6).trim();
1216
+ } else if (line.startsWith("data:")) {
1217
+ data += line.slice(5).trim();
1218
+ }
1219
+ }
1220
+ if (data) {
1221
+ try {
1222
+ onEvent(eventName, JSON.parse(data));
1223
+ } catch {}
1224
+ }
1225
+ }
1226
+ };
1227
+
1228
+ const setStreaming = (value) => {
1229
+ state.isStreaming = value;
1230
+ elements.send.disabled = value;
1231
+ };
1232
+
1233
+ const pushToolActivity = (assistantMessage, line) => {
1234
+ if (!line) {
1235
+ return;
1236
+ }
1237
+ if (
1238
+ !assistantMessage.metadata ||
1239
+ !Array.isArray(assistantMessage.metadata.toolActivity)
1240
+ ) {
1241
+ assistantMessage.metadata = {
1242
+ ...(assistantMessage.metadata || {}),
1243
+ toolActivity: [],
1244
+ };
1245
+ }
1246
+ assistantMessage.metadata.toolActivity.push(line);
1247
+ };
1248
+
1249
+ const autoResizePrompt = () => {
1250
+ const el = elements.prompt;
1251
+ el.style.height = "auto";
1252
+ const scrollHeight = el.scrollHeight;
1253
+ const nextHeight = Math.min(scrollHeight, 200);
1254
+ el.style.height = nextHeight + "px";
1255
+ el.style.overflowY = scrollHeight > 200 ? "auto" : "hidden";
1256
+ };
1257
+
1258
+ const sendMessage = async (text) => {
1259
+ const messageText = (text || "").trim();
1260
+ if (!messageText || state.isStreaming) {
1261
+ return;
1262
+ }
1263
+ const localMessages = [...(state.activeMessages || []), { role: "user", content: messageText }];
1264
+ let assistantMessage = { role: "assistant", content: "", metadata: { toolActivity: [] } };
1265
+ localMessages.push(assistantMessage);
1266
+ state.activeMessages = localMessages;
1267
+ renderMessages(localMessages, true);
1268
+ setStreaming(true);
1269
+ let conversationId = state.activeConversationId;
1270
+ try {
1271
+ if (!conversationId) {
1272
+ conversationId = await createConversation(messageText, { loadConversation: false });
1273
+ }
1274
+ const response = await fetch("/api/conversations/" + encodeURIComponent(conversationId) + "/messages", {
1275
+ method: "POST",
1276
+ credentials: "include",
1277
+ headers: { "Content-Type": "application/json", "x-csrf-token": state.csrfToken },
1278
+ body: JSON.stringify({ message: messageText })
1279
+ });
1280
+ if (!response.ok || !response.body) {
1281
+ throw new Error("Failed to stream response");
1282
+ }
1283
+ const reader = response.body.getReader();
1284
+ const decoder = new TextDecoder();
1285
+ let buffer = "";
1286
+ while (true) {
1287
+ const { value, done } = await reader.read();
1288
+ if (done) {
1289
+ break;
1290
+ }
1291
+ buffer += decoder.decode(value, { stream: true });
1292
+ buffer = parseSseChunk(buffer, (eventName, payload) => {
1293
+ if (eventName === "model:chunk") {
1294
+ assistantMessage.content += String(payload.content || "");
1295
+ renderMessages(localMessages, true);
1296
+ }
1297
+ if (eventName === "tool:started") {
1298
+ pushToolActivity(assistantMessage, "start " + (payload.tool || "tool"));
1299
+ renderMessages(localMessages, true);
1300
+ }
1301
+ if (eventName === "tool:completed") {
1302
+ const duration = typeof payload.duration === "number" ? payload.duration : null;
1303
+ pushToolActivity(
1304
+ assistantMessage,
1305
+ "done " +
1306
+ (payload.tool || "tool") +
1307
+ (duration !== null ? " (" + duration + "ms)" : ""),
1308
+ );
1309
+ renderMessages(localMessages, true);
1310
+ }
1311
+ if (eventName === "tool:error") {
1312
+ pushToolActivity(
1313
+ assistantMessage,
1314
+ "error " + (payload.tool || "tool") + ": " + (payload.error || "unknown error"),
1315
+ );
1316
+ renderMessages(localMessages, true);
1317
+ }
1318
+ if (eventName === "tool:approval:required") {
1319
+ pushToolActivity(assistantMessage, "approval required for " + (payload.tool || "tool"));
1320
+ renderMessages(localMessages, true);
1321
+ }
1322
+ if (eventName === "tool:approval:granted") {
1323
+ pushToolActivity(assistantMessage, "approval granted");
1324
+ renderMessages(localMessages, true);
1325
+ }
1326
+ if (eventName === "tool:approval:denied") {
1327
+ pushToolActivity(assistantMessage, "approval denied");
1328
+ renderMessages(localMessages, true);
1329
+ }
1330
+ if (eventName === "run:completed" && (!assistantMessage.content || assistantMessage.content.length === 0)) {
1331
+ assistantMessage.content = String(payload.result?.response || "");
1332
+ renderMessages(localMessages, false);
1333
+ }
1334
+ if (eventName === "run:error") {
1335
+ const errMsg = payload.error?.message || "Something went wrong";
1336
+ assistantMessage.content = "";
1337
+ assistantMessage._error = errMsg;
1338
+ renderMessages(localMessages, false);
1339
+ }
1340
+ });
1341
+ }
1342
+ await loadConversations();
1343
+ await loadConversation(conversationId);
1344
+ } finally {
1345
+ setStreaming(false);
1346
+ elements.prompt.focus();
1347
+ }
1348
+ };
1349
+
1350
+ const requireAuth = async () => {
1351
+ try {
1352
+ const session = await api("/api/auth/session");
1353
+ if (!session.authenticated) {
1354
+ elements.auth.classList.remove("hidden");
1355
+ elements.app.classList.add("hidden");
1356
+ return false;
1357
+ }
1358
+ state.csrfToken = session.csrfToken || "";
1359
+ elements.auth.classList.add("hidden");
1360
+ elements.app.classList.remove("hidden");
1361
+ return true;
1362
+ } catch {
1363
+ elements.auth.classList.remove("hidden");
1364
+ elements.app.classList.add("hidden");
1365
+ return false;
1366
+ }
1367
+ };
1368
+
1369
+ elements.loginForm.addEventListener("submit", async (event) => {
1370
+ event.preventDefault();
1371
+ elements.loginError.textContent = "";
1372
+ try {
1373
+ const result = await api("/api/auth/login", {
1374
+ method: "POST",
1375
+ body: JSON.stringify({ passphrase: elements.passphrase.value || "" })
1376
+ });
1377
+ state.csrfToken = result.csrfToken || "";
1378
+ elements.passphrase.value = "";
1379
+ elements.auth.classList.add("hidden");
1380
+ elements.app.classList.remove("hidden");
1381
+ await loadConversations();
1382
+ const urlConversationId = getConversationIdFromUrl();
1383
+ if (urlConversationId) {
1384
+ state.activeConversationId = urlConversationId;
1385
+ renderConversationList();
1386
+ try {
1387
+ await loadConversation(urlConversationId);
1388
+ } catch {
1389
+ state.activeConversationId = null;
1390
+ state.activeMessages = [];
1391
+ replaceConversationUrl(null);
1392
+ renderMessages([]);
1393
+ renderConversationList();
1394
+ }
1395
+ }
1396
+ } catch (error) {
1397
+ elements.loginError.textContent = error.message || "Login failed";
1398
+ }
1399
+ });
1400
+
1401
+ elements.newChat.addEventListener("click", () => {
1402
+ state.activeConversationId = null;
1403
+ state.activeMessages = [];
1404
+ state.confirmDeleteId = null;
1405
+ pushConversationUrl(null);
1406
+ elements.chatTitle.textContent = "";
1407
+ renderMessages([]);
1408
+ renderConversationList();
1409
+ elements.prompt.focus();
1410
+ if (isMobile()) {
1411
+ setSidebarOpen(false);
1412
+ }
1413
+ });
1414
+
1415
+ elements.prompt.addEventListener("input", () => {
1416
+ autoResizePrompt();
1417
+ });
1418
+
1419
+ elements.prompt.addEventListener("keydown", (event) => {
1420
+ if (event.key === "Enter" && !event.shiftKey) {
1421
+ event.preventDefault();
1422
+ elements.composer.requestSubmit();
1423
+ }
1424
+ });
1425
+
1426
+ elements.sidebarToggle.addEventListener("click", () => {
1427
+ if (isMobile()) setSidebarOpen(!elements.shell.classList.contains("sidebar-open"));
1428
+ });
1429
+
1430
+ elements.sidebarBackdrop.addEventListener("click", () => setSidebarOpen(false));
1431
+
1432
+ elements.logout.addEventListener("click", async () => {
1433
+ await api("/api/auth/logout", { method: "POST" });
1434
+ state.activeConversationId = null;
1435
+ state.activeMessages = [];
1436
+ state.confirmDeleteId = null;
1437
+ state.conversations = [];
1438
+ state.csrfToken = "";
1439
+ await requireAuth();
1440
+ });
1441
+
1442
+ elements.composer.addEventListener("submit", async (event) => {
1443
+ event.preventDefault();
1444
+ const value = elements.prompt.value;
1445
+ elements.prompt.value = "";
1446
+ autoResizePrompt();
1447
+ await sendMessage(value);
1448
+ });
1449
+
1450
+ document.addEventListener("click", (event) => {
1451
+ if (!(event.target instanceof Node)) {
1452
+ return;
1453
+ }
1454
+ if (!event.target.closest(".conversation-item") && state.confirmDeleteId) {
1455
+ state.confirmDeleteId = null;
1456
+ renderConversationList();
1457
+ }
1458
+ });
1459
+
1460
+ window.addEventListener("resize", () => {
1461
+ setSidebarOpen(false);
1462
+ });
1463
+
1464
+ const navigateToConversation = async (conversationId) => {
1465
+ if (conversationId) {
1466
+ state.activeConversationId = conversationId;
1467
+ renderConversationList();
1468
+ try {
1469
+ await loadConversation(conversationId);
1470
+ } catch {
1471
+ // Conversation not found \u2013 fall back to empty state
1472
+ state.activeConversationId = null;
1473
+ state.activeMessages = [];
1474
+ replaceConversationUrl(null);
1475
+ elements.chatTitle.textContent = "";
1476
+ renderMessages([]);
1477
+ renderConversationList();
1478
+ }
1479
+ } else {
1480
+ state.activeConversationId = null;
1481
+ state.activeMessages = [];
1482
+ elements.chatTitle.textContent = "";
1483
+ renderMessages([]);
1484
+ renderConversationList();
1485
+ }
1486
+ };
1487
+
1488
+ window.addEventListener("popstate", async () => {
1489
+ if (state.isStreaming) return;
1490
+ const conversationId = getConversationIdFromUrl();
1491
+ await navigateToConversation(conversationId);
1492
+ });
1493
+
1494
+ (async () => {
1495
+ const authenticated = await requireAuth();
1496
+ if (!authenticated) {
1497
+ return;
1498
+ }
1499
+ await loadConversations();
1500
+ const urlConversationId = getConversationIdFromUrl();
1501
+ if (urlConversationId) {
1502
+ state.activeConversationId = urlConversationId;
1503
+ replaceConversationUrl(urlConversationId);
1504
+ renderConversationList();
1505
+ try {
1506
+ await loadConversation(urlConversationId);
1507
+ } catch {
1508
+ // URL pointed to a conversation that no longer exists
1509
+ state.activeConversationId = null;
1510
+ state.activeMessages = [];
1511
+ replaceConversationUrl(null);
1512
+ elements.chatTitle.textContent = "";
1513
+ renderMessages([]);
1514
+ renderConversationList();
1515
+ if (state.conversations.length === 0) {
1516
+ await createConversation();
1517
+ }
1518
+ }
1519
+ } else if (state.conversations.length === 0) {
1520
+ await createConversation();
1521
+ }
1522
+ autoResizePrompt();
1523
+ elements.prompt.focus();
1524
+ })();
1525
+
1526
+ if ("serviceWorker" in navigator) {
1527
+ navigator.serviceWorker.register("/sw.js").catch(() => {});
1528
+ }
1529
+
1530
+ // Prevent iOS from scrolling the page when inputs are focused.
1531
+ (function() {
1532
+ var pinScroll = function() { if (window.scrollY !== 0) window.scrollTo(0, 0); };
1533
+ if (window.visualViewport) {
1534
+ window.visualViewport.addEventListener("scroll", pinScroll);
1535
+ }
1536
+ document.addEventListener("scroll", pinScroll);
1537
+
1538
+ // Draggable sidebar from left edge (mobile only)
1539
+ (function() {
1540
+ var sidebar = document.querySelector(".sidebar");
1541
+ var backdrop = document.querySelector(".sidebar-backdrop");
1542
+ var shell = document.querySelector(".shell");
1543
+ if (!sidebar || !backdrop || !shell) return;
1544
+
1545
+ var sidebarWidth = 260;
1546
+ var edgeThreshold = 50; // px from left edge to start drag
1547
+ var velocityThreshold = 0.3; // px/ms to trigger open/close
1548
+
1549
+ var dragging = false;
1550
+ var startX = 0;
1551
+ var startY = 0;
1552
+ var currentX = 0;
1553
+ var startTime = 0;
1554
+ var isOpen = false;
1555
+ var directionLocked = false;
1556
+ var isHorizontal = false;
1557
+
1558
+ function getProgress() {
1559
+ // Returns 0 (closed) to 1 (open)
1560
+ if (isOpen) {
1561
+ return Math.max(0, Math.min(1, 1 + currentX / sidebarWidth));
1562
+ } else {
1563
+ return Math.max(0, Math.min(1, currentX / sidebarWidth));
1564
+ }
1565
+ }
1566
+
1567
+ function updatePosition(progress) {
1568
+ var offset = (progress - 1) * sidebarWidth;
1569
+ sidebar.style.transform = "translateX(" + offset + "px)";
1570
+ backdrop.style.opacity = progress;
1571
+ if (progress > 0) {
1572
+ backdrop.style.pointerEvents = "auto";
1573
+ } else {
1574
+ backdrop.style.pointerEvents = "none";
1575
+ }
1576
+ }
1577
+
1578
+ function onTouchStart(e) {
1579
+ if (window.innerWidth > 768) return;
1580
+ var touch = e.touches[0];
1581
+ isOpen = shell.classList.contains("sidebar-open");
1582
+
1583
+ // Allow drag from edge when closed, or anywhere on sidebar/backdrop when open
1584
+ var fromEdge = touch.clientX < edgeThreshold;
1585
+ var onSidebar = sidebar.contains(e.target);
1586
+ var onBackdrop = e.target === backdrop;
1587
+
1588
+ if (!fromEdge && !isOpen) return;
1589
+ if (isOpen && !onSidebar && !onBackdrop) return;
1590
+
1591
+ // Prevent Safari back gesture when starting from edge
1592
+ if (fromEdge) {
1593
+ e.preventDefault();
1594
+ }
1595
+
1596
+ startX = touch.clientX;
1597
+ startY = touch.clientY;
1598
+ currentX = 0;
1599
+ startTime = Date.now();
1600
+ directionLocked = false;
1601
+ isHorizontal = false;
1602
+ dragging = true;
1603
+ sidebar.classList.add("dragging");
1604
+ backdrop.classList.add("dragging");
1605
+ }
1606
+
1607
+ function onTouchMove(e) {
1608
+ if (!dragging) return;
1609
+ var touch = e.touches[0];
1610
+ var dx = touch.clientX - startX;
1611
+ var dy = touch.clientY - startY;
1612
+
1613
+ // Lock direction after some movement
1614
+ if (!directionLocked && (Math.abs(dx) > 10 || Math.abs(dy) > 10)) {
1615
+ directionLocked = true;
1616
+ isHorizontal = Math.abs(dx) > Math.abs(dy);
1617
+ if (!isHorizontal) {
1618
+ // Vertical scroll, cancel drag
1619
+ dragging = false;
1620
+ sidebar.classList.remove("dragging");
1621
+ backdrop.classList.remove("dragging");
1622
+ return;
1623
+ }
1624
+ }
1625
+
1626
+ if (!directionLocked) return;
1627
+
1628
+ // Prevent scrolling while dragging sidebar
1629
+ e.preventDefault();
1630
+
1631
+ currentX = dx;
1632
+ updatePosition(getProgress());
1633
+ }
1634
+
1635
+ function onTouchEnd(e) {
1636
+ if (!dragging) return;
1637
+ dragging = false;
1638
+ sidebar.classList.remove("dragging");
1639
+ backdrop.classList.remove("dragging");
1640
+
1641
+ var touch = e.changedTouches[0];
1642
+ var dx = touch.clientX - startX;
1643
+ var dt = Date.now() - startTime;
1644
+ var velocity = dx / dt; // px/ms
1645
+
1646
+ var progress = getProgress();
1647
+ var shouldOpen;
1648
+
1649
+ // Use velocity if fast enough, otherwise use position threshold
1650
+ if (Math.abs(velocity) > velocityThreshold) {
1651
+ shouldOpen = velocity > 0;
1652
+ } else {
1653
+ shouldOpen = progress > 0.5;
1654
+ }
1655
+
1656
+ // Reset inline styles and let CSS handle the animation
1657
+ sidebar.style.transform = "";
1658
+ backdrop.style.opacity = "";
1659
+ backdrop.style.pointerEvents = "";
1660
+
1661
+ if (shouldOpen) {
1662
+ shell.classList.add("sidebar-open");
1663
+ } else {
1664
+ shell.classList.remove("sidebar-open");
1665
+ }
1666
+ }
1667
+
1668
+ document.addEventListener("touchstart", onTouchStart, { passive: false });
1669
+ document.addEventListener("touchmove", onTouchMove, { passive: false });
1670
+ document.addEventListener("touchend", onTouchEnd, { passive: true });
1671
+ document.addEventListener("touchcancel", onTouchEnd, { passive: true });
1672
+ })();
1673
+
1674
+ // Prevent Safari back/forward navigation by manipulating history
1675
+ // This doesn't stop the gesture animation but prevents actual navigation
1676
+ if (window.navigator.standalone || window.matchMedia("(display-mode: standalone)").matches) {
1677
+ history.pushState(null, "", location.href);
1678
+ window.addEventListener("popstate", function() {
1679
+ history.pushState(null, "", location.href);
1680
+ });
1681
+ }
1682
+
1683
+ // Right edge blocker - intercept touch events to prevent forward navigation
1684
+ var rightBlocker = document.querySelector(".edge-blocker-right");
1685
+ if (rightBlocker) {
1686
+ rightBlocker.addEventListener("touchstart", function(e) {
1687
+ e.preventDefault();
1688
+ }, { passive: false });
1689
+ rightBlocker.addEventListener("touchmove", function(e) {
1690
+ e.preventDefault();
1691
+ }, { passive: false });
1692
+ }
1693
+ })();
1694
+
1695
+ </script>
1696
+ </body>
1697
+ </html>`;
1698
+ };
1699
+
1700
+ // src/init-feature-context.ts
1701
+ import { createHash as createHash2 } from "crypto";
1702
+ import { access, mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
1703
+ import { basename as basename2, dirname as dirname2, resolve as resolve2 } from "path";
1704
+ import { homedir as homedir2 } from "os";
1705
+ var ONBOARDING_VERSION = 1;
1706
+ var getStateDirectory = () => {
1707
+ const cwd = process.cwd();
1708
+ const home = homedir2();
1709
+ 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";
1710
+ if (isServerless) {
1711
+ return "/tmp/.agentl/state";
1712
+ }
1713
+ return resolve2(homedir2(), ".agentl", "state");
1714
+ };
1715
+ var summarizeConfig = (config) => {
1716
+ const provider = config?.storage?.provider ?? config?.state?.provider ?? "local";
1717
+ const memoryEnabled = config?.storage?.memory?.enabled ?? config?.memory?.enabled ?? false;
1718
+ const authRequired = config?.auth?.required ?? false;
1719
+ const telemetryEnabled = config?.telemetry?.enabled ?? true;
1720
+ return [
1721
+ `storage: ${provider}`,
1722
+ `memory tools: ${memoryEnabled ? "enabled" : "disabled"}`,
1723
+ `auth: ${authRequired ? "required" : "not required"}`,
1724
+ `telemetry: ${telemetryEnabled ? "enabled" : "disabled"}`
1725
+ ];
1726
+ };
1727
+ var getOnboardingMarkerPath = (workingDir) => resolve2(
1728
+ getStateDirectory(),
1729
+ `${basename2(workingDir).replace(/[^a-zA-Z0-9_-]+/g, "-") || "project"}-${createHash2("sha256").update(workingDir).digest("hex").slice(0, 12)}-onboarding.json`
1730
+ );
1731
+ var readMarker = async (workingDir) => {
1732
+ const markerPath = getOnboardingMarkerPath(workingDir);
1733
+ try {
1734
+ await access(markerPath);
1735
+ } catch {
1736
+ return void 0;
1737
+ }
1738
+ try {
1739
+ const raw = await readFile2(markerPath, "utf8");
1740
+ return JSON.parse(raw);
1741
+ } catch {
1742
+ return void 0;
1743
+ }
1744
+ };
1745
+ var writeMarker = async (workingDir, state) => {
1746
+ const markerPath = getOnboardingMarkerPath(workingDir);
1747
+ await mkdir2(dirname2(markerPath), { recursive: true });
1748
+ await writeFile2(markerPath, JSON.stringify(state, null, 2), "utf8");
1749
+ };
1750
+ var initializeOnboardingMarker = async (workingDir, options) => {
1751
+ const current = await readMarker(workingDir);
1752
+ if (current) {
1753
+ return;
1754
+ }
1755
+ const allowIntro = options?.allowIntro ?? true;
1756
+ await writeMarker(workingDir, {
1757
+ introduced: allowIntro ? false : true,
1758
+ allowIntro,
1759
+ onboardingVersion: ONBOARDING_VERSION,
1760
+ createdAt: Date.now()
1761
+ });
1762
+ };
1763
+ var consumeFirstRunIntro = async (workingDir, input) => {
1764
+ const runtimeEnv = (process.env.AGENTL_ENV ?? process.env.NODE_ENV ?? "").toLowerCase();
1765
+ if (runtimeEnv === "production") {
1766
+ return void 0;
1767
+ }
1768
+ const marker = await readMarker(workingDir);
1769
+ if (marker?.allowIntro === false) {
1770
+ return void 0;
1771
+ }
1772
+ const shouldShow = !marker || marker.introduced === false;
1773
+ if (!shouldShow) {
1774
+ return void 0;
1775
+ }
1776
+ await writeMarker(workingDir, {
1777
+ introduced: true,
1778
+ allowIntro: true,
1779
+ onboardingVersion: ONBOARDING_VERSION,
1780
+ createdAt: marker?.createdAt ?? Date.now(),
1781
+ introducedAt: Date.now()
1782
+ });
1783
+ const summary = summarizeConfig(input.config);
1784
+ return [
1785
+ `Hi! I'm **${input.agentName}**. I can configure myself directly by chat.
1786
+ `,
1787
+ `**Current config**`,
1788
+ ` Model: ${input.provider}/${input.model}`,
1789
+ ` \`\`\`${summary.join(" \xB7 ")}\`\`\``,
1790
+ "",
1791
+ "Feel free to ask me anything when you're ready. I can help you:",
1792
+ "",
1793
+ "- **Build skills**: Create custom tools and capabilities for this agent",
1794
+ "- **Configure the model**: Switch providers (OpenAI, Anthropic, etc.) or models",
1795
+ "- **Set up storage**: Use local files, Upstash, or other backends",
1796
+ "- **Enable auth**: Add bearer tokens or custom authentication",
1797
+ "- **Turn on telemetry**: Track usage with OpenTelemetry/OTLP",
1798
+ "- **Add MCP servers**: Connect external tool servers",
1799
+ "",
1800
+ "Just let me know what you'd like to work on!\n"
1801
+ ].join("\n");
1802
+ };
1803
+
1804
+ export {
1805
+ SessionStore,
1806
+ LoginRateLimiter,
1807
+ parseCookies,
1808
+ setCookie,
1809
+ verifyPassphrase,
1810
+ getRequestIp,
1811
+ inferConversationTitle,
1812
+ renderManifest,
1813
+ renderIconSvg,
1814
+ renderServiceWorker,
1815
+ renderWebUiHtml,
1816
+ initializeOnboardingMarker,
1817
+ consumeFirstRunIntro
1818
+ };