Skip to content

Commit d42d2e7

Browse files
allquixoticoz-agent
andcommitted
fix: resolve allquixotic merge type errors
Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent 56b2314 commit d42d2e7

20 files changed

Lines changed: 180 additions & 273 deletions

packages/cloud/src/TaskSyncClient.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { z } from "zod"
22

3-
import {
4-
type AuthService,
5-
type ClineMessage,
6-
type SettingsService,
7-
clineMessageSchema,
8-
} from "@roo-code/types"
3+
import { type AuthService, type ClineMessage, type SettingsService, clineMessageSchema } from "@roo-code/types"
94

105
import { getRooCodeApiUrl } from "./config.js"
116
import type { RetryQueue } from "./retry-queue/index.js"
@@ -52,12 +47,16 @@ export class TaskSyncClient {
5247
}
5348

5449
const url = `${getRooCodeApiUrl()}/api/${path}`
55-
const requestHeaders =
56-
options.headers instanceof Headers
57-
? Object.fromEntries(options.headers.entries())
58-
: Array.isArray(options.headers)
59-
? Object.fromEntries(options.headers)
60-
: ((options.headers as Record<string, string> | undefined) ?? {})
50+
const requestHeaders: Record<string, string> = {}
51+
if (options.headers instanceof Headers) {
52+
options.headers.forEach((value, key) => {
53+
requestHeaders[key] = value
54+
})
55+
} else if (Array.isArray(options.headers)) {
56+
Object.assign(requestHeaders, Object.fromEntries(options.headers))
57+
} else {
58+
Object.assign(requestHeaders, (options.headers as Record<string, string> | undefined) ?? {})
59+
}
6160

