@shareai-lab/kode 2.0.2 → 2.0.3

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 (343) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +649 -25
  3. package/README.zh-CN.md +579 -0
  4. package/cli-acp.js +3 -17
  5. package/cli.js +5 -7
  6. package/dist/chunks/Doctor-M3J7GRTJ.js +12 -0
  7. package/dist/chunks/LogList-ISWZ6DDD.js +121 -0
  8. package/dist/chunks/LogList-ISWZ6DDD.js.map +7 -0
  9. package/dist/chunks/REPL-RQ6LO6S7.js +56 -0
  10. package/dist/chunks/ResumeConversation-6DMVBEGH.js +56 -0
  11. package/dist/chunks/agentLoader-FCRG3TFJ.js +31 -0
  12. package/dist/{agentsValidate-XP3CFN6F.js → chunks/agentsValidate-PEWMYN4Q.js} +97 -69
  13. package/dist/chunks/agentsValidate-PEWMYN4Q.js.map +7 -0
  14. package/dist/{ask-3G5H5KD5.js → chunks/ask-D7SOHJ6Z.js} +36 -44
  15. package/dist/chunks/ask-D7SOHJ6Z.js.map +7 -0
  16. package/dist/chunks/autoUpdater-CNESBOKO.js +19 -0
  17. package/dist/{chunk-EH34V7CY.js → chunks/chunk-2JN5MY67.js} +12 -14
  18. package/dist/chunks/chunk-2JN5MY67.js.map +7 -0
  19. package/dist/chunks/chunk-2QONJ5MG.js +14 -0
  20. package/dist/chunks/chunk-2QONJ5MG.js.map +7 -0
  21. package/dist/chunks/chunk-2WEXPKHH.js +903 -0
  22. package/dist/chunks/chunk-2WEXPKHH.js.map +7 -0
  23. package/dist/{chunk-K2MI4TPB.js → chunks/chunk-3BYE3ME6.js} +717 -792
  24. package/dist/chunks/chunk-3BYE3ME6.js.map +7 -0
  25. package/dist/chunks/chunk-3JDNWX7W.js +1264 -0
  26. package/dist/chunks/chunk-3JDNWX7W.js.map +7 -0
  27. package/dist/chunks/chunk-3OEJVB5A.js +906 -0
  28. package/dist/chunks/chunk-3OEJVB5A.js.map +7 -0
  29. package/dist/chunks/chunk-3TNIOEBO.js +369 -0
  30. package/dist/chunks/chunk-3TNIOEBO.js.map +7 -0
  31. package/dist/chunks/chunk-4A46ZXMJ.js +67 -0
  32. package/dist/chunks/chunk-4A46ZXMJ.js.map +7 -0
  33. package/dist/{chunk-4GAIJGRH.js → chunks/chunk-4ATBQOFO.js} +107 -55
  34. package/dist/chunks/chunk-4ATBQOFO.js.map +7 -0
  35. package/dist/chunks/chunk-4CRUCZR4.js +0 -0
  36. package/dist/{chunk-54DNHKOD.js → chunks/chunk-4EO6SIQY.js} +32 -75
  37. package/dist/chunks/chunk-4EO6SIQY.js.map +7 -0
  38. package/dist/chunks/chunk-53M46S5I.js +64 -0
  39. package/dist/chunks/chunk-53M46S5I.js.map +7 -0
  40. package/dist/{chunk-JC6NCUG5.js → chunks/chunk-54KOYG5C.js} +0 -2
  41. package/dist/{chunk-EZXMVTDU.js → chunks/chunk-6BAS4WY6.js} +29 -45
  42. package/dist/chunks/chunk-6BAS4WY6.js.map +7 -0
  43. package/dist/{chunk-BHGTA6JQ.js → chunks/chunk-6KRRFSDN.js} +4 -6
  44. package/dist/chunks/chunk-6KRRFSDN.js.map +7 -0
  45. package/dist/chunks/chunk-6LJNZK4K.js +39 -0
  46. package/dist/chunks/chunk-6LJNZK4K.js.map +7 -0
  47. package/dist/chunks/chunk-6ZWEOSEI.js +666 -0
  48. package/dist/chunks/chunk-6ZWEOSEI.js.map +7 -0
  49. package/dist/chunks/chunk-77XDJMBP.js +3326 -0
  50. package/dist/chunks/chunk-77XDJMBP.js.map +7 -0
  51. package/dist/chunks/chunk-7RRW4NTB.js +6454 -0
  52. package/dist/chunks/chunk-7RRW4NTB.js.map +7 -0
  53. package/dist/chunks/chunk-7X3TW4JB.js +4520 -0
  54. package/dist/chunks/chunk-7X3TW4JB.js.map +7 -0
  55. package/dist/chunks/chunk-B3MW3YGY.js +1409 -0
  56. package/dist/chunks/chunk-B3MW3YGY.js.map +7 -0
  57. package/dist/chunks/chunk-BBJFHTBC.js +28 -0
  58. package/dist/chunks/chunk-BBJFHTBC.js.map +7 -0
  59. package/dist/chunks/chunk-BHDHXOXB.js +24 -0
  60. package/dist/chunks/chunk-BHDHXOXB.js.map +7 -0
  61. package/dist/{chunk-OZNRLY3E.js → chunks/chunk-BTA7SZ26.js} +152 -223
  62. package/dist/chunks/chunk-BTA7SZ26.js.map +7 -0
  63. package/dist/chunks/chunk-CDGRYGPZ.js +103 -0
  64. package/dist/chunks/chunk-CDGRYGPZ.js.map +7 -0
  65. package/dist/{chunk-S6HRABTA.js → chunks/chunk-CP6E5UG6.js} +1 -4
  66. package/dist/chunks/chunk-CP6E5UG6.js.map +7 -0
  67. package/dist/{chunk-2PMO2FS2.js → chunks/chunk-DQ4JHXMT.js} +462 -424
  68. package/dist/chunks/chunk-DQ4JHXMT.js.map +7 -0
  69. package/dist/chunks/chunk-DXD76CMV.js +208 -0
  70. package/dist/chunks/chunk-DXD76CMV.js.map +7 -0
  71. package/dist/chunks/chunk-GCQCAXJZ.js +0 -0
  72. package/dist/chunks/chunk-GELCZWMB.js +42 -0
  73. package/dist/chunks/chunk-GELCZWMB.js.map +7 -0
  74. package/dist/{chunk-NQLEUHMS.js → chunks/chunk-HJYOH4HC.js} +23 -18
  75. package/dist/chunks/chunk-HJYOH4HC.js.map +7 -0
  76. package/dist/chunks/chunk-HPYNW6TT.js +744 -0
  77. package/dist/chunks/chunk-HPYNW6TT.js.map +7 -0
  78. package/dist/{chunk-2KWKUXLT.js → chunks/chunk-HRJ3ICQK.js} +59 -55
  79. package/dist/chunks/chunk-HRJ3ICQK.js.map +7 -0
  80. package/dist/{chunk-ZQU3TXLC.js → chunks/chunk-IFCIADS3.js} +571 -573
  81. package/dist/chunks/chunk-IFCIADS3.js.map +7 -0
  82. package/dist/chunks/chunk-IN7XZ7BC.js +27 -0
  83. package/dist/chunks/chunk-IN7XZ7BC.js.map +7 -0
  84. package/dist/chunks/chunk-L7P4M4KW.js +193 -0
  85. package/dist/chunks/chunk-L7P4M4KW.js.map +7 -0
  86. package/dist/chunks/chunk-LB6TCPDI.js +0 -0
  87. package/dist/{chunk-3RUXVV4S.js → chunks/chunk-LOCXPQNJ.js} +1 -4
  88. package/dist/{chunk-3RUXVV4S.js.map → chunks/chunk-LOCXPQNJ.js.map} +2 -2
  89. package/dist/{chunk-IE2CG2TV.js → chunks/chunk-LOD5ZHCI.js} +213 -208
  90. package/dist/chunks/chunk-LOD5ZHCI.js.map +7 -0
  91. package/dist/{chunk-S3J2TLV6.js → chunks/chunk-M7P3QNRU.js} +1 -4
  92. package/dist/{chunk-S3J2TLV6.js.map → chunks/chunk-M7P3QNRU.js.map} +2 -2
  93. package/dist/chunks/chunk-PPHLQVL7.js +4234 -0
  94. package/dist/chunks/chunk-PPHLQVL7.js.map +7 -0
  95. package/dist/{chunk-ABLVTESJ.js → chunks/chunk-QAXE37B5.js} +1 -4
  96. package/dist/chunks/chunk-QAXE37B5.js.map +7 -0
  97. package/dist/chunks/chunk-QHQOBUF6.js +60 -0
  98. package/dist/chunks/chunk-QHQOBUF6.js.map +7 -0
  99. package/dist/{chunk-SRZZFAS7.js → chunks/chunk-RPJXO7GG.js} +241 -214
  100. package/dist/chunks/chunk-RPJXO7GG.js.map +7 -0
  101. package/dist/{chunk-NPFOMITO.js → chunks/chunk-SWQV4KSY.js} +1 -4
  102. package/dist/{chunk-NPFOMITO.js.map → chunks/chunk-SWQV4KSY.js.map} +2 -2
  103. package/dist/chunks/chunk-SZLAPULP.js +28 -0
  104. package/dist/chunks/chunk-SZLAPULP.js.map +7 -0
  105. package/dist/{chunk-SDGKPKDK.js → chunks/chunk-T7RB5V5J.js} +23 -25
  106. package/dist/chunks/chunk-T7RB5V5J.js.map +7 -0
  107. package/dist/{chunk-HN4E4UUQ.js → chunks/chunk-TI2CTTMA.js} +25 -17
  108. package/dist/chunks/chunk-TI2CTTMA.js.map +7 -0
  109. package/dist/{chunk-G6I7XROM.js → chunks/chunk-TNGVRTO5.js} +45 -20
  110. package/dist/chunks/chunk-TNGVRTO5.js.map +7 -0
  111. package/dist/chunks/chunk-TNWB3U5Y.js +2077 -0
  112. package/dist/chunks/chunk-TNWB3U5Y.js.map +7 -0
  113. package/dist/chunks/chunk-U2IHWPCU.js +12 -0
  114. package/dist/chunks/chunk-U2IHWPCU.js.map +7 -0
  115. package/dist/{chunk-KAA5BGMQ.js → chunks/chunk-UNOY3VJ2.js} +1 -4
  116. package/dist/{chunk-KAA5BGMQ.js.map → chunks/chunk-UNOY3VJ2.js.map} +2 -2
  117. package/dist/{chunk-3TXNP6HH.js → chunks/chunk-UVDJL6ZZ.js} +97 -58
  118. package/dist/chunks/chunk-UVDJL6ZZ.js.map +7 -0
  119. package/dist/chunks/chunk-VNCW4C2Z.js +13452 -0
  120. package/dist/chunks/chunk-VNCW4C2Z.js.map +7 -0
  121. package/dist/chunks/chunk-W5EGGA44.js +15 -0
  122. package/dist/chunks/chunk-W5EGGA44.js.map +7 -0
  123. package/dist/chunks/chunk-XR2W3MAM.js +1533 -0
  124. package/dist/chunks/chunk-XR2W3MAM.js.map +7 -0
  125. package/dist/{chunk-QYFKRZQC.js → chunks/chunk-YIO5EBMQ.js} +423 -377
  126. package/dist/chunks/chunk-YIO5EBMQ.js.map +7 -0
  127. package/dist/chunks/chunk-ZBVLKZ5V.js +1062 -0
  128. package/dist/chunks/chunk-ZBVLKZ5V.js.map +7 -0
  129. package/dist/{chunk-E6YNABER.js → chunks/chunk-ZCLTZIVP.js} +1 -4
  130. package/dist/chunks/chunk-ZCLTZIVP.js.map +7 -0
  131. package/dist/chunks/client-SILZNM5N.js +42 -0
  132. package/dist/{config-6ZMBCL23.js → chunks/config-25HRTPSP.js} +48 -10
  133. package/dist/chunks/cost-tracker-Z2UZT2J5.js +28 -0
  134. package/dist/{customCommands-DNEJS3ZU.js → chunks/customCommands-TYMYZRG5.js} +11 -8
  135. package/dist/chunks/engine-MRVF6FK6.js +39 -0
  136. package/dist/{env-OFAXZ3XG.js → chunks/env-TJ5NOBEB.js} +7 -5
  137. package/dist/{kodeAgentSessionId-X6XWQW7B.js → chunks/kodeAgentSessionId-VTNISJ2L.js} +2 -4
  138. package/dist/chunks/kodeAgentSessionLoad-YB2RKBGJ.js +15 -0
  139. package/dist/chunks/kodeAgentSessionResume-DZSIVKVA.js +13 -0
  140. package/dist/chunks/kodeAgentStreamJson-X5PLS2S6.js +11 -0
  141. package/dist/{kodeAgentStreamJsonSession-GRWG3SPE.js → chunks/kodeAgentStreamJsonSession-RDXM4XYF.js} +38 -24
  142. package/dist/chunks/kodeAgentStreamJsonSession-RDXM4XYF.js.map +7 -0
  143. package/dist/{chunk-4RTX4AG4.js → chunks/kodeAgentStructuredStdio-SVGDSB4P.js} +14 -9
  144. package/dist/chunks/kodeAgentStructuredStdio-SVGDSB4P.js.map +7 -0
  145. package/dist/{kodeHooks-TDMXFWSO.js → chunks/kodeHooks-RVKYRJHG.js} +11 -9
  146. package/dist/{llm-XVXWYOHK.js → chunks/llm-62N6T5ZT.js} +1734 -1526
  147. package/dist/chunks/llm-62N6T5ZT.js.map +7 -0
  148. package/dist/chunks/llmLazy-ZUSSE3ZA.js +13 -0
  149. package/dist/{mentionProcessor-YD7YXYGF.js → chunks/mentionProcessor-RJW5UPJD.js} +46 -16
  150. package/dist/chunks/mentionProcessor-RJW5UPJD.js.map +7 -0
  151. package/dist/{messages-OFUJSPRV.js → chunks/messages-EEWWLPHN.js} +2 -6
  152. package/dist/chunks/model-5TIEKQPD.js +37 -0
  153. package/dist/{openai-5G5D5Q4B.js → chunks/openai-XXK3YZG4.js} +13 -10
  154. package/dist/{outputStyles-HLDXFQK3.js → chunks/outputStyles-FAJTXN2A.js} +6 -9
  155. package/dist/chunks/permissions-HO7INPWM.js +27 -0
  156. package/dist/{pluginRuntime-FPTKK6NY.js → chunks/pluginRuntime-C7K5ULK2.js} +31 -48
  157. package/dist/chunks/pluginRuntime-C7K5ULK2.js.map +7 -0
  158. package/dist/chunks/pluginValidation-DAM7WRTC.js +20 -0
  159. package/dist/chunks/registry-XYJXMOA5.js +60 -0
  160. package/dist/chunks/responsesStreaming-JNGE2P3D.js +8 -0
  161. package/dist/chunks/runNonTextPrintMode-SVBLCZQX.js +577 -0
  162. package/dist/chunks/runNonTextPrintMode-SVBLCZQX.js.map +7 -0
  163. package/dist/chunks/server-REXXF5IK.js +46 -0
  164. package/dist/{skillMarketplace-PSNKDINM.js → chunks/skillMarketplace-N4HVHNST.js} +8 -6
  165. package/dist/chunks/src-OROQIWP3.js +44 -0
  166. package/dist/chunks/src-QXLGGMUW.js +1647 -0
  167. package/dist/chunks/src-QXLGGMUW.js.map +7 -0
  168. package/dist/{cli-SRV2INSL.js → chunks/src-SSDT6MVP.js} +2659 -3384
  169. package/dist/chunks/src-SSDT6MVP.js.map +7 -0
  170. package/dist/chunks/theme-YBJUIMWK.js +10 -0
  171. package/dist/{toolPermissionContext-65L65VEZ.js → chunks/toolPermissionContext-MOCTRR7N.js} +2 -4
  172. package/dist/chunks/toolPermissionSettings-EV2EJAXL.js +18 -0
  173. package/dist/chunks/toolPermissionSettings-EV2EJAXL.js.map +7 -0
  174. package/dist/chunks/uuid-6577SO6X.js +7 -0
  175. package/dist/chunks/uuid-6577SO6X.js.map +7 -0
  176. package/dist/chunks/webOnlyMode-ALXX7UQY.js +66 -0
  177. package/dist/chunks/webOnlyMode-ALXX7UQY.js.map +7 -0
  178. package/dist/entrypoints/cli.js +10 -0
  179. package/dist/entrypoints/cli.js.map +7 -0
  180. package/dist/entrypoints/daemon.js +10 -0
  181. package/dist/entrypoints/daemon.js.map +7 -0
  182. package/dist/entrypoints/mcp.js +71 -0
  183. package/dist/entrypoints/mcp.js.map +7 -0
  184. package/dist/index.js +6 -7
  185. package/dist/index.js.map +3 -3
  186. package/dist/sdk/client.cjs +391 -0
  187. package/dist/sdk/client.cjs.map +7 -0
  188. package/dist/sdk/client.js +364 -0
  189. package/dist/sdk/client.js.map +7 -0
  190. package/dist/sdk/core.cjs +19932 -0
  191. package/dist/sdk/core.cjs.map +7 -0
  192. package/dist/sdk/core.js +19893 -0
  193. package/dist/sdk/core.js.map +7 -0
  194. package/dist/sdk/daemon-client.cjs +257 -0
  195. package/dist/sdk/daemon-client.cjs.map +7 -0
  196. package/dist/sdk/daemon-client.js +221 -0
  197. package/dist/sdk/daemon-client.js.map +7 -0
  198. package/dist/sdk/protocol.cjs +170 -0
  199. package/dist/sdk/protocol.cjs.map +7 -0
  200. package/dist/sdk/protocol.js +140 -0
  201. package/dist/sdk/protocol.js.map +7 -0
  202. package/dist/sdk/runtime-node.cjs +236 -0
  203. package/dist/sdk/runtime-node.cjs.map +7 -0
  204. package/dist/sdk/runtime-node.js +222 -0
  205. package/dist/sdk/runtime-node.js.map +7 -0
  206. package/dist/sdk/runtime.cjs +17 -0
  207. package/dist/sdk/runtime.cjs.map +7 -0
  208. package/dist/sdk/runtime.js +0 -0
  209. package/dist/sdk/runtime.js.map +7 -0
  210. package/dist/sdk/tools.cjs +30300 -0
  211. package/dist/sdk/tools.cjs.map +7 -0
  212. package/dist/sdk/tools.js +30282 -0
  213. package/dist/sdk/tools.js.map +7 -0
  214. package/dist/webui/assets/index-5hlfByVS.css +1 -0
  215. package/dist/webui/assets/index-BR9lm1lA.js +82 -0
  216. package/dist/webui/index.html +28 -0
  217. package/package.json +93 -22
  218. package/scripts/binary-utils.cjs +12 -4
  219. package/scripts/cli-acp-wrapper.cjs +3 -17
  220. package/scripts/cli-wrapper.cjs +5 -7
  221. package/scripts/postinstall.js +8 -4
  222. package/dist/REPL-GIU4ZIXM.js +0 -42
  223. package/dist/acp-H3VJ77YG.js +0 -1357
  224. package/dist/acp-H3VJ77YG.js.map +0 -7
  225. package/dist/agentsValidate-XP3CFN6F.js.map +0 -7
  226. package/dist/ask-3G5H5KD5.js.map +0 -7
  227. package/dist/autoUpdater-DNRMJWFQ.js +0 -17
  228. package/dist/chunk-2KWKUXLT.js.map +0 -7
  229. package/dist/chunk-2PMO2FS2.js.map +0 -7
  230. package/dist/chunk-3TXNP6HH.js.map +0 -7
  231. package/dist/chunk-4GAIJGRH.js.map +0 -7
  232. package/dist/chunk-4RTX4AG4.js.map +0 -7
  233. package/dist/chunk-54DNHKOD.js.map +0 -7
  234. package/dist/chunk-67PY5IX6.js +0 -34
  235. package/dist/chunk-67PY5IX6.js.map +0 -7
  236. package/dist/chunk-6DRDLOLP.js +0 -2613
  237. package/dist/chunk-6DRDLOLP.js.map +0 -7
  238. package/dist/chunk-7CQVZNQV.js +0 -1609
  239. package/dist/chunk-7CQVZNQV.js.map +0 -7
  240. package/dist/chunk-ABLVTESJ.js.map +0 -7
  241. package/dist/chunk-AIMIPK4B.js +0 -835
  242. package/dist/chunk-AIMIPK4B.js.map +0 -7
  243. package/dist/chunk-BHGTA6JQ.js.map +0 -7
  244. package/dist/chunk-CIG63V4E.js +0 -72
  245. package/dist/chunk-CIG63V4E.js.map +0 -7
  246. package/dist/chunk-E6YNABER.js.map +0 -7
  247. package/dist/chunk-EH34V7CY.js.map +0 -7
  248. package/dist/chunk-EZXMVTDU.js.map +0 -7
  249. package/dist/chunk-FH5CHM6L.js +0 -148
  250. package/dist/chunk-FH5CHM6L.js.map +0 -7
  251. package/dist/chunk-G6I7XROM.js.map +0 -7
  252. package/dist/chunk-HN4E4UUQ.js.map +0 -7
  253. package/dist/chunk-HSPVVDIW.js +0 -30198
  254. package/dist/chunk-HSPVVDIW.js.map +0 -7
  255. package/dist/chunk-IE2CG2TV.js.map +0 -7
  256. package/dist/chunk-K2MI4TPB.js.map +0 -7
  257. package/dist/chunk-MN77D2F7.js +0 -2931
  258. package/dist/chunk-MN77D2F7.js.map +0 -7
  259. package/dist/chunk-NQLEUHMS.js.map +0 -7
  260. package/dist/chunk-OIFQB3S4.js +0 -515
  261. package/dist/chunk-OIFQB3S4.js.map +0 -7
  262. package/dist/chunk-OWTG2W3A.js +0 -164
  263. package/dist/chunk-OWTG2W3A.js.map +0 -7
  264. package/dist/chunk-OZNRLY3E.js.map +0 -7
  265. package/dist/chunk-QYFKRZQC.js.map +0 -7
  266. package/dist/chunk-S6HRABTA.js.map +0 -7
  267. package/dist/chunk-SDGKPKDK.js.map +0 -7
  268. package/dist/chunk-SRZZFAS7.js.map +0 -7
  269. package/dist/chunk-UKHTVRJM.js +0 -47
  270. package/dist/chunk-UKHTVRJM.js.map +0 -7
  271. package/dist/chunk-UYXEDKOZ.js +0 -24
  272. package/dist/chunk-UYXEDKOZ.js.map +0 -7
  273. package/dist/chunk-VBXVYQYY.js +0 -145
  274. package/dist/chunk-VBXVYQYY.js.map +0 -7
  275. package/dist/chunk-WVHORZQ5.js +0 -17
  276. package/dist/chunk-WVHORZQ5.js.map +0 -7
  277. package/dist/chunk-WWUWDNWW.js +0 -49
  278. package/dist/chunk-WWUWDNWW.js.map +0 -7
  279. package/dist/chunk-Z33T5YN5.js +0 -654
  280. package/dist/chunk-Z33T5YN5.js.map +0 -7
  281. package/dist/chunk-ZQU3TXLC.js.map +0 -7
  282. package/dist/cli-SRV2INSL.js.map +0 -7
  283. package/dist/commands-TWH6PGVG.js +0 -46
  284. package/dist/context-JQIOOI4W.js +0 -30
  285. package/dist/costTracker-6SL26FDB.js +0 -19
  286. package/dist/kodeAgentSessionLoad-6N27AC5K.js +0 -18
  287. package/dist/kodeAgentSessionResume-HUSAEO24.js +0 -16
  288. package/dist/kodeAgentStreamJson-NXFN7TXH.js +0 -13
  289. package/dist/kodeAgentStreamJsonSession-GRWG3SPE.js.map +0 -7
  290. package/dist/kodeAgentStructuredStdio-HGWJT7CU.js +0 -10
  291. package/dist/llm-XVXWYOHK.js.map +0 -7
  292. package/dist/llmLazy-7TD5N7XP.js +0 -15
  293. package/dist/loader-AUXIJTY6.js +0 -28
  294. package/dist/mcp-BXJ3K7NZ.js +0 -49
  295. package/dist/mentionProcessor-YD7YXYGF.js.map +0 -7
  296. package/dist/model-KPYCXWBK.js +0 -30
  297. package/dist/pluginRuntime-FPTKK6NY.js.map +0 -7
  298. package/dist/pluginValidation-DSFXZ4GF.js +0 -17
  299. package/dist/prompts-LWLAJRS2.js +0 -48
  300. package/dist/query-HVPWL27C.js +0 -50
  301. package/dist/responsesStreaming-AW344PQO.js +0 -10
  302. package/dist/ripgrep-YOPCY2GO.js +0 -17
  303. package/dist/state-KNRWP3FO.js +0 -16
  304. package/dist/theme-7S2QN2FO.js +0 -14
  305. package/dist/toolPermissionSettings-GPOBH4IV.js +0 -18
  306. package/dist/tools-FZU2FZBD.js +0 -47
  307. package/dist/userInput-VHNBN2MW.js +0 -311
  308. package/dist/userInput-VHNBN2MW.js.map +0 -7
  309. package/dist/uuid-QN2CNKKN.js +0 -9
  310. /package/dist/{REPL-GIU4ZIXM.js.map → chunks/Doctor-M3J7GRTJ.js.map} +0 -0
  311. /package/dist/{autoUpdater-DNRMJWFQ.js.map → chunks/REPL-RQ6LO6S7.js.map} +0 -0
  312. /package/dist/{chunk-JC6NCUG5.js.map → chunks/ResumeConversation-6DMVBEGH.js.map} +0 -0
  313. /package/dist/{commands-TWH6PGVG.js.map → chunks/agentLoader-FCRG3TFJ.js.map} +0 -0
  314. /package/dist/{config-6ZMBCL23.js.map → chunks/autoUpdater-CNESBOKO.js.map} +0 -0
  315. /package/dist/{context-JQIOOI4W.js.map → chunks/chunk-4CRUCZR4.js.map} +0 -0
  316. /package/dist/{costTracker-6SL26FDB.js.map → chunks/chunk-54KOYG5C.js.map} +0 -0
  317. /package/dist/{customCommands-DNEJS3ZU.js.map → chunks/chunk-GCQCAXJZ.js.map} +0 -0
  318. /package/dist/{env-OFAXZ3XG.js.map → chunks/chunk-LB6TCPDI.js.map} +0 -0
  319. /package/dist/{kodeAgentSessionId-X6XWQW7B.js.map → chunks/client-SILZNM5N.js.map} +0 -0
  320. /package/dist/{kodeAgentSessionLoad-6N27AC5K.js.map → chunks/config-25HRTPSP.js.map} +0 -0
  321. /package/dist/{kodeAgentSessionResume-HUSAEO24.js.map → chunks/cost-tracker-Z2UZT2J5.js.map} +0 -0
  322. /package/dist/{kodeAgentStreamJson-NXFN7TXH.js.map → chunks/customCommands-TYMYZRG5.js.map} +0 -0
  323. /package/dist/{kodeAgentStructuredStdio-HGWJT7CU.js.map → chunks/engine-MRVF6FK6.js.map} +0 -0
  324. /package/dist/{kodeHooks-TDMXFWSO.js.map → chunks/env-TJ5NOBEB.js.map} +0 -0
  325. /package/dist/{llmLazy-7TD5N7XP.js.map → chunks/kodeAgentSessionId-VTNISJ2L.js.map} +0 -0
  326. /package/dist/{loader-AUXIJTY6.js.map → chunks/kodeAgentSessionLoad-YB2RKBGJ.js.map} +0 -0
  327. /package/dist/{mcp-BXJ3K7NZ.js.map → chunks/kodeAgentSessionResume-DZSIVKVA.js.map} +0 -0
  328. /package/dist/{messages-OFUJSPRV.js.map → chunks/kodeAgentStreamJson-X5PLS2S6.js.map} +0 -0
  329. /package/dist/{model-KPYCXWBK.js.map → chunks/kodeHooks-RVKYRJHG.js.map} +0 -0
  330. /package/dist/{openai-5G5D5Q4B.js.map → chunks/llmLazy-ZUSSE3ZA.js.map} +0 -0
  331. /package/dist/{outputStyles-HLDXFQK3.js.map → chunks/messages-EEWWLPHN.js.map} +0 -0
  332. /package/dist/{pluginValidation-DSFXZ4GF.js.map → chunks/model-5TIEKQPD.js.map} +0 -0
  333. /package/dist/{prompts-LWLAJRS2.js.map → chunks/openai-XXK3YZG4.js.map} +0 -0
  334. /package/dist/{query-HVPWL27C.js.map → chunks/outputStyles-FAJTXN2A.js.map} +0 -0
  335. /package/dist/{responsesStreaming-AW344PQO.js.map → chunks/permissions-HO7INPWM.js.map} +0 -0
  336. /package/dist/{ripgrep-YOPCY2GO.js.map → chunks/pluginValidation-DAM7WRTC.js.map} +0 -0
  337. /package/dist/{skillMarketplace-PSNKDINM.js.map → chunks/registry-XYJXMOA5.js.map} +0 -0
  338. /package/dist/{state-KNRWP3FO.js.map → chunks/responsesStreaming-JNGE2P3D.js.map} +0 -0
  339. /package/dist/{theme-7S2QN2FO.js.map → chunks/server-REXXF5IK.js.map} +0 -0
  340. /package/dist/{toolPermissionContext-65L65VEZ.js.map → chunks/skillMarketplace-N4HVHNST.js.map} +0 -0
  341. /package/dist/{toolPermissionSettings-GPOBH4IV.js.map → chunks/src-OROQIWP3.js.map} +0 -0
  342. /package/dist/{tools-FZU2FZBD.js.map → chunks/theme-YBJUIMWK.js.map} +0 -0
  343. /package/dist/{uuid-QN2CNKKN.js.map → chunks/toolPermissionContext-MOCTRR7N.js.map} +0 -0
