mirror of
https://github.com/openai/codex.git
synced 2026-09-07 15:40:00 +00:00
## Why Authentication mode is a domain concept used by login, model selection, telemetry, and transports. Keeping the canonical type in app-server protocol forces those lower-level crates to depend on an unrelated wire API. ## What changed - Added canonical `codex_protocol::auth::AuthMode` domain values. - Kept the app-server wire DTO unchanged and added an explicit app-side conversion. - Removed production app-server-protocol dependencies from login, model-provider-info, models-manager, and otel call paths. ## Stack This is PR 2 of 6, stacked on [PR #29714](https://github.com/openai/codex/pull/29714). Review only the delta from `codex/split-json-rpc-protocols`. Next: [PR #29722](https://github.com/openai/codex/pull/29722). ## Validation - Auth and login coverage passed in the focused protocol/domain test run. - App-server account and auth conversion coverage passed.
20 lines
937 B
Rust
20 lines
937 B
Rust
use codex_app_server_protocol::AuthMode as ApiAuthMode;
|
|
use codex_protocol::auth::AuthMode;
|
|
|
|
/// Converts the domain auth mode owned by `codex-protocol` into the app-server wire type owned by
|
|
/// `codex-app-server-protocol`.
|
|
///
|
|
/// The types stay separate so app-server protocol ownership does not leak into domain crates.
|
|
/// Because this crate owns neither type, Rust's orphan rules require an explicit conversion
|
|
/// function instead of a `From` implementation.
|
|
pub(crate) fn auth_mode_to_api(auth_mode: AuthMode) -> ApiAuthMode {
|
|
match auth_mode {
|
|
AuthMode::ApiKey => ApiAuthMode::ApiKey,
|
|
AuthMode::Chatgpt => ApiAuthMode::Chatgpt,
|
|
AuthMode::ChatgptAuthTokens => ApiAuthMode::ChatgptAuthTokens,
|
|
AuthMode::AgentIdentity => ApiAuthMode::AgentIdentity,
|
|
AuthMode::PersonalAccessToken => ApiAuthMode::PersonalAccessToken,
|
|
AuthMode::BedrockApiKey => ApiAuthMode::BedrockApiKey,
|
|
}
|
|
}
|