autohand-cli 0.7.13 → 0.8.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 (394) hide show
  1. package/assets/icon.png +0 -0
  2. package/dist/AgentRegistry-7LDL5HJH.js +10 -0
  3. package/dist/AgentRegistry-NQCLWABO.cjs +10 -0
  4. package/dist/{AutomodeManager-NGRAO2MH.js → AutomodeManager-MWLKGPZK.js} +2 -0
  5. package/dist/{AutomodeManager-ZKQMBM4T.cjs → AutomodeManager-NYIZNODK.cjs} +3 -1
  6. package/dist/CommunitySkillsCache-6QPRMTJO.js +8 -0
  7. package/dist/CommunitySkillsCache-GTQMOCCO.cjs +8 -0
  8. package/dist/{GitHubRegistryFetcher-US2JJID4.js → GitHubRegistryFetcher-6JQ5JEDZ.js} +1 -0
  9. package/dist/{GitHubRegistryFetcher-K744NNAJ.cjs → GitHubRegistryFetcher-S7QFUEKV.cjs} +1 -0
  10. package/dist/HookManager-Q2KYMCP4.cjs +7 -0
  11. package/dist/HookManager-TTP4Y6DC.js +7 -0
  12. package/dist/ImportWizard-IWVPRKFF.cjs +466 -0
  13. package/dist/ImportWizard-KASGQPUY.js +466 -0
  14. package/dist/McpClientManager-7RM6YT35.js +8 -0
  15. package/dist/McpClientManager-RKD7C6OY.cjs +8 -0
  16. package/dist/MemoryManager-GUNLRP5S.js +8 -0
  17. package/dist/MemoryManager-TNSGKDKX.cjs +8 -0
  18. package/dist/PermissionManager-2GO5PQ6M.cjs +11 -0
  19. package/dist/{PermissionManager-U5OMGR3L.js → PermissionManager-K7UWSNB6.js} +4 -3
  20. package/dist/ProjectProfiler-UMJJSOCE.js +194 -0
  21. package/dist/ProjectProfiler-ZDWR2ODG.cjs +194 -0
  22. package/dist/ProviderFactory-EFFQBRQ6.cjs +9 -0
  23. package/dist/ProviderFactory-S3LWTQQC.js +9 -0
  24. package/dist/SessionManager-FEUAU3ZJ.cjs +10 -0
  25. package/dist/SessionManager-IKWAK2PI.js +10 -0
  26. package/dist/SkillsRegistry-GDEGFP6O.cjs +9 -0
  27. package/dist/SkillsRegistry-SI5RUHQ4.js +9 -0
  28. package/dist/SubAgent-I75HELJG.js +11 -0
  29. package/dist/SubAgent-K3QP6WHC.cjs +11 -0
  30. package/dist/{SyncApiClient-AYXYSOJM.js → SyncApiClient-LVIO4C2S.js} +1 -0
  31. package/dist/{SyncApiClient-ID3KXEMA.cjs → SyncApiClient-ZNYMT36M.cjs} +1 -0
  32. package/dist/about-B2AGTV6N.js +12 -0
  33. package/dist/about-V2HWEZZO.cjs +12 -0
  34. package/dist/actionExecutor-6XCVL2SJ.js +19 -0
  35. package/dist/actionExecutor-YRUJNB5G.cjs +19 -0
  36. package/dist/add-dir-7FBQ5IFV.js +10 -0
  37. package/dist/add-dir-ALBSYRV3.cjs +10 -0
  38. package/dist/agents/builtin/code-cleaner.md +14 -0
  39. package/dist/agents/builtin/docs-writer.md +14 -0
  40. package/dist/agents/builtin/researcher.md +14 -0
  41. package/dist/agents/builtin/reviewer.md +15 -0
  42. package/dist/agents/builtin/tester.md +15 -0
  43. package/dist/agents/builtin/todo-resolver.md +15 -0
  44. package/dist/agents-FCGEWTA3.cjs +12 -0
  45. package/dist/agents-FENGUSJD.js +12 -0
  46. package/dist/agents-new-FU3O55CO.js +14 -0
  47. package/dist/agents-new-SAFTJ7TK.cjs +14 -0
  48. package/dist/assets/icon.png +0 -0
  49. package/dist/automode-CYLGXQ4A.cjs +10 -0
  50. package/dist/automode-O7G3DUYN.js +10 -0
  51. package/dist/{cc-UTTLESTY.js → cc-7LEIJ3KF.js} +1 -0
  52. package/dist/{cc-2W6M7J45.cjs → cc-Q5MM4AWC.cjs} +1 -0
  53. package/dist/{chunk-N4ZSG6JJ.cjs → chunk-22D2CNTP.cjs} +2 -2
  54. package/dist/chunk-24QIWILL.js +51 -0
  55. package/dist/{chunk-MYNHJHDZ.js → chunk-2AA5MFES.js} +1 -1
  56. package/dist/{chunk-2JMWWYMZ.js → chunk-2ELK5DMH.js} +44 -10
  57. package/dist/chunk-2JYIR3EC.cjs +1176 -0
  58. package/dist/{chunk-RRZFJIIB.js → chunk-2RIAPTET.js} +90 -66
  59. package/dist/{chunk-TSY7JHIV.cjs → chunk-33A755XB.cjs} +2 -2
  60. package/dist/chunk-3OEDGIFW.js +42 -0
  61. package/dist/{chunk-P5VDZ6PV.js → chunk-3PDTTAKJ.js} +1 -1
  62. package/dist/{chunk-ULMPJUJW.cjs → chunk-3WCOFXQS.cjs} +23 -23
  63. package/dist/{chunk-ONAY5SD2.cjs → chunk-4HKTYHNL.cjs} +22 -16
  64. package/dist/{chunk-Z4J4W6YQ.cjs → chunk-4JNNTOGF.cjs} +2 -48
  65. package/dist/chunk-55B6SBHK.js +260 -0
  66. package/dist/chunk-5DDDUUBM.cjs +29 -0
  67. package/dist/{chunk-TQB222ZB.js → chunk-5EIEWVYX.js} +2 -2
  68. package/dist/{chunk-SMHY3Q7B.cjs → chunk-5GGX6WNY.cjs} +54 -22
  69. package/dist/{chunk-3S4DEIJP.cjs → chunk-5IXII4HX.cjs} +2 -2
  70. package/dist/{chunk-3KBBARKO.js → chunk-5OBNULPU.js} +85 -28
  71. package/dist/{chunk-VVBBEYTH.cjs → chunk-5YJG6H6P.cjs} +10 -10
  72. package/dist/{chunk-PKOAXQKW.cjs → chunk-63WXWFDI.cjs} +11 -11
  73. package/dist/{chunk-DSKVMFRM.cjs → chunk-643VRA5S.cjs} +12 -4
  74. package/dist/{chunk-L5ZFPWHY.js → chunk-6OYHF6MF.js} +12 -4
  75. package/dist/chunk-7GDVDSNI.js +1176 -0
  76. package/dist/chunk-7QEE6SW6.cjs +260 -0
  77. package/dist/chunk-7UOUW76C.js +603 -0
  78. package/dist/{chunk-SZP4ULM5.cjs → chunk-AFN7LH5N.cjs} +17 -17
  79. package/dist/chunk-AHD5JJ6F.cjs +78 -0
  80. package/dist/{chunk-WLTVF77A.js → chunk-ALYU6VTM.js} +1 -1
  81. package/dist/{chunk-BRXIEKJ3.cjs → chunk-AMT2UZBI.cjs} +5 -5
  82. package/dist/{chunk-SFNT5DYE.cjs → chunk-BT35E7NE.cjs} +4 -4
  83. package/dist/{chunk-NUHYCFHW.cjs → chunk-BVKXEQVG.cjs} +54 -65
  84. package/dist/chunk-CDMGQR4L.cjs +4470 -0
  85. package/dist/chunk-CNBKZEX5.cjs +109 -0
  86. package/dist/{chunk-GD4AFYJ3.js → chunk-CVVEYUFR.js} +1 -1
  87. package/dist/chunk-CWALFEGU.js +58 -0
  88. package/dist/{chunk-MTALRU7R.cjs → chunk-D3YCFT5O.cjs} +3 -3
  89. package/dist/{chunk-METF3I6W.cjs → chunk-D6VG7B5X.cjs} +10 -4
  90. package/dist/{chunk-TOTDRAWG.js → chunk-DH7DKCUL.js} +1 -1
  91. package/dist/{chunk-RFNCTE4V.cjs → chunk-DLG43ZJ7.cjs} +2 -2
  92. package/dist/chunk-DN573ME7.cjs +1675 -0
  93. package/dist/{chunk-63BXZQZW.js → chunk-E23CMMNJ.js} +20 -4
  94. package/dist/{chunk-4HA7IHLJ.cjs → chunk-EEGK5DYE.cjs} +32 -16
  95. package/dist/{chunk-DTFR3WD6.js → chunk-EF4LKUQY.js} +1 -1
  96. package/dist/{chunk-PWLLLJHU.js → chunk-EGFT4PGW.js} +3 -1
  97. package/dist/{chunk-S47TCZDL.js → chunk-EIU7K7CM.js} +7 -7
  98. package/dist/{chunk-BISFR6ZL.js → chunk-EPNYD4NV.js} +1 -1
  99. package/dist/chunk-EZMINVLU.js +123 -0
  100. package/dist/{chunk-LYMTYC67.js → chunk-F23EVNJU.js} +2 -2
  101. package/dist/chunk-FHK7UDOJ.cjs +42 -0
  102. package/dist/chunk-FMB3TSWP.cjs +218 -0
  103. package/dist/{chunk-XBUMKEFN.cjs → chunk-FPAE6ORV.cjs} +91 -34
  104. package/dist/{chunk-DEAEO7RI.js → chunk-FYZ67R4R.js} +1 -1
  105. package/dist/{chunk-6SHHB2VD.js → chunk-G7SZIOHF.js} +2 -2
  106. package/dist/{chunk-FB6JWNJS.js → chunk-GBHDROGL.js} +54 -65
  107. package/dist/chunk-GCHELXLO.js +131 -0
  108. package/dist/{chunk-7YX3OD4B.js → chunk-GHSBZ3YB.js} +2 -2
  109. package/dist/chunk-GLBAF54O.js +218 -0
  110. package/dist/chunk-GO3N7LRW.cjs +131 -0
  111. package/dist/{chunk-KW4SQWBU.cjs → chunk-H6ZGZEBG.cjs} +57 -23
  112. package/dist/{chunk-CTJILRNQ.cjs → chunk-HA7OAVOB.cjs} +15 -15
  113. package/dist/{chunk-NMWEDN4Z.js → chunk-HFMLWH7B.js} +108 -0
  114. package/dist/{chunk-D2XFTCRP.js → chunk-HQ7YZKXE.js} +1 -1
  115. package/dist/{chunk-L42HTMMR.cjs → chunk-HTLINWX6.cjs} +2 -2
  116. package/dist/chunk-IETRBBMP.cjs +603 -0
  117. package/dist/chunk-IQ5RXU6O.js +1675 -0
  118. package/dist/{chunk-B5HIJJ4B.js → chunk-ITB3FS72.js} +11 -5
  119. package/dist/{chunk-B6EBHCK2.cjs → chunk-IUMJYXBX.cjs} +6 -6
  120. package/dist/{chunk-ZBIBLOZL.js → chunk-IVM5F2AE.js} +500 -317
  121. package/dist/{chunk-GRSVQ5YZ.js → chunk-IWVQ2EW3.js} +44 -12
  122. package/dist/chunk-JJWCQLOU.cjs +59 -0
  123. package/dist/{chunk-KXAAEROY.js → chunk-JMFDD7IZ.js} +2 -2
  124. package/dist/chunk-JSBRDJBE.js +30 -0
  125. package/dist/chunk-LJFUXC56.cjs +123 -0
  126. package/dist/chunk-LL3PQ2U6.js +4470 -0
  127. package/dist/chunk-LQ4LQQG6.cjs +27 -0
  128. package/dist/chunk-LQGVEP3E.js +109 -0
  129. package/dist/{chunk-425MT6Y5.cjs → chunk-LVE6Z5SL.cjs} +9 -9
  130. package/dist/{chunk-XL77XYI2.cjs → chunk-LXDOQTXQ.cjs} +4 -4
  131. package/dist/{chunk-BG4OQUKP.js → chunk-MBBY4ZIK.js} +1 -1
  132. package/dist/{chunk-XQLWN4Y3.cjs → chunk-MGMXR67S.cjs} +9 -9
  133. package/dist/{chunk-FHUNAB2K.cjs → chunk-MHLE6AVN.cjs} +33 -6
  134. package/dist/chunk-MHSDHPC4.cjs +58 -0
  135. package/dist/chunk-MUBW5UDH.cjs +55 -0
  136. package/dist/{chunk-R3H25HQZ.cjs → chunk-MVWOQBCC.cjs} +11 -11
  137. package/dist/chunk-N254NRHT.cjs +30 -0
  138. package/dist/{chunk-SRLY7K6J.js → chunk-OBLIITWJ.js} +2 -2
  139. package/dist/{chunk-SIGWDEPS.cjs → chunk-OI7OIGNB.cjs} +10 -10
  140. package/dist/{chunk-V7YTCNMN.cjs → chunk-OPR34VHL.cjs} +5 -5
  141. package/dist/chunk-OUHQZFN4.js +78 -0
  142. package/dist/{chunk-HMRDNRTH.js → chunk-PEC45WYS.js} +2 -2
  143. package/dist/{chunk-OSUWEUZE.js → chunk-PUOE5BCN.js} +1 -1
  144. package/dist/chunk-Q2VYSHWU.js +59 -0
  145. package/dist/chunk-Q3MJ6CYS.cjs +193 -0
  146. package/dist/{chunk-B2K7JZRW.js → chunk-Q5RN7RXC.js} +2 -2
  147. package/dist/{chunk-43XS26AQ.cjs → chunk-Q5RX3XGB.cjs} +4 -4
  148. package/dist/chunk-QCLYBIMM.cjs +51 -0
  149. package/dist/chunk-QMAKTSZB.cjs +48 -0
  150. package/dist/chunk-QT2VZNFA.js +29 -0
  151. package/dist/{chunk-3AWZFG5G.js → chunk-QUFAULH7.js} +10 -4
  152. package/dist/{chunk-RJP3SZ7Q.cjs → chunk-RD5XAJR2.cjs} +492 -309
  153. package/dist/chunk-RGR6ME5J.cjs +844 -0
  154. package/dist/{chunk-EOGKE5GD.cjs → chunk-RKJTGGMU.cjs} +221 -126
  155. package/dist/{chunk-NMGF2KUN.js → chunk-RO46YAPI.js} +1 -1
  156. package/dist/{chunk-2U5HFVRO.cjs → chunk-RVUQKMXX.cjs} +108 -0
  157. package/dist/chunk-S52YW5ZQ.js +844 -0
  158. package/dist/{chunk-ZLOTP56B.cjs → chunk-S6BDWWUG.cjs} +5 -5
  159. package/dist/{chunk-6DWXHBAY.js → chunk-SAHBLB3E.js} +222 -127
  160. package/dist/chunk-SALLHB2I.js +27 -0
  161. package/dist/{chunk-GIZL57FE.cjs → chunk-SEKD5FH3.cjs} +3 -1
  162. package/dist/{chunk-DZHR34H6.cjs → chunk-SHFA46CS.cjs} +8 -8
  163. package/dist/{chunk-MILZEEUV.js → chunk-SIHRD34Z.js} +2 -2
  164. package/dist/{chunk-BPTBKO7D.js → chunk-SO3QQJAZ.js} +216 -36
  165. package/dist/{chunk-HSPWX4Z2.cjs → chunk-SRQW3B6J.cjs} +223 -43
  166. package/dist/{chunk-MY3TZER2.js → chunk-T63AMO6H.js} +1 -1
  167. package/dist/{chunk-X765A7J5.js → chunk-TERCG25S.js} +1 -1
  168. package/dist/{chunk-WOGJXDBU.cjs → chunk-TFSRRZWP.cjs} +3 -3
  169. package/dist/{chunk-RRZS5A53.js → chunk-TQHOVHRS.js} +1 -1
  170. package/dist/{chunk-JHOQABEF.js → chunk-TWEKBHUO.js} +5 -5
  171. package/dist/chunk-U3WDY42C.cjs +42 -0
  172. package/dist/{chunk-CKN2BLHK.cjs → chunk-UBS46QL3.cjs} +2 -2
  173. package/dist/{chunk-H3GBSPK5.js → chunk-UGTFKUW4.js} +14 -6
  174. package/dist/chunk-UJTCTTUF.cjs +271 -0
  175. package/dist/{chunk-RUZB43HU.cjs → chunk-UTI6ZQEY.cjs} +22 -14
  176. package/dist/{chunk-OLG7LZBD.js → chunk-VG34MG2U.js} +1 -1
  177. package/dist/{chunk-ZKZRFH37.cjs → chunk-VJYPP6PP.cjs} +6 -6
  178. package/dist/{chunk-YHGTBPEC.js → chunk-VNQ5GL34.js} +1 -1
  179. package/dist/{chunk-XDVG3NM4.js → chunk-W3X6PAC7.js} +2 -48
  180. package/dist/{chunk-FK2DVRPJ.js → chunk-WFUUXADU.js} +2 -2
  181. package/dist/{chunk-R5OO7MEB.cjs → chunk-WGTJOIB7.cjs} +22 -22
  182. package/dist/{chunk-VHBUKGRG.js → chunk-WJDPVW7T.js} +4 -4
  183. package/dist/chunk-WNUVPKBW.js +42 -0
  184. package/dist/{chunk-EV53SLSB.cjs → chunk-WPVWQSL7.cjs} +4 -4
  185. package/dist/chunk-WQ3VJXZB.js +118 -0
  186. package/dist/chunk-WTNBX2JO.js +271 -0
  187. package/dist/chunk-XAV24VYN.js +48 -0
  188. package/dist/chunk-XDLH4EDL.cjs +118 -0
  189. package/dist/{chunk-U7CZFKPL.cjs → chunk-XMNHZRUB.cjs} +2 -2
  190. package/dist/chunk-XUDSXGGV.cjs +1822 -0
  191. package/dist/{chunk-YESQ7XR3.js → chunk-XWASJ2QL.js} +4 -4
  192. package/dist/chunk-Y2SXUCNJ.js +55 -0
  193. package/dist/{chunk-AIH6GUGB.cjs → chunk-YDCDGTK6.cjs} +5 -5
  194. package/dist/chunk-YFXTE422.cjs +92 -0
  195. package/dist/chunk-YKS55CMT.js +1822 -0
  196. package/dist/{chunk-KC5FPUOF.cjs → chunk-YRLYSQEQ.cjs} +2 -2
  197. package/dist/{chunk-JWPI6O5Z.js → chunk-YS34SVY5.js} +31 -4
  198. package/dist/{chunk-FEVHH525.cjs → chunk-YYB42DCU.cjs} +4 -4
  199. package/dist/chunk-ZK6HOR62.js +92 -0
  200. package/dist/{chunk-BHV7CBNT.js → chunk-ZSE42BRE.js} +1 -1
  201. package/dist/clear-ES5WCZRF.cjs +12 -0
  202. package/dist/clear-J7XS6T5W.js +12 -0
  203. package/dist/completion-XQTDTJLK.cjs +14 -0
  204. package/dist/completion-XR6ZONJQ.js +14 -0
  205. package/dist/config-2TB3A55J.js +18 -0
  206. package/dist/config-RDMVIV26.cjs +18 -0
  207. package/dist/constants-6CPCJ3DY.cjs +21 -0
  208. package/dist/{constants-V6J54N3X.js → constants-UFM5B232.js} +2 -1
  209. package/dist/{defaultHooks-WLMRQUXG.cjs → defaultHooks-RCXPHF4M.cjs} +3 -1
  210. package/dist/{defaultHooks-R56VYG7I.js → defaultHooks-RDRMER3Z.js} +2 -0
  211. package/dist/export-EWAYH353.cjs +12 -0
  212. package/dist/export-ZWA6XGVS.js +12 -0
  213. package/dist/extractSessionMemories-SDW2MVBQ.cjs +7 -0
  214. package/dist/extractSessionMemories-V7K42ZHW.js +7 -0
  215. package/dist/feedback-5RV6ODW4.js +15 -0
  216. package/dist/feedback-ZPITHFJR.cjs +15 -0
  217. package/dist/filesystem-3SGCW2BF.js +10 -0
  218. package/dist/filesystem-MCFXJQ6R.cjs +10 -0
  219. package/dist/formatters-6K7QVWQL.cjs +10 -0
  220. package/dist/formatters-DQHO5I36.js +10 -0
  221. package/dist/{help-RU24K66K.js → help-I5GRCA3S.js} +3 -2
  222. package/dist/help-X52PZM24.cjs +12 -0
  223. package/dist/history-4WIOZ4TW.cjs +14 -0
  224. package/dist/{history-AV4XBFRK.js → history-OCHJBJW7.js} +3 -2
  225. package/dist/hooks-IAVTXUAI.cjs +13 -0
  226. package/dist/hooks-YF6HL23E.js +13 -0
  227. package/dist/{i18n-BSAPXM56.js → i18n-KHBXUALK.js} +2 -1
  228. package/dist/i18n-MVQIAZWS.cjs +33 -0
  229. package/dist/ide-4R3BEBIS.js +12 -0
  230. package/dist/ide-C7WSPQTR.cjs +12 -0
  231. package/dist/import-2ICSKDL7.cjs +10 -0
  232. package/dist/import-EAAX5HJR.js +170 -0
  233. package/dist/import-KRVVYJCZ.js +10 -0
  234. package/dist/import-PQJPNXA4.cjs +170 -0
  235. package/dist/index.cjs +8671 -12373
  236. package/dist/index.js +8739 -12441
  237. package/dist/init-6K3NRDOM.js +10 -0
  238. package/dist/init-AOUGGITS.cjs +10 -0
  239. package/dist/language-Q7YFDVSR.cjs +18 -0
  240. package/dist/language-Y6ZC7LET.js +18 -0
  241. package/dist/{lint-44UQJ673.cjs → lint-D5UOJWIK.cjs} +1 -0
  242. package/dist/{lint-TA2ZHVLM.js → lint-NJPZWVN2.js} +1 -0
  243. package/dist/{localProjectPermissions-WQYMGI42.js → localProjectPermissions-N77HA3XK.js} +3 -2
  244. package/dist/localProjectPermissions-UFSMNTBJ.cjs +18 -0
  245. package/dist/login-6OAH2NEH.cjs +20 -0
  246. package/dist/login-DL3377MD.js +20 -0
  247. package/dist/logout-ELQBUMTU.cjs +18 -0
  248. package/dist/logout-TLYA5W45.js +18 -0
  249. package/dist/mcp-BHOIBYUB.js +18 -0
  250. package/dist/mcp-TNUEXR5T.cjs +18 -0
  251. package/dist/{mcp-install-2KVKRAMQ.cjs → mcp-install-GROTZHAW.cjs} +26 -14
  252. package/dist/{mcp-install-77UXRN6R.js → mcp-install-KSADVDBE.js} +21 -9
  253. package/dist/memory-6DRFA43C.js +10 -0
  254. package/dist/memory-IORZE6WF.cjs +10 -0
  255. package/dist/message-JUBOK2VU.js +9 -0
  256. package/dist/message-ZJ5AYAMT.cjs +9 -0
  257. package/dist/model-CJPSPGIC.cjs +10 -0
  258. package/dist/model-MQXC56ES.js +10 -0
  259. package/dist/new-7D2B7IWM.cjs +12 -0
  260. package/dist/new-7VYM36RC.js +12 -0
  261. package/dist/{patch-BAAQIYSW.js → patch-5F6VBIT3.js} +2 -0
  262. package/dist/{patch-J32X2QQP.cjs → patch-MOD7QC3D.cjs} +3 -1
  263. package/dist/permissions-MM77OSFO.js +13 -0
  264. package/dist/permissions-W2F62DJ6.cjs +13 -0
  265. package/dist/{plan-JFGNRL2S.js → plan-G5CEKJI4.js} +1 -0
  266. package/dist/{plan-B3CW5DXJ.cjs → plan-QKOHE3LH.cjs} +1 -0
  267. package/dist/quit-7D2RDGTD.cjs +10 -0
  268. package/dist/quit-PKBSEJOL.js +10 -0
  269. package/dist/registry-A5XLMQVC.cjs +1828 -0
  270. package/dist/registry-WQLWHOLY.js +1828 -0
  271. package/dist/resume-FBKXSDOA.js +13 -0
  272. package/dist/resume-KLPDYPWQ.cjs +13 -0
  273. package/dist/search-7RNYTCNO.js +17 -0
  274. package/dist/search-UESMQZC3.cjs +17 -0
  275. package/dist/{session-T3TAZ5ZU.cjs → session-BSU2L5UI.cjs} +1 -0
  276. package/dist/{session-H5QWKE5E.js → session-SZMRN5KG.js} +1 -0
  277. package/dist/sessions-TSSUFWIJ.cjs +10 -0
  278. package/dist/sessions-WAXBUQTU.js +10 -0
  279. package/dist/settings-D6JXX5RG.js +30 -0
  280. package/dist/settings-RKYGXKDG.cjs +30 -0
  281. package/dist/share-GLX4YHS4.cjs +14 -0
  282. package/dist/share-U2M2KBFJ.js +14 -0
  283. package/dist/skills-63QLZMUO.cjs +14 -0
  284. package/dist/{skills-LJZA6PVJ.js → skills-BAMMXP3Q.js} +3 -2
  285. package/dist/{skills-install-MQINL3EC.js → skills-install-QNQWC2MV.js} +99 -28
  286. package/dist/{skills-install-IKJZN4G2.cjs → skills-install-UMK5H3SO.cjs} +107 -36
  287. package/dist/skills-new-NYKNHJHV.cjs +15 -0
  288. package/dist/skills-new-NZFGFKML.js +15 -0
  289. package/dist/slashCommands-EJ23C3Z4.cjs +69 -0
  290. package/dist/slashCommands-JQIL4EWX.js +69 -0
  291. package/dist/status-BKC7GBNQ.js +11 -0
  292. package/dist/status-FU3CPJWQ.cjs +11 -0
  293. package/dist/sync-3IEIHXIP.cjs +18 -0
  294. package/dist/sync-7JMZVEQD.cjs +40 -0
  295. package/dist/{sync-EXYX7HXW.js → sync-KWX67OUN.js} +3 -2
  296. package/dist/sync-YVPFT7SL.js +18 -0
  297. package/dist/tasks-5FPBIFLC.js +9 -0
  298. package/dist/tasks-TXGKGNH6.cjs +9 -0
  299. package/dist/team-GVK5L73L.cjs +9 -0
  300. package/dist/team-RWIKCLTG.js +9 -0
  301. package/dist/teammate-3C4MLRGH.js +139 -0
  302. package/dist/teammate-7C3UDQSH.cjs +139 -0
  303. package/dist/theme-A2CEHI7W.js +18 -0
  304. package/dist/theme-LNOQOVR4.cjs +18 -0
  305. package/dist/ui/questionModal.cjs +7 -25
  306. package/dist/ui/questionModal.js +6 -24
  307. package/dist/undo-F2IZJQUV.js +10 -0
  308. package/dist/undo-QEV42XLU.cjs +10 -0
  309. package/dist/update-TVAJMMBC.js +82 -0
  310. package/dist/update-Z6BIIQDC.cjs +82 -0
  311. package/package.json +10 -4
  312. package/dist/CommunitySkillsCache-ILWHWE5P.js +0 -7
  313. package/dist/CommunitySkillsCache-KHC6RUJW.cjs +0 -7
  314. package/dist/HookManager-X47HCM5G.cjs +0 -6
  315. package/dist/HookManager-ZXKHCD7U.js +0 -6
  316. package/dist/MemoryManager-6ZT7IDO5.cjs +0 -7
  317. package/dist/MemoryManager-AJGS5AKB.js +0 -7
  318. package/dist/PermissionManager-HG6W2DGU.cjs +0 -10
  319. package/dist/SessionManager-BJ2G6VV4.cjs +0 -9
  320. package/dist/SessionManager-ENPGYK5J.js +0 -9
  321. package/dist/SkillsRegistry-6ZFOCT25.cjs +0 -8
  322. package/dist/SkillsRegistry-C2SHOZ5D.js +0 -8
  323. package/dist/about-BIZH6I2U.cjs +0 -11
  324. package/dist/about-PPIVMAPA.js +0 -11
  325. package/dist/add-dir-7FD4DMDA.cjs +0 -9
  326. package/dist/add-dir-LOYJ4YB5.js +0 -9
  327. package/dist/agents-2Y6ASV7C.js +0 -10
  328. package/dist/agents-UOSPKLQL.cjs +0 -10
  329. package/dist/agents-new-23NSGAM5.js +0 -13
  330. package/dist/agents-new-WI2EL7IJ.cjs +0 -13
  331. package/dist/automode-LGWTY3UX.js +0 -9
  332. package/dist/automode-WLBQ7MN7.cjs +0 -9
  333. package/dist/chunk-5UBW2BGC.js +0 -33
  334. package/dist/chunk-AXP53LTU.cjs +0 -169
  335. package/dist/chunk-IZBCMJHJ.cjs +0 -33
  336. package/dist/completion-7WGMHKOR.cjs +0 -13
  337. package/dist/completion-KH33NSGP.js +0 -13
  338. package/dist/constants-RBQTR32A.cjs +0 -20
  339. package/dist/export-3QN3IH7A.js +0 -11
  340. package/dist/export-BI54X3MP.cjs +0 -11
  341. package/dist/feedback-TBF2CUJR.js +0 -14
  342. package/dist/feedback-XXHPSUUO.cjs +0 -14
  343. package/dist/formatters-N5IJKYZY.cjs +0 -8
  344. package/dist/formatters-UG6VZJJ5.js +0 -8
  345. package/dist/help-4VSLIMP4.cjs +0 -11
  346. package/dist/history-73VBEMSI.cjs +0 -13
  347. package/dist/hooks-62UDQBGH.cjs +0 -12
  348. package/dist/hooks-XORDJD5X.js +0 -12
  349. package/dist/i18n-X2IU2EZD.cjs +0 -32
  350. package/dist/ide-RPKZALQV.js +0 -11
  351. package/dist/ide-YMNXJB6A.cjs +0 -11
  352. package/dist/init-J5HR4R7U.js +0 -9
  353. package/dist/init-JCC7RVMC.cjs +0 -9
  354. package/dist/language-AZISJCEZ.js +0 -16
  355. package/dist/language-F65RA6FZ.cjs +0 -16
  356. package/dist/localProjectPermissions-2EATUDZM.cjs +0 -17
  357. package/dist/login-5HLPMECE.js +0 -18
  358. package/dist/login-ISWYYBXP.cjs +0 -18
  359. package/dist/logout-3EKZM5J3.cjs +0 -16
  360. package/dist/logout-GE7TSZ24.js +0 -16
  361. package/dist/mcp-EW64QRFA.cjs +0 -15
  362. package/dist/mcp-VHS7AMF2.js +0 -15
  363. package/dist/memory-2I473RU3.js +0 -9
  364. package/dist/memory-JZ6NPSP3.cjs +0 -9
  365. package/dist/model-GXZLARPT.js +0 -9
  366. package/dist/model-Y274DBDO.cjs +0 -9
  367. package/dist/new-BG5VIGZ7.cjs +0 -9
  368. package/dist/new-YXFDQOA7.js +0 -9
  369. package/dist/permissions-QILEAGBP.cjs +0 -12
  370. package/dist/permissions-WVEOVMWO.js +0 -12
  371. package/dist/quit-NC32OEJG.cjs +0 -9
  372. package/dist/quit-WRRIGU33.js +0 -9
  373. package/dist/resume-GJIKIDPR.cjs +0 -12
  374. package/dist/resume-RMJNCAOK.js +0 -12
  375. package/dist/search-UIWIXB73.js +0 -14
  376. package/dist/search-WQNXDA2E.cjs +0 -14
  377. package/dist/sessions-HPFX2GDD.js +0 -9
  378. package/dist/sessions-SAQU6MFA.cjs +0 -9
  379. package/dist/share-IE6UTPKF.cjs +0 -13
  380. package/dist/share-NQXIMFSQ.js +0 -13
  381. package/dist/skills-YTYGART7.cjs +0 -13
  382. package/dist/skills-new-3WCU3CWB.js +0 -14
  383. package/dist/skills-new-O5LFVFZU.cjs +0 -14
  384. package/dist/slashCommands-3FFAL4SL.js +0 -55
  385. package/dist/slashCommands-JASFW3E4.cjs +0 -55
  386. package/dist/status-4NDGXPIM.js +0 -10
  387. package/dist/status-RHJIBHP2.cjs +0 -10
  388. package/dist/sync-3GFSEIAZ.js +0 -16
  389. package/dist/sync-6M3WRKMH.cjs +0 -39
  390. package/dist/sync-CQNQDNTJ.cjs +0 -16
  391. package/dist/theme-EMJGULMI.cjs +0 -16
  392. package/dist/theme-FGDSXNU3.js +0 -16
  393. package/dist/undo-CTXQYE7C.cjs +0 -9
  394. package/dist/undo-HX2ZMECP.js +0 -9
