Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a7dda4c
chore: bump packages to v6
rekram1-node Mar 20, 2026
6c68689
chore: run v6 codemod
rekram1-node Mar 20, 2026
07ff24f
chore: bump ai gateway package
rekram1-node Mar 20, 2026
be97290
fix: get provider.ts type errors fixed
rekram1-node Mar 20, 2026
44a251a
fix: update message-v2.ts and message-v2.test.ts to v6
rekram1-node Mar 20, 2026
9e03d49
fix: update compaction.ts to v6
rekram1-node Mar 20, 2026
6c2efcb
chore: add note to message-v2 that we need to do further updates to i…
rekram1-node Mar 20, 2026
ba895b1
fix: resolve most prompt.ts v6 issues, need to fully resolve llm.ts b…
rekram1-node Mar 20, 2026
d70a6b3
fix: azure now uses azure key instead of openai in ai sdk v6: https:/…
rekram1-node Mar 20, 2026
dbd72df
fix: further adjust provider.ts, ensure that the typing for language …
rekram1-node Mar 20, 2026
1c77277
fix: add specificationVersion to middleware in llm.ts
rekram1-node Mar 20, 2026
f881bac
chore: add todo in llm.ts
rekram1-node Mar 20, 2026
357a3fc
tweak: switch @ai-sdk/google-vertex key from google to vertex see: ht…
rekram1-node Mar 20, 2026
7644c89
fix prompt.ts to be v6 compat, wrap w/ try catch since type changed a…
rekram1-node Mar 20, 2026
781cc0f
fix: migrate structured-output.test.ts to v6
rekram1-node Mar 20, 2026
9f930bd
fix: adjust imports in github copilot sdk to be v6 compat
rekram1-node Mar 20, 2026
caf7d1f
fix: remove ts ignore for gh copilot provider, this revealed further …
rekram1-node Mar 20, 2026
7088fc6
fix: almost fix transform.ts, add exclusions for tool-approval-reques…
rekram1-node Mar 20, 2026
f38b91e
fix: finish transform.ts v6 migration
rekram1-node Mar 20, 2026
cfe0fc4
fix: migrate message-v2.ts to make toModelOutput logic compliant: htt…
rekram1-node Mar 20, 2026
d6a2460
fix: update stop reason to be 'other' instead of 'unknown' as per v6 …
rekram1-node Mar 23, 2026
0c519ac
chore: rm patches now that ai sdk packages are upgraded
rekram1-node Mar 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 54 additions & 194 deletions bun.lock

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"drizzle-kit": "1.0.0-beta.19-d95b7a4",
"drizzle-orm": "1.0.0-beta.19-d95b7a4",
"effect": "4.0.0-beta.35",
"ai": "5.0.124",
"ai": "6.0.116",
"hono": "4.10.7",
"hono-openapi": "1.1.2",
"fuzzysort": "3.1.0",
Expand Down Expand Up @@ -111,8 +111,6 @@
"@types/node": "catalog:"
},
"patchedDependencies": {
"@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch",
"@openrouter/ai-sdk-provider@1.5.4": "patches/@openrouter%2Fai-sdk-provider@1.5.4.patch",
"@ai-sdk/xai@2.0.51": "patches/@ai-sdk%2Fxai@2.0.51.patch"
"@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch"
}
}
6 changes: 3 additions & 3 deletions packages/console/function/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"@typescript/native-preview": "catalog:"
},
"dependencies": {
"@ai-sdk/anthropic": "2.0.0",
"@ai-sdk/openai": "2.0.2",
"@ai-sdk/openai-compatible": "1.0.1",
"@ai-sdk/anthropic": "3.0.58",
"@ai-sdk/openai": "3.0.41",
"@ai-sdk/openai-compatible": "2.0.35",
"@hono/zod-validator": "catalog:",
"@opencode-ai/console-core": "workspace:*",
"@opencode-ai/console-resource": "workspace:*",
Expand Down
42 changes: 21 additions & 21 deletions packages/opencode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,25 @@
"@actions/core": "1.11.1",
"@actions/github": "6.0.1",
"@agentclientprotocol/sdk": "0.14.1",
"@ai-sdk/amazon-bedrock": "3.0.82",
"@ai-sdk/anthropic": "2.0.65",
"@ai-sdk/azure": "2.0.91",
"@ai-sdk/cerebras": "1.0.36",
"@ai-sdk/cohere": "2.0.22",
"@ai-sdk/deepinfra": "1.0.36",
"@ai-sdk/gateway": "2.0.30",
"@ai-sdk/google": "2.0.54",
"@ai-sdk/google-vertex": "3.0.106",
"@ai-sdk/groq": "2.0.34",
"@ai-sdk/mistral": "2.0.27",
"@ai-sdk/openai": "2.0.89",
"@ai-sdk/openai-compatible": "1.0.32",
"@ai-sdk/perplexity": "2.0.23",
"@ai-sdk/provider": "2.0.1",
"@ai-sdk/provider-utils": "3.0.21",
"@ai-sdk/togetherai": "1.0.34",
"@ai-sdk/vercel": "1.0.33",
"@ai-sdk/xai": "2.0.51",
"@ai-sdk/amazon-bedrock": "4.0.77",
"@ai-sdk/anthropic": "3.0.58",
"@ai-sdk/azure": "3.0.42",
"@ai-sdk/cerebras": "2.0.39",
"@ai-sdk/cohere": "3.0.25",
"@ai-sdk/deepinfra": "2.0.39",
"@ai-sdk/gateway": "3.0.66",
"@ai-sdk/google": "3.0.43",
"@ai-sdk/google-vertex": "4.0.80",
"@ai-sdk/groq": "3.0.29",
"@ai-sdk/mistral": "3.0.24",
"@ai-sdk/openai": "3.0.41",
"@ai-sdk/openai-compatible": "2.0.35",
"@ai-sdk/perplexity": "3.0.23",
"@ai-sdk/provider": "3.0.8",
"@ai-sdk/provider-utils": "4.0.19",
"@ai-sdk/togetherai": "2.0.39",
"@ai-sdk/vercel": "2.0.37",
"@ai-sdk/xai": "3.0.67",
"@aws-sdk/credential-providers": "3.993.0",
"@clack/prompts": "1.0.0-alpha.1",
"@gitlab/gitlab-ai-provider": "3.6.0",
Expand All @@ -101,7 +101,7 @@
"@opencode-ai/script": "workspace:*",
"@opencode-ai/sdk": "workspace:*",
"@opencode-ai/util": "workspace:*",
"@openrouter/ai-sdk-provider": "1.5.4",
"@openrouter/ai-sdk-provider": "2.3.3",
"@opentui/core": "0.1.87",
"@opentui/solid": "0.1.87",
"@effect/platform-node": "catalog:",
Expand All @@ -112,7 +112,7 @@
"@standard-schema/spec": "1.0.0",
"@zip.js/zip.js": "2.7.62",
"ai": "catalog:",
"ai-gateway-provider": "2.3.1",
"ai-gateway-provider": "3.1.1",
"bonjour-service": "1.3.0",
"bun-pty": "0.4.8",
"chokidar": "4.0.3",
Expand Down
105 changes: 54 additions & 51 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { BunProc } from "../bun"
import { Hash } from "../util/hash"
import { Plugin } from "../plugin"
import { NamedError } from "@opencode-ai/util/error"
import { type LanguageModelV3 } from "@ai-sdk/provider"
import { ModelsDev } from "./models"
import { Auth } from "../auth"
import { Env } from "../env"
Expand All @@ -28,7 +29,7 @@ import { createVertex } from "@ai-sdk/google-vertex"
import { createVertexAnthropic } from "@ai-sdk/google-vertex/anthropic"
import { createOpenAI } from "@ai-sdk/openai"
import { createOpenAICompatible } from "@ai-sdk/openai-compatible"
import { createOpenRouter, type LanguageModelV2 } from "@openrouter/ai-sdk-provider"
import { createOpenRouter } from "@openrouter/ai-sdk-provider"
import { createOpenaiCompatible as createGitHubCopilotOpenAICompatible } from "./sdk/copilot"
import { createXai } from "@ai-sdk/xai"
import { createMistral } from "@ai-sdk/mistral"
Expand All @@ -40,7 +41,7 @@ import { createGateway } from "@ai-sdk/gateway"
import { createTogetherAI } from "@ai-sdk/togetherai"
import { createPerplexity } from "@ai-sdk/perplexity"
import { createVercel } from "@ai-sdk/vercel"
import { createGitLab, VERSION as GITLAB_PROVIDER_VERSION } from "@gitlab/gitlab-ai-provider"
// import { createGitLab, VERSION as GITLAB_PROVIDER_VERSION } from "@gitlab/gitlab-ai-provider"
import { fromNodeProviderChain } from "@aws-sdk/credential-providers"
import { GoogleAuth } from "google-auth-library"
import { ProviderTransform } from "./transform"
Expand Down Expand Up @@ -104,7 +105,11 @@ export namespace Provider {
})
}

