diff options
Diffstat (limited to 'packages/core/src/credentials')
| -rw-r--r-- | packages/core/src/credentials/anthropic-betas.ts | 24 | ||||
| -rw-r--r-- | packages/core/src/credentials/claude.ts | 21 |
2 files changed, 30 insertions, 15 deletions
diff --git a/packages/core/src/credentials/anthropic-betas.ts b/packages/core/src/credentials/anthropic-betas.ts new file mode 100644 index 0000000..f2ca7a6 --- /dev/null +++ b/packages/core/src/credentials/anthropic-betas.ts @@ -0,0 +1,24 @@ +// ─── Anthropic Beta Headers ─────────────────────────────────── +// +// The set of `anthropic-beta` features the official Claude Code CLI sends on +// every request. Kept in a dependency-free module (no DB / `bun:sqlite` +// import) so the LLM provider layer (`llm/provider.ts`) can pull the list in +// without dragging the whole credentials/DB stack into its import graph. +// +// `prompt-caching-scope-2026-01-05` is load-bearing for cost: without it the +// Anthropic API silently ignores every `cache_control` breakpoint we place, +// producing a 0% cache hit rate (see claude-report.md). `oauth-2025-04-20` +// gates the Bearer/OAuth flow used by Claude Pro/Max subscriptions. + +const BASE_BETAS = [ + "claude-code-20250219", + "oauth-2025-04-20", + "interleaved-thinking-2025-05-14", + "prompt-caching-scope-2026-01-05", + "context-management-2025-06-27", + "advisor-tool-2026-03-01", +]; + +export function getAnthropicBetas(): string[] { + return [...BASE_BETAS]; +} diff --git a/packages/core/src/credentials/claude.ts b/packages/core/src/credentials/claude.ts index 6018207..168d544 100644 --- a/packages/core/src/credentials/claude.ts +++ b/packages/core/src/credentials/claude.ts @@ -10,8 +10,14 @@ import { import { homedir } from "node:os"; import { basename, dirname, join } from "node:path"; import { getDatabase } from "../db/index.js"; +import { getAnthropicBetas } from "./anthropic-betas.js"; import { getStoredCredentials, listStoredCredentials, updateStoredTokens } from "./store.js"; +// Re-exported for backward compatibility — `getAnthropicBetas` historically +// lived here and is surfaced through `credentials/index.ts`. The definition +// now lives in the dependency-free `anthropic-betas.ts` module. +export { getAnthropicBetas }; + export interface ClaudeCredentials { accessToken: string; refreshToken: string; @@ -367,21 +373,6 @@ export function buildBillingHeaderValue( export const SYSTEM_IDENTITY = "You are Claude Code, Anthropic's official CLI for Claude."; -// ─── Anthropic Beta Headers ─────────────────────────────────── - -const BASE_BETAS = [ - "claude-code-20250219", - "oauth-2025-04-20", - "interleaved-thinking-2025-05-14", - "prompt-caching-scope-2026-01-05", - "context-management-2025-06-27", - "advisor-tool-2026-03-01", -]; - -export function getAnthropicBetas(): string[] { - return [...BASE_BETAS]; -} - // ─── Anthropic Request Headers ──────────────────────────────── export function getAnthropicHeaders(accessToken: string): Record<string, string> { |