@@ -0,0 +1,1176 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/providers/OllamaProvider.ts
2
+ var OllamaProvider = class {
3
+ constructor(config) {
4
+ this.disableTools = false;
5
+ this.baseUrl = config.baseUrl || "http://localhost:11434";
6
+ this.model = config.model || "llama3.2:latest";
7
+ }
8
+ getName() {
9
+ return "ollama";
10
+ }
11
+ setModel(model) {
12
+ this.model = model;
13
+ }
14
+ async listModels() {
15
+ try {
16
+ const response = await fetch(`${this.baseUrl}/api/tags`);
17
+ if (!response.ok) {
18
+ return [];
19
+ }
20
+ const data = await response.json();
21
+ return data.models.map((m) => m.name);
22
+ } catch (e) {
23
+ return [];
24
+ }
25
+ }
26
+ async isAvailable() {
27
+ try {
28
+ const response = await fetch(`${this.baseUrl}/api/tags`);
29
+ return response.ok;
30
+ } catch (e2) {
31
+ return false;
32
+ }
33
+ }
34
+ async complete(request) {
35
+ const messages = request.messages.map((msg) => {
36
+ const mapped = {
37
+ role: msg.role,
38
+ content: _nullishCoalesce(msg.content, () => ( ""))
39
+ };
40
+ if (msg.name) {
41
+ mapped.name = msg.name;
42
+ }
43
+ if (msg.role === "tool" && msg.tool_call_id) {
44
+ mapped.tool_call_id = msg.tool_call_id;
45
+ }
46
+ if (msg.role === "assistant" && msg.tool_calls) {
47
+ mapped.tool_calls = msg.tool_calls;
48
+ }
49
+ return mapped;
50
+ });
51
+ const body = {
52
+ model: request.model || this.model,
53
+ messages,
54
+ stream: request.stream || false
55
+ };
56
+ if (request.temperature !== void 0) {
57
+ body.options = { temperature: request.temperature };
58
+ }
59
+ if (!this.disableTools && request.tools && request.tools.length > 0) {
60
+ body.tools = request.tools.map((tool) => ({
61
+ type: "function",
62
+ function: {
63
+ name: tool.name,
64
+ description: tool.description,
65
+ parameters: _nullishCoalesce(tool.parameters, () => ( { type: "object", properties: {} }))
66
+ }
67
+ }));
68
+ }
69
+ const response = await fetch(`${this.baseUrl}/api/chat`, {
70
+ method: "POST",
71
+ headers: {
72
+ "Content-Type": "application/json"
73
+ },
74
+ body: JSON.stringify(body),
75
+ signal: request.signal
76
+ });
77
+ if (!response.ok) {
78
+ let errorDetail = "";
79
+ try {
80
+ const errorBody = await response.text();
81
+ errorDetail = errorBody ? `: ${errorBody}` : "";
82
+ if (errorBody.includes("does not support tools") && body.tools) {
83
+ console.warn(`Model ${body.model} does not support tools. Retrying without tool support.`);
84
+ this.disableTools = true;
85
+ delete body.tools;
86
+ return this.complete(request);
87
+ }
88
+ } catch (e3) {
89
+ }
90
+ throw new Error(`Ollama API error: ${response.status} ${response.statusText}${errorDetail}`);
91
+ }
92
+ if (request.stream) {
93
+ return this.handleStreamingResponse(response);
94
+ }
95
+ const data = await response.json();
96
+ let toolCalls;
97
+ if (data.message.tool_calls && Array.isArray(data.message.tool_calls)) {
98
+ toolCalls = data.message.tool_calls.map((tc, index) => ({
99
+ id: `ollama-tool-${Date.now()}-${index}`,
100
+ type: "function",
101
+ function: {
102
+ name: tc.function.name,
103
+ // Ollama returns arguments as object, convert to JSON string for consistency
104
+ arguments: JSON.stringify(tc.function.arguments)
105
+ }
106
+ }));
107
+ }
108
+ let usage;
109
+ if (data.prompt_eval_count !== void 0 || data.eval_count !== void 0) {
110
+ usage = {
111
+ promptTokens: _nullishCoalesce(data.prompt_eval_count, () => ( 0)),
112
+ completionTokens: _nullishCoalesce(data.eval_count, () => ( 0)),
113
+ totalTokens: (_nullishCoalesce(data.prompt_eval_count, () => ( 0))) + (_nullishCoalesce(data.eval_count, () => ( 0)))
114
+ };
115
+ }
116
+ return {
117
+ id: `ollama-${Date.now()}`,
118
+ created: Math.floor(new Date(data.created_at).getTime() / 1e3),
119
+ content: data.message.content,
120
+ toolCalls,
121
+ finishReason: _optionalChain([toolCalls, 'optionalAccess', _ => _.length]) ? "tool_calls" : "stop",
122
+ usage,
123
+ raw: data
124
+ };
125
+ }
126
+ async handleStreamingResponse(response) {
127
+ const reader = _optionalChain([response, 'access', _2 => _2.body, 'optionalAccess', _3 => _3.getReader, 'call', _4 => _4()]);
128
+ if (!reader) {
129
+ throw new Error("No response body");
130
+ }
131
+ const decoder = new TextDecoder();
132
+ let fullContent = "";
133
+ let lastData = null;
134
+ try {
135
+ while (true) {
136
+ const { done, value } = await reader.read();
137
+ if (done) break;
138
+ const chunk = decoder.decode(value, { stream: true });
139
+ const lines = chunk.split("\n").filter((line) => line.trim());
140
+ for (const line of lines) {
141
+ try {
142
+ const data = JSON.parse(line);
143
+ fullContent += data.message.content;
144
+ lastData = data;
145
+ } catch (e4) {
146
+ }
147
+ }
148
+ }
149
+ } finally {
150
+ reader.releaseLock();
151
+ }
152
+ return {
153
+ id: `ollama-${Date.now()}`,
154
+ created: lastData ? Math.floor(new Date(lastData.created_at).getTime() / 1e3) : Date.now(),
155
+ content: fullContent,
156
+ raw: lastData
157
+ };
158
+ }
159
+ };
160
+
161
+ // src/providers/OpenAIProvider.ts
162
+ var OpenAIProvider = class {
163
+ constructor(config) {
164
+ this.baseUrl = config.baseUrl || "https://api.openai.com/v1";
165
+ this.apiKey = config.apiKey || "";
166
+ this.model = config.model || "gpt-4o";
167
+ }
168
+ getName() {
169
+ return "openai";
170
+ }
171
+ setModel(model) {
172
+ this.model = model;
173
+ }
174
+ async listModels() {
175
+ return [
176
+ "gpt-4o",
177
+ "gpt-4o-mini",
178
+ "gpt-4-turbo",
179
+ "gpt-4",
180
+ "gpt-3.5-turbo"
181
+ ];
182
+ }
183
+ async isAvailable() {
184
+ try {
185
+ const response = await fetch(`${this.baseUrl}/models`, {
186
+ headers: {
187
+ "Authorization": `Bearer ${this.apiKey}`
188
+ }
189
+ });
190
+ return response.ok;
191
+ } catch (e5) {
192
+ return false;
193
+ }
194
+ }
195
+ async complete(request) {
196
+ const body = {
197
+ model: request.model || this.model,
198
+ messages: request.messages.map((msg) => {
199
+ const mapped = {
200
+ role: msg.role === "system" ? "system" : msg.role === "user" ? "user" : msg.role === "tool" ? "tool" : "assistant",
201
+ content: msg.content
202
+ };
203
+ if (msg.role === "tool" && msg.tool_call_id) {
204
+ mapped.tool_call_id = msg.tool_call_id;
205
+ }
206
+ if (msg.name) {
207
+ mapped.name = msg.name;
208
+ }
209
+ return mapped;
210
+ }),
211
+ temperature: request.temperature || 0.7,
212
+ max_tokens: request.maxTokens
213
+ };
214
+ if (request.tools && request.tools.length > 0) {
215
+ body.tools = request.tools.map((tool) => ({
216
+ type: "function",
217
+ function: {
218
+ name: tool.name,
219
+ description: tool.description,
220
+ parameters: _nullishCoalesce(tool.parameters, () => ( { type: "object", properties: {} }))
221
+ }
222
+ }));
223
+ if (request.toolChoice) {
224
+ body.tool_choice = request.toolChoice;
225
+ }
226
+ }
227
+ const response = await fetch(`${this.baseUrl}/chat/completions`, {
228
+ method: "POST",
229
+ headers: {
230
+ "Content-Type": "application/json",
231
+ "Authorization": `Bearer ${this.apiKey}`
232
+ },
233
+ body: JSON.stringify(body),
234
+ signal: request.signal
235
+ });
236
+ if (!response.ok) {
237
+ const error = await response.text();
238
+ throw new Error(`OpenAI API error: ${response.status} ${error}`);
239
+ }
240
+ const data = await response.json();
241
+ const message = data.choices[0].message;
242
+ const finishReason = data.choices[0].finish_reason;
243
+ let toolCalls;
244
+ if (message.tool_calls && Array.isArray(message.tool_calls)) {
245
+ toolCalls = message.tool_calls.map((tc) => ({
246
+ id: tc.id,
247
+ type: "function",
248
+ function: {
249
+ name: tc.function.name,
250
+ arguments: tc.function.arguments
251
+ }
252
+ }));
253
+ }
254
+ let usage;
255
+ if (data.usage) {
256
+ usage = {
257
+ promptTokens: data.usage.prompt_tokens,
258
+ completionTokens: data.usage.completion_tokens,
259
+ totalTokens: data.usage.total_tokens
260
+ };
261
+ }
262
+ return {
263
+ id: data.id,
264
+ created: data.created,
265
+ content: _nullishCoalesce(message.content, () => ( "")),
266
+ toolCalls,
267
+ finishReason,
268
+ usage,
269
+ raw: data
270
+ };
271
+ }
272
+ };
273
+
274
+ // src/providers/LlamaCppProvider.ts
275
+ var LlamaCppProvider = class {
276
+ constructor(config) {
277
+ const port = config.port || 8080;
278
+ this.baseUrl = config.baseUrl || `http://localhost:${port}`;
279
+ this.model = config.model || "llama-model";
280
+ }
281
+ getName() {
282
+ return "llamacpp";
283
+ }
284
+ setModel(model) {
285
+ this.model = model;
286
+ }
287
+ async listModels() {
288
+ try {
289
+ const response = await fetch(`${this.baseUrl}/v1/models`);
290
+ if (!response.ok) {
291
+ return this.model ? [this.model] : [];
292
+ }
293
+ const data = await response.json();
294
+ return _nullishCoalesce(_optionalChain([data, 'access', _5 => _5.data, 'optionalAccess', _6 => _6.map, 'call', _7 => _7((m) => m.id)]), () => ( [this.model]));
295
+ } catch (e6) {
296
+ return this.model ? [this.model] : [];
297
+ }
298
+ }
299
+ async isAvailable() {
300
+ try {
301
+ const response = await fetch(`${this.baseUrl}/health`);
302
+ return response.ok;
303
+ } catch (e7) {
304
+ return false;
305
+ }
306
+ }
307
+ async complete(request) {
308
+ const body = {
309
+ model: request.model || this.model,
310
+ messages: request.messages.map((msg) => {
311
+ const mapped = {
312
+ role: msg.role,
313
+ content: msg.content
314
+ };
315
+ if (msg.name) mapped.name = msg.name;
316
+ if (msg.role === "tool" && msg.tool_call_id) mapped.tool_call_id = msg.tool_call_id;
317
+ if (msg.role === "assistant" && msg.tool_calls) mapped.tool_calls = msg.tool_calls;
318
+ return mapped;
319
+ }),
320
+ temperature: _nullishCoalesce(request.temperature, () => ( 0.7)),
321
+ max_tokens: _nullishCoalesce(request.maxTokens, () => ( 4096)),
322
+ stream: false
323
+ };
324
+ if (request.tools && request.tools.length > 0) {
325
+ body.tools = request.tools.map((tool) => ({
326
+ type: "function",
327
+ function: {
328
+ name: tool.name,
329
+ description: tool.description,
330
+ parameters: _nullishCoalesce(tool.parameters, () => ( { type: "object", properties: {} }))
331
+ }
332
+ }));
333
+ }
334
+ const response = await fetch(`${this.baseUrl}/v1/chat/completions`, {
335
+ method: "POST",
336
+ headers: {
337
+ "Content-Type": "application/json"
338
+ },
339
+ body: JSON.stringify(body),
340
+ signal: request.signal
341
+ });
342
+ if (!response.ok) {
343
+ throw new Error(`llama.cpp API error: ${response.status} ${response.statusText}`);
344
+ }
345
+ const data = await response.json();
346
+ const choice = data.choices[0];
347
+ let toolCalls;
348
+ if (_optionalChain([choice, 'optionalAccess', _8 => _8.message, 'access', _9 => _9.tool_calls, 'optionalAccess', _10 => _10.length])) {
349
+ toolCalls = choice.message.tool_calls.map((tc) => ({
350
+ id: tc.id,
351
+ type: "function",
352
+ function: {
353
+ name: tc.function.name,
354
+ arguments: tc.function.arguments
355
+ }
356
+ }));
357
+ }
358
+ let usage;
359
+ if (data.usage) {
360
+ usage = {
361
+ promptTokens: data.usage.prompt_tokens,
362
+ completionTokens: data.usage.completion_tokens,
363
+ totalTokens: data.usage.total_tokens
364
+ };
365
+ }
366
+ const finishReason = _optionalChain([toolCalls, 'optionalAccess', _11 => _11.length]) ? "tool_calls" : _optionalChain([choice, 'optionalAccess', _12 => _12.finish_reason]) === "stop" || _optionalChain([choice, 'optionalAccess', _13 => _13.finish_reason]) === "length" || _optionalChain([choice, 'optionalAccess', _14 => _14.finish_reason]) === "content_filter" ? choice.finish_reason : "stop";
367
+ return {
368
+ id: data.id || `llamacpp-${Date.now()}`,
369
+ created: data.created || Math.floor(Date.now() / 1e3),
370
+ content: _nullishCoalesce(_optionalChain([choice, 'optionalAccess', _15 => _15.message, 'access', _16 => _16.content]), () => ( "")),
371
+ toolCalls,
372
+ finishReason,
373
+ usage,
374
+ raw: data
375
+ };
376
+ }
377
+ };
378
+
379
+ // src/providers/OpenRouterClient.ts
380
+ function sanitizeMessages(messages) {
381
+ return messages.map((msg) => {
382
+ const sanitized = {
383
+ role: msg.role,
384
+ content: msg.content
385
+ };
386
+ if (msg.role === "tool" && msg.tool_call_id) {
387
+ sanitized.tool_call_id = msg.tool_call_id;
388
+ }
389
+ if (msg.role === "assistant" && _optionalChain([msg, 'access', _17 => _17.tool_calls, 'optionalAccess', _18 => _18.length])) {
390
+ sanitized.tool_calls = msg.tool_calls;
391
+ }
392
+ if (msg.name) {
393
+ sanitized.name = msg.name;
394
+ }
395
+ return sanitized;
396
+ });
397
+ }
398
+ var DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
399
+ var DEFAULT_MAX_RETRIES = 3;
400
+ var MAX_ALLOWED_RETRIES = 5;
401
+ var DEFAULT_RETRY_DELAY = 1e3;
402
+ var DEFAULT_TIMEOUT = 3e4;
403
+ var FRIENDLY_ERRORS = {
404
+ 400: "The request was malformed. This often happens when the context is too long. Try /undo to remove recent turns or /new to start fresh.",
405
+ 401: "Authentication failed. Please verify your API key in ~/.autohand/config.json.",
406
+ 402: "Payment required. Please check your account balance or billing settings.",
407
+ 403: "Access denied. Your API key may not have permission for this model.",
408
+ 404: "The requested model was not found. Use /model to select a different one.",
409
+ 429: "Rate limit exceeded. Please wait a moment and try again, or choose a different model.",
410
+ 500: "The AI service encountered an internal error. Please try again later.",
411
+ 502: "The AI service is temporarily unavailable. Please try again in a few moments.",
412
+ 503: "The AI service is currently overloaded. Please try again later.",
413
+ 504: "The request timed out. The AI service may be experiencing high load."
414
+ };
415
+ var OpenRouterClient = class {
416
+ constructor(settings, networkSettings) {
417
+ this.apiKey = _nullishCoalesce(settings.apiKey, () => ( ""));
418
+ this.baseUrl = _nullishCoalesce(settings.baseUrl, () => ( DEFAULT_BASE_URL));
419
+ this.defaultModel = settings.model;
420
+ const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _19 => _19.maxRetries]), () => ( DEFAULT_MAX_RETRIES));
421
+ this.maxRetries = Math.min(
422
+ Math.max(0, configuredRetries),
423
+ MAX_ALLOWED_RETRIES
424
+ );
425
+ this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _20 => _20.retryDelay]), () => ( DEFAULT_RETRY_DELAY));
426
+ this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _21 => _21.timeout]), () => ( DEFAULT_TIMEOUT));
427
+ }
428
+ setDefaultModel(model) {
429
+ this.defaultModel = model;
430
+ }
431
+ async complete(request) {
432
+ const payload = {
433
+ model: _nullishCoalesce(request.model, () => ( this.defaultModel)),
434
+ messages: sanitizeMessages(request.messages),
435
+ temperature: _nullishCoalesce(request.temperature, () => ( 0.2)),
436
+ max_tokens: _nullishCoalesce(request.maxTokens, () => ( 16e3)),
437
+ // Increased from 1000 to allow large file generation
438
+ stream: _nullishCoalesce(request.stream, () => ( false))
439
+ };
440
+ if (request.tools && request.tools.length > 0) {
441
+ payload.tools = request.tools.map((tool) => ({
442
+ type: "function",
443
+ function: {
444
+ name: tool.name,
445
+ description: tool.description,
446
+ parameters: _nullishCoalesce(tool.parameters, () => ( { type: "object", properties: {} }))
447
+ }
448
+ }));
449
+ if (request.toolChoice) {
450
+ payload.tool_choice = request.toolChoice;
451
+ }
452
+ }
453
+ const model = (_nullishCoalesce(request.model, () => ( this.defaultModel))).toLowerCase();
454
+ if (request.thinkingLevel && request.thinkingLevel !== "normal") {
455
+ if (model.includes("o1") || model.includes("o3")) {
456
+ if (request.thinkingLevel === "extended") {
457
+ payload.reasoning_effort = "high";
458
+ } else if (request.thinkingLevel === "none") {
459
+ payload.reasoning_effort = "low";
460
+ }
461
+ }
462
+ if (model.includes("claude") && request.thinkingLevel === "extended") {
463
+ payload.provider = {
464
+ anthropic: {
465
+ thinking: {
466
+ type: "enabled",
467
+ budget_tokens: 1e4
468
+ }
469
+ }
470
+ };
471
+ }
472
+ }
473
+ const headers = {
474
+ "Content-Type": "application/json",
475
+ "HTTP-Referer": "https://github.com/autohandai/code-cli",
476
+ "X-Title": "autohand-code-cli"
477
+ };
478
+ if (this.apiKey) {
479
+ headers.Authorization = `Bearer ${this.apiKey}`;
480
+ }
481
+ const payloadJson = JSON.stringify(payload);
482
+ const payloadSizeBytes = payloadJson.length;
483
+ const maxPayloadSize = 5 * 1024 * 1024;
484
+ if (payloadSizeBytes > maxPayloadSize) {
485
+ const sizeMB = (payloadSizeBytes / (1024 * 1024)).toFixed(2);
486
+ throw new Error(
487
+ `Request payload too large (${sizeMB}MB). This usually happens when the conversation history grows too long. Try using /undo to remove recent turns or /new to start fresh.`
488
+ );
489
+ }
490
+ let lastError = null;
491
+ for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
492
+ try {
493
+ const response = await this.makeRequest(
494
+ payload,
495
+ headers,
496
+ request.signal,
497
+ payloadJson
498
+ );
499
+ return response;
500
+ } catch (error) {
501
+ lastError = error;
502
+ if (this.isNonRetryableError(error)) {
503
+ throw error;
504
+ }
505
+ if (attempt < this.maxRetries) {
506
+ const delay = this.retryDelay * Math.pow(2, attempt);
507
+ await this.sleep(delay);
508
+ }
509
+ }
510
+ }
511
+ throw _nullishCoalesce(lastError, () => ( new Error("Failed to communicate with the AI service. Please try again.")));
512
+ }
513
+ async makeRequest(payload, headers, signal, preSerializedBody) {
514
+ let response;
515
+ try {
516
+ const timeoutController = new AbortController();
517
+ const timeoutId = setTimeout(
518
+ () => timeoutController.abort(),
519
+ this.timeout
520
+ );
521
+ const combinedSignal = signal ? this.combineSignals(signal, timeoutController.signal) : timeoutController.signal;
522
+ try {
523
+ response = await fetch(`${this.baseUrl}/chat/completions`, {
524
+ method: "POST",
525
+ headers,
526
+ body: _nullishCoalesce(preSerializedBody, () => ( JSON.stringify(payload))),
527
+ signal: combinedSignal
528
+ });
529
+ } finally {
530
+ clearTimeout(timeoutId);
531
+ }
532
+ } catch (error) {
533
+ const err = error;
534
+ if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess', _22 => _22.aborted])) {
535
+ throw new Error("Request cancelled.");
536
+ }
537
+ if (err.name === "AbortError") {
538
+ throw new Error(
539
+ "Request timed out. The AI service may be experiencing high load."
540
+ );
541
+ }
542
+ throw new Error(
543
+ "Unable to connect to the AI service. Please check your internet connection."
544
+ );
545
+ }
546
+ if (!response.ok) {
547
+ throw new Error(await this.buildFriendlyError(response));
548
+ }
549
+ const json = await response.json();
550
+ const message = _optionalChain([json, 'optionalAccess', _23 => _23.choices, 'optionalAccess', _24 => _24[0], 'optionalAccess', _25 => _25.message]);
551
+ const text = _nullishCoalesce(_optionalChain([message, 'optionalAccess', _26 => _26.content]), () => ( ""));
552
+ const finishReason = _optionalChain([json, 'optionalAccess', _27 => _27.choices, 'optionalAccess', _28 => _28[0], 'optionalAccess', _29 => _29.finish_reason]);
553
+ let toolCalls;
554
+ if (_optionalChain([message, 'optionalAccess', _30 => _30.tool_calls]) && Array.isArray(message.tool_calls)) {
555
+ toolCalls = message.tool_calls.map((tc) => {
556
+ const rawArgs = _optionalChain([tc, 'access', _31 => _31.function, 'optionalAccess', _32 => _32.arguments]);
557
+ return {
558
+ id: tc.id,
559
+ type: "function",
560
+ function: {
561
+ name: _nullishCoalesce(_optionalChain([tc, 'access', _33 => _33.function, 'optionalAccess', _34 => _34.name]), () => ( "")),
562
+ arguments: _nullishCoalesce(rawArgs, () => ( "{}"))
563
+ }
564
+ };
565
+ });
566
+ }
567
+ let usage;
568
+ if (_optionalChain([json, 'optionalAccess', _35 => _35.usage])) {
569
+ usage = {
570
+ promptTokens: _nullishCoalesce(json.usage.prompt_tokens, () => ( 0)),
571
+ completionTokens: _nullishCoalesce(json.usage.completion_tokens, () => ( 0)),
572
+ totalTokens: _nullishCoalesce(json.usage.total_tokens, () => ( 0))
573
+ };
574
+ }
575
+ return {
576
+ id: _nullishCoalesce(json.id, () => ( "autohand-local")),
577
+ created: _nullishCoalesce(json.created, () => ( Date.now())),
578
+ content: text,
579
+ toolCalls,
580
+ finishReason,
581
+ usage,
582
+ raw: json
583
+ };
584
+ }
585
+ async buildFriendlyError(response) {
586
+ const status = response.status;
587
+ let errorDetail = "";
588
+ try {
589
+ const body = await response.json();
590
+ errorDetail = _optionalChain([body, 'optionalAccess', _36 => _36.error, 'optionalAccess', _37 => _37.message]) || _optionalChain([body, 'optionalAccess', _38 => _38.error]) || _optionalChain([body, 'optionalAccess', _39 => _39.message]) || "";
591
+ if (typeof errorDetail === "object") {
592
+ errorDetail = JSON.stringify(errorDetail);
593
+ }
594
+ } catch (e8) {
595
+ try {
596
+ errorDetail = await response.text();
597
+ } catch (e9) {
598
+ }
599
+ }
600
+ const friendlyMessage = FRIENDLY_ERRORS[status];
601
+ if (friendlyMessage) {
602
+ return errorDetail ? `${friendlyMessage}
603
+ ${errorDetail}` : friendlyMessage;
604
+ }
605
+ if (status >= 500) {
606
+ const base = "The AI service is temporarily unavailable. Please try again later.";
607
+ return errorDetail ? `${base}
608
+ (${status}: ${errorDetail})` : base;
609
+ }
610
+ if (status >= 400) {
611
+ const base = "The request could not be processed.";
612
+ return errorDetail ? `${base} (${status}: ${errorDetail})` : `${base} (HTTP ${status}) Please try again or adjust your prompt.`;
613
+ }
614
+ return errorDetail ? `An unexpected error occurred: ${errorDetail}` : "An unexpected error occurred. Please try again.";
615
+ }
616
+ isNonRetryableError(error) {
617
+ const message = error.message.toLowerCase();
618
+ if (message.includes("cancelled") || message.includes("aborted")) {
619
+ return true;
620
+ }
621
+ if (message.includes("authentication") || message.includes("api key")) {
622
+ return true;
623
+ }
624
+ if (message.includes("payment") || message.includes("access denied")) {
625
+ return true;
626
+ }
627
+ if (message.includes("not found")) {
628
+ return true;
629
+ }
630
+ return false;
631
+ }
632
+ combineSignals(signal1, signal2) {
633
+ const controller = new AbortController();
634
+ const abort = () => controller.abort();
635
+ signal1.addEventListener("abort", abort);
636
+ signal2.addEventListener("abort", abort);
637
+ if (signal1.aborted || signal2.aborted) {
638
+ controller.abort();
639
+ }
640
+ return controller.signal;
641
+ }
642
+ sleep(ms) {
643
+ return new Promise((resolve) => setTimeout(resolve, ms));
644
+ }
645
+ };
646
+
647
+ // src/providers/OpenRouterProvider.ts
648
+ var OpenRouterProvider = class {
649
+ constructor(config, networkSettings) {
650
+ this.client = new OpenRouterClient(config, networkSettings);
651
+ this.model = config.model;
652
+ }
653
+ getName() {
654
+ return "openrouter";
655
+ }
656
+ setModel(model) {
657
+ this.model = model;
658
+ this.client.setDefaultModel(model);
659
+ }
660
+ async listModels() {
661
+ return [
662
+ "anthropic/claude-3.5-sonnet",
663
+ "anthropic/claude-3-opus",
664
+ "google/gemini-pro-1.5",
665
+ "openai/gpt-4o",
666
+ "x-ai/grok-2-latest",
667
+ "meta-llama/llama-3.1-70b-instruct"
668
+ ];
669
+ }
670
+ async isAvailable() {
671
+ return true;
672
+ }
673
+ async complete(request) {
674
+ return this.client.complete(request);
675
+ }
676
+ };
677
+
678
+ // src/utils/platform.ts
679
+ function isAppleSilicon() {
680
+ return process.platform === "darwin" && process.arch === "arm64";
681
+ }
682
+ function isMLXSupported() {
683
+ return isAppleSilicon();
684
+ }
685
+
686
+ // src/providers/MLXProvider.ts
687
+ var MLXProvider = class {
688
+ constructor(config) {
689
+ const port = config.port || 8080;
690
+ this.baseUrl = config.baseUrl || `http://localhost:${port}`;
691
+ this.model = config.model || "mlx-model";
692
+ }
693
+ getName() {
694
+ return "mlx";
695
+ }
696
+ setModel(model) {
697
+ this.model = model;
698
+ }
699
+ async listModels() {
700
+ if (!isMLXSupported()) {
701
+ return [];
702
+ }
703
+ try {
704
+ const response = await fetch(`${this.baseUrl}/v1/models`);
705
+ if (!response.ok) {
706
+ return this.model ? [this.model] : [];
707
+ }
708
+ const data = await response.json();
709
+ return _nullishCoalesce(_optionalChain([data, 'access', _40 => _40.data, 'optionalAccess', _41 => _41.map, 'call', _42 => _42((m) => m.id)]), () => ( (this.model ? [this.model] : [])));
710
+ } catch (e10) {
711
+ return this.model ? [this.model] : [];
712
+ }
713
+ }
714
+ async isAvailable() {
715
+ if (!isMLXSupported()) {
716
+ return false;
717
+ }
718
+ try {
719
+ const response = await fetch(`${this.baseUrl}/v1/models`);
720
+ return response.ok;
721
+ } catch (e11) {
722
+ return false;
723
+ }
724
+ }
725
+ async complete(request) {
726
+ if (!isMLXSupported()) {
727
+ throw new Error("MLX is only supported on macOS with Apple Silicon");
728
+ }
729
+ const body = {
730
+ model: request.model || this.model,
731
+ messages: request.messages.map((msg) => {
732
+ const mapped = {
733
+ role: msg.role,
734
+ content: msg.content
735
+ };
736
+ if (msg.name) mapped.name = msg.name;
737
+ if (msg.role === "tool" && msg.tool_call_id) mapped.tool_call_id = msg.tool_call_id;
738
+ if (msg.role === "assistant" && msg.tool_calls) mapped.tool_calls = msg.tool_calls;
739
+ return mapped;
740
+ }),
741
+ temperature: _nullishCoalesce(request.temperature, () => ( 0.7)),
742
+ max_tokens: _nullishCoalesce(request.maxTokens, () => ( 4096)),
743
+ stream: false
744
+ };
745
+ if (request.tools && request.tools.length > 0) {
746
+ body.tools = request.tools.map((tool) => ({
747
+ type: "function",
748
+ function: {
749
+ name: tool.name,
750
+ description: tool.description,
751
+ parameters: _nullishCoalesce(tool.parameters, () => ( { type: "object", properties: {} }))
752
+ }
753
+ }));
754
+ }
755
+ const response = await fetch(`${this.baseUrl}/v1/chat/completions`, {
756
+ method: "POST",
757
+ headers: {
758
+ "Content-Type": "application/json"
759
+ },
760
+ body: JSON.stringify(body),
761
+ signal: request.signal
762
+ });
763
+ if (!response.ok) {
764
+ throw new Error(`MLX API error: ${response.status} ${response.statusText}`);
765
+ }
766
+ const data = await response.json();
767
+ const choice = data.choices[0];
768
+ let toolCalls;
769
+ if (_optionalChain([choice, 'optionalAccess', _43 => _43.message, 'access', _44 => _44.tool_calls, 'optionalAccess', _45 => _45.length])) {
770
+ toolCalls = choice.message.tool_calls.map((tc) => ({
771
+ id: tc.id,
772
+ type: "function",
773
+ function: {
774
+ name: tc.function.name,
775
+ arguments: tc.function.arguments
776
+ }
777
+ }));
778
+ }
779
+ let usage;
780
+ if (data.usage) {
781
+ usage = {
782
+ promptTokens: data.usage.prompt_tokens,
783
+ completionTokens: data.usage.completion_tokens,
784
+ totalTokens: data.usage.total_tokens
785
+ };
786
+ }
787
+ const finishReason = _optionalChain([toolCalls, 'optionalAccess', _46 => _46.length]) ? "tool_calls" : _optionalChain([choice, 'optionalAccess', _47 => _47.finish_reason]) === "stop" || _optionalChain([choice, 'optionalAccess', _48 => _48.finish_reason]) === "length" || _optionalChain([choice, 'optionalAccess', _49 => _49.finish_reason]) === "content_filter" ? choice.finish_reason : "stop";
788
+ return {
789
+ id: data.id || `mlx-${Date.now()}`,
790
+ created: data.created || Math.floor(Date.now() / 1e3),
791
+ content: _nullishCoalesce(_optionalChain([choice, 'optionalAccess', _50 => _50.message, 'access', _51 => _51.content]), () => ( "")),
792
+ toolCalls,
793
+ finishReason,
794
+ usage,
795
+ raw: data
796
+ };
797
+ }
798
+ };
799
+
800
+ // src/providers/LLMGatewayClient.ts
801
+ function sanitizeMessages2(messages) {
802
+ return messages.map((msg) => {
803
+ const sanitized = {
804
+ role: msg.role,
805
+ content: msg.content
806
+ };
807
+ if (msg.role === "tool" && msg.tool_call_id) {
808
+ sanitized.tool_call_id = msg.tool_call_id;
809
+ }
810
+ if (msg.role === "assistant" && _optionalChain([msg, 'access', _52 => _52.tool_calls, 'optionalAccess', _53 => _53.length])) {
811
+ sanitized.tool_calls = msg.tool_calls;
812
+ }
813
+ if (msg.name) {
814
+ sanitized.name = msg.name;
815
+ }
816
+ return sanitized;
817
+ });
818
+ }
819
+ var DEFAULT_BASE_URL2 = "https://api.llmgateway.io/v1";
820
+ var DEFAULT_MAX_RETRIES2 = 3;
821
+ var MAX_ALLOWED_RETRIES2 = 5;
822
+ var DEFAULT_RETRY_DELAY2 = 1e3;
823
+ var DEFAULT_TIMEOUT2 = 3e4;
824
+ var FRIENDLY_ERRORS2 = {
825
+ 400: "The request was malformed. This often happens when the context is too long. Try /undo to remove recent turns or /new to start fresh.",
826
+ 401: "Authentication failed. Please verify your LLM Gateway API key in ~/.autohand/config.json.",
827
+ 402: "Payment required. Please check your LLM Gateway account balance or billing settings.",
828
+ 403: "Access denied. Your API key may not have permission for this model.",
829
+ 404: "The requested model was not found. Use /model to select a different one.",
830
+ 429: "Rate limit exceeded. Please wait a moment and try again, or choose a different model.",
831
+ 500: "The LLM Gateway service encountered an internal error. Please try again later.",
832
+ 502: "The LLM Gateway service is temporarily unavailable. Please try again in a few moments.",
833
+ 503: "The LLM Gateway service is currently overloaded. Please try again later.",
834
+ 504: "The request timed out. The service may be experiencing high load."
835
+ };
836
+ var LLMGatewayClient = class {
837
+ constructor(settings, networkSettings) {
838
+ this.apiKey = _nullishCoalesce(settings.apiKey, () => ( ""));
839
+ this.baseUrl = _nullishCoalesce(settings.baseUrl, () => ( DEFAULT_BASE_URL2));
840
+ this.defaultModel = settings.model;
841
+ const configuredRetries = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _54 => _54.maxRetries]), () => ( DEFAULT_MAX_RETRIES2));
842
+ this.maxRetries = Math.min(
843
+ Math.max(0, configuredRetries),
844
+ MAX_ALLOWED_RETRIES2
845
+ );
846
+ this.retryDelay = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _55 => _55.retryDelay]), () => ( DEFAULT_RETRY_DELAY2));
847
+ this.timeout = _nullishCoalesce(_optionalChain([networkSettings, 'optionalAccess', _56 => _56.timeout]), () => ( DEFAULT_TIMEOUT2));
848
+ }
849
+ setDefaultModel(model) {
850
+ this.defaultModel = model;
851
+ }
852
+ async complete(request) {
853
+ const payload = {
854
+ model: _nullishCoalesce(request.model, () => ( this.defaultModel)),
855
+ messages: sanitizeMessages2(request.messages),
856
+ temperature: _nullishCoalesce(request.temperature, () => ( 0.2)),
857
+ max_tokens: _nullishCoalesce(request.maxTokens, () => ( 16e3)),
858
+ stream: _nullishCoalesce(request.stream, () => ( false))
859
+ };
860
+ if (request.tools && request.tools.length > 0) {
861
+ payload.tools = request.tools.map((tool) => ({
862
+ type: "function",
863
+ function: {
864
+ name: tool.name,
865
+ description: tool.description,
866
+ parameters: _nullishCoalesce(tool.parameters, () => ( { type: "object", properties: {} }))
867
+ }
868
+ }));
869
+ if (request.toolChoice) {
870
+ payload.tool_choice = request.toolChoice;
871
+ }
872
+ }
873
+ const headers = {
874
+ "Content-Type": "application/json"
875
+ };
876
+ if (this.apiKey) {
877
+ headers.Authorization = `Bearer ${this.apiKey}`;
878
+ }
879
+ const payloadJson = JSON.stringify(payload);
880
+ const payloadSizeBytes = payloadJson.length;
881
+ const maxPayloadSize = 5 * 1024 * 1024;
882
+ if (payloadSizeBytes > maxPayloadSize) {
883
+ const sizeMB = (payloadSizeBytes / (1024 * 1024)).toFixed(2);
884
+ throw new Error(
885
+ `Request payload too large (${sizeMB}MB). This usually happens when the conversation history grows too long. Try using /undo to remove recent turns or /new to start fresh.`
886
+ );
887
+ }
888
+ let lastError = null;
889
+ for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
890
+ try {
891
+ const response = await this.makeRequest(
892
+ payload,
893
+ headers,
894
+ request.signal,
895
+ payloadJson
896
+ );
897
+ return response;
898
+ } catch (error) {
899
+ lastError = error;
900
+ if (this.isNonRetryableError(error)) {
901
+ throw error;
902
+ }
903
+ if (attempt < this.maxRetries) {
904
+ const delay = this.retryDelay * Math.pow(2, attempt);
905
+ await this.sleep(delay);
906
+ }
907
+ }
908
+ }
909
+ throw _nullishCoalesce(lastError, () => ( new Error("Failed to communicate with LLM Gateway. Please try again.")));
910
+ }
911
+ async makeRequest(payload, headers, signal, preSerializedBody) {
912
+ let response;
913
+ try {
914
+ const timeoutController = new AbortController();
915
+ const timeoutId = setTimeout(
916
+ () => timeoutController.abort(),
917
+ this.timeout
918
+ );
919
+ const combinedSignal = signal ? this.combineSignals(signal, timeoutController.signal) : timeoutController.signal;
920
+ try {
921
+ response = await fetch(`${this.baseUrl}/chat/completions`, {
922
+ method: "POST",
923
+ headers,
924
+ body: _nullishCoalesce(preSerializedBody, () => ( JSON.stringify(payload))),
925
+ signal: combinedSignal
926
+ });
927
+ } finally {
928
+ clearTimeout(timeoutId);
929
+ }
930
+ } catch (error) {
931
+ const err = error;
932
+ if (err.name === "AbortError" && _optionalChain([signal, 'optionalAccess', _57 => _57.aborted])) {
933
+ throw new Error("Request cancelled.");
934
+ }
935
+ if (err.name === "AbortError") {
936
+ throw new Error(
937
+ "Request timed out. The LLM Gateway service may be experiencing high load."
938
+ );
939
+ }
940
+ throw new Error(
941
+ "Unable to connect to LLM Gateway. Please check your internet connection."
942
+ );
943
+ }
944
+ if (!response.ok) {
945
+ throw new Error(await this.buildFriendlyError(response));
946
+ }
947
+ const json = await response.json();
948
+ const message = _optionalChain([json, 'optionalAccess', _58 => _58.choices, 'optionalAccess', _59 => _59[0], 'optionalAccess', _60 => _60.message]);
949
+ const text = _nullishCoalesce(_optionalChain([message, 'optionalAccess', _61 => _61.content]), () => ( ""));
950
+ const finishReason = _optionalChain([json, 'optionalAccess', _62 => _62.choices, 'optionalAccess', _63 => _63[0], 'optionalAccess', _64 => _64.finish_reason]);
951
+ let toolCalls;
952
+ if (_optionalChain([message, 'optionalAccess', _65 => _65.tool_calls]) && Array.isArray(message.tool_calls)) {
953
+ toolCalls = message.tool_calls.map((tc) => {
954
+ const rawArgs = _optionalChain([tc, 'access', _66 => _66.function, 'optionalAccess', _67 => _67.arguments]);
955
+ return {
956
+ id: tc.id,
957
+ type: "function",
958
+ function: {
959
+ name: _nullishCoalesce(_optionalChain([tc, 'access', _68 => _68.function, 'optionalAccess', _69 => _69.name]), () => ( "")),
960
+ arguments: _nullishCoalesce(rawArgs, () => ( "{}"))
961
+ }
962
+ };
963
+ });
964
+ }
965
+ let usage;
966
+ if (_optionalChain([json, 'optionalAccess', _70 => _70.usage])) {
967
+ usage = {
968
+ promptTokens: _nullishCoalesce(json.usage.prompt_tokens, () => ( 0)),
969
+ completionTokens: _nullishCoalesce(json.usage.completion_tokens, () => ( 0)),
970
+ totalTokens: _nullishCoalesce(json.usage.total_tokens, () => ( 0))
971
+ };
972
+ }
973
+ return {
974
+ id: _nullishCoalesce(json.id, () => ( "llmgateway-response")),
975
+ created: _nullishCoalesce(json.created, () => ( Date.now())),
976
+ content: text,
977
+ toolCalls,
978
+ finishReason,
979
+ usage,
980
+ raw: json
981
+ };
982
+ }
983
+ async buildFriendlyError(response) {
984
+ const status = response.status;
985
+ let errorDetail = "";
986
+ try {
987
+ const body = await response.json();
988
+ errorDetail = _optionalChain([body, 'optionalAccess', _71 => _71.error, 'optionalAccess', _72 => _72.message]) || _optionalChain([body, 'optionalAccess', _73 => _73.error]) || _optionalChain([body, 'optionalAccess', _74 => _74.message]) || "";
989
+ if (typeof errorDetail === "object") {
990
+ errorDetail = JSON.stringify(errorDetail);
991
+ }
992
+ } catch (e12) {
993
+ try {
994
+ errorDetail = await response.text();
995
+ } catch (e13) {
996
+ }
997
+ }
998
+ const friendlyMessage = FRIENDLY_ERRORS2[status];
999
+ if (friendlyMessage) {
1000
+ return errorDetail ? `${friendlyMessage}
1001
+ ${errorDetail}` : friendlyMessage;
1002
+ }
1003
+ if (status >= 500) {
1004
+ const base = "The LLM Gateway service is temporarily unavailable. Please try again later.";
1005
+ return errorDetail ? `${base}
1006
+ (${status}: ${errorDetail})` : base;
1007
+ }
1008
+ if (status >= 400) {
1009
+ const base = "The request could not be processed.";
1010
+ return errorDetail ? `${base} (${status}: ${errorDetail})` : `${base} (HTTP ${status}) Please try again or adjust your prompt.`;
1011
+ }
1012
+ return errorDetail ? `An unexpected error occurred: ${errorDetail}` : "An unexpected error occurred. Please try again.";
1013
+ }
1014
+ isNonRetryableError(error) {
1015
+ const message = error.message.toLowerCase();
1016
+ if (message.includes("cancelled") || message.includes("aborted")) {
1017
+ return true;
1018
+ }
1019
+ if (message.includes("authentication") || message.includes("api key")) {
1020
+ return true;
1021
+ }
1022
+ if (message.includes("payment") || message.includes("access denied")) {
1023
+ return true;
1024
+ }
1025
+ if (message.includes("not found")) {
1026
+ return true;
1027
+ }
1028
+ return false;
1029
+ }
1030
+ combineSignals(signal1, signal2) {
1031
+ const controller = new AbortController();
1032
+ const abort = () => controller.abort();
1033
+ signal1.addEventListener("abort", abort);
1034
+ signal2.addEventListener("abort", abort);
1035
+ if (signal1.aborted || signal2.aborted) {
1036
+ controller.abort();
1037
+ }
1038
+ return controller.signal;
1039
+ }
1040
+ sleep(ms) {
1041
+ return new Promise((resolve) => setTimeout(resolve, ms));
1042
+ }
1043
+ };
1044
+
1045
+ // src/providers/LLMGatewayProvider.ts
1046
+ var LLMGatewayProvider = class {
1047
+ constructor(config, networkSettings) {
1048
+ this.client = new LLMGatewayClient(config, networkSettings);
1049
+ this.model = config.model;
1050
+ }
1051
+ getName() {
1052
+ return "llmgateway";
1053
+ }
1054
+ setModel(model) {
1055
+ this.model = model;
1056
+ this.client.setDefaultModel(model);
1057
+ }
1058
+ async listModels() {
1059
+ return [
1060
+ "gpt-4o",
1061
+ "gpt-4o-mini",
1062
+ "gpt-4-turbo",
1063
+ "claude-3-5-sonnet-20241022",
1064
+ "claude-3-5-haiku-20241022",
1065
+ "gemini-1.5-pro",
1066
+ "gemini-1.5-flash"
1067
+ ];
1068
+ }
1069
+ async isAvailable() {
1070
+ return true;
1071
+ }
1072
+ async complete(request) {
1073
+ return this.client.complete(request);
1074
+ }
1075
+ };
1076
+
1077
+ // src/providers/ProviderFactory.ts
1078
+ var ProviderNotConfiguredError = class extends Error {
1079
+ constructor(providerName) {
1080
+ super(`PROVIDER_NOT_CONFIGURED:${providerName}`);
1081
+ this.providerName = providerName;
1082
+ this.name = "ProviderNotConfiguredError";
1083
+ }
1084
+ };
1085
+ var UnconfiguredProvider = class {
1086
+ constructor(providerName) {
1087
+ this.providerName = providerName;
1088
+ }
1089
+ getName() {
1090
+ return "unconfigured";
1091
+ }
1092
+ async complete(_request) {
1093
+ throw new ProviderNotConfiguredError(this.providerName);
1094
+ }
1095
+ async listModels() {
1096
+ return [];
1097
+ }
1098
+ async isAvailable() {
1099
+ return false;
1100
+ }
1101
+ setModel(_model) {
1102
+ }
1103
+ };
1104
+ var ProviderFactory = class {
1105
+ /**
1106
+ * Create an LLM provider based on configuration.
1107
+ * Returns an UnconfiguredProvider if the selected provider is not configured,
1108
+ * allowing the agent to handle it gracefully instead of crashing.
1109
+ */
1110
+ static create(config) {
1111
+ const providerName = config.provider || "openrouter";
1112
+ switch (providerName) {
1113
+ case "ollama":
1114
+ if (!config.ollama) {
1115
+ return new UnconfiguredProvider("ollama");
1116
+ }
1117
+ return new OllamaProvider(config.ollama);
1118
+ case "openai":
1119
+ if (!config.openai) {
1120
+ return new UnconfiguredProvider("openai");
1121
+ }
1122
+ return new OpenAIProvider(config.openai);
1123
+ case "llamacpp":
1124
+ if (!config.llamacpp) {
1125
+ return new UnconfiguredProvider("llamacpp");
1126
+ }
1127
+ return new LlamaCppProvider(config.llamacpp);
1128
+ case "mlx":
1129
+ if (!config.mlx) {
1130
+ return new UnconfiguredProvider("mlx");
1131
+ }
1132
+ return new MLXProvider(config.mlx);
1133
+ case "llmgateway":
1134
+ if (!config.llmgateway) {
1135
+ return new UnconfiguredProvider("llmgateway");
1136
+ }
1137
+ return new LLMGatewayProvider(config.llmgateway, config.network);
1138
+ case "openrouter":
1139
+ default:
1140
+ if (!config.openrouter) {
1141
+ return new UnconfiguredProvider("openrouter");
1142
+ }
1143
+ return new OpenRouterProvider(config.openrouter);
1144
+ }
1145
+ }
1146
+ /**
1147
+ * Get all available provider names.
1148
+ * MLX is only included on Apple Silicon (macOS + arm64).
1149
+ */
1150
+ static getProviderNames() {
1151
+ const providers = ["openrouter", "ollama", "openai", "llamacpp", "llmgateway"];
1152
+ if (isMLXSupported()) {
1153
+ providers.push("mlx");
1154
+ }
1155
+ return providers;
1156
+ }
1157
+ /**
1158
+ * Check if a provider name is valid.
1159
+ * Note: This checks if the name is a valid provider type, not if it's available on this platform.
1160
+ * MLX is always a valid provider name, but may not be available on non-Apple Silicon systems.
1161
+ */
1162
+ static isValidProvider(name) {
1163
+ const allProviders = ["openrouter", "ollama", "openai", "llamacpp", "mlx", "llmgateway"];
1164
+ return allProviders.includes(name);
1165
+ }
1166
+ };
1167
+
1168
+
1169
+
1170
+
1171
+ exports.ProviderNotConfiguredError = ProviderNotConfiguredError; exports.ProviderFactory = ProviderFactory;
1172
+ /**
1173
+ * @license
1174
+ * Copyright 2025 Autohand AI LLC
1175
+ * SPDX-License-Identifier: Apache-2.0
1176
+ */