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