#[non_exhaustive]pub struct AuthStatus {
pub agent: Agent,
pub state: AuthState,
pub method: Option<String>,
pub account: Option<String>,
pub plan: Option<String>,
pub detail: String,
pub login_hint: &'static str,
}Expand description
What an agent reported about its credentials.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.agent: AgentThe agent asked.
state: AuthStateWhat it said.
method: Option<String>How it is authenticated, in its own words: claude.ai, ChatGPT, an
API key. None when it did not say.
account: Option<String>The account, where the agent reports one. Claude gives an email.
plan: Option<String>The plan or subscription, where reported.
detail: StringThe CLI’s own output, or an explanation when it could not be asked.
login_hint: &'static strThe command that resolves a missing login.
Implementations§
Source§impl AuthStatus
impl AuthStatus
Sourcepub async fn check(agent: Agent) -> Result<AuthStatus>
pub async fn check(agent: Agent) -> Result<AuthStatus>
Ask agent’s default binary.
§Errors
Error::NotInstalled if the binary is missing, Error::Spawn if it
cannot be run. A CLI that answers “logged out” is a successful check,
not an error.
Sourcepub async fn check_bin(agent: Agent, bin: &str) -> Result<AuthStatus>
pub async fn check_bin(agent: Agent, bin: &str) -> Result<AuthStatus>
Ask a specific binary, for a caller overriding the path with
crate::Request::bin.
§Errors
Error::NotInstalled if the binary is missing, Error::Spawn if it
cannot be run.
Sourcepub fn is_logged_in(&self) -> bool
pub fn is_logged_in(&self) -> bool
Whether the agent confirmed it is logged in.
False for AuthState::Unknown, so a caller that gates on this is
conservative. Check state directly to distinguish “no” from “cannot
tell”.
Sourcepub fn needs_login(&self) -> bool
pub fn needs_login(&self) -> bool
Whether the answer means someone has to log in.
Only a confirmed logout. An agent that cannot be asked is not evidence of a problem.
Trait Implementations§
Source§impl Clone for AuthStatus
impl Clone for AuthStatus
Source§fn clone(&self) -> AuthStatus
fn clone(&self) -> AuthStatus
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more