feat: 下发智能路由模型目录 (#74)

This commit is contained in:
2026-08-10 17:03:06 +08:00
committed by GitHub
parent 78ed93f127
commit d6f939af52
6 changed files with 1454 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ PR #1 曾把 reasoning 模型的 `defaultTemperature` / `defaultTopP` 写为 `nu
| `provider.schema.json` | `compute/providers/*.json``compute/coding-plans/*.json` | `defaultTemperature`/`defaultTopP` 必须是 number禁止 null/string`additionalProperties: false` |
| `manifest.schema.json` | `manifest.json` | `presetDataVersion` 必须是递增整数 |
| `service-map.schema.json` | `compute/service-map.json` | 每条映射须含 `modelName` + `providerId` |
| `smart-model-catalog.schema.json` | `compute/smart-routing/model-catalog.json` | 智能路由三档量级、接入面、exact model 能力和稳定优先级 |
| `providers-index.schema.json` | 两个 `_index.json` | `order` 数组无重复 |
| `pricing.schema.json` | `compute/pricing.json` | `markupRatio` / `usdToCny` 为正数 |
@@ -62,6 +63,17 @@ PR #1 曾把 reasoning 模型的 `defaultTemperature` / `defaultTopP` 写为 `nu
否则老客户端会因未知字段校验失败死锁。
### 智能路由目录的边界
`compute/smart-routing/model-catalog.json` 是路由器直接消费的、按接入面核对过的策略快照:
- `tier``routingPriority``eligibleForAgent``defaultReference` 属于路由策略;
- `capabilities`、上下文和 reasoning 是该 `providerId + model` 接入面的可用能力快照;
- 它不声明 API key、baseUrl、登录状态、用户额度或实时计价`desirecore-cloud` 的连接与计费状态仍由登录后的 Provider 接口动态下发;
- Codex、Claude 条目必须能在对应 `compute/providers/*.json` 中按 exact model 找到,测试会阻止已下线模型继续参与路由。
客户端把本文件作为可热更新主数据源,并保留同 Schema 的内置离线兜底。调整 Provider 或 model-spec 的能力事实时,应同步审阅本目录,避免路由快照漂移。
---
## 本地校验
@@ -78,7 +90,7 @@ CIGitHub Actions会在每个 PR 自动运行 `validate` 和 `test`,不
## 数据修改流程
1. 编辑 `compute/providers/<name>.json``compute/coding-plans/<name>.json``compute/service-map.json`
1. 编辑 `compute/providers/<name>.json``compute/coding-plans/<name>.json``compute/service-map.json``compute/smart-routing/model-catalog.json`
2. 编辑 `compute/providers/_index.json``coding-plans/_index.json`(新增/删除 provider 时)
3. **必须**递增 `manifest.json#presetDataVersion`,并更新 `updatedAt`
4. `npm run validate` 本地确认通过
@@ -95,3 +107,4 @@ CIGitHub Actions会在每个 PR 自动运行 `validate` 和 `test`,不
- **构建期同步**`npm run sync-config-center` 把数据复制到 desirecore 主仓 `lib/agent-service/defaults/`
- **运行时同步**:客户端启动后后台 git fetch 本仓库,每 30 分钟检查一次远程更新
- **版本比对**`presetDataVersion`(递增整数)+ digestSHA-256双重校验
- **智能路由目录**:新客户端按文件 mtime 热加载 `compute/smart-routing/model-catalog.json`;缺失或校验失败时使用随客户端发布的内置 JSON