Skip to main content

Module proxy

Module proxy 

Source

Functions§

build_status_snapshot
Build a status JSON snapshot from config + state — used by the heartbeat loop.
cooldown_watcher
Watches for account cooldowns expiring and triggers a post-cooldown prefetch so each account re-enters rotation with fresh rate-limit metrics.
create_app
create_app_with_state
Combined app used by tests and the single-port fallback mode. Includes both proxy routes and management routes (/health, /status, /use) sharing a single AppState so state changes are visible across all routes.
create_control_app
Create a control plane app (management routes only — sees ALL accounts). Registers /health, /status, /use.
create_proxy_app
openai_token_refresh_loop
Keeps shunt’s live credentials in sync with Codex CLI’s auth.json.
prefetch_rate_limits
For any account with no rate-limit data yet, make a cheap request directly to the upstream API so we populate metrics without waiting for a real user request. Runs as a background task after startup.
recovery_watcher
Runs as a background task. Every 2 minutes, tries to refresh tokens for any auth_failed account. If refresh succeeds the account is brought back online without a process restart. If all accounts remain unrecoverable, fires a macOS notification (at most once per hour).

Type Aliases§

LiveCredentials
Shared live credentials map — can be written to without restarting the proxy.