feat: replace Claude Code with OpenCode + Vercel AI Gateway#23
Conversation
- Add installOpenCode.ts to install opencode-ai CLI globally - Add writeOpenCodeConfig.ts to write opencode.json with Vercel AI Gateway provider config - Update runSandboxCommandTask to use OpenCode instead of Claude Code - Requires VERCEL_AI_GATEWAY_API_KEY env var in Trigger.dev Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, 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 the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThis pull request introduces two new modules ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/tasks/runSandboxCommandTask.ts (1)
36-40:⚠️ Potential issue | 🟠 Major
VERCEL_AI_GATEWAY_API_KEYis not validated despite being documented as required.The docstring at Lines 19-20 lists
VERCEL_AI_GATEWAY_API_KEYas a required env var, but the guard at Lines 36-40 only checks the other three. This is the natural place to add the check (see Option B in thewriteOpenCodeConfig.tscomment).Proposed fix
const token = process.env.VERCEL_TOKEN; const teamId = process.env.VERCEL_TEAM_ID; const projectId = process.env.VERCEL_PROJECT_ID; + const aiGatewayKey = process.env.VERCEL_AI_GATEWAY_API_KEY; - if (!token || !teamId || !projectId) { + if (!token || !teamId || !projectId || !aiGatewayKey) { throw new Error( - "Missing Vercel credentials. Set VERCEL_TOKEN, VERCEL_TEAM_ID, and VERCEL_PROJECT_ID." + "Missing Vercel credentials. Set VERCEL_TOKEN, VERCEL_TEAM_ID, VERCEL_PROJECT_ID, and VERCEL_AI_GATEWAY_API_KEY." ); }
🤖 Fix all issues with AI agents
In `@src/sandboxes/writeOpenCodeConfig.ts`:
- Around line 10-24: The writeOpenCodeConfig function currently sets apiKey:
process.env.VERCEL_AI_GATEWAY_API_KEY which may be undefined and will be dropped
by JSON.stringify; add a fail-fast validation in writeOpenCodeConfig that checks
process.env.VERCEL_AI_GATEWAY_API_KEY (the VERCEL_AI_GATEWAY_API_KEY env var)
and throw a clear Error (or reject) with a descriptive message if missing, so
the missing credential is caught close to usage; alternatively, if you prefer
centralized checks, add the same validation in runSandboxCommandTask alongside
other env var validations.
🧹 Nitpick comments (1)
src/sandboxes/installOpenCode.ts (1)
15-15: Pinopencode-aito a specific version range instead of@latest.Using
@latestin an automated pipeline means any breaking release will silently break all new sandbox runs. Since the package is currently at0.6.4, pinning to a caret range (e.g.,opencode-ai@^0.6) would allow security patches and minor updates without risking breaking changes.
installClaudeCode.ts and runClaudeCode.ts are no longer imported after switching to OpenCode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
installOpenCode.tsinstallsopencode-aiCLI globally in the sandboxwriteOpenCodeConfig.tswritesopencode.jsonwith Vercel AI Gateway provider andanthropic/claude-sonnet-4modelrunSandboxCommandTask.tsto call new install + config functionsEnvironment Variables
VERCEL_AI_GATEWAY_API_KEY— must be set in Trigger.dev env vars (get from Vercel dashboard > AI Gateway > API keys)Test plan
VERCEL_AI_GATEWAY_API_KEYin Trigger.dev environmentopencode.jsonis written in the sandboxrun-sandbox-commandtask completes successfully🤖 Generated with Claude Code
Summary by CodeRabbit