mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 08:50:08 +08:00
Replaces the oauth_cli_kit indirection with DeepTutor's own PKCE loopback sign-in, an account-scoped live model catalog, and a Settings card that exposes only the OAuth surface. Credentials live in `<user-root>/private/openai-codex/` with owner-only permissions, atomic writes, and a generation guard that stops a late refresh from resurrecting a signed-out session; `~/.codex` is never read or modified. A CLI path shares the same service. A Codex token authorizes one person's ChatGPT plan, so credentials anchor to the signing-in account's own root and the managed profile is marked `owner_bound`: `redacted_model_access` drops it for every caller, and it is not offered as an assignable model. Signing in publishes the profile but only activates it when no LLM is configured yet, so it never repoints a deployment that already has one. Also from review: reschedule the status poll so one dropped response cannot strand the card on "waiting"; defer the catalog reload when the operator has unsaved edits instead of discarding them; log the real cause behind the generic provider error; stop promising a retry when the token refresh actually failed; bind both loopback stacks since `localhost` may resolve to either; and drop the provider metadata fields nothing consumed.
24 lines
1.1 KiB
Python
24 lines
1.1 KiB
Python
"""Audited OpenAI Codex compatibility constants."""
|
|
|
|
CODEX_UPSTREAM_COMMIT = "81da9deb065d7adb283816b19b40f89bcc484276"
|
|
CODEX_CLIENT_VERSION = "0.145.0"
|
|
CODEX_OAUTH_ISSUER = "https://auth.openai.com"
|
|
CODEX_OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann"
|
|
CODEX_OAUTH_SCOPE = "openid profile email offline_access api.connectors.read api.connectors.invoke"
|
|
CODEX_OAUTH_ORIGINATOR = "codex_cli_rs"
|
|
CODEX_CALLBACK_PORTS = (1455, 1457)
|
|
CODEX_CALLBACK_PATH = "/auth/callback"
|
|
CODEX_LOGIN_TIMEOUT_SECONDS = 300
|
|
CODEX_TOKEN_URL = f"{CODEX_OAUTH_ISSUER}/oauth/token"
|
|
CODEX_REVOKE_URL = f"{CODEX_OAUTH_ISSUER}/oauth/revoke"
|
|
CODEX_MODELS_URL = "https://chatgpt.com/backend-api/codex/models"
|
|
CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses"
|
|
CODEX_FRESH_CACHE_SECONDS = 300
|
|
CODEX_STALE_CACHE_SECONDS = 86_400
|
|
CODEX_MAX_MODELS = 512
|
|
CODEX_MAX_CATALOG_BYTES = 8 * 1024 * 1024
|
|
# Fallback only, used when a caller does not name a model. The real list always
|
|
# comes from the signed-in account's live catalog.
|
|
CODEX_DEFAULT_MODEL = "gpt-5.6-sol"
|
|
CODEX_DEFAULT_MODEL_ID = f"openai-codex/{CODEX_DEFAULT_MODEL}"
|