autohand-cli 0.8.2 → 0.9.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 (551) hide show
  1. package/README.md +173 -74
  2. package/dist/AgentRegistry-EGBDIUAK.cjs +10 -0
  3. package/dist/{AgentRegistry-7LDL5HJH.js → AgentRegistry-XPWSVO3Q.js} +3 -3
  4. package/dist/{AutomodeManager-MWLKGPZK.js → AutomodeManager-APLLPEYJ.js} +32 -18
  5. package/dist/{AutomodeManager-NYIZNODK.cjs → AutomodeManager-MPSXT2RH.cjs} +38 -24
  6. package/dist/CommunitySkillsCache-2OIUV227.cjs +8 -0
  7. package/dist/CommunitySkillsCache-ZEQWP6YM.js +8 -0
  8. package/dist/GitHubRegistryFetcher-CYJLF2XL.cjs +7 -0
  9. package/dist/{GitHubRegistryFetcher-6JQ5JEDZ.js → GitHubRegistryFetcher-J2BWPXJF.js} +2 -2
  10. package/dist/HookManager-CWLTFKWO.js +7 -0
  11. package/dist/HookManager-TMAJQU4S.cjs +7 -0
  12. package/dist/{ImportWizard-35YBJ4AM.cjs → ImportWizard-MQXEED2U.cjs} +41 -17
  13. package/dist/{ImportWizard-XH7CINCH.js → ImportWizard-QBKQEXDW.js} +35 -11
  14. package/dist/LearnAdvisor-46FG2XIP.js +9 -0
  15. package/dist/LearnAdvisor-XBRDNAGH.cjs +9 -0
  16. package/dist/McpClientManager-BNSKLHIN.cjs +8 -0
  17. package/dist/{McpClientManager-7RM6YT35.js → McpClientManager-SL35BR24.js} +2 -2
  18. package/dist/MemoryManager-34L4YOKA.cjs +8 -0
  19. package/dist/MemoryManager-WJMLPWGU.js +8 -0
  20. package/dist/NVIDIAProvider-2HR737UE.js +14 -0
  21. package/dist/NVIDIAProvider-MVTL62PR.cjs +14 -0
  22. package/dist/PermissionManager-5OOJ7FAT.cjs +11 -0
  23. package/dist/{PermissionManager-ATUV34LQ.js → PermissionManager-KMYILJ4Z.js} +4 -4
  24. package/dist/{ProjectProfiler-ZDWR2ODG.cjs → ProjectProfiler-CDAE7ECW.cjs} +2 -1
  25. package/dist/{ProjectProfiler-UMJJSOCE.js → ProjectProfiler-NZTJDRHD.js} +2 -1
  26. package/dist/ProviderFactory-C3YPXTDD.cjs +11 -0
  27. package/dist/ProviderFactory-HFPRVQ25.js +11 -0
  28. package/dist/SessionManager-PNBTJJTQ.js +10 -0
  29. package/dist/SessionManager-WAPTFMDO.cjs +10 -0
  30. package/dist/SkillsRegistry-4RRD5GMX.js +9 -0
  31. package/dist/SkillsRegistry-7AJP74GJ.cjs +9 -0
  32. package/dist/SubAgent-FDIH3DXB.js +11 -0
  33. package/dist/SubAgent-HVL2ICVZ.cjs +11 -0
  34. package/dist/{SyncApiClient-LVIO4C2S.js → SyncApiClient-LRPFNCKJ.js} +2 -2
  35. package/dist/SyncApiClient-VMBOLQ6H.cjs +11 -0
  36. package/dist/about-BW3PDZUU.js +14 -0
  37. package/dist/about-FCAX37YC.cjs +14 -0
  38. package/dist/acp-EOETGAHC.cjs +1517 -0
  39. package/dist/acp-VHEL7BOW.js +1517 -0
  40. package/dist/actionExecutor-33I47NZS.js +24 -0
  41. package/dist/actionExecutor-4YBMR3YH.cjs +24 -0
  42. package/dist/add-dir-7SS6KSH5.cjs +11 -0
  43. package/dist/add-dir-VFX7QT4E.js +11 -0
  44. package/dist/agent-DMRUFU4M.cjs +116 -0
  45. package/dist/agent-WCJEYQJT.js +116 -0
  46. package/dist/agents/builtin/code-cleaner.md +1 -1
  47. package/dist/agents/builtin/docs-writer.md +1 -1
  48. package/dist/agents/builtin/researcher.md +2 -2
  49. package/dist/agents/builtin/reviewer.md +1 -1
  50. package/dist/agents/builtin/tester.md +1 -1
  51. package/dist/agents/builtin/todo-resolver.md +1 -1
  52. package/dist/agents-CHROO3VU.cjs +17 -0
  53. package/dist/agents-UVDUL65K.js +17 -0
  54. package/dist/agents-new-AUBWSOXP.js +17 -0
  55. package/dist/agents-new-Y562WC47.cjs +17 -0
  56. package/dist/{autoSkill-6TGBTEQD.js → autoSkill-EFMK6WU6.js} +3 -3
  57. package/dist/autoSkill-YOLLFTP2.cjs +20 -0
  58. package/dist/automode-BMYSRM34.js +10 -0
  59. package/dist/automode-DBLKTTKD.cjs +10 -0
  60. package/dist/browserToolBridge-BXRQB4B4.cjs +58 -0
  61. package/dist/browserToolBridge-F5N66PE7.js +58 -0
  62. package/dist/{cc-7LEIJ3KF.js → cc-AYEP2CA3.js} +1 -1
  63. package/dist/{cc-Q5MM4AWC.cjs → cc-S2QLQFBR.cjs} +1 -1
  64. package/dist/chrome-ATC4OO5I.cjs +20 -0
  65. package/dist/chrome-NHJ44WUN.js +50 -0
  66. package/dist/chrome-O62WXV7F.js +20 -0
  67. package/dist/chrome-XHJLCO4M.cjs +50 -0
  68. package/dist/chromeSkill-53TH55PM.js +105 -0
  69. package/dist/chromeSkill-THW7N4IY.cjs +105 -0
  70. package/dist/{chunk-HOAHWIQ5.cjs → chunk-2CGE7ZV3.cjs} +26 -26
  71. package/dist/chunk-2H5O745H.js +63 -0
  72. package/dist/chunk-2HOLOHVK.js +2219 -0
  73. package/dist/{chunk-3PDTTAKJ.js → chunk-2QL6MNXG.js} +15 -8
  74. package/dist/{chunk-PGRH5Q77.cjs → chunk-2VHB43IX.cjs} +35 -6
  75. package/dist/{chunk-VG34MG2U.js → chunk-37M5UM6I.js} +9 -6
  76. package/dist/{chunk-6HYLHBQG.cjs → chunk-3DDL2E55.cjs} +20 -16
  77. package/dist/chunk-3EDDDZS2.cjs +5 -0
  78. package/dist/{chunk-6OYHF6MF.js → chunk-3GUEUCZK.js} +28 -4
  79. package/dist/{chunk-N254NRHT.cjs → chunk-3HT76LNN.cjs} +9 -2
  80. package/dist/{chunk-DVUHHH3B.cjs → chunk-3KLSNNRW.cjs} +4 -4
  81. package/dist/chunk-3LJJG5YY.cjs +387 -0
  82. package/dist/chunk-3OF56EMA.cjs +197 -0
  83. package/dist/chunk-3PXKRVCW.js +108 -0
  84. package/dist/{chunk-IKGWDOGU.cjs → chunk-3S563FNF.cjs} +160 -79
  85. package/dist/chunk-3UT7R3XV.js +663 -0
  86. package/dist/chunk-4256YRCO.cjs +80 -0
  87. package/dist/chunk-46C73ZKK.cjs +663 -0
  88. package/dist/chunk-46MTALKD.js +44 -0
  89. package/dist/{chunk-AEJH23FO.cjs → chunk-47PHDKNW.cjs} +6 -6
  90. package/dist/chunk-4LMUDS2K.js +124 -0
  91. package/dist/{chunk-HLHTG5ZU.cjs → chunk-5CMYEM3R.cjs} +14 -12
  92. package/dist/{chunk-MBBY4ZIK.js → chunk-5F6ZKSHO.js} +4 -1
  93. package/dist/chunk-5JFTY3VU.js +74 -0
  94. package/dist/chunk-5JTTM5SC.js +59 -0
  95. package/dist/{chunk-IETRBBMP.cjs → chunk-5K3CDSWZ.cjs} +108 -31
  96. package/dist/{chunk-GJH7XMSK.js → chunk-5VHP6HDQ.js} +8 -6
  97. package/dist/{chunk-6ZCULLCA.js → chunk-62RTC3XX.js} +1 -1
  98. package/dist/{chunk-MSED7RH2.cjs → chunk-6GUODJKM.cjs} +112 -41
  99. package/dist/{chunk-47CKWKEX.cjs → chunk-6HH236FV.cjs} +9 -4
  100. package/dist/{chunk-WHE2SWHU.js → chunk-6NVAK6CK.js} +2 -2
  101. package/dist/chunk-6R25D2H5.js +121 -0
  102. package/dist/{chunk-3PCTTUNW.cjs → chunk-6XVVIY54.cjs} +55 -25
  103. package/dist/{chunk-3L53OA4E.cjs → chunk-75EDROHL.cjs} +10 -10
  104. package/dist/{chunk-G4CAKI3V.js → chunk-7HPWMALN.js} +7 -2
  105. package/dist/chunk-7JLT2VNW.cjs +18963 -0
  106. package/dist/chunk-7LWQCE4Y.cjs +987 -0
  107. package/dist/{chunk-OLSBBZW6.cjs → chunk-7MU7LWF3.cjs} +5 -5
  108. package/dist/{chunk-HLQV64Y5.js → chunk-7RFJB75Y.js} +140 -59
  109. package/dist/{chunk-X2MSVKDV.js → chunk-A7HHCIDQ.js} +2 -2
  110. package/dist/{chunk-SKYG33B2.cjs → chunk-AC7DZ6SK.cjs} +3 -3
  111. package/dist/{chunk-XX2ZO7DS.js → chunk-ACDQGA4Z.js} +90 -16
  112. package/dist/{chunk-CZXGCVTR.cjs → chunk-AOKCI722.cjs} +2 -2
  113. package/dist/chunk-ARBEHFCG.js +715 -0
  114. package/dist/{chunk-OOKY3HPZ.js → chunk-AT7OWLY5.js} +50 -9
  115. package/dist/chunk-AU6JAGZJ.cjs +231 -0
  116. package/dist/chunk-AUFNACED.js +18963 -0
  117. package/dist/{chunk-CDBPBM2K.cjs → chunk-AUYSIEVV.cjs} +3 -3
  118. package/dist/chunk-B4HSNOIH.cjs +354 -0
  119. package/dist/{chunk-EGMZDTSL.js → chunk-B5CGDNMR.js} +10 -2
  120. package/dist/{chunk-34M3HWLR.js → chunk-BFQDQRDE.js} +2 -2
  121. package/dist/{chunk-2AA5MFES.js → chunk-BL2UC7HC.js} +8 -5
  122. package/dist/{chunk-LNMYK2F5.cjs → chunk-BQ22N3TX.cjs} +56 -41
  123. package/dist/chunk-BQU3HAE7.js +21 -0
  124. package/dist/chunk-BWF4VDYE.js +3897 -0
  125. package/dist/chunk-BYE7RQFZ.cjs +121 -0
  126. package/dist/{chunk-APIXPPMT.js → chunk-CBFH2J3O.js} +855 -33
  127. package/dist/chunk-CCVMREXI.js +420 -0
  128. package/dist/chunk-CFAWTLSC.js +13 -0
  129. package/dist/{chunk-G27PQQFD.js → chunk-CFFE4VA3.js} +1 -1
  130. package/dist/{chunk-ZYQMLKOK.cjs → chunk-CH2J4PVE.cjs} +212 -70
  131. package/dist/{chunk-7BTSG4ME.cjs → chunk-CHI52KFR.cjs} +855 -33
  132. package/dist/{chunk-DJDE4DTT.cjs → chunk-CWINVFRI.cjs} +25 -19
  133. package/dist/{chunk-HXGBSJL5.cjs → chunk-D2OSPLYC.cjs} +2 -2
  134. package/dist/{chunk-GBHDROGL.js → chunk-D6GZBSOX.js} +16 -4
  135. package/dist/{chunk-CNBKZEX5.cjs → chunk-DA7NBAJK.cjs} +49 -17
  136. package/dist/chunk-DEQVRSV5.cjs +866 -0
  137. package/dist/{chunk-RGR6ME5J.cjs → chunk-DI57A4BX.cjs} +25 -28
  138. package/dist/{chunk-WM5PAOTQ.cjs → chunk-DIZTWFVR.cjs} +1649 -484
  139. package/dist/{chunk-YZXUDM5X.js → chunk-DLP436GI.js} +204 -62
  140. package/dist/{chunk-OHUZKDGX.js → chunk-DMRXF5DU.js} +3 -3
  141. package/dist/{chunk-U46VYPLR.cjs → chunk-DPSIGY6L.cjs} +9 -9
  142. package/dist/{chunk-DN573ME7.cjs → chunk-DRWDEHE5.cjs} +4 -4
  143. package/dist/{chunk-SEKD5FH3.cjs → chunk-E26KKI46.cjs} +5 -2
  144. package/dist/{chunk-J4Q7XR3G.js → chunk-E46DJH5S.js} +3 -3
  145. package/dist/{chunk-Q7XSCYND.cjs → chunk-E6GFD7VR.cjs} +49 -26
  146. package/dist/chunk-ES2HJQ4N.js +37 -0
  147. package/dist/chunk-EZJHLOWP.js +80 -0
  148. package/dist/chunk-FFBDRUO5.cjs +59 -0
  149. package/dist/{chunk-AYSFIUFW.js → chunk-FGT6KK6T.js} +38 -15
  150. package/dist/{chunk-SAHBLB3E.js → chunk-FP46B4X3.js} +208 -3
  151. package/dist/{chunk-DSPQEHDT.js → chunk-FQAVGSPW.js} +2 -2
  152. package/dist/chunk-FQVG6ZHF.js +197 -0
  153. package/dist/chunk-GBMDFWJX.cjs +152 -0
  154. package/dist/{chunk-DRE2RXBZ.js → chunk-GGLKUENP.js} +1605 -440
  155. package/dist/{chunk-S52YW5ZQ.js → chunk-GNBBIAMD.js} +16 -19
  156. package/dist/{chunk-MYISNQH4.js → chunk-GWO66KBI.js} +1 -1
  157. package/dist/chunk-GWY26SUD.cjs +63 -0
  158. package/dist/{chunk-YGN4CQIP.js → chunk-GZ6DV2UG.js} +1 -1
  159. package/dist/{chunk-EZMINVLU.js → chunk-H4D2Q2AL.js} +5 -2
  160. package/dist/chunk-HDK2EHVH.cjs +570 -0
  161. package/dist/chunk-HJIXWGQZ.js +139 -0
  162. package/dist/{chunk-6RF7UKUS.js → chunk-HKYZSUQ5.js} +48 -47
  163. package/dist/{chunk-LQGVEP3E.js → chunk-HQUSEWT4.js} +45 -13
  164. package/dist/{chunk-HTLINWX6.cjs → chunk-HQWQZML5.cjs} +16 -13
  165. package/dist/{chunk-DVZOENQ7.cjs → chunk-HS4USDND.cjs} +9 -4
  166. package/dist/chunk-HSCUPEA4.cjs +3897 -0
  167. package/dist/{chunk-JCLYQ2JC.js → chunk-HXJEGMGB.js} +12 -6
  168. package/dist/{chunk-LJFUXC56.cjs → chunk-HXQREVTA.cjs} +9 -6
  169. package/dist/{chunk-SCXX4LW5.js → chunk-I24CWKKK.js} +15 -8
  170. package/dist/chunk-IAGCRVJ3.js +355 -0
  171. package/dist/chunk-IEXKKKOF.cjs +92 -0
  172. package/dist/{chunk-5IXII4HX.cjs → chunk-IGMPWJ2I.cjs} +19 -12
  173. package/dist/chunk-IKUMVBCW.cjs +33 -0
  174. package/dist/{chunk-XTB6VJVQ.cjs → chunk-J2K57QM7.cjs} +6 -6
  175. package/dist/{chunk-O4IF4NJT.cjs → chunk-J5ADZN6V.cjs} +57 -56
  176. package/dist/chunk-J5HE6CUM.cjs +124 -0
  177. package/dist/{chunk-JS7IPR7P.js → chunk-JAQO6XDB.js} +31 -2
  178. package/dist/chunk-JIMSII7R.js +987 -0
  179. package/dist/chunk-JJ4KA7HK.cjs +2219 -0
  180. package/dist/chunk-JMN3GZU6.js +570 -0
  181. package/dist/{chunk-X5VSP65C.cjs → chunk-JP3YHTQ2.cjs} +4 -4
  182. package/dist/{chunk-SKV2F3NM.js → chunk-JYKPWK5O.js} +1 -1
  183. package/dist/{chunk-NNPAM4HC.cjs → chunk-KNTUI4TZ.cjs} +12 -6
  184. package/dist/{chunk-HIVRCQS2.js → chunk-L4F7SUYL.js} +56 -25
  185. package/dist/{chunk-C5IJIM2V.cjs → chunk-LDJQ5QHG.cjs} +68 -37
  186. package/dist/{chunk-ULQ6MDSJ.cjs → chunk-LFDPTJYF.cjs} +43 -35
  187. package/dist/chunk-LJD7KR3L.cjs +44 -0
  188. package/dist/chunk-LN7D3EJZ.js +387 -0
  189. package/dist/{chunk-643VRA5S.cjs → chunk-LQBONA55.cjs} +32 -8
  190. package/dist/{chunk-NCC6ETZS.js → chunk-LUMV3DB2.js} +41 -33
  191. package/dist/chunk-M4KNC5BQ.js +78 -0
  192. package/dist/chunk-MO4KP6XS.cjs +229 -0
  193. package/dist/{chunk-BVKXEQVG.cjs → chunk-MOJ7ADW4.cjs} +22 -10
  194. package/dist/chunk-MPULXVC4.cjs +715 -0
  195. package/dist/{chunk-X5YJ34FZ.cjs → chunk-MQESBFBZ.cjs} +46 -23
  196. package/dist/chunk-MUNUUFU7.cjs +21 -0
  197. package/dist/{chunk-X3WS5LDG.js → chunk-MX75JYIY.js} +7 -5
  198. package/dist/chunk-MXVIDIC6.cjs +139 -0
  199. package/dist/{chunk-3K2ESU53.cjs → chunk-N6O3XUZ2.cjs} +2 -2
  200. package/dist/{chunk-IVM5F2AE.js → chunk-NBGOIFKP.js} +265 -18
  201. package/dist/{chunk-SLQAYV3W.js → chunk-NMQ47RCG.js} +8 -2
  202. package/dist/{chunk-JYTDYJVW.js → chunk-O64I2GYI.js} +1 -1
  203. package/dist/{chunk-IFFXSTOM.cjs → chunk-O6TQP7U7.cjs} +3 -3
  204. package/dist/{chunk-AYS2ASM7.js → chunk-OHWMWKJQ.js} +1 -1
  205. package/dist/{chunk-N23UAW4I.js → chunk-OM24WXEE.js} +7 -2
  206. package/dist/{chunk-MAKMSQMQ.cjs → chunk-OPNI6O7F.cjs} +8 -6
  207. package/dist/chunk-OR67YXQK.cjs +13 -0
  208. package/dist/{chunk-QOXPOR5D.js → chunk-OV3PVUYN.js} +115 -44
  209. package/dist/{chunk-TNZRZQ7Q.js → chunk-PB7W7R72.js} +3 -78
  210. package/dist/chunk-PCM3N3CL.cjs +37 -0
  211. package/dist/{chunk-A4IJHHV7.cjs → chunk-PDHT7LQS.cjs} +52 -11
  212. package/dist/{chunk-LA7H35XM.cjs → chunk-PHJO5YAL.cjs} +9 -9
  213. package/dist/{chunk-KPELYZ6L.js → chunk-PQLKJCIE.js} +2 -2
  214. package/dist/chunk-PUD76XQT.cjs +78 -0
  215. package/dist/chunk-Q2IL4DDI.cjs +355 -0
  216. package/dist/{chunk-WPVWQSL7.cjs → chunk-Q6AC3PHY.cjs} +16 -13
  217. package/dist/{chunk-XRZEUWKF.js → chunk-QCHIDZBA.js} +1 -1
  218. package/dist/{chunk-IQ5RXU6O.js → chunk-QEGOB6QV.js} +1 -1
  219. package/dist/{chunk-JSBRDJBE.js → chunk-QGM4M3NI.js} +8 -1
  220. package/dist/chunk-QKP772OZ.js +4291 -0
  221. package/dist/chunk-QQ7PANOP.js +59 -0
  222. package/dist/{chunk-YHD6TUIR.cjs → chunk-QW2RW2GY.cjs} +2 -0
  223. package/dist/chunk-RAKO7UN7.js +114 -0
  224. package/dist/chunk-RBHANOYY.js +33 -0
  225. package/dist/chunk-RBZ7AFX7.cjs +29 -0
  226. package/dist/{chunk-TXSDBGKX.cjs → chunk-REMGR23V.cjs} +46 -49
  227. package/dist/chunk-ROLA6EFO.cjs +85 -0
  228. package/dist/{chunk-TBEGGJNC.cjs → chunk-SOLBYSLY.cjs} +33 -16
  229. package/dist/{chunk-FKSDEWDH.js → chunk-SWCQM52V.js} +68 -25
  230. package/dist/{chunk-H5SWOLG6.js → chunk-TBOLJDUG.js} +39 -24
  231. package/dist/chunk-TH26BQJG.js +101 -0
  232. package/dist/{chunk-245KJE5Y.cjs → chunk-TJNBASFD.cjs} +14 -6
  233. package/dist/chunk-TKKN34TV.js +229 -0
  234. package/dist/chunk-TQ33WBY5.cjs +74 -0
  235. package/dist/{chunk-EGFT4PGW.js → chunk-TWQDAUZU.js} +5 -2
  236. package/dist/{chunk-OGV4WJ5L.cjs → chunk-TXPSTCG7.cjs} +74 -59
  237. package/dist/{chunk-CAMZTXV6.js → chunk-U4C3HW6P.js} +67 -52
  238. package/dist/{chunk-5P2NXKP3.js → chunk-UEIXJG45.js} +104 -76
  239. package/dist/{chunk-22D2CNTP.cjs → chunk-UGFVM77J.cjs} +5 -2
  240. package/dist/chunk-UOQECODR.js +34 -0
  241. package/dist/chunk-UR27UDTB.js +354 -0
  242. package/dist/chunk-UWFG2R2I.cjs +420 -0
  243. package/dist/{chunk-Y72HH2TF.cjs → chunk-UXLW45ZE.cjs} +102 -28
  244. package/dist/{chunk-FPHU2ES6.cjs → chunk-VBOFPU5M.cjs} +6 -0
  245. package/dist/{chunk-JX3DFKBI.js → chunk-VDWJMWDF.js} +54 -24
  246. package/dist/{chunk-LENHP55G.cjs → chunk-VGEV44V2.cjs} +1076 -158
  247. package/dist/{chunk-33RSHBDH.js → chunk-VKBIE6I6.js} +38 -7
  248. package/dist/{chunk-CWMZKFTT.js → chunk-VRMZO6TB.js} +31 -8
  249. package/dist/chunk-VUGOOGHB.js +400 -0
  250. package/dist/chunk-WBU4Q4GS.cjs +400 -0
  251. package/dist/chunk-WGLBC5AY.cjs +59 -0
  252. package/dist/{chunk-KWXVKLQ5.cjs → chunk-WGNMOVMT.cjs} +7 -82
  253. package/dist/{chunk-RKJTGGMU.cjs → chunk-WKRDBCP2.cjs} +221 -16
  254. package/dist/chunk-WRTXCQ3V.cjs +4291 -0
  255. package/dist/chunk-WTB7AFL6.cjs +101 -0
  256. package/dist/{chunk-NDMIPTV4.js → chunk-WZV6UVPY.js} +8 -3
  257. package/dist/chunk-XF2WIKHR.cjs +34 -0
  258. package/dist/{chunk-L3WAH3EM.cjs → chunk-XGMI6IYB.cjs} +46 -15
  259. package/dist/{chunk-FW774QXH.js → chunk-XIVFAD2L.js} +1048 -130
  260. package/dist/chunk-XV2HXRHX.js +85 -0
  261. package/dist/{chunk-72FKPBT5.js → chunk-Y3M2DABP.js} +16 -12
  262. package/dist/{chunk-QNGEW5TC.js → chunk-YV63VW4K.js} +1 -1
  263. package/dist/{chunk-UJ2JSM6H.js → chunk-YVQI26H4.js} +2 -0
  264. package/dist/{chunk-RD5XAJR2.cjs → chunk-YWTIXHU6.cjs} +266 -19
  265. package/dist/chunk-YZWE7XSM.js +5 -0
  266. package/dist/{chunk-I5IW3T2Y.js → chunk-Z3XSSF7B.js} +32 -15
  267. package/dist/{chunk-6UJMCWRY.js → chunk-Z4LIPMPM.js} +6 -0
  268. package/dist/chunk-ZASDSY7P.cjs +114 -0
  269. package/dist/{chunk-R33VKSH5.cjs → chunk-ZHJ7JGME.cjs} +11 -11
  270. package/dist/chunk-ZPD2AO3U.js +866 -0
  271. package/dist/{chunk-7UOUW76C.js → chunk-ZQAT5VT5.js} +101 -24
  272. package/dist/chunk-ZR46OJNZ.js +152 -0
  273. package/dist/{chunk-G3V4SFET.cjs → chunk-ZZ63NW7A.cjs} +78 -35
  274. package/dist/clear-33TWQ2ES.cjs +12 -0
  275. package/dist/clear-OFLFQ3MR.js +12 -0
  276. package/dist/{communityInstaller-6KCFN7YZ.js → communityInstaller-COB2KTOW.js} +9 -6
  277. package/dist/communityInstaller-TWMGPSYM.cjs +22 -0
  278. package/dist/completion-IIZMHXYP.cjs +17 -0
  279. package/dist/completion-PT4VM2H2.js +17 -0
  280. package/dist/config-KL6WU7R2.cjs +20 -0
  281. package/dist/{config-ZN66VXPS.js → config-R4O7GBTY.js} +7 -5
  282. package/dist/{constants-UFM5B232.js → constants-HVCHVQAF.js} +2 -2
  283. package/dist/constants-RLMJ5D5P.cjs +21 -0
  284. package/dist/{defaultHooks-RCXPHF4M.cjs → defaultHooks-2V2CQL63.cjs} +26 -11
  285. package/dist/{defaultHooks-RDRMER3Z.js → defaultHooks-TMHDU3FS.js} +26 -11
  286. package/dist/export-3PK3VFCE.js +15 -0
  287. package/dist/export-WLGNWEMJ.cjs +15 -0
  288. package/dist/{extractSessionMemories-V7K42ZHW.js → extractSessionMemories-A2JX5WJ2.js} +1 -1
  289. package/dist/{extractSessionMemories-SDW2MVBQ.cjs → extractSessionMemories-XL3MS37F.cjs} +1 -1
  290. package/dist/feedback-G635NCLJ.js +18 -0
  291. package/dist/feedback-LLMK3TZH.cjs +18 -0
  292. package/dist/fffSearchProvider-2YCNKOYD.js +412 -0
  293. package/dist/fffSearchProvider-W6627E2V.cjs +412 -0
  294. package/dist/filesystem-L6DQKGWK.js +11 -0
  295. package/dist/filesystem-PGUPCMVK.cjs +11 -0
  296. package/dist/{formatters-6K7QVWQL.cjs → formatters-53XTCNGQ.cjs} +1 -1
  297. package/dist/{formatters-DQHO5I36.js → formatters-T6KV4BPP.js} +1 -1
  298. package/dist/help-BAXLP2M2.cjs +12 -0
  299. package/dist/{help-2BLR7L43.js → help-X3OAZ3CY.js} +3 -3
  300. package/dist/history-6HOJSEMT.cjs +14 -0
  301. package/dist/{history-5FZ3M2AK.js → history-YKFPHBJN.js} +3 -3
  302. package/dist/hooks-7TA4PIIB.js +18 -0
  303. package/dist/hooks-XVFU67T2.cjs +18 -0
  304. package/dist/{i18n-K7QOWIBH.js → i18n-2KBUU7XL.js} +2 -2
  305. package/dist/i18n-MUJMKTFM.cjs +33 -0
  306. package/dist/ide-CCQ33PGC.cjs +15 -0
  307. package/dist/ide-VLVFBZ5F.js +15 -0
  308. package/dist/immediateCommandRouter-MTEHZXQX.js +15 -0
  309. package/dist/immediateCommandRouter-ROXU3MWT.cjs +15 -0
  310. package/dist/{import-UXM3VK7B.js → import-4CHYLS4K.js} +4 -4
  311. package/dist/{import-QEME3E4T.cjs → import-I7T4ZHYL.cjs} +4 -4
  312. package/dist/import-J46F54JY.cjs +10 -0
  313. package/dist/import-JWPYKXCZ.js +10 -0
  314. package/dist/index.cjs +747 -22356
  315. package/dist/index.d.cts +93 -0
  316. package/dist/index.d.ts +93 -0
  317. package/dist/index.js +786 -22395
  318. package/dist/init-262MWZV4.js +10 -0
  319. package/dist/init-EE5Y7RBL.cjs +10 -0
  320. package/dist/inkMode-VUE6ZDLD.cjs +7 -0
  321. package/dist/inkMode-WBNFOSAT.js +7 -0
  322. package/dist/inputPrompt-IIFKCX5Q.cjs +90 -0
  323. package/dist/inputPrompt-YGBHDUEP.js +90 -0
  324. package/dist/language-CVLPB7OV.js +21 -0
  325. package/dist/language-ZTWFHUSV.cjs +21 -0
  326. package/dist/learn-PON7I5QS.js +23 -0
  327. package/dist/learn-XLRSVNA3.cjs +23 -0
  328. package/dist/{lint-D5UOJWIK.cjs → lint-4NDGCSCL.cjs} +1 -1
  329. package/dist/{lint-NJPZWVN2.js → lint-FZ7ZJUB3.js} +1 -1
  330. package/dist/login-223QTGBG.cjs +26 -0
  331. package/dist/login-6IKTBUBY.js +26 -0
  332. package/dist/logout-RN2AG6SI.js +23 -0
  333. package/dist/logout-U3M4FFX7.cjs +23 -0
  334. package/dist/mcp-5O6PUL4G.js +20 -0
  335. package/dist/mcp-NUQ76QQB.cjs +20 -0
  336. package/dist/{mcp-install-VESN42PI.js → mcp-install-6XWXLFVY.js} +18 -11
  337. package/dist/{mcp-install-G27HSS3Z.cjs → mcp-install-P6DHES7V.cjs} +22 -15
  338. package/dist/memory-CYMDQ2YC.cjs +10 -0
  339. package/dist/memory-Q54CESNM.js +10 -0
  340. package/dist/{message-ZJ5AYAMT.cjs → message-4OKO775J.cjs} +1 -1
  341. package/dist/{message-JUBOK2VU.js → message-X3LOAAM7.js} +1 -1
  342. package/dist/model-6AJ77PJG.js +10 -0
  343. package/dist/model-IDRCKDML.cjs +10 -0
  344. package/dist/new-7LEWOUF2.cjs +12 -0
  345. package/dist/new-ZXHEWC2S.js +12 -0
  346. package/dist/onboarding-FXX7YHSJ.cjs +35 -0
  347. package/dist/onboarding-JYNMK6NI.js +35 -0
  348. package/dist/{patch-MOD7QC3D.cjs → patch-DJ2GPFST.cjs} +1 -1
  349. package/dist/{patch-5F6VBIT3.js → patch-NIJWIRHS.js} +1 -1
  350. package/dist/permissions-YBNSANIA.cjs +10 -0
  351. package/dist/permissions-YHJMVA6L.js +10 -0
  352. package/dist/plan-XEJMOT55.cjs +13 -0
  353. package/dist/plan-YYUAXPTL.js +13 -0
  354. package/dist/pr-review-CW6J7P62.cjs +9 -0
  355. package/dist/pr-review-YZSBQVT2.js +9 -0
  356. package/dist/quit-B43SJ6E4.cjs +10 -0
  357. package/dist/quit-GWTNHQSP.js +10 -0
  358. package/dist/rawMode-6W5AXAKI.cjs +7 -0
  359. package/dist/rawMode-GFNLXQPU.js +7 -0
  360. package/dist/{registry-KWZGYJC2.js → registry-34GL6BNJ.js} +30 -45
  361. package/dist/{registry-YN4FQPOO.cjs → registry-V24W7YK6.cjs} +66 -81
  362. package/dist/repeat-P4FAPE3Y.cjs +17 -0
  363. package/dist/repeat-RALE6AUO.js +17 -0
  364. package/dist/resume-DYVOQN5L.cjs +16 -0
  365. package/dist/resume-M25UQKOX.js +16 -0
  366. package/dist/review-QHP2KP4Q.js +9 -0
  367. package/dist/review-UWHWQHCB.cjs +9 -0
  368. package/dist/ripgrep-67SCU2BA.cjs +9 -0
  369. package/dist/ripgrep-VHJQQ55W.js +9 -0
  370. package/dist/rpc-NPS3PU4O.cjs +3730 -0
  371. package/dist/rpc-S3DGW6KV.js +3730 -0
  372. package/dist/search-CPX4PWHP.js +20 -0
  373. package/dist/search-VUF3M4N3.cjs +20 -0
  374. package/dist/{session-BSU2L5UI.cjs → session-LXKC4X5Q.cjs} +1 -1
  375. package/dist/{session-SZMRN5KG.js → session-NMMO4QOL.js} +1 -1
  376. package/dist/sessions-IYAXMK23.js +10 -0
  377. package/dist/sessions-JODKER5D.cjs +10 -0
  378. package/dist/settings-55BNW6BF.js +33 -0
  379. package/dist/settings-BKTS7OMC.cjs +33 -0
  380. package/dist/setup-IRC5HQG2.js +29 -0
  381. package/dist/setup-MMQ7TWOP.cjs +29 -0
  382. package/dist/share-6JRQECAH.cjs +17 -0
  383. package/dist/share-YM5MJKMO.js +17 -0
  384. package/dist/{skills-FYY6F2WV.cjs → skills-GGMZOVIE.cjs} +14 -11
  385. package/dist/skills-LWSOKOSH.cjs +29 -0
  386. package/dist/{skills-6OL4OSGA.js → skills-MVIZNHT4.js} +13 -10
  387. package/dist/skills-VWOMV3CR.js +29 -0
  388. package/dist/{skills-install-6CSWC24P.js → skills-install-QBA5RCV6.js} +22 -71
  389. package/dist/{skills-install-O3LZ2ETC.cjs → skills-install-VTAMCNNY.cjs} +35 -84
  390. package/dist/skills-new-GPL46YV2.js +18 -0
  391. package/dist/skills-new-L5BEZN5V.cjs +18 -0
  392. package/dist/slashCommands-FBPCIWM5.cjs +95 -0
  393. package/dist/slashCommands-FCWY5DXW.js +95 -0
  394. package/dist/status-3B5SDZPL.js +17 -0
  395. package/dist/status-TTGRF6NC.cjs +17 -0
  396. package/dist/summarizer-DGPHE5IQ.js +17 -0
  397. package/dist/summarizer-JNXLUAQG.cjs +17 -0
  398. package/dist/sync-77CXVVTK.cjs +21 -0
  399. package/dist/{sync-KWX67OUN.js → sync-7BILIQHP.js} +4 -4
  400. package/dist/sync-7OKF6636.js +21 -0
  401. package/dist/sync-EH4K5U3N.cjs +40 -0
  402. package/dist/{tasks-5FPBIFLC.js → tasks-R5MBGAQ6.js} +1 -1
  403. package/dist/{tasks-TXGKGNH6.cjs → tasks-V4WB3MFR.cjs} +1 -1
  404. package/dist/{team-5YXP3JGR.js → team-JESCHGWB.js} +1 -1
  405. package/dist/{team-IIWEZKNR.cjs → team-VQQKWGZB.cjs} +1 -1
  406. package/dist/{teammate-L6EZQ3I2.js → teammate-GZQSCIMS.js} +29 -8
  407. package/dist/{teammate-2KMKJXAM.cjs → teammate-J6PHGL23.cjs} +30 -9
  408. package/dist/theme-64BYGJ57.cjs +21 -0
  409. package/dist/theme-YJE6HEON.js +21 -0
  410. package/dist/tools-3PPTTKFV.js +9 -0
  411. package/dist/tools-THIQA7WC.cjs +9 -0
  412. package/dist/ui/questionModal.cjs +9 -6
  413. package/dist/ui/questionModal.js +8 -5
  414. package/dist/undo-PRTEGL2J.cjs +10 -0
  415. package/dist/undo-SZEHLX7X.js +10 -0
  416. package/dist/{update-TVAJMMBC.js → update-53WMKYVS.js} +1 -1
  417. package/dist/{update-Z6BIIQDC.cjs → update-NV6QRYY7.cjs} +1 -1
  418. package/dist/web-3BA2WV37.cjs +37 -0
  419. package/dist/web-6FYGBX5K.js +37 -0
  420. package/dist/workspaceSafety-MDJGHK6D.cjs +9 -0
  421. package/dist/workspaceSafety-XOUMUBVB.js +9 -0
  422. package/dist/yolo-GF2YD7ZI.js +9 -0
  423. package/dist/yolo-OGDA7HNC.cjs +9 -0
  424. package/dist/yoloMode-3DJDA75U.cjs +17 -0
  425. package/dist/yoloMode-4JOOSU26.js +17 -0
  426. package/package.json +46 -49
  427. package/dist/AgentRegistry-NQCLWABO.cjs +0 -10
  428. package/dist/CommunitySkillsCache-6QPRMTJO.js +0 -8
  429. package/dist/CommunitySkillsCache-GTQMOCCO.cjs +0 -8
  430. package/dist/GitHubRegistryFetcher-S7QFUEKV.cjs +0 -7
  431. package/dist/HookManager-Q2KYMCP4.cjs +0 -7
  432. package/dist/HookManager-TTP4Y6DC.js +0 -7
  433. package/dist/LearnAdvisor-A4Q5PPBI.js +0 -9
  434. package/dist/LearnAdvisor-GASQD7HT.cjs +0 -9
  435. package/dist/McpClientManager-RKD7C6OY.cjs +0 -8
  436. package/dist/MemoryManager-GUNLRP5S.js +0 -8
  437. package/dist/MemoryManager-TNSGKDKX.cjs +0 -8
  438. package/dist/PermissionManager-KMN53FJP.cjs +0 -11
  439. package/dist/ProviderFactory-MR5B23QJ.js +0 -9
  440. package/dist/ProviderFactory-VFGCJJX6.cjs +0 -9
  441. package/dist/SessionManager-FEUAU3ZJ.cjs +0 -10
  442. package/dist/SessionManager-IKWAK2PI.js +0 -10
  443. package/dist/SkillsRegistry-KPQFTRIT.cjs +0 -9
  444. package/dist/SkillsRegistry-XJSKPDF2.js +0 -9
  445. package/dist/SubAgent-NYH6GWQ3.js +0 -11
  446. package/dist/SubAgent-PZKBDUBA.cjs +0 -11
  447. package/dist/SyncApiClient-ZNYMT36M.cjs +0 -11
  448. package/dist/about-HHTF2YFL.js +0 -12
  449. package/dist/about-JGRVNNQC.cjs +0 -12
  450. package/dist/actionExecutor-U6IBN2TU.cjs +0 -19
  451. package/dist/actionExecutor-XT5FW3W6.js +0 -19
  452. package/dist/add-dir-247K3XRY.js +0 -10
  453. package/dist/add-dir-GS4DXKKH.cjs +0 -10
  454. package/dist/agents-R6ZEFTVR.cjs +0 -12
  455. package/dist/agents-WJPQWQF2.js +0 -12
  456. package/dist/agents-new-HKVEIBDJ.js +0 -14
  457. package/dist/agents-new-X6GTHIO6.cjs +0 -14
  458. package/dist/autoSkill-H4T6VVDA.cjs +0 -20
  459. package/dist/automode-BC6NVECO.js +0 -10
  460. package/dist/automode-WN2RSOGW.cjs +0 -10
  461. package/dist/chunk-33A755XB.cjs +0 -168
  462. package/dist/chunk-3OTU3RS3.cjs +0 -1607
  463. package/dist/chunk-4PKF7WPD.js +0 -100
  464. package/dist/chunk-ALYU6VTM.js +0 -105
  465. package/dist/chunk-AS6RTLN7.cjs +0 -203
  466. package/dist/chunk-BWN2CLLM.cjs +0 -298
  467. package/dist/chunk-HQ7YZKXE.js +0 -168
  468. package/dist/chunk-HVKOZ2VP.cjs +0 -115
  469. package/dist/chunk-J6QET7EF.cjs +0 -454
  470. package/dist/chunk-LWUJFGOZ.js +0 -115
  471. package/dist/chunk-P47WPOXN.js +0 -298
  472. package/dist/chunk-PRRCJFU3.cjs +0 -85
  473. package/dist/chunk-RO6WYEWH.js +0 -454
  474. package/dist/chunk-SYVYLZZF.cjs +0 -24
  475. package/dist/chunk-T73IDKDF.js +0 -111
  476. package/dist/chunk-YRLYSQEQ.cjs +0 -105
  477. package/dist/chunk-ZQE72E6W.cjs +0 -100
  478. package/dist/chunk-ZVY2XD6T.js +0 -1607
  479. package/dist/clear-UO4MNWZW.cjs +0 -12
  480. package/dist/clear-ZJ5NYP6E.js +0 -12
  481. package/dist/communityInstaller-PVSOFDZD.cjs +0 -19
  482. package/dist/completion-MMF2PN2H.js +0 -14
  483. package/dist/completion-UI5WKHXI.cjs +0 -14
  484. package/dist/config-E7RINK4R.cjs +0 -18
  485. package/dist/constants-6CPCJ3DY.cjs +0 -21
  486. package/dist/export-N4XIVDSL.cjs +0 -12
  487. package/dist/export-W22L4D5C.js +0 -12
  488. package/dist/feedback-DR6ADSNE.cjs +0 -15
  489. package/dist/feedback-FEEAP4QW.js +0 -15
  490. package/dist/filesystem-3SGCW2BF.js +0 -10
  491. package/dist/filesystem-MCFXJQ6R.cjs +0 -10
  492. package/dist/help-AQHGTS7P.cjs +0 -12
  493. package/dist/history-NIUDRMKA.cjs +0 -14
  494. package/dist/hooks-2EY4IPKV.js +0 -13
  495. package/dist/hooks-LJVORRIG.cjs +0 -13
  496. package/dist/i18n-ARDG2SMC.cjs +0 -33
  497. package/dist/ide-GFW6IJHD.js +0 -12
  498. package/dist/ide-N2ZNSSB3.cjs +0 -12
  499. package/dist/import-DFVN3KNZ.js +0 -10
  500. package/dist/import-ZS6DPGU5.cjs +0 -10
  501. package/dist/init-PY75HA3S.cjs +0 -10
  502. package/dist/init-QNMWLAVY.js +0 -10
  503. package/dist/language-5UE4G2BT.cjs +0 -18
  504. package/dist/language-UXMHEZUJ.js +0 -18
  505. package/dist/learn-HJ3FLNZC.cjs +0 -20
  506. package/dist/learn-MVYS3RU5.js +0 -20
  507. package/dist/localProjectPermissions-N77HA3XK.js +0 -18
  508. package/dist/localProjectPermissions-UFSMNTBJ.cjs +0 -18
  509. package/dist/login-DSE7H63A.js +0 -20
  510. package/dist/login-V3MEWPKN.cjs +0 -20
  511. package/dist/logout-BMVCLKKW.js +0 -18
  512. package/dist/logout-XEG7FHOZ.cjs +0 -18
  513. package/dist/mcp-PYUR4PHO.js +0 -18
  514. package/dist/mcp-SG6JFLGC.cjs +0 -18
  515. package/dist/memory-4ZMMEZ2Z.js +0 -10
  516. package/dist/memory-QSGMVVGH.cjs +0 -10
  517. package/dist/model-NANLBZ4Z.cjs +0 -10
  518. package/dist/model-ZXNV4AF7.js +0 -10
  519. package/dist/new-5QJY5JP2.js +0 -12
  520. package/dist/new-PMMG55UX.cjs +0 -12
  521. package/dist/permissions-LECTCJ4H.cjs +0 -13
  522. package/dist/permissions-VP5VGIBL.js +0 -13
  523. package/dist/plan-G5CEKJI4.js +0 -11
  524. package/dist/plan-QKOHE3LH.cjs +0 -11
  525. package/dist/quit-BKOOPHU5.cjs +0 -10
  526. package/dist/quit-FVFNYACP.js +0 -10
  527. package/dist/resume-EXFQSQPH.js +0 -13
  528. package/dist/resume-PP2IQM5S.cjs +0 -13
  529. package/dist/search-C56FBN67.cjs +0 -17
  530. package/dist/search-XGZDYBF4.js +0 -17
  531. package/dist/sessions-54KI3F2Q.js +0 -10
  532. package/dist/sessions-DDTSPNVW.cjs +0 -10
  533. package/dist/settings-BDO37TTO.cjs +0 -30
  534. package/dist/settings-FHRDFPLK.js +0 -30
  535. package/dist/share-IERCTBGN.cjs +0 -14
  536. package/dist/share-TGROUE6R.js +0 -14
  537. package/dist/skills-OM4IGBAA.cjs +0 -26
  538. package/dist/skills-S3GRN323.js +0 -26
  539. package/dist/skills-new-ALD2PTHN.js +0 -15
  540. package/dist/skills-new-PWLKK7GW.cjs +0 -15
  541. package/dist/slashCommands-L4ZD33LJ.js +0 -75
  542. package/dist/slashCommands-YY2VUUDF.cjs +0 -75
  543. package/dist/status-3PC5XWSS.cjs +0 -11
  544. package/dist/status-KCLVOYPD.js +0 -11
  545. package/dist/sync-6SDWG5RK.js +0 -18
  546. package/dist/sync-7JMZVEQD.cjs +0 -40
  547. package/dist/sync-WHURZL3U.cjs +0 -18
  548. package/dist/theme-BE5A4FPN.cjs +0 -18
  549. package/dist/theme-YMFCQP7J.js +0 -18
  550. package/dist/undo-KZHUUZTD.cjs +0 -10
  551. package/dist/undo-NEIEHQVX.js +0 -10
