Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a3875d990 | ||
|
|
89c71fbfe6 | ||
|
|
7c88099ce1 | ||
|
|
cf9707326c | ||
|
|
93c5720769 |
No files matched your search
@@ -82,7 +82,7 @@ jobs:
|
|||||||
### 本次更新
|
### 本次更新
|
||||||
|
|
||||||
- **高级设置**:原「子代理设置」升级为「高级设置」,聚合子代理模型指定、实验功能开关与 WebUI 快捷入口
|
- **高级设置**:原「子代理设置」升级为「高级设置」,聚合子代理模型指定、实验功能开关与 WebUI 快捷入口
|
||||||
- **Kimi Code WebUI 应用内嵌窗口**:高级设置页可将新版 Web 界面以**独立顶层窗口**在应用内打开(单例、可缩放,关闭自动清理服务器进程),也可在系统浏览器打开(复用已运行的本地服务器)
|
- **仪表盘热力图双击弹窗**:双击热力图方块即可查看当日模型用量分布,每种模型展示 Token / 请求次数 / 费用 / 命中率
|
||||||
- **子代理模型指定(实验功能)**:为子代理绑定次主力模型,不再默认继承主模型;实验开关改为滑动开关并修复开启态隐形
|
- **子代理模型指定(实验功能)**:为子代理绑定次主力模型,不再默认继承主模型;实验开关改为滑动开关并修复开启态隐形
|
||||||
- **兼容 kimi-code 0.33+(v2 引擎)**:`loop_control` 写入新键名 `max_attempts_per_step`,旧配置自动迁移并保留旧键兼容 `KIMI_CODE_LEGACY_FLAG=1`;hooks 候选补充新事件
|
- **兼容 kimi-code 0.33+(v2 引擎)**:`loop_control` 写入新键名 `max_attempts_per_step`,旧配置自动迁移并保留旧键兼容 `KIMI_CODE_LEGACY_FLAG=1`;hooks 候选补充新事件
|
||||||
- models.dev 模型数据同步;官网企业版视觉升级;出品公司标识统一
|
- models.dev 模型数据同步;官网企业版视觉升级;出品公司标识统一
|
||||||
@@ -95,7 +95,7 @@ jobs:
|
|||||||
|
|
||||||
### macOS 安装说明(无开发者账号签名,需一次手动绕过)
|
### macOS 安装说明(无开发者账号签名,需一次手动绕过)
|
||||||
|
|
||||||
1. 下载 `KimiSwitch_*.dmg`,双击挂载后把 `Kimi Switch.app` 拖入「应用程序」文件夹
|
1. 下载 `Kimi.Switch_*.dmg`,双击挂载后把 `Kimi Switch.app` 拖入「应用程序」文件夹
|
||||||
2. 下载本 Release 附带的 `install-macos.sh`,在终端运行:
|
2. 下载本 Release 附带的 `install-macos.sh`,在终端运行:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
Generated
+473
-10
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "kimiswitch",
|
"name": "kimiswitch",
|
||||||
"version": "0.4.1",
|
"version": "0.7.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "kimiswitch",
|
"name": "kimiswitch",
|
||||||
"version": "0.4.1",
|
"version": "0.7.5",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tauri-apps/api": "^2.0.0",
|
"@tauri-apps/api": "^2.0.0",
|
||||||
"@tauri-apps/plugin-opener": "^2.5.0",
|
"@tauri-apps/plugin-opener": "^2.5.0",
|
||||||
@@ -24,7 +24,8 @@
|
|||||||
"postcss": "^8.4.41",
|
"postcss": "^8.4.41",
|
||||||
"tailwindcss": "^3.4.10",
|
"tailwindcss": "^3.4.10",
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.5.4",
|
||||||
"vite": "^5.4.2"
|
"vite": "^5.4.2",
|
||||||
|
"vitest": "^3.2.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@alloc/quick-lru": {
|
"node_modules/@alloc/quick-lru": {
|
||||||
@@ -1502,6 +1503,24 @@
|
|||||||
"@babel/types": "^7.28.2"
|
"@babel/types": "^7.28.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/chai": {
|
||||||
|
"version": "5.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz",
|
||||||
|
"integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/deep-eql": "*",
|
||||||
|
"assertion-error": "^2.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/deep-eql": {
|
||||||
|
"version": "4.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",
|
||||||
|
"integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/estree": {
|
"node_modules/@types/estree": {
|
||||||
"version": "1.0.9",
|
"version": "1.0.9",
|
||||||
"resolved": "https://registry.npmmirror.com/@types/estree/-/estree-1.0.9.tgz",
|
"resolved": "https://registry.npmmirror.com/@types/estree/-/estree-1.0.9.tgz",
|
||||||
@@ -1558,6 +1577,121 @@
|
|||||||
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
|
"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@vitest/expect": {
|
||||||
|
"version": "3.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.7.tgz",
|
||||||
|
"integrity": "sha512-E8eBXaKibuvH2pSZErOjdVb5vF4PbKYcrnluBTYxEk1l/VhhwZg1kZQsdtjq+CsF5CFydf2Rdkz7jDHKSisi3w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/chai": "^5.2.2",
|
||||||
|
"@vitest/spy": "3.2.7",
|
||||||
|
"@vitest/utils": "3.2.7",
|
||||||
|
"chai": "^5.2.0",
|
||||||
|
"tinyrainbow": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/vitest"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vitest/mocker": {
|
||||||
|
"version": "3.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.7.tgz",
|
||||||
|
"integrity": "sha512-Trr0hYO9CM3Wj6ksWHRhK9IZpIY6wTMO5u/MqXurMxT57sWBaOPEtP3Oq60ihZuh5JsiagKfz95OcxdEP6dBrA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@vitest/spy": "3.2.7",
|
||||||
|
"estree-walker": "^3.0.3",
|
||||||
|
"magic-string": "^0.30.17"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/vitest"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"msw": "^2.4.9",
|
||||||
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"msw": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"vite": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vitest/pretty-format": {
|
||||||
|
"version": "3.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.7.tgz",
|
||||||
|
"integrity": "sha512-KUHlwqVu0sRlhCdyPdQ/wBoTfRahjUky1MubOmYw9fWfIZy1gNoHpuaaQBPAaMaVYdQYHJLurzj8ECCj5OwTqA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tinyrainbow": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/vitest"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vitest/runner": {
|
||||||
|
"version": "3.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.7.tgz",
|
||||||
|
"integrity": "sha512-sB9y4ovltoQP+WaUPwmSxO9WIg9Ig694Di5PalVPsYHklAdE027mehpWF2SQSVq+k6sFgaivbTjTJwZLSHbedA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@vitest/utils": "3.2.7",
|
||||||
|
"pathe": "^2.0.3",
|
||||||
|
"strip-literal": "^3.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/vitest"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vitest/snapshot": {
|
||||||
|
"version": "3.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.7.tgz",
|
||||||
|
"integrity": "sha512-7C+MwShwtBSI5Buwoyg3s/iY1eHL9PKAf+O1wVh/TdnjXUtkoL/9YQtre90i4MtNXM6edP1wJ2zOBpfCyhIS7g==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@vitest/pretty-format": "3.2.7",
|
||||||
|
"magic-string": "^0.30.17",
|
||||||
|
"pathe": "^2.0.3"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/vitest"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vitest/spy": {
|
||||||
|
"version": "3.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.7.tgz",
|
||||||
|
"integrity": "sha512-Q2eQGI6d2L/hBtZ0qNuKcAGid68XK6cv1xsoaIma6PaJhHPoqcEJhYpXZ/5myCMqkNgtP6UKuBhbc0nHKnrkuQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"tinyspy": "^4.0.3"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/vitest"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vitest/utils": {
|
||||||
|
"version": "3.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.7.tgz",
|
||||||
|
"integrity": "sha512-x6BDOd7dyo3PFLY3I9/HJ25X/6OurhGXk2/B9gOZNPF7XDVjeBK4k01lQE5uvDpbuheErh91qYuE1E2OEjK3Rw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@vitest/pretty-format": "3.2.7",
|
||||||
|
"loupe": "^3.1.4",
|
||||||
|
"tinyrainbow": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/vitest"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/any-promise": {
|
"node_modules/any-promise": {
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"resolved": "https://registry.npmmirror.com/any-promise/-/any-promise-1.3.0.tgz",
|
"resolved": "https://registry.npmmirror.com/any-promise/-/any-promise-1.3.0.tgz",
|
||||||
@@ -1586,6 +1720,16 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/assertion-error": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/autoprefixer": {
|
"node_modules/autoprefixer": {
|
||||||
"version": "10.5.2",
|
"version": "10.5.2",
|
||||||
"resolved": "https://registry.npmmirror.com/autoprefixer/-/autoprefixer-10.5.2.tgz",
|
"resolved": "https://registry.npmmirror.com/autoprefixer/-/autoprefixer-10.5.2.tgz",
|
||||||
@@ -1696,6 +1840,16 @@
|
|||||||
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
|
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/cac": {
|
||||||
|
"version": "6.7.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz",
|
||||||
|
"integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/camelcase-css": {
|
"node_modules/camelcase-css": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmmirror.com/camelcase-css/-/camelcase-css-2.0.1.tgz",
|
"resolved": "https://registry.npmmirror.com/camelcase-css/-/camelcase-css-2.0.1.tgz",
|
||||||
@@ -1727,6 +1881,33 @@
|
|||||||
],
|
],
|
||||||
"license": "CC-BY-4.0"
|
"license": "CC-BY-4.0"
|
||||||
},
|
},
|
||||||
|
"node_modules/chai": {
|
||||||
|
"version": "5.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz",
|
||||||
|
"integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"assertion-error": "^2.0.1",
|
||||||
|
"check-error": "^2.1.1",
|
||||||
|
"deep-eql": "^5.0.1",
|
||||||
|
"loupe": "^3.1.0",
|
||||||
|
"pathval": "^2.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/check-error": {
|
||||||
|
"version": "2.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.3.tgz",
|
||||||
|
"integrity": "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 16"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/chokidar": {
|
"node_modules/chokidar": {
|
||||||
"version": "3.6.0",
|
"version": "3.6.0",
|
||||||
"resolved": "https://registry.npmmirror.com/chokidar/-/chokidar-3.6.0.tgz",
|
"resolved": "https://registry.npmmirror.com/chokidar/-/chokidar-3.6.0.tgz",
|
||||||
@@ -1820,6 +2001,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/deep-eql": {
|
||||||
|
"version": "5.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz",
|
||||||
|
"integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/didyoumean": {
|
"node_modules/didyoumean": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmmirror.com/didyoumean/-/didyoumean-1.2.2.tgz",
|
"resolved": "https://registry.npmmirror.com/didyoumean/-/didyoumean-1.2.2.tgz",
|
||||||
@@ -1851,6 +2042,13 @@
|
|||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/es-module-lexer": {
|
||||||
|
"version": "1.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz",
|
||||||
|
"integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/esbuild": {
|
"node_modules/esbuild": {
|
||||||
"version": "0.21.5",
|
"version": "0.21.5",
|
||||||
"resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.21.5.tgz",
|
"resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.21.5.tgz",
|
||||||
@@ -1900,6 +2098,26 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/estree-walker": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/estree": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/expect-type": {
|
||||||
|
"version": "1.4.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz",
|
||||||
|
"integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fast-glob": {
|
"node_modules/fast-glob": {
|
||||||
"version": "3.3.3",
|
"version": "3.3.3",
|
||||||
"resolved": "https://registry.npmmirror.com/fast-glob/-/fast-glob-3.3.3.tgz",
|
"resolved": "https://registry.npmmirror.com/fast-glob/-/fast-glob-3.3.3.tgz",
|
||||||
@@ -2164,6 +2382,13 @@
|
|||||||
"loose-envify": "cli.js"
|
"loose-envify": "cli.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/loupe": {
|
||||||
|
"version": "3.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz",
|
||||||
|
"integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/lru-cache": {
|
"node_modules/lru-cache": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-5.1.1.tgz",
|
"resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-5.1.1.tgz",
|
||||||
@@ -2183,6 +2408,16 @@
|
|||||||
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/magic-string": {
|
||||||
|
"version": "0.30.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
|
||||||
|
"integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/merge2": {
|
"node_modules/merge2": {
|
||||||
"version": "1.4.1",
|
"version": "1.4.1",
|
||||||
"resolved": "https://registry.npmmirror.com/merge2/-/merge2-1.4.1.tgz",
|
"resolved": "https://registry.npmmirror.com/merge2/-/merge2-1.4.1.tgz",
|
||||||
@@ -2227,9 +2462,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nanoid": {
|
"node_modules/nanoid": {
|
||||||
"version": "3.3.15",
|
"version": "3.3.18",
|
||||||
"resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.15.tgz",
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",
|
||||||
"integrity": "sha512-y7Wygv/7mEOvxTuEQDB8StXdMRBWf1kR/tlhAzBRUFkB2jfcLOAxO/SHmOO2zgz1pVgK29/kyupn059/bCHdjA==",
|
"integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -2292,6 +2527,23 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/pathe": {
|
||||||
|
"version": "2.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
|
||||||
|
"integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/pathval": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 14.16"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/picocolors": {
|
"node_modules/picocolors": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz",
|
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz",
|
||||||
@@ -2333,9 +2585,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
"version": "8.5.16",
|
"version": "8.5.26",
|
||||||
"resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.5.16.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",
|
||||||
"integrity": "sha512-vuwillviilfKZsg0VGj5R/YwwcHx4SLsIOI/7K6mQkWx+l5cUHTjj5g0AasTBcyXsbfTgrwsUNmVUb5xVwyPwg==",
|
"integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -2353,7 +2605,7 @@
|
|||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nanoid": "^3.3.12",
|
"nanoid": "^3.3.17",
|
||||||
"picocolors": "^1.1.1",
|
"picocolors": "^1.1.1",
|
||||||
"source-map-js": "^1.2.1"
|
"source-map-js": "^1.2.1"
|
||||||
},
|
},
|
||||||
@@ -2695,6 +2947,13 @@
|
|||||||
"semver": "bin/semver.js"
|
"semver": "bin/semver.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/siginfo": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
"node_modules/source-map-js": {
|
"node_modules/source-map-js": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.2.1.tgz",
|
"resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||||
@@ -2705,6 +2964,40 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/stackback": {
|
||||||
|
"version": "0.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",
|
||||||
|
"integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/std-env": {
|
||||||
|
"version": "3.10.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz",
|
||||||
|
"integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/strip-literal": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"js-tokens": "^9.0.1"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/antfu"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/strip-literal/node_modules/js-tokens": {
|
||||||
|
"version": "9.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz",
|
||||||
|
"integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/sucrase": {
|
"node_modules/sucrase": {
|
||||||
"version": "3.35.1",
|
"version": "3.35.1",
|
||||||
"resolved": "https://registry.npmmirror.com/sucrase/-/sucrase-3.35.1.tgz",
|
"resolved": "https://registry.npmmirror.com/sucrase/-/sucrase-3.35.1.tgz",
|
||||||
@@ -2802,6 +3095,20 @@
|
|||||||
"node": ">=0.8"
|
"node": ">=0.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tinybench": {
|
||||||
|
"version": "2.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",
|
||||||
|
"integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/tinyexec": {
|
||||||
|
"version": "0.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz",
|
||||||
|
"integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/tinyglobby": {
|
"node_modules/tinyglobby": {
|
||||||
"version": "0.2.17",
|
"version": "0.2.17",
|
||||||
"resolved": "https://registry.npmmirror.com/tinyglobby/-/tinyglobby-0.2.17.tgz",
|
"resolved": "https://registry.npmmirror.com/tinyglobby/-/tinyglobby-0.2.17.tgz",
|
||||||
@@ -2850,6 +3157,36 @@
|
|||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tinypool": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.0.0 || >=20.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tinyrainbow": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/tinyspy": {
|
||||||
|
"version": "4.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.4.tgz",
|
||||||
|
"integrity": "sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/to-regex-range": {
|
"node_modules/to-regex-range": {
|
||||||
"version": "5.0.1",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
"resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||||
@@ -2982,6 +3319,132 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/vite-node": {
|
||||||
|
"version": "3.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz",
|
||||||
|
"integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"cac": "^6.7.14",
|
||||||
|
"debug": "^4.4.1",
|
||||||
|
"es-module-lexer": "^1.7.0",
|
||||||
|
"pathe": "^2.0.3",
|
||||||
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"vite-node": "vite-node.mjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/vitest"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/vitest": {
|
||||||
|
"version": "3.2.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.7.tgz",
|
||||||
|
"integrity": "sha512-KrxIJ62Fd89gfysR4WotlgZABiz2dqFPgqGzX7s+CwsqLFomRH7777ZcrOD6+WVAh7khPQP41A+BKbpcJFrdEg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/chai": "^5.2.2",
|
||||||
|
"@vitest/expect": "3.2.7",
|
||||||
|
"@vitest/mocker": "3.2.7",
|
||||||
|
"@vitest/pretty-format": "^3.2.7",
|
||||||
|
"@vitest/runner": "3.2.7",
|
||||||
|
"@vitest/snapshot": "3.2.7",
|
||||||
|
"@vitest/spy": "3.2.7",
|
||||||
|
"@vitest/utils": "3.2.7",
|
||||||
|
"chai": "^5.2.0",
|
||||||
|
"debug": "^4.4.1",
|
||||||
|
"expect-type": "^1.2.1",
|
||||||
|
"magic-string": "^0.30.17",
|
||||||
|
"pathe": "^2.0.3",
|
||||||
|
"picomatch": "^4.0.2",
|
||||||
|
"std-env": "^3.9.0",
|
||||||
|
"tinybench": "^2.9.0",
|
||||||
|
"tinyexec": "^0.3.2",
|
||||||
|
"tinyglobby": "^0.2.14",
|
||||||
|
"tinypool": "^1.1.1",
|
||||||
|
"tinyrainbow": "^2.0.0",
|
||||||
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0",
|
||||||
|
"vite-node": "3.2.4",
|
||||||
|
"why-is-node-running": "^2.3.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"vitest": "vitest.mjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://opencollective.com/vitest"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@edge-runtime/vm": "*",
|
||||||
|
"@types/debug": "^4.1.12",
|
||||||
|
"@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
|
||||||
|
"@vitest/browser": "3.2.7",
|
||||||
|
"@vitest/ui": "3.2.7",
|
||||||
|
"happy-dom": "*",
|
||||||
|
"jsdom": "*"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@edge-runtime/vm": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/debug": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@vitest/browser": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@vitest/ui": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"happy-dom": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"jsdom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/vitest/node_modules/picomatch": {
|
||||||
|
"version": "4.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
|
||||||
|
"integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/why-is-node-running": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"siginfo": "^2.0.0",
|
||||||
|
"stackback": "0.0.2"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"why-is-node-running": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/yallist": {
|
"node_modules/yallist": {
|
||||||
"version": "3.1.1",
|
"version": "3.1.1",
|
||||||
"resolved": "https://registry.npmmirror.com/yallist/-/yallist-3.1.1.tgz",
|
"resolved": "https://registry.npmmirror.com/yallist/-/yallist-3.1.1.tgz",
|
||||||
|
|||||||
+4
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "kimiswitch",
|
"name": "kimiswitch",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.7.3",
|
"version": "0.7.5",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"fetch-models-dev": "node scripts/fetch-models-dev.mjs",
|
"fetch-models-dev": "node scripts/fetch-models-dev.mjs",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
"test": "vitest run",
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
"pretauri": "node scripts/fetch-models-dev.mjs || echo fetch-models-dev failed, using existing snapshot",
|
"pretauri": "node scripts/fetch-models-dev.mjs || echo fetch-models-dev failed, using existing snapshot",
|
||||||
"tauri-dev": "tauri dev",
|
"tauri-dev": "tauri dev",
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
"postcss": "^8.4.41",
|
"postcss": "^8.4.41",
|
||||||
"tailwindcss": "^3.4.10",
|
"tailwindcss": "^3.4.10",
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.5.4",
|
||||||
"vite": "^5.4.2"
|
"vite": "^5.4.2",
|
||||||
|
"vitest": "^3.2.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
## v0.7.4
|
||||||
|
|
||||||
|
### 仪表盘热力图双击弹窗(本次新增)
|
||||||
|
|
||||||
|
- 热力图方块**双击**即可弹窗查看当日模型用量分布
|
||||||
|
- 每种模型独立展示:**Token 用量 / 请求次数 / 费用 / 缓存命中率**(此前仅有 token 数)
|
||||||
|
- 范围外日期(不在当前 7d / 30d / all 范围内的方块)不可双击、无放大效果
|
||||||
|
- 弹窗内 Escape / 点击遮罩 / 关闭按钮均可关闭
|
||||||
|
|
||||||
|
### 数据结构升级
|
||||||
|
|
||||||
|
- 后端 `[dashboard] by_model` 从纯 token 数升级为结构化对象(含 requests / cost / cacheHitRate),弹窗和柱状图双击均展示全量指标
|
||||||
|
|
||||||
|
### Downloads by platform
|
||||||
|
|
||||||
|
- **Windows**: `.msi` installer
|
||||||
|
- **macOS**: `.dmg` + `.app`(未签名,仅 Apple Silicon / M 系列芯片)
|
||||||
|
- **Linux**: `.deb` / `.AppImage` / `.rpm`
|
||||||
|
|
||||||
|
### macOS 安装说明(无开发者账号签名,需一次手动绕过)
|
||||||
|
|
||||||
|
1. 下载 `Kimi.Switch_*.dmg`,双击挂载后把 `Kimi Switch.app` 拖入「应用程序」文件夹
|
||||||
|
2. 下载本 Release 附带的 `install-macos.sh`,在终端运行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash install-macos.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
脚本会自动清除下载隔离属性并启动应用,只需执行一次,之后正常使用。
|
||||||
|
3. 手动替代方案:右键 `Kimi Switch.app` → 打开 → 弹窗点「打开」;或 系统设置 → 隐私与安全性 → 仍要打开
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
## v0.7.5
|
||||||
|
|
||||||
|
### 子代理模型池适配(kimi-code 0.36.0 新引擎)
|
||||||
|
|
||||||
|
- 适配 kimi-code v2 的 `[secondary_model]` 模型池语义:`default_model` + `[secondary_model.models]` 表 + `force`
|
||||||
|
- **双写兼容**:写入配置时 `model` 与 `default_model` 同步同值,v1 legacy 引擎(`KIMI_CODE_LEGACY_FLAG=1`)与 v2 引擎均可正常识别
|
||||||
|
- 高级设置页新增**模型池管理**:升级旧配置为模型池、增删池条目、编辑每条目的路由描述(渲染进主代理 Agent/AgentSwarm 工具描述,直接影响主模型对子代理模型的调度质量)
|
||||||
|
- 支持 **force 强制默认模型**开关(开启会清空池条目,带二次确认)
|
||||||
|
- 保存前本地校验:primary 保留别名、池条目与 default_model 一致性、别名必须已注册、force 与池互斥等 6 类错误前置拦截
|
||||||
|
- 新增 32 个单元测试覆盖池读写与校验逻辑(vitest)
|
||||||
|
|
||||||
|
### 仪表盘热力图详情改为按需加载
|
||||||
|
|
||||||
|
- 双击热力图方块改为调用后端 `get_day_detail` 按需聚合当日数据,**不再受当前 7d / 30d 范围限制**,任何有数据的日期都可查看明细
|
||||||
|
- 无数据日期双击给出提示,不再静默无响应
|
||||||
|
|
||||||
|
### 模型数据更新
|
||||||
|
|
||||||
|
- models.dev 快照刷新至 2026-08-15(6583 模型 / 185 供应商),新增 **GLM-5.3** 等一批新模型(含定价与能力标记)
|
||||||
|
|
||||||
|
### Downloads by platform
|
||||||
|
|
||||||
|
- **Windows**: `.msi` installer
|
||||||
|
- **macOS**: `.dmg` + `.app`(未签名,仅 Apple Silicon / M 系列芯片)
|
||||||
|
- **Linux**: `.deb` / `.AppImage` / `.rpm`
|
||||||
|
|
||||||
|
### macOS 安装说明(无开发者账号签名,需一次手动绕过)
|
||||||
|
|
||||||
|
1. 下载 `Kimi.Switch_*.dmg`,双击挂载后把 `Kimi Switch.app` 拖入「应用程序」文件夹
|
||||||
|
2. 下载本 Release 附带的 `install-macos.sh`,在终端运行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash install-macos.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
脚本会自动清除下载隔离属性并启动应用,只需执行一次,之后正常使用。
|
||||||
|
3. 手动替代方案:右键 `Kimi Switch.app` → 打开 → 弹窗点「打开」;或 系统设置 → 隐私与安全性 → 仍要打开
|
||||||
Generated
+1
-1
@@ -1958,7 +1958,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kimiswitch"
|
name = "kimiswitch"
|
||||||
version = "0.7.3"
|
version = "0.7.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "kimiswitch"
|
name = "kimiswitch"
|
||||||
version = "0.7.3"
|
version = "0.7.5"
|
||||||
description = "Kimi Switch - model config manager"
|
description = "Kimi Switch - model config manager"
|
||||||
authors = ["codingplan.site"]
|
authors = ["codingplan.site"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ pub struct DailyRow {
|
|||||||
pub cost_usd: f64,
|
pub cost_usd: f64,
|
||||||
pub total_tokens: u64,
|
pub total_tokens: u64,
|
||||||
pub cache_hit_rate: f64,
|
pub cache_hit_rate: f64,
|
||||||
/// Per-model token breakdown for stacked-bar rendering
|
/// Per-model structured breakdown (tokens / requests / cost / cacheHitRate).
|
||||||
pub by_model: HashMap<String, u64>,
|
pub by_model: HashMap<String, TotalsRow>,
|
||||||
/// Per-provider token breakdown for stacked-bar rendering
|
/// Per-provider token breakdown for stacked-bar rendering
|
||||||
pub by_provider: HashMap<String, u64>,
|
pub by_provider: HashMap<String, u64>,
|
||||||
/// Per-provider, per-model nested token breakdown (provider → model → tokens),
|
/// Per-provider, per-model nested token breakdown (provider → model → tokens),
|
||||||
@@ -980,7 +980,7 @@ fn aggregate(records: &[UsageRecord], range: &str, now_ms: u64) -> RangeStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut totals = TotalsRow::default();
|
let mut totals = TotalsRow::default();
|
||||||
let mut by_day: HashMap<String, (TotalsRow, HashMap<String, u64>, HashMap<String, HashMap<String, u64>>)> = HashMap::new();
|
let mut by_day: HashMap<String, (TotalsRow, HashMap<String, TotalsRow>, HashMap<String, HashMap<String, u64>>)> = HashMap::new();
|
||||||
let mut by_model: HashMap<String, (ModelRow, TotalsRow)> = HashMap::new();
|
let mut by_model: HashMap<String, (ModelRow, TotalsRow)> = HashMap::new();
|
||||||
|
|
||||||
for r in &filtered {
|
for r in &filtered {
|
||||||
@@ -988,8 +988,7 @@ fn aggregate(records: &[UsageRecord], range: &str, now_ms: u64) -> RangeStats {
|
|||||||
let dk = day_key(r.time);
|
let dk = day_key(r.time);
|
||||||
let (day_totals, day_models, day_prov_models) = by_day.entry(dk.clone()).or_default();
|
let (day_totals, day_models, day_prov_models) = by_day.entry(dk.clone()).or_default();
|
||||||
day_totals.add(r);
|
day_totals.add(r);
|
||||||
*day_models.entry(r.model.clone()).or_insert(0) +=
|
day_models.entry(r.model.clone()).or_default().add(r);
|
||||||
r.input_other + r.output + r.input_cache_read + r.input_cache_creation;
|
|
||||||
let provider_key = r.provider.clone().unwrap_or_else(|| "unknown".to_string());
|
let provider_key = r.provider.clone().unwrap_or_else(|| "unknown".to_string());
|
||||||
*day_prov_models
|
*day_prov_models
|
||||||
.entry(provider_key)
|
.entry(provider_key)
|
||||||
@@ -1024,12 +1023,22 @@ fn aggregate(records: &[UsageRecord], range: &str, now_ms: u64) -> RangeStats {
|
|||||||
.map(|(date, (t, by_model, by_provider_model))| {
|
.map(|(date, (t, by_model, by_provider_model))| {
|
||||||
let ti = t.input_other + t.input_cache_read + t.input_cache_creation;
|
let ti = t.input_other + t.input_cache_read + t.input_cache_creation;
|
||||||
let ch = if ti > 0 { t.input_cache_read as f64 / ti as f64 } else { 0.0 };
|
let ch = if ti > 0 { t.input_cache_read as f64 / ti as f64 } else { 0.0 };
|
||||||
|
// Per-model cache_hit_rate (not cumulative; computed from the
|
||||||
|
// model's own input token split).
|
||||||
|
let by_model_finalized: HashMap<String, TotalsRow> = by_model
|
||||||
|
.into_iter()
|
||||||
|
.map(|(k, mut mt)| {
|
||||||
|
let mi = mt.input_other + mt.input_cache_read + mt.input_cache_creation;
|
||||||
|
mt.cache_hit_rate = if mi > 0 { mt.input_cache_read as f64 / mi as f64 } else { 0.0 };
|
||||||
|
(k, mt)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
DailyRow {
|
DailyRow {
|
||||||
date, requests: t.requests,
|
date, requests: t.requests,
|
||||||
input_other: t.input_other, output: t.output,
|
input_other: t.input_other, output: t.output,
|
||||||
input_cache_read: t.input_cache_read, input_cache_creation: t.input_cache_creation,
|
input_cache_read: t.input_cache_read, input_cache_creation: t.input_cache_creation,
|
||||||
cost_usd: t.cost_usd, total_tokens: t.total_tokens, cache_hit_rate: ch,
|
cost_usd: t.cost_usd, total_tokens: t.total_tokens, cache_hit_rate: ch,
|
||||||
by_model,
|
by_model: by_model_finalized,
|
||||||
by_provider: by_provider_model
|
by_provider: by_provider_model
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(p, m)| (p.clone(), m.values().sum::<u64>()))
|
.map(|(p, m)| (p.clone(), m.values().sum::<u64>()))
|
||||||
@@ -1744,10 +1753,9 @@ pub fn get_summary(home_override: Option<String>, range: Option<String>, refresh
|
|||||||
let t2 = std::time::Instant::now();
|
let t2 = std::time::Instant::now();
|
||||||
let scan_ms = t1.duration_since(t0).as_secs_f64() * 1000.0;
|
let scan_ms = t1.duration_since(t0).as_secs_f64() * 1000.0;
|
||||||
let aggregate_ms = t2.duration_since(t1).as_secs_f64() * 1000.0;
|
let aggregate_ms = t2.duration_since(t1).as_secs_f64() * 1000.0;
|
||||||
let total_ms = t2.duration_since(t0).as_secs_f64() * 1000.0;
|
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"[dashboard] get_summary range={} records={} scan={:.0}ms aggregate={:.0}ms total={:.0}ms",
|
"[dashboard] get_summary range={} records={} scan={:.0}ms aggregate={:.0}ms total={:.0}ms",
|
||||||
r, records.len(), scan_ms, aggregate_ms, total_ms
|
r, records.len(), scan_ms, aggregate_ms, t2.duration_since(t0).as_secs_f64() * 1000.0
|
||||||
);
|
);
|
||||||
|
|
||||||
SummaryResult {
|
SummaryResult {
|
||||||
@@ -1765,6 +1773,68 @@ pub fn get_summary(home_override: Option<String>, range: Option<String>, refresh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Aggregate a single calendar day into a `DailyRow` — lazy detail for the
|
||||||
|
/// heatmap double-click modal. Returns `None` when the date has no records.
|
||||||
|
fn build_day_detail(date: &str, records: &[UsageRecord]) -> Option<DailyRow> {
|
||||||
|
let mut t = TotalsRow::default();
|
||||||
|
let mut by_model: HashMap<String, TotalsRow> = HashMap::new();
|
||||||
|
let mut by_provider_model: HashMap<String, HashMap<String, u64>> = HashMap::new();
|
||||||
|
let mut found = false;
|
||||||
|
for r in records {
|
||||||
|
if day_key(r.time) != date {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
found = true;
|
||||||
|
t.add(r);
|
||||||
|
by_model.entry(r.model.clone()).or_default().add(r);
|
||||||
|
let p = r.provider.clone().unwrap_or_else(|| "unknown".to_string());
|
||||||
|
*by_provider_model
|
||||||
|
.entry(p)
|
||||||
|
.or_default()
|
||||||
|
.entry(r.model.clone())
|
||||||
|
.or_insert(0) += r.input_other + r.output + r.input_cache_read + r.input_cache_creation;
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let ti = t.input_other + t.input_cache_read + t.input_cache_creation;
|
||||||
|
let ch = if ti > 0 { t.input_cache_read as f64 / ti as f64 } else { 0.0 };
|
||||||
|
let by_model: HashMap<String, TotalsRow> = by_model
|
||||||
|
.into_iter()
|
||||||
|
.map(|(k, mut mt)| {
|
||||||
|
let mi = mt.input_other + mt.input_cache_read + mt.input_cache_creation;
|
||||||
|
mt.cache_hit_rate = if mi > 0 { mt.input_cache_read as f64 / mi as f64 } else { 0.0 };
|
||||||
|
(k, mt)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
Some(DailyRow {
|
||||||
|
date: date.to_string(),
|
||||||
|
requests: t.requests,
|
||||||
|
input_other: t.input_other,
|
||||||
|
output: t.output,
|
||||||
|
input_cache_read: t.input_cache_read,
|
||||||
|
input_cache_creation: t.input_cache_creation,
|
||||||
|
cost_usd: t.cost_usd,
|
||||||
|
total_tokens: t.total_tokens,
|
||||||
|
cache_hit_rate: ch,
|
||||||
|
by_model,
|
||||||
|
by_provider: by_provider_model
|
||||||
|
.iter()
|
||||||
|
.map(|(p, m)| (p.clone(), m.values().sum::<u64>()))
|
||||||
|
.collect(),
|
||||||
|
by_provider_model,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Lazy per-day detail for the heatmap double-click modal (fetched on demand,
|
||||||
|
/// so `get_summary` stays lean). Returns null when the date has no records.
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_day_detail(home_override: Option<String>, date: String) -> Option<DailyRow> {
|
||||||
|
let home = resolve_kimi_home(home_override);
|
||||||
|
let (records, _) = scan_usage_cached(&home, false);
|
||||||
|
build_day_detail(&date, &records)
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn list_sessions(home_override: Option<String>, status: Option<String>, workspace: Option<String>) -> SessionsResult {
|
pub fn list_sessions(home_override: Option<String>, status: Option<String>, workspace: Option<String>) -> SessionsResult {
|
||||||
let home = resolve_kimi_home(home_override);
|
let home = resolve_kimi_home(home_override);
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ pub fn run() {
|
|||||||
dashboard::get_paths,
|
dashboard::get_paths,
|
||||||
dashboard::get_prices,
|
dashboard::get_prices,
|
||||||
dashboard::get_summary,
|
dashboard::get_summary,
|
||||||
|
dashboard::get_day_detail,
|
||||||
dashboard::list_sessions,
|
dashboard::list_sessions,
|
||||||
dashboard::archive_session,
|
dashboard::archive_session,
|
||||||
dashboard::unarchive_session,
|
dashboard::unarchive_session,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"productName": "Kimi Switch",
|
"productName": "Kimi Switch",
|
||||||
"version": "0.7.3",
|
"version": "0.7.5",
|
||||||
"identifier": "com.kimiswitch.app",
|
"identifier": "com.kimiswitch.app",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
|
|||||||
@@ -8,12 +8,19 @@ import {
|
|||||||
clearSecondaryModel,
|
clearSecondaryModel,
|
||||||
forcedEnvValue,
|
forcedEnvValue,
|
||||||
getExperimentalFlags,
|
getExperimentalFlags,
|
||||||
getSecondaryModel,
|
getSubagentModelPool,
|
||||||
isFlagLockedByEnv,
|
isFlagLockedByEnv,
|
||||||
isMasterEnvOn,
|
isMasterEnvOn,
|
||||||
|
removeSubagentPoolEntry,
|
||||||
setExperimentalFlag,
|
setExperimentalFlag,
|
||||||
setSecondaryModelOnly,
|
setSecondaryModelOnly,
|
||||||
|
setSubagentDefault,
|
||||||
|
setSubagentForce,
|
||||||
|
upsertSubagentPoolEntry,
|
||||||
|
validateSubagentPool,
|
||||||
type ExperimentalFlagDef,
|
type ExperimentalFlagDef,
|
||||||
|
type PoolValidationError,
|
||||||
|
type ValidationErrorKey,
|
||||||
} from "../lib/subagent-settings";
|
} from "../lib/subagent-settings";
|
||||||
import { Card, Toggle } from "./ui/controls";
|
import { Card, Toggle } from "./ui/controls";
|
||||||
|
|
||||||
@@ -44,6 +51,97 @@ const FLAG_LABELS: Record<string, { name: TranslationKey; desc: TranslationKey }
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Validation-error i18n key per engine rule, for the pre-write self-check. */
|
||||||
|
const POOL_ERROR_KEYS: Record<ValidationErrorKey, TranslationKey> = {
|
||||||
|
primaryReserved: "secondaryPoolErrorPrimaryReserved",
|
||||||
|
defaultRequired: "secondaryPoolErrorDefaultRequired",
|
||||||
|
defaultNotInPool: "secondaryPoolErrorDefaultNotInPool",
|
||||||
|
aliasNotInModels: "secondaryPoolErrorAliasNotInModels",
|
||||||
|
forceRequiresDefault: "secondaryPoolErrorForceRequiresDefault",
|
||||||
|
forceExcludesModels: "secondaryPoolErrorForceExcludesModels",
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One row of the subagent model pool: default radio + alias + editable
|
||||||
|
* description (saved on blur/Enter via the parent's write chain) + remove.
|
||||||
|
* The description input keeps a local draft so typing is not persisted per
|
||||||
|
* keystroke; everything else is derived from `rawOther` on each render.
|
||||||
|
*/
|
||||||
|
function PoolEntryRow({
|
||||||
|
alias,
|
||||||
|
displayName,
|
||||||
|
description,
|
||||||
|
isDefault,
|
||||||
|
canRemove,
|
||||||
|
onSetDefault,
|
||||||
|
onSave,
|
||||||
|
onRemove,
|
||||||
|
}: {
|
||||||
|
alias: string;
|
||||||
|
displayName: string | null;
|
||||||
|
description: string;
|
||||||
|
isDefault: boolean;
|
||||||
|
canRemove: boolean;
|
||||||
|
onSetDefault: (alias: string) => void;
|
||||||
|
onSave: (alias: string, description: string) => void;
|
||||||
|
onRemove: (alias: string) => void;
|
||||||
|
}) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [draft, setDraft] = useState(description);
|
||||||
|
|
||||||
|
const commit = () => {
|
||||||
|
if (draft === description) return;
|
||||||
|
onSave(alias, draft);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-2 text-sm">
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
checked={isDefault}
|
||||||
|
aria-label={t("setDefault")}
|
||||||
|
onChange={() => onSetDefault(alias)}
|
||||||
|
className="shrink-0 accent-blue-600 focus:ring-blue-500"
|
||||||
|
/>
|
||||||
|
<span className="shrink-0 font-medium text-content-primary">{alias}</span>
|
||||||
|
{displayName && (
|
||||||
|
<span className="shrink-0 text-xs text-content-muted">{displayName}</span>
|
||||||
|
)}
|
||||||
|
{isDefault && (
|
||||||
|
<span className="shrink-0 text-xs text-blue-600 dark:text-blue-400 border border-blue-500/30 rounded px-1">
|
||||||
|
{t("default")}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={draft}
|
||||||
|
placeholder={t("secondaryPoolDescPlaceholder")}
|
||||||
|
onChange={(e) => setDraft(e.target.value)}
|
||||||
|
onBlur={commit}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
e.preventDefault();
|
||||||
|
(e.currentTarget as HTMLInputElement).blur();
|
||||||
|
} else if (e.key === "Escape") {
|
||||||
|
setDraft(description);
|
||||||
|
(e.currentTarget as HTMLInputElement).blur();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="flex-1 min-w-0 bg-input border border-border rounded px-2 py-1 text-xs focus:ring-2 focus:ring-blue-500 focus:outline-none"
|
||||||
|
/>
|
||||||
|
{canRemove && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => onRemove(alias)}
|
||||||
|
className="shrink-0 px-2 py-1 text-xs border border-border rounded hover:bg-hover-2 text-content-muted focus:ring-2 focus:ring-blue-500 focus:outline-none"
|
||||||
|
>
|
||||||
|
{t("secondaryPoolRemove")}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function SubagentSettingsPage({
|
export function SubagentSettingsPage({
|
||||||
rawOther,
|
rawOther,
|
||||||
models,
|
models,
|
||||||
@@ -52,6 +150,10 @@ export function SubagentSettingsPage({
|
|||||||
}: SubagentSettingsPageProps) {
|
}: SubagentSettingsPageProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [env, setEnv] = useState<ExperimentalEnvStatus | null>(null);
|
const [env, setEnv] = useState<ExperimentalEnvStatus | null>(null);
|
||||||
|
/** Pre-write validation failures (fallback guard; normal flows stay clear). */
|
||||||
|
const [poolErrors, setPoolErrors] = useState<PoolValidationError[]>([]);
|
||||||
|
/** Local draft for the "add pool entry" select (reset after each pick). */
|
||||||
|
const [addSelection, setAddSelection] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
invoke<ExperimentalEnvStatus>("get_experimental_env_status")
|
invoke<ExperimentalEnvStatus>("get_experimental_env_status")
|
||||||
@@ -60,7 +162,17 @@ export function SubagentSettingsPage({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const flags = getExperimentalFlags(rawOther);
|
const flags = getExperimentalFlags(rawOther);
|
||||||
const secondary = getSecondaryModel(rawOther);
|
const pool = getSubagentModelPool(rawOther);
|
||||||
|
const poolKeys = pool ? Object.keys(pool.models) : [];
|
||||||
|
// View selection: no/empty section or a bare legacy `model` → simple view;
|
||||||
|
// a `models` table or `default_model` → pool management view.
|
||||||
|
const isPoolView =
|
||||||
|
!!pool && (poolKeys.length > 0 || pool.defaultModel !== undefined);
|
||||||
|
// Effective default: v2 pool key first, legacy v1 recipe key as fallback.
|
||||||
|
const effectiveDefault = pool ? pool.defaultModel ?? pool.model : undefined;
|
||||||
|
// "Upgrade" only makes sense for the bare legacy form and when `force` is
|
||||||
|
// off — upgrading with force would create an invalid force+pool-table combo.
|
||||||
|
const canUpgrade = !!pool && !isPoolView && pool.model !== undefined && !pool.force;
|
||||||
const masterOn = isMasterEnvOn(env);
|
const masterOn = isMasterEnvOn(env);
|
||||||
const secondaryFlag = EXPERIMENTAL_FLAGS[0]; // "secondary-model"
|
const secondaryFlag = EXPERIMENTAL_FLAGS[0]; // "secondary-model"
|
||||||
const otherFlags = EXPERIMENTAL_FLAGS.slice(1);
|
const otherFlags = EXPERIMENTAL_FLAGS.slice(1);
|
||||||
@@ -75,10 +187,25 @@ export function SubagentSettingsPage({
|
|||||||
|
|
||||||
const aliasList = Object.keys(models).sort();
|
const aliasList = Object.keys(models).sort();
|
||||||
|
|
||||||
|
const aliasLabel = (alias: string): string =>
|
||||||
|
models[alias]?.display_name
|
||||||
|
? `${alias}(${models[alias].display_name})`
|
||||||
|
: alias;
|
||||||
|
|
||||||
|
// Rows of the pool view: every `models` table key plus the effective default
|
||||||
|
// when it is not already in the table (the implicit single-entry form).
|
||||||
|
const implicitDefault =
|
||||||
|
pool && effectiveDefault && !(effectiveDefault in pool.models)
|
||||||
|
? [effectiveDefault]
|
||||||
|
: [];
|
||||||
|
const poolEntries = [...poolKeys, ...implicitDefault];
|
||||||
|
// Aliases that can still be added to the pool (not already in the table).
|
||||||
|
const addableAliases = aliasList.filter((a) => !(a in (pool?.models ?? {})));
|
||||||
|
|
||||||
// Inherited settings shown for the picked model: subagents bind the pointed
|
// Inherited settings shown for the picked model: subagents bind the pointed
|
||||||
// entry directly (no patch fields), so context size and effort come from the
|
// entry directly (no patch fields), so context size and effort come from the
|
||||||
// model entry / global [thinking], not from a `[secondary_model]` patch.
|
// model entry / global [thinking], not from a `[secondary_model]` patch.
|
||||||
const selectedEntry = secondary.model ? models[secondary.model] : undefined;
|
const selectedEntry = effectiveDefault ? models[effectiveDefault] : undefined;
|
||||||
const inheritedContext = selectedEntry?.max_context_size;
|
const inheritedContext = selectedEntry?.max_context_size;
|
||||||
const modelEffort =
|
const modelEffort =
|
||||||
selectedEntry &&
|
selectedEntry &&
|
||||||
@@ -106,6 +233,61 @@ export function SubagentSettingsPage({
|
|||||||
return key ? t(key) : e;
|
return key ? t(key) : e;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fallback guard before any pool-related write: validate the *target* state
|
||||||
|
* against the engine rules (mirrored by `validateSubagentPool`) and block the
|
||||||
|
* write when it would produce an invalid config. Normal UI flows never trip
|
||||||
|
* this — it protects against stale/divergent configs.
|
||||||
|
*/
|
||||||
|
const validateWrite = (nextRaw: unknown): boolean => {
|
||||||
|
const nextPool = getSubagentModelPool(nextRaw);
|
||||||
|
const errors = nextPool ? validateSubagentPool(nextPool, aliasList) : [];
|
||||||
|
setPoolErrors(errors);
|
||||||
|
return errors.length === 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUpgrade = () => {
|
||||||
|
if (!effectiveDefault) return;
|
||||||
|
const nextRaw = setSubagentDefault(rawOther, effectiveDefault);
|
||||||
|
if (validateWrite(nextRaw)) onChange(nextRaw);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSetDefault = (alias: string) => {
|
||||||
|
if (alias === effectiveDefault) return;
|
||||||
|
const nextRaw = setSubagentDefault(rawOther, alias);
|
||||||
|
if (validateWrite(nextRaw)) onChange(nextRaw);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSaveDescription = (alias: string, description: string) => {
|
||||||
|
const nextRaw = upsertSubagentPoolEntry(rawOther, alias, description);
|
||||||
|
if (validateWrite(nextRaw)) onChange(nextRaw);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRemoveEntry = (alias: string) => {
|
||||||
|
const nextRaw = removeSubagentPoolEntry(rawOther, alias);
|
||||||
|
if (validateWrite(nextRaw)) onChange(nextRaw);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAddEntry = (alias: string) => {
|
||||||
|
const nextRaw = upsertSubagentPoolEntry(rawOther, alias, "");
|
||||||
|
if (validateWrite(nextRaw)) onChange(nextRaw);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleForceChange = (next: boolean) => {
|
||||||
|
if (!pool) return;
|
||||||
|
// Turning force on drops the `models` table — confirm when it is non-empty.
|
||||||
|
if (next && Object.keys(pool.models).length > 0) {
|
||||||
|
if (!confirm(t("secondaryPoolForceConfirm"))) return;
|
||||||
|
}
|
||||||
|
const nextRaw = setSubagentForce(rawOther, next);
|
||||||
|
if (validateWrite(nextRaw)) onChange(nextRaw);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClear = () => {
|
||||||
|
setPoolErrors([]);
|
||||||
|
onChange(clearSecondaryModel(rawOther));
|
||||||
|
};
|
||||||
|
|
||||||
const renderFlagRow = (flag: ExperimentalFlagDef) => {
|
const renderFlagRow = (flag: ExperimentalFlagDef) => {
|
||||||
const labels = FLAG_LABELS[flag.id];
|
const labels = FLAG_LABELS[flag.id];
|
||||||
const locked = masterOn || isFlagLockedByEnv(env, flag);
|
const locked = masterOn || isFlagLockedByEnv(env, flag);
|
||||||
@@ -194,36 +376,154 @@ export function SubagentSettingsPage({
|
|||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{/* Subagent: secondary model picker + inherited settings */}
|
{/* Subagent: secondary model picker / pool + inherited settings */}
|
||||||
<Card title={t("secondaryModelSection")}>
|
<Card title={t("secondaryModelSection")}>
|
||||||
<label className="flex items-center gap-3 text-sm text-content-primary">
|
{isPoolView && pool ? (
|
||||||
<span className="text-content-muted">{t("secondaryModelLabel")}</span>
|
<>
|
||||||
<select
|
{pool.force ? (
|
||||||
className="flex-1 max-w-md bg-input border border-border rounded px-2 py-1 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none"
|
/* Force on: the `models` table was dropped — only the pinned
|
||||||
value={secondary.model ?? ""}
|
default is shown, entries and "add" are hidden. */
|
||||||
onChange={(e) => {
|
<div className="rounded-lg border border-border bg-input/40 px-3 py-2.5">
|
||||||
const alias = e.target.value;
|
<div className="text-sm font-medium text-content-primary">
|
||||||
if (alias === "") {
|
🔒{" "}
|
||||||
onChange(clearSecondaryModel(rawOther));
|
{t("secondaryPoolForceOn", {
|
||||||
} else {
|
alias: aliasLabel(effectiveDefault ?? ""),
|
||||||
// Only the model reference is persisted — no patch fields.
|
})}
|
||||||
// Subagents bind the pointed entry directly and inherit its
|
</div>
|
||||||
// settings; usage records stay keyed on the real alias
|
</div>
|
||||||
// instead of Kimi Code's synthesized `__secondary__` entry.
|
) : (
|
||||||
onChange(setSecondaryModelOnly(rawOther, alias));
|
<>
|
||||||
}
|
<div className="space-y-2">
|
||||||
}}
|
{poolEntries.map((alias) => (
|
||||||
|
<PoolEntryRow
|
||||||
|
key={alias}
|
||||||
|
alias={alias}
|
||||||
|
displayName={models[alias]?.display_name ?? null}
|
||||||
|
description={pool.models[alias] ?? ""}
|
||||||
|
isDefault={alias === effectiveDefault}
|
||||||
|
canRemove={alias in pool.models}
|
||||||
|
onSetDefault={handleSetDefault}
|
||||||
|
onSave={handleSaveDescription}
|
||||||
|
onRemove={handleRemoveEntry}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<p className="text-xs text-content-muted">
|
||||||
|
{t("secondaryPoolDescHint")}
|
||||||
|
</p>
|
||||||
|
<label className="flex items-center gap-3 text-sm text-content-primary">
|
||||||
|
<span className="shrink-0 text-content-muted">
|
||||||
|
{t("secondaryPoolAddLabel")}
|
||||||
|
</span>
|
||||||
|
<select
|
||||||
|
className="flex-1 max-w-md bg-input border border-border rounded px-2 py-1 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none"
|
||||||
|
value={addSelection}
|
||||||
|
onChange={(e) => {
|
||||||
|
const alias = e.target.value;
|
||||||
|
setAddSelection("");
|
||||||
|
if (alias) handleAddEntry(alias);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option value="">{t("secondaryPoolAddPlaceholder")}</option>
|
||||||
|
{addableAliases.map((alias) => (
|
||||||
|
<option key={alias} value={alias}>
|
||||||
|
{aliasLabel(alias)}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
<div className="text-sm text-content-primary">
|
||||||
|
{t("secondaryPoolForce")}
|
||||||
|
</div>
|
||||||
|
<div className="text-xs text-content-muted">
|
||||||
|
{t("secondaryPoolForceDesc")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Toggle
|
||||||
|
checked={pool.force}
|
||||||
|
ariaLabel={t("secondaryPoolForce")}
|
||||||
|
onChange={handleForceChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleClear}
|
||||||
|
className="px-3 py-1.5 text-sm border border-border rounded hover:bg-hover-2 focus:ring-2 focus:ring-blue-500 focus:outline-none"
|
||||||
|
>
|
||||||
|
{t("secondaryModelClear")}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<label className="flex items-center gap-3 text-sm text-content-primary">
|
||||||
|
<span className="shrink-0 text-content-muted">
|
||||||
|
{t("secondaryModelLabel")}
|
||||||
|
</span>
|
||||||
|
<select
|
||||||
|
className="flex-1 max-w-md bg-input border border-border rounded px-2 py-1 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none"
|
||||||
|
value={effectiveDefault ?? ""}
|
||||||
|
onChange={(e) => {
|
||||||
|
const alias = e.target.value;
|
||||||
|
if (alias === "") {
|
||||||
|
setPoolErrors([]);
|
||||||
|
onChange(clearSecondaryModel(rawOther));
|
||||||
|
} else {
|
||||||
|
// Only the model reference is persisted — no patch fields.
|
||||||
|
// Subagents bind the pointed entry directly and inherit
|
||||||
|
// its settings; usage records stay keyed on the real
|
||||||
|
// alias instead of the synthesized `__secondary__` entry.
|
||||||
|
const nextRaw = setSecondaryModelOnly(rawOther, alias);
|
||||||
|
if (validateWrite(nextRaw)) onChange(nextRaw);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option value="">{t("secondaryModelUnset")}</option>
|
||||||
|
{aliasList.map((alias) => (
|
||||||
|
<option key={alias} value={alias}>
|
||||||
|
{aliasLabel(alias)}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
{pool?.force && (
|
||||||
|
<span className="shrink-0 text-xs text-content-muted">
|
||||||
|
🔒 {t("secondaryModelForceBadge")}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</label>
|
||||||
|
|
||||||
|
{canUpgrade && (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleUpgrade}
|
||||||
|
className="px-3 py-1.5 text-sm border border-border rounded hover:bg-hover-2 focus:ring-2 focus:ring-blue-500 focus:outline-none"
|
||||||
|
>
|
||||||
|
{t("secondaryPoolUpgrade")}
|
||||||
|
</button>
|
||||||
|
<span className="text-xs text-content-muted">
|
||||||
|
{t("secondaryPoolUpgradeDesc")}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{poolErrors.length > 0 && (
|
||||||
|
<div
|
||||||
|
role="alert"
|
||||||
|
className="bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-500/30 rounded-lg px-3 py-2 text-sm text-red-700 dark:text-red-400 space-y-1"
|
||||||
>
|
>
|
||||||
<option value="">{t("secondaryModelUnset")}</option>
|
{poolErrors.map((err, i) => (
|
||||||
{aliasList.map((alias) => (
|
<div key={i}>{t(POOL_ERROR_KEYS[err.key], err.params)}</div>
|
||||||
<option key={alias} value={alias}>
|
|
||||||
{models[alias]?.display_name
|
|
||||||
? `${alias}(${models[alias].display_name})`
|
|
||||||
: alias}
|
|
||||||
</option>
|
|
||||||
))}
|
))}
|
||||||
</select>
|
</div>
|
||||||
</label>
|
)}
|
||||||
|
|
||||||
<div className="border-t border-border" />
|
<div className="border-t border-border" />
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
@@ -248,7 +548,7 @@ export function SubagentSettingsPage({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{secondary.model !== undefined && (
|
{effectiveDefault !== undefined && (
|
||||||
<div className="rounded-lg border border-border bg-input/40 px-3 py-2.5 space-y-2">
|
<div className="rounded-lg border border-border bg-input/40 px-3 py-2.5 space-y-2">
|
||||||
<div className="flex items-baseline gap-2 text-sm">
|
<div className="flex items-baseline gap-2 text-sm">
|
||||||
<span className="shrink-0 text-content-muted">
|
<span className="shrink-0 text-content-muted">
|
||||||
|
|||||||
@@ -97,7 +97,12 @@ export function DailyBars({ daily, dimension, names, unknownProviderLabel }: Dai
|
|||||||
const h = Math.max(4, Math.round(((d.totalTokens || 0) / max) * 170));
|
const h = Math.max(4, Math.round(((d.totalTokens || 0) / max) * 170));
|
||||||
const total = d.totalTokens || 1;
|
const total = d.totalTokens || 1;
|
||||||
|
|
||||||
const breakdown = dimension === "provider" ? d.byProvider : d.byModel;
|
const breakdown =
|
||||||
|
dimension === "provider"
|
||||||
|
? d.byProvider
|
||||||
|
: Object.fromEntries(
|
||||||
|
Object.entries(d.byModel || {}).map(([k, v]) => [k, v.totalTokens])
|
||||||
|
);
|
||||||
const segments = Object.entries(breakdown || {})
|
const segments = Object.entries(breakdown || {})
|
||||||
.map(([key, tokens]) => ({
|
.map(([key, tokens]) => ({
|
||||||
key,
|
key,
|
||||||
|
|||||||
@@ -48,12 +48,15 @@ export function DailyDetailModal({ day, dimension, colorMap, unknownProviderLabe
|
|||||||
const total = day.totalTokens || 1;
|
const total = day.totalTokens || 1;
|
||||||
const isProvider = dimension === "provider";
|
const isProvider = dimension === "provider";
|
||||||
|
|
||||||
// Flat per-model breakdown (model tab)
|
// Flat per-model breakdown (model tab) — structured TotalsRow per model
|
||||||
const modelSegments = Object.entries(day.byModel || {})
|
const modelSegments = Object.entries(day.byModel || {})
|
||||||
.map(([model, tokens]) => ({
|
.map(([model, row]) => ({
|
||||||
model,
|
model,
|
||||||
tokens,
|
tokens: row.totalTokens,
|
||||||
pct: (tokens / total) * 100,
|
requests: row.requests,
|
||||||
|
costUsd: row.costUsd,
|
||||||
|
cacheHitRate: row.cacheHitRate,
|
||||||
|
pct: ((row.totalTokens || 0) / total) * 100,
|
||||||
}))
|
}))
|
||||||
.sort((a, b) => b.tokens - a.tokens);
|
.sort((a, b) => b.tokens - a.tokens);
|
||||||
|
|
||||||
@@ -165,20 +168,22 @@ export function DailyDetailModal({ day, dimension, colorMap, unknownProviderLabe
|
|||||||
{modelSegments.length === 0 ? (
|
{modelSegments.length === 0 ? (
|
||||||
<div className="py-6 text-center text-sm text-content-muted">{t("noData")}</div>
|
<div className="py-6 text-center text-sm text-content-muted">{t("noData")}</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-1.5 max-h-72 overflow-y-auto pr-1">
|
<div className="space-y-2 max-h-72 overflow-y-auto pr-1">
|
||||||
{modelSegments.map((s, i) => (
|
{modelSegments.map((s, i) => (
|
||||||
<div key={s.model} className="flex items-center gap-3 text-sm">
|
<div key={s.model} className="rounded-lg bg-hover/50 px-3 py-2">
|
||||||
<span className="inline-block h-2.5 w-2.5 rounded-sm shrink-0" style={{ backgroundColor: modelColor(i) }} />
|
<div className="flex items-center gap-2 text-sm">
|
||||||
<div className="min-w-0 flex-1">
|
<span className="inline-block h-2.5 w-2.5 rounded-sm shrink-0" style={{ backgroundColor: modelColor(i) }} />
|
||||||
<div className="flex items-baseline justify-between gap-2">
|
<span className="truncate flex-1 text-content-primary" title={s.model}>{modelName(s.model)}</span>
|
||||||
<span className="truncate text-content-primary" title={s.model}>{modelName(s.model)}</span>
|
<span className="shrink-0 text-xs text-content-muted tabular-nums">{s.pct.toFixed(1)}%</span>
|
||||||
<span className="shrink-0 text-xs text-content-muted tabular-nums">
|
</div>
|
||||||
{fmtTokens(s.tokens)} <span className="text-content-muted">· {s.pct.toFixed(1)}%</span>
|
<div className="mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-border">
|
||||||
</span>
|
<div className="h-full rounded-full transition-all" style={{ width: `${Math.max(2, s.pct)}%`, backgroundColor: modelColor(i) }} />
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-1 h-1.5 w-full overflow-hidden rounded-full bg-border">
|
<div className="mt-1.5 flex flex-wrap gap-x-4 gap-y-0.5 text-xs text-content-muted tabular-nums">
|
||||||
<div className="h-full rounded-full transition-all" style={{ width: `${Math.max(2, s.pct)}%`, backgroundColor: modelColor(i) }} />
|
<span>{t("totalTokens")}: <span className="text-content-primary font-medium">{fmtTokens(s.tokens)}</span></span>
|
||||||
</div>
|
<span>{t("requests")}: <span className="text-content-primary font-medium">{s.requests.toLocaleString()}</span></span>
|
||||||
|
{s.costUsd > 0 && <span>{t("cost")}: <span className="text-content-primary font-medium">{money(s.costUsd)}</span></span>}
|
||||||
|
<span>{t("cacheHitRate")}: <span className="text-content-primary font-medium">{fmtPct(s.cacheHitRate)}</span></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
import { useState, type ReactNode } from "react";
|
import { useState, type ReactNode } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { useDashboard, type DashboardRange } from "../../hooks/useDashboard";
|
import { useDashboard, type DashboardRange } from "../../hooks/useDashboard";
|
||||||
import { useCurrency } from "../../hooks/useCurrency";
|
import { useCurrency } from "../../hooks/useCurrency";
|
||||||
import { useTranslation } from "../../i18n";
|
import { useTranslation } from "../../i18n";
|
||||||
import { fmtInt, fmtPct, fmtTime, fmtTokens } from "../../lib/dashboard-format";
|
import { fmtInt, fmtPct, fmtTime, fmtTokens } from "../../lib/dashboard-format";
|
||||||
import { DailyBars } from "./DailyBars";
|
import { DailyBars } from "./DailyBars";
|
||||||
|
import { DailyDetailModal } from "./DailyDetailModal";
|
||||||
import { Heatmap } from "./Heatmap";
|
import { Heatmap } from "./Heatmap";
|
||||||
import { TrendLineChart } from "./TrendLineChart";
|
import { TrendLineChart } from "./TrendLineChart";
|
||||||
|
import type { DailyRow, HeatmapCell } from "../../types/dashboard";
|
||||||
|
|
||||||
const RANGES: DashboardRange[] = ["today", "7d", "30d", "all"];
|
const RANGES: DashboardRange[] = ["today", "7d", "30d", "all"];
|
||||||
|
|
||||||
@@ -56,6 +60,9 @@ export function DashboardPage() {
|
|||||||
const [showAllModels, setShowAllModels] = useState(false);
|
const [showAllModels, setShowAllModels] = useState(false);
|
||||||
const [recentPage, setRecentPage] = useState(1);
|
const [recentPage, setRecentPage] = useState(1);
|
||||||
const [trendTab, setTrendTab] = useState<"daily" | "model" | "provider">("daily");
|
const [trendTab, setTrendTab] = useState<"daily" | "model" | "provider">("daily");
|
||||||
|
const [heatmapSelected, setHeatmapSelected] = useState<DailyRow | null>(null);
|
||||||
|
|
||||||
|
const daily = data?.stats.daily ?? [];
|
||||||
|
|
||||||
const RANGE_LABELS: Record<DashboardRange, string> = {
|
const RANGE_LABELS: Record<DashboardRange, string> = {
|
||||||
today: t("rangeToday"),
|
today: t("rangeToday"),
|
||||||
@@ -92,13 +99,29 @@ export function DashboardPage() {
|
|||||||
if (!data) return null;
|
if (!data) return null;
|
||||||
|
|
||||||
const totals = data.stats.totals;
|
const totals = data.stats.totals;
|
||||||
const daily = data.stats.daily;
|
|
||||||
const models = data.stats.models;
|
const models = data.stats.models;
|
||||||
const recent = data.stats.recent;
|
const recent = data.stats.recent;
|
||||||
const heatmap = data.heatmap;
|
const heatmap = data.heatmap;
|
||||||
const rangeTotals = data.rangeTotals;
|
const rangeTotals = data.rangeTotals;
|
||||||
const visibleModels = showAllModels ? models : models.slice(0, 8);
|
const visibleModels = showAllModels ? models : models.slice(0, 8);
|
||||||
|
|
||||||
|
const onHeatmapCellDoubleClick = async (cell: HeatmapCell) => {
|
||||||
|
try {
|
||||||
|
const row = await invoke<DailyRow | null>("get_day_detail", {
|
||||||
|
date: cell.date,
|
||||||
|
});
|
||||||
|
if (row) {
|
||||||
|
setHeatmapSelected(row);
|
||||||
|
} else {
|
||||||
|
setHeatmapSelected(null);
|
||||||
|
alert(t("dayDetailNoData", { date: cell.date }));
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
setHeatmapSelected(null);
|
||||||
|
alert(err instanceof Error ? err.message : String(err));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Recent pagination
|
// Recent pagination
|
||||||
const RECENT_PAGE_SIZE = 30;
|
const RECENT_PAGE_SIZE = 30;
|
||||||
const recentTotal = data.stats.recentTotal;
|
const recentTotal = data.stats.recentTotal;
|
||||||
@@ -206,7 +229,7 @@ export function DashboardPage() {
|
|||||||
|
|
||||||
{/* Heatmap — full row */}
|
{/* Heatmap — full row */}
|
||||||
<Card title={t("cardHeatmap")} subtitle={t("cardHeatmapSub")}>
|
<Card title={t("cardHeatmap")} subtitle={t("cardHeatmapSub")}>
|
||||||
<Heatmap heatmap={heatmap} />
|
<Heatmap heatmap={heatmap} onCellDoubleClick={onHeatmapCellDoubleClick} />
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
{/* Usage-trend tabs + Model table side by side */}
|
{/* Usage-trend tabs + Model table side by side */}
|
||||||
@@ -451,6 +474,19 @@ export function DashboardPage() {
|
|||||||
{data.meta.home}
|
{data.meta.home}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Heatmap double-click detail modal */}
|
||||||
|
{heatmapSelected &&
|
||||||
|
createPortal(
|
||||||
|
<DailyDetailModal
|
||||||
|
day={heatmapSelected}
|
||||||
|
dimension="model"
|
||||||
|
colorMap={{}}
|
||||||
|
unknownProviderLabel={t("providerUnknown")}
|
||||||
|
onClose={() => setHeatmapSelected(null)}
|
||||||
|
/>,
|
||||||
|
document.body,
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,8 @@ import type { HeatmapCell, HeatmapData } from "../../types/dashboard";
|
|||||||
|
|
||||||
interface HeatmapProps {
|
interface HeatmapProps {
|
||||||
heatmap: HeatmapData;
|
heatmap: HeatmapData;
|
||||||
|
/** Called when a cell with data (level > 0) is double-clicked. */
|
||||||
|
onCellDoubleClick?: (cell: HeatmapCell) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LEVEL_BG = [
|
const LEVEL_BG = [
|
||||||
@@ -30,7 +32,7 @@ interface HoverState {
|
|||||||
y: number;
|
y: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Heatmap({ heatmap }: HeatmapProps) {
|
export function Heatmap({ heatmap, onCellDoubleClick }: HeatmapProps) {
|
||||||
const { t, lang } = useTranslation();
|
const { t, lang } = useTranslation();
|
||||||
const cells = heatmap?.cells || [];
|
const cells = heatmap?.cells || [];
|
||||||
const monthLabels = heatmap?.monthLabels || [];
|
const monthLabels = heatmap?.monthLabels || [];
|
||||||
@@ -172,6 +174,7 @@ export function Heatmap({ heatmap }: HeatmapProps) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const level = cell.level ?? 0;
|
const level = cell.level ?? 0;
|
||||||
|
const hasDetail = level > 0;
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={cell.date}
|
key={cell.date}
|
||||||
@@ -182,7 +185,8 @@ export function Heatmap({ heatmap }: HeatmapProps) {
|
|||||||
onMouseLeave={hideTooltip}
|
onMouseLeave={hideTooltip}
|
||||||
onFocus={() => showTooltipFromFocus(cell)}
|
onFocus={() => showTooltipFromFocus(cell)}
|
||||||
onBlur={hideTooltip}
|
onBlur={hideTooltip}
|
||||||
className={`rounded-[3px] ring-1 ring-inset ring-white/5 transition-transform hover:scale-[1.35] focus:scale-[1.35] outline-none ${LEVEL_BG[level] || LEVEL_BG[0]}`}
|
onDoubleClick={hasDetail && onCellDoubleClick ? () => onCellDoubleClick(cell) : undefined}
|
||||||
|
className={`rounded-[3px] ring-1 ring-inset ring-white/5 transition-transform outline-none ${LEVEL_BG[level] || LEVEL_BG[0]} ${hasDetail && onCellDoubleClick ? "cursor-pointer hover:scale-[1.35] focus:scale-[1.35]" : "cursor-default"}`}
|
||||||
style={{ width: CELL, height: CELL }}
|
style={{ width: CELL, height: CELL }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
+30
-1
@@ -227,6 +227,7 @@ export const enTranslations: Record<TranslationKey, string> = {
|
|||||||
|
|
||||||
// Daily detail modal
|
// Daily detail modal
|
||||||
dayDetail: "Daily usage detail",
|
dayDetail: "Daily usage detail",
|
||||||
|
dayDetailNoData: "No usage data for {date}",
|
||||||
close: "Close",
|
close: "Close",
|
||||||
totalTokens: "Total tokens",
|
totalTokens: "Total tokens",
|
||||||
cost: "Cost",
|
cost: "Cost",
|
||||||
@@ -477,7 +478,35 @@ export const enTranslations: Record<TranslationKey, string> = {
|
|||||||
secondaryModelHint:
|
secondaryModelHint:
|
||||||
"Second model config bound to subagents by default; when unset, subagents inherit the primary model. Only the model reference is stored; subagents inherit all of that model's settings",
|
"Second model config bound to subagents by default; when unset, subagents inherit the primary model. Only the model reference is stored; subagents inherit all of that model's settings",
|
||||||
secondaryModelPriorityHint:
|
secondaryModelPriorityHint:
|
||||||
"Priority: explicit tool model param > profile model_preference > this config > inherit primary model",
|
"Priority (v2): tool model param (pool alias or primary) > default_model > inherit primary; (v1 legacy): tool param > model_preference > model > inherit primary",
|
||||||
|
|
||||||
|
// Subagent model pool (secondary_model v2 keys)
|
||||||
|
secondaryPoolUpgrade: "Upgrade to model pool",
|
||||||
|
secondaryPoolUpgradeDesc:
|
||||||
|
"Writes default_model in sync with model (dual-write for both engines); more pool entries can be added afterwards",
|
||||||
|
secondaryPoolAddLabel: "Add pool entry",
|
||||||
|
secondaryPoolAddPlaceholder: "Select a model to add to the pool…",
|
||||||
|
secondaryPoolRemove: "Remove",
|
||||||
|
secondaryPoolDescPlaceholder: "Subagent routing description for this model…",
|
||||||
|
secondaryPoolDescHint:
|
||||||
|
"The description is rendered into the main agent's tool description (Agent/AgentSwarm) and directly affects how well the main model routes to subagent models",
|
||||||
|
secondaryPoolForce: "Force default model",
|
||||||
|
secondaryPoolForceDesc:
|
||||||
|
"When enabled, all subagents are forced onto the default model; force excludes pool entries, which are removed",
|
||||||
|
secondaryPoolForceOn: "Force is on: subagents always use \"{alias}\"",
|
||||||
|
secondaryPoolForceConfirm:
|
||||||
|
"Enabling force removes every pool entry, keeping only the default model. Continue?",
|
||||||
|
secondaryModelClear: "Clear subagent config",
|
||||||
|
secondaryModelForceBadge: "Force on: subagents always use this model",
|
||||||
|
secondaryPoolErrorPrimaryReserved:
|
||||||
|
"\"{alias}\" is a reserved alias and cannot be a pool entry",
|
||||||
|
secondaryPoolErrorDefaultRequired: "default_model is required when pool entries exist",
|
||||||
|
secondaryPoolErrorDefaultNotInPool: "Default model \"{alias}\" is not in the pool",
|
||||||
|
secondaryPoolErrorAliasNotInModels: "Model \"{alias}\" is not registered in [models]",
|
||||||
|
secondaryPoolErrorForceRequiresDefault:
|
||||||
|
"A default model is required before enabling force",
|
||||||
|
secondaryPoolErrorForceExcludesModels:
|
||||||
|
"force is mutually exclusive with pool entries",
|
||||||
|
|
||||||
// Kimi Code WebUI quick open
|
// Kimi Code WebUI quick open
|
||||||
webuiSection: "Kimi Code WebUI",
|
webuiSection: "Kimi Code WebUI",
|
||||||
|
|||||||
+27
-1
@@ -222,6 +222,7 @@ export const zhTranslations = {
|
|||||||
|
|
||||||
// Daily detail modal
|
// Daily detail modal
|
||||||
dayDetail: "每日用量详情",
|
dayDetail: "每日用量详情",
|
||||||
|
dayDetailNoData: "「{date}」当日无用量数据",
|
||||||
close: "关闭",
|
close: "关闭",
|
||||||
totalTokens: "总 Token",
|
totalTokens: "总 Token",
|
||||||
cost: "费用",
|
cost: "费用",
|
||||||
@@ -472,7 +473,32 @@ export const zhTranslations = {
|
|||||||
secondaryModelHint:
|
secondaryModelHint:
|
||||||
"子代理默认绑定的第二份模型配置;未配置时子代理继承主模型;仅保存模型引用,子代理继承该模型的全部设置",
|
"子代理默认绑定的第二份模型配置;未配置时子代理继承主模型;仅保存模型引用,子代理继承该模型的全部设置",
|
||||||
secondaryModelPriorityHint:
|
secondaryModelPriorityHint:
|
||||||
"优先级:工具显式 model 参数 > 子代理 profile 的 model_preference > 本配置 > 继承主模型",
|
"优先级(v2):工具 model 参数(池别名或 primary)> default_model > 继承主模型;(v1 legacy):工具参数 > model_preference > model > 继承主模型",
|
||||||
|
|
||||||
|
// Subagent model pool (secondary_model v2 keys)
|
||||||
|
secondaryPoolUpgrade: "升级为模型池",
|
||||||
|
secondaryPoolUpgradeDesc:
|
||||||
|
"为旧式配置补写 default_model,与 model 双写一致;之后可继续添加多个池条目",
|
||||||
|
secondaryPoolAddLabel: "添加池条目",
|
||||||
|
secondaryPoolAddPlaceholder: "选择要加入模型池的模型…",
|
||||||
|
secondaryPoolRemove: "移除",
|
||||||
|
secondaryPoolDescPlaceholder: "该模型的子代理路由描述…",
|
||||||
|
secondaryPoolDescHint:
|
||||||
|
"描述会渲染进主 Agent 的工具描述(Agent/AgentSwarm),直接影响主模型挑选子代理模型的路由质量",
|
||||||
|
secondaryPoolForce: "强制使用默认模型",
|
||||||
|
secondaryPoolForceDesc:
|
||||||
|
"开启后所有子代理固定使用默认模型;force 与模型池条目互斥,条目将被移除",
|
||||||
|
secondaryPoolForceOn: "force 已开启:子代理固定使用「{alias}」",
|
||||||
|
secondaryPoolForceConfirm:
|
||||||
|
"开启 force 将移除模型池中的所有条目,只保留默认模型。确定继续?",
|
||||||
|
secondaryModelClear: "不再配置",
|
||||||
|
secondaryModelForceBadge: "force 已开启:子代理固定使用该模型",
|
||||||
|
secondaryPoolErrorPrimaryReserved: "「{alias}」是保留别名,不能用作模型池条目",
|
||||||
|
secondaryPoolErrorDefaultRequired: "存在模型池条目时 default_model 必填",
|
||||||
|
secondaryPoolErrorDefaultNotInPool: "默认模型「{alias}」不在模型池中",
|
||||||
|
secondaryPoolErrorAliasNotInModels: "模型「{alias}」未在 [models] 中注册",
|
||||||
|
secondaryPoolErrorForceRequiresDefault: "开启 force 前必须设置默认模型",
|
||||||
|
secondaryPoolErrorForceExcludesModels: "force 与模型池条目互斥",
|
||||||
|
|
||||||
// Kimi Code WebUI quick open
|
// Kimi Code WebUI quick open
|
||||||
webuiSection: "Kimi Code WebUI",
|
webuiSection: "Kimi Code WebUI",
|
||||||
|
|||||||
+83976
-78508
File diff suppressed because it is too large.
Load diff
+69317
-64626
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,426 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import {
|
||||||
|
getSecondaryModel,
|
||||||
|
getSubagentModelPool,
|
||||||
|
removeSubagentPoolEntry,
|
||||||
|
setSecondaryModelOnly,
|
||||||
|
setSubagentDefault,
|
||||||
|
setSubagentForce,
|
||||||
|
setSubagentModelPool,
|
||||||
|
upsertSubagentPoolEntry,
|
||||||
|
validateSubagentPool,
|
||||||
|
type SubagentModelPool,
|
||||||
|
} from "./subagent-settings";
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Helpers — drill into the `[secondary_model]` section of the written result
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function rawWith(section: Record<string, unknown>): unknown {
|
||||||
|
return { secondary_model: section };
|
||||||
|
}
|
||||||
|
|
||||||
|
function section(raw: unknown): Record<string, unknown> {
|
||||||
|
const root = raw as { secondary_model?: unknown };
|
||||||
|
const sec = root?.secondary_model;
|
||||||
|
return sec && typeof sec === "object" && !Array.isArray(sec)
|
||||||
|
? (sec as Record<string, unknown>)
|
||||||
|
: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
function modelsOf(raw: unknown): Record<string, unknown> {
|
||||||
|
const m = section(raw)["models"];
|
||||||
|
return m && typeof m === "object" && !Array.isArray(m)
|
||||||
|
? (m as Record<string, unknown>)
|
||||||
|
: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Reading — four config combinations + effective-default normalization
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
describe("getSecondaryModel / getSubagentModelPool", () => {
|
||||||
|
it("returns an empty config / undefined pool when the section is absent or empty", () => {
|
||||||
|
expect(getSecondaryModel({})).toEqual({});
|
||||||
|
expect(getSubagentModelPool({})).toBeUndefined();
|
||||||
|
expect(getSubagentModelPool(rawWith({}))).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("legacy `model` alone forms the effective default", () => {
|
||||||
|
const raw = rawWith({ model: "kimi-k2" });
|
||||||
|
expect(getSecondaryModel(raw)).toEqual({ model: "kimi-k2" });
|
||||||
|
const pool = getSubagentModelPool(raw);
|
||||||
|
expect(pool).toEqual({ model: "kimi-k2", models: {}, force: false });
|
||||||
|
expect(pool?.defaultModel ?? pool?.model).toBe("kimi-k2");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("`default_model` alone forms the effective default", () => {
|
||||||
|
const raw = rawWith({ default_model: "kimi-k2" });
|
||||||
|
expect(getSecondaryModel(raw)).toEqual({ default_model: "kimi-k2" });
|
||||||
|
const pool = getSubagentModelPool(raw);
|
||||||
|
expect(pool?.defaultModel).toBe("kimi-k2");
|
||||||
|
expect(pool?.model).toBeUndefined();
|
||||||
|
expect(pool?.defaultModel ?? pool?.model).toBe("kimi-k2");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("a divergent `model` + `default_model` resolves the effective default to `default_model`", () => {
|
||||||
|
const raw = rawWith({ model: "kimi-k2", default_model: "kimi-k1" });
|
||||||
|
expect(getSecondaryModel(raw)).toEqual({
|
||||||
|
model: "kimi-k2",
|
||||||
|
default_model: "kimi-k1",
|
||||||
|
});
|
||||||
|
const pool = getSubagentModelPool(raw);
|
||||||
|
expect(pool?.model).toBe("kimi-k2");
|
||||||
|
expect(pool?.defaultModel).toBe("kimi-k1");
|
||||||
|
expect(pool?.defaultModel ?? pool?.model).toBe("kimi-k1");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reads the models table filtering non-string values, and force", () => {
|
||||||
|
const raw = rawWith({
|
||||||
|
default_model: "kimi-k2",
|
||||||
|
models: { "kimi-k2": "Kimi K2", "kimi-k2-thinking": 42, broken: true },
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
|
expect(getSecondaryModel(raw).models).toEqual({ "kimi-k2": "Kimi K2" });
|
||||||
|
expect(getSecondaryModel(raw).force).toBe(true);
|
||||||
|
expect(getSubagentModelPool(raw)).toMatchObject({
|
||||||
|
models: { "kimi-k2": "Kimi K2" },
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reports `force` only when true and tolerates a malformed models table", () => {
|
||||||
|
expect(getSecondaryModel(rawWith({ force: false })).force).toBeUndefined();
|
||||||
|
expect(getSubagentModelPool(rawWith({ force: false }))?.force).toBe(false);
|
||||||
|
const pool = getSubagentModelPool(rawWith({ models: "nope", model: "kimi-k2" }));
|
||||||
|
expect(pool?.models).toEqual({});
|
||||||
|
expect(pool?.model).toBe("kimi-k2");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// setSecondaryModelOnly — pool-aware pick
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
describe("setSecondaryModelOnly", () => {
|
||||||
|
it("creates the section when absent", () => {
|
||||||
|
const next = setSecondaryModelOnly({}, "kimi-k2");
|
||||||
|
expect(section(next)).toEqual({ model: "kimi-k2" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("without a pool: writes only `model`, drops known patch fields, keeps unknown fields", () => {
|
||||||
|
const raw = rawWith({
|
||||||
|
model: "old",
|
||||||
|
default_effort: "high",
|
||||||
|
max_output_size: 64000,
|
||||||
|
max_context_size: 128000,
|
||||||
|
custom_field: "keep",
|
||||||
|
});
|
||||||
|
const next = setSecondaryModelOnly(raw, "kimi-k2");
|
||||||
|
expect(section(next)).toEqual({ model: "kimi-k2", custom_field: "keep" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("pool via default_model: syncs both keys, adds a missing alias to the table, preserves the rest", () => {
|
||||||
|
const raw = rawWith({
|
||||||
|
default_model: "kimi-k1",
|
||||||
|
models: { "kimi-k1": "K1" },
|
||||||
|
force: true,
|
||||||
|
unknown_field: "keep",
|
||||||
|
});
|
||||||
|
const next = setSecondaryModelOnly(raw, "kimi-k2");
|
||||||
|
expect(section(next)).toEqual({
|
||||||
|
default_model: "kimi-k2",
|
||||||
|
model: "kimi-k2",
|
||||||
|
models: { "kimi-k1": "K1", "kimi-k2": "" },
|
||||||
|
force: true,
|
||||||
|
unknown_field: "keep",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("pool via models table: keeps existing descriptions", () => {
|
||||||
|
const raw = rawWith({ models: { "kimi-k1": "K1", "kimi-k2": "K2" } });
|
||||||
|
const next = setSecondaryModelOnly(raw, "kimi-k2");
|
||||||
|
expect(modelsOf(next)).toEqual({ "kimi-k1": "K1", "kimi-k2": "K2" });
|
||||||
|
expect(section(next).default_model).toBe("kimi-k2");
|
||||||
|
expect(section(next).model).toBe("kimi-k2");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("heals a divergent legacy + pool default to the picked alias", () => {
|
||||||
|
const raw = rawWith({
|
||||||
|
model: "kimi-k1",
|
||||||
|
default_model: "kimi-k2",
|
||||||
|
models: { "kimi-k1": "K1", "kimi-k2": "K2" },
|
||||||
|
});
|
||||||
|
const next = setSecondaryModelOnly(raw, "kimi-k1");
|
||||||
|
expect(section(next).model).toBe("kimi-k1");
|
||||||
|
expect(section(next).default_model).toBe("kimi-k1");
|
||||||
|
expect(modelsOf(next)).toEqual({ "kimi-k1": "K1", "kimi-k2": "K2" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("preserves other top-level raw_other sections", () => {
|
||||||
|
const raw = {
|
||||||
|
experimental: { "secondary-model": true },
|
||||||
|
secondary_model: { model: "kimi-k1" },
|
||||||
|
};
|
||||||
|
const next = setSecondaryModelOnly(raw, "kimi-k2") as {
|
||||||
|
experimental?: unknown;
|
||||||
|
};
|
||||||
|
expect(next.experimental).toEqual({ "secondary-model": true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Pool mutations — rebuild / upsert / remove / default
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
describe("pool mutations", () => {
|
||||||
|
it("setSubagentModelPool rebuilds with dual-written default (effective wins) and force", () => {
|
||||||
|
const raw = rawWith({ model: "stale", custom: "keep" });
|
||||||
|
const next = setSubagentModelPool(raw, {
|
||||||
|
defaultModel: "kimi-k2",
|
||||||
|
model: "kimi-k1", // divergent — effective default (`defaultModel`) wins
|
||||||
|
models: { "kimi-k2": "K2" },
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
|
expect(section(next)).toEqual({
|
||||||
|
default_model: "kimi-k2",
|
||||||
|
model: "kimi-k2",
|
||||||
|
models: { "kimi-k2": "K2" },
|
||||||
|
force: true,
|
||||||
|
custom: "keep",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("setSubagentModelPool omits the models table when the pool has no entries", () => {
|
||||||
|
const next = setSubagentModelPool(rawWith({}), {
|
||||||
|
defaultModel: "kimi-k2",
|
||||||
|
models: {},
|
||||||
|
force: false,
|
||||||
|
});
|
||||||
|
expect(section(next)).toEqual({
|
||||||
|
default_model: "kimi-k2",
|
||||||
|
model: "kimi-k2",
|
||||||
|
force: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("setSubagentModelPool is idempotent", () => {
|
||||||
|
const pool: SubagentModelPool = {
|
||||||
|
defaultModel: "kimi-k2",
|
||||||
|
models: { "kimi-k2": "K2" },
|
||||||
|
force: true,
|
||||||
|
};
|
||||||
|
const once = setSubagentModelPool(rawWith({ custom: "keep" }), pool);
|
||||||
|
const twice = setSubagentModelPool(once, pool);
|
||||||
|
expect(once).toEqual(twice);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("upsertSubagentPoolEntry adds and updates aliases, preserving the rest", () => {
|
||||||
|
const raw = rawWith({
|
||||||
|
default_model: "kimi-k1",
|
||||||
|
models: { "kimi-k1": "K1" },
|
||||||
|
force: false,
|
||||||
|
});
|
||||||
|
const added = upsertSubagentPoolEntry(raw, "kimi-k2", "K2");
|
||||||
|
expect(modelsOf(added)).toEqual({ "kimi-k1": "K1", "kimi-k2": "K2" });
|
||||||
|
const updated = upsertSubagentPoolEntry(added, "kimi-k2", "K2 thinking");
|
||||||
|
expect(modelsOf(updated)).toEqual({
|
||||||
|
"kimi-k1": "K1",
|
||||||
|
"kimi-k2": "K2 thinking",
|
||||||
|
});
|
||||||
|
expect(section(updated).default_model).toBe("kimi-k1");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("removeSubagentPoolEntry keeps the default when removing a non-default alias", () => {
|
||||||
|
const raw = rawWith({
|
||||||
|
default_model: "kimi-k1",
|
||||||
|
model: "kimi-k1",
|
||||||
|
models: { "kimi-k1": "K1", "kimi-k2": "K2", "kimi-k3": "K3" },
|
||||||
|
});
|
||||||
|
const next = removeSubagentPoolEntry(raw, "kimi-k3");
|
||||||
|
expect(modelsOf(next)).toEqual({ "kimi-k1": "K1", "kimi-k2": "K2" });
|
||||||
|
expect(section(next).default_model).toBe("kimi-k1");
|
||||||
|
expect(section(next).model).toBe("kimi-k1");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("removeSubagentPoolEntry falls the default back to the first remaining key", () => {
|
||||||
|
const raw = rawWith({
|
||||||
|
default_model: "kimi-k1",
|
||||||
|
model: "kimi-k1",
|
||||||
|
models: { "kimi-k1": "K1", "kimi-k2": "K2" },
|
||||||
|
});
|
||||||
|
const next = removeSubagentPoolEntry(raw, "kimi-k1");
|
||||||
|
expect(modelsOf(next)).toEqual({ "kimi-k2": "K2" });
|
||||||
|
expect(section(next).default_model).toBe("kimi-k2");
|
||||||
|
expect(section(next).model).toBe("kimi-k2");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("removeSubagentPoolEntry collapses an emptied pool to the implicit form", () => {
|
||||||
|
const raw = rawWith({
|
||||||
|
default_model: "kimi-k1",
|
||||||
|
model: "kimi-k1",
|
||||||
|
models: { "kimi-k1": "K1" },
|
||||||
|
});
|
||||||
|
const next = removeSubagentPoolEntry(raw, "kimi-k1");
|
||||||
|
const sec = section(next);
|
||||||
|
expect(sec).not.toHaveProperty("models");
|
||||||
|
expect(sec.default_model).toBe("kimi-k1");
|
||||||
|
expect(sec.model).toBe("kimi-k1");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("setSubagentDefault syncs both keys and adds a missing alias with an empty description", () => {
|
||||||
|
const raw = rawWith({ models: { "kimi-k2": "K2" } });
|
||||||
|
const next = setSubagentDefault(raw, "kimi-k1");
|
||||||
|
expect(section(next).default_model).toBe("kimi-k1");
|
||||||
|
expect(section(next).model).toBe("kimi-k1");
|
||||||
|
expect(modelsOf(next)).toEqual({ "kimi-k2": "K2", "kimi-k1": "" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// setSubagentForce — mutual exclusion with the models table
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
describe("setSubagentForce", () => {
|
||||||
|
it("turning force on drops the models table but keeps the default and unknown fields", () => {
|
||||||
|
const raw = rawWith({
|
||||||
|
default_model: "kimi-k1",
|
||||||
|
model: "kimi-k1",
|
||||||
|
models: { "kimi-k1": "K1", "kimi-k2": "K2" },
|
||||||
|
custom: "keep",
|
||||||
|
});
|
||||||
|
const next = setSubagentForce(raw, true);
|
||||||
|
const sec = section(next);
|
||||||
|
expect(sec).not.toHaveProperty("models");
|
||||||
|
expect(sec.force).toBe(true);
|
||||||
|
expect(sec.default_model).toBe("kimi-k1");
|
||||||
|
expect(sec.model).toBe("kimi-k1");
|
||||||
|
expect(sec.custom).toBe("keep");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("turning force off leaves the models table untouched", () => {
|
||||||
|
const raw = rawWith({
|
||||||
|
default_model: "kimi-k1",
|
||||||
|
models: { "kimi-k1": "K1", "kimi-k2": "K2" },
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
|
const next = setSubagentForce(raw, false);
|
||||||
|
expect(section(next).force).toBe(false);
|
||||||
|
expect(modelsOf(next)).toEqual({ "kimi-k1": "K1", "kimi-k2": "K2" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("is idempotent in both directions", () => {
|
||||||
|
const raw = rawWith({ force: false, custom: "keep" });
|
||||||
|
expect(setSubagentForce(raw, true)).toEqual(
|
||||||
|
setSubagentForce(setSubagentForce(raw, true), true)
|
||||||
|
);
|
||||||
|
expect(setSubagentForce(raw, false)).toEqual(
|
||||||
|
setSubagentForce(setSubagentForce(raw, false), false)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// validateSubagentPool — mirror of the 6 engine rules
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
describe("validateSubagentPool", () => {
|
||||||
|
const aliases = ["kimi-k1", "kimi-k2", "kimi-k3"];
|
||||||
|
|
||||||
|
const pool = (p: Partial<SubagentModelPool>): SubagentModelPool => ({
|
||||||
|
models: {},
|
||||||
|
force: false,
|
||||||
|
...p,
|
||||||
|
});
|
||||||
|
|
||||||
|
it("accepts a valid pool", () => {
|
||||||
|
expect(
|
||||||
|
validateSubagentPool(
|
||||||
|
pool({
|
||||||
|
defaultModel: "kimi-k2",
|
||||||
|
models: { "kimi-k2": "K2", "kimi-k3": "K3" },
|
||||||
|
}),
|
||||||
|
aliases
|
||||||
|
)
|
||||||
|
).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("accepts the implicit single-entry form when the model resolves", () => {
|
||||||
|
expect(validateSubagentPool(pool({ model: "kimi-k2" }), aliases)).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("accepts force with a model fallback when no pool table exists", () => {
|
||||||
|
expect(
|
||||||
|
validateSubagentPool(pool({ force: true, model: "kimi-k2" }), aliases)
|
||||||
|
).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("flags `primary` as a reserved pool key", () => {
|
||||||
|
const byDefault = validateSubagentPool(pool({ defaultModel: "primary" }), aliases);
|
||||||
|
expect(byDefault).toContainEqual({
|
||||||
|
key: "primaryReserved",
|
||||||
|
params: { alias: "primary" },
|
||||||
|
});
|
||||||
|
const byEntry = validateSubagentPool(
|
||||||
|
pool({ defaultModel: "kimi-k1", models: { primary: "" } }),
|
||||||
|
aliases
|
||||||
|
);
|
||||||
|
expect(byEntry).toContainEqual({
|
||||||
|
key: "primaryReserved",
|
||||||
|
params: { alias: "primary" },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("requires `default_model` when the models table exists", () => {
|
||||||
|
// Strict mirror of the engine: a `model` fallback does not satisfy the
|
||||||
|
// `default_model` requirement once a `models` table is present.
|
||||||
|
expect(
|
||||||
|
validateSubagentPool(
|
||||||
|
pool({ model: "kimi-k2", models: { "kimi-k2": "K2" } }),
|
||||||
|
aliases
|
||||||
|
)
|
||||||
|
).toEqual([{ key: "defaultRequired" }]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("flags a default that is not a key of the pool table", () => {
|
||||||
|
const errors = validateSubagentPool(
|
||||||
|
pool({ defaultModel: "kimi-k3", models: { "kimi-k2": "K2" } }),
|
||||||
|
aliases
|
||||||
|
);
|
||||||
|
expect(errors).toContainEqual({
|
||||||
|
key: "defaultNotInPool",
|
||||||
|
params: { alias: "kimi-k3" },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("flags pool keys that do not resolve in the [models] registry", () => {
|
||||||
|
const errors = validateSubagentPool(
|
||||||
|
pool({ defaultModel: "kimi-k2", models: { "kimi-k2": "K2", ghost: "?" } }),
|
||||||
|
aliases
|
||||||
|
);
|
||||||
|
expect(errors).toContainEqual({
|
||||||
|
key: "aliasNotInModels",
|
||||||
|
params: { alias: "ghost" },
|
||||||
|
});
|
||||||
|
// the implicit single-entry default is checked against the registry too
|
||||||
|
const implicit = validateSubagentPool(pool({ model: "ghost" }), aliases);
|
||||||
|
expect(implicit).toContainEqual({
|
||||||
|
key: "aliasNotInModels",
|
||||||
|
params: { alias: "ghost" },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("flags force without any default", () => {
|
||||||
|
expect(validateSubagentPool(pool({ force: true }), aliases)).toEqual([
|
||||||
|
{ key: "forceRequiresDefault" },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("flags force coexisting with the models table", () => {
|
||||||
|
const errors = validateSubagentPool(
|
||||||
|
pool({ force: true, defaultModel: "kimi-k2", models: { "kimi-k2": "K2" } }),
|
||||||
|
aliases
|
||||||
|
);
|
||||||
|
expect(errors).toContainEqual({ key: "forceExcludesModels" });
|
||||||
|
});
|
||||||
|
});
|
||||||
+293
-18
@@ -99,15 +99,48 @@ export function setExperimentalFlag(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// [secondary_model] — subagent secondary model
|
// [secondary_model] — subagent model pool
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsed subagent model pool (`[secondary_model]` v2 keys). The currently
|
||||||
|
* effective default is `defaultModel ?? model` (v2 pool key first, legacy v1
|
||||||
|
* recipe key as fallback).
|
||||||
|
*/
|
||||||
|
export interface SubagentModelPool {
|
||||||
|
/** v2 pool default (`default_model`). */
|
||||||
|
defaultModel?: string;
|
||||||
|
/** Legacy v1 recipe key (`model`), kept in sync with `defaultModel`. */
|
||||||
|
model?: string;
|
||||||
|
/** `[models]` table (alias → description); non-string values dropped. */
|
||||||
|
models: Record<string, string>;
|
||||||
|
/** Force subagents onto the default alias. */
|
||||||
|
force: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Known v1 patch fields, dropped when re-picking without a pool so stale
|
||||||
|
* patches are cleaned up. */
|
||||||
|
const PATCH_FIELDS: ReadonlySet<string> = new Set([
|
||||||
|
"default_effort",
|
||||||
|
"max_output_size",
|
||||||
|
"max_context_size",
|
||||||
|
]);
|
||||||
|
|
||||||
/** Read `[secondary_model]` from raw_other; `{}` when absent. */
|
/** Read `[secondary_model]` from raw_other; `{}` when absent. */
|
||||||
export function getSecondaryModel(rawOther: unknown): SecondaryModelConfig {
|
export function getSecondaryModel(rawOther: unknown): SecondaryModelConfig {
|
||||||
const section = asRecord(rawOther)["secondary_model"];
|
const section = asRecord(rawOther)["secondary_model"];
|
||||||
const cfg = asRecord(section);
|
const cfg = asRecord(section);
|
||||||
const out: SecondaryModelConfig = {};
|
const out: SecondaryModelConfig = {};
|
||||||
|
if (typeof cfg.default_model === "string" && cfg.default_model !== "")
|
||||||
|
out.default_model = cfg.default_model;
|
||||||
if (typeof cfg.model === "string" && cfg.model !== "") out.model = cfg.model;
|
if (typeof cfg.model === "string" && cfg.model !== "") out.model = cfg.model;
|
||||||
|
const models = asRecord(cfg.models);
|
||||||
|
const pool: Record<string, string> = {};
|
||||||
|
for (const [k, v] of Object.entries(models)) {
|
||||||
|
if (typeof v === "string") pool[k] = v;
|
||||||
|
}
|
||||||
|
if (Object.keys(pool).length > 0) out.models = pool;
|
||||||
|
if (cfg.force === true) out.force = true;
|
||||||
if (typeof cfg.default_effort === "string" && cfg.default_effort !== "")
|
if (typeof cfg.default_effort === "string" && cfg.default_effort !== "")
|
||||||
out.default_effort = cfg.default_effort;
|
out.default_effort = cfg.default_effort;
|
||||||
if (typeof cfg.max_output_size === "number" && cfg.max_output_size > 0)
|
if (typeof cfg.max_output_size === "number" && cfg.max_output_size > 0)
|
||||||
@@ -117,15 +150,40 @@ export function getSecondaryModel(rawOther: unknown): SecondaryModelConfig {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Read the v2 subagent model pool from raw_other; `undefined` when there is
|
||||||
|
* no `[secondary_model]` section or it is empty. The effective default is
|
||||||
|
* `defaultModel ?? model`. */
|
||||||
|
export function getSubagentModelPool(
|
||||||
|
rawOther: unknown
|
||||||
|
): SubagentModelPool | undefined {
|
||||||
|
const section = asRecord(asRecord(rawOther)["secondary_model"]);
|
||||||
|
if (Object.keys(section).length === 0) return undefined;
|
||||||
|
const models: Record<string, string> = {};
|
||||||
|
for (const [k, v] of Object.entries(asRecord(section["models"]))) {
|
||||||
|
if (typeof v === "string") models[k] = v;
|
||||||
|
}
|
||||||
|
const out: SubagentModelPool = { models, force: section["force"] === true };
|
||||||
|
if (typeof section["default_model"] === "string" && section["default_model"] !== "")
|
||||||
|
out.defaultModel = section["default_model"];
|
||||||
|
if (typeof section["model"] === "string" && section["model"] !== "")
|
||||||
|
out.model = section["model"];
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write `[secondary_model]` with only the `model` field — no patch fields.
|
* Write `[secondary_model]` picking the given alias as the subagent model.
|
||||||
* Subagents then bind the pointed model entry directly and inherit its
|
*
|
||||||
* settings (context size, capabilities, effort fallback), which also keeps
|
* Pool-aware: when a pool exists (`models` table or `default_model` present)
|
||||||
* usage records keyed on the real model alias instead of the synthesized
|
* the alias becomes the v2 default (added to the `models` table with an empty
|
||||||
* `__secondary__` derived entry. Unknown fields already present in the
|
* description when missing) and the legacy `model` key is synced; the rest of
|
||||||
* section are preserved; the known patch fields (`default_effort`,
|
* the section — `force`, patch fields, unknown fields — is preserved. This
|
||||||
* `max_output_size`, `max_context_size`) are dropped so stale patches are
|
* keeps usage records keyed on the real model alias instead of the
|
||||||
* cleaned up when the model is re-picked.
|
* synthesized `__secondary__` derived entry.
|
||||||
|
*
|
||||||
|
* Without a pool the legacy single-model form is written: only `model`, with
|
||||||
|
* the known patch fields (`default_effort`, `max_output_size`,
|
||||||
|
* `max_context_size`) dropped so stale patches are cleaned up when the model
|
||||||
|
* is re-picked; unknown fields are preserved.
|
||||||
*/
|
*/
|
||||||
export function setSecondaryModelOnly(
|
export function setSecondaryModelOnly(
|
||||||
rawOther: unknown,
|
rawOther: unknown,
|
||||||
@@ -133,20 +191,237 @@ export function setSecondaryModelOnly(
|
|||||||
): unknown {
|
): unknown {
|
||||||
const root = { ...asRecord(rawOther) };
|
const root = { ...asRecord(rawOther) };
|
||||||
const section = asRecord(asRecord(rawOther)["secondary_model"]);
|
const section = asRecord(asRecord(rawOther)["secondary_model"]);
|
||||||
const next: Record<string, unknown> = { model: alias };
|
const next: Record<string, unknown> = {};
|
||||||
const knownFields: ReadonlySet<string> = new Set([
|
const hasPool =
|
||||||
"model",
|
section["models"] !== undefined || section["default_model"] !== undefined;
|
||||||
"default_effort",
|
if (hasPool) {
|
||||||
"max_output_size",
|
for (const [k, v] of Object.entries(section)) next[k] = v;
|
||||||
"max_context_size",
|
next.default_model = alias;
|
||||||
]);
|
next.model = alias;
|
||||||
for (const [k, v] of Object.entries(section)) {
|
const models: Record<string, unknown> = {};
|
||||||
if (!knownFields.has(k)) next[k] = v;
|
for (const [k, v] of Object.entries(asRecord(next.models))) models[k] = v;
|
||||||
|
if (!(alias in models)) models[alias] = "";
|
||||||
|
next.models = models;
|
||||||
|
} else {
|
||||||
|
for (const [k, v] of Object.entries(section)) {
|
||||||
|
if (!PATCH_FIELDS.has(k)) next[k] = v;
|
||||||
|
}
|
||||||
|
next.model = alias;
|
||||||
}
|
}
|
||||||
root.secondary_model = next;
|
root.secondary_model = next;
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rebuild the subagent model pool atomically. `default_model` and `model` are
|
||||||
|
* written with the same value — the effective default, `defaultModel ?? model`
|
||||||
|
* — plus the `models` table and `force`; unknown fields in the section are
|
||||||
|
* preserved. An empty `models` table is omitted: the engine requires
|
||||||
|
* `default_model` to be a key of the table, so an empty table can never be
|
||||||
|
* valid, and omitting it keeps the implicit single-entry form.
|
||||||
|
*/
|
||||||
|
export function setSubagentModelPool(
|
||||||
|
rawOther: unknown,
|
||||||
|
pool: SubagentModelPool
|
||||||
|
): unknown {
|
||||||
|
const root = { ...asRecord(rawOther) };
|
||||||
|
const section = asRecord(asRecord(rawOther)["secondary_model"]);
|
||||||
|
const next: Record<string, unknown> = {};
|
||||||
|
for (const [k, v] of Object.entries(section)) next[k] = v;
|
||||||
|
const effective = pool.defaultModel ?? pool.model;
|
||||||
|
if (effective) {
|
||||||
|
next.default_model = effective;
|
||||||
|
next.model = effective;
|
||||||
|
} else {
|
||||||
|
delete next.default_model;
|
||||||
|
delete next.model;
|
||||||
|
}
|
||||||
|
if (Object.keys(pool.models).length > 0) {
|
||||||
|
next.models = { ...pool.models };
|
||||||
|
} else {
|
||||||
|
delete next.models;
|
||||||
|
}
|
||||||
|
next.force = pool.force === true;
|
||||||
|
root.secondary_model = next;
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add or update one alias in the pool `models` table. The rest of the
|
||||||
|
* section (default, force, unknown fields) is preserved untouched. */
|
||||||
|
export function upsertSubagentPoolEntry(
|
||||||
|
rawOther: unknown,
|
||||||
|
alias: string,
|
||||||
|
description: string
|
||||||
|
): unknown {
|
||||||
|
const root = { ...asRecord(rawOther) };
|
||||||
|
const section = asRecord(asRecord(rawOther)["secondary_model"]);
|
||||||
|
const next: Record<string, unknown> = {};
|
||||||
|
for (const [k, v] of Object.entries(section)) next[k] = v;
|
||||||
|
const models: Record<string, unknown> = {};
|
||||||
|
for (const [k, v] of Object.entries(asRecord(next.models))) models[k] = v;
|
||||||
|
models[alias] = description;
|
||||||
|
next.models = models;
|
||||||
|
root.secondary_model = next;
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove one alias from the pool `models` table. If it was the default, the
|
||||||
|
* default falls back to the first remaining key (`default_model` and `model`
|
||||||
|
* are both synced). Removing the last entry drops the `models` table and
|
||||||
|
* leaves `default_model`/`model` in place — the implicit single-entry pool.
|
||||||
|
*/
|
||||||
|
export function removeSubagentPoolEntry(
|
||||||
|
rawOther: unknown,
|
||||||
|
alias: string
|
||||||
|
): unknown {
|
||||||
|
const root = { ...asRecord(rawOther) };
|
||||||
|
const section = asRecord(asRecord(rawOther)["secondary_model"]);
|
||||||
|
const next: Record<string, unknown> = {};
|
||||||
|
for (const [k, v] of Object.entries(section)) next[k] = v;
|
||||||
|
const models: Record<string, unknown> = {};
|
||||||
|
for (const [k, v] of Object.entries(asRecord(next.models))) {
|
||||||
|
if (k !== alias) models[k] = v;
|
||||||
|
}
|
||||||
|
const remaining = Object.keys(models);
|
||||||
|
if (remaining.length === 0) {
|
||||||
|
delete next.models;
|
||||||
|
} else {
|
||||||
|
next.models = models;
|
||||||
|
if (next.default_model === alias) {
|
||||||
|
next.default_model = remaining[0];
|
||||||
|
next.model = remaining[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
root.secondary_model = next;
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set the pool default alias, syncing `default_model` and `model`; the alias
|
||||||
|
* is added to the `models` table with an empty description when missing. */
|
||||||
|
export function setSubagentDefault(
|
||||||
|
rawOther: unknown,
|
||||||
|
alias: string
|
||||||
|
): unknown {
|
||||||
|
const root = { ...asRecord(rawOther) };
|
||||||
|
const section = asRecord(asRecord(rawOther)["secondary_model"]);
|
||||||
|
const next: Record<string, unknown> = {};
|
||||||
|
for (const [k, v] of Object.entries(section)) next[k] = v;
|
||||||
|
const models: Record<string, unknown> = {};
|
||||||
|
for (const [k, v] of Object.entries(asRecord(next.models))) models[k] = v;
|
||||||
|
if (!(alias in models)) models[alias] = "";
|
||||||
|
next.models = models;
|
||||||
|
next.default_model = alias;
|
||||||
|
next.model = alias;
|
||||||
|
root.secondary_model = next;
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the `force` flag. Turning force on drops the `models` table — `force`
|
||||||
|
* and the pool table are mutually exclusive per the engine (the implicit
|
||||||
|
* `default_model`/`model` form stays); turning it off leaves the table
|
||||||
|
* untouched. Everything else in the section is preserved.
|
||||||
|
*/
|
||||||
|
export function setSubagentForce(
|
||||||
|
rawOther: unknown,
|
||||||
|
force: boolean
|
||||||
|
): unknown {
|
||||||
|
const root = { ...asRecord(rawOther) };
|
||||||
|
const section = asRecord(asRecord(rawOther)["secondary_model"]);
|
||||||
|
const next: Record<string, unknown> = {};
|
||||||
|
for (const [k, v] of Object.entries(section)) {
|
||||||
|
if (force && k === "models") continue;
|
||||||
|
next[k] = v;
|
||||||
|
}
|
||||||
|
next.force = force;
|
||||||
|
root.secondary_model = next;
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Keys of validation errors, mirroring the kimi-code engine checks. */
|
||||||
|
export type ValidationErrorKey =
|
||||||
|
| "primaryReserved"
|
||||||
|
| "defaultRequired"
|
||||||
|
| "defaultNotInPool"
|
||||||
|
| "aliasNotInModels"
|
||||||
|
| "forceRequiresDefault"
|
||||||
|
| "forceExcludesModels";
|
||||||
|
|
||||||
|
/** A pool validation error; `params` carries the offending alias. */
|
||||||
|
export interface PoolValidationError {
|
||||||
|
key: ValidationErrorKey;
|
||||||
|
params?: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mirror the kimi-code engine validation for the subagent model pool
|
||||||
|
* (violations fail the kimi session with CONFIG_INVALID):
|
||||||
|
* 1. `"primary"` is reserved and cannot be a pool key;
|
||||||
|
* 2. a `models` table requires `default_model`;
|
||||||
|
* 3. `default_model` must be a key of the `models` table;
|
||||||
|
* 4. every pool key must resolve in the top-level `[models]` registry;
|
||||||
|
* 5. `force` requires a default (`default_model` or the `model` fallback);
|
||||||
|
* 6. `force` and a `models` table are mutually exclusive.
|
||||||
|
*
|
||||||
|
* `availableAliases` is the set of top-level `[models]` aliases. A pool
|
||||||
|
* without a `models` table is the implicit single-entry form: only the
|
||||||
|
* effective default is checked against the registry.
|
||||||
|
*/
|
||||||
|
export function validateSubagentPool(
|
||||||
|
pool: SubagentModelPool,
|
||||||
|
availableAliases: string[]
|
||||||
|
): PoolValidationError[] {
|
||||||
|
const errors: PoolValidationError[] = [];
|
||||||
|
const { defaultModel, model, models, force } = pool;
|
||||||
|
const effectiveDefault = defaultModel ?? model;
|
||||||
|
const poolKeys = Object.keys(models);
|
||||||
|
const hasPoolTable = poolKeys.length > 0;
|
||||||
|
const registry = new Set(availableAliases);
|
||||||
|
|
||||||
|
const aliasError = (alias: string) => {
|
||||||
|
if (alias !== "primary" && !registry.has(alias)) {
|
||||||
|
errors.push({ key: "aliasNotInModels", params: { alias } });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Rule 1: "primary" is reserved as a pool key.
|
||||||
|
if (effectiveDefault === "primary") {
|
||||||
|
errors.push({ key: "primaryReserved", params: { alias: "primary" } });
|
||||||
|
}
|
||||||
|
for (const key of poolKeys) {
|
||||||
|
if (key === "primary") {
|
||||||
|
errors.push({ key: "primaryReserved", params: { alias: key } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rule 2: a `models` table requires `default_model`.
|
||||||
|
if (hasPoolTable && !defaultModel) {
|
||||||
|
errors.push({ key: "defaultRequired" });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rule 3: `default_model` must be a key of the `models` table.
|
||||||
|
if (hasPoolTable && defaultModel && !(defaultModel in models)) {
|
||||||
|
errors.push({ key: "defaultNotInPool", params: { alias: defaultModel } });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rule 4: every pool key must resolve in the `[models]` registry.
|
||||||
|
for (const key of poolKeys) aliasError(key);
|
||||||
|
if (!hasPoolTable && effectiveDefault) aliasError(effectiveDefault);
|
||||||
|
|
||||||
|
// Rule 5: `force` requires a default (`default_model` or `model` fallback).
|
||||||
|
if (force && !effectiveDefault) {
|
||||||
|
errors.push({ key: "forceRequiresDefault" });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rule 6: `force` and a `models` table are mutually exclusive.
|
||||||
|
if (force && hasPoolTable) {
|
||||||
|
errors.push({ key: "forceExcludesModels" });
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors;
|
||||||
|
}
|
||||||
|
|
||||||
/** Remove `[secondary_model]` entirely (the "not configured" option). */
|
/** Remove `[secondary_model]` entirely (the "not configured" option). */
|
||||||
export function clearSecondaryModel(rawOther: unknown): unknown {
|
export function clearSecondaryModel(rawOther: unknown): unknown {
|
||||||
const root = { ...asRecord(rawOther) };
|
const root = { ...asRecord(rawOther) };
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ export interface TotalsRow {
|
|||||||
|
|
||||||
export interface DailyRow extends TotalsRow {
|
export interface DailyRow extends TotalsRow {
|
||||||
date: string;
|
date: string;
|
||||||
byModel: Record<string, number>;
|
/** Per-model structured breakdown (tokens / requests / cost / cacheHitRate). */
|
||||||
|
byModel: Record<string, TotalsRow>;
|
||||||
byProvider: Record<string, number>;
|
byProvider: Record<string, number>;
|
||||||
byProviderModel: Record<string, Record<string, number>>;
|
byProviderModel: Record<string, Record<string, number>>;
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-4
@@ -134,13 +134,28 @@ export interface AgentSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kimi Code `[secondary_model]` section of config.toml: the secondary model
|
* Kimi Code `[secondary_model]` section of config.toml: the subagent model
|
||||||
* bound to newly spawned subagents (experimental feature).
|
* pool (experimental feature).
|
||||||
* `model` points at an alias defined in `[models]`; the remaining fields are
|
*
|
||||||
* a patch applied on top of the referenced entry (subagents only).
|
* v2 engine (default) reads the pool keys: `default_model` + `[models]` table
|
||||||
|
* (alias → description) + `force`. `model` is ignored by the v2 validator when
|
||||||
|
* pool keys are present, but is kept in sync with `default_model` so the v1
|
||||||
|
* engine (KIMI_CODE_LEGACY_FLAG=1) resolves the same alias.
|
||||||
|
*
|
||||||
|
* v1 engine reads only the recipe key `model` plus the patch fields; pool keys
|
||||||
|
* are ignored by it. Pool resolution order: `models` table → `default_model` →
|
||||||
|
* `model`.
|
||||||
*/
|
*/
|
||||||
export interface SecondaryModelConfig {
|
export interface SecondaryModelConfig {
|
||||||
|
/** v2: default subagent alias in the pool (a key of `models`). */
|
||||||
|
default_model?: string;
|
||||||
|
/** v2: alias → description table for the subagent model pool. */
|
||||||
|
models?: Record<string, string>;
|
||||||
|
/** v2: force subagents onto the default alias (excludes `models`). */
|
||||||
|
force?: boolean;
|
||||||
|
/** Legacy v1 recipe key — written in sync so KIMI_CODE_LEGACY_FLAG=1 works. */
|
||||||
model?: string;
|
model?: string;
|
||||||
|
/** v1 patch fields, applied on top of the referenced entry (v1 only). */
|
||||||
default_effort?: string;
|
default_effort?: string;
|
||||||
max_output_size?: number;
|
max_output_size?: number;
|
||||||
max_context_size?: number;
|
max_context_size?: number;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/// <reference types="vitest" />
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
|
|
||||||
@@ -10,4 +11,7 @@ export default defineConfig(async () => ({
|
|||||||
watch: { ignored: ["**/src-tauri/**"] },
|
watch: { ignored: ["**/src-tauri/**"] },
|
||||||
},
|
},
|
||||||
envPrefix: ["VITE_"],
|
envPrefix: ["VITE_"],
|
||||||
|
test: {
|
||||||
|
environment: "node",
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
import { recommendLinks } from "../data/recommendLinks";
|
import { recommendLinks } from "../data/recommendLinks";
|
||||||
import { useLang } from "../i18n";
|
import { useLang } from "../i18n";
|
||||||
import { asset } from "../lib/asset";
|
import { asset } from "../lib/asset";
|
||||||
@@ -12,8 +13,62 @@ const logoFor: Record<string, string> = {
|
|||||||
"基元律动": "logos/tokenrhythm.svg",
|
"基元律动": "logos/tokenrhythm.svg",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 下载统计:只拉 GitHub(公开 API 带 CORS),镜像站 Gitea 未开 CORS 不计入。
|
||||||
|
const STATS_URL =
|
||||||
|
"https://api.github.com/repos/billowliu2/KimiSwitch/releases?per_page=100";
|
||||||
|
const STATS_CACHE_KEY = "kimi-switch-downloads";
|
||||||
|
const STATS_CACHE_TTL = 60 * 60 * 1000; // 1 hour
|
||||||
|
|
||||||
|
/** GitHub Release 全部资产 download_count 之和;拉取失败返回 null(不展示)。 */
|
||||||
|
function useDownloadCount(): number | null {
|
||||||
|
const [count, setCount] = useState<number | null>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
let cancelled = false;
|
||||||
|
try {
|
||||||
|
const cached = localStorage.getItem(STATS_CACHE_KEY);
|
||||||
|
if (cached) {
|
||||||
|
const { ts, total } = JSON.parse(cached) as { ts: number; total: number };
|
||||||
|
if (Date.now() - ts < STATS_CACHE_TTL) {
|
||||||
|
setCount(total);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
/* ignore corrupt cache */
|
||||||
|
}
|
||||||
|
fetch(STATS_URL)
|
||||||
|
.then((r) => (r.ok ? r.json() : Promise.reject(new Error(String(r.status)))))
|
||||||
|
.then((releases: Array<{ assets?: Array<{ download_count?: number }> }>) => {
|
||||||
|
if (cancelled) return;
|
||||||
|
const total = (releases ?? []).reduce(
|
||||||
|
(sum, rel) =>
|
||||||
|
sum +
|
||||||
|
(rel.assets ?? []).reduce((s, a) => s + (a.download_count ?? 0), 0),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
setCount(total);
|
||||||
|
try {
|
||||||
|
localStorage.setItem(
|
||||||
|
STATS_CACHE_KEY,
|
||||||
|
JSON.stringify({ ts: Date.now(), total })
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
/* ignore quota errors */
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
/* 拉取失败则不显示 */
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
export default function Footer() {
|
export default function Footer() {
|
||||||
const { t } = useLang();
|
const { t } = useLang();
|
||||||
|
const downloadCount = useDownloadCount();
|
||||||
return (
|
return (
|
||||||
<footer className="border-t border-border py-12">
|
<footer className="border-t border-border py-12">
|
||||||
<div className="container-page space-y-8">
|
<div className="container-page space-y-8">
|
||||||
@@ -86,6 +141,15 @@ export default function Footer() {
|
|||||||
{t.footer.mirror}
|
{t.footer.mirror}
|
||||||
</a>{" "}
|
</a>{" "}
|
||||||
· MIT License
|
· MIT License
|
||||||
|
{downloadCount !== null && (
|
||||||
|
<>
|
||||||
|
{" "}
|
||||||
|
·{" "}
|
||||||
|
<span className="opacity-60">
|
||||||
|
{t.footer.downloads.replace("{n}", downloadCount.toLocaleString())}
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs opacity-80">
|
<div className="text-xs opacity-80">
|
||||||
{t.footer.creditBefore}
|
{t.footer.creditBefore}
|
||||||
|
|||||||
+26
-6
@@ -16,10 +16,10 @@ const zh = {
|
|||||||
performance: "性能",
|
performance: "性能",
|
||||||
changelog: "更新日志",
|
changelog: "更新日志",
|
||||||
download: "下载",
|
download: "下载",
|
||||||
downloadBtn: "下载 v0.7.3",
|
downloadBtn: "下载 v0.7.4",
|
||||||
},
|
},
|
||||||
hero: {
|
hero: {
|
||||||
badge: "v0.7.3 · 开源 MIT · Windows / macOS / Linux",
|
badge: "v0.7.4 · 开源 MIT · Windows / macOS / Linux",
|
||||||
titleBefore: "统一管理你的",
|
titleBefore: "统一管理你的",
|
||||||
titleAccent: "AI 供应商",
|
titleAccent: "AI 供应商",
|
||||||
titleAfter: "",
|
titleAfter: "",
|
||||||
@@ -140,6 +140,15 @@ const zh = {
|
|||||||
syncedNote: "数据已同步 GitHub Releases",
|
syncedNote: "数据已同步 GitHub Releases",
|
||||||
fallbackNote: "内置版本记录",
|
fallbackNote: "内置版本记录",
|
||||||
entries: [
|
entries: [
|
||||||
|
{
|
||||||
|
version: "v0.7.4",
|
||||||
|
date: "2026-08-09",
|
||||||
|
items: [
|
||||||
|
"仪表盘热力图双击弹窗:双击方块查看当日模型用量分布,每种模型展示 Token / 请求次数 / 费用 / 命中率",
|
||||||
|
"后端 by_model 数据结构升级:从纯 token 数升级为结构化对象,柱状图双击弹窗也同步展示全量指标",
|
||||||
|
"范围外日期不可双击、无放大效果",
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
version: "v0.7.3",
|
version: "v0.7.3",
|
||||||
date: "2026-08-07",
|
date: "2026-08-07",
|
||||||
@@ -302,7 +311,7 @@ const zh = {
|
|||||||
},
|
},
|
||||||
download: {
|
download: {
|
||||||
title: "下载 Kimi Switch",
|
title: "下载 Kimi Switch",
|
||||||
subtitle: "当前版本 v0.7.3 · Windows / macOS / Linux 三平台已发布",
|
subtitle: "当前版本 v0.7.4 · Windows / macOS / Linux 三平台已发布",
|
||||||
autoUpdate: "应用内置自动检测更新,新版本发布后在设置页一键升级。",
|
autoUpdate: "应用内置自动检测更新,新版本发布后在设置页一键升级。",
|
||||||
ready: "已发布",
|
ready: "已发布",
|
||||||
wip: "开发中",
|
wip: "开发中",
|
||||||
@@ -345,6 +354,7 @@ const zh = {
|
|||||||
footer: {
|
footer: {
|
||||||
recommend: "推荐供应商",
|
recommend: "推荐供应商",
|
||||||
mirror: "国内镜像",
|
mirror: "国内镜像",
|
||||||
|
downloads: "GitHub 累计下载 {n} 次",
|
||||||
creditBefore: "仪表盘与会话管理功能基于 ",
|
creditBefore: "仪表盘与会话管理功能基于 ",
|
||||||
creditAfter: " (MIT, © JochenYang) 移植",
|
creditAfter: " (MIT, © JochenYang) 移植",
|
||||||
recommendText: {
|
recommendText: {
|
||||||
@@ -370,10 +380,10 @@ const en: Dict = {
|
|||||||
performance: "Performance",
|
performance: "Performance",
|
||||||
changelog: "Changelog",
|
changelog: "Changelog",
|
||||||
download: "Download",
|
download: "Download",
|
||||||
downloadBtn: "Download v0.7.3",
|
downloadBtn: "Download v0.7.4",
|
||||||
},
|
},
|
||||||
hero: {
|
hero: {
|
||||||
badge: "v0.7.3 · Open source MIT · Windows / macOS / Linux",
|
badge: "v0.7.4 · Open source MIT · Windows / macOS / Linux",
|
||||||
titleBefore: "One app for all your ",
|
titleBefore: "One app for all your ",
|
||||||
titleAccent: "AI providers",
|
titleAccent: "AI providers",
|
||||||
titleAfter: "",
|
titleAfter: "",
|
||||||
@@ -494,6 +504,15 @@ const en: Dict = {
|
|||||||
syncedNote: "Synced from GitHub Releases",
|
syncedNote: "Synced from GitHub Releases",
|
||||||
fallbackNote: "Built-in release notes",
|
fallbackNote: "Built-in release notes",
|
||||||
entries: [
|
entries: [
|
||||||
|
{
|
||||||
|
version: "v0.7.4",
|
||||||
|
date: "2026-08-09",
|
||||||
|
items: [
|
||||||
|
"Dashboard heatmap double-click: click any heatmap cell to see per-model breakdown with Token / requests / cost / cache hit rate",
|
||||||
|
"Backend by_model data structure upgraded from plain token counts to structured objects; bar chart double-click modal also shows full metrics",
|
||||||
|
"Out-of-range dates are not double-clickable and have no hover zoom",
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
version: "v0.7.3",
|
version: "v0.7.3",
|
||||||
date: "2026-08-07",
|
date: "2026-08-07",
|
||||||
@@ -655,7 +674,7 @@ const en: Dict = {
|
|||||||
},
|
},
|
||||||
download: {
|
download: {
|
||||||
title: "Download Kimi Switch",
|
title: "Download Kimi Switch",
|
||||||
subtitle: "Current version v0.7.3 · Windows, macOS and Linux now released",
|
subtitle: "Current version v0.7.4 · Windows, macOS and Linux now released",
|
||||||
autoUpdate: "Built-in update detection: upgrade in one click from Settings when a new version ships.",
|
autoUpdate: "Built-in update detection: upgrade in one click from Settings when a new version ships.",
|
||||||
ready: "Available",
|
ready: "Available",
|
||||||
wip: "In development",
|
wip: "In development",
|
||||||
@@ -698,6 +717,7 @@ const en: Dict = {
|
|||||||
footer: {
|
footer: {
|
||||||
recommend: "Recommended Providers",
|
recommend: "Recommended Providers",
|
||||||
mirror: "China mirror",
|
mirror: "China mirror",
|
||||||
|
downloads: "Total GitHub downloads: {n}",
|
||||||
creditBefore: "Dashboard & session management adapted from ",
|
creditBefore: "Dashboard & session management adapted from ",
|
||||||
creditAfter: " (MIT, © JochenYang)",
|
creditAfter: " (MIT, © JochenYang)",
|
||||||
recommendText: {
|
recommendText: {
|
||||||
|
|||||||
@@ -8,27 +8,27 @@ const icons: Record<string, Icon> = {
|
|||||||
linux: LinuxLogo,
|
linux: LinuxLogo,
|
||||||
};
|
};
|
||||||
|
|
||||||
const VERSION = "0.7.3";
|
const VERSION = "0.7.4";
|
||||||
const GITHUB = "https://github.com/billowliu2/KimiSwitch";
|
const GITHUB = "https://github.com/billowliu2/KimiSwitch";
|
||||||
const MIRROR_RELEASES = "https://git.codingplan.site/admin/KimiCodeSwitch/releases";
|
const MIRROR_RELEASES = "https://git.codingplan.site/admin/KimiCodeSwitch/releases";
|
||||||
const dl = (file: string) => `${GITHUB}/releases/download/v${VERSION}/${file}`;
|
const dl = (file: string) => `${GITHUB}/releases/download/v${VERSION}/${file}`;
|
||||||
|
|
||||||
/** Per-platform download assets for the current release (names match the CI
|
/** Per-platform download assets for the current release (names match the CI
|
||||||
* release workflow. NOTE: tauri-bundler keeps the productName verbatim, so the
|
* release workflow exactly — verified against the published v0.7.4 assets:
|
||||||
* real asset is "Kimi Switch_0.7.3_…" (space), URL-encoded as %20. */
|
* tauri-bundler on CI produces `Kimi.Switch_…` (dots) on every platform). */
|
||||||
const assets: Record<string, { label: string; href: string }[]> = {
|
const assets: Record<string, { label: string; href: string }[]> = {
|
||||||
windows: [
|
windows: [
|
||||||
{ label: "MSI", href: dl("Kimi%20Switch_0.7.3_x64_en-US.msi") },
|
{ label: "MSI", href: dl("Kimi.Switch_0.7.4_x64_en-US.msi") },
|
||||||
{ label: "镜像", href: MIRROR_RELEASES },
|
{ label: "镜像", href: MIRROR_RELEASES },
|
||||||
],
|
],
|
||||||
macos: [
|
macos: [
|
||||||
{ label: "Apple Silicon (.dmg)", href: dl("Kimi%20Switch_0.7.3_aarch64.dmg") },
|
{ label: "Apple Silicon (.dmg)", href: dl("Kimi.Switch_0.7.4_aarch64.dmg") },
|
||||||
{ label: "安装脚本", href: dl("install-macos.sh") },
|
{ label: "安装脚本", href: dl("install-macos.sh") },
|
||||||
],
|
],
|
||||||
linux: [
|
linux: [
|
||||||
{ label: ".deb", href: dl("Kimi%20Switch_0.7.3_amd64.deb") },
|
{ label: ".deb", href: dl("Kimi.Switch_0.7.4_amd64.deb") },
|
||||||
{ label: ".AppImage", href: dl("Kimi%20Switch_0.7.3_amd64.AppImage") },
|
{ label: ".AppImage", href: dl("Kimi.Switch_0.7.4_amd64.AppImage") },
|
||||||
{ label: ".rpm", href: dl("Kimi%20Switch-0.7.3-1.x86_64.rpm") },
|
{ label: ".rpm", href: dl("Kimi.Switch-0.7.4-1.x86_64.rpm") },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user