fix(config): 保存不再误删 CLI 后加的顶层配置节 + 未知供应商类型原样保留

- 导出 stale-key 清理增加导入基线(imported_section_keys):CLI 在导入后
  新增的顶层节(kimi-code 0.38+ 的 [task]/[swarm]/[cron] 等)在保存时
  原样保留;用户在 UI 显式删除的节仍被移除;空基线(SQLite 快照恢复)
  不删任何键(安全退化)
- ProviderType 增加 Unknown(String) 变体,手写 serde 保持纯字符串线格式,
  上游新增的 type 值往返不再被改写为 kimi;SQLite 快照恢复路径同步修复;
  模型发现对未知类型返回明确错误,不再误用 KIMI_API_KEY
- 新增 3 个往返测试(106 个 Rust 测试全绿),前端 tsc/vitest 通过
This commit is contained in:
KimiSwitch Dev committed 2026-08-29 00:09:55 +08:00
1 parent 9764929919
commit 67db19eda4
9 files changed
+251 -58

No files matched your search

+5 -2
View File
@@ -205,8 +205,10 @@ pub fn pi_api_for_provider(provider_type: &ProviderType) -> &'static str {
ProviderType::Anthropic => "anthropic-messages",
ProviderType::GoogleGenai => "google-generative-ai",
ProviderType::Vertexai => "google-vertex",
// Treat Kimi as OpenAI-compatible since it is not a native Pi API.
ProviderType::Kimi => "openai-completions",
// Treat Kimi as OpenAI-compatible since it is not a native Pi API;
// unknown upstream types get the same lenient handling (Pi is a
// legacy path).
ProviderType::Kimi | ProviderType::Unknown(_) => "openai-completions",
}
}
@@ -383,6 +385,7 @@ pub fn pi_file_to_config(file: &PiModelsFile) -> Config {
providers,
models,
raw_other: file.extra.clone(),
imported_section_keys: Vec::new(),
}
}