Reference claude ai code sessions status api

Confirmed via probe (2026-07-05, chat-archive-sync-debug session): GET https://api.anthropic.com/v1/code/sessions, authenticated with the existing claudeAiOauth token from ~/.claude/.credentials.json (scope user:sessions:claude_code), returns every claude.ai/code session with a status field of literally "active" or "archived". Each row also carries title (matches the tmux session name), id (cse_<suffix>, same suffix as the local bridge id session_<suffix>), worker_status, last_event_at, and next_cursor for pagination.

This is the missing link for making chat.justin (forge_session_launcher_api.py) mirror the claude.ai web UI's active/archived state instead of relying purely on local tmux liveness. Today chat.justin's bucketing is tmux-only: alive (live tmux + bridge url) vs Unlinked & ended (dead tmux or lost bridge). Justin's actual workflow is: archive a session in the claude.ai web UI when done, which kills the tmux-hosted claude process (since archiving tears down the bridge) — but only for sessions where the bridge link is still intact. Sessions with a lost bridge link, or spawned workers/pool spares without a claude.ai tab, don't get cleaned up by archiving and pile up in chat.justin's drawer.

The unsolved piece (per the session): the OAuth accessToken expires ~hourly. A CLI process auto-refreshes it while active, but chat.justin runs as a 24/7 background service, so it would need its own token refresh using the stored refreshToken to keep reading the session list reliably, plus a fallback to today's tmux-only behavior if the API is unreachable.

Why: Justin wants chat.justin's Active/Unlinked sections to directly reflect claude.ai's active/archived flag rather than requiring a manual periodic purge of sessions whose tmux is alive but bridge is gone. How to apply: When picking up work on chat.justin / forge_session_launcher_api.py session bucketing, this is the confirmed API shape and auth path to build the feature on. Route through /feature-plan before implementing (multi-file, hard-gate territory) — this was in-flight as of 2026-07-05, not yet spec'd or built.

[auto-memory session f7a2c956-394a-461d-9680-bd1434d69be4, confidence 0.85, mode direct]