Startup auth was split between the CLI and API crates, which made saved OAuth refresh behavior eager and easy to drift. This change adds a startup-specific resolver in the API layer, keeps env-only auth semantics intact, preserves saved refresh tokens when refresh responses omit them, and lets the CLI reuse the shared resolver while keeping --version on a purely local path. Constraint: Saved OAuth credentials live in ~/.claude/credentials.json and must remain compatible with existing runtime helpers Constraint: --version must not require config loading or any API/auth client initialization Rejected: Keep refresh orchestration only in rusty-claude-cli | would preserve split auth policy and lazy-load bugs Rejected: Change AnthropicClient::from_env to load config | would broaden configless API semantics for non-CLI callers Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep startup-only OAuth refresh separate from AuthSource::from_env() / AnthropicClient::from_env() unless all non-CLI callers are re-evaluated Tested: cargo fmt --all; cargo build; cargo clippy --workspace --all-targets -- -D warnings; cargo test; cargo run -p rusty-claude-cli -- --version Not-tested: Live OAuth refresh against a real auth server
18 lines
630 B
Rust
18 lines
630 B
Rust
mod client;
|
|
mod error;
|
|
mod sse;
|
|
mod types;
|
|
|
|
pub use client::{
|
|
oauth_token_is_expired, resolve_saved_oauth_token, resolve_startup_auth_source,
|
|
AnthropicClient, AuthSource, MessageStream, OAuthTokenSet,
|
|
};
|
|
pub use error::ApiError;
|
|
pub use sse::{parse_frame, SseParser};
|
|
pub use types::{
|
|
ContentBlockDelta, ContentBlockDeltaEvent, ContentBlockStartEvent, ContentBlockStopEvent,
|
|
InputContentBlock, InputMessage, MessageDelta, MessageDeltaEvent, MessageRequest,
|
|
MessageResponse, MessageStartEvent, MessageStopEvent, OutputContentBlock, StreamEvent,
|
|
ToolChoice, ToolDefinition, ToolResultContentBlock, Usage,
|
|
};
|