From c32c2e8a8f892b375dd8c47cbd303dbe37913f4f Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Wed, 18 Mar 2026 18:16:00 -0500 Subject: [PATCH] feat: add model reconciliation hook --- packages/opencode/src/plugin/index.ts | 6 +++--- packages/plugin/src/index.ts | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/plugin/index.ts b/packages/opencode/src/plugin/index.ts index 8790efac49b..a57084e2e79 100644 --- a/packages/opencode/src/plugin/index.ts +++ b/packages/opencode/src/plugin/index.ts @@ -110,9 +110,9 @@ export namespace Plugin { }) export async function trigger< - Name extends Exclude, "auth" | "event" | "tool">, - Input = Parameters[Name]>[0], - Output = Parameters[Name]>[1], + Name extends Exclude, "auth" | "event" | "tool" | "provider">, + Input = Parameters[Name], (...args: any) => any>>[0], + Output = Parameters[Name], (...args: any) => any>>[1], >(name: Name, input: Input, output: Output): Promise { if (!name) return output for (const hook of await state().then((x) => x.hooks)) { diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts index 7e5ae7a6ec5..2ab5195fba7 100644 --- a/packages/plugin/src/index.ts +++ b/packages/plugin/src/index.ts @@ -159,6 +159,16 @@ export type AuthOuathResult = { url: string; instructions: string } & ( } ) +export type ProviderHook = { + id: string + models?: { + reconcile?: (input: { + provider: Provider + models: Record + }) => Promise | undefined> + } +} + export interface Hooks { event?: (input: { event: Event }) => Promise config?: (input: Config) => Promise @@ -166,6 +176,7 @@ export interface Hooks { [key: string]: ToolDefinition } auth?: AuthHook + provider?: ProviderHook /** * Called when a new message is received */