feat(server): migrate claude-provider to @protolabsai/sdk/anthropic-compat#3628
Conversation
|
Warning Review limit reached
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 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Code Review — ? finding(s)
protoLabs Code Review Report
No findings recorded. |
Why
PR 3 of the namesake SDK cutover. PRs #3625 + #3626 added
ProtoProviderand made it the primary driver. This PR migrates the runtimequery()call inClaudeProviderfrom@anthropic-ai/claude-agent-sdkto@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-sdkissdk-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/sdkto^0.3.0(the version with the anthropic-compat subpath).apps/server/src/providers/claude-provider.ts— swap the imports:Three small adapter fixes for shape mismatches between our
ExecuteOptionsand the compat layer's narrowerOptions:systemPrompt— only passed through when it's astring. TheSystemPromptPresetshape (Claude SDK's{ preset: 'claude_code' }) isn't surfaced through the compat layer; callers needing presets should provide a string at the ExecuteOptions layer.env—buildEnv()returnsRecord<string, string | undefined>. The compat layer'senvfield isRecord<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 structuredMcpServerConfigunion from@protolabsai/typesto the compat layer'sRecord<string, unknown>shape.apps/server/tests/unit/providers/claude-provider.test.ts—vi.mocktarget updated to@protolabsai/sdk/anthropic-compatso 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.tsstill importsOptions,HookCallback,PostToolUseHookInputfrom@anthropic-ai/claude-agent-sdk. The compat layer's current typing is too narrow to absorb these as-is:HookCallbackin the compat layer is(input) => ...(1 arg); Claude SDK's actual signature is(input, toolUseID, options) => ...(3 args).mcpServersfield types differ between@protolabsai/types's structuredMcpServerConfigunion and the compat'sRecord<string, unknown>.systemPromptfield acceptsstring | SystemPromptConfigin usage; compat accepts onlystring.outputFormatfield accepts a structured{ type: 'json_schema', schema }; compat accepts onlystring.Each of these is a widening change to
@protolabsai/sdk/anthropic-compat's.d.ts.templatein protoCLI. Filing follow-ups; until they ship in@protolabsai/sdk@0.3.1,sdk-options.tskeeps its current import path. Functionally fine — the type-level imports compile to no runtime code, and the runtimequery()call on the chat/agent path now goes through the compat layer viaClaudeProvider.Validation
npm run typecheckclean across all 21 workspacesvitest runin apps/server: 3431 passed, 23 skipped, 0 failedAfter this lands
PR 4 (follow-up, after compat layer widening in protoCLI):
HookCallback,mcpServers,systemPrompt,outputFormattypes in the compat .d.ts.template@protolabsai/sdk@0.3.1sdk-options.tsimportsverify-claude-auth.ts+ UI call sites@anthropic-ai/claude-agent-sdkfromapps/server/package.json