import type { Anthropic } from '@anthropic-ai/sdk'; import { AnthropicToolChoice } from '../types.js'; export function handleToolChoice( toolChoice?: AnthropicToolChoice ): | Anthropic.Messages.ToolChoiceAuto | Anthropic.Messages.ToolChoiceAny | Anthropic.Messages.ToolChoiceTool | undefined { if (toolChoice == null) { return undefined; } else if (toolChoice === 'any') { return { type: 'any', }; } else if (toolChoice === 'auto') { return { type: 'auto', }; } else if (typeof toolChoice === 'string') { return { type: 'tool', name: toolChoice, }; } else { return toolChoice; } }