probe_oauth_status

Function probe_oauth_status 

Source
pub fn probe_oauth_status(
    provider: &str,
    dir: &str,
    now_ms: i64,
) -> Option<OAuthProbeStatus>
Expand description

Cheap on-disk probe of the per-bundle OAuth token file for a provider. No network calls — just reads + parses the token JSON, then compares expiresAt against now_ms.

Provider token-file shape (spec §4.4 + §4.5):

  • claude<dir>/.credentials.json with { "claudeAiOauth": { "accessToken", "refreshToken", "expiresAt": <ms> } } (Anthropic’s documented format — see docs/specs/agentmux-isolated-auth.md §1.6).
  • codex<dir>/.credentials.json (MCP OAuth). Exact field layout undocumented by OpenAI; for now we treat presence-of-file as Valid and absence as NeedsReauth, deferring strict expiry parsing until the shape is pinned down. Falls through to the Claude parser as a best-effort — if the file is shape-compatible (some CLIs reuse Anthropic’s format) the expiry check still works.
  • openclaw — same fallback as codex.

Returns Some(status) on a definitive read, None when probing isn’t supported for the provider (so the caller skips status updates rather than mis-writing needs_reauth for a provider whose file we just don’t know how to parse yet).