feat(claude-code): add model catalog and provider settings types#801
feat(claude-code): add model catalog and provider settings types#801edelauna wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughAdds a new "claude-code" provider: a model catalog with zero-cost pricing, Zod schema wiring into provider-settings (discriminated and non-discriminated), default model id resolution, webview ChangesClaude Code provider integration
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant Webview as useSelectedModel
participant Types as providerSettingsSchema
participant Catalog as claudeCodeModels
Webview->>Types: validate apiConfiguration (apiProvider: "claude-code")
Types-->>Webview: validated settings
Webview->>Catalog: lookup apiModelId or claudeCodeDefaultModelId
Catalog-->>Webview: ModelInfo (id, pricing, capabilities)
Webview-->>Webview: return { provider, id, info }
Possibly related issues
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
0c5fead to
4083b40
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4083b40 to
cf63e5f
Compare
| import { describe, it, expect } from "vitest" | ||
|
|
||
| import { claudeCodeModels, claudeCodeDefaultModelId } from "../providers/claude-code.js" | ||
| import { providerSettingsSchema, providerSettingsSchemaDiscriminated } from "../provider-settings.js" |
navedmerchant
left a comment
There was a problem hiding this comment.
lets remove the .js from the imports otherwise looks good to merge
Related GitHub Issue
Closes: #757
Description
Adds the
@roo-code/typesdefinitions for the new "Claude Code (Subscription)" provider, the first of 7 sub-issues under the #756 epic. This is types/schema only — no runtime handler, UI, or auth wiring yet (those land in #758-763).packages/types/src/providers/claude-code.ts(new):claudeCodeModelscatalog (7 models: Fable 5, Opus 4.8/4.7/4.6, Sonnet 5, Sonnet 4.6 + its[1m]1M-context variant, Haiku 4.5),ClaudeCodeModelId,claudeCodeDefaultModelId. RuntimeinputPrice/outputPriceare0(subscription-covered); real list prices are recorded as comments for reference.packages/types/src/provider-settings.ts: adds"claude-code"to the provider union,claudeCodeSchema(apiModelId+ optionalclaudeCodeCliPath, no API key field), wired into the discriminated union,modelIdKeysByProvider, andMODELS_BY_PROVIDER.packages/types/src/providers/index.ts: export +getProviderDefaultModelIdwiring.webview-ui/src/components/ui/hooks/useSelectedModel.ts: added aclaude-codecase. This was required, not optional scope creep — adding"claude-code"toProviderNamebroke an existing exhaustiveness (satisfies) check in this hook's default branch, so a matching case was needed to keep the build green.Model catalog grounding:
contextWindow/maxTokensvalues are verified against liveclaude --model <id> --output-format jsonoutput (modelUsage[id].contextWindow/.maxOutputTokens) rather than copied fromanthropic.ts, since the Agent SDK/CLI path reports different (generally lower) max-output caps than the direct API for the same model name. Pricing was cross-checked against Anthropic's live pricing page.Test Procedure
packages/types/src/__tests__/claude-code.spec.ts(new): default model exists, all models haveinputPrice/outputPriceof0, schema accepts empty object /claudeCodeCliPath, rejects unknown keys in strict mode, and the discriminated-union arm (apiProvider: "claude-code") parses correctly with and withoutclaudeCodeCliPath.webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts: added coverage for the newclaude-codebranch (default model, custom model ID) to satisfy patch coverage.check-types(11 packages) and test suites for@roo-code/typesand@roo-code/vscode-webviewpass locally and in CI.Pre-Submission Checklist
Documentation Updates
Additional Notes
This is a types-only foundation for the epic in #756. Downstream sub-issues (#758 message conversion, #759 core handler, #760 usage tracking, #761 CLI detection, #762 settings UI, #763 usage dashboard) build on top of what's added here.
Summary by CodeRabbit
New Features
Bug Fixes