6261
const fetchOptions: RequestInit = {
6362
...options,
@@ -80,7 +79,9 @@ export class TaskSyncClient {
8079
const response = await fetch(url, fetchOptions)
8180

8281
if (!response.ok) {
83-
console.error(`[TaskSyncClient#fetch] ${options.method} ${path} -> ${response.status} ${response.statusText}`)
82+
console.error(
83+
`[TaskSyncClient#fetch] ${options.method} ${path} -> ${response.status} ${response.statusText}`,
84+
)
8485

8586
if (this.retryQueue && allowQueueing && (response.status >= 500 || response.status === 429)) {
8687
await this.retryQueue.enqueue(url, fetchOptions, "task-sync", path)

packages/types/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export * from "./mcp.js"
1818
export * from "./message.js"
1919
export * from "./mode.js"
2020
export * from "./model.js"
21+
export * from "./marketplace.js"
2122
export * from "./provider-settings.js"
2223
export * from "./task.js"
2324
export * from "./todo.js"

packages/types/src/providers/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export * from "./openrouter.js"
1616
export * from "./poe.js"
1717
export * from "./qwen-code.js"
1818
export * from "./requesty.js"
19+
export * from "./roo.js"
1920
export * from "./sambanova.js"
2021
export * from "./unbound.js"
2122
export * from "./vertex.js"
@@ -41,6 +42,7 @@ import { openRouterDefaultModelId } from "./openrouter.js"
4142
import { poeDefaultModelId } from "./poe.js"
4243
import { qwenCodeDefaultModelId } from "./qwen-code.js"
4344
import { requestyDefaultModelId } from "./requesty.js"
45+
import { rooDefaultModelId } from "./roo.js"
4446
import { sambaNovaDefaultModelId } from "./sambanova.js"
4547
import { unboundDefaultModelId } from "./unbound.js"
4648
import { vertexDefaultModelId } from "./vertex.js"
@@ -69,6 +71,8 @@ export function getProviderDefaultModelId(
6971
return openRouterDefaultModelId
7072
case "requesty":
7173
return requestyDefaultModelId
74+
case "roo":
75+
return rooDefaultModelId
7276
case "litellm":
7377
return litellmDefaultModelId
7478
case "xai":

packages/types/src/vscode-extension-host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export interface ExtensionMessage {
110110
}
111111
action?:
112112
| "chatButtonClicked"
113+
| "cloudButtonClicked"
113114
| "settingsButtonClicked"
114115
| "historyButtonClicked"
115116
| "marketplaceButtonClicked"
@@ -180,7 +181,6 @@ export interface ExtensionMessage {
180181
context?: string
181182
commands?: Command[]
182183
queuedMessages?: QueuedMessage[]
183-
organizationId?: string | null // For organizationSwitchResult
184184
tools?: SerializedCustomToolDefinition[] // For customToolsResult
185185
skills?: SkillMetadata[] // For skills response
186186
modes?: { slug: string; name: string }[] // For modes response

packages/types/src/vscode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const commandIds = [
3030
"activationCompleted",
3131

3232
"plusButtonClicked",
33+
"cloudButtonClicked",
3334
"historyButtonClicked",
3435
"marketplaceButtonClicked",
3536
"popoutButtonClicked",

src/__tests__/extension.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import type * as vscode from "vscode"
44
import type { AuthState } from "@roo-code/types"
55

6+
const mockRefreshModels = vi.hoisted(() => vi.fn().mockResolvedValue({}))
7+
68
vi.mock("vscode", () => ({
79
window: {
810
createOutputChannel: vi.fn().mockReturnValue({
@@ -189,7 +191,7 @@ vi.mock("../api/providers/fetchers/modelCache", () => ({
189191
flushModels: vi.fn(),
190192
getModels: vi.fn().mockResolvedValue([]),
191193
initializeModelCacheRefresh: vi.fn(),
192-
refreshModels: vi.fn().mockResolvedValue({}),
194+
refreshModels: mockRefreshModels,
193195
}))
194196

195197
describe("extension.ts", () => {

src/activate/CodeActionProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import * as vscode from "vscode"
22

3-
import { CodeActionId } from "@roo-code/types"
3+
import { type CodeActionId, type CodeActionName } from "@roo-code/types"
44
import { Package } from "../shared/package"
5+
import { t } from "../i18n"
56

67
import { getCodeActionCommand } from "../utils/commands"
78
import { EditorUtils } from "../integrations/editor/EditorUtils"

src/api/providers/anthropic.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type { ApiHandlerOptions } from "../../shared/api"
1515
import { ApiStream } from "../transform/stream"
1616
import { getModelParams } from "../transform/model-params"
1717
import { filterNonAnthropicBlocks } from "../transform/anthropic-filter"
18+
import { getAnthropicProviderReasoning } from "../transform/reasoning"
1819

1920
import { BaseProvider } from "./base-provider"
2021
import type { SingleCompletionHandler, ApiHandlerCreateMessageMetadata } from "../index"
@@ -119,7 +120,7 @@ export class AnthropicHandler extends BaseProvider implements SingleCompletionHa
119120
model: modelId,
120121
max_tokens: maxTokens ?? ANTHROPIC_DEFAULT_MAX_TOKENS,
121122
temperature,
122-
thinking,
123+
thinking: thinking as unknown as Anthropic.Messages.MessageCreateParams["thinking"],
123124
// Setting cache breakpoint for system prompt so new tasks can reuse it.
124125
system: [{ text: systemPrompt, type: "text", cache_control: cacheControl }],
125126
messages: sanitizedMessages.map((message, index) => {

src/api/providers/bedrock-discovery.ts

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import {
2121

2222
import { Package } from "../../shared/package"
2323

24+
export const BEDROCK_DISCOVERY_TIMEOUT_MS = 30_000
25+
2426
// The two AWS SDK packages we use here (`@aws-sdk/client-bedrock` for control-plane discovery
2527
// and `@aws-sdk/client-bedrock-runtime` for Converse probes) each ship their own discriminated
2628
// `Config` interface where `token`/`credentials` are tagged with package-private branded types.
@@ -152,7 +154,7 @@ const buildInferenceProfileTarget = (summary: InferenceProfileSummary): BedrockD
152154
}
153155
}
154156

155-
const listInferenceProfiles = async (client: BedrockClient) => {
157+
const listInferenceProfiles = async (client: BedrockClient, abortSignal?: AbortSignal) => {
156158
const results: InferenceProfileSummary[] = []
157159
let nextToken: string | undefined
158160

@@ -162,6 +164,7 @@ const listInferenceProfiles = async (client: BedrockClient) => {
162164
nextToken,
163165
maxResults: 100,
164166
}),
167+
{ abortSignal },
165168
)
166169

167170
results.push(...(response.inferenceProfileSummaries ?? []))
@@ -177,42 +180,59 @@ export const discoverBedrockTargets = async (options: ProviderSettings): Promise
177180
}
178181

179182
const client = new BedrockClient(toBedrockClientConfig(options))
183+
const controller = new AbortController()
184+
const timeout = setTimeout(() => controller.abort(), BEDROCK_DISCOVERY_TIMEOUT_MS)
185+
const timeoutPromise = new Promise<never>((_, reject) => {
186+
controller.signal.addEventListener(
187+
"abort",
188+
() => reject(new Error(`Bedrock discovery timed out after ${BEDROCK_DISCOVERY_TIMEOUT_MS}ms`)),
189+
{ once: true },
190+
)
191+
})
180192

181-
const [foundationModelsResponse, inferenceProfiles] = await Promise.all([
182-
client.send(new ListFoundationModelsCommand({})),
183-
listInferenceProfiles(client),
184-
])
185-
186-
const targets = [
187-
...(foundationModelsResponse.modelSummaries ?? [])
188-
.map((summary) => buildFoundationTarget(summary))
189-
.filter((target): target is BedrockDiscoveredTarget => Boolean(target)),
190-
...inferenceProfiles
191-
.filter((summary) => summary.status === "ACTIVE")
192-
.map((summary) => buildInferenceProfileTarget(summary))
193-
.filter((target): target is BedrockDiscoveredTarget => Boolean(target)),
194-
]
195-
196-
const dedupedTargets = Array.from(new Map(targets.map((target) => [target.id, target])).values())
197-
198-
const sortedTargets = dedupedTargets.sort((a, b) => {
199-
const kindOrder = { "foundation-model": 0, "system-profile": 1, "application-profile": 2 }
200-
const kindCompare = kindOrder[a.targetKind] - kindOrder[b.targetKind]
201-
if (kindCompare !== 0) {
202-
return kindCompare
203-
}
193+
const discoveryPromise = (async () => {
194+
const [foundationModelsResponse, inferenceProfiles] = await Promise.all([
195+
client.send(new ListFoundationModelsCommand({}), { abortSignal: controller.signal }),
196+
listInferenceProfiles(client, controller.signal),
197+
])
198+
199+
const targets = [
200+
...(foundationModelsResponse.modelSummaries ?? [])
201+
.map((summary) => buildFoundationTarget(summary))
202+
.filter((target): target is BedrockDiscoveredTarget => Boolean(target)),
203+
...inferenceProfiles
204+
.filter((summary) => summary.status === "ACTIVE")
205+
.map((summary) => buildInferenceProfileTarget(summary))
206+
.filter((target): target is BedrockDiscoveredTarget => Boolean(target)),
207+
]
208+
209+
const dedupedTargets = Array.from(new Map(targets.map((target) => [target.id, target])).values())
210+
211+
const sortedTargets = dedupedTargets.sort((a, b) => {
212+
const kindOrder = { "foundation-model": 0, "system-profile": 1, "application-profile": 2 }
213+
const kindCompare = kindOrder[a.targetKind] - kindOrder[b.targetKind]
214+
if (kindCompare !== 0) {
215+
return kindCompare
216+
}
204217

205-
if (a.baseModelId !== b.baseModelId) {
206-
return a.baseModelId.localeCompare(b.baseModelId)
207-
}
218+
if (a.baseModelId !== b.baseModelId) {
219+
return a.baseModelId.localeCompare(b.baseModelId)
220+
}
208221

209-
return a.label.localeCompare(b.label)
210-
})
222+
return a.label.localeCompare(b.label)
223+
})
211224

212-
// AWS often returns a single inference profile id for models that support both 128K
213-
// and 1M context windows. Expand those into two dropdown entries so users can pick
214-
// the context tier explicitly; the `:1m` suffix is round-tripped through the runtime.
215-
return expandBedrockTargetsWith1MVariants(sortedTargets)
225+
// AWS often returns a single inference profile id for models that support both 128K
226+
// and 1M context windows. Expand those into two dropdown entries so users can pick
227+
// the context tier explicitly; the `:1m` suffix is round-tripped through the runtime.
228+
return expandBedrockTargetsWith1MVariants(sortedTargets)
229+
})()
230+
231+
try {
232+
return await Promise.race([discoveryPromise, timeoutPromise])
233+
} finally {
234+
clearTimeout(timeout)
235+
}
216236
}
217237

218238
/**

src/api/providers/fetchers/modelCache.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { getOpenRouterModels } from "./openrouter"
1919
import { getVercelAiGatewayModels } from "./vercel-ai-gateway"
2020
import { getOpencodeGoModels } from "./opencode-go"
2121
import { getRequestyModels } from "./requesty"
22+
import { getRooModels } from "./roo"
2223
import { getUnboundModels } from "./unbound"
2324
import { getLiteLLMModels } from "./litellm"
2425
import { GetModelsOptions } from "../../../shared/api"
@@ -70,6 +71,12 @@ async function fetchModelsFromProvider(options: GetModelsOptions): Promise<Model
7071
// Requesty models endpoint requires an API key for per-user custom policies.
7172
models = await getRequestyModels(options.baseUrl, options.apiKey)
7273
break
74+
case "roo":
75+
models = await getRooModels(
76+
options.baseUrl ?? process.env.ROO_CODE_PROVIDER_URL ?? "https://api.roocode.com/proxy",
77+
options.apiKey,
78+
)
79+
break
7380
case "unbound":
7481
models = await getUnboundModels(options.apiKey)
7582
break

0 commit comments

Comments
 (0)