@@ -21,8 +21,8 @@ import { AnthropicStreamState } from './types';
2121
2222interface AnthropicTool extends PromptCache {
2323 name : string ;
24- description : string ;
25- input_schema : {
24+ description ? : string ;
25+ input_schema ? : {
2626 type : string ;
2727 properties : Record <
2828 string ,
@@ -32,7 +32,12 @@ interface AnthropicTool extends PromptCache {
3232 }
3333 > ;
3434 required : string [ ] ;
35+ $defs : Record < string , any > ;
3536 } ;
37+ type ?: string ;
38+ display_width_px ?: number ;
39+ display_height_px ?: number ;
40+ display_number ?: number ;
3641}
3742
3843interface AnthropicToolResultContentItem {
@@ -130,7 +135,9 @@ const transformAssistantMessage = (msg: Message): AnthropicMessage => {
130135 type : 'tool_use' ,
131136 name : toolCall . function . name ,
132137 id : toolCall . id ,
133- input : JSON . parse ( toolCall . function . arguments ) ,
138+ input : toolCall . function . arguments ?. length
139+ ? JSON . parse ( toolCall . function . arguments )
140+ : { } ,
134141 } ) ;
135142 } ) ;
136143 }
@@ -336,11 +343,18 @@ export const AnthropicChatCompleteConfig: ProviderConfig = {
336343 type : tool . function . parameters ?. type || 'object' ,
337344 properties : tool . function . parameters ?. properties || { } ,
338345 required : tool . function . parameters ?. required || [ ] ,
346+ $defs : tool . function . parameters ?. [ '$defs' ] || { } ,
339347 } ,
340348 ...( tool . cache_control && {
341349 cache_control : { type : 'ephemeral' } ,
342350 } ) ,
343351 } ) ;
352+ } else if ( tool . computer ) {
353+ tools . push ( {
354+ ...tool . computer ,
355+ name : 'computer' ,
356+ type : tool . computer . name ,
357+ } ) ;
344358 }
345359 } ) ;
346360 }
0 commit comments