From 1fcfb69bf772f085289dd22f6898ac5d926226e9 Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Wed, 1 Apr 2026 18:04:14 -0500 Subject: feat: add new provider plugin hook for resolving models and sync models from github models endpoint (falls back to models.dev) (#20533) --- packages/plugin/src/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'packages/plugin') diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts index a264cf5aa..473cac8a9 100644 --- a/packages/plugin/src/index.ts +++ b/packages/plugin/src/index.ts @@ -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> +} + /** @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 */ -- cgit v1.2.3