use-computer 0.0.5__tar.gz → 0.0.7__tar.gz
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.
- use_computer-0.0.7/PKG-INFO +57 -0
- use_computer-0.0.7/README.md +35 -0
- use_computer-0.0.7/examples/_1_hello_macos.py +8 -0
- use_computer-0.0.7/examples/_2_hello_ios.py +7 -0
- use_computer-0.0.7/examples/_3_recording.py +10 -0
- use_computer-0.0.7/examples/_4_file_transfer.py +7 -0
- use_computer-0.0.7/examples/_5_keepalive.py +9 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/tasks/__init__.py +25 -1
- {use_computer-0.0.5 → use_computer-0.0.7}/pyproject.toml +1 -1
- use_computer-0.0.5/PKG-INFO +0 -100
- use_computer-0.0.5/README.md +0 -78
- use_computer-0.0.5/examples/ios_quickstart.py +0 -89
- use_computer-0.0.5/examples/quickstart.py +0 -45
- use_computer-0.0.5/examples/setup_with_exec.py +0 -54
- use_computer-0.0.5/examples/upload_file.py +0 -43
- {use_computer-0.0.5 → use_computer-0.0.7}/.env.example +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/.gitignore +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/.pre-commit-config.yaml +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/__init__.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/ax_transpile.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/client.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/display.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/errors.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/ios/__init__.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/ios/apps.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/ios/environment.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/ios/input.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/macos/__init__.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/macos/keyboard.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/macos/mouse.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/models.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/parsers.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/py.typed +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/recording.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/retry.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/sandbox.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/screenshot.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/tasks/templates/pre_command.sh +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/tasks/templates/task.toml +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/tasks/templates/test_ios.sh +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/tasks/templates/test_ios_nograder.sh +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/tasks/templates/test_macos.sh +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/tasks/templates/test_macos_check.sh +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/mmini/tasks/templates/test_macos_nograder.sh +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/use_computer/__init__.py +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/use_computer/py.typed +0 -0
- {use_computer-0.0.5 → use_computer-0.0.7}/uv.lock +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: use-computer
|
|
3
|
+
Version: 0.0.7
|
|
4
|
+
Summary: Python SDK for the use.computer macOS and iOS Computer Use API
|
|
5
|
+
Project-URL: Homepage, https://use.computer
|
|
6
|
+
Project-URL: Documentation, https://api.use.computer/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/josancamon19/use-computer-python
|
|
8
|
+
Author: use.computer
|
|
9
|
+
Keywords: automation,computer-use,ios,macos,sandbox
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: httpx>=0.27
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# use-computer Python SDK
|
|
24
|
+
|
|
25
|
+
Python client for [use.computer](https://use.computer) — rent dedicated Mac minis with macOS and iOS sandboxes built for computer-use agents.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install use-computer
|
|
29
|
+
export USE_COMPUTER_API_KEY=mk_live_...
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from use_computer import Computer
|
|
34
|
+
|
|
35
|
+
with Computer().create() as mac:
|
|
36
|
+
mac.exec_ssh("open -a TextEdit")
|
|
37
|
+
mac.keyboard.type("hello")
|
|
38
|
+
png = mac.screenshot.take_full_screen()
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Full DSL reference (macOS + iOS): [docs.use.computer/docs/sdk](https://docs.use.computer/docs/sdk)
|
|
42
|
+
|
|
43
|
+
## Examples
|
|
44
|
+
|
|
45
|
+
| File | What it shows |
|
|
46
|
+
| -------------------------------------------------------------- | ------------------------------------------ |
|
|
47
|
+
| [`examples/_1_hello_macos.py`](examples/_1_hello_macos.py) | create → exec → keyboard → screenshot |
|
|
48
|
+
| [`examples/_2_hello_ios.py`](examples/_2_hello_ios.py) | create iOS → open URL → screenshot |
|
|
49
|
+
| [`examples/_3_recording.py`](examples/_3_recording.py) | start / stop / download a screen recording |
|
|
50
|
+
| [`examples/_4_file_transfer.py`](examples/_4_file_transfer.py) | upload bytes, download a file back |
|
|
51
|
+
| [`examples/_5_keepalive.py`](examples/_5_keepalive.py) | heartbeat for sessions idle > 2 min |
|
|
52
|
+
|
|
53
|
+
For agent loops and evals: [use-computer-cookbook](https://github.com/josancamon19/use-computer-cookbook).
|
|
54
|
+
|
|
55
|
+
## HTTP API
|
|
56
|
+
|
|
57
|
+
Every SDK method wraps `https://api.use.computer/v1/...` with `Authorization: Bearer mk_live_...`. Swagger: [api.use.computer/docs](https://api.use.computer/docs). OpenAPI spec: [api.use.computer/openapi.yaml](https://api.use.computer/openapi.yaml).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# use-computer Python SDK
|
|
2
|
+
|
|
3
|
+
Python client for [use.computer](https://use.computer) — rent dedicated Mac minis with macOS and iOS sandboxes built for computer-use agents.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install use-computer
|
|
7
|
+
export USE_COMPUTER_API_KEY=mk_live_...
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```python
|
|
11
|
+
from use_computer import Computer
|
|
12
|
+
|
|
13
|
+
with Computer().create() as mac:
|
|
14
|
+
mac.exec_ssh("open -a TextEdit")
|
|
15
|
+
mac.keyboard.type("hello")
|
|
16
|
+
png = mac.screenshot.take_full_screen()
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Full DSL reference (macOS + iOS): [docs.use.computer/docs/sdk](https://docs.use.computer/docs/sdk)
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
| File | What it shows |
|
|
24
|
+
| -------------------------------------------------------------- | ------------------------------------------ |
|
|
25
|
+
| [`examples/_1_hello_macos.py`](examples/_1_hello_macos.py) | create → exec → keyboard → screenshot |
|
|
26
|
+
| [`examples/_2_hello_ios.py`](examples/_2_hello_ios.py) | create iOS → open URL → screenshot |
|
|
27
|
+
| [`examples/_3_recording.py`](examples/_3_recording.py) | start / stop / download a screen recording |
|
|
28
|
+
| [`examples/_4_file_transfer.py`](examples/_4_file_transfer.py) | upload bytes, download a file back |
|
|
29
|
+
| [`examples/_5_keepalive.py`](examples/_5_keepalive.py) | heartbeat for sessions idle > 2 min |
|
|
30
|
+
|
|
31
|
+
For agent loops and evals: [use-computer-cookbook](https://github.com/josancamon19/use-computer-cookbook).
|
|
32
|
+
|
|
33
|
+
## HTTP API
|
|
34
|
+
|
|
35
|
+
Every SDK method wraps `https://api.use.computer/v1/...` with `Authorization: Bearer mk_live_...`. Swagger: [api.use.computer/docs](https://api.use.computer/docs). OpenAPI spec: [api.use.computer/openapi.yaml](https://api.use.computer/openapi.yaml).
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from use_computer import Computer
|
|
2
|
+
|
|
3
|
+
with Computer().create() as mac:
|
|
4
|
+
mac.exec_ssh("open -a TextEdit")
|
|
5
|
+
mac.keyboard.type("hello from use.computer")
|
|
6
|
+
png = mac.screenshot.take_full_screen()
|
|
7
|
+
open("hello_macos.png", "wb").write(png)
|
|
8
|
+
print(f"saved hello_macos.png ({len(png)} bytes)")
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from use_computer import Computer
|
|
2
|
+
|
|
3
|
+
with Computer().create() as mac:
|
|
4
|
+
# Seed data files the task needs before handing the sandbox to an agent.
|
|
5
|
+
mac.upload_bytes(b"hello from use.computer\n", "/Users/lume/Desktop/hello.txt")
|
|
6
|
+
mac.download_file("/Users/lume/Desktop/hello.txt", "hello.txt")
|
|
7
|
+
print("saved hello.txt")
|
|
@@ -29,6 +29,13 @@ def _render(text: str, **kwargs: str) -> str:
|
|
|
29
29
|
return out
|
|
30
30
|
|
|
31
31
|
|
|
32
|
+
def _strip_ios_prefix(s: str, kind: str) -> str:
|
|
33
|
+
"""Drop boilerplate `com.apple.CoreSimulator.<kind>.` so the toml is readable.
|
|
34
|
+
`kind` is "SimDeviceType" or "SimRuntime"."""
|
|
35
|
+
prefix = f"com.apple.CoreSimulator.{kind}."
|
|
36
|
+
return s[len(prefix) :] if s.startswith(prefix) else s
|
|
37
|
+
|
|
38
|
+
|
|
32
39
|
@dataclass
|
|
33
40
|
class TaskSummary:
|
|
34
41
|
"""Lightweight task info from the list endpoint."""
|
|
@@ -66,6 +73,8 @@ class Task:
|
|
|
66
73
|
accessibility_tree: dict | None = None
|
|
67
74
|
grader: str = ""
|
|
68
75
|
setup_actions: list = field(default_factory=list)
|
|
76
|
+
device_type: str = ""
|
|
77
|
+
runtime: str = ""
|
|
69
78
|
|
|
70
79
|
@property
|
|
71
80
|
def runnable(self) -> bool:
|
|
@@ -115,6 +124,8 @@ class TasksClient:
|
|
|
115
124
|
accessibility_tree=d.get("accessibility_tree"),
|
|
116
125
|
grader=d.get("grader", ""),
|
|
117
126
|
setup_actions=d.get("setup_actions") or [],
|
|
127
|
+
device_type=d.get("device_type", ""),
|
|
128
|
+
runtime=d.get("runtime", ""),
|
|
118
129
|
)
|
|
119
130
|
|
|
120
131
|
def export_harbor(
|
|
@@ -227,7 +238,10 @@ def task_to_harbor(
|
|
|
227
238
|
# instruction.md
|
|
228
239
|
(task_dir / "instruction.md").write_text(task.instruction + "\n", encoding="utf-8")
|
|
229
240
|
|
|
230
|
-
# task.toml
|
|
241
|
+
# task.toml — append the [ios] block when the task pins a device/runtime so
|
|
242
|
+
# the runner can spin up the matching simulator. Long
|
|
243
|
+
# com.apple.CoreSimulator.* identifiers are shortened to the readable form
|
|
244
|
+
# ("iPhone-17-Pro" / "iOS-26-4"); the runner reconstructs the prefix.
|
|
231
245
|
tags = ["collected", "gui", task.platform]
|
|
232
246
|
if category:
|
|
233
247
|
tags.append(category)
|
|
@@ -237,6 +251,16 @@ def task_to_harbor(
|
|
|
237
251
|
PLATFORM=task.platform,
|
|
238
252
|
RUNNABLE="true" if task.runnable else "false",
|
|
239
253
|
)
|
|
254
|
+
if task.platform == "ios":
|
|
255
|
+
device_type = _strip_ios_prefix(task.device_type, "SimDeviceType")
|
|
256
|
+
runtime = _strip_ios_prefix(task.runtime, "SimRuntime")
|
|
257
|
+
if device_type or runtime:
|
|
258
|
+
ios_block = ["\n[ios]\n"]
|
|
259
|
+
if device_type:
|
|
260
|
+
ios_block.append(f'device_type = "{device_type}"\n')
|
|
261
|
+
if runtime:
|
|
262
|
+
ios_block.append(f'runtime = "{runtime}"\n')
|
|
263
|
+
toml += "".join(ios_block)
|
|
240
264
|
(task_dir / "task.toml").write_text(toml, encoding="utf-8")
|
|
241
265
|
|
|
242
266
|
# actions.json — flat {steps: [{function, args}, ...]} for the debug agent's
|
use_computer-0.0.5/PKG-INFO
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: use-computer
|
|
3
|
-
Version: 0.0.5
|
|
4
|
-
Summary: Python SDK for the use.computer macOS and iOS Computer Use API
|
|
5
|
-
Project-URL: Homepage, https://use.computer
|
|
6
|
-
Project-URL: Documentation, https://api.use.computer/docs
|
|
7
|
-
Project-URL: Repository, https://github.com/josancamon19/use-computer-python
|
|
8
|
-
Author: use.computer
|
|
9
|
-
Keywords: automation,computer-use,ios,macos,sandbox
|
|
10
|
-
Classifier: Development Status :: 3 - Alpha
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
-
Classifier: Typing :: Typed
|
|
19
|
-
Requires-Python: >=3.10
|
|
20
|
-
Requires-Dist: httpx>=0.27
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
|
|
23
|
-
# use-computer Python SDK
|
|
24
|
-
|
|
25
|
-
Python client for use.computer macOS and iOS sandboxes.
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
pip install use-computer
|
|
29
|
-
export USE_COMPUTER_API_KEY=mk_live_...
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
```python
|
|
33
|
-
from use_computer import Computer
|
|
34
|
-
|
|
35
|
-
computer = Computer()
|
|
36
|
-
sandbox = computer.create() # macOS
|
|
37
|
-
|
|
38
|
-
try:
|
|
39
|
-
png = sandbox.screenshot.take_full_screen()
|
|
40
|
-
sandbox.mouse.click(500, 400)
|
|
41
|
-
sandbox.keyboard.type("hello")
|
|
42
|
-
sandbox.exec_ssh("open -a TextEdit")
|
|
43
|
-
finally:
|
|
44
|
-
sandbox.close()
|
|
45
|
-
computer.close()
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## iOS
|
|
49
|
-
|
|
50
|
-
```python
|
|
51
|
-
from use_computer import Computer
|
|
52
|
-
|
|
53
|
-
computer = Computer()
|
|
54
|
-
ios = computer.create(type="ios")
|
|
55
|
-
try:
|
|
56
|
-
ios.apps.open_url("https://example.com")
|
|
57
|
-
ios.input.tap(200, 300)
|
|
58
|
-
ios.input.type_text("hello")
|
|
59
|
-
ios.environment.set_appearance("dark")
|
|
60
|
-
finally:
|
|
61
|
-
ios.close()
|
|
62
|
-
computer.close()
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
In runner configs, use `platform: ios`; the runner calls the iOS SDK create path under the hood.
|
|
66
|
-
|
|
67
|
-
## Action DSL
|
|
68
|
-
|
|
69
|
-
Actions are dotted method calls plus args/kwargs. They are useful when a model emits tool-like steps. Given an open macOS `sandbox`:
|
|
70
|
-
|
|
71
|
-
```python
|
|
72
|
-
from use_computer import Action, parse_pyautogui, parse_xdotool
|
|
73
|
-
|
|
74
|
-
actions = [
|
|
75
|
-
Action("mouse.move", [500, 400]),
|
|
76
|
-
Action("mouse.click", [500, 400]),
|
|
77
|
-
Action("keyboard.hotkey", ["command+space"]),
|
|
78
|
-
Action("keyboard.type", ["Safari"]),
|
|
79
|
-
Action("screenshot.take_full_screen"),
|
|
80
|
-
]
|
|
81
|
-
|
|
82
|
-
for action in actions:
|
|
83
|
-
action.execute(sandbox)
|
|
84
|
-
|
|
85
|
-
for action in parse_pyautogui("pyautogui.click(100, 200); pyautogui.write('hi')"):
|
|
86
|
-
action.execute(sandbox)
|
|
87
|
-
|
|
88
|
-
for action in parse_xdotool("xdotool mousemove 100 200 click 1 type hello"):
|
|
89
|
-
action.execute(sandbox)
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Common macOS targets: `mouse.*`, `keyboard.*`, `screenshot.*`, `display.*`, `recording.*`.
|
|
93
|
-
|
|
94
|
-
Common iOS targets: `input.*`, `apps.*`, `environment.*`, `screenshot.*`, `recording.*`.
|
|
95
|
-
|
|
96
|
-
Docs: https://api.use.computer/docs
|
|
97
|
-
|
|
98
|
-
OpenAPI: https://api.use.computer/openapi.yaml
|
|
99
|
-
|
|
100
|
-
Examples: https://github.com/josancamon19/use-computer-examples
|
use_computer-0.0.5/README.md
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# use-computer Python SDK
|
|
2
|
-
|
|
3
|
-
Python client for use.computer macOS and iOS sandboxes.
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
pip install use-computer
|
|
7
|
-
export USE_COMPUTER_API_KEY=mk_live_...
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
```python
|
|
11
|
-
from use_computer import Computer
|
|
12
|
-
|
|
13
|
-
computer = Computer()
|
|
14
|
-
sandbox = computer.create() # macOS
|
|
15
|
-
|
|
16
|
-
try:
|
|
17
|
-
png = sandbox.screenshot.take_full_screen()
|
|
18
|
-
sandbox.mouse.click(500, 400)
|
|
19
|
-
sandbox.keyboard.type("hello")
|
|
20
|
-
sandbox.exec_ssh("open -a TextEdit")
|
|
21
|
-
finally:
|
|
22
|
-
sandbox.close()
|
|
23
|
-
computer.close()
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## iOS
|
|
27
|
-
|
|
28
|
-
```python
|
|
29
|
-
from use_computer import Computer
|
|
30
|
-
|
|
31
|
-
computer = Computer()
|
|
32
|
-
ios = computer.create(type="ios")
|
|
33
|
-
try:
|
|
34
|
-
ios.apps.open_url("https://example.com")
|
|
35
|
-
ios.input.tap(200, 300)
|
|
36
|
-
ios.input.type_text("hello")
|
|
37
|
-
ios.environment.set_appearance("dark")
|
|
38
|
-
finally:
|
|
39
|
-
ios.close()
|
|
40
|
-
computer.close()
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
In runner configs, use `platform: ios`; the runner calls the iOS SDK create path under the hood.
|
|
44
|
-
|
|
45
|
-
## Action DSL
|
|
46
|
-
|
|
47
|
-
Actions are dotted method calls plus args/kwargs. They are useful when a model emits tool-like steps. Given an open macOS `sandbox`:
|
|
48
|
-
|
|
49
|
-
```python
|
|
50
|
-
from use_computer import Action, parse_pyautogui, parse_xdotool
|
|
51
|
-
|
|
52
|
-
actions = [
|
|
53
|
-
Action("mouse.move", [500, 400]),
|
|
54
|
-
Action("mouse.click", [500, 400]),
|
|
55
|
-
Action("keyboard.hotkey", ["command+space"]),
|
|
56
|
-
Action("keyboard.type", ["Safari"]),
|
|
57
|
-
Action("screenshot.take_full_screen"),
|
|
58
|
-
]
|
|
59
|
-
|
|
60
|
-
for action in actions:
|
|
61
|
-
action.execute(sandbox)
|
|
62
|
-
|
|
63
|
-
for action in parse_pyautogui("pyautogui.click(100, 200); pyautogui.write('hi')"):
|
|
64
|
-
action.execute(sandbox)
|
|
65
|
-
|
|
66
|
-
for action in parse_xdotool("xdotool mousemove 100 200 click 1 type hello"):
|
|
67
|
-
action.execute(sandbox)
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Common macOS targets: `mouse.*`, `keyboard.*`, `screenshot.*`, `display.*`, `recording.*`.
|
|
71
|
-
|
|
72
|
-
Common iOS targets: `input.*`, `apps.*`, `environment.*`, `screenshot.*`, `recording.*`.
|
|
73
|
-
|
|
74
|
-
Docs: https://api.use.computer/docs
|
|
75
|
-
|
|
76
|
-
OpenAPI: https://api.use.computer/openapi.yaml
|
|
77
|
-
|
|
78
|
-
Examples: https://github.com/josancamon19/use-computer-examples
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
iOS simulator sandbox — end to end example.
|
|
3
|
-
|
|
4
|
-
Creates an iPhone simulator, opens Safari, takes a screenshot,
|
|
5
|
-
taps around, types a URL, and cleans up.
|
|
6
|
-
|
|
7
|
-
Usage:
|
|
8
|
-
cd sdk && uv run python examples/ios_quickstart.py
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import time
|
|
12
|
-
|
|
13
|
-
from use_computer import Computer
|
|
14
|
-
|
|
15
|
-
client = Computer(base_url="http://localhost:8080")
|
|
16
|
-
|
|
17
|
-
# Create an iOS sandbox (iPhone 17 Pro by default)
|
|
18
|
-
sandbox = client.create(type="ios")
|
|
19
|
-
print(f"Created: {sandbox}")
|
|
20
|
-
|
|
21
|
-
# Check display info
|
|
22
|
-
info = sandbox.display.get_info()
|
|
23
|
-
print(f"Display: {info.width}x{info.height} @{info.scale}x")
|
|
24
|
-
|
|
25
|
-
# Take initial screenshot (home screen)
|
|
26
|
-
time.sleep(3) # wait for simulator to settle
|
|
27
|
-
img = sandbox.screenshot.take_full_screen()
|
|
28
|
-
with open("ios_home.png", "wb") as f:
|
|
29
|
-
f.write(img)
|
|
30
|
-
print(f"Home screen saved ({len(img)} bytes)")
|
|
31
|
-
|
|
32
|
-
# Open Safari via URL scheme
|
|
33
|
-
sandbox.apps.open_url("https://example.com")
|
|
34
|
-
time.sleep(3)
|
|
35
|
-
|
|
36
|
-
# Screenshot Safari
|
|
37
|
-
img = sandbox.screenshot.take_full_screen()
|
|
38
|
-
with open("ios_safari.png", "wb") as f:
|
|
39
|
-
f.write(img)
|
|
40
|
-
print("Safari screenshot saved")
|
|
41
|
-
|
|
42
|
-
# Tap the address bar (top center of screen)
|
|
43
|
-
sandbox.input.tap(info.width / 2, 70)
|
|
44
|
-
time.sleep(1)
|
|
45
|
-
|
|
46
|
-
# Type a URL
|
|
47
|
-
sandbox.input.type_text("https://apple.com")
|
|
48
|
-
time.sleep(0.5)
|
|
49
|
-
|
|
50
|
-
# Press Go (tap keyboard return area)
|
|
51
|
-
sandbox.input.press_button("HOME") # dismiss keyboard first
|
|
52
|
-
time.sleep(1)
|
|
53
|
-
|
|
54
|
-
# Screenshot final state
|
|
55
|
-
img = sandbox.screenshot.take_full_screen()
|
|
56
|
-
with open("ios_final.png", "wb") as f:
|
|
57
|
-
f.write(img)
|
|
58
|
-
print("Final screenshot saved")
|
|
59
|
-
|
|
60
|
-
# Set dark mode
|
|
61
|
-
sandbox.environment.set_appearance("dark")
|
|
62
|
-
time.sleep(1)
|
|
63
|
-
img = sandbox.screenshot.take_full_screen()
|
|
64
|
-
with open("ios_dark.png", "wb") as f:
|
|
65
|
-
f.write(img)
|
|
66
|
-
print("Dark mode screenshot saved")
|
|
67
|
-
|
|
68
|
-
# Upload a file to the simulator
|
|
69
|
-
sandbox.upload_bytes(b"Hello from use.computer iOS!", "Documents/test.txt")
|
|
70
|
-
print("File uploaded")
|
|
71
|
-
|
|
72
|
-
# Download it back
|
|
73
|
-
sandbox.download_file("Documents/test.txt", "ios_downloaded.txt")
|
|
74
|
-
with open("ios_downloaded.txt") as f:
|
|
75
|
-
print(f"Downloaded: {f.read()}")
|
|
76
|
-
|
|
77
|
-
# Start recording
|
|
78
|
-
rec = sandbox.recording.start(name="demo")
|
|
79
|
-
print(f"Recording started: {rec.id}")
|
|
80
|
-
time.sleep(3)
|
|
81
|
-
|
|
82
|
-
# Stop recording
|
|
83
|
-
rec = sandbox.recording.stop(rec.id)
|
|
84
|
-
print(f"Recording stopped: {rec.status}")
|
|
85
|
-
|
|
86
|
-
# Clean up
|
|
87
|
-
sandbox.close()
|
|
88
|
-
print("Sandbox destroyed.")
|
|
89
|
-
client.close()
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Quick test of the use-computer SDK against a local gateway.
|
|
3
|
-
|
|
4
|
-
Usage:
|
|
5
|
-
cd sdk && uv run python examples/quickstart.py
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import time
|
|
9
|
-
|
|
10
|
-
from use_computer import Computer
|
|
11
|
-
|
|
12
|
-
client = Computer(base_url="http://localhost:8080")
|
|
13
|
-
|
|
14
|
-
sandbox = client.create()
|
|
15
|
-
print(f"Created: {sandbox}")
|
|
16
|
-
print(f"VNC: {sandbox.vnc_url}")
|
|
17
|
-
|
|
18
|
-
# Open TextEdit via exec
|
|
19
|
-
sandbox.exec_ssh("open -a TextEdit")
|
|
20
|
-
time.sleep(2)
|
|
21
|
-
|
|
22
|
-
# Click in the document area to focus it
|
|
23
|
-
sandbox.mouse.click(512, 400)
|
|
24
|
-
time.sleep(0.5)
|
|
25
|
-
|
|
26
|
-
# Take initial screenshot
|
|
27
|
-
img = sandbox.screenshot.take_full_screen()
|
|
28
|
-
with open("screen.png", "wb") as f:
|
|
29
|
-
f.write(img)
|
|
30
|
-
print(f"Screenshot saved to screen.png ({len(img)} bytes)")
|
|
31
|
-
|
|
32
|
-
# Type something
|
|
33
|
-
sandbox.keyboard.type("Hello from use.computer!")
|
|
34
|
-
time.sleep(0.5)
|
|
35
|
-
|
|
36
|
-
# Screenshot after typing
|
|
37
|
-
img = sandbox.screenshot.take_full_screen()
|
|
38
|
-
with open("screen_after.png", "wb") as f:
|
|
39
|
-
f.write(img)
|
|
40
|
-
print("After typing saved to screen_after.png")
|
|
41
|
-
|
|
42
|
-
# Clean up
|
|
43
|
-
sandbox.close()
|
|
44
|
-
print("Sandbox destroyed.")
|
|
45
|
-
client.close()
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Example: seed a sandbox by running shell commands via exec.
|
|
3
|
-
|
|
4
|
-
Opens Notes, creates a note, and sets system preferences — all via exec.
|
|
5
|
-
This replaces the old seed mechanism with direct shell commands.
|
|
6
|
-
|
|
7
|
-
Usage:
|
|
8
|
-
cd sdk && uv run python examples/setup_with_exec.py
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import asyncio
|
|
12
|
-
|
|
13
|
-
from use_computer import AsyncComputer
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
async def main() -> None:
|
|
17
|
-
client = AsyncComputer(base_url="http://localhost:8080")
|
|
18
|
-
sandbox = await client.create()
|
|
19
|
-
print(f"Created: {sandbox.sandbox_id}")
|
|
20
|
-
|
|
21
|
-
# Open an app
|
|
22
|
-
await sandbox.exec_ssh("open -a Notes")
|
|
23
|
-
await asyncio.sleep(2)
|
|
24
|
-
|
|
25
|
-
# Create a note via osascript
|
|
26
|
-
await sandbox.exec_ssh(
|
|
27
|
-
'osascript -e \'tell application "Notes" to make new note'
|
|
28
|
-
' with properties {name:"Test Note", body:"Created by mmini SDK"}\''
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
# Set system preferences
|
|
32
|
-
await sandbox.exec_ssh("defaults write com.apple.dock autohide -bool true && killall Dock")
|
|
33
|
-
|
|
34
|
-
# Run any shell command
|
|
35
|
-
result = await sandbox.exec_ssh("sw_vers -productVersion")
|
|
36
|
-
print(f"macOS version: {result.stdout.strip()}")
|
|
37
|
-
|
|
38
|
-
# Verify the note was created
|
|
39
|
-
notes = await sandbox.exec_ssh(
|
|
40
|
-
"osascript -e 'tell application \"Notes\" to get the name of every note'"
|
|
41
|
-
)
|
|
42
|
-
print(f"Notes: {notes.stdout.strip()}")
|
|
43
|
-
|
|
44
|
-
# Take a screenshot to see the result
|
|
45
|
-
img = await sandbox.screenshot.take_full_screen()
|
|
46
|
-
with open("setup_result.png", "wb") as f:
|
|
47
|
-
f.write(img)
|
|
48
|
-
print("Screenshot saved to setup_result.png")
|
|
49
|
-
|
|
50
|
-
await sandbox.close()
|
|
51
|
-
await client.close()
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
asyncio.run(main())
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Example: upload a file to a sandbox and verify it.
|
|
3
|
-
|
|
4
|
-
Uses the file upload endpoint to put a file on the VM's filesystem,
|
|
5
|
-
then verifies it exists via exec.
|
|
6
|
-
|
|
7
|
-
Usage:
|
|
8
|
-
cd sdk && uv run python examples/upload_file.py
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
import asyncio
|
|
12
|
-
|
|
13
|
-
from use_computer import AsyncComputer
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
async def main() -> None:
|
|
17
|
-
client = AsyncComputer(base_url="http://localhost:8080")
|
|
18
|
-
sandbox = await client.create()
|
|
19
|
-
print(f"Created: {sandbox.sandbox_id}")
|
|
20
|
-
|
|
21
|
-
# Create some content
|
|
22
|
-
content = b"Name,Score\nAlice,95\nBob,87\nCharlie,92\n"
|
|
23
|
-
|
|
24
|
-
# Upload to the VM
|
|
25
|
-
await sandbox.upload_bytes(content, "/Users/lume/Desktop/scores.csv")
|
|
26
|
-
print("Uploaded scores.csv to Desktop")
|
|
27
|
-
|
|
28
|
-
# Verify it's there
|
|
29
|
-
result = await sandbox.exec_ssh("cat /Users/lume/Desktop/scores.csv")
|
|
30
|
-
print(f"File contents:\n{result.stdout}")
|
|
31
|
-
|
|
32
|
-
# Upload a script and run it
|
|
33
|
-
script = b"#!/bin/bash\necho 'Hello from uploaded script!'\nls ~/Desktop/\n"
|
|
34
|
-
await sandbox.upload_bytes(script, "/Users/lume/Desktop/check.sh")
|
|
35
|
-
await sandbox.exec_ssh("chmod +x /Users/lume/Desktop/check.sh")
|
|
36
|
-
result = await sandbox.exec_ssh("/Users/lume/Desktop/check.sh")
|
|
37
|
-
print(f"Script output:\n{result.stdout}")
|
|
38
|
-
|
|
39
|
-
await sandbox.close()
|
|
40
|
-
await client.close()
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
asyncio.run(main())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|