Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit f2a3282

Browse files
committed
feat(cli): improve CLI agent and command handling
1 parent cb83656 commit f2a3282

6 files changed

Lines changed: 23 additions & 1 deletion

File tree

apps/cli/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ Tokens are valid for 90 days. The CLI will prompt you to re-authenticate when yo
190190
| `-k, --api-key <key>` | API key for the LLM provider | From env var |
191191
| `--provider <provider>` | API provider (roo, anthropic, openai, openrouter, etc.) | `openrouter` (or `roo` if authenticated) |
192192
| `-m, --model <model>` | Model to use | `anthropic/claude-opus-4.6` |
193+
| `-b, --base-url <url>` | Base URL for the LLM provider (e.g., for OpenAI-compatible APIs) | None |
193194
| `--mode <mode>` | Mode to start in (code, architect, ask, debug, etc.) | `code` |
194195
| `--terminal-shell <path>` | Absolute shell path for inline terminal command execution | Auto-detected shell |
195196
| `-r, --reasoning-effort <effort>` | Reasoning effort level (unspecified, disabled, none, minimal, low, medium, high, xhigh) | `medium` |

apps/cli/src/agent/extension-host.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export interface ExtensionHostOptions {
7171
provider: SupportedProvider
7272
apiKey?: string
7373
model: string
74+
baseUrl?: string
7475
workspacePath: string
7576
extensionPath: string
7677
nonInteractive?: boolean
@@ -227,7 +228,12 @@ export class ExtensionHost extends EventEmitter implements ExtensionHostInterfac
227228
experiments: {
228229
customTools: true,
229230
},
230-
...getProviderSettings(this.options.provider, this.options.apiKey, this.options.model),
231+
...getProviderSettings(
232+
this.options.provider,
233+
this.options.apiKey,
234+
this.options.model,
235+
this.options.baseUrl,
236+
),
231237
}
232238

233239
this.initialSettings = this.options.nonInteractive

apps/cli/src/commands/cli/run.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export async function run(promptArg: string | undefined, flagOptions: FlagOption
219219
user: null,
220220
provider: effectiveProvider,
221221
model: effectiveModel,
222+
baseUrl: flagOptions.baseUrl,
222223
workspacePath: effectiveWorkspacePath,
223224
extensionPath: path.resolve(flagOptions.extension || getDefaultExtensionPath(__dirname)),
224225
nonInteractive: !effectiveRequireApproval,

apps/cli/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ program
4747
.option("-k, --api-key <key>", "API key for the LLM provider")
4848
.option("--provider <provider>", "API provider (roo, anthropic, openai, openrouter, etc.)")
4949
.option("-m, --model <model>", "Model to use", DEFAULT_FLAGS.model)
50+
.option("-b, --base-url <url>", "Base URL for the LLM provider (e.g., for OpenAI-compatible APIs)")
5051
.option("--mode <mode>", "Mode to start in (code, architect, ask, debug, etc.)", DEFAULT_FLAGS.mode)
5152
.option("--terminal-shell <path>", "Absolute path to shell executable for inline terminal commands")
5253
.option(

apps/cli/src/lib/utils/provider.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { SupportedProvider } from "@/types/index.js"
55
const envVarMap: Record<SupportedProvider, string> = {
66
anthropic: "ANTHROPIC_API_KEY",
77
"openai-native": "OPENAI_API_KEY",
8+
openai: "OPENAI_API_KEY",
89
gemini: "GOOGLE_API_KEY",
910
openrouter: "OPENROUTER_API_KEY",
1011
"vercel-ai-gateway": "VERCEL_AI_GATEWAY_API_KEY",
@@ -24,6 +25,7 @@ export function getProviderSettings(
2425
provider: SupportedProvider,
2526
apiKey: string | undefined,
2627
model: string | undefined,
28+
baseUrl: string | undefined,
2729
): RooCodeSettings {
2830
const config: RooCodeSettings = { apiProvider: provider }
2931

@@ -32,17 +34,25 @@ export function getProviderSettings(
3234
if (apiKey) config.apiKey = apiKey
3335
if (model) config.apiModelId = model
3436
break
37+
case "openai":
38+
if (apiKey) config.openAiApiKey = apiKey
39+
if (model) config.openAiModelId = model
40+
if (baseUrl) config.openAiBaseUrl = baseUrl
41+
break
3542
case "openai-native":
3643
if (apiKey) config.openAiNativeApiKey = apiKey
3744
if (model) config.apiModelId = model
45+
if (baseUrl) config.openAiNativeBaseUrl = baseUrl
3846
break
3947
case "gemini":
4048
if (apiKey) config.geminiApiKey = apiKey
4149
if (model) config.apiModelId = model
50+
if (baseUrl) config.googleGeminiBaseUrl = baseUrl
4251
break
4352
case "openrouter":
4453
if (apiKey) config.openRouterApiKey = apiKey
4554
if (model) config.openRouterModelId = model
55+
if (baseUrl) config.openRouterBaseUrl = baseUrl
4656
break
4757
case "vercel-ai-gateway":
4858
if (apiKey) config.vercelAiGatewayApiKey = apiKey
@@ -55,6 +65,7 @@ export function getProviderSettings(
5565
default:
5666
if (apiKey) config.apiKey = apiKey
5767
if (model) config.apiModelId = model
68+
if (baseUrl) config.openAiBaseUrl = baseUrl
5869
}
5970

6071
return config

apps/cli/src/types/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { OutputFormat } from "./json-events.js"
44
export const supportedProviders = [
55
"anthropic",
66
"openai-native",
7+
"openai",
78
"gemini",
89
"openrouter",
910
"vercel-ai-gateway",
@@ -34,6 +35,7 @@ export type FlagOptions = {
3435
apiKey?: string
3536
provider?: SupportedProvider
3637
model?: string
38+
baseUrl?: string
3739
mode?: string
3840
terminalShell?: string
3941
reasoningEffort?: ReasoningEffortFlagOptions

0 commit comments

Comments
 (0)