slaude Docs

Field notes

2026-05-11 — Claude subscription OAuth

  • CLAUDE_CODE_OAUTH_TOKEN accepted as alt provider auth. Generated via claude setup-token on a machine already logged into Claude Code; lets operators run slaude on a Pro/Max subscription instead of metered API credits. Three touchpoints:
    1. src/agent/manager.ts — added CLAUDE_CODE_OAUTH_TOKEN to the env-passthrough whitelist for the SDK child. The SDK CLI natively reads this env var and switches to OAuth Bearer against api.anthropic.com. No code change inside the SDK is needed.
    2. src/soul/extract.ts — direct fetch /v1/messages. When only CLAUDE_CODE_OAUTH_TOKEN is set (no ANTHROPIC_API_KEY), the request carries Authorization: Bearer <tok> + anthropic-beta: oauth-2025-04-20 instead of x-api-key. The beta header is mandatory — bearer-token requests without it 401 on Anthropic. API key wins when both env vars are set (explicit > subscription).
    3. src/config/env.ts — added env.provider.oauthToken() accessor for symmetry / future callers. Not consumed yet outside of the env propagation path.
  • Test coverage added: tests/soul-extract.test.ts asserts header shape on the OAuth branch + API-key precedence when both present. tests/config.test.ts extends the populated-getters case. 175 pass total.
  • BREAKING (same release): SLAUDE_MODEL semantics changed from "default = claude-sonnet-4-6" to "override; empty = let the SDK pick". env.model() returns "" when unset; manager.ts only sets options.model when truthy. Rationale: with CLAUDE_CODE_OAUTH_TOKEN, Claude Code's CLI already knows the subscription's default model — hardcoding claude-sonnet-4-6 in slaude either pinned the wrong tier or silently overrode the user's Pro/Max default. With non-Anthropic gateways the operator was already forced to set SLAUDE_MODEL (their endpoint doesn't speak Anthropic's default id), so this change is no-op for them. Soul extractor still has its own fallback chain (SLAUDE_SOUL_PARSE_MODEL || SLAUDE_MODEL || claude-haiku-4-5-20251001) because it calls /v1/messages directly and model is a required field.