/** * `anthropic-oauth` wire family — Claude Pro/Max via "Sign in with Claude". * * Same wire as the API-key `anthropic` family (api.anthropic.com/v1/messages), * but authenticated with an OAuth access token instead of an API key. Three * things differ from the API-key path, all REQUIRED for the subscription * backend to accept the request: * 1. `Authorization: Bearer ` (no `x-api-key`). * 2. `anthropic-beta: claude-code-20250219,oauth-2025-04-20`. * 3. The first system block MUST be exactly the Claude Code identity line — * Anthropic rejects OAuth requests whose system prompt doesn't lead with it. * * The API-key `anthropic` family is untouched. Tokens self-refresh (near-expiry * + once on 401) via the refresh token; rotated tokens persist through the same * `setOAuthTokenPersister` hook the codex family uses. */ import { type Capabilities, type Request, type StreamEvent } from '@wrongstack/core/types'; import type { AnthropicStreamState } from './presets/anthropic.js'; import { WireFormatProvider } from './wire-format.js'; import type { WireAdapterStreamOptions } from './wire-adapter.js'; import type { BuildBodyContext } from './model-output-limits.js'; /** Required first system block for OAuth/subscription requests. */ export declare const CLAUDE_CODE_SYSTEM_PROMPT = "You are Claude Code, Anthropic's official CLI for Claude."; export interface AnthropicOAuthTokens { access: string; refresh: string; /** Absolute expiry in epoch milliseconds. */ expires: number; } /** Refresh an expired Claude OAuth access token. */ export declare function refreshAnthropicOAuthToken(refreshToken: string, signal?: AbortSignal): Promise; export interface AnthropicOAuthCredentials { accessToken: string; refreshToken?: string | undefined; expiresAt?: number | undefined; } export interface AnthropicOAuthProviderOptions { credentials: AnthropicOAuthCredentials; baseUrl?: string | undefined; id?: string | undefined; fetchImpl?: typeof fetch | undefined; streamOpts?: WireAdapterStreamOptions | undefined; onRefresh?: ((creds: { accessToken: string; refreshToken: string; expiresAt: number; }) => void) | undefined; refreshFn?: ((refreshToken: string, signal?: AbortSignal) => Promise) | undefined; } export declare class AnthropicOAuthProvider extends WireFormatProvider { readonly id: string; readonly capabilities: Capabilities; private access; private refresh; private readonly refreshFn; /** Shared OAuth refresh machinery — see packages/providers/src/oauth-refresh-coordinator.ts */ private readonly refreshCoordinator; constructor(opts: AnthropicOAuthProviderOptions); stream(req: Request, opts: { signal: AbortSignal; }): AsyncGenerator; /** Map Claude-Code-cased tool_use names in the stream back to real names. */ private remapToolNames; private ensureFreshToken; private doRefresh; protected buildHeaders(_req: Request): Record; protected buildBody(req: Request, ctx: BuildBodyContext): Record; } //# sourceMappingURL=anthropic-oauth.d.ts.map