Skip to content

feat: add OrcaRouter support and update version to 0.1.80#220

Merged
yashdev9274 merged 1 commit into
mainfrom
supercode-cli
Jul 20, 2026
Merged

feat: add OrcaRouter support and update version to 0.1.80#220
yashdev9274 merged 1 commit into
mainfrom
supercode-cli

Conversation

@yashdev9274

@yashdev9274 yashdev9274 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Description

  • Introduced OrcaRouter API integration for chat and object generation.
  • Enhanced error handling for OrcaRouter API responses.
  • Updated environment variable management for OrcaRouter API keys.
  • Bumped supercode-cli version to 0.1.80 for new features and improvements.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no functional changes)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • bun test passes
  • bun run typecheck passes
  • bun run lint passes (if applicable)

Checklist:

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Summary by CodeRabbit

  • New Features

    • Added OrcaRouter as a supported AI provider for chat and structured responses.
    • Added MiniMax to the provider connection options.
    • Added support for separate production and development BYOK credentials.
    • Requests can now use a secure proxy when OrcaRouter credentials are unavailable.
  • Improvements

    • Provider credentials now resolve more reliably across configured environments.
    • Published a new SuperCode CLI release, version 0.1.80.

- Introduced OrcaRouter API integration for chat and object generation.
- Enhanced error handling for OrcaRouter API responses.
- Updated environment variable management for OrcaRouter API keys.
- Bumped supercode-cli version to 0.1.80 for new features and improvements.
@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
supercli Ready Ready Preview, Comment Jul 20, 2026 12:49pm
supercli-client Ready Ready Preview, Comment Jul 20, 2026 12:49pm
supercli-docs Ready Ready Preview, Comment Jul 20, 2026 12:49pm

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

MiniMax BYOK configuration and selection were added. OrcaRouter now supports direct streaming and structured requests, API-key precedence, and proxy fallback when no key is configured. The server package version was incremented to 0.1.80.

Changes

Provider support

Layer / File(s) Summary
Provider registration and key resolution
apps/supercode-cli/server/src/config/orcarouter.config.ts, apps/supercode-cli/server/src/cli/ai/provider.ts, apps/supercode-cli/server/src/lib/cli-config.ts, apps/supercode-cli/server/src/cli/commands/slashCommands/connect.ts
MiniMax selection and BYOK variables were added, while MiniMax and OrcaRouter key resolution now follows the updated environment-variable precedence.
OrcaRouter request handlers
apps/supercode-cli/server/src/index.ts
Chat streaming now handles text, tool calls, usage, and finish events from OrcaRouter; structured generation sends a non-streaming request and returns the response content.
Proxy fallback and package release
apps/supercode-cli/server/src/cli/ai/provider.ts, apps/supercode-cli/server/package.json
OrcaRouter uses ServerProxyService when no API key is configured, and the package version changes to 0.1.80.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ChatEndpoint
  participant OrcaRouterAPI
  participant UsageRecorder
  Client->>ChatEndpoint: provider orcarouter request
  ChatEndpoint->>OrcaRouterAPI: streaming chat completion
  OrcaRouterAPI-->>ChatEndpoint: SSE text, tool calls, and usage
  ChatEndpoint->>UsageRecorder: token usage and computed cost
  ChatEndpoint-->>Client: NDJSON text, tool-call, and finish events
Loading

Possibly related PRs

Poem

I’m a bunny with keys in my den,
MiniMax hops into the provider pen.
Orca streams words, tools, and cost,
Proxy paths help when keys are lost.
Version eighty blooms—thump, thump, hooray!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change by adding OrcaRouter support and noting the version bump.
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.
✨ 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 supercode-cli

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@yashdev9274
yashdev9274 merged commit 22e907f into main Jul 20, 2026
4 of 8 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
apps/supercode-cli/server/src/cli/ai/provider.ts (1)

87-99: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate proxy-provider construction for supercode and orcarouter.

The new orcarouter fallback branch (Lines 87-99) is structurally identical to the existing supercode branch (Lines 72-86), differing only in the provider name and comment. Consider extracting a small helper (e.g., buildProxyProvider(providerName, model, meta)) to avoid the duplication going forward.

