Skip to content

feat(claude-code): add model catalog and provider settings types#801

Open
edelauna wants to merge 1 commit into
mainfrom
feat/claude-code-provider-types
Open

feat(claude-code): add model catalog and provider settings types#801
edelauna wants to merge 1 commit into
mainfrom
feat/claude-code-provider-types

Conversation

@edelauna

@edelauna edelauna commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #757

Description

Adds the @roo-code/types definitions 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): claudeCodeModels catalog (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. Runtime inputPrice/outputPrice are 0 (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 + optional claudeCodeCliPath, no API key field), wired into the discriminated union, modelIdKeysByProvider, and MODELS_BY_PROVIDER.
  • packages/types/src/providers/index.ts: export + getProviderDefaultModelId wiring.
  • webview-ui/src/components/ui/hooks/useSelectedModel.ts: added a claude-code case. This was required, not optional scope creep — adding "claude-code" to ProviderName broke 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/maxTokens values are verified 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 (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 have inputPrice/outputPrice of 0, schema accepts empty object / claudeCodeCliPath, rejects unknown keys in strict mode, and the discriminated-union arm (apiProvider: "claude-code") parses correctly with and without claudeCodeCliPath.
  • webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts: added coverage for the new claude-code branch (default model, custom model ID) to satisfy patch coverage.
  • Full monorepo check-types (11 packages) and test suites for @roo-code/types and @roo-code/vscode-webview pass locally and in CI.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

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

    • Added support for selecting and using the Claude Code provider in provider settings and model selection.
    • Introduced a default Claude Code model and a supported model list with capability details.
  • Bug Fixes

    • Improved validation so provider settings accept valid Claude Code configurations and reject unexpected fields.
    • Updated model selection to correctly return the chosen Claude Code model or its default when none is set.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds 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 useSelectedModel support, plus tests. Also updates existing import/export tests to use generic removed-provider identifiers instead of claude-code.

Changes

Claude Code provider integration

Layer / File(s) Summary
Model catalog
packages/types/src/providers/claude-code.ts
Defines ClaudeCodeModelId, claudeCodeDefaultModelId ("claude-sonnet-5"), and claudeCodeModels with per-model capabilities and zero pricing.
Schema and registry wiring
packages/types/src/provider-settings.ts
Adds "claude-code" to providerNames, new claudeCodeSchema, wires it into discriminated/non-discriminated providerSettingsSchema, updates modelIdKeysByProvider and MODELS_BY_PROVIDER.
Default model resolution and catalog tests
packages/types/src/providers/index.ts, packages/types/src/__tests__/claude-code.spec.ts
Re-exports claude-code module, adds default-model-id switch case, and adds tests for model pricing defaults and schema validation.
Webview model selection
webview-ui/src/components/ui/hooks/useSelectedModel.ts, webview-ui/src/components/ui/hooks/__tests__/useSelectedModel.spec.ts
Adds a claude-code switch case resolving selected model id/info, with tests for default and custom model selection.
Import/export test fixture updates
src/core/config/__tests__/importExport.spec.ts
Replaces claude-code as example invalid/removed provider with generic identifiers in fixtures and assertions.

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 }
Loading

Possibly related issues

Suggested labels: awaiting-review

Suggested reviewers: taltas, JamesRobert20, hannesrudolph, navedmerchant

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding Claude Code model catalog and provider settings types.
Description check ✅ Passed The description matches the template well, including the linked issue, implementation summary, test procedure, checklist, and documentation notes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/claude-code-provider-types

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@edelauna edelauna force-pushed the feat/claude-code-provider-types branch from 0c5fead to 4083b40 Compare July 4, 2026 18:00
@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@edelauna edelauna force-pushed the feat/claude-code-provider-types branch from 4083b40 to cf63e5f Compare July 4, 2026 18:24
@edelauna edelauna marked this pull request as ready for review July 4, 2026 18:30
@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 4, 2026
import { describe, it, expect } from "vitest"

import { claudeCodeModels, claudeCodeDefaultModelId } from "../providers/claude-code.js"
import { providerSettingsSchema, providerSettingsSchemaDiscriminated } from "../provider-settings.js"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why .js?

@navedmerchant navedmerchant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove the .js from the imports otherwise looks good to merge

@github-actions github-actions Bot added awaiting-author PR is waiting for the author to address requested changes has-conflicts PR has merge conflicts with the base branch and removed awaiting-review PR changes are ready and waiting for maintainer re-review awaiting-author PR is waiting for the author to address requested changes labels Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has-conflicts PR has merge conflicts with the base branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[claude-code] Add model catalog and provider settings types

2 participants