diff options
| author | Dax Raad <[email protected]> | 2025-08-14 16:24:46 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-08-14 16:25:08 -0400 |
| commit | a433766a31fbf5c0597aec757de59a3d882c02fa (patch) | |
| tree | 6d8be3725830059c55b8260021e00c5501854922 /packages/plugin | |
| parent | c93d50e8c7af7911c41ba445b431a5428aaf15b8 (diff) | |
| download | opencode-a433766a31fbf5c0597aec757de59a3d882c02fa.tar.gz opencode-a433766a31fbf5c0597aec757de59a3d882c02fa.zip | |
allow plugins to create custom auth providers
Diffstat (limited to 'packages/plugin')
| -rw-r--r-- | packages/plugin/src/index.ts | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts index 7ea82d2aa..1a6cbf124 100644 --- a/packages/plugin/src/index.ts +++ b/packages/plugin/src/index.ts @@ -1,4 +1,14 @@ -import type { Event, createOpencodeClient, App, Model, Provider, Permission, UserMessage, Part } from "@opencode-ai/sdk" +import type { + Event, + createOpencodeClient, + App, + Model, + Provider, + Permission, + UserMessage, + Part, + Auth, +} from "@opencode-ai/sdk" import type { BunShell } from "./shell" export type PluginInput = { @@ -10,6 +20,49 @@ export type Plugin = (input: PluginInput) => Promise<Hooks> export interface Hooks { event?: (input: { event: Event }) => Promise<void> + auth?: { + provider: string + loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>> + methods: ( + | { + type: "oauth" + label: string + authorize(): Promise< + { url: string; instructions: string } & ( + | { + method: "auto" + callback(): Promise< + | { + type: "success" + refresh: string + access: string + expires: number + } + | { + type: "failed" + } + > + } + | { + method: "code" + callback(code: string): Promise< + | { + type: "success" + refresh: string + access: string + expires: number + } + | { + type: "failed" + } + > + } + ) + > + } + | { type: "api"; label: string } + )[] + } /** * Called when a new message is received */ |
