Skip to content

Commit 0616d33

Browse files
committed
Add support for Sonic model
1 parent 87c42c1 commit 0616d33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+293
-56
lines changed

packages/types/src/provider-settings.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const providerNames = [
4747
"zai",
4848
"fireworks",
4949
"io-intelligence",
50+
"roo",
5051
] as const
5152

5253
export const providerNamesSchema = z.enum(providerNames)
@@ -288,6 +289,10 @@ const ioIntelligenceSchema = apiModelIdProviderModelSchema.extend({
288289
ioIntelligenceApiKey: z.string().optional(),
289290
})
290291

292+
const rooSchema = apiModelIdProviderModelSchema.extend({
293+
// No additional fields needed - uses cloud authentication
294+
})
295+
291296
const defaultSchema = z.object({
292297
apiProvider: z.undefined(),
293298
})
@@ -324,6 +329,7 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
324329
zaiSchema.merge(z.object({ apiProvider: z.literal("zai") })),
325330
fireworksSchema.merge(z.object({ apiProvider: z.literal("fireworks") })),
326331
ioIntelligenceSchema.merge(z.object({ apiProvider: z.literal("io-intelligence") })),
332+
rooSchema.merge(z.object({ apiProvider: z.literal("roo") })),
327333
defaultSchema,
328334
])
329335

@@ -360,6 +366,7 @@ export const providerSettingsSchema = z.object({
360366
...zaiSchema.shape,
361367
...fireworksSchema.shape,
362368
...ioIntelligenceSchema.shape,
369+
...rooSchema.shape,
363370
...codebaseIndexProviderSchema.shape,
364371
})
365372

packages/types/src/providers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ export * from "./xai.js"
2525
export * from "./doubao.js"
2626
export * from "./zai.js"
2727
export * from "./fireworks.js"
28+
export * from "./roo.js"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { ModelInfo } from "../model.js"
2+
3+
// Roo provider with single model
4+
export type RooModelId = "roo/sonic"
5+
6+
export const rooDefaultModelId: RooModelId = "roo/sonic"
7+
8+
export const rooModels = {
9+
"roo/sonic": {
10+
maxTokens: 8192,
11+
contextWindow: 262_144,
12+
supportsImages: false,
13+
supportsPromptCache: false,
14+
inputPrice: 0,
15+
outputPrice: 0,
16+
description:
17+
"Stealth coding model with 262K context window, accessible for free through Roo Code Cloud for a limited time. (Note: prompts and completions are logged by the model creator and used to improve the model.)",
18+
},
19+
} as const satisfies Record<string, ModelInfo>

src/api/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
DoubaoHandler,
3636
ZAiHandler,
3737
FireworksHandler,
38+
RooHandler,
3839
} from "./providers"
3940
import { NativeOllamaHandler } from "./providers/native-ollama"
4041

@@ -140,6 +141,8 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
140141
return new FireworksHandler(options)
141142
case "io-intelligence":
142143
return new IOIntelligenceHandler(options)
144+
case "roo":
145+
return new RooHandler(options)
143146
default:
144147
apiProvider satisfies "gemini-cli" | undefined
145148
return new AnthropicHandler(options)

src/api/providers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ export { VsCodeLmHandler } from "./vscode-lm"
2929
export { XAIHandler } from "./xai"
3030
export { ZAiHandler } from "./zai"
3131
export { FireworksHandler } from "./fireworks"
32+
export { RooHandler } from "./roo"

src/api/providers/roo.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { rooDefaultModelId, rooModels, type RooModelId } from "@roo-code/types"
2+
import { CloudService } from "@roo-code/cloud"
3+
4+
import type { ApiHandlerOptions } from "../../shared/api"
5+
import { BaseOpenAiCompatibleProvider } from "./base-openai-compatible-provider"
6+
import { t } from "../../i18n"
7+
8+
export class RooHandler extends BaseOpenAiCompatibleProvider<RooModelId> {
9+
constructor(options: ApiHandlerOptions) {
10+
// Check if CloudService is available and get the session token
11+
if (!CloudService.hasInstance()) {
12+
throw new Error(t("common:errors.roo.authenticationRequired"))
13+
}
14+
15+
const sessionToken = CloudService.instance.authService?.getSessionToken()
16+
17+
if (!sessionToken) {
18+
throw new Error(t("common:errors.roo.authenticationRequired"))
19+
}
20+
21+
super({
22+
...options,
23+
providerName: "Roo Code Cloud",
24+
baseURL: "https://api.roocode.com/v1",
25+
apiKey: sessionToken,
26+
defaultProviderModelId: rooDefaultModelId,
27+
providerModels: rooModels,
28+
defaultTemperature: 0.7,
29+
})
30+
}
31+
32+
override getModel() {
33+
const modelId = this.options.apiModelId || rooDefaultModelId
34+
const modelInfo = this.providerModels[modelId as RooModelId] ?? this.providerModels[rooDefaultModelId]
35+
36+
if (modelInfo) {
37+
return { id: modelId as RooModelId, info: modelInfo }
38+
}
39+
40+
// Return the requested model ID even if not found, with fallback info
41+
return {
42+
id: modelId as RooModelId,
43+
info: {
44+
maxTokens: 8192,
45+
contextWindow: 262_144,
46+
supportsImages: false,
47+
supportsPromptCache: false,
48+
inputPrice: 0,
49+
outputPrice: 0,
50+
},
51+
}
52+
}
53+
}

src/i18n/locales/ca/common.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/de/common.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/locales/en/common.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
"genericError": "Cerebras API Error ({{status}}): {{message}}",
101101
"noResponseBody": "Cerebras API Error: No response body",
102102
"completionError": "Cerebras completion error: {{error}}"
103+
},
104+
"roo": {
105+
"authenticationRequired": "Roo provider requires cloud authentication. Please sign in to Roo Code Cloud."
103106
}
104107
},
105108
"warnings": {

src/i18n/locales/es/common.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)