diff options
Diffstat (limited to 'packages/plugin/src')
| -rw-r--r-- | packages/plugin/src/index.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts index a00b48d10..fca176f57 100644 --- a/packages/plugin/src/index.ts +++ b/packages/plugin/src/index.ts @@ -18,9 +18,34 @@ export type PluginInput = { directory: string worktree: string $: BunShell + Tool: { + define( + id: string, + init: any | (() => Promise<any>) + ): any + } + z: any // Zod instance for creating schemas } export type Plugin = (input: PluginInput) => Promise<Hooks> +// Lightweight schema spec for HTTP-registered tools +export type HttpParamSpec = { + type: "string" | "number" | "boolean" | "array" + description?: string + optional?: boolean + items?: "string" | "number" | "boolean" +} +export type HttpToolRegistration = { + id: string + description: string + parameters: { + type: "object" + properties: Record<string, HttpParamSpec> + } + callbackUrl: string + headers?: Record<string, string> +} + export interface Hooks { event?: (input: { event: Event }) => Promise<void> config?: (input: Config) => Promise<void> @@ -99,4 +124,16 @@ export interface Hooks { metadata: any }, ) => Promise<void> + /** + * Allow plugins to register additional tools with the server. + * Use registerHTTP to add a tool that calls back to your plugin/service. + * Use register to add a native/local tool with direct function execution. + */ + "tool.register"?: ( + input: {}, + output: { + registerHTTP: (tool: HttpToolRegistration) => void | Promise<void> + register: (tool: any) => void | Promise<void> // Tool.Info type from opencode + }, + ) => Promise<void> } |
