feat: add new provider plugin hook for resolving models and sync models from github models endpoint (falls back to models.dev) (#20533)

This commit is contained in:
Aiden Cline
2026-04-01 18:04:14 -05:00
committed by GitHub
parent fa96cb9c6e
commit 1fcfb69bf7
6 changed files with 356 additions and 48 deletions

View File

@@ -11,6 +11,7 @@ import type {
Auth,
Config as SDKConfig,
} from "@opencode-ai/sdk"
import type { Provider as ProviderV2, Model as ModelV2 } from "@opencode-ai/sdk/v2"
import type { BunShell } from "./shell.js"
import { type ToolDefinition } from "./tool.js"
@@ -173,6 +174,15 @@ export type AuthOAuthResult = { url: string; instructions: string } & (
}
)
export type ProviderHookContext = {
auth?: Auth
}
export type ProviderHook = {
id: string
models?: (provider: ProviderV2, ctx: ProviderHookContext) => Promise<Record<string, ModelV2>>
}
/** @deprecated Use AuthOAuthResult instead. */
export type AuthOuathResult = AuthOAuthResult
@@ -183,6 +193,7 @@ export interface Hooks {
[key: string]: ToolDefinition
}
auth?: AuthHook
provider?: ProviderHook
/**
* Called when a new message is received
*/