|
1 | | -//! OpenAI Codex OAuth configuration and constants. |
2 | | -//! |
3 | | -
|
4 | | -/// OpenAI Codex OAuth client ID (shared with the OpenCode ecosystem). |
5 | | -pub const CODEX_CLIENT_ID: &str = "app_EMoamEEZ73f0CkXaXp7hrann"; |
6 | | - |
7 | | -/// OpenAI OAuth issuer base URL. |
8 | | -pub const CODEX_ISSUER: &str = "https://auth.openai.com"; |
9 | | - |
10 | | -/// OpenAI OAuth authorization endpoint |
11 | | -pub const CODEX_AUTHORIZE_URL: &str = "https://auth.openai.com/oauth/authorize"; |
12 | | - |
13 | | -/// OpenAI OAuth token endpoint |
14 | | -pub const CODEX_TOKEN_URL: &str = "https://auth.openai.com/oauth/token"; |
15 | | - |
16 | | -/// Codex Responses API endpoint (used for inference after login) |
17 | | -pub const CODEX_API_ENDPOINT: &str = "https://chatgpt.com/backend-api/codex/responses"; |
18 | | - |
19 | | -/// Local redirect URI for OAuth callback |
20 | | -pub const CODEX_REDIRECT_URI: &str = "http://localhost:1455/auth/callback"; |
21 | | - |
22 | | -/// OAuth callback port |
23 | | -pub const CODEX_OAUTH_PORT: u16 = 1455; |
24 | | - |
25 | | -/// OAuth scopes requested from OpenAI |
26 | | -pub const CODEX_SCOPES: &str = "openid profile email offline_access"; |
27 | | - |
28 | | -/// Available Codex models |
29 | | -pub const CODEX_MODELS: &[(&str, &str)] = &[ |
30 | | - ("gpt-5.2-codex", "GPT-5.2 Codex (default)"), |
31 | | - ("gpt-5.1-codex", "GPT-5.1 Codex"), |
32 | | - ("gpt-5.1-codex-mini", "GPT-5.1 Codex Mini"), |
33 | | - ("gpt-5.1-codex-max", "GPT-5.1 Codex Max"), |
34 | | - ("gpt-5.4", "GPT-5.4"), |
35 | | - ("gpt-5.2", "GPT-5.2"), |
36 | | -]; |
37 | | - |
38 | | -/// Default Codex model to use |
39 | | -pub const DEFAULT_CODEX_MODEL: &str = "gpt-5.2-codex"; |
40 | | - |
41 | | -#[cfg(test)] |
42 | | -mod tests { |
43 | | - use super::*; |
44 | | - |
45 | | - #[test] |
46 | | - fn test_codex_constants_not_empty() { |
47 | | - assert!(!CODEX_CLIENT_ID.is_empty()); |
48 | | - assert!(!CODEX_AUTHORIZE_URL.is_empty()); |
49 | | - assert!(!CODEX_TOKEN_URL.is_empty()); |
50 | | - assert!(!CODEX_REDIRECT_URI.is_empty()); |
51 | | - assert!(!CODEX_SCOPES.is_empty()); |
52 | | - assert!(!CODEX_MODELS.is_empty()); |
53 | | - assert!(!DEFAULT_CODEX_MODEL.is_empty()); |
54 | | - } |
55 | | - |
56 | | - #[test] |
57 | | - fn test_codex_models_contains_default() { |
58 | | - let default_found = CODEX_MODELS |
59 | | - .iter() |
60 | | - .any(|(model, _)| model == &DEFAULT_CODEX_MODEL); |
61 | | - assert!( |
62 | | - default_found, |
63 | | - "DEFAULT_CODEX_MODEL must be in CODEX_MODELS list" |
64 | | - ); |
65 | | - } |
66 | | - |
67 | | - #[test] |
68 | | - fn test_redirect_uri_is_localhost() { |
69 | | - assert!(CODEX_REDIRECT_URI.contains("localhost:1455")); |
70 | | - } |
71 | | -} |
| 1 | +//! OpenAI Codex OAuth configuration and constants. |
| 2 | +//! |
| 3 | +
|
| 4 | +/// OpenAI Codex OAuth client ID (shared with the OpenCode ecosystem). |
| 5 | +pub const CODEX_CLIENT_ID: &str = "app_EMoamEEZ73f0CkXaXp7hrann"; |
| 6 | + |
| 7 | +/// OpenAI OAuth issuer base URL. |
| 8 | +pub const CODEX_ISSUER: &str = "https://auth.openai.com"; |
| 9 | + |
| 10 | +/// OpenAI OAuth authorization endpoint |
| 11 | +pub const CODEX_AUTHORIZE_URL: &str = "https://auth.openai.com/oauth/authorize"; |
| 12 | + |
| 13 | +/// OpenAI OAuth token endpoint |
| 14 | +pub const CODEX_TOKEN_URL: &str = "https://auth.openai.com/oauth/token"; |
| 15 | + |
| 16 | +/// Codex Responses API endpoint (used for inference after login) |
| 17 | +pub const CODEX_API_ENDPOINT: &str = "https://chatgpt.com/backend-api/codex/responses"; |
| 18 | + |
| 19 | +/// Local redirect URI for OAuth callback |
| 20 | +pub const CODEX_REDIRECT_URI: &str = "http://localhost:1455/auth/callback"; |
| 21 | + |
| 22 | +/// OAuth callback port |
| 23 | +pub const CODEX_OAUTH_PORT: u16 = 1455; |
| 24 | + |
| 25 | +/// OAuth scopes requested from OpenAI |
| 26 | +pub const CODEX_SCOPES: &str = "openid profile email offline_access"; |
| 27 | + |
| 28 | +/// Available Codex models |
| 29 | +pub const CODEX_MODELS: &[(&str, &str)] = &[ |
| 30 | + ("gpt-5.5", "GPT-5.5 (default)"), |
| 31 | + ("gpt-5.4", "GPT-5.4"), |
| 32 | + ("gpt-5.4-mini", "GPT-5.4 Mini"), |
| 33 | + ("gpt-5.3-codex-spark", "GPT-5.3 Codex Spark (Pro preview)"), |
| 34 | + ( |
| 35 | + "gpt-5.3-codex", |
| 36 | + "GPT-5.3 Codex (deprecated for ChatGPT sign-in)", |
| 37 | + ), |
| 38 | + ( |
| 39 | + "gpt-5.2-codex", |
| 40 | + "GPT-5.2 Codex (deprecated for ChatGPT sign-in)", |
| 41 | + ), |
| 42 | + ("gpt-5.1-codex", "GPT-5.1 Codex"), |
| 43 | + ("gpt-5.1-codex-mini", "GPT-5.1 Codex Mini"), |
| 44 | + ("gpt-5.1-codex-max", "GPT-5.1 Codex Max"), |
| 45 | + ("gpt-5.2", "GPT-5.2"), |
| 46 | +]; |
| 47 | + |
| 48 | +/// Default Codex model to use |
| 49 | +pub const DEFAULT_CODEX_MODEL: &str = "gpt-5.5"; |
| 50 | + |
| 51 | +#[cfg(test)] |
| 52 | +mod tests { |
| 53 | + use super::*; |
| 54 | + |
| 55 | + #[test] |
| 56 | + fn test_codex_constants_not_empty() { |
| 57 | + assert!(!CODEX_CLIENT_ID.is_empty()); |
| 58 | + assert!(!CODEX_AUTHORIZE_URL.is_empty()); |
| 59 | + assert!(!CODEX_TOKEN_URL.is_empty()); |
| 60 | + assert!(!CODEX_REDIRECT_URI.is_empty()); |
| 61 | + assert!(!CODEX_SCOPES.is_empty()); |
| 62 | + assert!(!CODEX_MODELS.is_empty()); |
| 63 | + assert!(!DEFAULT_CODEX_MODEL.is_empty()); |
| 64 | + } |
| 65 | + |
| 66 | + #[test] |
| 67 | + fn test_codex_models_contains_default() { |
| 68 | + let default_found = CODEX_MODELS |
| 69 | + .iter() |
| 70 | + .any(|(model, _)| model == &DEFAULT_CODEX_MODEL); |
| 71 | + assert!( |
| 72 | + default_found, |
| 73 | + "DEFAULT_CODEX_MODEL must be in CODEX_MODELS list" |
| 74 | + ); |
| 75 | + } |
| 76 | + |
| 77 | + #[test] |
| 78 | + fn test_redirect_uri_is_localhost() { |
| 79 | + assert!(CODEX_REDIRECT_URI.contains("localhost:1455")); |
| 80 | + } |
| 81 | +} |
0 commit comments