Skip to content

Commit b5ad3c1

Browse files
feat(anthropic): support computer use tool
1 parent f74479a commit b5ad3c1

File tree

1 file changed

+131
-0
lines changed
  • libs/providers/langchain-anthropic/src/tools

1 file changed

+131
-0
lines changed

libs/providers/langchain-anthropic/src/tools/types.ts

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,134 @@ export interface ComputerZoomAction {
196196
/** Coordinates [x1, y1, x2, y2] defining top-left and bottom-right corners */
197197
region: [number, number, number, number];
198198
}
199+
200+
/**
201+
* Computer use tool action types for Claude Opus 4.5.
202+
* Includes zoom action which is not available in earlier versions.
203+
* @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/computer-use
204+
*/
205+
export type Computer20251124Action =
206+
| ComputerScreenshotAction
207+
| ComputerLeftClickAction
208+
| ComputerRightClickAction
209+
| ComputerMiddleClickAction
210+
| ComputerDoubleClickAction
211+
| ComputerTripleClickAction
212+
| ComputerLeftClickDragAction
213+
| ComputerLeftMouseDownAction
214+
| ComputerLeftMouseUpAction
215+
| ComputerScrollAction
216+
| ComputerTypeAction
217+
| ComputerKeyAction
218+
| ComputerMouseMoveAction
219+
| ComputerHoldKeyAction
220+
| ComputerWaitAction
221+
| ComputerZoomAction;
222+
223+
/**
224+
* Computer use tool action types for Claude 4 models and Claude 3.7.
225+
* @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/computer-use
226+
*/
227+
export type Computer20250124Action =
228+
| ComputerScreenshotAction
229+
| ComputerLeftClickAction
230+
| ComputerRightClickAction
231+
| ComputerMiddleClickAction
232+
| ComputerDoubleClickAction
233+
| ComputerTripleClickAction
234+
| ComputerLeftClickDragAction
235+
| ComputerLeftMouseDownAction
236+
| ComputerLeftMouseUpAction
237+
| ComputerScrollAction
238+
| ComputerTypeAction
239+
| ComputerKeyAction
240+
| ComputerMouseMoveAction
241+
| ComputerHoldKeyAction
242+
| ComputerWaitAction;
243+
244+
export interface ComputerScreenshotAction {
245+
action: "screenshot";
246+
}
247+
248+
export interface ComputerLeftClickAction {
249+
action: "left_click";
250+
coordinate: [number, number];
251+
}
252+
253+
export interface ComputerRightClickAction {
254+
action: "right_click";
255+
coordinate: [number, number];
256+
}
257+
258+
export interface ComputerMiddleClickAction {
259+
action: "middle_click";
260+
coordinate: [number, number];
261+
}
262+
263+
export interface ComputerDoubleClickAction {
264+
action: "double_click";
265+
coordinate: [number, number];
266+
}
267+
268+
export interface ComputerTripleClickAction {
269+
action: "triple_click";
270+
coordinate: [number, number];
271+
}
272+
273+
export interface ComputerLeftClickDragAction {
274+
action: "left_click_drag";
275+
start_coordinate: [number, number];
276+
end_coordinate: [number, number];
277+
}
278+
279+
export interface ComputerLeftMouseDownAction {
280+
action: "left_mouse_down";
281+
coordinate: [number, number];
282+
}
283+
284+
export interface ComputerLeftMouseUpAction {
285+
action: "left_mouse_up";
286+
coordinate: [number, number];
287+
}
288+
289+
export interface ComputerScrollAction {
290+
action: "scroll";
291+
coordinate: [number, number];
292+
scroll_direction: "up" | "down" | "left" | "right";
293+
scroll_amount: number;
294+
}
295+
296+
export interface ComputerTypeAction {
297+
action: "type";
298+
text: string;
299+
}
300+
301+
export interface ComputerKeyAction {
302+
action: "key";
303+
key: string;
304+
}
305+
306+
export interface ComputerMouseMoveAction {
307+
action: "mouse_move";
308+
coordinate: [number, number];
309+
}
310+
311+
export interface ComputerHoldKeyAction {
312+
action: "hold_key";
313+
key: string;
314+
}
315+
316+
export interface ComputerWaitAction {
317+
action: "wait";
318+
duration?: number;
319+
}
320+
321+
/**
322+
* Zoom action for Claude Opus 4.5 only.
323+
* Allows viewing a specific region of the screen at full resolution.
324+
*/
325+
export interface ComputerZoomAction {
326+
action: "zoom";
327+
/** Coordinates [x1, y1, x2, y2] defining top-left and bottom-right corners */
328+
region: [number, number, number, number];
329+
}

0 commit comments

Comments
 (0)