♻️ Example helper extraction
+function buildProxyProvider(providerName: ModelProvider, model: string | undefined, meta: { defaultModel: string }): AIProvider {
+  const svc = new ServerProxyService(providerName, model || meta.defaultModel)
+  return {
+    name: providerName,
+    modelName: model || meta.defaultModel,
+    connectionType: "proxy",
+    sendMessage: (messages, onChunk, tools, onToolCall, signal, onReasoning, onToolResult, onStepFinish) =>
+      svc.sendMessage(messages, onChunk, tools, onToolCall, signal, onReasoning, onToolResult, onStepFinish),
+    generateObject: (schema, prompt) => svc.generateObject(schema, prompt),
+  }
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/supercode-cli/server/src/cli/ai/provider.ts` around lines 87 - 99,
Extract the duplicated proxy-provider construction from the existing supercode
and orcarouter branches into a shared helper, such as buildProxyProvider,
accepting the provider name, model, and meta. Have both branches call the helper
while preserving their provider-specific fallback behavior and comments.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/supercode-cli/server/src/cli/ai/provider.ts`:
- Line 58: Add a case for "minimax" in createProvider(), constructing and
returning MinimaxService with the resolved providerConfigs.minimax key. Preserve
the existing no-key validation and default error behavior for other providers.

In `@apps/supercode-cli/server/src/index.ts`:
- Around line 1166-1188: The non-streaming OrcaRouter request in the
“orcarouter” case lacks the required timeout. Update its fetch call to use the
same timeout mechanism and duration as the streaming OrcaRouter handler,
preserving the existing request and response handling.
- Around line 692-701: Update the OrcaRouter fetch call in the request handler
to use an AbortSignal with a finite timeout, ensuring hung or unreachable
streaming requests are aborted and handled through the existing error path.
Preserve the current request payload, headers, and non-OK response handling.
- Around line 763-766: Update the final finish event in the streaming response
to use the actual OrcaRouter finish_reason captured during streaming instead of
hardcoding "stop". Preserve the existing usage payload and ensure the streamed
reason is propagated for cases such as "length" and "content_filter".

---

Nitpick comments:
In `@apps/supercode-cli/server/src/cli/ai/provider.ts`:
- Around line 87-99: Extract the duplicated proxy-provider construction from the
existing supercode and orcarouter branches into a shared helper, such as
buildProxyProvider, accepting the provider name, model, and meta. Have both
branches call the helper while preserving their provider-specific fallback
behavior and comments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9de46f97-3bf6-4112-8823-3069f2e53e5f

📥 Commits

Reviewing files that changed from the base of the PR and between 6f514ac and fe4c30c.

📒 Files selected for processing (6)
  • apps/supercode-cli/server/package.json
  • apps/supercode-cli/server/src/cli/ai/provider.ts
  • apps/supercode-cli/server/src/cli/commands/slashCommands/connect.ts
  • apps/supercode-cli/server/src/config/orcarouter.config.ts
  • apps/supercode-cli/server/src/index.ts
  • apps/supercode-cli/server/src/lib/cli-config.ts

supercode: () => "",
google: () => process.env.GOOGLE_BYOK_PROD_KEY || process.env.GOOGLE_BYOK_DEV_KEY || config.googleApiKey,
minimax: () => minimaxConfig.apiKey,
minimax: () => process.env.MINIMAX_BYOK_PROD_KEY || process.env.MINIMAX_BYOK_DEV_KEY || minimaxConfig.apiKey,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm whether provider.ts routes "minimax" to a direct service.
rg -n 'case "minimax"' apps/supercode-cli/server/src/cli/ai/provider.ts
rg -n 'MinimaxService' apps/supercode-cli/server/src/cli/ai/provider.ts
ast-grep run --pattern 'switch ($P) { $$$ }' --lang ts apps/supercode-cli/server/src/cli/ai/provider.ts

Repository: yashdev9274/supercli

Length of output: 6657


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,240p' apps/supercode-cli/server/src/cli/ai/provider.ts
printf '\n--- connect.ts ---\n'
sed -n '1,220p' apps/supercode-cli/server/src/cli/ai/connect.ts
printf '\n--- minimax-service.ts ---\n'
sed -n '1,220p' apps/supercode-cli/server/src/cli/ai/minimax-service.ts

Repository: yashdev9274/supercli

Length of output: 9268


Add a minimax switch branch

providerConfigs.minimax now returns a BYOK/config key, but createProvider() has no case "minimax". With a valid key, this skips the no-key path and falls through to the default "paused or unavailable" error. Wire MinimaxService into the switch so MiniMax can actually be selected.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/supercode-cli/server/src/cli/ai/provider.ts` at line 58, Add a case for
"minimax" in createProvider(), constructing and returning MinimaxService with
the resolved providerConfigs.minimax key. Preserve the existing no-key
validation and default error behavior for other providers.

Comment on lines +692 to +701
const response = await fetch("https://api.orcarouter.ai/v1/chat/completions", {
method: "POST",
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
body: JSON.stringify(bodyObj),
})
if (!response.ok) {
const errText = await response.text().catch(() => "unknown error")
res.status(response.status).json({ error: `OrcaRouter API ${response.status}: ${errText}` })
return
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

No timeout on the OrcaRouter fetch call.

The streaming request to https://api.orcarouter.ai/v1/chat/completions has no AbortSignal/timeout. If OrcaRouter hangs or is unreachable, this request-handling thread can block indefinitely, tying up server resources with no way for the client to recover other than disconnecting.

🛡️ Suggested fix
+        const controller = new AbortController()
+        const timeoutId = setTimeout(() => controller.abort(), 60_000)
         const response = await fetch("https://api.orcarouter.ai/v1/chat/completions", {
           method: "POST",
           headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
           body: JSON.stringify(bodyObj),
+          signal: controller.signal,
         })
+        clearTimeout(timeoutId)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const response = await fetch("https://api.orcarouter.ai/v1/chat/completions", {
method: "POST",
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
body: JSON.stringify(bodyObj),
})
if (!response.ok) {
const errText = await response.text().catch(() => "unknown error")
res.status(response.status).json({ error: `OrcaRouter API ${response.status}: ${errText}` })
return
}
const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), 60_000)
const response = await fetch("https://api.orcarouter.ai/v1/chat/completions", {
method: "POST",
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
body: JSON.stringify(bodyObj),
signal: controller.signal,
})
clearTimeout(timeoutId)
if (!response.ok) {
const errText = await response.text().catch(() => "unknown error")
res.status(response.status).json({ error: `OrcaRouter API ${response.status}: ${errText}` })
return
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/supercode-cli/server/src/index.ts` around lines 692 - 701, Update the
OrcaRouter fetch call in the request handler to use an AbortSignal with a finite
timeout, ensuring hung or unreachable streaming requests are aborted and handled
through the existing error path. Preserve the current request payload, headers,
and non-OK response handling.

Comment on lines +763 to +766
res.write(JSON.stringify({
type: "finish", reason: "stop",
usage: { inputTokens, outputTokenDetails: { textTokens: outputTokens, reasoningTokens: 0 }, outputTokens, inputTokenDetails: { noCacheTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 }, totalTokens: inputTokens + outputTokens }
}) + "\n")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Finish reason always reported as "stop".

The final finish event hardcodes reason: "stop" regardless of the actual finish_reason streamed by OrcaRouter (e.g., "length" or "content_filter"). Callers lose the ability to distinguish a truncated response from a normal completion.

🐛 Suggested fix
+        let lastFinishReason = "stop"
         while (true) {
           ...
               const finishReason = data.choices?.[0]?.finish_reason
+              if (finishReason) lastFinishReason = finishReason
               if (finishReason === "tool_calls") {
         ...
         res.write(JSON.stringify({
-          type: "finish", reason: "stop",
+          type: "finish", reason: lastFinishReason === "tool_calls" ? "tool-calls" : lastFinishReason,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
res.write(JSON.stringify({
type: "finish", reason: "stop",
usage: { inputTokens, outputTokenDetails: { textTokens: outputTokens, reasoningTokens: 0 }, outputTokens, inputTokenDetails: { noCacheTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 }, totalTokens: inputTokens + outputTokens }
}) + "\n")
res.write(JSON.stringify({
type: "finish", reason: lastFinishReason === "tool_calls" ? "tool-calls" : lastFinishReason,
usage: { inputTokens, outputTokenDetails: { textTokens: outputTokens, reasoningTokens: 0 }, outputTokens, inputTokenDetails: { noCacheTokens: 0, cacheReadTokens: 0, cacheWriteTokens: 0 }, totalTokens: inputTokens + outputTokens }
}) + "\n")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/supercode-cli/server/src/index.ts` around lines 763 - 766, Update the
final finish event in the streaming response to use the actual OrcaRouter
finish_reason captured during streaming instead of hardcoding "stop". Preserve
the existing usage payload and ensure the streamed reason is propagated for
cases such as "length" and "content_filter".

Comment on lines +1166 to +1188
case "orcarouter": {
const apiKey = process.env.ORCAROUTER_API_KEY
if (!apiKey) { res.status(500).json({ error: "OrcaRouter not configured on server" }); return }
const modelName = modelParam || "openai/gpt-4o-mini"
const response = await fetch("https://api.orcarouter.ai/v1/chat/completions", {
method: "POST",
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
body: JSON.stringify({
model: modelName,
messages: [{ role: "user", content: prompt }],
max_tokens: getModelMaxTokens(modelName),
stream: false,
}),
})
if (!response.ok) {
const errText = await response.text().catch(() => "unknown error")
res.status(response.status).json({ error: `OrcaRouter API ${response.status}: ${errText}` })
return
}
const data: any = await response.json()
res.json({ object: { content: data.choices?.[0]?.message?.content || "" } })
break
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Non-streaming OrcaRouter call also lacks a timeout — shares root cause with the streaming handler.

See the fetch-timeout comment on Lines 692-701 (same issue, same fix pattern applies here).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/supercode-cli/server/src/index.ts` around lines 1166 - 1188, The
non-streaming OrcaRouter request in the “orcarouter” case lacks the required
timeout. Update its fetch call to use the same timeout mechanism and duration as
the streaming OrcaRouter handler, preserving the existing request and response
handling.

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