use rho_providers::provider::OpenAiCompatibleApi;
use crate::agent::AgentRuntime;
use super::claude_login::CLAUDE_CODE_TARGET;
const CURSOR_AGENT_ALIAS: &str = "cursor-agent";
pub(super) fn external_login_methods() -> [ExternalLoginMethod; 3] {
[
ExternalLoginMethod {
group_id: "anthropic",
value: CLAUDE_CODE_TARGET,
aliases: &[],
name: "Claude Code",
detail: "Uses the claude CLI, not Anthropic API billing. \
Claude Code manages credentials, not Rho.",
},
ExternalLoginMethod {
group_id: "google",
value: AgentRuntime::Antigravity.as_str(),
aliases: &[],
name: "Antigravity",
detail: "Uses agy_acp_server, not Gemini API billing. \
Antigravity manages credentials, not Rho.",
},
ExternalLoginMethod {
group_id: "xai",
value: AgentRuntime::Cursor.as_str(),
aliases: &[CURSOR_AGENT_ALIAS],
name: "Cursor",
detail: "Uses the cursor-agent CLI, not SpaceXAI API billing. \
Cursor manages credentials, not Rho.",
},
]
}
pub(super) struct ExternalLoginMethod {
pub(super) group_id: &'static str,
pub(super) value: &'static str,
pub(super) aliases: &'static [&'static str],
pub(super) name: &'static str,
pub(super) detail: &'static str,
}
impl ExternalLoginMethod {
pub(super) fn label(&self) -> String {
format!("{} (delegation only)", self.name)
}
}
pub(super) enum SignInTarget {
ClaudeCode,
Cursor,
Antigravity,
NewCustomHost { api: OpenAiCompatibleApi },
Provider(String),
}
impl SignInTarget {
pub(super) fn parse(value: &str) -> Self {
let value = value.trim();
if value.eq_ignore_ascii_case(CLAUDE_CODE_TARGET) {
Self::ClaudeCode
} else if is_cursor_login_target(value) {
Self::Cursor
} else if value.eq_ignore_ascii_case(AgentRuntime::Antigravity.as_str()) {
Self::Antigravity
} else if let Some(api) = super::custom_provider_login::parse_custom_host_api(value) {
Self::NewCustomHost { api }
} else {
Self::Provider(value.to_string())
}
}
}
fn is_cursor_login_target(value: &str) -> bool {
value.eq_ignore_ascii_case(AgentRuntime::Cursor.as_str())
|| value.eq_ignore_ascii_case(CURSOR_AGENT_ALIAS)
}
#[cfg(test)]
#[path = "login_target_tests.rs"]
mod tests;