mirror of
https://github.com/openai/codex.git
synced 2026-05-17 09:43:19 +00:00
## Summary This PR adds `CodexAuth::AgentIdentity` as an explicit auth mode. An AgentIdentity auth record is a standalone `auth.json` mode. When `AuthManager::auth().await` loads that mode, it registers one process-scoped task and stores it in runtime-only state on the auth value. Header creation stays synchronous after that because the task is initialized before callers receive the auth object. This PR also removes the old feature flag path. AgentIdentity is selected by explicit auth mode, not by a hidden flag or lazy mutation of ChatGPT auth records. Reference old stack: https://github.com/openai/codex/pull/17387/changes ## Design Decisions - AgentIdentity is a real auth enum variant because it can be the only credential in `auth.json`. - The process task is ephemeral runtime state. It is not serialized and is not stored in rollout/session data. - Account/user metadata needed by existing Codex backend checks lives on the AgentIdentity record for now. - `is_chatgpt_auth()` remains token-specific. - `uses_codex_backend()` is the broader predicate for ChatGPT-token auth and AgentIdentity auth. ## Stack 1. https://github.com/openai/codex/pull/18757: full revert 2. https://github.com/openai/codex/pull/18871: isolated Agent Identity crate 3. This PR: explicit AgentIdentity auth mode and startup task allocation 4. https://github.com/openai/codex/pull/18811: migrate Codex backend auth callsites through AuthProvider 5. https://github.com/openai/codex/pull/18904: accept AgentIdentity JWTs and load `CODEX_AGENT_IDENTITY` ## Testing Tests: targeted Rust checks, cargo-shear, Bazel lock check, and CI.
68 lines
2.3 KiB
Rust
68 lines
2.3 KiB
Rust
pub(crate) mod config;
|
|
mod events;
|
|
pub(crate) mod metrics;
|
|
pub(crate) mod provider;
|
|
pub(crate) mod trace_context;
|
|
|
|
mod otlp;
|
|
mod targets;
|
|
|
|
use crate::metrics::Result as MetricsResult;
|
|
use serde::Serialize;
|
|
use strum_macros::Display;
|
|
|
|
pub use crate::config::OtelExporter;
|
|
pub use crate::config::OtelHttpProtocol;
|
|
pub use crate::config::OtelSettings;
|
|
pub use crate::config::OtelTlsConfig;
|
|
pub use crate::events::session_telemetry::AuthEnvTelemetryMetadata;
|
|
pub use crate::events::session_telemetry::SessionTelemetry;
|
|
pub use crate::events::session_telemetry::SessionTelemetryMetadata;
|
|
pub use crate::metrics::runtime_metrics::RuntimeMetricTotals;
|
|
pub use crate::metrics::runtime_metrics::RuntimeMetricsSummary;
|
|
pub use crate::metrics::timer::Timer;
|
|
pub use crate::metrics::*;
|
|
pub use crate::provider::OtelProvider;
|
|
pub use crate::trace_context::context_from_w3c_trace_context;
|
|
pub use crate::trace_context::current_span_trace_id;
|
|
pub use crate::trace_context::current_span_w3c_trace_context;
|
|
pub use crate::trace_context::set_parent_from_context;
|
|
pub use crate::trace_context::set_parent_from_w3c_trace_context;
|
|
pub use crate::trace_context::span_w3c_trace_context;
|
|
pub use crate::trace_context::traceparent_context_from_env;
|
|
pub use codex_utils_string::sanitize_metric_tag_value;
|
|
|
|
#[derive(Debug, Clone, Serialize, Display)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ToolDecisionSource {
|
|
AutomatedReviewer,
|
|
Config,
|
|
User,
|
|
}
|
|
|
|
/// Maps to API/auth `AuthMode` to avoid a circular dependency on codex-core.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Display)]
|
|
pub enum TelemetryAuthMode {
|
|
ApiKey,
|
|
Chatgpt,
|
|
}
|
|
|
|
impl From<codex_app_server_protocol::AuthMode> for TelemetryAuthMode {
|
|
fn from(mode: codex_app_server_protocol::AuthMode) -> Self {
|
|
match mode {
|
|
codex_app_server_protocol::AuthMode::ApiKey => Self::ApiKey,
|
|
codex_app_server_protocol::AuthMode::Chatgpt
|
|
| codex_app_server_protocol::AuthMode::ChatgptAuthTokens
|
|
| codex_app_server_protocol::AuthMode::AgentIdentity => Self::Chatgpt,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Start a metrics timer using the globally installed metrics client.
|
|
pub fn start_global_timer(name: &str, tags: &[(&str, &str)]) -> MetricsResult<Timer> {
|
|
let Some(metrics) = crate::metrics::global() else {
|
|
return Err(MetricsError::ExporterDisabled);
|
|
};
|
|
metrics.start_timer(name, tags)
|
|
}
|