@opencode-ai/plugin
Advanced tools
+99
-42
@@ -13,2 +13,89 @@ import type { Event, createOpencodeClient, Project, Model, Provider, Permission, UserMessage, Part, Auth, Config } from "@opencode-ai/sdk"; | ||
| export type Plugin = (input: PluginInput) => Promise<Hooks>; | ||
| export type AuthHook = { | ||
| provider: string; | ||
| loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, any>>; | ||
| methods: ({ | ||
| type: "oauth"; | ||
| label: string; | ||
| prompts?: Array<{ | ||
| type: "text"; | ||
| key: string; | ||
| message: string; | ||
| placeholder?: string; | ||
| validate?: (value: string) => string | undefined; | ||
| condition?: (inputs: Record<string, string>) => boolean; | ||
| } | { | ||
| type: "select"; | ||
| key: string; | ||
| message: string; | ||
| options: Array<{ | ||
| label: string; | ||
| value: string; | ||
| hint?: string; | ||
| }>; | ||
| condition?: (inputs: Record<string, string>) => boolean; | ||
| }>; | ||
| authorize(inputs?: Record<string, string>): Promise<AuthOuathResult>; | ||
| } | { | ||
| type: "api"; | ||
| label: string; | ||
| prompts?: Array<{ | ||
| type: "text"; | ||
| key: string; | ||
| message: string; | ||
| placeholder?: string; | ||
| validate?: (value: string) => string | undefined; | ||
| condition?: (inputs: Record<string, string>) => boolean; | ||
| } | { | ||
| type: "select"; | ||
| key: string; | ||
| message: string; | ||
| options: Array<{ | ||
| label: string; | ||
| value: string; | ||
| hint?: string; | ||
| }>; | ||
| condition?: (inputs: Record<string, string>) => boolean; | ||
| }>; | ||
| authorize?(inputs?: Record<string, string>): Promise<{ | ||
| type: "success"; | ||
| key: string; | ||
| provider?: string; | ||
| } | { | ||
| type: "failed"; | ||
| }>; | ||
| })[]; | ||
| }; | ||
| export type AuthOuathResult = { | ||
| url: string; | ||
| instructions: string; | ||
| } & ({ | ||
| method: "auto"; | ||
| callback(): Promise<({ | ||
| type: "success"; | ||
| provider?: string; | ||
| } & ({ | ||
| refresh: string; | ||
| access: string; | ||
| expires: number; | ||
| } | { | ||
| key: string; | ||
| })) | { | ||
| type: "failed"; | ||
| }>; | ||
| } | { | ||
| method: "code"; | ||
| callback(code: string): Promise<({ | ||
| type: "success"; | ||
| provider?: string; | ||
| } & ({ | ||
| refresh: string; | ||
| access: string; | ||
| expires: number; | ||
| } | { | ||
| key: string; | ||
| })) | { | ||
| type: "failed"; | ||
| }>; | ||
| }); | ||
| export interface Hooks { | ||
@@ -22,47 +109,15 @@ event?: (input: { | ||
| }; | ||
| 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; | ||
| } | { | ||
| key: string; | ||
| })) | { | ||
| type: "failed"; | ||
| }>; | ||
| } | { | ||
| method: "code"; | ||
| callback(code: string): Promise<({ | ||
| type: "success"; | ||
| } & ({ | ||
| refresh: string; | ||
| access: string; | ||
| expires: number; | ||
| } | { | ||
| key: string; | ||
| })) | { | ||
| type: "failed"; | ||
| }>; | ||
| })>; | ||
| } | { | ||
| type: "api"; | ||
| label: string; | ||
| })[]; | ||
| }; | ||
| auth?: AuthHook; | ||
| /** | ||
| * Called when a new message is received | ||
| */ | ||
| "chat.message"?: (input: {}, output: { | ||
| "chat.message"?: (input: { | ||
| sessionID: string; | ||
| agent?: string; | ||
| model?: { | ||
| providerID: string; | ||
| modelID: string; | ||
| }; | ||
| messageID?: string; | ||
| }, output: { | ||
| message: UserMessage; | ||
@@ -75,2 +130,4 @@ parts: Part[]; | ||
| "chat.params"?: (input: { | ||
| sessionID: string; | ||
| agent: string; | ||
| model: Model; | ||
@@ -77,0 +134,0 @@ provider: Provider; |
+2
-2
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "name": "@opencode-ai/plugin", | ||
| "version": "0.0.0-opentui-202510312235", | ||
| "version": "0.0.0-test-bedrock-202511260007", | ||
| "type": "module", | ||
@@ -24,3 +24,3 @@ "scripts": { | ||
| "dependencies": { | ||
| "@opencode-ai/sdk": "0.0.0-opentui-202510312235", | ||
| "@opencode-ai/sdk": "0.0.0-test-bedrock-202511260007", | ||
| "zod": "4.1.8" | ||
@@ -27,0 +27,0 @@ }, |
9467
17.08%310
22.53%+ Added
- Removed