const BUNDLED_PROVIDERS: Record<string, (options: any) => SDK> = {
type BundledSDK = {
languageModel(modelId: string): LanguageModelV3
}

const BUNDLED_PROVIDERS: Record<string, (options: any) => BundledSDK> = {
"@ai-sdk/amazon-bedrock": createAmazonBedrock,
"@ai-sdk/anthropic": createAnthropic,
"@ai-sdk/azure": createAzure,
Expand All @@ -124,8 +129,6 @@ export namespace Provider {
"@ai-sdk/togetherai": createTogetherAI,
"@ai-sdk/perplexity": createPerplexity,
"@ai-sdk/vercel": createVercel,
"@gitlab/gitlab-ai-provider": createGitLab,
// @ts-ignore (TODO: kill this code so we dont have to maintain it)
"@ai-sdk/github-copilot": createGitHubCopilotOpenAICompatible,
}

Expand Down Expand Up @@ -514,49 +517,49 @@ export namespace Provider {
},
}
},
gitlab: async (input) => {
const instanceUrl = Env.get("GITLAB_INSTANCE_URL") || "https://gitlab.com"

const auth = await Auth.get(input.id)
const apiKey = await (async () => {
if (auth?.type === "oauth") return auth.access
if (auth?.type === "api") return auth.key
return Env.get("GITLAB_TOKEN")
})()

const config = await Config.get()
const providerConfig = config.provider?.["gitlab"]

const aiGatewayHeaders = {
"User-Agent": `opencode/${Installation.VERSION} gitlab-ai-provider/${GITLAB_PROVIDER_VERSION} (${os.platform()} ${os.release()}; ${os.arch()})`,
"anthropic-beta": "context-1m-2025-08-07",
...(providerConfig?.options?.aiGatewayHeaders || {}),
}

return {
autoload: !!apiKey,
options: {
instanceUrl,
apiKey,
aiGatewayHeaders,
featureFlags: {
duo_agent_platform_agentic_chat: true,
duo_agent_platform: true,
...(providerConfig?.options?.featureFlags || {}),
},
},
async getModel(sdk: ReturnType<typeof createGitLab>, modelID: string) {
return sdk.agenticChat(modelID, {
aiGatewayHeaders,
featureFlags: {
duo_agent_platform_agentic_chat: true,
duo_agent_platform: true,
...(providerConfig?.options?.featureFlags || {}),
},
})
},
}
},
// gitlab: async (input) => {
// const instanceUrl = Env.get("GITLAB_INSTANCE_URL") || "https://gitlab.com"
//
// const auth = await Auth.get(input.id)
// const apiKey = await (async () => {
// if (auth?.type === "oauth") return auth.access
// if (auth?.type === "api") return auth.key
// return Env.get("GITLAB_TOKEN")
// })()
//
// const config = await Config.get()
// const providerConfig = config.provider?.["gitlab"]
//
// const aiGatewayHeaders = {
// "User-Agent": `opencode/${Installation.VERSION} gitlab-ai-provider/${GITLAB_PROVIDER_VERSION} (${os.platform()} ${os.release()}; ${os.arch()})`,
// "anthropic-beta": "context-1m-2025-08-07",
// ...(providerConfig?.options?.aiGatewayHeaders || {}),
// }
//
// return {
// autoload: !!apiKey,
// options: {
// instanceUrl,
// apiKey,
// aiGatewayHeaders,
// featureFlags: {
// duo_agent_platform_agentic_chat: true,
// duo_agent_platform: true,
// ...(providerConfig?.options?.featureFlags || {}),
// },
// },
// async getModel(sdk: ReturnType<typeof createGitLab>, modelID: string) {
// return sdk.agenticChat(modelID, {
// aiGatewayHeaders,
// featureFlags: {
// duo_agent_platform_agentic_chat: true,
// duo_agent_platform: true,
// ...(providerConfig?.options?.featureFlags || {}),
// },
// })
// },
// }
// },
"cloudflare-workers-ai": async (input) => {
const accountId = Env.get("CLOUDFLARE_ACCOUNT_ID")
if (!accountId) return { autoload: false }
Expand Down Expand Up @@ -846,14 +849,14 @@ export namespace Provider {
}

const providers: Record<ProviderID, Info> = {} as Record<ProviderID, Info>
const languages = new Map<string, LanguageModelV2>()
const languages = new Map<string, LanguageModelV3>()
const modelLoaders: {
[providerID: string]: CustomModelLoader
} = {}
const varsLoaders: {
[providerID: string]: CustomVarsLoader
} = {}
const sdk = new Map<string, SDK>()
const sdk = new Map<string, BundledSDK>()

log.info("init")

Expand Down Expand Up @@ -1240,7 +1243,7 @@ export namespace Provider {
return info
}

export async function getLanguage(model: Model): Promise<LanguageModelV2> {
export async function getLanguage(model: Model): Promise<LanguageModelV3> {
const s = await state()
const key = `${model.providerID}/${model.id}`
if (s.models.has(key)) return s.models.get(key)!
Expand Down
10 changes: 5 additions & 5 deletions packages/opencode/src/provider/sdk/copilot/copilot-provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LanguageModelV2 } from "@ai-sdk/provider"
import type { LanguageModelV3 } from "@ai-sdk/provider"
import { type FetchFunction, withoutTrailingSlash, withUserAgentSuffix } from "@ai-sdk/provider-utils"
import { OpenAICompatibleChatLanguageModel } from "./chat/openai-compatible-chat-language-model"
import { OpenAIResponsesLanguageModel } from "./responses/openai-responses-language-model"
Expand Down Expand Up @@ -36,10 +36,10 @@ export interface OpenaiCompatibleProviderSettings {
}

export interface OpenaiCompatibleProvider {
(modelId: OpenaiCompatibleModelId): LanguageModelV2
chat(modelId: OpenaiCompatibleModelId): LanguageModelV2
responses(modelId: OpenaiCompatibleModelId): LanguageModelV2
languageModel(modelId: OpenaiCompatibleModelId): LanguageModelV2
(modelId: OpenaiCompatibleModelId): LanguageModelV3
chat(modelId: OpenaiCompatibleModelId): LanguageModelV3
responses(modelId: OpenaiCompatibleModelId): LanguageModelV3
languageModel(modelId: OpenaiCompatibleModelId): LanguageModelV3

// embeddingModel(modelId: any): EmbeddingModelV2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
import { z } from "zod/v4"

export const codeInterpreterInputSchema = z.object({
Expand Down Expand Up @@ -37,7 +37,7 @@ type CodeInterpreterArgs = {
container?: string | { fileIds?: string[] }
}

export const codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema<
export const codeInterpreterToolFactory = createProviderToolFactoryWithOutputSchema<
{
/**
* The code to run, or null if not available.
Expand Down Expand Up @@ -76,7 +76,6 @@ export const codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOu
CodeInterpreterArgs
>({
id: "openai.code_interpreter",
name: "code_interpreter",
inputSchema: codeInterpreterInputSchema,
outputSchema: codeInterpreterOutputSchema,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
import type {
OpenAIResponsesFileSearchToolComparisonFilter,
OpenAIResponsesFileSearchToolCompoundFilter,
Expand Down Expand Up @@ -43,7 +43,7 @@ export const fileSearchOutputSchema = z.object({
.nullable(),
})

export const fileSearch = createProviderDefinedToolFactoryWithOutputSchema<
export const fileSearch = createProviderToolFactoryWithOutputSchema<
{},
{
/**
Expand Down Expand Up @@ -122,7 +122,6 @@ export const fileSearch = createProviderDefinedToolFactoryWithOutputSchema<
}
>({
id: "openai.file_search",
name: "file_search",
inputSchema: z.object({}),
outputSchema: fileSearchOutputSchema,
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
import { z } from "zod/v4"

export const imageGenerationArgsSchema = z
Expand Down Expand Up @@ -92,7 +92,7 @@ type ImageGenerationArgs = {
size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024"
}

const imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema<
const imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema<
{},
{
/**
Expand All @@ -103,7 +103,6 @@ const imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSch
ImageGenerationArgs
>({
id: "openai.image_generation",
name: "image_generation",
inputSchema: z.object({}),
outputSchema: imageGenerationOutputSchema,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
import { createProviderToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils"
import { z } from "zod/v4"

export const localShellInputSchema = z.object({
Expand All @@ -16,7 +16,7 @@ export const localShellOutputSchema = z.object({
output: z.string(),
})

export const localShell = createProviderDefinedToolFactoryWithOutputSchema<
export const localShell = createProviderToolFactoryWithOutputSchema<
{
/**
* Execute a shell command on the server.
Expand Down Expand Up @@ -59,7 +59,6 @@ export const localShell = createProviderDefinedToolFactoryWithOutputSchema<
{}
>({
id: "openai.local_shell",
name: "local_shell",
inputSchema: localShellInputSchema,
outputSchema: localShellOutputSchema,
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createProviderDefinedToolFactory } from "@ai-sdk/provider-utils"
import { createProviderToolFactory } from "@ai-sdk/provider-utils"
import { z } from "zod/v4"

// Args validation schema
Expand Down Expand Up @@ -40,7 +40,7 @@ export const webSearchPreviewArgsSchema = z.object({
.optional(),
})

export const webSearchPreview = createProviderDefinedToolFactory<
export const webSearchPreview = createProviderToolFactory<
{
// Web search doesn't take input parameters - it's controlled by the prompt
},
Expand Down Expand Up @@ -81,7 +81,6 @@ export const webSearchPreview = createProviderDefinedToolFactory<
}
>({
id: "openai.web_search_preview",
name: "web_search_preview",
inputSchema: z.object({
action: z
.discriminatedUnion("type", [
Expand Down
Loading
Loading