@@ -1,654 +0,0 @@
1
- import { createRequire as __kodeCreateRequire } from "node:module";
2
- const require = __kodeCreateRequire(import.meta.url);
3
- import {
4
- getGlobalConfig,
5
- saveGlobalConfig
6
- } from "./chunk-AIMIPK4B.js";
7
- import {
8
- debug
9
- } from "./chunk-QYFKRZQC.js";
10
- import {
11
- logError
12
- } from "./chunk-MN77D2F7.js";
13
-
14
- // src/utils/model/index.ts
15
- import { memoize } from "lodash-es";
16
- var USE_BEDROCK = !!(process.env.KODE_USE_BEDROCK ?? process.env.CLAUDE_CODE_USE_BEDROCK);
17
- var USE_VERTEX = !!(process.env.KODE_USE_VERTEX ?? process.env.CLAUDE_CODE_USE_VERTEX);
18
- var DEFAULT_MODEL_CONFIG = {
19
- bedrock: "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
20
- vertex: "claude-3-7-sonnet@20250219",
21
- firstParty: "claude-sonnet-4-20250514"
22
- };
23
- async function getModelConfig() {
24
- return DEFAULT_MODEL_CONFIG;
25
- }
26
- var getSlowAndCapableModel = memoize(async () => {
27
- const config = await getGlobalConfig();
28
- const modelManager = new ModelManager(config);
29
- const model = modelManager.getMainAgentModel();
30
- if (model) {
31
- return model;
32
- }
33
- const modelConfig = await getModelConfig();
34
- if (USE_BEDROCK) return modelConfig.bedrock;
35
- if (USE_VERTEX) return modelConfig.vertex;
36
- return modelConfig.firstParty;
37
- });
38
- async function isDefaultSlowAndCapableModel() {
39
- return !process.env.ANTHROPIC_MODEL || process.env.ANTHROPIC_MODEL === await getSlowAndCapableModel();
40
- }
41
- function getVertexRegionForModel(model) {
42
- if (model?.startsWith("claude-3-5-haiku")) {
43
- return process.env.VERTEX_REGION_CLAUDE_3_5_HAIKU;
44
- } else if (model?.startsWith("claude-3-5-sonnet")) {
45
- return process.env.VERTEX_REGION_CLAUDE_3_5_SONNET;
46
- } else if (model?.startsWith("claude-3-7-sonnet")) {
47
- return process.env.VERTEX_REGION_CLAUDE_3_7_SONNET;
48
- }
49
- }
50
- var ModelManager = class {
51
- config;
52
- modelProfiles;
53
- constructor(config) {
54
- this.config = config;
55
- this.modelProfiles = config.modelProfiles || [];
56
- }
57
- getCurrentModel() {
58
- const mainModelName = this.config.modelPointers?.main;
59
- if (mainModelName) {
60
- const profile = this.findModelProfile(mainModelName);
61
- if (profile && profile.isActive) {
62
- return profile.modelName;
63
- }
64
- }
65
- return this.getMainAgentModel();
66
- }
67
- getMainAgentModel() {
68
- const mainModelName = this.config.modelPointers?.main;
69
- if (mainModelName) {
70
- const profile = this.findModelProfile(mainModelName);
71
- if (profile && profile.isActive) {
72
- return profile.modelName;
73
- }
74
- }
75
- const activeProfile = this.modelProfiles.find((p) => p.isActive);
76
- if (activeProfile) {
77
- return activeProfile.modelName;
78
- }
79
- return null;
80
- }
81
- getTaskToolModel() {
82
- const taskModelName = this.config.modelPointers?.task;
83
- if (taskModelName) {
84
- const profile = this.findModelProfile(taskModelName);
85
- if (profile && profile.isActive) {
86
- return profile.modelName;
87
- }
88
- }
89
- return this.getMainAgentModel();
90
- }
91
- switchToNextModelWithContextCheck(currentContextTokens = 0) {
92
- const allProfiles = this.getAllConfiguredModels();
93
- if (allProfiles.length === 0) {
94
- return {
95
- success: false,
96
- modelName: null,
97
- previousModelName: null,
98
- contextOverflow: false,
99
- usagePercentage: 0,
100
- currentContextTokens
101
- };
102
- }
103
- allProfiles.sort((a, b) => a.createdAt - b.createdAt);
104
- const currentMainModelName = this.config.modelPointers?.main;
105
- const currentModel = currentMainModelName ? this.findModelProfile(currentMainModelName) : null;
106
- const previousModelName = currentModel?.name || null;
107
- const budgetForModel = (model) => {
108
- const contextLength = Number(model.contextLength);
109
- if (!Number.isFinite(contextLength) || contextLength <= 0) {
110
- return { budgetTokens: null, usagePercentage: 0, compatible: true };
111
- }
112
- const budgetTokens = Math.floor(contextLength * 0.9);
113
- const usagePercentage = budgetTokens > 0 ? currentContextTokens / budgetTokens * 100 : 0;
114
- return {
115
- budgetTokens,
116
- usagePercentage,
117
- compatible: budgetTokens > 0 ? currentContextTokens <= budgetTokens : true
118
- };
119
- };
120
- const currentIndex = currentMainModelName ? allProfiles.findIndex((p) => p.modelName === currentMainModelName) : -1;
121
- const startIndex = currentIndex >= 0 ? currentIndex : -1;
122
- if (allProfiles.length === 1) {
123
- return {
124
- success: false,
125
- modelName: null,
126
- previousModelName,
127
- contextOverflow: false,
128
- usagePercentage: 0,
129
- currentContextTokens
130
- };
131
- }
132
- const maxOffsets = startIndex === -1 ? allProfiles.length : allProfiles.length - 1;
133
- const skippedModels = [];
134
- let selected = null;
135
- let selectedUsagePercentage = 0;
136
- for (let offset = 1; offset <= maxOffsets; offset++) {
137
- const candidateIndex = (startIndex + offset + allProfiles.length) % allProfiles.length;
138
- const candidate = allProfiles[candidateIndex];
139
- if (!candidate) continue;
140
- const { budgetTokens, usagePercentage, compatible } = budgetForModel(candidate);
141
- if (compatible) {
142
- selected = candidate;
143
- selectedUsagePercentage = usagePercentage;
144
- break;
145
- }
146
- skippedModels.push({
147
- name: candidate.name,
148
- provider: candidate.provider,
149
- contextLength: candidate.contextLength,
150
- budgetTokens,
151
- usagePercentage
152
- });
153
- }
154
- if (!selected) {
155
- const firstSkipped = skippedModels[0];
156
- return {
157
- success: false,
158
- modelName: null,
159
- previousModelName,
160
- contextOverflow: true,
161
- usagePercentage: firstSkipped?.usagePercentage ?? 0,
162
- currentContextTokens,
163
- skippedModels
164
- };
165
- }
166
- if (!selected.isActive) {
167
- selected.isActive = true;
168
- }
169
- this.setPointer("main", selected.modelName);
170
- this.updateLastUsed(selected.modelName);
171
- return {
172
- success: true,
173
- modelName: selected.name,
174
- previousModelName,
175
- contextOverflow: false,
176
- usagePercentage: selectedUsagePercentage,
177
- currentContextTokens,
178
- skippedModels
179
- };
180
- }
181
- switchToNextModel(currentContextTokens = 0) {
182
- const result = this.switchToNextModelWithContextCheck(currentContextTokens);
183
- const formatTokens = (tokens) => {
184
- if (!Number.isFinite(tokens)) return "unknown";
185
- if (tokens >= 1e3) return `${Math.round(tokens / 1e3)}k`;
186
- return String(Math.round(tokens));
187
- };
188
- const allModels = this.getAllConfiguredModels();
189
- if (allModels.length === 0) {
190
- return {
191
- success: false,
192
- modelName: null,
193
- blocked: false,
194
- message: "\u274C No models configured. Use /model to add models."
195
- };
196
- }
197
- if (allModels.length === 1) {
198
- return {
199
- success: false,
200
- modelName: null,
201
- blocked: false,
202
- message: `\u26A0\uFE0F Only one model configured (${allModels[0].modelName}). Use /model to add more models for switching.`
203
- };
204
- }
205
- const currentModel = this.findModelProfile(this.config.modelPointers?.main);
206
- const modelsSorted = [...allModels].sort(
207
- (a, b) => a.createdAt - b.createdAt
208
- );
209
- const currentIndex = modelsSorted.findIndex(
210
- (m) => m.modelName === currentModel?.modelName
211
- );
212
- const totalModels = modelsSorted.length;
213
- if (result.success && result.modelName) {
214
- const skippedCount = result.skippedModels?.length ?? 0;
215
- const skippedSuffix = skippedCount > 0 ? ` \xB7 skipped ${skippedCount} incompatible` : "";
216
- const contextSuffix = currentModel?.contextLength && result.currentContextTokens ? ` \xB7 context ~${formatTokens(result.currentContextTokens)}/${formatTokens(currentModel.contextLength)}` : "";
217
- return {
218
- success: true,
219
- modelName: result.modelName,
220
- blocked: false,
221
- message: `\u2705 Switched to ${result.modelName} (${currentIndex + 1}/${totalModels})${currentModel?.provider ? ` [${currentModel.provider}]` : ""}${skippedSuffix}${contextSuffix}`
222
- };
223
- }
224
- if (result.contextOverflow) {
225
- const attempted = result.skippedModels?.[0];
226
- const attemptedContext = attempted?.contextLength;
227
- const attemptedBudget = attempted?.budgetTokens;
228
- const currentLabel = currentModel?.name || currentModel?.modelName || "current model";
229
- const attemptedText = attempted ? `Can't switch to ${attempted.name}: current ~${formatTokens(result.currentContextTokens)} tokens exceeds safe budget (~${formatTokens(attemptedBudget ?? 0)} tokens, 90% of ${formatTokens(attemptedContext ?? 0)}).` : `Can't switch models due to context size (~${formatTokens(result.currentContextTokens)} tokens).`;
230
- return {
231
- success: false,
232
- modelName: null,
233
- blocked: true,
234
- message: `\u26A0\uFE0F ${attemptedText} Keeping ${currentLabel}.`
235
- };
236
- }
237
- return {
238
- success: false,
239
- modelName: null,
240
- blocked: false,
241
- message: "\u274C Failed to switch models"
242
- };
243
- }
244
- revertToPreviousModel(previousModelName) {
245
- const previousModel = this.modelProfiles.find(
246
- (p) => p.name === previousModelName && p.isActive
247
- );
248
- if (!previousModel) {
249
- return false;
250
- }
251
- this.setPointer("main", previousModel.modelName);
252
- this.updateLastUsed(previousModel.modelName);
253
- return true;
254
- }
255
- analyzeContextCompatibility(model, contextTokens) {
256
- const usableContext = Math.floor(model.contextLength * 0.8);
257
- const usagePercentage = contextTokens / usableContext * 100;
258
- if (usagePercentage <= 70) {
259
- return {
260
- compatible: true,
261
- severity: "safe",
262
- usagePercentage,
263
- recommendation: "Full context preserved"
264
- };
265
- } else if (usagePercentage <= 90) {
266
- return {
267
- compatible: true,
268
- severity: "warning",
269
- usagePercentage,
270
- recommendation: "Context usage high, consider compression"
271
- };
272
- } else {
273
- return {
274
- compatible: false,
275
- severity: "critical",
276
- usagePercentage,
277
- recommendation: "Auto-compression or message truncation required"
278
- };
279
- }
280
- }
281
- switchToNextModelWithAnalysis(currentContextTokens = 0) {
282
- const result = this.switchToNextModel(currentContextTokens);
283
- if (!result.success || !result.modelName) {
284
- return {
285
- modelName: null,
286
- contextAnalysis: null,
287
- requiresCompression: false,
288
- estimatedTokensAfterSwitch: 0
289
- };
290
- }
291
- const newModel = this.getModel("main");
292
- if (!newModel) {
293
- return {
294
- modelName: result.modelName,
295
- contextAnalysis: null,
296
- requiresCompression: false,
297
- estimatedTokensAfterSwitch: currentContextTokens
298
- };
299
- }
300
- const analysis = this.analyzeContextCompatibility(
301
- newModel,
302
- currentContextTokens
303
- );
304
- return {
305
- modelName: result.modelName,
306
- contextAnalysis: analysis,
307
- requiresCompression: analysis.severity === "critical",
308
- estimatedTokensAfterSwitch: currentContextTokens
309
- };
310
- }
311
- canModelHandleContext(model, contextTokens) {
312
- const analysis = this.analyzeContextCompatibility(model, contextTokens);
313
- return analysis.compatible;
314
- }
315
- findModelWithSufficientContext(models, contextTokens) {
316
- return models.find((model) => this.canModelHandleContext(model, contextTokens)) || null;
317
- }
318
- getModelForContext(contextType) {
319
- switch (contextType) {
320
- case "terminal":
321
- return this.getCurrentModel();
322
- case "main-agent":
323
- return this.getMainAgentModel();
324
- case "task-tool":
325
- return this.getTaskToolModel();
326
- default:
327
- return this.getMainAgentModel();
328
- }
329
- }
330
- getActiveModelProfiles() {
331
- return this.modelProfiles.filter((p) => p.isActive);
332
- }
333
- hasConfiguredModels() {
334
- return this.getActiveModelProfiles().length > 0;
335
- }
336
- getModel(pointer) {
337
- const pointerId = this.config.modelPointers?.[pointer];
338
- if (!pointerId) {
339
- return this.getDefaultModel();
340
- }
341
- const profile = this.findModelProfile(pointerId);
342
- return profile && profile.isActive ? profile : this.getDefaultModel();
343
- }
344
- getModelName(pointer) {
345
- const profile = this.getModel(pointer);
346
- return profile ? profile.modelName : null;
347
- }
348
- getCompactModel() {
349
- return this.getModelName("compact") || this.getModelName("main");
350
- }
351
- getQuickModel() {
352
- return this.getModelName("quick") || this.getModelName("task") || this.getModelName("main");
353
- }
354
- async addModel(config) {
355
- const existingByModelName = this.modelProfiles.find(
356
- (p) => p.modelName === config.modelName
357
- );
358
- if (existingByModelName) {
359
- throw new Error(
360
- `Model with modelName '${config.modelName}' already exists: ${existingByModelName.name}`
361
- );
362
- }
363
- const existingByName = this.modelProfiles.find((p) => p.name === config.name);
364
- if (existingByName) {
365
- throw new Error(`Model with name '${config.name}' already exists`);
366
- }
367
- const newModel = {
368
- ...config,
369
- createdAt: Date.now(),
370
- isActive: true
371
- };
372
- this.modelProfiles.push(newModel);
373
- if (this.modelProfiles.length === 1) {
374
- this.config.modelPointers = {
375
- main: config.modelName,
376
- task: config.modelName,
377
- compact: config.modelName,
378
- quick: config.modelName
379
- };
380
- this.config.defaultModelName = config.modelName;
381
- } else {
382
- if (!this.config.modelPointers) {
383
- this.config.modelPointers = {
384
- main: config.modelName,
385
- task: "",
386
- compact: "",
387
- quick: ""
388
- };
389
- } else {
390
- this.config.modelPointers.main = config.modelName;
391
- }
392
- }
393
- this.saveConfig();
394
- return config.modelName;
395
- }
396
- setPointer(pointer, modelName) {
397
- if (!this.findModelProfile(modelName)) {
398
- throw new Error(`Model '${modelName}' not found`);
399
- }
400
- if (!this.config.modelPointers) {
401
- this.config.modelPointers = {
402
- main: "",
403
- task: "",
404
- compact: "",
405
- quick: ""
406
- };
407
- }
408
- this.config.modelPointers[pointer] = modelName;
409
- this.saveConfig();
410
- }
411
- getAvailableModels() {
412
- return this.modelProfiles.filter((p) => p.isActive);
413
- }
414
- getAllConfiguredModels() {
415
- return this.modelProfiles;
416
- }
417
- getAllAvailableModelNames() {
418
- return this.getAvailableModels().map((p) => p.modelName);
419
- }
420
- getAllConfiguredModelNames() {
421
- return this.getAllConfiguredModels().map((p) => p.modelName);
422
- }
423
- getModelSwitchingDebugInfo() {
424
- const availableModels = this.getAvailableModels();
425
- const currentMainModelName = this.config.modelPointers?.main;
426
- return {
427
- totalModels: this.modelProfiles.length,
428
- activeModels: availableModels.length,
429
- inactiveModels: this.modelProfiles.length - availableModels.length,
430
- currentMainModel: currentMainModelName || null,
431
- availableModels: this.modelProfiles.map((p) => ({
432
- name: p.name,
433
- modelName: p.modelName,
434
- provider: p.provider,
435
- isActive: p.isActive,
436
- lastUsed: p.lastUsed
437
- })),
438
- modelPointers: this.config.modelPointers || {}
439
- };
440
- }
441
- removeModel(modelName) {
442
- this.modelProfiles = this.modelProfiles.filter(
443
- (p) => p.modelName !== modelName
444
- );
445
- if (this.config.modelPointers) {
446
- Object.keys(this.config.modelPointers).forEach((pointer) => {
447
- if (this.config.modelPointers[pointer] === modelName) {
448
- this.config.modelPointers[pointer] = this.config.defaultModelName || "";
449
- }
450
- });
451
- }
452
- this.saveConfig();
453
- }
454
- getDefaultModel() {
455
- if (this.config.defaultModelId) {
456
- const profile = this.findModelProfile(this.config.defaultModelId);
457
- if (profile && profile.isActive) {
458
- return profile;
459
- }
460
- }
461
- return this.modelProfiles.find((p) => p.isActive) || null;
462
- }
463
- saveConfig() {
464
- const updatedConfig = {
465
- ...this.config,
466
- modelProfiles: this.modelProfiles
467
- };
468
- saveGlobalConfig(updatedConfig);
469
- }
470
- async getFallbackModel() {
471
- const modelConfig = await getModelConfig();
472
- if (USE_BEDROCK) return modelConfig.bedrock;
473
- if (USE_VERTEX) return modelConfig.vertex;
474
- return modelConfig.firstParty;
475
- }
476
- resolveModel(modelParam) {
477
- if (["main", "task", "compact", "quick"].includes(modelParam)) {
478
- const pointerId = this.config.modelPointers?.[modelParam];
479
- if (pointerId) {
480
- let profile2 = this.findModelProfile(pointerId);
481
- if (!profile2) {
482
- profile2 = this.findModelProfileByModelName(pointerId);
483
- }
484
- if (profile2 && profile2.isActive) {
485
- return profile2;
486
- }
487
- }
488
- return this.getDefaultModel();
489
- }
490
- let profile = this.findModelProfile(modelParam);
491
- if (profile && profile.isActive) {
492
- return profile;
493
- }
494
- profile = this.findModelProfileByModelName(modelParam);
495
- if (profile && profile.isActive) {
496
- return profile;
497
- }
498
- profile = this.findModelProfileByName(modelParam);
499
- if (profile && profile.isActive) {
500
- return profile;
501
- }
502
- if (typeof modelParam === "string") {
503
- const qualified = this.resolveProviderQualifiedModel(modelParam);
504
- if (qualified && qualified.isActive) {
505
- return qualified;
506
- }
507
- }
508
- return this.getDefaultModel();
509
- }
510
- resolveModelWithInfo(modelParam) {
511
- const isPointer = ["main", "task", "compact", "quick"].includes(modelParam);
512
- if (isPointer) {
513
- const pointerId = this.config.modelPointers?.[modelParam];
514
- if (!pointerId) {
515
- return {
516
- success: false,
517
- profile: null,
518
- error: `Model pointer '${modelParam}' is not configured. Use /model to set up models.`
519
- };
520
- }
521
- let profile = this.findModelProfile(pointerId);
522
- if (!profile) {
523
- profile = this.findModelProfileByModelName(pointerId);
524
- }
525
- if (!profile) {
526
- return {
527
- success: false,
528
- profile: null,
529
- error: `Model pointer '${modelParam}' points to invalid model '${pointerId}'. Use /model to reconfigure.`
530
- };
531
- }
532
- if (!profile.isActive) {
533
- return {
534
- success: false,
535
- profile: null,
536
- error: `Model '${profile.name}' (pointed by '${modelParam}') is inactive. Use /model to activate it.`
537
- };
538
- }
539
- return {
540
- success: true,
541
- profile
542
- };
543
- } else {
544
- let profile = this.findModelProfile(modelParam);
545
- if (!profile) {
546
- profile = this.findModelProfileByModelName(modelParam);
547
- }
548
- if (!profile) {
549
- profile = this.findModelProfileByName(modelParam);
550
- }
551
- if (!profile && typeof modelParam === "string") {
552
- profile = this.resolveProviderQualifiedModel(modelParam);
553
- }
554
- if (!profile) {
555
- return {
556
- success: false,
557
- profile: null,
558
- error: `Model '${modelParam}' not found. Use /model to add models, or run 'kode models list' to see configured profiles.`
559
- };
560
- }
561
- if (!profile.isActive) {
562
- return {
563
- success: false,
564
- profile: null,
565
- error: `Model '${profile.name}' is inactive. Use /model to activate it.`
566
- };
567
- }
568
- return {
569
- success: true,
570
- profile
571
- };
572
- }
573
- }
574
- resolveProviderQualifiedModel(input) {
575
- const trimmed = input.trim();
576
- const colonIndex = trimmed.indexOf(":");
577
- if (colonIndex <= 0 || colonIndex >= trimmed.length - 1) return null;
578
- const provider = trimmed.slice(0, colonIndex).trim().toLowerCase();
579
- const modelOrName = trimmed.slice(colonIndex + 1).trim();
580
- if (!provider || !modelOrName) return null;
581
- const providerProfiles = this.modelProfiles.filter(
582
- (p) => String(p.provider).trim().toLowerCase() === provider
583
- );
584
- if (providerProfiles.length === 0) return null;
585
- const byModelName = providerProfiles.find((p) => p.modelName === modelOrName);
586
- if (byModelName) return byModelName;
587
- const byName = providerProfiles.find((p) => p.name === modelOrName);
588
- if (byName) return byName;
589
- return null;
590
- }
591
- findModelProfile(modelName) {
592
- return this.modelProfiles.find((p) => p.modelName === modelName) || null;
593
- }
594
- findModelProfileByModelName(modelName) {
595
- return this.modelProfiles.find((p) => p.modelName === modelName) || null;
596
- }
597
- findModelProfileByName(name) {
598
- return this.modelProfiles.find((p) => p.name === name) || null;
599
- }
600
- updateLastUsed(modelName) {
601
- const profile = this.findModelProfile(modelName);
602
- if (profile) {
603
- profile.lastUsed = Date.now();
604
- }
605
- }
606
- };
607
- var globalModelManager = null;
608
- var getModelManager = () => {
609
- try {
610
- if (!globalModelManager) {
611
- const config = getGlobalConfig();
612
- if (!config) {
613
- debug.warn("MODEL_MANAGER_GLOBAL_CONFIG_MISSING", {});
614
- globalModelManager = new ModelManager({
615
- modelProfiles: [],
616
- modelPointers: { main: "", task: "", compact: "", quick: "" }
617
- });
618
- } else {
619
- globalModelManager = new ModelManager(config);
620
- }
621
- }
622
- return globalModelManager;
623
- } catch (error) {
624
- logError(error);
625
- debug.error("MODEL_MANAGER_CREATE_FAILED", {
626
- error: error instanceof Error ? error.message : String(error)
627
- });
628
- return new ModelManager({
629
- modelProfiles: [],
630
- modelPointers: { main: "", task: "", compact: "", quick: "" }
631
- });
632
- }
633
- };
634
- var reloadModelManager = () => {
635
- globalModelManager = null;
636
- getModelManager();
637
- };
638
- var getQuickModel = () => {
639
- const manager = getModelManager();
640
- const quickModel = manager.getModel("quick");
641
- return quickModel?.modelName || "quick";
642
- };
643
-
644
- export {
645
- USE_BEDROCK,
646
- USE_VERTEX,
647
- getSlowAndCapableModel,
648
- isDefaultSlowAndCapableModel,
649
- getVertexRegionForModel,
650
- ModelManager,
651
- getModelManager,
652
- reloadModelManager,
653
- getQuickModel
654
- };