@@ -14,7 +14,7 @@ function asNativeInput(args: unknown): NativeInput {
1414
1515const MAX_KEY_REPEAT = 100 ;
1616
17- /** Map one `computer_20260701` tool input onto canonical computer-plane actions. */
17+ /** Map one Anthropic computer toolset member onto canonical computer-plane actions. */
1818export function mapNativeComputerInput ( input : NativeInput ) : ComputerUseAction [ ] {
1919 switch ( input . action ) {
2020 case "screenshot" :
@@ -52,19 +52,19 @@ export function mapNativeComputerInput(input: NativeInput): ComputerUseAction[]
5252 }
5353 case "hold_key" :
5454 // Canonical keypress duration is milliseconds; the native tool speaks seconds.
55- return [ { type : "keypress" , keys : [ text ( input ) ] , duration : durationSeconds ( input ) * 1000 } ] ;
55+ return [ { type : "keypress" , keys : [ text ( input ) ] , duration : durationSeconds ( input , 300 ) * 1000 } ] ;
5656 case "wait" :
57- return [ { type : "wait" , ms : durationSeconds ( input ) * 1000 } ] ;
57+ return [ { type : "wait" , ms : durationSeconds ( input , 300 ) * 1000 } ] ;
5858 case "cursor_position" :
5959 return [ { type : "cursor_position" } ] ;
6060 case "zoom" :
6161 return [ { type : "zoom" , region : region ( input . region ) } ] ;
6262 default :
63- throw new Error ( `unsupported computer_20260701 action "${ input . action } "` ) ;
63+ throw new Error ( `unsupported computer toolset member "${ input . action } "` ) ;
6464 }
6565}
6666
67- /** Map one `browser_20260701` tool input onto canonical browser-plane actions. */
67+ /** Map one Anthropic browser toolset member onto canonical browser-plane actions. */
6868export function mapNativeBrowserInput ( input : NativeInput ) : ComputerUseAction [ ] {
6969 const tab = tabId ( input ) ;
7070 switch ( input . action ) {
@@ -100,12 +100,20 @@ export function mapNativeBrowserInput(input: NativeInput): ComputerUseAction[] {
100100 return [ { type : "browser_click" , ...pageTarget ( input . target ) , ...modifiers ( input . modifiers ) , ...tab } ] ;
101101 case "right_click" :
102102 return [ { type : "browser_click" , ...pageTarget ( input . target ) , button : "right" , ...modifiers ( input . modifiers ) , ...tab } ] ;
103+ case "middle_click" :
104+ return [ { type : "browser_click" , ...pageTarget ( input . target ) , button : "middle" , ...modifiers ( input . modifiers ) , ...tab } ] ;
103105 case "double_click" :
104106 return [ { type : "browser_click" , ...pageTarget ( input . target ) , num_clicks : 2 , ...modifiers ( input . modifiers ) , ...tab } ] ;
105107 case "triple_click" :
106108 return [ { type : "browser_click" , ...pageTarget ( input . target ) , num_clicks : 3 , ...modifiers ( input . modifiers ) , ...tab } ] ;
107109 case "hover" :
108110 return [ { type : "browser_hover" , ...pageTarget ( input . target ) , ...tab } ] ;
111+ case "mouse_move" :
112+ return [ { type : "browser_hover" , ...coordinateTarget ( input . target , "target" ) , ...tab } ] ;
113+ case "left_mouse_down" :
114+ return [ { type : "browser_mouse_down" , ...coordinateTarget ( input . target , "target" ) , ...tab } ] ;
115+ case "left_mouse_up" :
116+ return [ { type : "browser_mouse_up" , ...coordinateTarget ( input . target , "target" ) , ...tab } ] ;
109117 case "left_click_drag" :
110118 return [ { type : "browser_drag" , from : coordinateTarget ( input . from , "from" ) , to : coordinateTarget ( input . target , "target" ) , ...tab } ] ;
111119 case "scroll" :
@@ -124,12 +132,18 @@ export function mapNativeBrowserInput(input: NativeInput): ComputerUseAction[] {
124132 const repeat = clampRepeat ( input . repeat ) ;
125133 return Array . from ( { length : repeat } , ( ) => ( { type : "browser_key" as const , text : text ( input ) , ...tab } ) ) ;
126134 }
135+ case "hold_key" :
136+ return [ { type : "browser_hold_key" , text : text ( input ) , duration : durationSeconds ( input , 30 ) , ...tab } ] ;
127137 case "wait" :
128- return [ { type : "wait" , ms : durationSeconds ( input ) * 1000 } ] ;
138+ return [ { type : "wait" , ms : durationSeconds ( input , 30 ) * 1000 } ] ;
139+ case "switch_tab" :
140+ return [ { type : "browser_switch_tab" , tab_id : requireString ( input . tab_id , "tab_id" ) } ] ;
141+ case "close_tab" :
142+ return [ { type : "browser_close_tab" , tab_id : requireString ( input . tab_id , "tab_id" ) } ] ;
129143 case "javascript_exec" :
130144 return [ { type : "browser_evaluate" , code : text ( input ) , ...tab } ] ;
131145 default :
132- throw new Error ( `unsupported browser_20260701 action "${ input . action } "` ) ;
146+ throw new Error ( `unsupported browser toolset member "${ input . action } "` ) ;
133147 }
134148}
135149
@@ -191,10 +205,10 @@ function requireString(value: unknown, field: string): string {
191205 return value ;
192206}
193207
194- function durationSeconds ( input : NativeInput ) : number {
208+ function durationSeconds ( input : NativeInput , maximum : number ) : number {
195209 const value = input . duration ;
196210 if ( typeof value !== "number" || ! Number . isFinite ( value ) || value < 0 ) throw new Error ( "invalid duration: expected a non-negative number" ) ;
197- return Math . min ( value , 100 ) ;
211+ return Math . min ( value , maximum ) ;
198212}
199213
200214function clampRepeat ( value : unknown ) : number {
0 commit comments