import { describe, it, expect } from 'vitest'; import type { ChatRequest, ChatResponse, ToolMessage, ContentBlock } from './types.js'; describe('Model types with tool support', () => { it('ChatRequest accepts tools array', () => { const req: ChatRequest = { messages: [{ role: 'user', content: 'hi' }], tools: [{ name: 'test', description: 'test tool', input_schema: { type: 'object', properties: {} }, }], }; expect(req.tools).toHaveLength(1); }); it('ChatResponse has optional toolCalls', () => { const resp: ChatResponse = { content: '', stopReason: 'tool_use', usage: { inputTokens: 0, outputTokens: 0 }, toolCalls: [{ id: 'call_1', name: 'test', args: {} }], }; expect(resp.toolCalls).toHaveLength(1); expect(resp.stopReason).toBe('tool_use'); }); it('ChatResponse works without toolCalls (backward compatible)', () => { const resp: ChatResponse = { content: 'hello', stopReason: 'end_turn', usage: { inputTokens: 10, outputTokens: 5 }, }; expect(resp.toolCalls).toBeUndefined(); }); it('ToolMessage represents tool results in conversation', () => { const msg: ToolMessage = { role: 'tool_result', toolResults: [{ tool_use_id: 'call_1', content: 'result', is_error: false }], }; expect(msg.role).toBe('tool_result'); expect(msg.toolResults).toHaveLength(1); }); it('ContentBlock can be text or tool_use', () => { const text: ContentBlock = { type: 'text', text: 'hello' }; const tool: ContentBlock = { type: 'tool_use', id: 'c1', name: 'test', input: {} }; expect(text.type).toBe('text'); expect(tool.type).toBe('tool_use'); }); });