-
Notifications
You must be signed in to change notification settings - Fork 182
feat(claude-code): add model catalog and provider settings types #801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
edelauna
wants to merge
1
commit into
main
Choose a base branch
from
feat/claude-code-provider-types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { describe, it, expect } from "vitest" | ||
|
|
||
| import { claudeCodeModels, claudeCodeDefaultModelId } from "../providers/claude-code.js" | ||
| import { providerSettingsSchema, providerSettingsSchemaDiscriminated } from "../provider-settings.js" | ||
|
|
||
| describe("claudeCodeModels", () => { | ||
| it("default model ID exists in the models record", () => { | ||
| expect(claudeCodeModels).toHaveProperty(claudeCodeDefaultModelId) | ||
| }) | ||
|
|
||
| it("all models have inputPrice: 0 and outputPrice: 0", () => { | ||
| for (const [id, model] of Object.entries(claudeCodeModels)) { | ||
| expect(model.inputPrice, `${id}: inputPrice must be 0`).toBe(0) | ||
| expect(model.outputPrice, `${id}: outputPrice must be 0`).toBe(0) | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| describe("claudeCodeSchema (via providerSettingsSchema)", () => { | ||
| it("accepts an empty object", () => { | ||
| const result = providerSettingsSchema.safeParse({}) | ||
| expect(result.success).toBe(true) | ||
| }) | ||
|
|
||
| it("accepts claudeCodeCliPath as an optional string", () => { | ||
| const result = providerSettingsSchema.safeParse({ claudeCodeCliPath: "/usr/local/bin/claude" }) | ||
| expect(result.success).toBe(true) | ||
| if (result.success) { | ||
| expect(result.data.claudeCodeCliPath).toBe("/usr/local/bin/claude") | ||
| } | ||
| }) | ||
|
|
||
| it("rejects unknown keys in strict mode", () => { | ||
| const result = providerSettingsSchema.strict().safeParse({ claudeCodeApiKey: "should-not-exist" }) | ||
| expect(result.success).toBe(false) | ||
| }) | ||
| }) | ||
|
|
||
| describe("claudeCodeSchema (via providerSettingsSchemaDiscriminated)", () => { | ||
| it("accepts apiProvider: 'claude-code' with no other fields", () => { | ||
| const result = providerSettingsSchemaDiscriminated.safeParse({ apiProvider: "claude-code" }) | ||
| expect(result.success).toBe(true) | ||
| }) | ||
|
|
||
| it("accepts apiProvider: 'claude-code' with claudeCodeCliPath", () => { | ||
| const result = providerSettingsSchemaDiscriminated.safeParse({ | ||
| apiProvider: "claude-code", | ||
| claudeCodeCliPath: "/usr/local/bin/claude", | ||
| }) | ||
| expect(result.success).toBe(true) | ||
| if (result.success) { | ||
| expect(result.data.apiProvider).toBe("claude-code") | ||
| } | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| import type { ModelInfo } from "../model.js" | ||
|
|
||
| /** | ||
| * Claude Code (Subscription) Provider | ||
| * | ||
| * This provider shells out to the user's own locally-installed and | ||
| * already-authenticated `claude` CLI (Pro/Max/Team/Enterprise subscription), | ||
| * instead of an Anthropic API key. No credentials are read, stored, or | ||
| * transmitted by this extension. | ||
| * | ||
| * Key differences from anthropic: | ||
| * - Uses the local CLI session instead of API keys | ||
| * - Subscription-based pricing (no per-token costs) | ||
| * - Model availability depends on the authenticated subscription | ||
| * | ||
| * Pricing below (0 at runtime) mirrors the real per-token list prices from | ||
| * `anthropic.ts` as of 2026-07-04, for reference only. | ||
| * | ||
| * contextWindow/maxTokens are grounded against live `claude --model <id> | ||
| * --output-format json` output (`modelUsage[id].contextWindow` / | ||
| * `.maxOutputTokens`) rather than copied from `anthropic.ts`, since the | ||
| * Agent SDK/CLI path reports different max output caps than the direct API | ||
| * for the same model name (e.g. 64K here vs. 128K direct for Opus/Sonnet 5/ | ||
| * Fable 5, 32K here vs. 64K direct for Haiku 4.5/Sonnet 4.6). | ||
| * | ||
| * `claude-sonnet-4-6[1m]` is a distinct, explicitly-selected model key (not | ||
| * a flag) that reports contextWindow: 1_000_000 vs. 200_000 for the bare | ||
| * `claude-sonnet-4-6` id. `claude-opus-4-6[1m]` was tried and did not | ||
| * resolve to a model (empty modelUsage), so no 1M variant is listed for it. | ||
| */ | ||
|
|
||
| export type ClaudeCodeModelId = keyof typeof claudeCodeModels | ||
|
|
||
| export const claudeCodeDefaultModelId: ClaudeCodeModelId = "claude-sonnet-5" | ||
|
|
||
| /** | ||
| * Models available through the Claude Code CLI subscription flow. | ||
| * Costs are 0 as they are covered by the subscription. | ||
| */ | ||
| export const claudeCodeModels = { | ||
| "claude-fable-5": { | ||
| maxTokens: 64_000, | ||
| contextWindow: 1_000_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| // List price: $10/$50 per million in/out, $12.50 cache write, $1.00 cache read. | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| cacheWritesPrice: 0, | ||
| cacheReadsPrice: 0, | ||
| supportsReasoningBudget: true, | ||
| supportsReasoningBinary: true, | ||
| supportsTemperature: false, | ||
| description: "Claude Fable 5 via Claude Code subscription (Pro/Max/Team/Enterprise).", | ||
| }, | ||
| "claude-opus-4-8": { | ||
| maxTokens: 64_000, | ||
| contextWindow: 1_000_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| // List price: $5/$25 per million in/out, $6.25 cache write, $0.50 cache read. | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| cacheWritesPrice: 0, | ||
| cacheReadsPrice: 0, | ||
| supportsReasoningBudget: true, | ||
| supportsReasoningBinary: true, | ||
| supportsTemperature: false, | ||
| description: "Claude Opus 4.8 via Claude Code subscription (Pro/Max/Team/Enterprise).", | ||
| }, | ||
| "claude-opus-4-7": { | ||
| maxTokens: 64_000, | ||
| contextWindow: 1_000_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| // List price: $5/$25 per million in/out, $6.25 cache write, $0.50 cache read. | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| cacheWritesPrice: 0, | ||
| cacheReadsPrice: 0, | ||
| supportsReasoningBudget: true, | ||
| supportsReasoningBinary: true, | ||
| supportsTemperature: false, | ||
| description: "Claude Opus 4.7 via Claude Code subscription (Pro/Max/Team/Enterprise).", | ||
| }, | ||
| "claude-opus-4-6": { | ||
| maxTokens: 64_000, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| // List price: $5/$25 per million in/out, $6.25 cache write, $0.50 cache read. | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| cacheWritesPrice: 0, | ||
| cacheReadsPrice: 0, | ||
| supportsReasoningBudget: true, | ||
| description: "Claude Opus 4.6 via Claude Code subscription (Pro/Max/Team/Enterprise).", | ||
| }, | ||
| "claude-sonnet-5": { | ||
| maxTokens: 64_000, | ||
| contextWindow: 1_000_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| // List price: $2/$10 per million in/out (introductory, through Aug 31, 2026), | ||
| // $2.50 cache write, $0.20 cache read. | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| cacheWritesPrice: 0, | ||
| cacheReadsPrice: 0, | ||
| supportsReasoningBudget: true, | ||
| supportsReasoningBinary: true, | ||
| supportsTemperature: false, | ||
| description: "Claude Sonnet 5 via Claude Code subscription (Pro/Max/Team/Enterprise).", | ||
| }, | ||
| "claude-sonnet-4-6": { | ||
| maxTokens: 32_000, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| // List price: $3/$15 per million in/out, $3.75 cache write, $0.30 cache read. | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| cacheWritesPrice: 0, | ||
| cacheReadsPrice: 0, | ||
| supportsReasoningBudget: true, | ||
| description: "Claude Sonnet 4.6 via Claude Code subscription (Pro/Max/Team/Enterprise).", | ||
| }, | ||
| "claude-sonnet-4-6[1m]": { | ||
| maxTokens: 32_000, | ||
| contextWindow: 1_000_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| // Same list price as claude-sonnet-4-6; [1m] only changes context window. | ||
| // Tiered pricing above 200K would apply on the direct Anthropic API path | ||
| // but subscription usage is $0 either way. | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| cacheWritesPrice: 0, | ||
| cacheReadsPrice: 0, | ||
| supportsReasoningBudget: true, | ||
| description: "Claude Sonnet 4.6 (1M context) via Claude Code subscription (Pro/Max/Team/Enterprise).", | ||
| }, | ||
| "claude-haiku-4-5-20251001": { | ||
| maxTokens: 32_000, | ||
| contextWindow: 200_000, | ||
| supportsImages: true, | ||
| supportsPromptCache: true, | ||
| // List price: $1/$5 per million in/out, $1.25 cache write, $0.10 cache read. | ||
| inputPrice: 0, | ||
| outputPrice: 0, | ||
| cacheWritesPrice: 0, | ||
| cacheReadsPrice: 0, | ||
| supportsReasoningBudget: true, | ||
| description: "Claude Haiku 4.5 via Claude Code subscription (Pro/Max/Team/Enterprise).", | ||
| }, | ||
| } as const satisfies Record<string, ModelInfo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why .js?