inspect-ai 0.3.71__py3-none-any.whl → 0.3.72__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. inspect_ai/_view/www/node_modules/flatted/python/flatted.py +149 -0
  2. inspect_ai/_view/www/node_modules/flatted/python/test.py +63 -0
  3. inspect_ai/model/_providers/anthropic.py +148 -128
  4. inspect_ai/tool/_tools/_computer/_common.py +117 -58
  5. inspect_ai/tool/_tools/_computer/_computer.py +80 -57
  6. inspect_ai/tool/_tools/_computer/_resources/image_home_dir/.config/Code/User/settings.json +7 -1
  7. inspect_ai/tool/_tools/_computer/_resources/image_home_dir/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml +91 -0
  8. inspect_ai/tool/_tools/_computer/_resources/tool/.pylintrc +8 -0
  9. inspect_ai/tool/_tools/_computer/_resources/tool/.vscode/settings.json +12 -0
  10. inspect_ai/tool/_tools/_computer/_resources/tool/_args.py +78 -0
  11. inspect_ai/tool/_tools/_computer/_resources/tool/_constants.py +20 -0
  12. inspect_ai/tool/_tools/_computer/_resources/tool/_x11_client.py +175 -113
  13. inspect_ai/tool/_tools/_computer/_resources/tool/computer_tool.py +76 -20
  14. inspect_ai/tool/_tools/_computer/_resources/tool/pyproject.toml +65 -0
  15. inspect_ai/tool/_tools/_computer/test_args.py +151 -0
  16. {inspect_ai-0.3.71.dist-info → inspect_ai-0.3.72.dist-info}/METADATA +1 -1
  17. {inspect_ai-0.3.71.dist-info → inspect_ai-0.3.72.dist-info}/RECORD +21 -13
  18. inspect_ai/tool/_tools/_computer/_computer_split.py +0 -198
  19. {inspect_ai-0.3.71.dist-info → inspect_ai-0.3.72.dist-info}/LICENSE +0 -0
  20. {inspect_ai-0.3.71.dist-info → inspect_ai-0.3.72.dist-info}/WHEEL +0 -0
  21. {inspect_ai-0.3.71.dist-info → inspect_ai-0.3.72.dist-info}/entry_points.txt +0 -0
  22. {inspect_ai-0.3.71.dist-info → inspect_ai-0.3.72.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,151 @@
1
+ import pytest
2
+
3
+ from ._resources.tool._args import parse_arguments
4
+
5
+
6
+ def test_parse_args_screenshot() -> None:
7
+ args = parse_arguments(["screenshot"])
8
+ assert args.action == "screenshot"
9
+
10
+
11
+ def test_parse_args_cursor_position() -> None:
12
+ args = parse_arguments(["cursor_position"])
13
+ assert args.action == "cursor_position"
14
+
15
+
16
+ def test_parse_args_type() -> None:
17
+ args = parse_arguments(["type", "--text", "hello"])
18
+ assert args.action == "type"
19
+ assert args.text == "hello"
20
+
21
+
22
+ def test_parse_args_mouse_move() -> None:
23
+ args = parse_arguments(["mouse_move", "--coordinate", "100", "200"])
24
+ assert args.action == "mouse_move"
25
+ assert args.coordinate == [100, 200]
26
+
27
+
28
+ def test_parse_args_left_click() -> None:
29
+ args = parse_arguments(["left_click", "--coordinate", "100", "200"])
30
+ assert args.action == "left_click"
31
+ assert args.coordinate == [100, 200]
32
+
33
+
34
+ def test_parse_args_right_click() -> None:
35
+ args = parse_arguments(["right_click", "--coordinate", "100", "200"])
36
+ assert args.action == "right_click"
37
+ assert args.coordinate == [100, 200]
38
+
39
+
40
+ def test_parse_args_middle_click() -> None:
41
+ args = parse_arguments(["middle_click", "--coordinate", "100", "200"])
42
+ assert args.action == "middle_click"
43
+ assert args.coordinate == [100, 200]
44
+
45
+
46
+ def test_parse_args_double_click() -> None:
47
+ args = parse_arguments(["double_click", "--coordinate", "100", "200"])
48
+ assert args.action == "double_click"
49
+ assert args.coordinate == [100, 200]
50
+
51
+
52
+ def test_parse_args_triple_click() -> None:
53
+ args = parse_arguments(["triple_click", "--coordinate", "100", "200"])
54
+ assert args.action == "triple_click"
55
+ assert args.coordinate == [100, 200]
56
+
57
+
58
+ def test_parse_args_hold_key() -> None:
59
+ args = parse_arguments(["hold_key", "--text", "a", "--duration", "5"])
60
+ assert args.action == "hold_key"
61
+ assert args.text == "a"
62
+ assert args.duration == 5
63
+
64
+
65
+ def test_parse_args_left_click_drag() -> None:
66
+ args = parse_arguments(
67
+ [
68
+ "left_click_drag",
69
+ "--start_coordinate",
70
+ "100",
71
+ "200",
72
+ "--coordinate",
73
+ "300",
74
+ "400",
75
+ "--text",
76
+ "drag",
77
+ ]
78
+ )
79
+ assert args.action == "left_click_drag"
80
+ assert args.start_coordinate == [100, 200]
81
+ assert args.coordinate == [300, 400]
82
+ assert args.text == "drag"
83
+
84
+
85
+ def test_parse_args_scroll() -> None:
86
+ args = parse_arguments(
87
+ [
88
+ "scroll",
89
+ "--scroll_direction",
90
+ "up",
91
+ "--scroll_amount",
92
+ "10",
93
+ "--coordinate",
94
+ "100",
95
+ "200",
96
+ ]
97
+ )
98
+ assert args.action == "scroll"
99
+ assert args.scroll_direction == "up"
100
+ assert args.scroll_amount == 10
101
+ assert args.coordinate == [100, 200]
102
+
103
+
104
+ def test_parse_args_wait() -> None:
105
+ args = parse_arguments(["wait", "--duration", "5"])
106
+ assert args.action == "wait"
107
+ assert args.duration == 5
108
+
109
+
110
+ def test_parse_args_type_missing_text() -> None:
111
+ with pytest.raises(SystemExit):
112
+ parse_arguments(["type"])
113
+
114
+
115
+ def test_parse_args_invalid_action() -> None:
116
+ with pytest.raises(SystemExit):
117
+ parse_arguments(["invalid_action"])
118
+
119
+
120
+ def test_parse_args_mouse_move_missing_coordinate() -> None:
121
+ with pytest.raises(SystemExit):
122
+ parse_arguments(["mouse_move"])
123
+
124
+
125
+ def test_parse_args_click_invalid_coordinate() -> None:
126
+ with pytest.raises(SystemExit):
127
+ parse_arguments(["left_click", "--coordinate", "100"])
128
+
129
+
130
+ def test_parse_args_hold_key_missing_duration() -> None:
131
+ with pytest.raises(SystemExit):
132
+ parse_arguments(["hold_key", "--text", "a"])
133
+
134
+
135
+ def test_parse_args_left_click_drag_missing_start_coordinate() -> None:
136
+ with pytest.raises(SystemExit):
137
+ parse_arguments(
138
+ ["left_click_drag", "--coordinate", "300", "400", "--text", "drag"]
139
+ )
140
+
141
+
142
+ def test_parse_args_scroll_missing_scroll_direction() -> None:
143
+ with pytest.raises(SystemExit):
144
+ parse_arguments(
145
+ ["scroll", "--scroll_amount", "10", "--coordinate", "100", "200"]
146
+ )
147
+
148
+
149
+ def test_parse_args_wait_missing_duration() -> None:
150
+ with pytest.raises(SystemExit):
151
+ parse_arguments(["wait"])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: inspect_ai
3
- Version: 0.3.71
3
+ Version: 0.3.72
4
4
  Summary: Framework for large language model evaluations
5
5
  Author: UK AI Security Institute
6
6
  License: MIT License
@@ -142,6 +142,8 @@ inspect_ai/_view/www/dist/index.html,sha256=gpdu6SR-SOH9EWx15cCWHzujMZujnZR5tRlE
142
142
  inspect_ai/_view/www/dist/assets/favicon.svg,sha256=b9AHYZaO2zBzeKH6G4PwXZMGGW_UxY0omKHam-c9MAs,1508
143
143
  inspect_ai/_view/www/dist/assets/index.css,sha256=mKi28ncgmZ4plebpFbAQA8XVzQR4rpcanTXeUwRohdg,895284
144
144
  inspect_ai/_view/www/dist/assets/index.js,sha256=2sU6BLWcnnfYVvy-lrP4cN6CWhiSYHlqI5BlZu1uJkM,2737852
145
+ inspect_ai/_view/www/node_modules/flatted/python/flatted.py,sha256=ke8FuEflns-WlphCcQ9CC0qJqWqX3zEEuak74o6rgE8,3879
146
+ inspect_ai/_view/www/node_modules/flatted/python/test.py,sha256=uTOn6HJd7KeY_PTRvvufv60dmvON3KWp3nnqACj8IlA,2129
145
147
  inspect_ai/_view/www/src/App.tsx,sha256=rhiZKs-f1y9amyX_OLay7aL4OXaQ_o0gNd04M3pZVuk,28852
146
148
  inspect_ai/_view/www/src/AppErrorBoundary.tsx,sha256=RyhZWbIMZj1QeUOUUXh9hUFvq6LoDEoHuTY0giswmL0,1169
147
149
  inspect_ai/_view/www/src/constants.ts,sha256=UIxGbDscs61CcOQLQiW6MsZAU1uupSYNVLGxx2pp14A,1169
@@ -461,7 +463,7 @@ inspect_ai/model/_openai.py,sha256=f7xzsOsE-2Q-L3whDbt8qzZCc5GKkMt0EDmDQDygisw,1
461
463
  inspect_ai/model/_reasoning.py,sha256=qmR8WT6t_cb7NIsJOQHPyFZh2eLV0HmYxKo2vtvteQ4,929
462
464
  inspect_ai/model/_registry.py,sha256=Cr2y32EqLnOqLbSWoXHVK4ivTTzCUhJuACxoTyPt8kY,2032
463
465
  inspect_ai/model/_render.py,sha256=rWypNUjgrH4NGp0r-ESAze9gZz7lYNjheEP438vRYZE,922
464
- inspect_ai/model/_providers/anthropic.py,sha256=qDK-kFS-zXOd6kS7AX95PQxV6vDfkB0NCaccefGe0tA,29367
466
+ inspect_ai/model/_providers/anthropic.py,sha256=Ngef2jDkMcBuFaXMWza-iJckKJqEldbl2U4UqmZdEkc,30521
465
467
  inspect_ai/model/_providers/azureai.py,sha256=L0aZrx-mcRLZWXmNQG2gEmGYVQ7QtLF-o7hvM9dbMeY,14162
466
468
  inspect_ai/model/_providers/bedrock.py,sha256=glBi-3uaWu7ywhBHB-8RSpgTLBvEVZqULyhkwgQxr98,23829
467
469
  inspect_ai/model/_providers/cloudflare.py,sha256=qS75o1elsdPNrL1dfecJK_JD9WOMX-Ogzf3DNK5jaHk,4634
@@ -555,9 +557,9 @@ inspect_ai/tool/_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
555
557
  inspect_ai/tool/_tools/_execute.py,sha256=SZdtVxxGoQNErWFtYaJgfTtLsZbBP28lnY112mt-VWQ,3435
556
558
  inspect_ai/tool/_tools/_web_search.py,sha256=DjxLfKbhvz6sPAncHT7MR3NPz0swiCn_X6xonAeR22M,7869
557
559
  inspect_ai/tool/_tools/_computer/__init__.py,sha256=fq4BSM4aDhtEtE4279xm47NiO6vyiZHhhw7cq-azFzk,56
558
- inspect_ai/tool/_tools/_computer/_common.py,sha256=JbnxNlFclV7C_ThEsf_BW7BO7Lu8GZSwFBx5BSlxMY8,4049
559
- inspect_ai/tool/_tools/_computer/_computer.py,sha256=vxoY7gjtF_8cCn-IYuyipVfI6mla0feJfpyrH53y6hc,7825
560
- inspect_ai/tool/_tools/_computer/_computer_split.py,sha256=H3DVCJqpHp_2ra85W_z9s5r-oHTVWwctuEq5fDdy2T4,5588
560
+ inspect_ai/tool/_tools/_computer/_common.py,sha256=nX8Cf9jagsnjwZb9f9eWADUjzETf6PSNRcFrzp0_KLg,5949
561
+ inspect_ai/tool/_tools/_computer/_computer.py,sha256=-HdnT0syLRYhyWMsATFJVc3UcBrs2gY1OQ_oiR31mE4,9146
562
+ inspect_ai/tool/_tools/_computer/test_args.py,sha256=tgySEFbsI-jPK9LA75ickN3qI_bLev81XGaprgoKL5k,4234
561
563
  inspect_ai/tool/_tools/_computer/_resources/Dockerfile,sha256=DA1ZzOqO3vEySSfoDV9bCBl_iVmpzhiNz_s1Oyd1gO0,3568
562
564
  inspect_ai/tool/_tools/_computer/_resources/README.md,sha256=5JDNaGJ-Ebq6Io57ANFIqgjPoh11aGDSrrgrhyfiqxU,1657
563
565
  inspect_ai/tool/_tools/_computer/_resources/entrypoint/entrypoint.sh,sha256=IR8sE-b22YO7lwzdDiyjhLTJWIf0X__wA8WE98dwkwM,394
@@ -565,20 +567,26 @@ inspect_ai/tool/_tools/_computer/_resources/entrypoint/novnc_startup.sh,sha256=P
565
567
  inspect_ai/tool/_tools/_computer/_resources/entrypoint/x11vnc_startup.sh,sha256=JFcW46u2ioDpGLptmUOMaqtt2YvuFhCTB42cyWRmo8c,993
566
568
  inspect_ai/tool/_tools/_computer/_resources/entrypoint/xfce_startup.sh,sha256=w_27I4o7usP8SUMzP3lrXeNuISslyy1aywkgpm_2l4Q,209
567
569
  inspect_ai/tool/_tools/_computer/_resources/entrypoint/xvfb_startup.sh,sha256=hd2naWFFpm3S0cWZ6Lhlpm6KD3L6-g8Zw2dgxchXMUg,1118
568
- inspect_ai/tool/_tools/_computer/_resources/image_home_dir/.config/Code/User/settings.json,sha256=n4B3q9qIcPnku_LXa3s0c87rtS7rpYRRMRrZfQuef3M,48
570
+ inspect_ai/tool/_tools/_computer/_resources/image_home_dir/.config/Code/User/settings.json,sha256=lgMzLKdThcGlGRlqgmJFBismaGtVB7Nx10hgDsS5VaA,230
569
571
  inspect_ai/tool/_tools/_computer/_resources/image_home_dir/.config/Code/User/globalStorage/state.vscdb,sha256=IywnS_kbluMmzEigds2Leg1r_uoIQEDX1eWKtYy4fQc,155648
570
572
  inspect_ai/tool/_tools/_computer/_resources/image_home_dir/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml,sha256=dIUGsB1BFK37S1ahbyhCiFsyGlGS4yT_paViPwXBW_g,2725
571
573
  inspect_ai/tool/_tools/_computer/_resources/image_home_dir/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-screensaver.xml,sha256=jNgaNqBCngQlykTlLhmmdc_LLOrH2AMk7pUpLkbCjMY,312
574
+ inspect_ai/tool/_tools/_computer/_resources/image_home_dir/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml,sha256=6j7UX8YIffTEpcelpjd-gNtO5rtNCM5roI59hkBEK9o,5518
572
575
  inspect_ai/tool/_tools/_computer/_resources/image_home_dir/Desktop/Firefox Web Browser.desktop,sha256=Odm77RSEiTlMx7cY8odUCO2a8fvIUwHcpEUanpHzbL0,181
573
576
  inspect_ai/tool/_tools/_computer/_resources/image_home_dir/Desktop/Terminal.desktop,sha256=Kq3CHhYP-YjwEIUS90TJVib_LoQ-9Tq0-3VIGYj6urM,195
574
577
  inspect_ai/tool/_tools/_computer/_resources/image_home_dir/Desktop/Visual Studio Code.desktop,sha256=jYYu8pcdIhFCC_3cEgO-0z0A6eQO2WQkIVViebSBbpA,184
578
+ inspect_ai/tool/_tools/_computer/_resources/tool/.pylintrc,sha256=29ApBnQCmHnovZJxSpkVcoGBaMfnEXSK8WVi38s5M8Y,199
575
579
  inspect_ai/tool/_tools/_computer/_resources/tool/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
580
+ inspect_ai/tool/_tools/_computer/_resources/tool/_args.py,sha256=-Njv3RPaz7ZD3HJEERHwBrhwI4C5jQeXj_cFZNq9Lsc,2467
581
+ inspect_ai/tool/_tools/_computer/_resources/tool/_constants.py,sha256=vf31bFxF0A3xWFpcEHpCPtpouz4rOUkBn8NQMmJYjlM,336
576
582
  inspect_ai/tool/_tools/_computer/_resources/tool/_logger.py,sha256=owkNYe9lyShTLXoMqhK4Qtzacnt5FvSxN8Wqf2MO5XM,652
577
583
  inspect_ai/tool/_tools/_computer/_resources/tool/_run.py,sha256=yhg1LCWptRhK34tWfyvhm8oTkcnEesRd9ki_a4-o8As,1611
578
584
  inspect_ai/tool/_tools/_computer/_resources/tool/_tool_result.py,sha256=cd6JNFhwyI4yDlDTPFqCTB1mV8cqvDR1TBvlOe5qoSg,1131
579
- inspect_ai/tool/_tools/_computer/_resources/tool/_x11_client.py,sha256=TAPEpUYvN8oHYKG07d8CMB6QgKiMCbANZWNWda8VkcU,9559
580
- inspect_ai/tool/_tools/_computer/_resources/tool/computer_tool.py,sha256=0ehJuuUO6AlWUZKt3TyUbWQuwyBmkpsBbHxizZI_0GQ,2574
585
+ inspect_ai/tool/_tools/_computer/_resources/tool/_x11_client.py,sha256=jxMdmDLuMYj9mssJ_R_52JMqYX1Vtemo_GRCwQXqUDs,11726
586
+ inspect_ai/tool/_tools/_computer/_resources/tool/computer_tool.py,sha256=aZywnPv6QJWVUBD4jNERGLxI6aHfKl9u5m6BrgrtNYw,4704
587
+ inspect_ai/tool/_tools/_computer/_resources/tool/pyproject.toml,sha256=MCZ84Su8yT5GniEM5Iq1onvKHfdND4jscn6jqPt9SMA,1441
581
588
  inspect_ai/tool/_tools/_computer/_resources/tool/requirements.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
589
+ inspect_ai/tool/_tools/_computer/_resources/tool/.vscode/settings.json,sha256=cfeAnDRwpgensIPY5LeICNh5P-o5Hw951sdmHtqI_LU,151
582
590
  inspect_ai/tool/_tools/_web_browser/__init__.py,sha256=dnnzy96pcvMvxD1OGg4hG-doL7Ru7WH0i25Sb9VIXwE,65
583
591
  inspect_ai/tool/_tools/_web_browser/_web_browser.py,sha256=CDyBTqwM5MU-VdGixRXZXI7tTEEy4nY7JKPB4AM_w1M,16375
584
592
  inspect_ai/tool/_tools/_web_browser/_resources/.pylintrc,sha256=btgbudy--y-aMrbvpfH9OluYm9MLaJgwlpdQzZVhqco,187
@@ -640,9 +648,9 @@ inspect_ai/util/_sandbox/docker/internal.py,sha256=fATyk2pdtjSl-D0VPT4dmkXV-gOc5
640
648
  inspect_ai/util/_sandbox/docker/prereqs.py,sha256=0j6_OauBBnVlpBleADcZavIAAQZy4WewVjbRn9c0stg,3355
641
649
  inspect_ai/util/_sandbox/docker/service.py,sha256=hhHIWH1VDFLwehdGd19aUBD_VKfDO3GCPxpw1HSwVQk,2437
642
650
  inspect_ai/util/_sandbox/docker/util.py,sha256=EeInihCNXgUWxaqZ4dNOJd719kXL2_jr63QCoXn68vA,3154
643
- inspect_ai-0.3.71.dist-info/LICENSE,sha256=xZPCr8gTiFIerrA_DRpLAbw-UUftnLFsHxKeW-NTtq8,1081
644
- inspect_ai-0.3.71.dist-info/METADATA,sha256=huN-VbzYrWgHANgNHIXTh_9w1K290p1uj6wO0LTVt28,4781
645
- inspect_ai-0.3.71.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
646
- inspect_ai-0.3.71.dist-info/entry_points.txt,sha256=WGGLmzTzDWLzYfiyovSY6oEKuf-gqzSDNOb5V-hk3fM,54
647
- inspect_ai-0.3.71.dist-info/top_level.txt,sha256=Tp3za30CHXJEKLk8xLe9qGsW4pBzJpEIOMHOHNCXiVo,11
648
- inspect_ai-0.3.71.dist-info/RECORD,,
651
+ inspect_ai-0.3.72.dist-info/LICENSE,sha256=xZPCr8gTiFIerrA_DRpLAbw-UUftnLFsHxKeW-NTtq8,1081
652
+ inspect_ai-0.3.72.dist-info/METADATA,sha256=XimRPGg7EKQUmKJXG9hpB8GPHktP03zyFuF8mCT2rbs,4781
653
+ inspect_ai-0.3.72.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
654
+ inspect_ai-0.3.72.dist-info/entry_points.txt,sha256=WGGLmzTzDWLzYfiyovSY6oEKuf-gqzSDNOb5V-hk3fM,54
655
+ inspect_ai-0.3.72.dist-info/top_level.txt,sha256=Tp3za30CHXJEKLk8xLe9qGsW4pBzJpEIOMHOHNCXiVo,11
656
+ inspect_ai-0.3.72.dist-info/RECORD,,
@@ -1,198 +0,0 @@
1
- """
2
- This module provides the same functionality as the computer tool but via a list of per-action tools . e.g. computer_mouse_move(100, 100).
3
-
4
- The split version is not publicly exported, but is retained until we decide if it performs better than the monolithic computer tool.
5
- """
6
-
7
- from typing import Awaitable, Callable
8
-
9
- from inspect_ai.tool import Tool, ToolResult, tool
10
-
11
- from . import _common as common
12
-
13
- ActionFunction = Callable[[str], ToolResult | Awaitable[ToolResult]]
14
-
15
-
16
- def computer_split(timeout: int | None = None) -> list[Tool]:
17
- """
18
- Computer interaction tools.
19
-
20
- Args:
21
- timeout (int | None): Timeout (in seconds) for command.
22
-
23
- Returns:
24
- List of computer interaction tools.
25
- """
26
- return [
27
- computer_cursor_position(),
28
- computer_screenshot(),
29
- computer_mouse_move(),
30
- computer_left_click(),
31
- computer_double_click(),
32
- computer_left_click_drag(),
33
- computer_right_click(),
34
- computer_key(),
35
- computer_type(),
36
- ]
37
-
38
-
39
- @tool()
40
- def computer_cursor_position(timeout: int | None = None) -> Tool:
41
- async def execute() -> ToolResult:
42
- """
43
- Get the current (x, y) pixel coordinate of the cursor on the screen.
44
-
45
- Args:
46
- None
47
-
48
- Returns:
49
- A `str` of the form "x y" where x and y are the current mouse coordinates.
50
- """
51
- return await common.cursor_position(timeout=timeout)
52
-
53
- return execute
54
-
55
-
56
- @tool()
57
- def computer_screenshot(timeout: int | None = None) -> Tool:
58
- async def execute() -> ToolResult:
59
- """
60
- Take a screenshot.
61
-
62
- Args:
63
- None
64
-
65
- Returns:
66
- A `list` with a single `ContentImage` of the screen.
67
- """
68
- return await common.screenshot(timeout=timeout)
69
-
70
- return execute
71
-
72
-
73
- @tool()
74
- def computer_mouse_move(timeout: int | None = None) -> Tool:
75
- async def execute(x: int, y: int) -> ToolResult:
76
- """
77
- Move the cursor to a specified (x, y) pixel coordinate on the screen.
78
-
79
- Args:
80
- x: X coordinate of the mouse destination.
81
- y: Y coordinate of the mouse destination.
82
-
83
- Returns:
84
- A `list` with a single `ContentImage` of the screen.
85
- """
86
- return await common.mouse_move(x, y, timeout=timeout)
87
-
88
- return execute
89
-
90
-
91
- @tool()
92
- def computer_left_click(timeout: int | None = None) -> Tool:
93
- async def execute() -> ToolResult:
94
- """
95
- Click the left mouse button.
96
-
97
- Args:
98
- None
99
-
100
- Returns:
101
- A `list` with a single `ContentImage` of the screen.
102
- """
103
- return await common.left_click(timeout=timeout)
104
-
105
- return execute
106
-
107
-
108
- @tool()
109
- def computer_double_click(timeout: int | None = None) -> Tool:
110
- async def execute() -> ToolResult:
111
- """
112
- Double-click the left mouse button.
113
-
114
- Args:
115
- None
116
-
117
- Returns:
118
- A `list` with a single `ContentImage` of the screen.
119
- """
120
- return await common.double_click(timeout=timeout)
121
-
122
- return execute
123
-
124
-
125
- @tool()
126
- def computer_left_click_drag(timeout: int | None = None) -> Tool:
127
- async def execute(x: int, y: int) -> ToolResult:
128
- """
129
- Click and drag the cursor to a specified (x, y) pixel coordinate on the screen.
130
-
131
- Args:
132
- x: X coordinate of the mouse destination.
133
- y: Y coordinate of the mouse destination.
134
-
135
- Returns:
136
- A `list` with a single `ContentImage` of the screen.
137
- """
138
- return await common.left_click_drag(x, y, timeout=timeout)
139
-
140
- return execute
141
-
142
-
143
- @tool()
144
- def computer_right_click(timeout: int | None = None) -> Tool:
145
- async def execute() -> ToolResult:
146
- """
147
- Click the right mouse button.
148
-
149
- Args:
150
- None
151
-
152
- Returns:
153
- A `list` with a single `ContentImage` of the screen.
154
- """
155
- return await common.right_click(timeout=timeout)
156
-
157
- return execute
158
-
159
-
160
- # keysm list is from https://gist.github.com/rvaiya/be31f42049a4b5ad46666a8e120d9843
161
- @tool()
162
- def computer_key(timeout: int | None = None) -> Tool:
163
- async def execute(key: str) -> ToolResult:
164
- """
165
- Press a key or key-combination on the keyboard.
166
-
167
- Args:
168
- key: The key or key-combination to press. Can be any key name supported by xdotool's `key` such as:
169
- "Return", "Escape", "alt+Tab", "BackSpace", "Tab", "alt+Tab", "ctrl+s", "Up", "KP_0" (for the numpad 0 key),
170
- "Insert", "Delete", "Home", "End", "Prior", "Next", "Left", "Up", "Right", "Down",
171
- "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12",
172
- "Shift_L", "Shift_R", "Control_L", "Control_R", "Alt_L", "Alt_R", "Scroll_Lock", "Num_Lock", "Caps_Lock", "Pause",
173
- "KP_Multiply", "KP_Home", "KP_Up", "KP_Prior", "KP_Subtract", "KP_Left", "KP_Begin", "KP_Right", "KP_Add", "KP_End","KP_Down",
174
- "KP_Next", "KP_Insert", "KP_Delete", "KP_Enter", "KP_Divide", "KP_Equal", "KP_Decimal"
175
-
176
- Returns:
177
- A `list` with a single `ContentImage` of the screen.
178
- """
179
- return await common.press_key(key, timeout=timeout)
180
-
181
- return execute
182
-
183
-
184
- @tool()
185
- def computer_type(timeout: int | None = None) -> Tool:
186
- async def execute(text: str) -> ToolResult:
187
- """
188
- Type a string of text on the keyboard.
189
-
190
- Args:
191
- text: The text to type. If the text contains spaces, enclose it in quotes.
192
-
193
- Returns:
194
- A `list` with a single `ContentImage` of the screen.
195
- """
196
- return await common.type(text, timeout=timeout)
197
-
198
- return execute