|
| 1 | +import { createOpencodeClient } from "@opencode-ai/sdk" |
1 | 2 | import type { |
2 | 3 | Event, |
3 | | - createOpencodeClient, |
4 | 4 | Project, |
5 | 5 | Model, |
6 | 6 | Provider, |
7 | | - Permission, |
8 | 7 | UserMessage, |
9 | | - Message, |
10 | | - Part, |
11 | 8 | Auth, |
12 | 9 | Config, |
13 | | -} from "@opencode-ai/sdk" |
| 10 | + Agent, |
| 11 | + Message, |
| 12 | + Part, |
| 13 | +} from "@opencode-ai/sdk/v2" |
14 | 14 |
|
15 | 15 | import type { BunShell } from "./shell" |
16 | 16 | import { type ToolDefinition } from "./tool" |
@@ -169,29 +169,42 @@ export interface Hooks { |
169 | 169 | * Modify parameters sent to LLM |
170 | 170 | */ |
171 | 171 | "chat.params"?: ( |
172 | | - input: { sessionID: string; agent: string; model: Model; provider: ProviderContext; message: UserMessage }, |
173 | | - output: { temperature: number; topP: number; topK: number; options: Record<string, any> }, |
| 172 | + input: { sessionID: string; agent: Agent; model: Model; provider: Provider; message: UserMessage }, |
| 173 | + output: { temperature?: number; topP?: number; topK?: number; options: Record<string, any> }, |
174 | 174 | ) => Promise<void> |
175 | 175 | "chat.headers"?: ( |
176 | | - input: { sessionID: string; agent: string; model: Model; provider: ProviderContext; message: UserMessage }, |
| 176 | + input: { sessionID: string; agent: Omit<Agent, 'builtIn' | 'tools'>; model: Model; provider: Provider; message: UserMessage }, |
177 | 177 | output: { headers: Record<string, string> }, |
178 | 178 | ) => Promise<void> |
179 | | - "permission.ask"?: (input: Permission, output: { status: "ask" | "deny" | "allow" }) => Promise<void> |
| 179 | + "permission.ask"?: ( |
| 180 | + input: { |
| 181 | + id: string |
| 182 | + type: string |
| 183 | + pattern?: string | Array<string> |
| 184 | + sessionID: string |
| 185 | + messageID: string |
| 186 | + callID?: string |
| 187 | + message: string |
| 188 | + metadata: { [key: string]: unknown } |
| 189 | + time: { created: number } |
| 190 | + }, |
| 191 | + output: { status: "ask" | "deny" | "allow" }, |
| 192 | + ) => Promise<void> |
180 | 193 | "command.execute.before"?: ( |
181 | 194 | input: { command: string; sessionID: string; arguments: string }, |
182 | | - output: { parts: Part[] }, |
| 195 | + output: { parts: Omit<Part | { id?: string }, 'sessionID' | 'messageID'>[] }, |
183 | 196 | ) => Promise<void> |
184 | 197 | "tool.execute.before"?: ( |
185 | | - input: { tool: string; sessionID: string; callID: string }, |
| 198 | + input: { tool: string; sessionID: string; callID?: string }, |
186 | 199 | output: { args: any }, |
187 | 200 | ) => Promise<void> |
188 | 201 | "tool.execute.after"?: ( |
189 | | - input: { tool: string; sessionID: string; callID: string }, |
| 202 | + input: { tool: string; sessionID: string; callID?: string }, |
190 | 203 | output: { |
191 | 204 | title: string |
192 | 205 | output: string |
193 | 206 | metadata: any |
194 | | - }, |
| 207 | + } | undefined, |
195 | 208 | ) => Promise<void> |
196 | 209 | "experimental.chat.messages.transform"?: ( |
197 | 210 | input: {}, |
|
0 commit comments