* Registers custom tool handlers for this session. * * Tools with handlers allow the assistant to execute custom functions automatically. * Declaration-only tools are surfaced as events and left pending for the consumer. * * @param tools - An array of tool definitions with t
(tools?: Tool[])
| 768 | * @internal This method is typically called internally when creating a session with tools. |
| 769 | */ |
| 770 | registerTools(tools?: Tool[]): void { |
| 771 | this.toolHandlers.clear(); |
| 772 | if (!tools) { |
| 773 | return; |
| 774 | } |
| 775 | |
| 776 | for (const tool of tools) { |
| 777 | if (tool.handler) { |
| 778 | this.toolHandlers.set(tool.name, tool.handler); |
| 779 | } |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | /** |
| 784 | * Retrieves a registered tool handler by name. |
no test coverage detected