diff options
Diffstat (limited to 'packages/plugin/src')
| -rw-r--r-- | packages/plugin/src/example.ts | 8 | ||||
| -rw-r--r-- | packages/plugin/src/index.ts | 67 |
2 files changed, 26 insertions, 49 deletions
diff --git a/packages/plugin/src/example.ts b/packages/plugin/src/example.ts index 4e9bc4b88..998108f0a 100644 --- a/packages/plugin/src/example.ts +++ b/packages/plugin/src/example.ts @@ -3,12 +3,8 @@ import { Plugin } from "./index" export const ExamplePlugin: Plugin = async ({ app, client, $ }) => { return { permission: {}, - tool: { - execute: { - async before(input, output) { - console.log("before", input, output) - }, - }, + async "chat.params"(input, output) { + output.topP = 1 }, } } diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts index 9040fb517..be9822ee2 100644 --- a/packages/plugin/src/index.ts +++ b/packages/plugin/src/index.ts @@ -10,47 +10,28 @@ export type Plugin = (input: PluginInput) => Promise<Hooks> export interface Hooks { event?: (input: { event: Event }) => Promise<void> - chat?: { - /** - * Called when a new message is received - */ - message?: (input: {}, output: { message: UserMessage; parts: Part[] }) => Promise<void> - /** - * Modify parameters sent to LLM - */ - params?: ( - input: { model: Model; provider: Provider; message: UserMessage }, - output: { temperature: number; topP: number }, - ) => Promise<void> - } - permission?: { - /** - * Called when a permission is asked - */ - ask?: (input: Permission, output: { status: "ask" | "deny" | "allow" }) => Promise<void> - } - tool?: { - execute?: { - /** - * Called before a tool is executed - */ - before?: ( - input: { tool: string; sessionID: string; callID: string }, - output: { - args: any - }, - ) => Promise<void> - /** - * Called after a tool is executed - */ - after?: ( - input: { tool: string; sessionID: string; callID: string }, - output: { - title: string - output: string - metadata: any - }, - ) => Promise<void> - } - } + /** + * Called when a new message is received + */ + "chat.message"?: (input: {}, output: { message: UserMessage; parts: Part[] }) => Promise<void> + /** + * Modify parameters sent to LLM + */ + "chat.params"?: ( + input: { model: Model; provider: Provider; message: UserMessage }, + output: { temperature: number; topP: number }, + ) => Promise<void> + "permission.ask"?: (input: Permission, output: { status: "ask" | "deny" | "allow" }) => Promise<void> + "tool.execute.before"?: ( + input: { tool: string; sessionID: string; callID: string }, + output: { args: any }, + ) => Promise<void> + "tool.execute.after"?: ( + input: { tool: string; sessionID: string; callID: string }, + output: { + title: string + output: string + metadata: any + }, + ) => Promise<void> } |
