feat(shell): custom providers declared in config.toml join the model catalog

[platforms.<name>] with base_url and api (openai or anthropic) declares a provider.
Its key lives in auth.json under the name or in the table; /models is fetched per
provider, entries are keyed <name>/<model>, and the key is stamped in memory only.
This commit is contained in:
雷电芽衣 committed 2026-09-29 14:50:24 -04:00
1 parent 4514b66ffe
commit 2ca1f3baa7
11 files changed
+1048 -23

No files matched your search

+10 -1
View File
@@ -619,6 +619,15 @@ pub fn store_platform_api_key(
),
));
}
store_scoped_api_key(kigi_home, platform.as_str(), api_key)
}
/// Stores a key under `scope`; callers own the name.
pub(crate) fn store_scoped_api_key(
kigi_home: &Path,
scope: &str,
api_key: &str,
) -> std::io::Result<()> {
let path = kigi_home.join("auth.json");
// Serialize with the manager's cross-process auth.json writers (token
// refresh holds the same flock): an unlocked read-modify-write here
@@ -641,7 +650,7 @@ pub fn store_platform_api_key(
};
let mut map = read_auth_json_or_empty_recovering_corrupt(&path)?;
map.insert(
platform.as_str().to_owned(),
scope.to_owned(),
KimiAuth {
key: api_key.to_owned(),
auth_mode: AuthMode::ApiKey,