feat: Dynamically detect if a selected client in the sandbox first run wizard supports oauth
This commit is contained in:
@@ -38,6 +38,15 @@ register_client!(
|
||||
(bedrock, "bedrock", BedrockConfig, BedrockClient),
|
||||
);
|
||||
|
||||
pub fn client_type_supports_oauth(type_str: &str) -> bool {
|
||||
matches!(
|
||||
type_str,
|
||||
ClaudeClient::NAME | OpenAIClient::NAME | GeminiClient::NAME
|
||||
) || ALL_PROVIDER_MODELS
|
||||
.iter()
|
||||
.any(|pm| pm.provider == type_str && pm.oauth.is_some())
|
||||
}
|
||||
|
||||
pub const OPENAI_COMPATIBLE_PROVIDERS: [(&str, &str); 18] = [
|
||||
("ai21", "https://api.ai21.com/studio/v1"),
|
||||
(
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ pub use self::skill_policy::SkillPolicy;
|
||||
pub use self::skill_registry::SkillRegistry;
|
||||
pub use self::update::run_self_update;
|
||||
use crate::client::{
|
||||
ClientConfig, MessageContentToolCalls, Model, ModelType, OPENAI_COMPATIBLE_PROVIDERS,
|
||||
self, ClientConfig, MessageContentToolCalls, Model, ModelType, OPENAI_COMPATIBLE_PROVIDERS,
|
||||
ProviderModels, create_client_config, list_client_types, oauth, set_client_models_config,
|
||||
};
|
||||
use crate::function::{FunctionDeclaration, Functions};
|
||||
@@ -830,7 +830,7 @@ async fn create_config_file_sandbox(config_path: &Path) -> Result<()> {
|
||||
|
||||
let mut client_config = serde_json::json!({ "type": client });
|
||||
|
||||
if matches!(client, "claude" | "openai" | "gemini") {
|
||||
if client::client_type_supports_oauth(client) {
|
||||
let use_oauth = Confirm::new("Use OAuth authentication instead?")
|
||||
.with_default(false)
|
||||
.prompt()?;
|
||||
|
||||
Reference in New Issue
Block a user