docs/codex.md
Codex has three automatic usage data paths (OAuth API, web dashboard, CLI RPC) plus a manual CLI PTY diagnostic parser and a local cost-usage scanner. The OAuth API is the default app source when credentials are available; web access is optional for dashboard extras.
codex app-server.primary + openai-web.Usage source picker:
--source auto)codex app-server.~/.codex/auth.json (or $CODEX_HOME/auth.json).last_refresh is older than 8 days.GET https://chatgpt.com/backend-api/wham/usage (default) with Authorization: Bearer <token>.chatgpt.com in a hidden WebView and can materially increase battery or network usage.https://chatgpt.com/codex/settings/usage.WKWebView with a per-account WKWebsiteDataStore.
~/Library/Cookies/Cookies.binarycookies~/Library/Application Support/Google/Chrome/*/Cookies~/Library/Application Support/Firefox/Profiles/*/cookies.sqlitechatgpt.com, openai.com.com.steipete.codexbar.cache (account cookie.codex, source + timestamp).
Reused before re-importing from browsers.Cookie: header from a chatgpt.com request in Preferences → Providers → Codex.client-bootstrap JSON in HTML (or __NEXT_DATA__).OpenAIDashboardScrapeScript + OpenAIDashboardParser):
codex -s read-only -a untrusted app-server.initialize (client name/version)account/readaccount/rateLimits/readcodex app-server process so the stdout reader unwinds instead
of leaving refresh stuck indefinitely.wham/usage JSON body in the error text./status)CodexBarCLI usage --source cli do not launch bare Codex TUI.codex TUI can start interactive auth and open browser tabs./status output:
Credits: line5h limit line → percent + reset textWeekly limit line → percent + reset text~/.codex/auth.json (JWT claims: email + plan).account/rateLimits/read → credits balance.Credits: from saved/manual /status output.~/.codex/sessions/YYYY/MM/DD/*.jsonl~/.codex/archived_sessions/*.jsonl (flat; date inferred from filename when present)$CODEX_HOME/sessions/... + $CODEX_HOME/archived_sessions/... if CODEX_HOME is set.~/.pi/agent/sessions/**/*.jsonlevent_msg token_count entries and turn_context model markers; when both are present,
turn_context is authoritative for the model bucket.openai-codex assistant usage to Codex.~/Library/Caches/CodexBar/cost-usage/codex-v2.json~/Library/Caches/CodexBar/cost-usage/pi-sessions-v1.jsonSources/CodexBarCore/OpenAIWeb/*Sources/CodexBarCore/UsageFetcher.swift,
Sources/CodexBarCore/Providers/Codex/CodexStatusProbe.swiftSources/CodexBarCore/CostUsageFetcher.swift,
Sources/CodexBarCore/PiSessionCostScanner.swift,
Sources/CodexBarCore/PiSessionCostCache.swift,
Sources/CodexBarCore/Vendored/CostUsage/*