Skip to content

feat(server): migrate claude-provider to @protolabsai/sdk/anthropic-compat#3628

Merged
mabry1985 merged 1 commit into
mainfrom
feat/rip-anthropic-sdk-final-cutover
May 22, 2026
Merged

feat(server): migrate claude-provider to @protolabsai/sdk/anthropic-compat#3628
mabry1985 merged 1 commit into
mainfrom
feat/rip-anthropic-sdk-final-cutover

Conversation

@mabry1985
Copy link
Copy Markdown
Contributor

Why

PR 3 of the namesake SDK cutover. PRs #3625 + #3626 added ProtoProvider and made it the primary driver. This PR migrates the runtime query() call in ClaudeProvider from @anthropic-ai/claude-agent-sdk to @protolabsai/sdk/anthropic-compat — the drop-in compatibility subpath we shipped in protoCLI #241 + released as @protolabsai/sdk@0.3.0.

Net effect: the only remaining caller of @anthropic-ai/claude-agent-sdk is sdk-options.ts, which still uses it for type imports only. PR 4 finishes that and removes the dep entirely.

Changes

apps/server/package.json — bump @protolabsai/sdk to ^0.3.0 (the version with the anthropic-compat subpath).

apps/server/src/providers/claude-provider.ts — swap the imports:

- import { query, type Options, ... } from '@anthropic-ai/claude-agent-sdk';
+ import { query, type Options, ... } from '@protolabsai/sdk/anthropic-compat';

Three small adapter fixes for shape mismatches between our ExecuteOptions and the compat layer's narrower Options:

  • systemPrompt — only passed through when it's a string. The SystemPromptPreset shape (Claude SDK's { preset: 'claude_code' }) isn't surfaced through the compat layer; callers needing presets should provide a string at the ExecuteOptions layer.
  • envbuildEnv() returns Record<string, string | undefined>. The compat layer's env field is Record<string, string>. Filter undefined values before assignment.
  • mcpServers + outputFormat — cast to compat's looser types. The runtime translation in the compat layer passes both through verbatim; the type-level cast just bridges the structured McpServerConfig union from @protolabsai/types to the compat layer's Record<string, unknown> shape.

apps/server/tests/unit/providers/claude-provider.test.tsvi.mock target updated to @protolabsai/sdk/anthropic-compat so the test mocks intercept the same import the production code now uses.

Out of scope (deferred to PR 4)

apps/server/src/lib/sdk-options.ts still imports Options, HookCallback, PostToolUseHookInput from @anthropic-ai/claude-agent-sdk. The compat layer's current typing is too narrow to absorb these as-is:

  • HookCallback in the compat layer is (input) => ... (1 arg); Claude SDK's actual signature is (input, toolUseID, options) => ... (3 args).
  • mcpServers field types differ between @protolabsai/types's structured McpServerConfig union and the compat's Record<string, unknown>.
  • systemPrompt field accepts string | SystemPromptConfig in usage; compat accepts only string.
  • outputFormat field accepts a structured { type: 'json_schema', schema }; compat accepts only string.

Each of these is a widening change to @protolabsai/sdk/anthropic-compat's .d.ts.template in protoCLI. Filing follow-ups; until they ship in @protolabsai/sdk@0.3.1, sdk-options.ts keeps its current import path. Functionally fine — the type-level imports compile to no runtime code, and the runtime query() call on the chat/agent path now goes through the compat layer via ClaudeProvider.

Validation

  • npm run typecheck clean across all 21 workspaces
  • vitest run in apps/server: 3431 passed, 23 skipped, 0 failed
  • claude-provider's own 34 tests pass with the new mock target

After this lands

PR 4 (follow-up, after compat layer widening in protoCLI):

  1. Widen HookCallback, mcpServers, systemPrompt, outputFormat types in the compat .d.ts.template
  2. Release @protolabsai/sdk@0.3.1
  3. Migrate sdk-options.ts imports
  4. Delete verify-claude-auth.ts + UI call sites
  5. Remove @anthropic-ai/claude-agent-sdk from apps/server/package.json

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Warning

Review limit reached

@mabry1985, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 2 reviews/hour. Refill in 15 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6ef9304b-fb61-4b1d-bc69-8122aecb9326

📥 Commits

Reviewing files that changed from the base of the PR and between 43003f3 and 7e9f0bf.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • apps/server/package.json
  • apps/server/src/lib/sdk-options.ts
  • apps/server/src/providers/claude-provider.ts
  • apps/server/tests/unit/providers/claude-provider.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rip-anthropic-sdk-final-cutover

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

@github-actions
Copy link
Copy Markdown
Contributor

Code Review — ? finding(s)

Async review running parallel to CodeRabbit. Findings are advisory; not all are merge blockers.

protoLabs Code Review Report

  • Generated: 2026-05-22T22:34:31Z
  • Git head: fb35454b4d1f108d7d6ec95a0277b089c867d954
  • Features mapped: 3
  • Findings: 0

No findings recorded.

@mabry1985 mabry1985 merged commit 581bf0f into main May 22, 2026
7 checks passed
@mabry1985 mabry1985 deleted the feat/rip-anthropic-sdk-final-cutover branch May 22, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant