(callbackId: string, timeout?: number)
| 659 | } |
| 660 | |
| 661 | createHookCallback(callbackId: string, timeout?: number): HookCallback { |
| 662 | return { |
| 663 | type: 'callback', |
| 664 | timeout, |
| 665 | callback: async ( |
| 666 | input: HookInput, |
| 667 | toolUseID: string | null, |
| 668 | abort: AbortSignal | undefined, |
| 669 | ): Promise<HookJSONOutput> => { |
| 670 | try { |
| 671 | const result = await this.sendRequest<HookJSONOutput>( |
| 672 | { |
| 673 | subtype: 'hook_callback', |
| 674 | callback_id: callbackId, |
| 675 | input, |
| 676 | tool_use_id: toolUseID || undefined, |
| 677 | }, |
| 678 | hookJSONOutputSchema(), |
| 679 | abort, |
| 680 | ) |
| 681 | return result |
| 682 | } catch (error) { |
| 683 | // biome-ignore lint/suspicious/noConsole:: intentional console output |
| 684 | console.error(`Error in hook callback ${callbackId}:`, error) |
| 685 | return {} |
| 686 | } |
| 687 | }, |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | /** |
| 692 | * Sends an elicitation request to the SDK consumer and returns the response. |
no test coverage detected