1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! `/login` and `/logout` argument routing for external runtimes and hosts.
use rho_providers::provider::OpenAiCompatibleApi;
use crate::agent::AgentRuntime;
use super::claude_login::CLAUDE_CODE_TARGET;
/// Agent runtime sign-ins, which are not Rho provider credentials: each
/// runtime runs its own agent, for subagents and for daemon sessions.
///
/// Each one nests under its vendor's login group rather than standing as a
/// top-level provider, since neither is a model provider for Rho's own agent loop.
pub(super) fn external_login_methods() -> [ExternalLoginMethod; 2] {
[
ExternalLoginMethod {
group_id: "anthropic",
value: CLAUDE_CODE_TARGET,
name: "Claude Code",
detail: "Uses Claude Code through claude-agent-acp, not Anthropic API billing. \
Claude Code manages credentials, not Rho.",
},
ExternalLoginMethod {
group_id: "google",
value: AgentRuntime::Antigravity.as_str(),
name: "Antigravity",
detail: "Uses the agy CLI, not Gemini API billing. \
agy manages credentials, not Rho.",
},
]
}
/// One login method backed by an agent runtime rather than a Rho credential.
pub(super) struct ExternalLoginMethod {
/// Login group this method is offered under.
pub(super) group_id: &'static str,
/// Picker value, which is also the `/login` argument.
pub(super) value: &'static str,
/// Runtime name; the picker label adds the shared runtime marker.
pub(super) name: &'static str,
pub(super) detail: &'static str,
}
impl ExternalLoginMethod {
/// Picker label, marked the same way for every agent runtime.
pub(super) fn label(&self) -> String {
format!("{} (agent runtime)", self.name)
}
}
/// What a `/login` or `/logout` argument names.
///
/// Parsed once at each command or picker boundary so the provider flows never
/// re-sniff for an external runtime.
pub(super) enum SignInTarget {
/// Claude Code, which owns its credential.
ClaudeCode,
/// Antigravity's `agy` CLI, which owns its Google sign-in.
Antigravity,
/// Onboarding for a host that does not exist yet.
NewCustomHost { api: OpenAiCompatibleApi },
/// A Rho provider credential.
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 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())
}
}
}
#[cfg(test)]
#[path = "login_target_tests.rs"]
mod tests;