@@ -0,0 +1,3730 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; } var _class; var _class2;
2
+
3
+ var _chunk7JLT2VNWcjs = require('./chunk-7JLT2VNW.cjs');
4
+
5
+
6
+ var _chunk5K3CDSWZcjs = require('./chunk-5K3CDSWZ.cjs');
7
+ require('./chunk-QMAKTSZB.cjs');
8
+ require('./chunk-HQWQZML5.cjs');
9
+
10
+
11
+ var _chunkVGEV44V2cjs = require('./chunk-VGEV44V2.cjs');
12
+ require('./chunk-Q6AC3PHY.cjs');
13
+ require('./chunk-5CMYEM3R.cjs');
14
+
15
+
16
+ var _chunkDI57A4BXcjs = require('./chunk-DI57A4BX.cjs');
17
+ require('./chunk-LQBONA55.cjs');
18
+ require('./chunk-AU6JAGZJ.cjs');
19
+ require('./chunk-GBMDFWJX.cjs');
20
+ require('./chunk-FFBDRUO5.cjs');
21
+ require('./chunk-GWY26SUD.cjs');
22
+ require('./chunk-ROLA6EFO.cjs');
23
+ require('./chunk-PCM3N3CL.cjs');
24
+ require('./chunk-BYE7RQFZ.cjs');
25
+ require('./chunk-PHJO5YAL.cjs');
26
+ require('./chunk-Z36XBUMX.cjs');
27
+ require('./chunk-U3WDY42C.cjs');
28
+ require('./chunk-FHK7UDOJ.cjs');
29
+ require('./chunk-DRWDEHE5.cjs');
30
+ require('./chunk-AUYSIEVV.cjs');
31
+ require('./chunk-HDK2EHVH.cjs');
32
+ require('./chunk-PDHT7LQS.cjs');
33
+ require('./chunk-MQESBFBZ.cjs');
34
+ require('./chunk-TXPSTCG7.cjs');
35
+ require('./chunk-PUD76XQT.cjs');
36
+ require('./chunk-IEXKKKOF.cjs');
37
+ require('./chunk-CWINVFRI.cjs');
38
+ require('./chunk-J2K57QM7.cjs');
39
+ require('./chunk-J5ADZN6V.cjs');
40
+ require('./chunk-3S563FNF.cjs');
41
+ require('./chunk-DPSIGY6L.cjs');
42
+ require('./chunk-JHGIWNHL.cjs');
43
+ require('./chunk-ZASDSY7P.cjs');
44
+ require('./chunk-6GUODJKM.cjs');
45
+ require('./chunk-SOLBYSLY.cjs');
46
+ require('./chunk-OPNI6O7F.cjs');
47
+ require('./chunk-E6GFD7VR.cjs');
48
+ require('./chunk-47PHDKNW.cjs');
49
+ require('./chunk-QCLYBIMM.cjs');
50
+ require('./chunk-M7RVTUWE.cjs');
51
+ require('./chunk-AC7DZ6SK.cjs');
52
+ require('./chunk-75EDROHL.cjs');
53
+ require('./chunk-6XVVIY54.cjs');
54
+ require('./chunk-WGLBC5AY.cjs');
55
+ require('./chunk-LDJQ5QHG.cjs');
56
+ require('./chunk-O6TQP7U7.cjs');
57
+ require('./chunk-MFK6HE47.cjs');
58
+ require('./chunk-TJNBASFD.cjs');
59
+ require('./chunk-JP3YHTQ2.cjs');
60
+ require('./chunk-3KLSNNRW.cjs');
61
+ require('./chunk-6HH236FV.cjs');
62
+ require('./chunk-HS4USDND.cjs');
63
+
64
+
65
+ var _chunkDA7NBAJKcjs = require('./chunk-DA7NBAJK.cjs');
66
+ require('./chunk-YFXTE422.cjs');
67
+ require('./chunk-DIZTWFVR.cjs');
68
+ require('./chunk-HXQREVTA.cjs');
69
+ require('./chunk-4JNNTOGF.cjs');
70
+ require('./chunk-RBZ7AFX7.cjs');
71
+ require('./chunk-VXCMGBXY.cjs');
72
+ require('./chunk-XGMI6IYB.cjs');
73
+ require('./chunk-AOKCI722.cjs');
74
+ require('./chunk-N6O3XUZ2.cjs');
75
+ require('./chunk-UXLW45ZE.cjs');
76
+ require('./chunk-OR67YXQK.cjs');
77
+ require('./chunk-DEQVRSV5.cjs');
78
+
79
+
80
+
81
+
82
+ var _chunkJ5HE6CUMcjs = require('./chunk-J5HE6CUM.cjs');
83
+ require('./chunk-UGFVM77J.cjs');
84
+ require('./chunk-QW2RW2GY.cjs');
85
+ require('./chunk-ZHJ7JGME.cjs');
86
+ require('./chunk-JJ4KA7HK.cjs');
87
+ require('./chunk-WTB7AFL6.cjs');
88
+
89
+
90
+
91
+ var _chunkWRTXCQ3Vcjs = require('./chunk-WRTXCQ3V.cjs');
92
+
93
+
94
+ var _chunkHSCUPEA4cjs = require('./chunk-HSCUPEA4.cjs');
95
+ require('./chunk-WBU4Q4GS.cjs');
96
+
97
+
98
+ var _chunkLFDPTJYFcjs = require('./chunk-LFDPTJYF.cjs');
99
+ require('./chunk-MUNUUFU7.cjs');
100
+ require('./chunk-MOJ7ADW4.cjs');
101
+ require('./chunk-WKRDBCP2.cjs');
102
+ require('./chunk-B4HSNOIH.cjs');
103
+ require('./chunk-BQ22N3TX.cjs');
104
+ require('./chunk-IGMPWJ2I.cjs');
105
+ require('./chunk-2CGE7ZV3.cjs');
106
+ require('./chunk-3DDL2E55.cjs');
107
+ require('./chunk-4256YRCO.cjs');
108
+ require('./chunk-LJD7KR3L.cjs');
109
+ require('./chunk-ZZ63NW7A.cjs');
110
+ require('./chunk-7MU7LWF3.cjs');
111
+ require('./chunk-UWFG2R2I.cjs');
112
+
113
+
114
+
115
+ var _chunk7LWQCE4Ycjs = require('./chunk-7LWQCE4Y.cjs');
116
+
117
+
118
+ var _chunk3LJJG5YYcjs = require('./chunk-3LJJG5YY.cjs');
119
+ require('./chunk-XDLH4EDL.cjs');
120
+
121
+
122
+
123
+
124
+ var _chunkMPULXVC4cjs = require('./chunk-MPULXVC4.cjs');
125
+
126
+
127
+ var _chunkQ2IL4DDIcjs = require('./chunk-Q2IL4DDI.cjs');
128
+ require('./chunk-FMB3TSWP.cjs');
129
+ require('./chunk-IKUMVBCW.cjs');
130
+ require('./chunk-REMGR23V.cjs');
131
+
132
+
133
+ var _chunk3OF56EMAcjs = require('./chunk-3OF56EMA.cjs');
134
+ require('./chunk-D2OSPLYC.cjs');
135
+ require('./chunk-CH2J4PVE.cjs');
136
+ require('./chunk-KNTUI4TZ.cjs');
137
+ require('./chunk-TQ33WBY5.cjs');
138
+
139
+
140
+ var _chunk46C73ZKKcjs = require('./chunk-46C73ZKK.cjs');
141
+ require('./chunk-MXVIDIC6.cjs');
142
+ require('./chunk-3EDDDZS2.cjs');
143
+ require('./chunk-YWTIXHU6.cjs');
144
+ require('./chunk-2VHB43IX.cjs');
145
+ require('./chunk-E26KKI46.cjs');
146
+ require('./chunk-XF2WIKHR.cjs');
147
+
148
+
149
+ var _chunkWGNMOVMTcjs = require('./chunk-WGNMOVMT.cjs');
150
+ require('./chunk-CHI52KFR.cjs');
151
+ require('./chunk-VBOFPU5M.cjs');
152
+ require('./chunk-3HT76LNN.cjs');
153
+
154
+ // src/modes/rpc/index.ts
155
+ var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
156
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
157
+
158
+ // src/modes/rpc/types.ts
159
+ var JSON_RPC_ERROR_CODES = {
160
+ // Standard JSON-RPC 2.0 errors
161
+ PARSE_ERROR: -32700,
162
+ INVALID_REQUEST: -32600,
163
+ METHOD_NOT_FOUND: -32601,
164
+ INVALID_PARAMS: -32602,
165
+ INTERNAL_ERROR: -32603,
166
+ // Server errors (reserved for implementation-defined errors: -32000 to -32099)
167
+ EXECUTION_ERROR: -32e3,
168
+ PERMISSION_DENIED: -32001,
169
+ TIMEOUT: -32002,
170
+ AGENT_BUSY: -32003,
171
+ ABORTED: -32004
172
+ };
173
+ var RPC_METHODS = {
174
+ // Client -> Server requests
175
+ PROMPT: "autohand.prompt",
176
+ ABORT: "autohand.abort",
177
+ RESET: "autohand.reset",
178
+ GET_STATE: "autohand.getState",
179
+ GET_MESSAGES: "autohand.getMessages",
180
+ BROWSER_HANDOFF_CREATE: "autohand.browserHandoff.create",
181
+ BROWSER_HANDOFF_ATTACH: "autohand.browserHandoff.attach",
182
+ BROWSER_HANDOFF_ATTACH_LATEST: "autohand.browserHandoff.attachLatest",
183
+ PERMISSION_RESPONSE: "autohand.permissionResponse",
184
+ PERMISSION_ACKNOWLEDGED: "autohand.permissionAcknowledged",
185
+ DIRECTORY_ACCESS_RESPONSE: "autohand.directoryAccessResponse",
186
+ DIRECTORY_ACCESS_ACKNOWLEDGED: "autohand.directoryAccessAcknowledged",
187
+ // Multi-file change preview
188
+ CHANGES_DECISION: "autohand.changesDecision",
189
+ // Skills management (non-interactive for RPC mode)
190
+ GET_SKILLS_REGISTRY: "autohand.getSkillsRegistry",
191
+ INSTALL_SKILL: "autohand.installSkill",
192
+ // Auto-mode control
193
+ AUTOMODE_START: "autohand.automode.start",
194
+ AUTOMODE_STATUS: "autohand.automode.status",
195
+ AUTOMODE_PAUSE: "autohand.automode.pause",
196
+ AUTOMODE_RESUME: "autohand.automode.resume",
197
+ AUTOMODE_CANCEL: "autohand.automode.cancel",
198
+ AUTOMODE_GET_LOG: "autohand.automode.getLog",
199
+ // Plan mode control
200
+ PLAN_MODE_SET: "autohand.planModeSet",
201
+ // Session history
202
+ GET_HISTORY: "autohand.getHistory",
203
+ GET_SESSION: "autohand.getSession",
204
+ // YOLO mode control
205
+ YOLO_SET: "autohand.yoloSet",
206
+ // MCP (Model Context Protocol) management
207
+ MCP_LIST_SERVERS: "autohand.mcp.listServers",
208
+ MCP_LIST_TOOLS: "autohand.mcp.listTools",
209
+ MCP_SET_VSCODE_TOOLS: "autohand.mcp.setVscodeTools",
210
+ MCP_INVOKE_RESPONSE: "autohand.mcp.invokeResponse",
211
+ MCP_GET_SERVER_CONFIGS: "autohand.mcp.getServerConfigs",
212
+ LEARN_RECOMMEND: "autohand.learn.recommend",
213
+ LEARN_UPDATE: "autohand.learn.update",
214
+ LEARN_GENERATE: "autohand.learn.generate",
215
+ SKILLS_SEARCH: "autohand.skills.search",
216
+ SKILLS_TRENDING: "autohand.skills.trending",
217
+ SKILLS_REMOVE: "autohand.skills.remove",
218
+ SKILLS_INSTALL: "autohand.skills.install",
219
+ // SDK control methods
220
+ SET_PERMISSION_MODE: "autohand.permissionModeSet",
221
+ SET_MODEL: "autohand.modelSet",
222
+ SET_MAX_THINKING_TOKENS: "autohand.maxThinkingTokensSet",
223
+ APPLY_FLAG_SETTINGS: "autohand.applyFlagSettings",
224
+ GET_SUPPORTED_MODELS: "autohand.getSupportedModels",
225
+ GET_SUPPORTED_COMMANDS: "autohand.getSupportedCommands",
226
+ GET_TOOLS_REGISTRY: "autohand.getToolsRegistry",
227
+ GET_CONTEXT_USAGE: "autohand.getContextUsage",
228
+ RELOAD_PLUGINS: "autohand.reloadPlugins",
229
+ GET_ACCOUNT_INFO: "autohand.getAccountInfo",
230
+ MCP_TOGGLE_SERVER: "autohand.mcp.toggleServer",
231
+ MCP_RECONNECT_SERVER: "autohand.mcp.reconnectServer",
232
+ MCP_SET_SERVERS: "autohand.mcp.setServers",
233
+ // Context compaction control
234
+ SET_CONTEXT_COMPACT: "autohand.setContextCompact",
235
+ // Setup wizard
236
+ SETUP: "autohand.setup"
237
+ };
238
+ var RPC_NOTIFICATIONS = {
239
+ AGENT_START: "autohand.agentStart",
240
+ AGENT_END: "autohand.agentEnd",
241
+ PING: "autohand.ping",
242
+ TURN_START: "autohand.turnStart",
243
+ TURN_END: "autohand.turnEnd",
244
+ MESSAGE_START: "autohand.messageStart",
245
+ MESSAGE_UPDATE: "autohand.messageUpdate",
246
+ MESSAGE_END: "autohand.messageEnd",
247
+ TOOL_START: "autohand.toolStart",
248
+ TOOL_UPDATE: "autohand.toolUpdate",
249
+ TOOL_END: "autohand.toolEnd",
250
+ PERMISSION_REQUEST: "autohand.permissionRequest",
251
+ DIRECTORY_ACCESS_REQUEST: "autohand.directoryAccessRequest",
252
+ ERROR: "autohand.error",
253
+ // Multi-file change preview notifications
254
+ CHANGES_BATCH_START: "autohand.changesBatchStart",
255
+ CHANGES_BATCH_UPDATE: "autohand.changesBatchUpdate",
256
+ CHANGES_BATCH_END: "autohand.changesBatchEnd",
257
+ // Hook lifecycle notifications
258
+ HOOK_PRE_TOOL: "autohand.hook.preTool",
259
+ HOOK_POST_TOOL: "autohand.hook.postTool",
260
+ HOOK_FILE_MODIFIED: "autohand.hook.fileModified",
261
+ HOOK_PRE_PROMPT: "autohand.hook.prePrompt",
262
+ HOOK_POST_RESPONSE: "autohand.hook.postResponse",
263
+ HOOK_SESSION_ERROR: "autohand.hook.sessionError",
264
+ HOOK_STOP: "autohand.hook.stop",
265
+ HOOK_SESSION_START: "autohand.hook.sessionStart",
266
+ HOOK_SESSION_END: "autohand.hook.sessionEnd",
267
+ HOOK_SUBAGENT_STOP: "autohand.hook.subagentStop",
268
+ HOOK_PERMISSION_REQUEST: "autohand.hook.permissionRequest",
269
+ HOOK_NOTIFICATION: "autohand.hook.notification",
270
+ // Auto-mode lifecycle notifications
271
+ AUTOMODE_START: "autohand.automode.start",
272
+ AUTOMODE_ITERATION: "autohand.automode.iteration",
273
+ AUTOMODE_CHECKPOINT: "autohand.automode.checkpoint",
274
+ AUTOMODE_PAUSE: "autohand.automode.pause",
275
+ AUTOMODE_RESUME: "autohand.automode.resume",
276
+ AUTOMODE_CANCEL: "autohand.automode.cancel",
277
+ AUTOMODE_COMPLETE: "autohand.automode.complete",
278
+ AUTOMODE_ERROR: "autohand.automode.error",
279
+ // Mode change notifications
280
+ MODE_CHANGE: "autohand.modeChange",
281
+ // Pipe mode notifications
282
+ PIPE_OUTPUT: "autohand.pipe.output",
283
+ PIPE_COMPLETE: "autohand.pipe.complete",
284
+ PIPE_ERROR: "autohand.pipe.error",
285
+ // MCP bridge notifications (Server -> Client)
286
+ MCP_INVOKE_REQUEST: "autohand.mcp.invokeRequest",
287
+ MCP_TOOLS_CHANGED: "autohand.mcp.toolsChanged",
288
+ LEARN_INSTALL_COMPLETE: "autohand.learn.installComplete",
289
+ LEARN_SECURITY_WARNING: "autohand.learn.securityWarning",
290
+ LEARN_PROGRESS: "autohand.learn.progress",
291
+ SCHEDULE_TRIGGERED: "autohand.schedule.triggered",
292
+ // Setup wizard notifications
293
+ SETUP_STARTED: "autohand.setup.started",
294
+ SETUP_STEP_START: "autohand.setup.stepStart",
295
+ SETUP_STEP_COMPLETE: "autohand.setup.stepComplete",
296
+ SETUP_CANCELLED: "autohand.setup.cancelled",
297
+ SETUP_ERROR: "autohand.setup.error",
298
+ SETUP_COMPLETE: "autohand.setup.complete",
299
+ // Context lifecycle notifications
300
+ HOOK_CONTEXT_COMPACTED: "autohand.hook.contextCompacted",
301
+ HOOK_CONTEXT_OVERFLOW: "autohand.hook.contextOverflow",
302
+ HOOK_CONTEXT_WARNING: "autohand.hook.contextWarning",
303
+ HOOK_CONTEXT_CRITICAL: "autohand.hook.contextCritical"
304
+ };
305
+ var MAX_IMAGE_SIZE = 10 * 1024 * 1024;
306
+ var VALID_IMAGE_MIME_TYPES = [
307
+ "image/png",
308
+ "image/jpeg",
309
+ "image/gif",
310
+ "image/webp"
311
+ ];
312
+ function isValidImageMimeType(mimeType) {
313
+ return VALID_IMAGE_MIME_TYPES.includes(mimeType);
314
+ }
315
+ function isJsonRpcRequest(obj) {
316
+ if (typeof obj !== "object" || obj === null) return false;
317
+ const req = obj;
318
+ return req.jsonrpc === "2.0" && typeof req.method === "string";
319
+ }
320
+ function isJsonRpcResponse(obj) {
321
+ if (typeof obj !== "object" || obj === null) return false;
322
+ const res = obj;
323
+ return res.jsonrpc === "2.0" && ("result" in res || "error" in res);
324
+ }
325
+ function isJsonRpcBatch(obj) {
326
+ return Array.isArray(obj) && obj.length > 0;
327
+ }
328
+ function isNotification(request) {
329
+ return request.id === void 0;
330
+ }
331
+ function createRequest(method, params, id) {
332
+ const request = {
333
+ jsonrpc: "2.0",
334
+ method
335
+ };
336
+ if (params !== void 0) {
337
+ request.params = params;
338
+ }
339
+ if (id !== void 0) {
340
+ request.id = id;
341
+ }
342
+ return request;
343
+ }
344
+ function createResponse(id, result) {
345
+ return {
346
+ jsonrpc: "2.0",
347
+ result,
348
+ id
349
+ };
350
+ }
351
+ function createErrorResponse(id, code, message, data) {
352
+ const response = {
353
+ jsonrpc: "2.0",
354
+ error: { code, message },
355
+ id
356
+ };
357
+ if (data !== void 0) {
358
+ response.error.data = data;
359
+ }
360
+ return response;
361
+ }
362
+ function createNotification(method, params) {
363
+ const notification = {
364
+ jsonrpc: "2.0",
365
+ method
366
+ };
367
+ if (params !== void 0) {
368
+ notification.params = params;
369
+ }
370
+ return notification;
371
+ }
372
+
373
+ // src/modes/rpc/adapter.ts
374
+ var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
375
+
376
+ // src/modes/rpc/protocol.ts
377
+ function parseRequest(line) {
378
+ const trimmed = line.trim();
379
+ if (!trimmed) {
380
+ return {
381
+ type: "error",
382
+ code: JSON_RPC_ERROR_CODES.INVALID_REQUEST,
383
+ message: "Empty request"
384
+ };
385
+ }
386
+ let parsed;
387
+ try {
388
+ parsed = JSON.parse(trimmed);
389
+ } catch (e2) {
390
+ return {
391
+ type: "error",
392
+ code: JSON_RPC_ERROR_CODES.PARSE_ERROR,
393
+ message: "Parse error: Invalid JSON"
394
+ };
395
+ }
396
+ if (isJsonRpcBatch(parsed)) {
397
+ const validRequests = [];
398
+ for (const item of parsed) {
399
+ if (isJsonRpcRequest(item)) {
400
+ validRequests.push(item);
401
+ }
402
+ }
403
+ if (validRequests.length === 0) {
404
+ return {
405
+ type: "error",
406
+ code: JSON_RPC_ERROR_CODES.INVALID_REQUEST,
407
+ message: "Invalid batch: No valid requests"
408
+ };
409
+ }
410
+ return { type: "batch", requests: validRequests };
411
+ }
412
+ if (isJsonRpcRequest(parsed)) {
413
+ return { type: "single", request: parsed };
414
+ }
415
+ return {
416
+ type: "error",
417
+ code: JSON_RPC_ERROR_CODES.INVALID_REQUEST,
418
+ message: "Invalid request: Missing jsonrpc version or method"
419
+ };
420
+ }
421
+ function serialize(obj) {
422
+ try {
423
+ return JSON.stringify(obj);
424
+ } catch (error) {
425
+ const message = error instanceof Error ? error.message : "Unknown serialization error";
426
+ process.stderr.write(`[RPC] Serialization error: ${message}
427
+ `);
428
+ return JSON.stringify({
429
+ jsonrpc: "2.0",
430
+ error: {
431
+ code: JSON_RPC_ERROR_CODES.INTERNAL_ERROR,
432
+ message: `Serialization failed: ${message}`
433
+ },
434
+ id: null
435
+ });
436
+ }
437
+ }
438
+ function serializeBatch(responses) {
439
+ try {
440
+ return JSON.stringify(responses);
441
+ } catch (error) {
442
+ const message = error instanceof Error ? error.message : "Unknown serialization error";
443
+ process.stderr.write(`[RPC] Batch serialization error: ${message}
444
+ `);
445
+ return JSON.stringify([{
446
+ jsonrpc: "2.0",
447
+ error: {
448
+ code: JSON_RPC_ERROR_CODES.INTERNAL_ERROR,
449
+ message: `Batch serialization failed: ${message}`
450
+ },
451
+ id: null
452
+ }]);
453
+ }
454
+ }
455
+ function createTimestamp() {
456
+ return (/* @__PURE__ */ new Date()).toISOString();
457
+ }
458
+ var idCounter = 0;
459
+ function generateId(prefix = "id") {
460
+ return `${prefix}_${++idCounter}_${Date.now()}`;
461
+ }
462
+ var LineReader = (_class = class {
463
+ constructor(stream) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
464
+ this.stream = stream;
465
+ this.stream.setEncoding("utf8");
466
+ this.stream.on("data", (chunk) => this.handleData(chunk));
467
+ this.stream.on("end", () => this.handleEnd());
468
+ this.stream.on("close", () => this.handleClose());
469
+ }
470
+
471
+ __init() {this.buffer = ""}
472
+ __init2() {this.lineQueue = []}
473
+ __init3() {this.resolvers = []}
474
+ __init4() {this.closed = false}
475
+ handleData(chunk) {
476
+ this.buffer += chunk;
477
+ let newlineIndex;
478
+ while ((newlineIndex = this.buffer.indexOf("\n")) !== -1) {
479
+ const line = this.buffer.slice(0, newlineIndex);
480
+ this.buffer = this.buffer.slice(newlineIndex + 1);
481
+ if (line.trim()) {
482
+ this.deliverLine(line);
483
+ }
484
+ }
485
+ }
486
+ handleEnd() {
487
+ if (this.buffer.trim()) {
488
+ this.deliverLine(this.buffer);
489
+ }
490
+ this.buffer = "";
491
+ this.closed = true;
492
+ }
493
+ handleClose() {
494
+ this.closed = true;
495
+ }
496
+ deliverLine(line) {
497
+ if (this.resolvers.length > 0) {
498
+ const resolver = this.resolvers.shift();
499
+ resolver(line);
500
+ } else {
501
+ this.lineQueue.push(line);
502
+ }
503
+ }
504
+ /**
505
+ * Read the next line (async)
506
+ */
507
+ async readLine() {
508
+ if (this.lineQueue.length > 0) {
509
+ return this.lineQueue.shift();
510
+ }
511
+ if (this.closed) {
512
+ throw new Error("Stream closed");
513
+ }
514
+ return new Promise((resolve) => {
515
+ this.resolvers.push(resolve);
516
+ });
517
+ }
518
+ /**
519
+ * Check if there are pending lines
520
+ */
521
+ hasPendingLines() {
522
+ return this.lineQueue.length > 0;
523
+ }
524
+ /**
525
+ * Check if the stream is closed
526
+ */
527
+ isClosed() {
528
+ return this.closed;
529
+ }
530
+ }, _class);
531
+ function writeResponse(id, result) {
532
+ try {
533
+ const response = createResponse(id, result);
534
+ const serialized = serialize(response) + "\n";
535
+ process.stderr.write(`[RPC DEBUG] writeResponse id=${id} size=${serialized.length}b
536
+ `);
537
+ process.stdout.write(serialized);
538
+ } catch (error) {
539
+ const message = error instanceof Error ? error.message : "Unknown write error";
540
+ process.stderr.write(`[RPC] Failed to write response for id '${id}': ${message}
541
+ `);
542
+ }
543
+ }
544
+ function writeErrorResponse(id, code, message, data) {
545
+ try {
546
+ const response = createErrorResponse(id, code, message, data);
547
+ const serialized = serialize(response) + "\n";
548
+ process.stderr.write(`[RPC DEBUG] writeErrorResponse id=${id} size=${serialized.length}b
549
+ `);
550
+ process.stdout.write(serialized);
551
+ } catch (error) {
552
+ const errMsg = error instanceof Error ? error.message : "Unknown write error";
553
+ process.stderr.write(`[RPC] Failed to write error response: ${errMsg}
554
+ `);
555
+ }
556
+ }
557
+ function writeBatchResponse(responses) {
558
+ if (responses.length > 0) {
559
+ try {
560
+ const serialized = serializeBatch(responses) + "\n";
561
+ process.stderr.write(`[RPC DEBUG] writeBatchResponse count=${responses.length} size=${serialized.length}b
562
+ `);
563
+ process.stdout.write(serialized);
564
+ } catch (error) {
565
+ const message = error instanceof Error ? error.message : "Unknown write error";
566
+ process.stderr.write(`[RPC] Failed to write batch response: ${message}
567
+ `);
568
+ }
569
+ }
570
+ }
571
+ function writeNotification(method, params) {
572
+ try {
573
+ const notification = createNotification(method, params);
574
+ const serialized = serialize(notification) + "\n";
575
+ if (method !== "autohand.ping") {
576
+ process.stderr.write(`[RPC DEBUG] writeNotification method=${method} size=${serialized.length}b
577
+ `);
578
+ }
579
+ process.stdout.write(serialized);
580
+ } catch (error) {
581
+ const message = error instanceof Error ? error.message : "Unknown write error";
582
+ process.stderr.write(`[RPC] Failed to write notification '${method}': ${message}
583
+ `);
584
+ }
585
+ }
586
+ function writeParseError(message = "Parse error") {
587
+ writeErrorResponse(null, JSON_RPC_ERROR_CODES.PARSE_ERROR, message);
588
+ }
589
+ function writeInvalidRequestError(id, message = "Invalid request") {
590
+ writeErrorResponse(id, JSON_RPC_ERROR_CODES.INVALID_REQUEST, message);
591
+ }
592
+ function writeMethodNotFoundError(id, method) {
593
+ writeErrorResponse(
594
+ id,
595
+ JSON_RPC_ERROR_CODES.METHOD_NOT_FOUND,
596
+ `Method not found: ${method}`
597
+ );
598
+ }
599
+ function writeInternalError(id, message, data) {
600
+ writeErrorResponse(id, JSON_RPC_ERROR_CODES.INTERNAL_ERROR, message, data);
601
+ }
602
+
603
+ // src/modes/rpc/adapter.ts
604
+ var RPC_ERROR_TYPE_MAP = {
605
+ context_overflow: "context",
606
+ model_not_found: "model",
607
+ invalid_request: "context",
608
+ auth_failed: "auth",
609
+ payment_required: "payment",
610
+ access_denied: "model",
611
+ rate_limited: "rate_limit",
612
+ server_error: "server",
613
+ network_error: "network",
614
+ timeout: "network",
615
+ cancelled: "unknown",
616
+ unknown: "unknown"
617
+ };
618
+ var RPC_ERROR_CODE_MAP = {
619
+ context_overflow: 400,
620
+ model_not_found: 404,
621
+ invalid_request: 400,
622
+ auth_failed: 401,
623
+ payment_required: 402,
624
+ access_denied: 403,
625
+ rate_limited: 429,
626
+ server_error: 500,
627
+ network_error: 504,
628
+ timeout: 504,
629
+ cancelled: -32e3,
630
+ unknown: -32e3
631
+ };
632
+ var RPC_ERROR_ICON_MAP = {
633
+ context_overflow: "\u{1F4E6}",
634
+ // 📦
635
+ model_not_found: "\u{1F916}",
636
+ // 🤖
637
+ invalid_request: "\u{1F4E6}",
638
+ // 📦
639
+ auth_failed: "\u{1F510}",
640
+ // 🔐
641
+ payment_required: "\u{1F4B3}",
642
+ // 💳
643
+ access_denied: "\u{1F916}",
644
+ // 🤖
645
+ rate_limited: "\u23F1\uFE0F",
646
+ // ⏱️
647
+ server_error: "\u{1F527}",
648
+ // 🔧
649
+ network_error: "\u{1F310}",
650
+ // 🌐
651
+ timeout: "\u{1F310}",
652
+ // 🌐
653
+ cancelled: "\u26A0\uFE0F",
654
+ // ⚠️
655
+ unknown: "\u26A0\uFE0F"
656
+ // ⚠️
657
+ };
658
+ var RPCAdapter = (_class2 = class {constructor() { _class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);_class2.prototype.__init16.call(this);_class2.prototype.__init17.call(this);_class2.prototype.__init18.call(this);_class2.prototype.__init19.call(this);_class2.prototype.__init20.call(this);_class2.prototype.__init21.call(this);_class2.prototype.__init22.call(this);_class2.prototype.__init23.call(this);_class2.prototype.__init24.call(this);_class2.prototype.__init25.call(this);_class2.prototype.__init26.call(this);_class2.prototype.__init27.call(this);_class2.prototype.__init28.call(this); }
659
+ __init5() {this.agent = null}
660
+ __init6() {this.conversation = null}
661
+ __init7() {this.imageManager = null}
662
+ __init8() {this.sessionId = null}
663
+ __init9() {this.currentTurnId = null}
664
+ __init10() {this.turnStartTime = null}
665
+ __init11() {this.currentMessageId = null}
666
+ __init12() {this.currentMessageContent = ""}
667
+ __init13() {this.pendingPermissions = /* @__PURE__ */ new Map()}
668
+ __init14() {this.pendingDirectoryAccess = /* @__PURE__ */ new Map()}
669
+ __init15() {this.abortController = null}
670
+ __init16() {this.status = "idle"}
671
+ __init17() {this.model = ""}
672
+ __init18() {this.workspace = ""}
673
+ __init19() {this.contextPercent = 0}
674
+ __init20() {this.currentChangesBatchId = null}
675
+ // Enable preview mode for multi-file change batching (future: make configurable)
676
+ __init21() {this.previewModeEnabled = true}
677
+ // MCP bridge: VS Code tools registered by the extension
678
+ __init22() {this.vscodeTools = /* @__PURE__ */ new Map()}
679
+ // MCP bridge: pending tool invocations waiting for extension response
680
+ __init23() {this.pendingVscodeInvocations = /* @__PURE__ */ new Map()}
681
+ // MCP server configurations from CLI config (set during initialization)
682
+ __init24() {this.mcpServerConfigs = []}
683
+ // Cached vision support result (null = not yet checked)
684
+ __init25() {this.visionSupported = null}
685
+ // Keepalive interval to prevent Chrome from killing the MV3 service worker
686
+ // during long turns with no traffic.
687
+ __init26() {this.keepaliveInterval = null}
688
+ __init27() {this.KEEPALIVE_MS = 15e3}
689
+ // Config reference for runtime settings changes
690
+ __init28() {this.config = {}}
691
+ /**
692
+ * Check if the current model supports vision/image inputs.
693
+ * Uses async OpenRouter API with pattern-matching fallback, cached for the session.
694
+ */
695
+ async checkVisionSupport() {
696
+ if (this.visionSupported !== null) {
697
+ return this.visionSupported;
698
+ }
699
+ this.visionSupported = await _chunkWRTXCQ3Vcjs.modelSupportsImages.call(void 0, this.model);
700
+ return this.visionSupported;
701
+ }
702
+ /**
703
+ * Initialize the adapter with an agent instance
704
+ */
705
+ initialize(agent, conversation, model, workspace, mcpServerConfigs) {
706
+ this.agent = agent;
707
+ this.conversation = conversation;
708
+ this.model = model;
709
+ this.workspace = workspace;
710
+ this.sessionId = generateId("session");
711
+ this.mcpServerConfigs = _nullishCoalesce(mcpServerConfigs, () => ( []));
712
+ this.imageManager = _nullishCoalesce(_optionalChain([agent, 'access', _ => _.getImageManager, 'optionalCall', _2 => _2()]), () => ( new (0, _chunkHSCUPEA4cjs.ImageManager)()));
713
+ agent.setStatusListener((snapshot) => {
714
+ this.contextPercent = snapshot.contextPercent;
715
+ this.model = snapshot.model;
716
+ });
717
+ agent.setOutputListener((event) => {
718
+ this.handleAgentOutput(event);
719
+ });
720
+ writeNotification(RPC_NOTIFICATIONS.AGENT_START, {
721
+ sessionId: this.sessionId,
722
+ model: this.model,
723
+ workspace: this.workspace,
724
+ timestamp: createTimestamp(),
725
+ contextPercent: this.contextPercent
726
+ });
727
+ }
728
+ /**
729
+ * Get current agent state
730
+ */
731
+ getState() {
732
+ return {
733
+ status: this.status,
734
+ sessionId: this.sessionId,
735
+ model: this.model,
736
+ workspace: this.workspace,
737
+ contextPercent: this.contextPercent,
738
+ messageCount: _nullishCoalesce(_optionalChain([this, 'access', _3 => _3.conversation, 'optionalAccess', _4 => _4.history, 'call', _5 => _5(), 'access', _6 => _6.length]), () => ( 0))
739
+ };
740
+ }
741
+ /**
742
+ * Get message history
743
+ */
744
+ getMessages(limit) {
745
+ if (!this.conversation) {
746
+ return [];
747
+ }
748
+ let messages = this.conversation.history();
749
+ if (limit && limit > 0) {
750
+ messages = messages.slice(-limit);
751
+ }
752
+ return messages.map((msg, index) => this.convertMessage(msg, index));
753
+ }
754
+ /**
755
+ * Handle a prompt request
756
+ * Returns result for JSON-RPC response
757
+ */
758
+ async handlePrompt(requestId, params) {
759
+ if (!this.agent) {
760
+ throw new Error("Agent not initialized");
761
+ }
762
+ if (this.status === "processing") {
763
+ throw new Error("Agent is already processing");
764
+ }
765
+ this.status = "processing";
766
+ this.abortController = new AbortController();
767
+ this.startKeepalive();
768
+ this.currentTurnId = generateId("turn");
769
+ this.turnStartTime = Date.now();
770
+ writeNotification(RPC_NOTIFICATIONS.TURN_START, {
771
+ turnId: this.currentTurnId,
772
+ timestamp: createTimestamp()
773
+ });
774
+ try {
775
+ const imagePlaceholders = [];
776
+ process.stderr.write(`[RPC] handlePrompt: images=${_optionalChain([params, 'access', _7 => _7.images, 'optionalAccess', _8 => _8.length]) || 0}, hasImageManager=${!!this.imageManager}, model=${this.model}
777
+ `);
778
+ if (params.images && params.images.length > 0) {
779
+ const supportsVisionResult = await this.checkVisionSupport();
780
+ if (!supportsVisionResult) {
781
+ process.stderr.write(`[RPC] WARNING: Model '${this.model}' does not support vision. Images will not be processed.
782
+ `);
783
+ writeNotification(RPC_NOTIFICATIONS.ERROR, {
784
+ code: -32e3,
785
+ message: `Model '${this.model}' does not support image inputs. Please use a vision-capable model like claude-3.5-sonnet, gpt-4o, or gemini-1.5-pro.`,
786
+ recoverable: true,
787
+ timestamp: createTimestamp()
788
+ });
789
+ }
790
+ }
791
+ if (params.images && params.images.length > 0 && this.imageManager && await this.checkVisionSupport()) {
792
+ process.stderr.write(`[RPC] Processing ${params.images.length} images
793
+ `);
794
+ for (const img of params.images) {
795
+ try {
796
+ process.stderr.write(`[RPC] Image: mimeType=${img.mimeType}, dataLength=${_optionalChain([img, 'access', _9 => _9.data, 'optionalAccess', _10 => _10.length]) || 0}
797
+ `);
798
+ if (!isValidImageMimeType(img.mimeType)) {
799
+ process.stderr.write(`[RPC] Invalid MIME type: ${img.mimeType}
800
+ `);
801
+ writeNotification(RPC_NOTIFICATIONS.ERROR, {
802
+ code: -32602,
803
+ // Invalid params
804
+ message: `Invalid image MIME type: ${img.mimeType}`,
805
+ recoverable: true,
806
+ timestamp: createTimestamp()
807
+ });
808
+ continue;
809
+ }
810
+ const data = Buffer.from(img.data, "base64");
811
+ process.stderr.write(`[RPC] Image decoded: ${data.length} bytes
812
+ `);
813
+ if (data.length > MAX_IMAGE_SIZE) {
814
+ writeNotification(RPC_NOTIFICATIONS.ERROR, {
815
+ code: -32602,
816
+ message: `Image too large: ${Math.round(data.length / 1024 / 1024)}MB (max: ${Math.round(MAX_IMAGE_SIZE / 1024 / 1024)}MB)`,
817
+ recoverable: true,
818
+ timestamp: createTimestamp()
819
+ });
820
+ continue;
821
+ }
822
+ const id = this.imageManager.add(data, img.mimeType, img.filename);
823
+ const placeholder = this.imageManager.formatPlaceholder(id);
824
+ imagePlaceholders.push(placeholder);
825
+ } catch (error) {
826
+ const message = error instanceof Error ? error.message : "Unknown error";
827
+ writeNotification(RPC_NOTIFICATIONS.ERROR, {
828
+ code: -32e3,
829
+ message: `Failed to process image: ${message}`,
830
+ recoverable: true,
831
+ timestamp: createTimestamp()
832
+ });
833
+ }
834
+ }
835
+ }
836
+ let instruction = params.message;
837
+ const isSlashCmd = this.agent.isSlashCommand(instruction);
838
+ if (!isSlashCmd) {
839
+ if (imagePlaceholders.length > 0) {
840
+ process.stderr.write(`[RPC] Image placeholders: ${imagePlaceholders.join(", ")}
841
+ `);
842
+ instruction = `${imagePlaceholders.join(" ")}
843
+
844
+ ${instruction}`;
845
+ } else if (params.images && params.images.length > 0) {
846
+ process.stderr.write(`[RPC] WARNING: Images provided but no placeholders generated!
847
+ `);
848
+ }
849
+ if (_optionalChain([params, 'access', _11 => _11.context, 'optionalAccess', _12 => _12.selection])) {
850
+ const sel = params.context.selection;
851
+ instruction = `${instruction}
852
+
853
+ Context from ${sel.file} (lines ${sel.startLine}-${sel.endLine}):
854
+ \`\`\`
855
+ ${sel.text}
856
+ \`\`\``;
857
+ }
858
+ }
859
+ this.currentMessageId = generateId("msg");
860
+ this.currentMessageContent = "";
861
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_START, {
862
+ messageId: this.currentMessageId,
863
+ role: "assistant",
864
+ timestamp: createTimestamp()
865
+ });
866
+ let success = false;
867
+ try {
868
+ process.stderr.write(`[RPC DEBUG] Executing instruction: ${instruction.substring(0, 100)}
869
+ `);
870
+ if (isSlashCmd) {
871
+ const { command, args } = this.agent.parseSlashCommand(instruction);
872
+ process.stderr.write(`[RPC DEBUG] Handling slash command: ${command}, args: ${JSON.stringify(args)}
873
+ `);
874
+ if (this.agent.isSlashCommandSupported(command)) {
875
+ const result = await this.agent.handleSlashCommand(command, args);
876
+ if (result !== null) {
877
+ this.currentMessageContent = result;
878
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_UPDATE, {
879
+ messageId: this.currentMessageId,
880
+ delta: result,
881
+ timestamp: createTimestamp()
882
+ });
883
+ } else {
884
+ this.currentMessageContent = `Command ${command} executed.`;
885
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_UPDATE, {
886
+ messageId: this.currentMessageId,
887
+ delta: this.currentMessageContent,
888
+ timestamp: createTimestamp()
889
+ });
890
+ }
891
+ success = true;
892
+ } else {
893
+ this.currentMessageContent = `Unknown command: ${command}. Type /help for available commands.`;
894
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_UPDATE, {
895
+ messageId: this.currentMessageId,
896
+ delta: this.currentMessageContent,
897
+ timestamp: createTimestamp()
898
+ });
899
+ success = false;
900
+ }
901
+ } else {
902
+ const fileManager = this.agent.getFileManager();
903
+ process.stderr.write(`[RPC DEBUG] previewModeEnabled=${this.previewModeEnabled}, hasFileManager=${!!fileManager}
904
+ `);
905
+ if (this.previewModeEnabled && fileManager) {
906
+ this.currentChangesBatchId = generateId("changes");
907
+ process.stderr.write(`[RPC DEBUG] Entering preview mode with batchId=${this.currentChangesBatchId}
908
+ `);
909
+ this.emitChangesBatchStart(this.currentChangesBatchId);
910
+ fileManager.enterPreviewMode(this.currentChangesBatchId, (change) => {
911
+ this.emitChangesBatchUpdate(this.currentChangesBatchId, {
912
+ id: change.id,
913
+ filePath: change.filePath,
914
+ changeType: change.changeType,
915
+ originalContent: change.originalContent,
916
+ proposedContent: change.proposedContent,
917
+ description: change.description,
918
+ toolId: change.toolId,
919
+ toolName: change.toolName
920
+ });
921
+ });
922
+ }
923
+ try {
924
+ success = await this.agent.runInstruction(instruction);
925
+ } finally {
926
+ if (this.previewModeEnabled && fileManager && this.currentChangesBatchId) {
927
+ const pendingChanges = fileManager.getPendingChanges();
928
+ process.stderr.write(`[RPC DEBUG] Turn finished, pendingChanges=${pendingChanges.length}, files=${pendingChanges.map((c) => c.filePath).join(", ")}
929
+ `);
930
+ this.emitChangesBatchEnd(this.currentChangesBatchId, pendingChanges.length);
931
+ if (pendingChanges.length === 0) {
932
+ fileManager.exitPreviewMode();
933
+ }
934
+ this.currentChangesBatchId = null;
935
+ }
936
+ }
937
+ }
938
+ process.stderr.write(`[RPC DEBUG] Instruction completed, success=${success}, content length=${this.currentMessageContent.length}
939
+ `);
940
+ const turnDuration = this.turnStartTime ? Date.now() - this.turnStartTime : 0;
941
+ try {
942
+ const hookManager = _optionalChain([this, 'access', _13 => _13.agent, 'optionalAccess', _14 => _14.getHookManager, 'optionalCall', _15 => _15()]);
943
+ process.stderr.write(`[RPC DEBUG] Hook execution: hookManager=${!!hookManager}
944
+ `);
945
+ if (hookManager) {
946
+ const snapshot2 = _optionalChain([this, 'access', _16 => _16.agent, 'optionalAccess', _17 => _17.getStatusSnapshot, 'call', _18 => _18()]);
947
+ process.stderr.write(`[RPC DEBUG] Executing stop hooks...
948
+ `);
949
+ await hookManager.executeHooks("stop", {
950
+ sessionId: this.sessionId || void 0,
951
+ turnDuration,
952
+ tokensUsed: _nullishCoalesce(_optionalChain([snapshot2, 'optionalAccess', _19 => _19.tokensUsed]), () => ( 0))
953
+ });
954
+ process.stderr.write(`[RPC DEBUG] Stop hooks completed
955
+ `);
956
+ this.emitHookStop(
957
+ _nullishCoalesce(_optionalChain([snapshot2, 'optionalAccess', _20 => _20.tokensUsed]), () => ( 0)),
958
+ 0,
959
+ // toolCallsCount - not tracked per turn currently
960
+ turnDuration
961
+ );
962
+ process.stderr.write(`[RPC DEBUG] HOOK_STOP emitted
963
+ `);
964
+ }
965
+ } catch (hookErr) {
966
+ const hookErrMsg = hookErr instanceof Error ? hookErr.message : String(hookErr);
967
+ process.stderr.write(`[RPC DEBUG] Hook execution error (non-blocking): ${hookErrMsg}
968
+ `);
969
+ }
970
+ } catch (err) {
971
+ const errorMessage = err instanceof Error ? err.message : String(err);
972
+ const errorStack = err instanceof Error ? err.stack : "";
973
+ process.stderr.write(`[RPC DEBUG] Error during runInstruction: ${errorMessage}
974
+ `);
975
+ process.stderr.write(`[RPC DEBUG] Stack: ${errorStack}
976
+ `);
977
+ writeNotification(RPC_NOTIFICATIONS.ERROR, {
978
+ code: -32e3,
979
+ message: errorMessage,
980
+ recoverable: true,
981
+ timestamp: createTimestamp()
982
+ });
983
+ success = false;
984
+ }
985
+ process.stderr.write(`[RPC DEBUG] Emitting MESSAGE_END, messageId=${this.currentMessageId}
986
+ `);
987
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_END, {
988
+ messageId: this.currentMessageId,
989
+ content: this.currentMessageContent,
990
+ timestamp: createTimestamp()
991
+ });
992
+ process.stderr.write(`[RPC DEBUG] MESSAGE_END emitted successfully
993
+ `);
994
+ const durationMs = this.turnStartTime ? Date.now() - this.turnStartTime : void 0;
995
+ const snapshot = _optionalChain([this, 'access', _21 => _21.agent, 'optionalAccess', _22 => _22.getStatusSnapshot, 'call', _23 => _23()]);
996
+ process.stderr.write(`[RPC DEBUG] Emitting TURN_END, turnId=${this.currentTurnId}
997
+ `);
998
+ writeNotification(RPC_NOTIFICATIONS.TURN_END, {
999
+ turnId: this.currentTurnId,
1000
+ timestamp: createTimestamp(),
1001
+ contextPercent: this.contextPercent,
1002
+ tokensUsed: _optionalChain([snapshot, 'optionalAccess', _24 => _24.tokensUsed]),
1003
+ durationMs
1004
+ });
1005
+ process.stderr.write(`[RPC DEBUG] TURN_END emitted successfully
1006
+ `);
1007
+ this.stopKeepalive();
1008
+ this.status = "idle";
1009
+ this.currentTurnId = null;
1010
+ this.turnStartTime = null;
1011
+ this.currentMessageId = null;
1012
+ this.abortController = null;
1013
+ return { success };
1014
+ } catch (error) {
1015
+ const errorMsg = error instanceof Error ? error.message : String(error);
1016
+ process.stderr.write(`[RPC DEBUG] Outer catch - error: ${errorMsg}
1017
+ `);
1018
+ if (this.currentMessageId) {
1019
+ process.stderr.write(`[RPC DEBUG] Emitting MESSAGE_END from outer catch, messageId=${this.currentMessageId}
1020
+ `);
1021
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_END, {
1022
+ messageId: this.currentMessageId,
1023
+ content: this.currentMessageContent,
1024
+ timestamp: createTimestamp()
1025
+ });
1026
+ }
1027
+ const durationMs = this.turnStartTime ? Date.now() - this.turnStartTime : void 0;
1028
+ const snapshot = _optionalChain([this, 'access', _25 => _25.agent, 'optionalAccess', _26 => _26.getStatusSnapshot, 'call', _27 => _27()]);
1029
+ process.stderr.write(`[RPC DEBUG] Emitting TURN_END from outer catch, turnId=${this.currentTurnId}
1030
+ `);
1031
+ writeNotification(RPC_NOTIFICATIONS.TURN_END, {
1032
+ turnId: this.currentTurnId,
1033
+ timestamp: createTimestamp(),
1034
+ contextPercent: this.contextPercent,
1035
+ tokensUsed: _optionalChain([snapshot, 'optionalAccess', _28 => _28.tokensUsed]),
1036
+ durationMs
1037
+ });
1038
+ this.stopKeepalive();
1039
+ this.status = "idle";
1040
+ this.currentTurnId = null;
1041
+ this.turnStartTime = null;
1042
+ this.currentMessageId = null;
1043
+ this.abortController = null;
1044
+ throw error;
1045
+ }
1046
+ }
1047
+ /**
1048
+ * Handle abort request (can be notification with null id for instant abort)
1049
+ */
1050
+ handleAbort(_requestId) {
1051
+ process.stderr.write(`[RPC] handleAbort called, abortController=${!!this.abortController}
1052
+ `);
1053
+ for (const [permId, pending] of this.pendingPermissions) {
1054
+ process.stderr.write(`[RPC] Clearing pending permission ${permId} due to abort
1055
+ `);
1056
+ if (pending.ackTimeout) clearTimeout(pending.ackTimeout);
1057
+ if (pending.responseTimeout) clearTimeout(pending.responseTimeout);
1058
+ pending.resolve({ decision: "deny_once" });
1059
+ }
1060
+ this.pendingPermissions.clear();
1061
+ if (this.abortController) {
1062
+ this.abortController.abort();
1063
+ this.stopKeepalive();
1064
+ this.status = "idle";
1065
+ if (this.currentMessageId) {
1066
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_END, {
1067
+ messageId: this.currentMessageId,
1068
+ content: this.currentMessageContent,
1069
+ // No marker - UI handles display
1070
+ aborted: true,
1071
+ timestamp: createTimestamp()
1072
+ });
1073
+ }
1074
+ if (this.currentTurnId) {
1075
+ const durationMs = this.turnStartTime ? Date.now() - this.turnStartTime : void 0;
1076
+ const snapshot = _optionalChain([this, 'access', _29 => _29.agent, 'optionalAccess', _30 => _30.getStatusSnapshot, 'call', _31 => _31()]);
1077
+ writeNotification(RPC_NOTIFICATIONS.TURN_END, {
1078
+ turnId: this.currentTurnId,
1079
+ timestamp: createTimestamp(),
1080
+ contextPercent: this.contextPercent,
1081
+ tokensUsed: _optionalChain([snapshot, 'optionalAccess', _32 => _32.tokensUsed]),
1082
+ durationMs
1083
+ });
1084
+ }
1085
+ this.currentTurnId = null;
1086
+ this.turnStartTime = null;
1087
+ this.currentMessageId = null;
1088
+ this.currentMessageContent = "";
1089
+ this.abortController = null;
1090
+ return { success: true };
1091
+ }
1092
+ return { success: false };
1093
+ }
1094
+ /**
1095
+ * Handle reset request
1096
+ */
1097
+ async handleReset(_requestId) {
1098
+ if (this.agent && this.conversation) {
1099
+ try {
1100
+ const { extractAndSaveSessionMemories } = await Promise.resolve().then(() => _interopRequireWildcard(require("./extractSessionMemories-XL3MS37F.cjs")));
1101
+ await extractAndSaveSessionMemories({
1102
+ llm: this.agent.getLlmProvider(),
1103
+ memoryManager: this.agent.getMemoryManager(),
1104
+ conversationHistory: this.conversation.history(),
1105
+ workspaceRoot: this.workspace
1106
+ });
1107
+ } catch (e3) {
1108
+ }
1109
+ }
1110
+ if (this.conversation) {
1111
+ const history = this.conversation.history();
1112
+ const systemPrompt = _nullishCoalesce(_optionalChain([history, 'access', _33 => _33.find, 'call', _34 => _34((m) => m.role === "system"), 'optionalAccess', _35 => _35.content]), () => ( ""));
1113
+ this.conversation.reset(systemPrompt);
1114
+ }
1115
+ _optionalChain([this, 'access', _36 => _36.imageManager, 'optionalAccess', _37 => _37.clear, 'call', _38 => _38()]);
1116
+ this.stopKeepalive();
1117
+ this.sessionId = generateId("session");
1118
+ this.status = "idle";
1119
+ this.currentTurnId = null;
1120
+ this.currentMessageId = null;
1121
+ this.currentMessageContent = "";
1122
+ writeNotification(RPC_NOTIFICATIONS.AGENT_START, {
1123
+ sessionId: this.sessionId,
1124
+ model: this.model,
1125
+ workspace: this.workspace,
1126
+ timestamp: createTimestamp()
1127
+ });
1128
+ return { sessionId: this.sessionId };
1129
+ }
1130
+ /**
1131
+ * Handle get_state request
1132
+ */
1133
+ handleGetState(_requestId) {
1134
+ return this.getState();
1135
+ }
1136
+ /**
1137
+ * Handle get_messages request
1138
+ */
1139
+ handleGetMessages(requestId, limit) {
1140
+ const messages = this.getMessages(limit);
1141
+ return { messages };
1142
+ }
1143
+ async handleBrowserHandoffCreate(_requestId, params) {
1144
+ const session = _optionalChain([this, 'access', _39 => _39.agent, 'optionalAccess', _40 => _40.getSessionManager, 'optionalCall', _41 => _41(), 'access', _42 => _42.getCurrentSession, 'optionalCall', _43 => _43()]);
1145
+ if (!session) {
1146
+ throw new Error("No active session available for browser handoff.");
1147
+ }
1148
+ return _chunkMPULXVC4cjs.createBrowserHandoff.call(void 0, {
1149
+ sessionId: session.metadata.sessionId,
1150
+ workspaceRoot: session.metadata.projectPath,
1151
+ extensionId: _optionalChain([params, 'optionalAccess', _44 => _44.extensionId]),
1152
+ installUrl: _optionalChain([params, 'optionalAccess', _45 => _45.installUrl])
1153
+ });
1154
+ }
1155
+ async handleBrowserHandoffAttach(_requestId, params) {
1156
+ const handoff = await _chunkMPULXVC4cjs.attachBrowserHandoff.call(void 0, params.token);
1157
+ if (!handoff) {
1158
+ return { success: false };
1159
+ }
1160
+ if (!this.agent) {
1161
+ throw new Error("Agent not initialized");
1162
+ }
1163
+ const attached = await this.agent.attachSession(handoff.sessionId);
1164
+ this.sessionId = attached.sessionId;
1165
+ this.stopKeepalive();
1166
+ this.stopKeepalive();
1167
+ this.workspace = attached.workspaceRoot;
1168
+ this.model = attached.model;
1169
+ this.status = "idle";
1170
+ return {
1171
+ success: true,
1172
+ sessionId: attached.sessionId,
1173
+ workspaceRoot: attached.workspaceRoot,
1174
+ messageCount: attached.messageCount
1175
+ };
1176
+ }
1177
+ async handleBrowserHandoffAttachLatest(_requestId, _params) {
1178
+ const handoff = await _chunkMPULXVC4cjs.attachLatestBrowserHandoff.call(void 0, );
1179
+ if (!handoff) {
1180
+ return { success: false };
1181
+ }
1182
+ if (!this.agent) {
1183
+ throw new Error("Agent not initialized");
1184
+ }
1185
+ const attached = await this.agent.attachSession(handoff.sessionId);
1186
+ this.stopKeepalive();
1187
+ this.sessionId = attached.sessionId;
1188
+ this.workspace = attached.workspaceRoot;
1189
+ this.model = attached.model;
1190
+ this.status = "idle";
1191
+ return {
1192
+ success: true,
1193
+ sessionId: attached.sessionId,
1194
+ workspaceRoot: attached.workspaceRoot,
1195
+ messageCount: attached.messageCount
1196
+ };
1197
+ }
1198
+ /**
1199
+ * Handle permission response from client
1200
+ */
1201
+ handlePermissionResponse(requestId, permRequestId, decision) {
1202
+ process.stderr.write(`[RPC] handlePermissionResponse called: permRequestId=${permRequestId}, allowed=${decision}, pending keys=${Array.from(this.pendingPermissions.keys()).join(",")}
1203
+ `);
1204
+ const pending = this.pendingPermissions.get(permRequestId);
1205
+ if (pending) {
1206
+ const normalized = _chunkVGEV44V2cjs.normalizePermissionPromptResponse.call(void 0, decision);
1207
+ process.stderr.write(`[RPC] Found pending permission, resolving with allowed=${normalized.decision}
1208
+ `);
1209
+ if (pending.ackTimeout) {
1210
+ clearTimeout(pending.ackTimeout);
1211
+ }
1212
+ if (pending.responseTimeout) {
1213
+ clearTimeout(pending.responseTimeout);
1214
+ }
1215
+ this.pendingPermissions.delete(permRequestId);
1216
+ pending.resolve(normalized);
1217
+ this.status = "processing";
1218
+ process.stderr.write(`[RPC] Permission resolved, status set to processing
1219
+ `);
1220
+ return { success: true };
1221
+ }
1222
+ process.stderr.write(`[RPC] Permission response for unknown request ${permRequestId}
1223
+ `);
1224
+ return { success: false };
1225
+ }
1226
+ /**
1227
+ * Request permission from client (called from agent's confirmDangerousAction)
1228
+ * Uses two-phase timeout:
1229
+ * - Phase 1: 30s to receive acknowledgment from extension
1230
+ * - Phase 2: 1 hour for user to respond after ack received
1231
+ */
1232
+ async requestPermission(tool, description, context) {
1233
+ const permRequestId = generateId("perm");
1234
+ this.status = "waiting_permission";
1235
+ process.stderr.write(`[RPC] requestPermission: tool=${tool}, permRequestId=${permRequestId}
1236
+ `);
1237
+ writeNotification(RPC_NOTIFICATIONS.PERMISSION_REQUEST, {
1238
+ requestId: permRequestId,
1239
+ tool,
1240
+ description,
1241
+ context,
1242
+ options: [
1243
+ "allow_once",
1244
+ "deny_once",
1245
+ "allow_session",
1246
+ "deny_session",
1247
+ "allow_always_project",
1248
+ "allow_always_user",
1249
+ "deny_always_project",
1250
+ "deny_always_user",
1251
+ "alternative"
1252
+ ],
1253
+ timestamp: createTimestamp()
1254
+ });
1255
+ return new Promise((resolve, reject) => {
1256
+ const ackTimeout = setTimeout(() => {
1257
+ this.pendingPermissions.delete(permRequestId);
1258
+ this.status = "processing";
1259
+ process.stderr.write(`[RPC] Permission ack timeout for ${permRequestId}
1260
+ `);
1261
+ resolve({ decision: "deny_once" });
1262
+ }, 3e4);
1263
+ this.pendingPermissions.set(permRequestId, {
1264
+ requestId: permRequestId,
1265
+ resolve,
1266
+ reject,
1267
+ ackTimeout,
1268
+ responseTimeout: null,
1269
+ acknowledged: false
1270
+ });
1271
+ });
1272
+ }
1273
+ /**
1274
+ * Handle acknowledgment from client that permission UI is shown
1275
+ * Extends timeout since we know extension is alive and user is deciding
1276
+ */
1277
+ handlePermissionAcknowledged(permRequestId) {
1278
+ const pending = this.pendingPermissions.get(permRequestId);
1279
+ if (!pending) {
1280
+ process.stderr.write(`[RPC] Permission ack for unknown request ${permRequestId}
1281
+ `);
1282
+ return { success: false };
1283
+ }
1284
+ if (pending.acknowledged) {
1285
+ return { success: true };
1286
+ }
1287
+ if (pending.ackTimeout) {
1288
+ clearTimeout(pending.ackTimeout);
1289
+ pending.ackTimeout = null;
1290
+ }
1291
+ pending.acknowledged = true;
1292
+ pending.responseTimeout = setTimeout(() => {
1293
+ this.pendingPermissions.delete(permRequestId);
1294
+ this.status = "processing";
1295
+ process.stderr.write(`[RPC] Permission response timeout for ${permRequestId} (1 hour)
1296
+ `);
1297
+ pending.resolve({ decision: "deny_once" });
1298
+ }, 36e5);
1299
+ process.stderr.write(`[RPC] Permission acknowledged for ${permRequestId}
1300
+ `);
1301
+ return { success: true };
1302
+ }
1303
+ /**
1304
+ * Request directory access from client (called from agent's requestDirectoryAccess)
1305
+ * Uses two-phase timeout similar to permission requests:
1306
+ * - Phase 1: 30s to receive acknowledgment from extension
1307
+ * - Phase 2: 1 hour for user to respond after ack received
1308
+ */
1309
+ async requestDirectoryAccess(dirPath, reason) {
1310
+ const requestId = generateId("dir");
1311
+ this.status = "waiting_permission";
1312
+ process.stderr.write(`[RPC] requestDirectoryAccess: path=${dirPath}, requestId=${requestId}
1313
+ `);
1314
+ writeNotification(RPC_NOTIFICATIONS.DIRECTORY_ACCESS_REQUEST, {
1315
+ requestId,
1316
+ path: dirPath,
1317
+ reason,
1318
+ timestamp: createTimestamp()
1319
+ });
1320
+ return new Promise((resolve, reject) => {
1321
+ const ackTimeout = setTimeout(() => {
1322
+ this.pendingDirectoryAccess.delete(requestId);
1323
+ this.status = "processing";
1324
+ process.stderr.write(`[RPC] Directory access ack timeout for ${requestId}
1325
+ `);
1326
+ resolve(void 0);
1327
+ }, 3e4);
1328
+ this.pendingDirectoryAccess.set(requestId, {
1329
+ requestId,
1330
+ path: dirPath,
1331
+ resolve,
1332
+ reject,
1333
+ ackTimeout,
1334
+ responseTimeout: null,
1335
+ acknowledged: false
1336
+ });
1337
+ });
1338
+ }
1339
+ /**
1340
+ * Handle acknowledgment from client that directory access UI is shown
1341
+ */
1342
+ handleDirectoryAccessAcknowledged(requestId) {
1343
+ const pending = this.pendingDirectoryAccess.get(requestId);
1344
+ if (!pending) {
1345
+ process.stderr.write(`[RPC] Directory access ack for unknown request ${requestId}
1346
+ `);
1347
+ return { success: false };
1348
+ }
1349
+ if (pending.acknowledged) {
1350
+ return { success: true };
1351
+ }
1352
+ if (pending.ackTimeout) {
1353
+ clearTimeout(pending.ackTimeout);
1354
+ pending.ackTimeout = null;
1355
+ }
1356
+ pending.acknowledged = true;
1357
+ pending.responseTimeout = setTimeout(() => {
1358
+ this.pendingDirectoryAccess.delete(requestId);
1359
+ this.status = "processing";
1360
+ process.stderr.write(`[RPC] Directory access response timeout for ${requestId} (1 hour)
1361
+ `);
1362
+ pending.resolve(void 0);
1363
+ }, 36e5);
1364
+ process.stderr.write(`[RPC] Directory access acknowledged for ${requestId}
1365
+ `);
1366
+ return { success: true };
1367
+ }
1368
+ /**
1369
+ * Handle directory access response from client
1370
+ */
1371
+ handleDirectoryAccessResponse(requestId, granted) {
1372
+ process.stderr.write(`[RPC] handleDirectoryAccessResponse: requestId=${requestId}, granted=${granted}
1373
+ `);
1374
+ const pending = this.pendingDirectoryAccess.get(requestId);
1375
+ if (pending) {
1376
+ if (pending.ackTimeout) {
1377
+ clearTimeout(pending.ackTimeout);
1378
+ }
1379
+ if (pending.responseTimeout) {
1380
+ clearTimeout(pending.responseTimeout);
1381
+ }
1382
+ this.pendingDirectoryAccess.delete(requestId);
1383
+ pending.resolve(granted ? pending.path : void 0);
1384
+ this.status = "processing";
1385
+ process.stderr.write(`[RPC] Directory access resolved, status set to processing
1386
+ `);
1387
+ return { success: true };
1388
+ }
1389
+ process.stderr.write(`[RPC] Directory access response for unknown request ${requestId}
1390
+ `);
1391
+ return { success: false };
1392
+ }
1393
+ /**
1394
+ * Emit tool execution start notification
1395
+ */
1396
+ emitToolStart(toolName, args) {
1397
+ const toolId = generateId("tool");
1398
+ writeNotification(RPC_NOTIFICATIONS.TOOL_START, {
1399
+ toolId,
1400
+ toolName,
1401
+ args,
1402
+ timestamp: createTimestamp()
1403
+ });
1404
+ return toolId;
1405
+ }
1406
+ /**
1407
+ * Emit tool execution update notification (streaming output)
1408
+ */
1409
+ emitToolUpdate(toolId, chunk) {
1410
+ writeNotification(RPC_NOTIFICATIONS.TOOL_UPDATE, {
1411
+ toolId,
1412
+ output: chunk.data,
1413
+ stream: chunk.stream,
1414
+ timestamp: createTimestamp()
1415
+ });
1416
+ }
1417
+ /**
1418
+ * Emit tool execution end notification
1419
+ */
1420
+ emitToolEnd(toolId, toolName, success, output, error) {
1421
+ writeNotification(RPC_NOTIFICATIONS.TOOL_END, {
1422
+ toolId,
1423
+ toolName,
1424
+ success,
1425
+ output,
1426
+ error,
1427
+ timestamp: createTimestamp()
1428
+ });
1429
+ }
1430
+ /**
1431
+ * Emit message update notification (streaming content)
1432
+ */
1433
+ emitMessageUpdate(delta, thought) {
1434
+ this.currentMessageContent += delta;
1435
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_UPDATE, {
1436
+ messageId: this.currentMessageId,
1437
+ delta,
1438
+ thought,
1439
+ timestamp: createTimestamp()
1440
+ });
1441
+ }
1442
+ // ============================================================================
1443
+ // Multi-File Change Preview Methods
1444
+ // ============================================================================
1445
+ /**
1446
+ * Emit changes batch start notification
1447
+ */
1448
+ emitChangesBatchStart(batchId) {
1449
+ process.stderr.write(`[RPC DEBUG] emitChangesBatchStart: batchId=${batchId}
1450
+ `);
1451
+ writeNotification(RPC_NOTIFICATIONS.CHANGES_BATCH_START, {
1452
+ batchId,
1453
+ turnId: _nullishCoalesce(this.currentTurnId, () => ( "")),
1454
+ timestamp: createTimestamp()
1455
+ });
1456
+ }
1457
+ /**
1458
+ * Emit changes batch update notification (individual file change)
1459
+ */
1460
+ emitChangesBatchUpdate(batchId, change) {
1461
+ process.stderr.write(`[RPC DEBUG] emitChangesBatchUpdate: batchId=${batchId}, changeId=${change.id}, file=${change.filePath}
1462
+ `);
1463
+ writeNotification(RPC_NOTIFICATIONS.CHANGES_BATCH_UPDATE, {
1464
+ batchId,
1465
+ change,
1466
+ timestamp: createTimestamp()
1467
+ });
1468
+ }
1469
+ /**
1470
+ * Emit changes batch end notification
1471
+ */
1472
+ emitChangesBatchEnd(batchId, changeCount) {
1473
+ process.stderr.write(`[RPC DEBUG] emitChangesBatchEnd: batchId=${batchId}, changeCount=${changeCount}
1474
+ `);
1475
+ writeNotification(RPC_NOTIFICATIONS.CHANGES_BATCH_END, {
1476
+ batchId,
1477
+ changeCount,
1478
+ timestamp: createTimestamp()
1479
+ });
1480
+ }
1481
+ // ============================================================================
1482
+ // Hook Lifecycle Notification Methods
1483
+ // ============================================================================
1484
+ /**
1485
+ * Emit hook pre-tool notification
1486
+ * Called before a tool begins execution
1487
+ */
1488
+ emitHookPreTool(toolId, toolName, args) {
1489
+ writeNotification(RPC_NOTIFICATIONS.HOOK_PRE_TOOL, {
1490
+ toolId,
1491
+ toolName,
1492
+ args,
1493
+ timestamp: createTimestamp()
1494
+ });
1495
+ }
1496
+ /**
1497
+ * Emit hook post-tool notification
1498
+ * Called after a tool completes execution
1499
+ */
1500
+ emitHookPostTool(toolId, toolName, success, duration, output) {
1501
+ writeNotification(RPC_NOTIFICATIONS.HOOK_POST_TOOL, {
1502
+ toolId,
1503
+ toolName,
1504
+ success,
1505
+ duration,
1506
+ output,
1507
+ timestamp: createTimestamp()
1508
+ });
1509
+ }
1510
+ /**
1511
+ * Emit hook file-modified notification
1512
+ * Called when a file is created, modified, or deleted
1513
+ */
1514
+ emitHookFileModified(filePath, changeType, toolId) {
1515
+ writeNotification(RPC_NOTIFICATIONS.HOOK_FILE_MODIFIED, {
1516
+ filePath,
1517
+ changeType,
1518
+ toolId,
1519
+ timestamp: createTimestamp()
1520
+ });
1521
+ }
1522
+ /**
1523
+ * Emit hook pre-prompt notification
1524
+ * Called before sending a prompt to the LLM
1525
+ */
1526
+ emitHookPrePrompt(instruction, mentionedFiles) {
1527
+ writeNotification(RPC_NOTIFICATIONS.HOOK_PRE_PROMPT, {
1528
+ instruction,
1529
+ mentionedFiles,
1530
+ timestamp: createTimestamp()
1531
+ });
1532
+ }
1533
+ /**
1534
+ * Emit hook post-response notification
1535
+ * Called after receiving a response from the LLM
1536
+ */
1537
+ emitHookPostResponse(tokensUsed, toolCallsCount, duration) {
1538
+ writeNotification(RPC_NOTIFICATIONS.HOOK_POST_RESPONSE, {
1539
+ tokensUsed,
1540
+ toolCallsCount,
1541
+ duration,
1542
+ timestamp: createTimestamp()
1543
+ });
1544
+ }
1545
+ /**
1546
+ * Emit hook session-error notification
1547
+ * Called when an error occurs during agent execution
1548
+ */
1549
+ emitHookSessionError(error, code, context) {
1550
+ writeNotification(RPC_NOTIFICATIONS.HOOK_SESSION_ERROR, {
1551
+ error,
1552
+ code,
1553
+ context,
1554
+ timestamp: createTimestamp()
1555
+ });
1556
+ }
1557
+ /**
1558
+ * Emit hook stop notification
1559
+ * Called when agent finishes responding to a turn
1560
+ */
1561
+ emitHookStop(tokensUsed, toolCallsCount, duration) {
1562
+ writeNotification(RPC_NOTIFICATIONS.HOOK_STOP, {
1563
+ tokensUsed,
1564
+ toolCallsCount,
1565
+ duration,
1566
+ timestamp: createTimestamp()
1567
+ });
1568
+ }
1569
+ /**
1570
+ * Emit hook session-start notification
1571
+ * Called when a session begins
1572
+ */
1573
+ emitHookSessionStart(sessionType) {
1574
+ writeNotification(RPC_NOTIFICATIONS.HOOK_SESSION_START, {
1575
+ sessionType,
1576
+ timestamp: createTimestamp()
1577
+ });
1578
+ }
1579
+ /**
1580
+ * Emit hook session-end notification
1581
+ * Called when a session ends
1582
+ */
1583
+ emitHookSessionEnd(reason, duration) {
1584
+ writeNotification(RPC_NOTIFICATIONS.HOOK_SESSION_END, {
1585
+ reason,
1586
+ duration,
1587
+ timestamp: createTimestamp()
1588
+ });
1589
+ }
1590
+ /**
1591
+ * Emit hook subagent-stop notification
1592
+ * Called when a subagent finishes execution
1593
+ */
1594
+ emitHookSubagentStop(subagentId, subagentName, subagentType, success, duration, error) {
1595
+ writeNotification(RPC_NOTIFICATIONS.HOOK_SUBAGENT_STOP, {
1596
+ subagentId,
1597
+ subagentName,
1598
+ subagentType,
1599
+ success,
1600
+ duration,
1601
+ error,
1602
+ timestamp: createTimestamp()
1603
+ });
1604
+ }
1605
+ /**
1606
+ * Emit hook permission-request notification
1607
+ * Called when a permission dialog is about to be shown
1608
+ */
1609
+ emitHookPermissionRequest(tool, path2, command, args) {
1610
+ writeNotification(RPC_NOTIFICATIONS.HOOK_PERMISSION_REQUEST, {
1611
+ tool,
1612
+ path: path2,
1613
+ command,
1614
+ args,
1615
+ timestamp: createTimestamp()
1616
+ });
1617
+ }
1618
+ /**
1619
+ * Emit hook notification
1620
+ * Called when a notification is sent to the user
1621
+ */
1622
+ emitHookNotification(notificationType, message) {
1623
+ writeNotification(RPC_NOTIFICATIONS.HOOK_NOTIFICATION, {
1624
+ notificationType,
1625
+ message,
1626
+ timestamp: createTimestamp()
1627
+ });
1628
+ }
1629
+ /**
1630
+ * Handle changes decision from client (accept/reject)
1631
+ */
1632
+ async handleChangesDecision(requestId, params) {
1633
+ const fileManager = _optionalChain([this, 'access', _46 => _46.agent, 'optionalAccess', _47 => _47.getFileManager, 'optionalCall', _48 => _48()]);
1634
+ if (!fileManager) {
1635
+ return {
1636
+ success: false,
1637
+ appliedCount: 0,
1638
+ skippedCount: 0,
1639
+ errors: [{ changeId: "unknown", error: "FileActionManager not available" }]
1640
+ };
1641
+ }
1642
+ const { action, selectedChangeIds, batchId } = params;
1643
+ if (fileManager.getBatchId() !== batchId) {
1644
+ return {
1645
+ success: false,
1646
+ appliedCount: 0,
1647
+ skippedCount: 0,
1648
+ errors: [{ changeId: "unknown", error: `Batch ${batchId} not found or expired` }]
1649
+ };
1650
+ }
1651
+ const pendingChanges = fileManager.getPendingChanges();
1652
+ const totalCount = pendingChanges.length;
1653
+ if (action === "reject_all") {
1654
+ fileManager.clearPendingChanges();
1655
+ fileManager.exitPreviewMode();
1656
+ return {
1657
+ success: true,
1658
+ appliedCount: 0,
1659
+ skippedCount: totalCount
1660
+ };
1661
+ }
1662
+ const changeIds = action === "accept_selected" ? selectedChangeIds : void 0;
1663
+ const result = await fileManager.applyPendingChanges(changeIds);
1664
+ fileManager.exitPreviewMode();
1665
+ return {
1666
+ success: result.errors.length === 0,
1667
+ appliedCount: result.applied.length,
1668
+ skippedCount: totalCount - result.applied.length,
1669
+ errors: result.errors.length > 0 ? result.errors.map((e) => ({ changeId: e.id, error: e.error })) : void 0
1670
+ };
1671
+ }
1672
+ // ============================================================================
1673
+ // Skills Management Methods (Non-Interactive for RPC Mode)
1674
+ // ============================================================================
1675
+ /**
1676
+ * Get community skills registry
1677
+ */
1678
+ async handleGetSkillsRegistry(requestId, params) {
1679
+ try {
1680
+ const { CommunitySkillsCache } = await Promise.resolve().then(() => _interopRequireWildcard(require("./CommunitySkillsCache-2OIUV227.cjs")));
1681
+ const { GitHubRegistryFetcher } = await Promise.resolve().then(() => _interopRequireWildcard(require("./GitHubRegistryFetcher-CYJLF2XL.cjs")));
1682
+ const cache = new CommunitySkillsCache();
1683
+ const fetcher = new GitHubRegistryFetcher();
1684
+ let registry;
1685
+ if (_optionalChain([params, 'optionalAccess', _49 => _49.forceRefresh])) {
1686
+ process.stderr.write("[RPC] Force refreshing skills registry from GitHub\n");
1687
+ registry = await fetcher.fetchRegistry();
1688
+ await cache.setRegistry(registry);
1689
+ } else {
1690
+ const cached = await cache.getRegistry();
1691
+ if (cached) {
1692
+ registry = cached;
1693
+ } else {
1694
+ process.stderr.write("[RPC] Fetching skills registry from GitHub\n");
1695
+ registry = await fetcher.fetchRegistry();
1696
+ await cache.setRegistry(registry);
1697
+ }
1698
+ }
1699
+ const skills = registry.skills.map((skill) => ({
1700
+ id: skill.id,
1701
+ name: skill.name,
1702
+ description: skill.description,
1703
+ category: skill.category,
1704
+ tags: skill.tags,
1705
+ rating: skill.rating,
1706
+ downloadCount: skill.downloadCount,
1707
+ isFeatured: skill.isFeatured,
1708
+ isCurated: skill.isCurated
1709
+ }));
1710
+ return {
1711
+ success: true,
1712
+ skills,
1713
+ categories: registry.categories
1714
+ };
1715
+ } catch (error) {
1716
+ const message = error instanceof Error ? error.message : "Unknown error";
1717
+ process.stderr.write(`[RPC] Failed to get skills registry: ${message}
1718
+ `);
1719
+ return {
1720
+ success: false,
1721
+ skills: [],
1722
+ categories: [],
1723
+ error: message
1724
+ };
1725
+ }
1726
+ }
1727
+ /**
1728
+ * Install a skill by name (non-interactive)
1729
+ */
1730
+ async handleInstallSkill(requestId, params) {
1731
+ try {
1732
+ const skillsRegistry = _optionalChain([this, 'access', _50 => _50.agent, 'optionalAccess', _51 => _51.getSkillsRegistry, 'optionalCall', _52 => _52()]);
1733
+ if (!skillsRegistry) {
1734
+ return {
1735
+ success: false,
1736
+ error: "Skills registry not available"
1737
+ };
1738
+ }
1739
+ const workspaceRoot = this.workspace;
1740
+ const { CommunitySkillsCache } = await Promise.resolve().then(() => _interopRequireWildcard(require("./CommunitySkillsCache-2OIUV227.cjs")));
1741
+ const { GitHubRegistryFetcher } = await Promise.resolve().then(() => _interopRequireWildcard(require("./GitHubRegistryFetcher-CYJLF2XL.cjs")));
1742
+ const { AUTOHAND_PATHS, PROJECT_DIR_NAME } = await Promise.resolve().then(() => _interopRequireWildcard(require("./constants-RLMJ5D5P.cjs")));
1743
+ const path2 = await Promise.resolve().then(() => _interopRequireWildcard(require("path")));
1744
+ const cache = new CommunitySkillsCache();
1745
+ const fetcher = new GitHubRegistryFetcher();
1746
+ let registry = await cache.getRegistry();
1747
+ if (!registry) {
1748
+ process.stderr.write("[RPC] Fetching skills registry for install\n");
1749
+ registry = await fetcher.fetchRegistry();
1750
+ await cache.setRegistry(registry);
1751
+ }
1752
+ const skill = fetcher.findSkill(registry.skills, params.skillName);
1753
+ if (!skill) {
1754
+ const similar = fetcher.findSimilarSkills(registry.skills, params.skillName, 3);
1755
+ const suggestions = similar.map((s) => s.name).join(", ");
1756
+ return {
1757
+ success: false,
1758
+ error: `Skill not found: ${params.skillName}${suggestions ? `. Did you mean: ${suggestions}?` : ""}`
1759
+ };
1760
+ }
1761
+ const targetDir = params.scope === "project" ? path2.join(workspaceRoot, PROJECT_DIR_NAME, "skills") : AUTOHAND_PATHS.skills;
1762
+ const isInstalled = await skillsRegistry.isSkillInstalled(skill.name, targetDir);
1763
+ if (isInstalled && !params.force) {
1764
+ return {
1765
+ success: false,
1766
+ error: `Skill "${skill.name}" already exists. Use force=true to overwrite.`
1767
+ };
1768
+ }
1769
+ process.stderr.write(`[RPC] Installing skill ${skill.name} to ${params.scope}
1770
+ `);
1771
+ let files = await cache.getSkillDirectory(skill.id);
1772
+ if (!files) {
1773
+ process.stderr.write(`[RPC] Fetching skill files from GitHub
1774
+ `);
1775
+ files = await fetcher.fetchSkillDirectory(skill);
1776
+ await cache.setSkillDirectory(skill.id, files);
1777
+ }
1778
+ const result = await skillsRegistry.importCommunitySkillDirectory(
1779
+ skill.name,
1780
+ files,
1781
+ targetDir,
1782
+ isInstalled
1783
+ // force if overwriting
1784
+ );
1785
+ if (result.success) {
1786
+ process.stderr.write(`[RPC] Successfully installed ${skill.name}
1787
+ `);
1788
+ return {
1789
+ success: true,
1790
+ skillName: skill.name,
1791
+ path: result.path
1792
+ };
1793
+ } else {
1794
+ return {
1795
+ success: false,
1796
+ error: result.error || "Installation failed"
1797
+ };
1798
+ }
1799
+ } catch (error) {
1800
+ const message = error instanceof Error ? error.message : "Unknown error";
1801
+ process.stderr.write(`[RPC] Failed to install skill: ${message}
1802
+ `);
1803
+ return {
1804
+ success: false,
1805
+ error: message
1806
+ };
1807
+ }
1808
+ }
1809
+ // ============================================================================
1810
+ // Learn Command Methods (RPC Mode)
1811
+ // ============================================================================
1812
+ /**
1813
+ * Handle /learn recommend - analyze project and recommend skills
1814
+ */
1815
+ async handleLearnRecommend(requestId, params) {
1816
+ try {
1817
+ const { ProjectAnalyzer } = await Promise.resolve().then(() => _interopRequireWildcard(require("./autoSkill-YOLLFTP2.cjs")));
1818
+ const { CommunitySkillsCache } = await Promise.resolve().then(() => _interopRequireWildcard(require("./CommunitySkillsCache-2OIUV227.cjs")));
1819
+ const { GitHubRegistryFetcher } = await Promise.resolve().then(() => _interopRequireWildcard(require("./GitHubRegistryFetcher-CYJLF2XL.cjs")));
1820
+ const { fetchRegistryWithFallback } = await Promise.resolve().then(() => _interopRequireWildcard(require("./communityInstaller-TWMGPSYM.cjs")));
1821
+ const { LearnAdvisor } = await Promise.resolve().then(() => _interopRequireWildcard(require("./LearnAdvisor-XBRDNAGH.cjs")));
1822
+ const workspace = this.workspace || process.cwd();
1823
+ const deep = _nullishCoalesce(_optionalChain([params, 'optionalAccess', _53 => _53.deep]), () => ( false));
1824
+ writeNotification(RPC_NOTIFICATIONS.LEARN_PROGRESS, {
1825
+ status: "analyzing",
1826
+ timestamp: createTimestamp()
1827
+ });
1828
+ process.stderr.write(`[RPC] Learn recommend: analyzing project (deep=${deep})
1829
+ `);
1830
+ const analyzer = new ProjectAnalyzer(workspace);
1831
+ const analysis = await analyzer.analyze();
1832
+ writeNotification(RPC_NOTIFICATIONS.LEARN_PROGRESS, {
1833
+ status: "loading-registry",
1834
+ timestamp: createTimestamp()
1835
+ });
1836
+ const cache = new CommunitySkillsCache();
1837
+ const fetcher = new GitHubRegistryFetcher();
1838
+ let registry;
1839
+ try {
1840
+ registry = await fetchRegistryWithFallback(cache, fetcher);
1841
+ } catch (e4) {
1842
+ }
1843
+ const skillsRegistry = _optionalChain([this, 'access', _54 => _54.agent, 'optionalAccess', _55 => _55.getSkillsRegistry, 'optionalCall', _56 => _56()]);
1844
+ const installedSkills = _nullishCoalesce(_optionalChain([skillsRegistry, 'optionalAccess', _57 => _57.listSkills, 'call', _58 => _58()]), () => ( []));
1845
+ const registrySkills = _nullishCoalesce(_optionalChain([registry, 'optionalAccess', _59 => _59.skills]), () => ( []));
1846
+ writeNotification(RPC_NOTIFICATIONS.LEARN_PROGRESS, {
1847
+ status: "evaluating",
1848
+ timestamp: createTimestamp()
1849
+ });
1850
+ const llm = _optionalChain([this, 'access', _60 => _60.agent, 'optionalAccess', _61 => _61.getLlmProvider, 'optionalCall', _62 => _62()]);
1851
+ if (!llm) {
1852
+ return {
1853
+ success: false,
1854
+ projectSummary: "",
1855
+ audit: [],
1856
+ recommendations: [],
1857
+ gapAnalysis: null,
1858
+ error: "LLM provider not available"
1859
+ };
1860
+ }
1861
+ const advisor = new LearnAdvisor(llm);
1862
+ const result = await advisor.analyze(analysis, installedSkills, registrySkills);
1863
+ return {
1864
+ success: true,
1865
+ projectSummary: result.projectSummary,
1866
+ audit: result.audit,
1867
+ recommendations: result.recommendations,
1868
+ gapAnalysis: result.gapAnalysis
1869
+ };
1870
+ } catch (error) {
1871
+ const message = error instanceof Error ? error.message : "Unknown error";
1872
+ process.stderr.write(`[RPC] Learn recommend failed: ${message}
1873
+ `);
1874
+ return {
1875
+ success: false,
1876
+ projectSummary: "",
1877
+ audit: [],
1878
+ recommendations: [],
1879
+ gapAnalysis: null,
1880
+ error: message
1881
+ };
1882
+ }
1883
+ }
1884
+ /**
1885
+ * Handle /learn update - regenerate stale LLM-generated skills
1886
+ */
1887
+ async handleLearnUpdate(_requestId, _params) {
1888
+ try {
1889
+ const { ProjectAnalyzer } = await Promise.resolve().then(() => _interopRequireWildcard(require("./autoSkill-YOLLFTP2.cjs")));
1890
+ const { computeProjectHash, injectGeneratedMetadata } = await Promise.resolve().then(() => _interopRequireWildcard(require("./communityInstaller-TWMGPSYM.cjs")));
1891
+ const { LearnAdvisor } = await Promise.resolve().then(() => _interopRequireWildcard(require("./LearnAdvisor-XBRDNAGH.cjs")));
1892
+ const fse = await Promise.resolve().then(() => _interopRequireWildcard(require("fs-extra")));
1893
+ const workspace = this.workspace || process.cwd();
1894
+ writeNotification(RPC_NOTIFICATIONS.LEARN_PROGRESS, {
1895
+ status: "updating",
1896
+ timestamp: createTimestamp()
1897
+ });
1898
+ process.stderr.write("[RPC] Learn update: checking for stale skills\n");
1899
+ const analyzer = new ProjectAnalyzer(workspace);
1900
+ const analysis = await analyzer.analyze();
1901
+ const currentHash = computeProjectHash(analysis);
1902
+ const skillsRegistry = _optionalChain([this, 'access', _63 => _63.agent, 'optionalAccess', _64 => _64.getSkillsRegistry, 'optionalCall', _65 => _65()]);
1903
+ if (!skillsRegistry) {
1904
+ return { success: false, updated: 0, unchanged: 0, results: [], error: "Skills registry not available" };
1905
+ }
1906
+ const allSkills = skillsRegistry.listSkills();
1907
+ const generatedSkills = allSkills.filter(
1908
+ (s) => _optionalChain([s, 'access', _66 => _66.metadata, 'optionalAccess', _67 => _67["agentskill-source"]]) === "llm-generated"
1909
+ );
1910
+ if (generatedSkills.length === 0) {
1911
+ return { success: true, updated: 0, unchanged: 0, results: [] };
1912
+ }
1913
+ const llm = _optionalChain([this, 'access', _68 => _68.agent, 'optionalAccess', _69 => _69.getLlmProvider, 'optionalCall', _70 => _70()]);
1914
+ if (!llm) {
1915
+ return { success: false, updated: 0, unchanged: 0, results: [], error: "LLM provider not available" };
1916
+ }
1917
+ const advisor = new LearnAdvisor(llm);
1918
+ let updated = 0;
1919
+ let unchanged = 0;
1920
+ const results = [];
1921
+ for (const skill of generatedSkills) {
1922
+ const storedHash = _optionalChain([skill, 'access', _71 => _71.metadata, 'optionalAccess', _72 => _72["agentskill-project-hash"]]);
1923
+ if (storedHash === currentHash) {
1924
+ unchanged++;
1925
+ results.push({ name: skill.name, status: "unchanged" });
1926
+ continue;
1927
+ }
1928
+ const generated = await advisor.generateSkill(analysis, null, []);
1929
+ if (!generated) {
1930
+ results.push({ name: skill.name, status: "failed" });
1931
+ continue;
1932
+ }
1933
+ let frontmatter = `---
1934
+ name: ${generated.name}
1935
+ description: ${generated.description}
1936
+ `;
1937
+ if (generated.allowedTools.length > 0) {
1938
+ frontmatter += `allowed-tools: ${generated.allowedTools.join(" ")}
1939
+ `;
1940
+ }
1941
+ frontmatter += `---
1942
+
1943
+ `;
1944
+ let content = frontmatter + generated.body + "\n";
1945
+ content = injectGeneratedMetadata(content, skill.name, currentHash);
1946
+ try {
1947
+ await fse.writeFile(skill.path, content, "utf-8");
1948
+ updated++;
1949
+ results.push({ name: skill.name, status: "updated" });
1950
+ } catch (e5) {
1951
+ results.push({ name: skill.name, status: "failed" });
1952
+ }
1953
+ }
1954
+ return { success: true, updated, unchanged, results };
1955
+ } catch (error) {
1956
+ const message = error instanceof Error ? error.message : "Unknown error";
1957
+ process.stderr.write(`[RPC] Learn update failed: ${message}
1958
+ `);
1959
+ return { success: false, updated: 0, unchanged: 0, results: [], error: message };
1960
+ }
1961
+ }
1962
+ /**
1963
+ * Handle /learn generate - generate a custom skill for the project
1964
+ */
1965
+ async handleLearnGenerate(requestId, params) {
1966
+ try {
1967
+ const { ProjectAnalyzer } = await Promise.resolve().then(() => _interopRequireWildcard(require("./autoSkill-YOLLFTP2.cjs")));
1968
+ const { computeProjectHash, injectGeneratedMetadata } = await Promise.resolve().then(() => _interopRequireWildcard(require("./communityInstaller-TWMGPSYM.cjs")));
1969
+ const { LearnAdvisor } = await Promise.resolve().then(() => _interopRequireWildcard(require("./LearnAdvisor-XBRDNAGH.cjs")));
1970
+ const { AUTOHAND_PATHS, PROJECT_DIR_NAME } = await Promise.resolve().then(() => _interopRequireWildcard(require("./constants-RLMJ5D5P.cjs")));
1971
+ const fse = await Promise.resolve().then(() => _interopRequireWildcard(require("fs-extra")));
1972
+ const path2 = await Promise.resolve().then(() => _interopRequireWildcard(require("path")));
1973
+ const workspace = this.workspace || process.cwd();
1974
+ const scope = params.scope;
1975
+ writeNotification(RPC_NOTIFICATIONS.LEARN_PROGRESS, {
1976
+ status: "generating",
1977
+ timestamp: createTimestamp()
1978
+ });
1979
+ process.stderr.write(`[RPC] Learn generate: scope=${scope}
1980
+ `);
1981
+ const llm = _optionalChain([this, 'access', _73 => _73.agent, 'optionalAccess', _74 => _74.getLlmProvider, 'optionalCall', _75 => _75()]);
1982
+ if (!llm) {
1983
+ return { success: false, error: "LLM provider not available" };
1984
+ }
1985
+ const analyzer = new ProjectAnalyzer(workspace);
1986
+ const analysis = await analyzer.analyze();
1987
+ const projectHash = computeProjectHash(analysis);
1988
+ const advisor = new LearnAdvisor(llm);
1989
+ const generated = await advisor.generateSkill(analysis, null, []);
1990
+ if (!generated) {
1991
+ return { success: false, error: "Failed to generate a custom skill" };
1992
+ }
1993
+ let frontmatter = `---
1994
+ name: ${generated.name}
1995
+ description: ${generated.description}
1996
+ `;
1997
+ if (generated.allowedTools.length > 0) {
1998
+ frontmatter += `allowed-tools: ${generated.allowedTools.join(" ")}
1999
+ `;
2000
+ }
2001
+ frontmatter += `---
2002
+
2003
+ `;
2004
+ let skillContent = frontmatter + generated.body + "\n";
2005
+ skillContent = injectGeneratedMetadata(skillContent, generated.name, projectHash);
2006
+ const targetDir = scope === "project" ? path2.join(workspace, PROJECT_DIR_NAME, "skills") : AUTOHAND_PATHS.skills;
2007
+ const skillDir = path2.join(targetDir, generated.name);
2008
+ await fse.ensureDir(skillDir);
2009
+ const skillPath = path2.join(skillDir, "SKILL.md");
2010
+ await fse.writeFile(skillPath, skillContent, "utf-8");
2011
+ return { success: true, skillName: generated.name, skillPath };
2012
+ } catch (error) {
2013
+ const message = error instanceof Error ? error.message : "Unknown error";
2014
+ process.stderr.write(`[RPC] Learn generate failed: ${message}
2015
+ `);
2016
+ return { success: false, error: message };
2017
+ }
2018
+ }
2019
+ // ============================================================================
2020
+ // Session History, YOLO, and MCP Handlers
2021
+ // ============================================================================
2022
+ /**
2023
+ * Get paginated session history
2024
+ */
2025
+ async handleGetHistory(_requestId, params) {
2026
+ const sessionManager = _optionalChain([this, 'access', _76 => _76.agent, 'optionalAccess', _77 => _77.getSessionManager, 'optionalCall', _78 => _78()]);
2027
+ if (!sessionManager) {
2028
+ return { sessions: [], currentPage: 1, totalPages: 0, totalItems: 0 };
2029
+ }
2030
+ try {
2031
+ const allSessions = await sessionManager.listSessions();
2032
+ const page = _nullishCoalesce(_optionalChain([params, 'optionalAccess', _79 => _79.page]), () => ( 1));
2033
+ const pageSize = _nullishCoalesce(_optionalChain([params, 'optionalAccess', _80 => _80.pageSize]), () => ( 20));
2034
+ const totalItems = allSessions.length;
2035
+ const totalPages = Math.max(1, Math.ceil(totalItems / pageSize));
2036
+ const startIndex = (page - 1) * pageSize;
2037
+ const pageSessions = allSessions.slice(startIndex, startIndex + pageSize);
2038
+ return {
2039
+ sessions: pageSessions.map((s) => ({
2040
+ sessionId: s.sessionId,
2041
+ createdAt: s.createdAt,
2042
+ lastActiveAt: _nullishCoalesce(s.lastActiveAt, () => ( s.createdAt)),
2043
+ projectName: _nullishCoalesce(s.projectName, () => ( "")),
2044
+ model: _nullishCoalesce(s.model, () => ( "")),
2045
+ messageCount: _nullishCoalesce(s.messageCount, () => ( 0)),
2046
+ status: _nullishCoalesce(s.status, () => ( "completed"))
2047
+ })),
2048
+ currentPage: page,
2049
+ totalPages,
2050
+ totalItems
2051
+ };
2052
+ } catch (error) {
2053
+ const message = error instanceof Error ? error.message : String(error);
2054
+ process.stderr.write(`[RPC] Failed to get history: ${message}
2055
+ `);
2056
+ return { sessions: [], currentPage: 1, totalPages: 0, totalItems: 0 };
2057
+ }
2058
+ }
2059
+ /**
2060
+ * Get a specific session's metadata and messages
2061
+ */
2062
+ async handleGetSession(_requestId, params) {
2063
+ const sessionManager = _optionalChain([this, 'access', _81 => _81.agent, 'optionalAccess', _82 => _82.getSessionManager, 'optionalCall', _83 => _83()]);
2064
+ if (!sessionManager) {
2065
+ return { success: false, error: "Session manager not available" };
2066
+ }
2067
+ try {
2068
+ const session = await sessionManager.loadSession(params.sessionId);
2069
+ const m = session.metadata;
2070
+ const messages = session.getMessages().map((msg) => ({
2071
+ id: msg.role === "user" ? `user-${_crypto2.default.randomUUID()}` : `msg-${_crypto2.default.randomUUID()}`,
2072
+ role: msg.role,
2073
+ content: msg.content,
2074
+ timestamp: new Date(m.createdAt).toISOString(),
2075
+ toolCalls: (_nullishCoalesce(msg.toolCalls, () => ( []))).map((tc) => ({
2076
+ id: _nullishCoalesce(tc.callId, () => ( "")),
2077
+ name: _nullishCoalesce(tc.name, () => ( "")),
2078
+ args: _nullishCoalesce(tc.arguments, () => ( {}))
2079
+ }))
2080
+ }));
2081
+ return {
2082
+ success: true,
2083
+ sessionId: m.sessionId,
2084
+ projectName: _nullishCoalesce(m.projectName, () => ( "")),
2085
+ model: _nullishCoalesce(m.model, () => ( "")),
2086
+ messageCount: _nullishCoalesce(m.messageCount, () => ( 0)),
2087
+ status: _nullishCoalesce(m.status, () => ( "completed")),
2088
+ createdAt: m.createdAt,
2089
+ lastActiveAt: _nullishCoalesce(m.lastActiveAt, () => ( m.createdAt)),
2090
+ summary: m.summary,
2091
+ messages,
2092
+ workspaceRoot: _nullishCoalesce(m.projectPath, () => ( ""))
2093
+ };
2094
+ } catch (error) {
2095
+ const message = error instanceof Error ? error.message : String(error);
2096
+ process.stderr.write(`[RPC] Failed to get session: ${message}
2097
+ `);
2098
+ return {
2099
+ success: false,
2100
+ error: message,
2101
+ sessionId: params.sessionId,
2102
+ projectName: "",
2103
+ model: "",
2104
+ messageCount: 0,
2105
+ status: "completed",
2106
+ createdAt: "",
2107
+ lastActiveAt: "",
2108
+ messages: [],
2109
+ workspaceRoot: ""
2110
+ };
2111
+ }
2112
+ }
2113
+ /**
2114
+ * Set YOLO (unrestricted) mode with pattern and optional timeout
2115
+ */
2116
+ handleYoloSet(_requestId, params) {
2117
+ const permissionManager = _optionalChain([this, 'access', _84 => _84.agent, 'optionalAccess', _85 => _85.getPermissionManager, 'optionalCall', _86 => _86()]);
2118
+ if (!permissionManager) {
2119
+ return { success: false };
2120
+ }
2121
+ try {
2122
+ permissionManager.setMode("unrestricted");
2123
+ process.stderr.write(`[RPC] YOLO mode enabled with pattern: ${params.pattern}
2124
+ `);
2125
+ let expiresIn;
2126
+ if (params.timeoutSeconds && params.timeoutSeconds > 0) {
2127
+ expiresIn = params.timeoutSeconds;
2128
+ setTimeout(() => {
2129
+ permissionManager.setMode("interactive");
2130
+ process.stderr.write(`[RPC] YOLO mode expired, reverted to interactive
2131
+ `);
2132
+ }, params.timeoutSeconds * 1e3);
2133
+ }
2134
+ return { success: true, expiresIn };
2135
+ } catch (error) {
2136
+ const message = error instanceof Error ? error.message : String(error);
2137
+ process.stderr.write(`[RPC] Failed to set YOLO mode: ${message}
2138
+ `);
2139
+ return { success: false };
2140
+ }
2141
+ }
2142
+ /**
2143
+ * List all MCP servers and their connection status
2144
+ */
2145
+ handleMcpListServers(_requestId) {
2146
+ const mcpManager = _optionalChain([this, 'access', _87 => _87.agent, 'optionalAccess', _88 => _88.getMcpManager, 'optionalCall', _89 => _89()]);
2147
+ if (!mcpManager) {
2148
+ return { servers: [] };
2149
+ }
2150
+ return { servers: mcpManager.getServers() };
2151
+ }
2152
+ /**
2153
+ * List all MCP tools, optionally filtered by server name
2154
+ */
2155
+ handleMcpListTools(_requestId, params) {
2156
+ const mcpManager = _optionalChain([this, 'access', _90 => _90.agent, 'optionalAccess', _91 => _91.getMcpManager, 'optionalCall', _92 => _92()]);
2157
+ if (!mcpManager) {
2158
+ return { tools: [] };
2159
+ }
2160
+ const allTools = _optionalChain([params, 'optionalAccess', _93 => _93.serverName]) ? mcpManager.getToolsForServer(params.serverName) : mcpManager.getAllTools();
2161
+ return {
2162
+ tools: allTools.map((t) => {
2163
+ const parsed = _chunkDI57A4BXcjs.McpClientManager.parseMcpToolName(t.name);
2164
+ return {
2165
+ name: t.name,
2166
+ description: t.description,
2167
+ serverName: _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _94 => _94.serverName]), () => ( "unknown"))
2168
+ };
2169
+ })
2170
+ };
2171
+ }
2172
+ /**
2173
+ * List persisted meta-tools and registry diagnostics for non-interactive clients.
2174
+ */
2175
+ handleGetToolsRegistry() {
2176
+ const registry = _optionalChain([this, 'access', _95 => _95.agent, 'optionalAccess', _96 => _96.getToolsRegistry, 'optionalCall', _97 => _97()]);
2177
+ if (!registry) {
2178
+ return { tools: [], diagnostics: [] };
2179
+ }
2180
+ return {
2181
+ tools: registry.listMetaTools({ includeDisabled: true }).map((tool) => ({
2182
+ name: tool.name,
2183
+ description: tool.description,
2184
+ source: "meta",
2185
+ scope: tool.scope,
2186
+ disabled: tool.disabled,
2187
+ createdAt: tool.createdAt,
2188
+ schemaVersion: tool.schemaVersion,
2189
+ handlerPreview: tool.handler.length > 140 ? `${tool.handler.slice(0, 137)}...` : tool.handler,
2190
+ reuseHint: `Use ${tool.name} instead of creating another tool for: ${tool.description}`
2191
+ })),
2192
+ diagnostics: registry.getDiagnostics()
2193
+ };
2194
+ }
2195
+ // ============================================================================
2196
+ // MCP Bridge Methods (VS Code <-> CLI bidirectional tool bridging)
2197
+ // ============================================================================
2198
+ /**
2199
+ * Receive VS Code MCP tool descriptors from the extension.
2200
+ * These tools become available for the agent to invoke via the extension.
2201
+ * Tool names are stored with a 'vscode__' prefix to distinguish them.
2202
+ */
2203
+ handleMcpSetVscodeTools(_requestId, params) {
2204
+ this.vscodeTools.clear();
2205
+ for (const tool of params.tools) {
2206
+ const prefixedName = `vscode__${tool.serverName}__${tool.name}`;
2207
+ this.vscodeTools.set(prefixedName, {
2208
+ name: tool.name,
2209
+ description: tool.description,
2210
+ serverName: tool.serverName,
2211
+ inputSchema: tool.inputSchema
2212
+ });
2213
+ }
2214
+ process.stderr.write(
2215
+ `[RPC] MCP bridge: registered ${this.vscodeTools.size} VS Code tools
2216
+ `
2217
+ );
2218
+ const allTools = this.getVscodeToolsList();
2219
+ writeNotification(RPC_NOTIFICATIONS.MCP_TOOLS_CHANGED, {
2220
+ tools: allTools,
2221
+ timestamp: createTimestamp()
2222
+ });
2223
+ return { success: true };
2224
+ }
2225
+ /**
2226
+ * Get the list of registered VS Code tools for notifications
2227
+ */
2228
+ getVscodeToolsList() {
2229
+ const tools = [];
2230
+ for (const [prefixedName, tool] of this.vscodeTools) {
2231
+ tools.push({
2232
+ name: prefixedName,
2233
+ description: tool.description,
2234
+ serverName: tool.serverName
2235
+ });
2236
+ }
2237
+ return tools;
2238
+ }
2239
+ /**
2240
+ * Invoke a VS Code MCP tool by sending a notification to the extension
2241
+ * and waiting for the response. Called internally when the agent uses
2242
+ * a tool with the 'vscode__' prefix.
2243
+ */
2244
+ async invokeVscodeTool(toolName, args) {
2245
+ const tool = this.vscodeTools.get(toolName);
2246
+ if (!tool) {
2247
+ throw new Error(`VS Code tool not found: ${toolName}`);
2248
+ }
2249
+ const requestId = generateId("mcp-invoke");
2250
+ writeNotification(RPC_NOTIFICATIONS.MCP_INVOKE_REQUEST, {
2251
+ requestId,
2252
+ toolName,
2253
+ args,
2254
+ timestamp: createTimestamp()
2255
+ });
2256
+ return new Promise((resolve, reject) => {
2257
+ const timeout = setTimeout(() => {
2258
+ this.pendingVscodeInvocations.delete(requestId);
2259
+ reject(new Error(`VS Code tool invocation timed out: ${toolName}`));
2260
+ }, 3e5);
2261
+ this.pendingVscodeInvocations.set(requestId, {
2262
+ resolve: (result) => {
2263
+ clearTimeout(timeout);
2264
+ resolve(result);
2265
+ },
2266
+ reject: (error) => {
2267
+ clearTimeout(timeout);
2268
+ reject(error);
2269
+ }
2270
+ });
2271
+ });
2272
+ }
2273
+ /**
2274
+ * Handle the invoke response from the extension for a pending VS Code tool call.
2275
+ * Resolves or rejects the promise created in invokeVscodeTool.
2276
+ */
2277
+ handleMcpInvokeResponse(_requestId, params) {
2278
+ const pending = this.pendingVscodeInvocations.get(params.requestId);
2279
+ if (!pending) {
2280
+ process.stderr.write(
2281
+ `[RPC] MCP bridge: invoke response for unknown request ${params.requestId}
2282
+ `
2283
+ );
2284
+ return { success: false };
2285
+ }
2286
+ this.pendingVscodeInvocations.delete(params.requestId);
2287
+ if (params.success) {
2288
+ pending.resolve(_nullishCoalesce(params.result, () => ( "")));
2289
+ } else {
2290
+ pending.reject(new Error(_nullishCoalesce(params.error, () => ( "VS Code tool invocation failed"))));
2291
+ }
2292
+ return { success: true };
2293
+ }
2294
+ /**
2295
+ * Return MCP server configurations from the CLI config.
2296
+ * Sensitive environment variables (keys, tokens, secrets) are sanitized.
2297
+ */
2298
+ handleMcpGetServerConfigs(_requestId) {
2299
+ const configs = this.mcpServerConfigs.map((server) => ({
2300
+ name: server.name,
2301
+ transport: server.transport,
2302
+ command: server.command,
2303
+ args: server.args,
2304
+ url: server.url,
2305
+ env: server.env ? this.sanitizeEnv(server.env) : void 0,
2306
+ headers: server.headers ? this.sanitizeHeaders(server.headers) : void 0,
2307
+ autoConnect: server.autoConnect
2308
+ }));
2309
+ return { configs };
2310
+ }
2311
+ /**
2312
+ * Check if a tool name is a registered VS Code MCP tool
2313
+ */
2314
+ isVscodeTool(toolName) {
2315
+ return this.vscodeTools.has(toolName);
2316
+ }
2317
+ /**
2318
+ * Sanitize environment variables by redacting values that look like secrets.
2319
+ * Keeps the key names but replaces sensitive values with '***'.
2320
+ */
2321
+ sanitizeEnv(env) {
2322
+ const sensitivePatterns = /key|token|secret|password|credential|auth/i;
2323
+ const sanitized = {};
2324
+ for (const [key, value] of Object.entries(env)) {
2325
+ if (sensitivePatterns.test(key)) {
2326
+ sanitized[key] = "***";
2327
+ } else {
2328
+ sanitized[key] = value;
2329
+ }
2330
+ }
2331
+ return sanitized;
2332
+ }
2333
+ /**
2334
+ * Sanitize HTTP headers by redacting values that look like auth tokens.
2335
+ */
2336
+ sanitizeHeaders(headers) {
2337
+ const sensitivePatterns = /authorization|token|key|secret|bearer/i;
2338
+ const sanitized = {};
2339
+ for (const [key, value] of Object.entries(headers)) {
2340
+ if (sensitivePatterns.test(key)) {
2341
+ sanitized[key] = "***";
2342
+ } else {
2343
+ sanitized[key] = value;
2344
+ }
2345
+ }
2346
+ return sanitized;
2347
+ }
2348
+ /**
2349
+ * Shutdown the adapter
2350
+ */
2351
+ startKeepalive() {
2352
+ this.stopKeepalive();
2353
+ this.keepaliveInterval = setInterval(() => {
2354
+ writeNotification(RPC_NOTIFICATIONS.PING, {
2355
+ timestamp: createTimestamp(),
2356
+ status: this.status,
2357
+ turnId: this.currentTurnId
2358
+ });
2359
+ }, this.KEEPALIVE_MS);
2360
+ }
2361
+ stopKeepalive() {
2362
+ if (this.keepaliveInterval) {
2363
+ clearInterval(this.keepaliveInterval);
2364
+ this.keepaliveInterval = null;
2365
+ }
2366
+ }
2367
+ shutdown(reason = "completed") {
2368
+ this.stopKeepalive();
2369
+ for (const [, pending] of this.pendingPermissions) {
2370
+ if (pending.ackTimeout) {
2371
+ clearTimeout(pending.ackTimeout);
2372
+ }
2373
+ if (pending.responseTimeout) {
2374
+ clearTimeout(pending.responseTimeout);
2375
+ }
2376
+ pending.reject(new Error("Adapter shutdown"));
2377
+ }
2378
+ this.pendingPermissions.clear();
2379
+ for (const [, pending] of this.pendingVscodeInvocations) {
2380
+ pending.reject(new Error("Adapter shutdown"));
2381
+ }
2382
+ this.pendingVscodeInvocations.clear();
2383
+ if (this.abortController) {
2384
+ this.abortController.abort();
2385
+ }
2386
+ writeNotification(RPC_NOTIFICATIONS.AGENT_END, {
2387
+ sessionId: this.sessionId,
2388
+ reason,
2389
+ timestamp: createTimestamp()
2390
+ });
2391
+ }
2392
+ /**
2393
+ * Handle output events from the agent
2394
+ */
2395
+ handleAgentOutput(event) {
2396
+ process.stderr.write(`[RPC DEBUG] handleAgentOutput: type=${event.type}, content length=${_nullishCoalesce(_optionalChain([event, 'access', _98 => _98.content, 'optionalAccess', _99 => _99.length]), () => ( 0))}
2397
+ `);
2398
+ switch (event.type) {
2399
+ case "thinking":
2400
+ if (event.thought) {
2401
+ process.stderr.write(`[RPC DEBUG] Emitting thinking: ${event.thought.substring(0, 50)}...
2402
+ `);
2403
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_UPDATE, {
2404
+ messageId: this.currentMessageId,
2405
+ delta: "",
2406
+ thought: event.thought,
2407
+ timestamp: createTimestamp()
2408
+ });
2409
+ }
2410
+ break;
2411
+ case "message":
2412
+ if (event.content) {
2413
+ process.stderr.write(`[RPC DEBUG] Emitting message content: ${event.content.substring(0, 100)}...
2414
+ `);
2415
+ this.currentMessageContent = event.content;
2416
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_UPDATE, {
2417
+ messageId: this.currentMessageId,
2418
+ delta: event.content,
2419
+ timestamp: createTimestamp()
2420
+ });
2421
+ }
2422
+ break;
2423
+ case "tool_start":
2424
+ if (event.toolName) {
2425
+ writeNotification(RPC_NOTIFICATIONS.TOOL_START, {
2426
+ toolId: _nullishCoalesce(event.toolId, () => ( generateId("tool"))),
2427
+ toolName: event.toolName,
2428
+ args: _nullishCoalesce(event.toolArgs, () => ( {})),
2429
+ timestamp: createTimestamp()
2430
+ });
2431
+ }
2432
+ break;
2433
+ case "tool_end":
2434
+ if (event.toolName) {
2435
+ writeNotification(RPC_NOTIFICATIONS.TOOL_END, {
2436
+ toolId: _nullishCoalesce(event.toolId, () => ( "unknown")),
2437
+ toolName: event.toolName,
2438
+ success: _nullishCoalesce(event.toolSuccess, () => ( true)),
2439
+ output: event.toolOutput,
2440
+ timestamp: createTimestamp()
2441
+ });
2442
+ }
2443
+ break;
2444
+ case "schedule_triggered":
2445
+ writeNotification(RPC_NOTIFICATIONS.SCHEDULE_TRIGGERED, {
2446
+ prompt: event.content,
2447
+ scheduleId: event.scheduleId,
2448
+ timestamp: createTimestamp()
2449
+ });
2450
+ break;
2451
+ case "file_modified":
2452
+ if (event.filePath) {
2453
+ writeNotification(RPC_NOTIFICATIONS.HOOK_FILE_MODIFIED, {
2454
+ filePath: event.filePath,
2455
+ changeType: _nullishCoalesce(event.changeType, () => ( "modify")),
2456
+ toolId: _nullishCoalesce(event.toolId, () => ( "")),
2457
+ timestamp: createTimestamp()
2458
+ });
2459
+ }
2460
+ break;
2461
+ case "error":
2462
+ if (event.content) {
2463
+ process.stderr.write(`[RPC DEBUG] Emitting error: ${event.content.substring(0, 100)}...
2464
+ `);
2465
+ const errorType = this.classifyError(event.content);
2466
+ const icon = errorType.icon;
2467
+ this.currentMessageContent = `${icon} ${event.content}`;
2468
+ writeNotification(RPC_NOTIFICATIONS.MESSAGE_UPDATE, {
2469
+ messageId: this.currentMessageId,
2470
+ delta: this.currentMessageContent,
2471
+ timestamp: createTimestamp()
2472
+ });
2473
+ writeNotification(RPC_NOTIFICATIONS.ERROR, {
2474
+ code: errorType.code,
2475
+ message: event.content,
2476
+ errorType: errorType.type,
2477
+ recoverable: errorType.recoverable,
2478
+ timestamp: createTimestamp()
2479
+ });
2480
+ }
2481
+ break;
2482
+ }
2483
+ }
2484
+ /**
2485
+ * Classify error messages for appropriate UI treatment.
2486
+ * Delegates to the shared classifyApiError() and maps the result
2487
+ * to the RPC-specific shape (type, code, icon, recoverable).
2488
+ */
2489
+ classifyError(message) {
2490
+ const classified = _chunk3OF56EMAcjs.classifyApiError.call(void 0, 0, message);
2491
+ return {
2492
+ type: _nullishCoalesce(RPC_ERROR_TYPE_MAP[classified.code], () => ( "unknown")),
2493
+ code: _nullishCoalesce(RPC_ERROR_CODE_MAP[classified.code], () => ( -32e3)),
2494
+ icon: _nullishCoalesce(RPC_ERROR_ICON_MAP[classified.code], () => ( "\u26A0\uFE0F")),
2495
+ recoverable: classified.retryable
2496
+ };
2497
+ }
2498
+ /**
2499
+ * Convert LLMMessage to RpcMessage
2500
+ */
2501
+ convertMessage(msg, index) {
2502
+ let toolCalls;
2503
+ if (msg.tool_calls && msg.tool_calls.length > 0) {
2504
+ toolCalls = msg.tool_calls.map((tc) => {
2505
+ let args = {};
2506
+ try {
2507
+ if (_optionalChain([tc, 'access', _100 => _100.function, 'optionalAccess', _101 => _101.arguments])) {
2508
+ args = JSON.parse(tc.function.arguments);
2509
+ }
2510
+ } catch (e6) {
2511
+ }
2512
+ return {
2513
+ id: tc.id,
2514
+ name: _nullishCoalesce(_optionalChain([tc, 'access', _102 => _102.function, 'optionalAccess', _103 => _103.name]), () => ( "unknown")),
2515
+ args
2516
+ };
2517
+ });
2518
+ }
2519
+ return {
2520
+ id: `msg_${index}`,
2521
+ role: msg.role,
2522
+ content: msg.content,
2523
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2524
+ toolCalls
2525
+ };
2526
+ }
2527
+ // ============================================================================
2528
+ // Auto-Mode RPC Handlers
2529
+ // ============================================================================
2530
+ /**
2531
+ * Start auto-mode loop
2532
+ */
2533
+ async handleAutomodeStart(requestId, params) {
2534
+ try {
2535
+ const automodeManager = _optionalChain([this, 'access', _104 => _104.agent, 'optionalAccess', _105 => _105.getAutomodeManager, 'optionalCall', _106 => _106()]);
2536
+ if (!automodeManager) {
2537
+ return {
2538
+ success: false,
2539
+ error: "Auto-mode manager not available"
2540
+ };
2541
+ }
2542
+ if (automodeManager.isActive()) {
2543
+ return {
2544
+ success: false,
2545
+ error: "Auto-mode is already running"
2546
+ };
2547
+ }
2548
+ process.stderr.write(`[RPC] Auto-mode start requested: ${params.prompt}
2549
+ `);
2550
+ return {
2551
+ success: true,
2552
+ sessionId: `automode-${Date.now()}`
2553
+ };
2554
+ } catch (error) {
2555
+ const message = error instanceof Error ? error.message : String(error);
2556
+ return {
2557
+ success: false,
2558
+ error: message
2559
+ };
2560
+ }
2561
+ }
2562
+ /**
2563
+ * Get auto-mode status
2564
+ */
2565
+ handleAutomodeStatus(_requestId) {
2566
+ const automodeManager = _optionalChain([this, 'access', _107 => _107.agent, 'optionalAccess', _108 => _108.getAutomodeManager, 'optionalCall', _109 => _109()]);
2567
+ if (!automodeManager) {
2568
+ return {
2569
+ active: false,
2570
+ paused: false
2571
+ };
2572
+ }
2573
+ const state = automodeManager.getState();
2574
+ return {
2575
+ active: automodeManager.isActive(),
2576
+ paused: automodeManager.isPausedState(),
2577
+ state: state ? {
2578
+ sessionId: state.sessionId,
2579
+ status: state.status,
2580
+ currentIteration: state.currentIteration,
2581
+ maxIterations: state.maxIterations,
2582
+ filesCreated: state.filesCreated,
2583
+ filesModified: state.filesModified,
2584
+ branch: state.branch,
2585
+ lastCheckpoint: state.lastCheckpoint
2586
+ } : void 0
2587
+ };
2588
+ }
2589
+ /**
2590
+ * Pause auto-mode loop
2591
+ */
2592
+ async handleAutomodePause(_requestId) {
2593
+ try {
2594
+ const automodeManager = _optionalChain([this, 'access', _110 => _110.agent, 'optionalAccess', _111 => _111.getAutomodeManager, 'optionalCall', _112 => _112()]);
2595
+ if (!automodeManager) {
2596
+ return {
2597
+ success: false,
2598
+ error: "Auto-mode manager not available"
2599
+ };
2600
+ }
2601
+ if (!automodeManager.isActive()) {
2602
+ return {
2603
+ success: false,
2604
+ error: "No auto-mode session is running"
2605
+ };
2606
+ }
2607
+ if (automodeManager.isPausedState()) {
2608
+ return {
2609
+ success: false,
2610
+ error: "Auto-mode is already paused"
2611
+ };
2612
+ }
2613
+ await automodeManager.pause();
2614
+ return { success: true };
2615
+ } catch (error) {
2616
+ const message = error instanceof Error ? error.message : String(error);
2617
+ return {
2618
+ success: false,
2619
+ error: message
2620
+ };
2621
+ }
2622
+ }
2623
+ /**
2624
+ * Resume auto-mode loop
2625
+ */
2626
+ async handleAutomodeResume(_requestId) {
2627
+ try {
2628
+ const automodeManager = _optionalChain([this, 'access', _113 => _113.agent, 'optionalAccess', _114 => _114.getAutomodeManager, 'optionalCall', _115 => _115()]);
2629
+ if (!automodeManager) {
2630
+ return {
2631
+ success: false,
2632
+ error: "Auto-mode manager not available"
2633
+ };
2634
+ }
2635
+ if (!automodeManager.isActive()) {
2636
+ return {
2637
+ success: false,
2638
+ error: "No auto-mode session to resume"
2639
+ };
2640
+ }
2641
+ if (!automodeManager.isPausedState()) {
2642
+ return {
2643
+ success: false,
2644
+ error: "Auto-mode is not paused"
2645
+ };
2646
+ }
2647
+ await automodeManager.resume();
2648
+ return { success: true };
2649
+ } catch (error) {
2650
+ const message = error instanceof Error ? error.message : String(error);
2651
+ return {
2652
+ success: false,
2653
+ error: message
2654
+ };
2655
+ }
2656
+ }
2657
+ /**
2658
+ * Cancel auto-mode loop
2659
+ */
2660
+ async handleAutomodeCancel(requestId, reason) {
2661
+ try {
2662
+ const automodeManager = _optionalChain([this, 'access', _116 => _116.agent, 'optionalAccess', _117 => _117.getAutomodeManager, 'optionalCall', _118 => _118()]);
2663
+ if (!automodeManager) {
2664
+ return {
2665
+ success: false,
2666
+ error: "Auto-mode manager not available"
2667
+ };
2668
+ }
2669
+ if (!automodeManager.isActive()) {
2670
+ return {
2671
+ success: false,
2672
+ error: "No auto-mode session to cancel"
2673
+ };
2674
+ }
2675
+ await automodeManager.cancel(reason || "rpc_cancel");
2676
+ return { success: true };
2677
+ } catch (error) {
2678
+ const message = error instanceof Error ? error.message : String(error);
2679
+ return {
2680
+ success: false,
2681
+ error: message
2682
+ };
2683
+ }
2684
+ }
2685
+ /**
2686
+ * Get auto-mode iteration log
2687
+ */
2688
+ handleAutomodeGetLog(requestId, limit) {
2689
+ try {
2690
+ const automodeManager = _optionalChain([this, 'access', _119 => _119.agent, 'optionalAccess', _120 => _120.getAutomodeManager, 'optionalCall', _121 => _121()]);
2691
+ if (!automodeManager) {
2692
+ return {
2693
+ success: false,
2694
+ iterations: [],
2695
+ error: "Auto-mode manager not available"
2696
+ };
2697
+ }
2698
+ const state = automodeManager.getState();
2699
+ if (!state) {
2700
+ return {
2701
+ success: true,
2702
+ iterations: []
2703
+ };
2704
+ }
2705
+ const iterations = [];
2706
+ return {
2707
+ success: true,
2708
+ iterations: limit ? iterations.slice(-limit) : iterations
2709
+ };
2710
+ } catch (error) {
2711
+ const message = error instanceof Error ? error.message : String(error);
2712
+ return {
2713
+ success: false,
2714
+ iterations: [],
2715
+ error: message
2716
+ };
2717
+ }
2718
+ }
2719
+ // ============================================================================
2720
+ // SDK Control RPC Methods
2721
+ // ============================================================================
2722
+ /**
2723
+ * Set permission mode
2724
+ */
2725
+ async handleSetPermissionMode(params) {
2726
+ try {
2727
+ const previousMode = _optionalChain([this, 'access', _122 => _122.config, 'optionalAccess', _123 => _123.permissionMode]) || "default";
2728
+ this.config.permissionMode = params.mode;
2729
+ return {
2730
+ success: true,
2731
+ currentMode: params.mode,
2732
+ previousMode
2733
+ };
2734
+ } catch (e7) {
2735
+ return {
2736
+ success: false,
2737
+ currentMode: _optionalChain([this, 'access', _124 => _124.config, 'optionalAccess', _125 => _125.permissionMode]) || "default",
2738
+ previousMode: _optionalChain([this, 'access', _126 => _126.config, 'optionalAccess', _127 => _127.permissionMode]) || "default"
2739
+ };
2740
+ }
2741
+ }
2742
+ /**
2743
+ * Set model
2744
+ */
2745
+ async handleSetModel(params) {
2746
+ try {
2747
+ this.config.model = params.model;
2748
+ return {
2749
+ success: true,
2750
+ currentModel: params.model
2751
+ };
2752
+ } catch (e8) {
2753
+ return {
2754
+ success: false,
2755
+ currentModel: _optionalChain([this, 'access', _128 => _128.config, 'optionalAccess', _129 => _129.model])
2756
+ };
2757
+ }
2758
+ }
2759
+ /**
2760
+ * Set max thinking tokens
2761
+ */
2762
+ async handleSetMaxThinkingTokens(params) {
2763
+ try {
2764
+ this.config.maxThinkingTokens = _nullishCoalesce(params.maxThinkingTokens, () => ( void 0));
2765
+ return {
2766
+ success: true,
2767
+ currentMaxThinkingTokens: _nullishCoalesce(params.maxThinkingTokens, () => ( null))
2768
+ };
2769
+ } catch (e9) {
2770
+ return {
2771
+ success: false,
2772
+ currentMaxThinkingTokens: _optionalChain([this, 'access', _130 => _130.config, 'optionalAccess', _131 => _131.maxThinkingTokens]) || null
2773
+ };
2774
+ }
2775
+ }
2776
+ /**
2777
+ * Apply flag settings — now propagates contextCompact to the agent.
2778
+ */
2779
+ async handleApplyFlagSettings(params) {
2780
+ try {
2781
+ const appliedSettings = [];
2782
+ for (const [key, value] of Object.entries(params.settings)) {
2783
+ if (value !== void 0) {
2784
+ this.config[key] = value;
2785
+ appliedSettings.push(key);
2786
+ if (key === "contextCompact" && typeof value === "boolean") {
2787
+ _optionalChain([this, 'access', _132 => _132.agent, 'optionalAccess', _133 => _133.setContextCompaction, 'call', _134 => _134(value)]);
2788
+ }
2789
+ }
2790
+ }
2791
+ return {
2792
+ success: true,
2793
+ appliedSettings
2794
+ };
2795
+ } catch (e10) {
2796
+ return {
2797
+ success: false,
2798
+ appliedSettings: []
2799
+ };
2800
+ }
2801
+ }
2802
+ /**
2803
+ * Get supported models
2804
+ */
2805
+ async handleGetSupportedModels() {
2806
+ try {
2807
+ const models = [
2808
+ { id: "anthropic/claude-sonnet-4", displayName: "Claude Sonnet 4" },
2809
+ { id: "anthropic/claude-3-5-sonnet-20241022", displayName: "Claude 3.5 Sonnet" },
2810
+ { id: "openai/gpt-4o", displayName: "GPT-4o" },
2811
+ { id: "openai/gpt-4o-mini", displayName: "GPT-4o Mini" }
2812
+ ];
2813
+ return {
2814
+ models
2815
+ };
2816
+ } catch (e11) {
2817
+ return {
2818
+ models: []
2819
+ };
2820
+ }
2821
+ }
2822
+ /**
2823
+ * Get supported commands
2824
+ */
2825
+ async handleGetSupportedCommands() {
2826
+ try {
2827
+ const commands = [
2828
+ "help",
2829
+ "model",
2830
+ "auto",
2831
+ "plan",
2832
+ "skills",
2833
+ "learn",
2834
+ "mcp",
2835
+ "chrome"
2836
+ ];
2837
+ return {
2838
+ commands
2839
+ };
2840
+ } catch (e12) {
2841
+ return {
2842
+ commands: []
2843
+ };
2844
+ }
2845
+ }
2846
+ /**
2847
+ * Get context usage — returns real data from the agent's orchestrator.
2848
+ */
2849
+ async handleGetContextUsage() {
2850
+ try {
2851
+ if (_optionalChain([this, 'access', _135 => _135.agent, 'optionalAccess', _136 => _136.getContextOrchestrator])) {
2852
+ const orchestrator = this.agent.getContextOrchestrator();
2853
+ const tools = _nullishCoalesce(_optionalChain([this, 'access', _137 => _137.agent, 'access', _138 => _138.getToolDefinitions, 'optionalCall', _139 => _139()]), () => ( []));
2854
+ const usage = orchestrator.getExtendedUsage(tools);
2855
+ return {
2856
+ systemPrompt: usage.systemPrompt,
2857
+ tools: usage.tools,
2858
+ messages: usage.messages,
2859
+ mcpTools: usage.mcpTools,
2860
+ memoryFiles: usage.memoryFiles,
2861
+ total: usage.total,
2862
+ contextWindow: usage.contextWindow,
2863
+ usagePercent: usage.usagePercent,
2864
+ isWarning: usage.isWarning,
2865
+ isCritical: usage.isCritical
2866
+ };
2867
+ }
2868
+ return {
2869
+ systemPrompt: 0,
2870
+ tools: 0,
2871
+ messages: 0,
2872
+ mcpTools: 0,
2873
+ memoryFiles: 0,
2874
+ total: 0
2875
+ };
2876
+ } catch (e13) {
2877
+ return {
2878
+ systemPrompt: 0,
2879
+ tools: 0,
2880
+ messages: 0,
2881
+ mcpTools: 0,
2882
+ memoryFiles: 0,
2883
+ total: 0
2884
+ };
2885
+ }
2886
+ }
2887
+ /**
2888
+ * Set context compaction enabled/disabled
2889
+ */
2890
+ async handleSetContextCompact(params) {
2891
+ try {
2892
+ _optionalChain([this, 'access', _140 => _140.agent, 'optionalAccess', _141 => _141.setContextCompaction, 'call', _142 => _142(params.enabled)]);
2893
+ return { enabled: params.enabled };
2894
+ } catch (e14) {
2895
+ return { enabled: _nullishCoalesce(_optionalChain([this, 'access', _143 => _143.agent, 'optionalAccess', _144 => _144.isContextCompactionEnabled, 'optionalCall', _145 => _145()]), () => ( false)) };
2896
+ }
2897
+ }
2898
+ /**
2899
+ * Reload plugins
2900
+ */
2901
+ async handleReloadPlugins() {
2902
+ try {
2903
+ const reloadedPlugins = ["skills"];
2904
+ return {
2905
+ success: true,
2906
+ reloadedPlugins
2907
+ };
2908
+ } catch (e15) {
2909
+ return {
2910
+ success: false,
2911
+ reloadedPlugins: []
2912
+ };
2913
+ }
2914
+ }
2915
+ /**
2916
+ * Get account info
2917
+ */
2918
+ async handleGetAccountInfo() {
2919
+ try {
2920
+ return {
2921
+ email: "user@example.com"
2922
+ };
2923
+ } catch (e16) {
2924
+ return {
2925
+ email: ""
2926
+ };
2927
+ }
2928
+ }
2929
+ /**
2930
+ * Toggle MCP server
2931
+ */
2932
+ async handleMcpToggleServer(params) {
2933
+ try {
2934
+ return {
2935
+ success: true,
2936
+ serverName: params.serverName,
2937
+ status: params.enabled ? "enabled" : "disabled"
2938
+ };
2939
+ } catch (e17) {
2940
+ return {
2941
+ success: false,
2942
+ serverName: params.serverName,
2943
+ status: "disabled"
2944
+ };
2945
+ }
2946
+ }
2947
+ /**
2948
+ * Reconnect MCP server
2949
+ */
2950
+ async handleMcpReconnectServer(params) {
2951
+ try {
2952
+ return {
2953
+ success: true,
2954
+ serverName: params.serverName,
2955
+ status: "connected"
2956
+ };
2957
+ } catch (e18) {
2958
+ return {
2959
+ success: false,
2960
+ serverName: params.serverName,
2961
+ status: "disconnected"
2962
+ };
2963
+ }
2964
+ }
2965
+ /**
2966
+ * Set MCP servers
2967
+ */
2968
+ async handleMcpSetServers(params) {
2969
+ try {
2970
+ const configuredServers = Object.keys(params.servers);
2971
+ return {
2972
+ success: true,
2973
+ configuredServers
2974
+ };
2975
+ } catch (e19) {
2976
+ return {
2977
+ success: false,
2978
+ configuredServers: []
2979
+ };
2980
+ }
2981
+ }
2982
+ }, _class2);
2983
+
2984
+ // src/modes/rpc/index.ts
2985
+ var originalConsole = {
2986
+ log: console.log,
2987
+ warn: console.warn,
2988
+ error: console.error,
2989
+ info: console.info,
2990
+ debug: console.debug
2991
+ };
2992
+ function suppressConsole() {
2993
+ console.log = () => {
2994
+ };
2995
+ console.warn = () => {
2996
+ };
2997
+ console.error = () => {
2998
+ };
2999
+ console.info = () => {
3000
+ };
3001
+ console.debug = () => {
3002
+ };
3003
+ }
3004
+ function restoreConsole() {
3005
+ console.log = originalConsole.log;
3006
+ console.warn = originalConsole.warn;
3007
+ console.error = originalConsole.error;
3008
+ console.info = originalConsole.info;
3009
+ console.debug = originalConsole.debug;
3010
+ }
3011
+ async function runRpcMode(options) {
3012
+ suppressConsole();
3013
+ const { setBrowserBridgeOutput } = await Promise.resolve().then(() => _interopRequireWildcard(require("./browserToolBridge-BXRQB4B4.cjs")));
3014
+ setBrowserBridgeOutput(process.stdout);
3015
+ process.stdout.on("error", (err) => {
3016
+ process.stderr.write(`[RPC] stdout error: ${err.message}
3017
+ `);
3018
+ });
3019
+ process.stdin.on("error", (err) => {
3020
+ process.stderr.write(`[RPC] stdin error: ${err.message}
3021
+ `);
3022
+ });
3023
+ process.stdin.on("end", () => {
3024
+ process.stderr.write("[RPC] stdin end (extension disconnected)\n");
3025
+ });
3026
+ let adapter = null;
3027
+ let agent = null;
3028
+ try {
3029
+ const config = await _chunk46C73ZKKcjs.loadConfig.call(void 0, options.config, process.cwd());
3030
+ const normalizedYolo = _chunkJ5HE6CUMcjs.normalizeYoloInput.call(void 0, options.yolo);
3031
+ if (normalizedYolo) {
3032
+ try {
3033
+ const yoloPattern = _chunkJ5HE6CUMcjs.parseYoloPattern.call(void 0, normalizedYolo);
3034
+ options.yolo = normalizedYolo;
3035
+ config.permissions = {
3036
+ ...config.permissions,
3037
+ ..._chunkJ5HE6CUMcjs.buildPermissionSettingsFromYolo.call(void 0, yoloPattern)
3038
+ };
3039
+ } catch (error) {
3040
+ const message = error instanceof Error ? error.message : String(error);
3041
+ writeErrorResponse(null, JSON_RPC_ERROR_CODES.INTERNAL_ERROR, message);
3042
+ process.exit(1);
3043
+ }
3044
+ }
3045
+ const originalWorkspaceRoot = _nullishCoalesce(options.path, () => ( process.cwd()));
3046
+ let workspaceRoot = originalWorkspaceRoot;
3047
+ const workspacePathValidation = await _chunk3LJJG5YYcjs.validateWorkspacePath.call(void 0, originalWorkspaceRoot);
3048
+ if (!workspacePathValidation.valid) {
3049
+ writeErrorResponse(
3050
+ null,
3051
+ JSON_RPC_ERROR_CODES.INTERNAL_ERROR,
3052
+ workspacePathValidation.error || "Invalid workspace path"
3053
+ );
3054
+ process.exit(1);
3055
+ }
3056
+ const safetyCheck = _chunkWGNMOVMTcjs.checkWorkspaceSafety.call(void 0, originalWorkspaceRoot);
3057
+ if (!safetyCheck.safe) {
3058
+ writeErrorResponse(
3059
+ null,
3060
+ JSON_RPC_ERROR_CODES.INTERNAL_ERROR,
3061
+ `Unsafe workspace: ${safetyCheck.reason || originalWorkspaceRoot}`
3062
+ );
3063
+ process.exit(1);
3064
+ }
3065
+ const isAuthed = await _chunkQ2IL4DDIcjs.checkAuthenticated.call(void 0, config);
3066
+ if (!isAuthed) {
3067
+ writeErrorResponse(
3068
+ null,
3069
+ JSON_RPC_ERROR_CODES.INTERNAL_ERROR,
3070
+ "Authentication required. Run `autohand login` first."
3071
+ );
3072
+ process.exit(1);
3073
+ }
3074
+ if (!config.ui) {
3075
+ config.ui = {};
3076
+ }
3077
+ config.ui.useInkRenderer = false;
3078
+ if (_chunk7LWQCE4Ycjs.isSessionWorktreeEnabled.call(void 0, options.worktree)) {
3079
+ const sessionWorktree = _chunk7LWQCE4Ycjs.prepareSessionWorktree.call(void 0, {
3080
+ cwd: originalWorkspaceRoot,
3081
+ worktree: options.worktree,
3082
+ mode: "rpc"
3083
+ });
3084
+ workspaceRoot = sessionWorktree.worktreePath;
3085
+ process.stderr.write(`[RPC] Using git worktree ${sessionWorktree.worktreePath} (${sessionWorktree.branchName})
3086
+ `);
3087
+ }
3088
+ const additionalDirs = [];
3089
+ if (options.addDir && options.addDir.length > 0) {
3090
+ for (const dir of options.addDir) {
3091
+ const resolvedDir = _path2.default.resolve(dir);
3092
+ if (!await _fsextra2.default.pathExists(resolvedDir)) {
3093
+ throw new Error(`Additional directory does not exist: ${dir}`);
3094
+ }
3095
+ const stats = await _fsextra2.default.stat(resolvedDir);
3096
+ if (!stats.isDirectory()) {
3097
+ throw new Error(`Additional path is not a directory: ${dir}`);
3098
+ }
3099
+ const addDirSafetyCheck = _chunkWGNMOVMTcjs.checkWorkspaceSafety.call(void 0, resolvedDir);
3100
+ if (!addDirSafetyCheck.safe) {
3101
+ throw new Error(`Unsafe additional directory: ${dir} - ${addDirSafetyCheck.reason}`);
3102
+ }
3103
+ additionalDirs.push(resolvedDir);
3104
+ }
3105
+ }
3106
+ const runtime = {
3107
+ config,
3108
+ workspaceRoot,
3109
+ options: {
3110
+ ...options,
3111
+ clientContext: "chrome"
3112
+ // Do NOT set yes: true - permissions are handled via RPC
3113
+ },
3114
+ additionalDirs: additionalDirs.length > 0 ? additionalDirs : void 0,
3115
+ isRpcMode: true
3116
+ };
3117
+ const provider = _chunkWRTXCQ3Vcjs.ProviderFactory.create(config);
3118
+ if (options.model) {
3119
+ provider.setModel(options.model);
3120
+ }
3121
+ const files = new (0, _chunk5K3CDSWZcjs.FileActionManager)(workspaceRoot, additionalDirs);
3122
+ agent = new (0, _chunk7JLT2VNWcjs.AutohandAgent)(provider, files, runtime);
3123
+ await agent.initializeForRPC();
3124
+ const conversation = _chunkDA7NBAJKcjs.ConversationManager.getInstance();
3125
+ try {
3126
+ const { CHROME_AUTOMATION_SYSTEM_PROMPT } = await Promise.resolve().then(() => _interopRequireWildcard(require("./chromeSkill-THW7N4IY.cjs")));
3127
+ conversation.addSystemNote(CHROME_AUTOMATION_SYSTEM_PROMPT);
3128
+ } catch (e20) {
3129
+ }
3130
+ adapter = new RPCAdapter();
3131
+ adapter.initialize(
3132
+ agent,
3133
+ conversation,
3134
+ _nullishCoalesce(_nullishCoalesce(options.model, () => ( _optionalChain([config, 'access', _146 => _146.openrouter, 'optionalAccess', _147 => _147.model]))), () => ( "unknown")),
3135
+ workspaceRoot,
3136
+ _optionalChain([config, 'access', _148 => _148.mcp, 'optionalAccess', _149 => _149.servers])
3137
+ );
3138
+ agent.setConfirmationCallback(async (message, context) => {
3139
+ if (!adapter) {
3140
+ throw new Error("RPC adapter not initialized");
3141
+ }
3142
+ const tool = _nullishCoalesce(_optionalChain([context, 'optionalAccess', _150 => _150.tool]), () => ( "action"));
3143
+ const description = message;
3144
+ const permContext = {};
3145
+ if (_optionalChain([context, 'optionalAccess', _151 => _151.command])) permContext.command = context.command;
3146
+ if (_optionalChain([context, 'optionalAccess', _152 => _152.path])) permContext.path = context.path;
3147
+ return adapter.requestPermission(tool, description, permContext);
3148
+ });
3149
+ agent.setDirectoryAccessCallback(async (path2, reason) => {
3150
+ if (!adapter) {
3151
+ throw new Error("RPC adapter not initialized");
3152
+ }
3153
+ return adapter.requestDirectoryAccess(path2, reason);
3154
+ });
3155
+ const reader = new LineReader(process.stdin);
3156
+ while (true) {
3157
+ try {
3158
+ const line = await reader.readLine();
3159
+ process.stderr.write(`[RPC DEBUG] stdin read line size=${line.length}b
3160
+ `);
3161
+ await handleLine(line, adapter);
3162
+ } catch (error) {
3163
+ if (error instanceof Error && error.message === "Stream closed") {
3164
+ process.stderr.write("[RPC] Extension disconnected (stdin closed). Shutting down gracefully.\n");
3165
+ break;
3166
+ }
3167
+ const message = error instanceof Error ? error.message : String(error);
3168
+ process.stderr.write(`[RPC] Fatal error in request loop: ${message}
3169
+ `);
3170
+ writeInternalError(null, message);
3171
+ }
3172
+ }
3173
+ _optionalChain([adapter, 'optionalAccess', _153 => _153.shutdown, 'call', _154 => _154("disconnected")]);
3174
+ process.exit(0);
3175
+ } catch (error) {
3176
+ const message = error instanceof Error ? error.message : String(error);
3177
+ writeErrorResponse(null, JSON_RPC_ERROR_CODES.INTERNAL_ERROR, `Initialization error: ${message}`);
3178
+ _optionalChain([adapter, 'optionalAccess', _155 => _155.shutdown, 'call', _156 => _156("error")]);
3179
+ process.exit(1);
3180
+ }
3181
+ }
3182
+ async function handleLine(line, adapter) {
3183
+ process.stderr.write(`[RPC DEBUG] handleLine received: ${line.slice(0, 100)}
3184
+ `);
3185
+ const parseResult = parseRequest(line);
3186
+ if (parseResult.type === "error") {
3187
+ writeErrorResponse(null, parseResult.code, parseResult.message);
3188
+ return;
3189
+ }
3190
+ if (parseResult.type === "batch") {
3191
+ const responses = await Promise.all(
3192
+ parseResult.requests.map((req) => handleSingleRequest(req, adapter))
3193
+ );
3194
+ const validResponses = responses.filter((r) => r !== null);
3195
+ writeBatchResponse(validResponses);
3196
+ return;
3197
+ }
3198
+ const response = await handleSingleRequest(parseResult.request, adapter);
3199
+ if (response !== null) {
3200
+ process.stdout.write(JSON.stringify(response) + "\n");
3201
+ }
3202
+ }
3203
+ async function handleSingleRequest(request, adapter) {
3204
+ const { method, params, id } = request;
3205
+ const shouldRespond = !isNotification(request);
3206
+ try {
3207
+ let result;
3208
+ switch (method) {
3209
+ case RPC_METHODS.PROMPT: {
3210
+ const promptParams = params;
3211
+ if (!_optionalChain([promptParams, 'optionalAccess', _157 => _157.message])) {
3212
+ if (shouldRespond) {
3213
+ return createErrorResponse(
3214
+ id,
3215
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3216
+ "Missing required parameter: message"
3217
+ );
3218
+ }
3219
+ return null;
3220
+ }
3221
+ adapter.handlePrompt(id, promptParams).then((promptResult) => {
3222
+ if (shouldRespond) {
3223
+ process.stdout.write(JSON.stringify(createResponse(id, promptResult)) + "\n");
3224
+ }
3225
+ }).catch((error) => {
3226
+ const message = error instanceof Error ? error.message : String(error);
3227
+ if (shouldRespond) {
3228
+ process.stdout.write(JSON.stringify(createErrorResponse(
3229
+ id,
3230
+ JSON_RPC_ERROR_CODES.INTERNAL_ERROR,
3231
+ message
3232
+ )) + "\n");
3233
+ }
3234
+ });
3235
+ return null;
3236
+ }
3237
+ case RPC_METHODS.ABORT: {
3238
+ process.stderr.write(`[RPC DEBUG] ABORT received! id=${id}, isNotification=${!shouldRespond}
3239
+ `);
3240
+ result = adapter.handleAbort(_nullishCoalesce(id, () => ( null)));
3241
+ break;
3242
+ }
3243
+ case RPC_METHODS.RESET: {
3244
+ result = await adapter.handleReset(id);
3245
+ break;
3246
+ }
3247
+ case RPC_METHODS.GET_STATE: {
3248
+ result = adapter.handleGetState(id);
3249
+ break;
3250
+ }
3251
+ case RPC_METHODS.GET_MESSAGES: {
3252
+ const messagesParams = params;
3253
+ result = adapter.handleGetMessages(id, _optionalChain([messagesParams, 'optionalAccess', _158 => _158.limit]));
3254
+ break;
3255
+ }
3256
+ case RPC_METHODS.BROWSER_HANDOFF_CREATE: {
3257
+ const handoffCreateParams = params;
3258
+ result = await adapter.handleBrowserHandoffCreate(id, handoffCreateParams);
3259
+ break;
3260
+ }
3261
+ case RPC_METHODS.BROWSER_HANDOFF_ATTACH: {
3262
+ const handoffAttachParams = params;
3263
+ if (!_optionalChain([handoffAttachParams, 'optionalAccess', _159 => _159.token])) {
3264
+ if (shouldRespond) {
3265
+ return createErrorResponse(
3266
+ id,
3267
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3268
+ "Missing required parameter: token"
3269
+ );
3270
+ }
3271
+ return null;
3272
+ }
3273
+ result = await adapter.handleBrowserHandoffAttach(id, handoffAttachParams);
3274
+ break;
3275
+ }
3276
+ case RPC_METHODS.BROWSER_HANDOFF_ATTACH_LATEST: {
3277
+ const handoffAttachLatestParams = params;
3278
+ result = await adapter.handleBrowserHandoffAttachLatest(id, handoffAttachLatestParams);
3279
+ break;
3280
+ }
3281
+ case RPC_METHODS.PERMISSION_RESPONSE: {
3282
+ const permParams = params;
3283
+ if (!_optionalChain([permParams, 'optionalAccess', _160 => _160.requestId]) || _optionalChain([permParams, 'optionalAccess', _161 => _161.decision]) === void 0 && _optionalChain([permParams, 'optionalAccess', _162 => _162.allowed]) === void 0) {
3284
+ if (shouldRespond) {
3285
+ return createErrorResponse(
3286
+ id,
3287
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3288
+ "Missing required parameters: requestId and a permission decision"
3289
+ );
3290
+ }
3291
+ return null;
3292
+ }
3293
+ result = adapter.handlePermissionResponse(
3294
+ id,
3295
+ permParams.requestId,
3296
+ permParams.decision ? { decision: permParams.decision, alternative: permParams.alternative } : Boolean(permParams.allowed)
3297
+ );
3298
+ break;
3299
+ }
3300
+ case RPC_METHODS.PERMISSION_ACKNOWLEDGED: {
3301
+ const ackParams = params;
3302
+ if (!_optionalChain([ackParams, 'optionalAccess', _163 => _163.requestId])) {
3303
+ if (shouldRespond) {
3304
+ return createErrorResponse(
3305
+ id,
3306
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3307
+ "Missing required parameter: requestId"
3308
+ );
3309
+ }
3310
+ return null;
3311
+ }
3312
+ result = adapter.handlePermissionAcknowledged(ackParams.requestId);
3313
+ break;
3314
+ }
3315
+ case RPC_METHODS.DIRECTORY_ACCESS_RESPONSE: {
3316
+ const dirParams = params;
3317
+ if (!_optionalChain([dirParams, 'optionalAccess', _164 => _164.requestId]) || typeof dirParams.granted !== "boolean") {
3318
+ if (shouldRespond) {
3319
+ return createErrorResponse(
3320
+ id,
3321
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3322
+ "Missing required parameters: requestId, granted"
3323
+ );
3324
+ }
3325
+ return null;
3326
+ }
3327
+ result = adapter.handleDirectoryAccessResponse(dirParams.requestId, dirParams.granted);
3328
+ break;
3329
+ }
3330
+ case RPC_METHODS.DIRECTORY_ACCESS_ACKNOWLEDGED: {
3331
+ const dirAckParams = params;
3332
+ if (!_optionalChain([dirAckParams, 'optionalAccess', _165 => _165.requestId])) {
3333
+ if (shouldRespond) {
3334
+ return createErrorResponse(
3335
+ id,
3336
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3337
+ "Missing required parameter: requestId"
3338
+ );
3339
+ }
3340
+ return null;
3341
+ }
3342
+ result = adapter.handleDirectoryAccessAcknowledged(dirAckParams.requestId);
3343
+ break;
3344
+ }
3345
+ case RPC_METHODS.CHANGES_DECISION: {
3346
+ const decisionParams = params;
3347
+ if (!_optionalChain([decisionParams, 'optionalAccess', _166 => _166.batchId]) || !_optionalChain([decisionParams, 'optionalAccess', _167 => _167.action])) {
3348
+ if (shouldRespond) {
3349
+ return createErrorResponse(
3350
+ id,
3351
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3352
+ "Missing required parameters: batchId, action"
3353
+ );
3354
+ }
3355
+ return null;
3356
+ }
3357
+ result = await adapter.handleChangesDecision(id, decisionParams);
3358
+ break;
3359
+ }
3360
+ case RPC_METHODS.GET_SKILLS_REGISTRY: {
3361
+ const registryParams = params;
3362
+ result = await adapter.handleGetSkillsRegistry(id, registryParams);
3363
+ break;
3364
+ }
3365
+ case RPC_METHODS.INSTALL_SKILL: {
3366
+ const installParams = params;
3367
+ if (!_optionalChain([installParams, 'optionalAccess', _168 => _168.skillName]) || !_optionalChain([installParams, 'optionalAccess', _169 => _169.scope])) {
3368
+ if (shouldRespond) {
3369
+ return createErrorResponse(
3370
+ id,
3371
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3372
+ "Missing required parameters: skillName, scope"
3373
+ );
3374
+ }
3375
+ return null;
3376
+ }
3377
+ result = await adapter.handleInstallSkill(id, installParams);
3378
+ break;
3379
+ }
3380
+ // Auto-mode RPC methods
3381
+ case RPC_METHODS.AUTOMODE_START: {
3382
+ const startParams = params;
3383
+ if (!_optionalChain([startParams, 'optionalAccess', _170 => _170.prompt])) {
3384
+ if (shouldRespond) {
3385
+ return createErrorResponse(
3386
+ id,
3387
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3388
+ "Missing required parameter: prompt"
3389
+ );
3390
+ }
3391
+ return null;
3392
+ }
3393
+ result = await adapter.handleAutomodeStart(id, startParams);
3394
+ break;
3395
+ }
3396
+ case RPC_METHODS.AUTOMODE_STATUS: {
3397
+ result = adapter.handleAutomodeStatus(id);
3398
+ break;
3399
+ }
3400
+ case RPC_METHODS.AUTOMODE_PAUSE: {
3401
+ result = await adapter.handleAutomodePause(id);
3402
+ break;
3403
+ }
3404
+ case RPC_METHODS.AUTOMODE_RESUME: {
3405
+ result = await adapter.handleAutomodeResume(id);
3406
+ break;
3407
+ }
3408
+ case RPC_METHODS.AUTOMODE_CANCEL: {
3409
+ const cancelParams = params;
3410
+ result = await adapter.handleAutomodeCancel(id, _optionalChain([cancelParams, 'optionalAccess', _171 => _171.reason]));
3411
+ break;
3412
+ }
3413
+ case RPC_METHODS.AUTOMODE_GET_LOG: {
3414
+ const logParams = params;
3415
+ result = adapter.handleAutomodeGetLog(id, _optionalChain([logParams, 'optionalAccess', _172 => _172.limit]));
3416
+ break;
3417
+ }
3418
+ case RPC_METHODS.PLAN_MODE_SET: {
3419
+ const planParams = params;
3420
+ if (_optionalChain([planParams, 'optionalAccess', _173 => _173.enabled]) === void 0) {
3421
+ if (shouldRespond) {
3422
+ return createErrorResponse(
3423
+ id,
3424
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3425
+ "Missing required parameter: enabled"
3426
+ );
3427
+ }
3428
+ return null;
3429
+ }
3430
+ const planModeManager = _chunkLFDPTJYFcjs.getPlanModeManager.call(void 0, );
3431
+ if (planParams.enabled) {
3432
+ planModeManager.enable();
3433
+ } else {
3434
+ planModeManager.disable();
3435
+ }
3436
+ process.stderr.write(`[RPC DEBUG] Plan mode set to: ${planParams.enabled}
3437
+ `);
3438
+ result = { success: true };
3439
+ break;
3440
+ }
3441
+ case RPC_METHODS.GET_HISTORY: {
3442
+ const historyParams = params;
3443
+ result = await adapter.handleGetHistory(id, historyParams);
3444
+ break;
3445
+ }
3446
+ case RPC_METHODS.GET_SESSION: {
3447
+ result = await adapter.handleGetSession(id, params);
3448
+ break;
3449
+ }
3450
+ case RPC_METHODS.YOLO_SET: {
3451
+ const yoloParams = params;
3452
+ if (!_optionalChain([yoloParams, 'optionalAccess', _174 => _174.pattern])) {
3453
+ if (shouldRespond) {
3454
+ return createErrorResponse(
3455
+ id,
3456
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3457
+ "Missing required parameter: pattern"
3458
+ );
3459
+ }
3460
+ return null;
3461
+ }
3462
+ result = adapter.handleYoloSet(id, yoloParams);
3463
+ break;
3464
+ }
3465
+ case RPC_METHODS.MCP_LIST_SERVERS: {
3466
+ result = adapter.handleMcpListServers(id);
3467
+ break;
3468
+ }
3469
+ case RPC_METHODS.MCP_LIST_TOOLS: {
3470
+ const mcpToolsParams = params;
3471
+ result = adapter.handleMcpListTools(id, mcpToolsParams);
3472
+ break;
3473
+ }
3474
+ case RPC_METHODS.MCP_SET_VSCODE_TOOLS: {
3475
+ const setToolsParams = params;
3476
+ if (!_optionalChain([setToolsParams, 'optionalAccess', _175 => _175.tools])) {
3477
+ if (shouldRespond) {
3478
+ return createErrorResponse(
3479
+ id,
3480
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3481
+ "Missing required parameter: tools"
3482
+ );
3483
+ }
3484
+ return null;
3485
+ }
3486
+ result = adapter.handleMcpSetVscodeTools(id, setToolsParams);
3487
+ break;
3488
+ }
3489
+ case RPC_METHODS.MCP_INVOKE_RESPONSE: {
3490
+ const invokeParams = params;
3491
+ if (!_optionalChain([invokeParams, 'optionalAccess', _176 => _176.requestId]) || _optionalChain([invokeParams, 'optionalAccess', _177 => _177.success]) === void 0) {
3492
+ if (shouldRespond) {
3493
+ return createErrorResponse(
3494
+ id,
3495
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3496
+ "Missing required parameters: requestId, success"
3497
+ );
3498
+ }
3499
+ return null;
3500
+ }
3501
+ if (invokeParams.requestId.startsWith("browser_")) {
3502
+ const { resolveBrowserToolResponse } = await Promise.resolve().then(() => _interopRequireWildcard(require("./browserToolBridge-BXRQB4B4.cjs")));
3503
+ const handled = resolveBrowserToolResponse(
3504
+ invokeParams.requestId,
3505
+ invokeParams.success,
3506
+ typeof invokeParams.result === "string" ? invokeParams.result : JSON.stringify(invokeParams.result),
3507
+ invokeParams.error
3508
+ );
3509
+ if (handled) {
3510
+ result = { success: true };
3511
+ break;
3512
+ }
3513
+ }
3514
+ result = adapter.handleMcpInvokeResponse(id, invokeParams);
3515
+ break;
3516
+ }
3517
+ case RPC_METHODS.MCP_GET_SERVER_CONFIGS: {
3518
+ result = adapter.handleMcpGetServerConfigs(id);
3519
+ break;
3520
+ }
3521
+ // Learn command methods
3522
+ case RPC_METHODS.LEARN_RECOMMEND: {
3523
+ const learnParams = params;
3524
+ result = await adapter.handleLearnRecommend(id, learnParams);
3525
+ break;
3526
+ }
3527
+ case RPC_METHODS.LEARN_UPDATE: {
3528
+ result = await adapter.handleLearnUpdate(id);
3529
+ break;
3530
+ }
3531
+ case RPC_METHODS.LEARN_GENERATE: {
3532
+ const generateParams = params;
3533
+ if (!_optionalChain([generateParams, 'optionalAccess', _178 => _178.scope])) {
3534
+ if (shouldRespond) {
3535
+ return createErrorResponse(
3536
+ id,
3537
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3538
+ "Missing required parameter: scope"
3539
+ );
3540
+ }
3541
+ return null;
3542
+ }
3543
+ result = await adapter.handleLearnGenerate(id, generateParams);
3544
+ break;
3545
+ }
3546
+ // SDK control methods
3547
+ case RPC_METHODS.SET_PERMISSION_MODE: {
3548
+ const setPermParams = params;
3549
+ if (!_optionalChain([setPermParams, 'optionalAccess', _179 => _179.mode])) {
3550
+ if (shouldRespond) {
3551
+ return createErrorResponse(
3552
+ id,
3553
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3554
+ "Missing required parameter: mode"
3555
+ );
3556
+ }
3557
+ return null;
3558
+ }
3559
+ result = await adapter.handleSetPermissionMode(setPermParams);
3560
+ break;
3561
+ }
3562
+ case RPC_METHODS.SET_MODEL: {
3563
+ const setModelParams = params;
3564
+ result = await adapter.handleSetModel(setModelParams);
3565
+ break;
3566
+ }
3567
+ case RPC_METHODS.SET_MAX_THINKING_TOKENS: {
3568
+ const setThinkingParams = params;
3569
+ result = await adapter.handleSetMaxThinkingTokens(setThinkingParams);
3570
+ break;
3571
+ }
3572
+ case RPC_METHODS.APPLY_FLAG_SETTINGS: {
3573
+ const applyFlagsParams = params;
3574
+ if (!_optionalChain([applyFlagsParams, 'optionalAccess', _180 => _180.settings])) {
3575
+ if (shouldRespond) {
3576
+ return createErrorResponse(
3577
+ id,
3578
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3579
+ "Missing required parameter: settings"
3580
+ );
3581
+ }
3582
+ return null;
3583
+ }
3584
+ result = await adapter.handleApplyFlagSettings(applyFlagsParams);
3585
+ break;
3586
+ }
3587
+ case RPC_METHODS.GET_SUPPORTED_MODELS: {
3588
+ result = await adapter.handleGetSupportedModels();
3589
+ break;
3590
+ }
3591
+ case RPC_METHODS.GET_SUPPORTED_COMMANDS: {
3592
+ result = await adapter.handleGetSupportedCommands();
3593
+ break;
3594
+ }
3595
+ case RPC_METHODS.GET_TOOLS_REGISTRY: {
3596
+ result = adapter.handleGetToolsRegistry();
3597
+ break;
3598
+ }
3599
+ case RPC_METHODS.GET_CONTEXT_USAGE: {
3600
+ result = await adapter.handleGetContextUsage();
3601
+ break;
3602
+ }
3603
+ case RPC_METHODS.SET_CONTEXT_COMPACT: {
3604
+ const compactParams = params;
3605
+ if (_optionalChain([compactParams, 'optionalAccess', _181 => _181.enabled]) === void 0) {
3606
+ if (shouldRespond) {
3607
+ return {
3608
+ jsonrpc: "2.0",
3609
+ error: { code: -32602, message: "Missing enabled parameter" },
3610
+ id: _nullishCoalesce(id, () => ( null))
3611
+ };
3612
+ }
3613
+ return null;
3614
+ }
3615
+ result = await adapter.handleSetContextCompact({ enabled: compactParams.enabled });
3616
+ break;
3617
+ }
3618
+ case RPC_METHODS.RELOAD_PLUGINS: {
3619
+ result = await adapter.handleReloadPlugins();
3620
+ break;
3621
+ }
3622
+ case RPC_METHODS.GET_ACCOUNT_INFO: {
3623
+ result = await adapter.handleGetAccountInfo();
3624
+ break;
3625
+ }
3626
+ case RPC_METHODS.MCP_TOGGLE_SERVER: {
3627
+ const toggleParams = params;
3628
+ if (!_optionalChain([toggleParams, 'optionalAccess', _182 => _182.serverName]) || _optionalChain([toggleParams, 'optionalAccess', _183 => _183.enabled]) === void 0) {
3629
+ if (shouldRespond) {
3630
+ return createErrorResponse(
3631
+ id,
3632
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3633
+ "Missing required parameters: serverName, enabled"
3634
+ );
3635
+ }
3636
+ return null;
3637
+ }
3638
+ result = await adapter.handleMcpToggleServer(toggleParams);
3639
+ break;
3640
+ }
3641
+ case RPC_METHODS.MCP_RECONNECT_SERVER: {
3642
+ const reconnectParams = params;
3643
+ if (!_optionalChain([reconnectParams, 'optionalAccess', _184 => _184.serverName])) {
3644
+ if (shouldRespond) {
3645
+ return createErrorResponse(
3646
+ id,
3647
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3648
+ "Missing required parameter: serverName"
3649
+ );
3650
+ }
3651
+ return null;
3652
+ }
3653
+ result = await adapter.handleMcpReconnectServer(reconnectParams);
3654
+ break;
3655
+ }
3656
+ case RPC_METHODS.MCP_SET_SERVERS: {
3657
+ const setServersParams = params;
3658
+ if (!_optionalChain([setServersParams, 'optionalAccess', _185 => _185.servers])) {
3659
+ if (shouldRespond) {
3660
+ return createErrorResponse(
3661
+ id,
3662
+ JSON_RPC_ERROR_CODES.INVALID_PARAMS,
3663
+ "Missing required parameter: servers"
3664
+ );
3665
+ }
3666
+ return null;
3667
+ }
3668
+ result = await adapter.handleMcpSetServers(setServersParams);
3669
+ break;
3670
+ }
3671
+ default: {
3672
+ if (shouldRespond) {
3673
+ return createErrorResponse(
3674
+ id,
3675
+ JSON_RPC_ERROR_CODES.METHOD_NOT_FOUND,
3676
+ `Method not found: ${method}`
3677
+ );
3678
+ }
3679
+ return null;
3680
+ }
3681
+ }
3682
+ if (shouldRespond) {
3683
+ return createResponse(id, result);
3684
+ }
3685
+ return null;
3686
+ } catch (error) {
3687
+ const message = error instanceof Error ? error.message : String(error);
3688
+ if (shouldRespond) {
3689
+ return createErrorResponse(
3690
+ id,
3691
+ JSON_RPC_ERROR_CODES.INTERNAL_ERROR,
3692
+ message
3693
+ );
3694
+ }
3695
+ return null;
3696
+ }
3697
+ }
3698
+
3699
+
3700
+
3701
+
3702
+
3703
+
3704
+
3705
+
3706
+
3707
+
3708
+
3709
+
3710
+
3711
+
3712
+
3713
+
3714
+
3715
+
3716
+
3717
+
3718
+
3719
+
3720
+
3721
+
3722
+
3723
+
3724
+
3725
+
3726
+
3727
+
3728
+
3729
+
3730
+ exports.JSON_RPC_ERROR_CODES = JSON_RPC_ERROR_CODES; exports.LineReader = LineReader; exports.MAX_IMAGE_SIZE = MAX_IMAGE_SIZE; exports.RPCAdapter = RPCAdapter; exports.RPC_METHODS = RPC_METHODS; exports.RPC_NOTIFICATIONS = RPC_NOTIFICATIONS; exports.VALID_IMAGE_MIME_TYPES = VALID_IMAGE_MIME_TYPES; exports.createErrorResponse = createErrorResponse; exports.createNotification = createNotification; exports.createRequest = createRequest; exports.createResponse = createResponse; exports.createTimestamp = createTimestamp; exports.generateId = generateId; exports.isJsonRpcBatch = isJsonRpcBatch; exports.isJsonRpcRequest = isJsonRpcRequest; exports.isJsonRpcResponse = isJsonRpcResponse; exports.isNotification = isNotification; exports.isValidImageMimeType = isValidImageMimeType; exports.parseRequest = parseRequest; exports.restoreConsole = restoreConsole; exports.runRpcMode = runRpcMode; exports.serialize = serialize; exports.serializeBatch = serializeBatch; exports.writeBatchResponse = writeBatchResponse; exports.writeErrorResponse = writeErrorResponse; exports.writeInternalError = writeInternalError; exports.writeInvalidRequestError = writeInvalidRequestError; exports.writeMethodNotFoundError = writeMethodNotFoundError; exports.writeNotification = writeNotification; exports.writeParseError = writeParseError; exports.writeResponse = writeResponse;