cyberdesk 0.2.1__tar.gz → 0.2.2__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.

Potentially problematic release.


This version of cyberdesk might be problematic. Click here for more details.

@@ -0,0 +1,216 @@
1
+ Metadata-Version: 2.4
2
+ Name: cyberdesk
3
+ Version: 0.2.2
4
+ Summary: The official Python SDK for Cyberdesk
5
+ Author-email: Cyberdesk Team <dev@cyberdesk.io>
6
+ License-Expression: MIT
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: httpx
10
+ Provides-Extra: dev
11
+ Requires-Dist: openapi-python-client; extra == "dev"
12
+ Requires-Dist: build; extra == "dev"
13
+ Requires-Dist: twine; extra == "dev"
14
+ Dynamic: license-file
15
+
16
+ # cyberdesk
17
+
18
+ [![PyPI version](https://badge.fury.io/py/cyberdesk.svg)](https://badge.fury.io/py/cyberdesk)
19
+
20
+ The official Python SDK for Cyberdesk.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install cyberdesk
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ First, create a Cyberdesk client instance with your API key:
31
+
32
+ ```python
33
+ from cyberdesk import CyberdeskClient
34
+
35
+ client = CyberdeskClient(api_key="YOUR_API_KEY")
36
+ ```
37
+
38
+ ---
39
+
40
+ ### Launch a Desktop
41
+
42
+ ```python
43
+ result = client.launch_desktop(timeout_ms=10000) # Optional: set a timeout for the desktop session
44
+
45
+ # Error handling example
46
+ if hasattr(result, 'error') and result.error:
47
+ raise Exception('Failed to launch desktop: ' + str(result.error))
48
+
49
+ # Success
50
+ if hasattr(result, 'id'):
51
+ desktop_id = result.id
52
+ print('Launched desktop with ID:', desktop_id)
53
+ ```
54
+
55
+ ---
56
+
57
+ ### Get Desktop Info
58
+
59
+ ```python
60
+ info = client.get_desktop("your-desktop-id")
61
+
62
+ if hasattr(info, 'error') and info.error:
63
+ raise Exception('Failed to get desktop info: ' + str(info.error))
64
+
65
+ print('Desktop info:', info)
66
+ ```
67
+
68
+ ---
69
+
70
+ ### Perform a Computer Action (e.g., Mouse Click)
71
+
72
+ ```python
73
+ from cyberdesk.actions import click_mouse
74
+
75
+ action = click_mouse(x=100, y=150, button="left")
76
+ action_result = client.execute_computer_action("your-desktop-id", action)
77
+
78
+ if hasattr(action_result, 'error') and action_result.error:
79
+ raise Exception('Action failed: ' + str(action_result.error))
80
+
81
+ print('Action result:', action_result)
82
+ ```
83
+
84
+ ---
85
+
86
+ ### Run a Bash Command
87
+
88
+ ```python
89
+ bash_result = client.execute_bash_action(
90
+ "your-desktop-id",
91
+ "echo Hello, world!"
92
+ )
93
+
94
+ if hasattr(bash_result, 'error') and bash_result.error:
95
+ raise Exception('Bash command failed: ' + str(bash_result.error))
96
+
97
+ print('Bash output:', getattr(bash_result, 'output', bash_result))
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Ergonomic, Type-Safe Actions
103
+
104
+ To create computer actions (mouse, keyboard, etc.), use the factory functions in `cyberdesk.actions`. These provide full type hints and IDE autocompletion for all required and optional fields.
105
+
106
+ **Example:**
107
+ ```python
108
+ from cyberdesk.actions import click_mouse, type_text
109
+
110
+ action1 = click_mouse(x=100, y=200, button="left")
111
+ action2 = type_text(text="Hello, world!")
112
+
113
+ client.execute_computer_action("your-desktop-id", action1)
114
+ client.execute_computer_action("your-desktop-id", action2)
115
+ ```
116
+
117
+ | Action | Factory Function | Description |
118
+ |----------------|-------------------------|----------------------------|
119
+ | Click Mouse | `click_mouse` | Mouse click at (x, y) |
120
+ | Drag Mouse | `drag_mouse` | Mouse drag from/to (x, y) |
121
+ | Move Mouse | `move_mouse` | Move mouse to (x, y) |
122
+ | Scroll | `scroll` | Scroll by dx, dy |
123
+ | Type Text | `type_text` | Type text |
124
+ | Press Keys | `press_keys` | Press keyboard keys |
125
+ | Screenshot | `screenshot` | Take a screenshot |
126
+ | Wait | `wait` | Wait for ms milliseconds |
127
+ | Get Cursor Pos | `get_cursor_position` | Get mouse cursor position |
128
+
129
+ ---
130
+
131
+ ## Async Usage
132
+
133
+ All methods are also available as async variants (prefixed with `async_`). Example:
134
+
135
+ ```python
136
+ import asyncio
137
+ from cyberdesk import CyberdeskClient
138
+ from cyberdesk.actions import click_mouse
139
+
140
+ async def main():
141
+ client = CyberdeskClient(api_key="YOUR_API_KEY")
142
+ result = await client.async_launch_desktop(timeout_ms=10000)
143
+ print(result)
144
+ # Example async computer action
145
+ action = click_mouse(x=100, y=200)
146
+ await client.async_execute_computer_action("your-desktop-id", action)
147
+ # ... use other async_ methods as needed
148
+
149
+ asyncio.run(main())
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Type Hints and Models
155
+
156
+ All request/response types are available from the generated models, and all computer actions are available as factory functions in `cyberdesk.actions` for ergonomic, type-safe usage.
157
+
158
+ ```python
159
+ from cyberdesk.actions import click_mouse, drag_mouse, type_text, wait, scroll, move_mouse, press_keys, screenshot, get_cursor_position
160
+ ```
161
+
162
+ ---
163
+
164
+ ## For Cyberdesk Team: Publishing to PyPI
165
+
166
+ **Recommended:** Always use a [virtual environment](https://docs.python.org/3/library/venv.html) (venv) for building and publishing to avoid dependency conflicts.
167
+
168
+ To build and publish this package to [PyPI](https://pypi.org/project/cyberdesk/):
169
+
170
+ 1. **Log into PyPI** (get credentials from the Cyberdesk team).
171
+
172
+ 2. **Install dev dependencies** (in a clean venv):
173
+ ```bash
174
+ pip install .[dev]
175
+ # or
176
+ uv pip install .[dev]
177
+ ```
178
+
179
+ 3. **Build the package:**
180
+ ```bash
181
+ python -m build
182
+ ```
183
+ This creates a `dist/` directory with `.whl` and `.tar.gz` files.
184
+
185
+ 4. **(Recommended) Set up a `.pypirc` file for easy publishing:**
186
+ - Create a file named `.pypirc` in your home directory (e.g., `C:\Users\yourname\.pypirc` on Windows or `~/.pypirc` on Linux/macOS).
187
+ - Add:
188
+ ```ini
189
+ [distutils]
190
+ index-servers =
191
+ pypi
192
+
193
+ [pypi]
194
+ username = __token__
195
+ password = pypi-AgEIcH... # <-- paste your API token here
196
+ ```
197
+
198
+ 5. **Publish to PyPI:**
199
+ ```bash
200
+ twine upload dist/*
201
+ ```
202
+ - If you set up `.pypirc`, you won't be prompted for credentials.
203
+ - If not, enter `__token__` as the username and paste your API token as the password.
204
+
205
+ 6. **Verify:**
206
+ - Visit https://pypi.org/project/cyberdesk/ to see your published package.
207
+ - Try installing it in a fresh environment:
208
+ ```bash
209
+ pip install cyberdesk
210
+ ```
211
+
212
+ ---
213
+
214
+ ## License
215
+
216
+ [MIT](LICENSE)
@@ -0,0 +1,201 @@
1
+ # cyberdesk
2
+
3
+ [![PyPI version](https://badge.fury.io/py/cyberdesk.svg)](https://badge.fury.io/py/cyberdesk)
4
+
5
+ The official Python SDK for Cyberdesk.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install cyberdesk
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ First, create a Cyberdesk client instance with your API key:
16
+
17
+ ```python
18
+ from cyberdesk import CyberdeskClient
19
+
20
+ client = CyberdeskClient(api_key="YOUR_API_KEY")
21
+ ```
22
+
23
+ ---
24
+
25
+ ### Launch a Desktop
26
+
27
+ ```python
28
+ result = client.launch_desktop(timeout_ms=10000) # Optional: set a timeout for the desktop session
29
+
30
+ # Error handling example
31
+ if hasattr(result, 'error') and result.error:
32
+ raise Exception('Failed to launch desktop: ' + str(result.error))
33
+
34
+ # Success
35
+ if hasattr(result, 'id'):
36
+ desktop_id = result.id
37
+ print('Launched desktop with ID:', desktop_id)
38
+ ```
39
+
40
+ ---
41
+
42
+ ### Get Desktop Info
43
+
44
+ ```python
45
+ info = client.get_desktop("your-desktop-id")
46
+
47
+ if hasattr(info, 'error') and info.error:
48
+ raise Exception('Failed to get desktop info: ' + str(info.error))
49
+
50
+ print('Desktop info:', info)
51
+ ```
52
+
53
+ ---
54
+
55
+ ### Perform a Computer Action (e.g., Mouse Click)
56
+
57
+ ```python
58
+ from cyberdesk.actions import click_mouse
59
+
60
+ action = click_mouse(x=100, y=150, button="left")
61
+ action_result = client.execute_computer_action("your-desktop-id", action)
62
+
63
+ if hasattr(action_result, 'error') and action_result.error:
64
+ raise Exception('Action failed: ' + str(action_result.error))
65
+
66
+ print('Action result:', action_result)
67
+ ```
68
+
69
+ ---
70
+
71
+ ### Run a Bash Command
72
+
73
+ ```python
74
+ bash_result = client.execute_bash_action(
75
+ "your-desktop-id",
76
+ "echo Hello, world!"
77
+ )
78
+
79
+ if hasattr(bash_result, 'error') and bash_result.error:
80
+ raise Exception('Bash command failed: ' + str(bash_result.error))
81
+
82
+ print('Bash output:', getattr(bash_result, 'output', bash_result))
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Ergonomic, Type-Safe Actions
88
+
89
+ To create computer actions (mouse, keyboard, etc.), use the factory functions in `cyberdesk.actions`. These provide full type hints and IDE autocompletion for all required and optional fields.
90
+
91
+ **Example:**
92
+ ```python
93
+ from cyberdesk.actions import click_mouse, type_text
94
+
95
+ action1 = click_mouse(x=100, y=200, button="left")
96
+ action2 = type_text(text="Hello, world!")
97
+
98
+ client.execute_computer_action("your-desktop-id", action1)
99
+ client.execute_computer_action("your-desktop-id", action2)
100
+ ```
101
+
102
+ | Action | Factory Function | Description |
103
+ |----------------|-------------------------|----------------------------|
104
+ | Click Mouse | `click_mouse` | Mouse click at (x, y) |
105
+ | Drag Mouse | `drag_mouse` | Mouse drag from/to (x, y) |
106
+ | Move Mouse | `move_mouse` | Move mouse to (x, y) |
107
+ | Scroll | `scroll` | Scroll by dx, dy |
108
+ | Type Text | `type_text` | Type text |
109
+ | Press Keys | `press_keys` | Press keyboard keys |
110
+ | Screenshot | `screenshot` | Take a screenshot |
111
+ | Wait | `wait` | Wait for ms milliseconds |
112
+ | Get Cursor Pos | `get_cursor_position` | Get mouse cursor position |
113
+
114
+ ---
115
+
116
+ ## Async Usage
117
+
118
+ All methods are also available as async variants (prefixed with `async_`). Example:
119
+
120
+ ```python
121
+ import asyncio
122
+ from cyberdesk import CyberdeskClient
123
+ from cyberdesk.actions import click_mouse
124
+
125
+ async def main():
126
+ client = CyberdeskClient(api_key="YOUR_API_KEY")
127
+ result = await client.async_launch_desktop(timeout_ms=10000)
128
+ print(result)
129
+ # Example async computer action
130
+ action = click_mouse(x=100, y=200)
131
+ await client.async_execute_computer_action("your-desktop-id", action)
132
+ # ... use other async_ methods as needed
133
+
134
+ asyncio.run(main())
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Type Hints and Models
140
+
141
+ All request/response types are available from the generated models, and all computer actions are available as factory functions in `cyberdesk.actions` for ergonomic, type-safe usage.
142
+
143
+ ```python
144
+ from cyberdesk.actions import click_mouse, drag_mouse, type_text, wait, scroll, move_mouse, press_keys, screenshot, get_cursor_position
145
+ ```
146
+
147
+ ---
148
+
149
+ ## For Cyberdesk Team: Publishing to PyPI
150
+
151
+ **Recommended:** Always use a [virtual environment](https://docs.python.org/3/library/venv.html) (venv) for building and publishing to avoid dependency conflicts.
152
+
153
+ To build and publish this package to [PyPI](https://pypi.org/project/cyberdesk/):
154
+
155
+ 1. **Log into PyPI** (get credentials from the Cyberdesk team).
156
+
157
+ 2. **Install dev dependencies** (in a clean venv):
158
+ ```bash
159
+ pip install .[dev]
160
+ # or
161
+ uv pip install .[dev]
162
+ ```
163
+
164
+ 3. **Build the package:**
165
+ ```bash
166
+ python -m build
167
+ ```
168
+ This creates a `dist/` directory with `.whl` and `.tar.gz` files.
169
+
170
+ 4. **(Recommended) Set up a `.pypirc` file for easy publishing:**
171
+ - Create a file named `.pypirc` in your home directory (e.g., `C:\Users\yourname\.pypirc` on Windows or `~/.pypirc` on Linux/macOS).
172
+ - Add:
173
+ ```ini
174
+ [distutils]
175
+ index-servers =
176
+ pypi
177
+
178
+ [pypi]
179
+ username = __token__
180
+ password = pypi-AgEIcH... # <-- paste your API token here
181
+ ```
182
+
183
+ 5. **Publish to PyPI:**
184
+ ```bash
185
+ twine upload dist/*
186
+ ```
187
+ - If you set up `.pypirc`, you won't be prompted for credentials.
188
+ - If not, enter `__token__` as the username and paste your API token as the password.
189
+
190
+ 6. **Verify:**
191
+ - Visit https://pypi.org/project/cyberdesk/ to see your published package.
192
+ - Try installing it in a fresh environment:
193
+ ```bash
194
+ pip install cyberdesk
195
+ ```
196
+
197
+ ---
198
+
199
+ ## License
200
+
201
+ [MIT](LICENSE)
@@ -0,0 +1,8 @@
1
+ from .client import CyberdeskClient
2
+ from .types import (
3
+ GetDesktopParams,
4
+ LaunchDesktopParams,
5
+ TerminateDesktopParams,
6
+ ExecuteComputerActionParams,
7
+ ExecuteBashActionParams,
8
+ )
@@ -0,0 +1,38 @@
1
+ from .types import (
2
+ PostV1DesktopIdComputerActionClickMouseAction,
3
+ PostV1DesktopIdComputerActionDragMouseAction,
4
+ PostV1DesktopIdComputerActionGetCursorPositionAction,
5
+ PostV1DesktopIdComputerActionMoveMouseAction,
6
+ PostV1DesktopIdComputerActionPressKeysAction,
7
+ PostV1DesktopIdComputerActionScreenshotAction,
8
+ PostV1DesktopIdComputerActionScrollAction,
9
+ PostV1DesktopIdComputerActionTypeTextAction,
10
+ PostV1DesktopIdComputerActionWaitAction,
11
+ )
12
+
13
+ def click_mouse(x: int, y: int, button: str = "left") -> PostV1DesktopIdComputerActionClickMouseAction:
14
+ return PostV1DesktopIdComputerActionClickMouseAction(type="click_mouse", x=x, y=y, button=button)
15
+
16
+ def drag_mouse(start_x: int, start_y: int, end_x: int, end_y: int, button: str = "left") -> PostV1DesktopIdComputerActionDragMouseAction:
17
+ return PostV1DesktopIdComputerActionDragMouseAction(type="drag_mouse", start_x=start_x, start_y=start_y, end_x=end_x, end_y=end_y, button=button)
18
+
19
+ def get_cursor_position() -> PostV1DesktopIdComputerActionGetCursorPositionAction:
20
+ return PostV1DesktopIdComputerActionGetCursorPositionAction(type="get_cursor_position")
21
+
22
+ def move_mouse(x: int, y: int) -> PostV1DesktopIdComputerActionMoveMouseAction:
23
+ return PostV1DesktopIdComputerActionMoveMouseAction(type="move_mouse", x=x, y=y)
24
+
25
+ def press_keys(keys: list[str]) -> PostV1DesktopIdComputerActionPressKeysAction:
26
+ return PostV1DesktopIdComputerActionPressKeysAction(type="press_keys", keys=keys)
27
+
28
+ def screenshot() -> PostV1DesktopIdComputerActionScreenshotAction:
29
+ return PostV1DesktopIdComputerActionScreenshotAction(type="screenshot")
30
+
31
+ def scroll(dx: int, dy: int) -> PostV1DesktopIdComputerActionScrollAction:
32
+ return PostV1DesktopIdComputerActionScrollAction(type="scroll", dx=dx, dy=dy)
33
+
34
+ def type_text(text: str) -> PostV1DesktopIdComputerActionTypeTextAction:
35
+ return PostV1DesktopIdComputerActionTypeTextAction(type="type", text=text)
36
+
37
+ def wait(ms: int) -> PostV1DesktopIdComputerActionWaitAction:
38
+ return PostV1DesktopIdComputerActionWaitAction(type="wait", ms=ms)
@@ -0,0 +1,75 @@
1
+ """
2
+ Cyberdesk Python SDK wrapper client.
3
+ """
4
+
5
+ from .types import (
6
+ GetDesktopParams,
7
+ TerminateDesktopParams,
8
+ ExecuteBashActionParams,
9
+ ComputerActionModel,
10
+ )
11
+ from openapi_client.api_reference_client.client import Client
12
+ from openapi_client.api_reference_client.api.desktop import (
13
+ get_v1_desktop_id,
14
+ post_v1_desktop,
15
+ post_v1_desktop_id_stop,
16
+ post_v1_desktop_id_computer_action,
17
+ post_v1_desktop_id_bash_action,
18
+ )
19
+ from openapi_client.api_reference_client.models import (
20
+ PostV1DesktopBody,
21
+ PostV1DesktopIdBashActionBody,
22
+ )
23
+
24
+ class CyberdeskClient:
25
+ """
26
+ Wrapper client for the Cyberdesk API.
27
+ Provides both synchronous and asynchronous methods.
28
+ """
29
+ def __init__(self, api_key: str, base_url: str = "https://api.cyberdesk.io"):
30
+ self.api_key = api_key
31
+ self.client = Client(base_url=base_url, headers={"x-api-key": api_key})
32
+
33
+ def get_desktop(self, id: GetDesktopParams):
34
+ """Synchronous: Get details of a specific desktop instance."""
35
+ return get_v1_desktop_id.sync(id=id, client=self.client, x_api_key=self.api_key)
36
+
37
+ async def async_get_desktop(self, id: GetDesktopParams):
38
+ """Async: Get details of a specific desktop instance. Use with 'await'."""
39
+ return await get_v1_desktop_id.asyncio(id=id, client=self.client, x_api_key=self.api_key)
40
+
41
+ def launch_desktop(self, timeout_ms: int = None):
42
+ """Synchronous: Create a new virtual desktop instance."""
43
+ body = PostV1DesktopBody(timeout_ms=timeout_ms) if timeout_ms is not None else PostV1DesktopBody()
44
+ return post_v1_desktop.sync(client=self.client, body=body, x_api_key=self.api_key)
45
+
46
+ async def async_launch_desktop(self, timeout_ms: int = None):
47
+ """Async: Create a new virtual desktop instance. Use with 'await'."""
48
+ body = PostV1DesktopBody(timeout_ms=timeout_ms) if timeout_ms is not None else PostV1DesktopBody()
49
+ return await post_v1_desktop.asyncio(client=self.client, body=body, x_api_key=self.api_key)
50
+
51
+ def terminate_desktop(self, id: TerminateDesktopParams):
52
+ """Synchronous: Stop a running desktop instance."""
53
+ return post_v1_desktop_id_stop.sync(id=id, client=self.client, x_api_key=self.api_key)
54
+
55
+ async def async_terminate_desktop(self, id: TerminateDesktopParams):
56
+ """Async: Stop a running desktop instance. Use with 'await'."""
57
+ return await post_v1_desktop_id_stop.asyncio(id=id, client=self.client, x_api_key=self.api_key)
58
+
59
+ def execute_computer_action(self, id: GetDesktopParams, action: ComputerActionModel):
60
+ """Synchronous: Perform an action on the desktop (mouse, keyboard, etc)."""
61
+ return post_v1_desktop_id_computer_action.sync(id=id, client=self.client, body=action, x_api_key=self.api_key)
62
+
63
+ async def async_execute_computer_action(self, id: GetDesktopParams, action: ComputerActionModel):
64
+ """Async: Perform an action on the desktop (mouse, keyboard, etc). Use with 'await'."""
65
+ return await post_v1_desktop_id_computer_action.asyncio(id=id, client=self.client, body=action, x_api_key=self.api_key)
66
+
67
+ def execute_bash_action(self, id: GetDesktopParams, command: ExecuteBashActionParams):
68
+ """Synchronous: Execute a bash command on the desktop."""
69
+ body = PostV1DesktopIdBashActionBody(command=command)
70
+ return post_v1_desktop_id_bash_action.sync(id=id, client=self.client, body=body, x_api_key=self.api_key)
71
+
72
+ async def async_execute_bash_action(self, id: GetDesktopParams, command: ExecuteBashActionParams):
73
+ """Async: Execute a bash command on the desktop. Use with 'await'."""
74
+ body = PostV1DesktopIdBashActionBody(command=command)
75
+ return await post_v1_desktop_id_bash_action.asyncio(id=id, client=self.client, body=body, x_api_key=self.api_key)
@@ -0,0 +1,50 @@
1
+ from openapi_client.api_reference_client.models import (
2
+ PostV1DesktopBody,
3
+ PostV1DesktopIdComputerActionClickMouseAction,
4
+ PostV1DesktopIdComputerActionDragMouseAction,
5
+ PostV1DesktopIdComputerActionGetCursorPositionAction,
6
+ PostV1DesktopIdComputerActionMoveMouseAction,
7
+ PostV1DesktopIdComputerActionPressKeysAction,
8
+ PostV1DesktopIdComputerActionScreenshotAction,
9
+ PostV1DesktopIdComputerActionScrollAction,
10
+ PostV1DesktopIdComputerActionTypeTextAction,
11
+ PostV1DesktopIdComputerActionWaitAction,
12
+ )
13
+ from typing import Union
14
+
15
+ # Named parameter types for SDK methods
16
+ GetDesktopParams = str # Desktop ID
17
+ LaunchDesktopParams = PostV1DesktopBody
18
+ TerminateDesktopParams = str # Desktop ID
19
+ ExecuteBashActionParams = str # Command string
20
+
21
+ # Strongly-typed union for all computer action models
22
+ ComputerActionModel = Union[
23
+ PostV1DesktopIdComputerActionClickMouseAction,
24
+ PostV1DesktopIdComputerActionDragMouseAction,
25
+ PostV1DesktopIdComputerActionGetCursorPositionAction,
26
+ PostV1DesktopIdComputerActionMoveMouseAction,
27
+ PostV1DesktopIdComputerActionPressKeysAction,
28
+ PostV1DesktopIdComputerActionScreenshotAction,
29
+ PostV1DesktopIdComputerActionScrollAction,
30
+ PostV1DesktopIdComputerActionTypeTextAction,
31
+ PostV1DesktopIdComputerActionWaitAction,
32
+ ]
33
+
34
+ # Re-export action models for ergonomic imports
35
+ __all__ = [
36
+ "GetDesktopParams",
37
+ "LaunchDesktopParams",
38
+ "TerminateDesktopParams",
39
+ "ExecuteBashActionParams",
40
+ "ComputerActionModel",
41
+ "PostV1DesktopIdComputerActionClickMouseAction",
42
+ "PostV1DesktopIdComputerActionDragMouseAction",
43
+ "PostV1DesktopIdComputerActionGetCursorPositionAction",
44
+ "PostV1DesktopIdComputerActionMoveMouseAction",
45
+ "PostV1DesktopIdComputerActionPressKeysAction",
46
+ "PostV1DesktopIdComputerActionScreenshotAction",
47
+ "PostV1DesktopIdComputerActionScrollAction",
48
+ "PostV1DesktopIdComputerActionTypeTextAction",
49
+ "PostV1DesktopIdComputerActionWaitAction",
50
+ ]
@@ -0,0 +1,216 @@
1
+ Metadata-Version: 2.4
2
+ Name: cyberdesk
3
+ Version: 0.2.2
4
+ Summary: The official Python SDK for Cyberdesk
5
+ Author-email: Cyberdesk Team <dev@cyberdesk.io>
6
+ License-Expression: MIT
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: httpx
10
+ Provides-Extra: dev
11
+ Requires-Dist: openapi-python-client; extra == "dev"
12
+ Requires-Dist: build; extra == "dev"
13
+ Requires-Dist: twine; extra == "dev"
14
+ Dynamic: license-file
15
+
16
+ # cyberdesk
17
+
18
+ [![PyPI version](https://badge.fury.io/py/cyberdesk.svg)](https://badge.fury.io/py/cyberdesk)
19
+
20
+ The official Python SDK for Cyberdesk.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install cyberdesk
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ First, create a Cyberdesk client instance with your API key:
31
+
32
+ ```python
33
+ from cyberdesk import CyberdeskClient
34
+
35
+ client = CyberdeskClient(api_key="YOUR_API_KEY")
36
+ ```
37
+
38
+ ---
39
+
40
+ ### Launch a Desktop
41
+
42
+ ```python
43
+ result = client.launch_desktop(timeout_ms=10000) # Optional: set a timeout for the desktop session
44
+
45
+ # Error handling example
46
+ if hasattr(result, 'error') and result.error:
47
+ raise Exception('Failed to launch desktop: ' + str(result.error))
48
+
49
+ # Success
50
+ if hasattr(result, 'id'):
51
+ desktop_id = result.id
52
+ print('Launched desktop with ID:', desktop_id)
53
+ ```
54
+
55
+ ---
56
+
57
+ ### Get Desktop Info
58
+
59
+ ```python
60
+ info = client.get_desktop("your-desktop-id")
61
+
62
+ if hasattr(info, 'error') and info.error:
63
+ raise Exception('Failed to get desktop info: ' + str(info.error))
64
+
65
+ print('Desktop info:', info)
66
+ ```
67
+
68
+ ---
69
+
70
+ ### Perform a Computer Action (e.g., Mouse Click)
71
+
72
+ ```python
73
+ from cyberdesk.actions import click_mouse
74
+
75
+ action = click_mouse(x=100, y=150, button="left")
76
+ action_result = client.execute_computer_action("your-desktop-id", action)
77
+
78
+ if hasattr(action_result, 'error') and action_result.error:
79
+ raise Exception('Action failed: ' + str(action_result.error))
80
+
81
+ print('Action result:', action_result)
82
+ ```
83
+
84
+ ---
85
+
86
+ ### Run a Bash Command
87
+
88
+ ```python
89
+ bash_result = client.execute_bash_action(
90
+ "your-desktop-id",
91
+ "echo Hello, world!"
92
+ )
93
+
94
+ if hasattr(bash_result, 'error') and bash_result.error:
95
+ raise Exception('Bash command failed: ' + str(bash_result.error))
96
+
97
+ print('Bash output:', getattr(bash_result, 'output', bash_result))
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Ergonomic, Type-Safe Actions
103
+
104
+ To create computer actions (mouse, keyboard, etc.), use the factory functions in `cyberdesk.actions`. These provide full type hints and IDE autocompletion for all required and optional fields.
105
+
106
+ **Example:**
107
+ ```python
108
+ from cyberdesk.actions import click_mouse, type_text
109
+
110
+ action1 = click_mouse(x=100, y=200, button="left")
111
+ action2 = type_text(text="Hello, world!")
112
+
113
+ client.execute_computer_action("your-desktop-id", action1)
114
+ client.execute_computer_action("your-desktop-id", action2)
115
+ ```
116
+
117
+ | Action | Factory Function | Description |
118
+ |----------------|-------------------------|----------------------------|
119
+ | Click Mouse | `click_mouse` | Mouse click at (x, y) |
120
+ | Drag Mouse | `drag_mouse` | Mouse drag from/to (x, y) |
121
+ | Move Mouse | `move_mouse` | Move mouse to (x, y) |
122
+ | Scroll | `scroll` | Scroll by dx, dy |
123
+ | Type Text | `type_text` | Type text |
124
+ | Press Keys | `press_keys` | Press keyboard keys |
125
+ | Screenshot | `screenshot` | Take a screenshot |
126
+ | Wait | `wait` | Wait for ms milliseconds |
127
+ | Get Cursor Pos | `get_cursor_position` | Get mouse cursor position |
128
+
129
+ ---
130
+
131
+ ## Async Usage
132
+
133
+ All methods are also available as async variants (prefixed with `async_`). Example:
134
+
135
+ ```python
136
+ import asyncio
137
+ from cyberdesk import CyberdeskClient
138
+ from cyberdesk.actions import click_mouse
139
+
140
+ async def main():
141
+ client = CyberdeskClient(api_key="YOUR_API_KEY")
142
+ result = await client.async_launch_desktop(timeout_ms=10000)
143
+ print(result)
144
+ # Example async computer action
145
+ action = click_mouse(x=100, y=200)
146
+ await client.async_execute_computer_action("your-desktop-id", action)
147
+ # ... use other async_ methods as needed
148
+
149
+ asyncio.run(main())
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Type Hints and Models
155
+
156
+ All request/response types are available from the generated models, and all computer actions are available as factory functions in `cyberdesk.actions` for ergonomic, type-safe usage.
157
+
158
+ ```python
159
+ from cyberdesk.actions import click_mouse, drag_mouse, type_text, wait, scroll, move_mouse, press_keys, screenshot, get_cursor_position
160
+ ```
161
+
162
+ ---
163
+
164
+ ## For Cyberdesk Team: Publishing to PyPI
165
+
166
+ **Recommended:** Always use a [virtual environment](https://docs.python.org/3/library/venv.html) (venv) for building and publishing to avoid dependency conflicts.
167
+
168
+ To build and publish this package to [PyPI](https://pypi.org/project/cyberdesk/):
169
+
170
+ 1. **Log into PyPI** (get credentials from the Cyberdesk team).
171
+
172
+ 2. **Install dev dependencies** (in a clean venv):
173
+ ```bash
174
+ pip install .[dev]
175
+ # or
176
+ uv pip install .[dev]
177
+ ```
178
+
179
+ 3. **Build the package:**
180
+ ```bash
181
+ python -m build
182
+ ```
183
+ This creates a `dist/` directory with `.whl` and `.tar.gz` files.
184
+
185
+ 4. **(Recommended) Set up a `.pypirc` file for easy publishing:**
186
+ - Create a file named `.pypirc` in your home directory (e.g., `C:\Users\yourname\.pypirc` on Windows or `~/.pypirc` on Linux/macOS).
187
+ - Add:
188
+ ```ini
189
+ [distutils]
190
+ index-servers =
191
+ pypi
192
+
193
+ [pypi]
194
+ username = __token__
195
+ password = pypi-AgEIcH... # <-- paste your API token here
196
+ ```
197
+
198
+ 5. **Publish to PyPI:**
199
+ ```bash
200
+ twine upload dist/*
201
+ ```
202
+ - If you set up `.pypirc`, you won't be prompted for credentials.
203
+ - If not, enter `__token__` as the username and paste your API token as the password.
204
+
205
+ 6. **Verify:**
206
+ - Visit https://pypi.org/project/cyberdesk/ to see your published package.
207
+ - Try installing it in a fresh environment:
208
+ ```bash
209
+ pip install cyberdesk
210
+ ```
211
+
212
+ ---
213
+
214
+ ## License
215
+
216
+ [MIT](LICENSE)
@@ -2,7 +2,9 @@ LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
4
  cyberdesk/__init__.py
5
+ cyberdesk/actions.py
5
6
  cyberdesk/client.py
7
+ cyberdesk/types.py
6
8
  cyberdesk.egg-info/PKG-INFO
7
9
  cyberdesk.egg-info/SOURCES.txt
8
10
  cyberdesk.egg-info/dependency_links.txt
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cyberdesk"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "The official Python SDK for Cyberdesk"
5
5
  authors = [{name = "Cyberdesk Team", email = "dev@cyberdesk.io"}]
6
6
  readme = "README.md"
cyberdesk-0.2.1/PKG-INFO DELETED
@@ -1,137 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: cyberdesk
3
- Version: 0.2.1
4
- Summary: The official Python SDK for Cyberdesk
5
- Author-email: Cyberdesk Team <dev@cyberdesk.io>
6
- License-Expression: MIT
7
- Description-Content-Type: text/markdown
8
- License-File: LICENSE
9
- Requires-Dist: httpx
10
- Provides-Extra: dev
11
- Requires-Dist: openapi-python-client; extra == "dev"
12
- Requires-Dist: build; extra == "dev"
13
- Requires-Dist: twine; extra == "dev"
14
- Dynamic: license-file
15
-
16
- # cyberdesk
17
-
18
- [![PyPI version](https://badge.fury.io/py/cyberdesk.svg)](https://badge.fury.io/py/cyberdesk)
19
-
20
- The official Python SDK for Cyberdesk.
21
-
22
- ## Installation
23
-
24
- ```bash
25
- pip install cyberdesk
26
- ```
27
-
28
- ## Usage
29
-
30
- First, create a Cyberdesk client instance with your API key:
31
-
32
- ```python
33
- from cyberdesk import CyberdeskClient
34
-
35
- client = CyberdeskClient(api_key="YOUR_API_KEY")
36
- ```
37
-
38
- ---
39
-
40
- ### Launch a Desktop
41
-
42
- ```python
43
- result = client.launch_desktop(timeout_ms=10000) # Optional: set a timeout for the desktop session
44
-
45
- # Error handling example
46
- if hasattr(result, 'error') and result.error:
47
- raise Exception('Failed to launch desktop: ' + str(result.error))
48
-
49
- # Success
50
- if hasattr(result, 'id'):
51
- desktop_id = result.id
52
- print('Launched desktop with ID:', desktop_id)
53
- ```
54
-
55
- ---
56
-
57
- ### Get Desktop Info
58
-
59
- ```python
60
- info = client.get_desktop("your-desktop-id")
61
-
62
- if hasattr(info, 'error') and info.error:
63
- raise Exception('Failed to get desktop info: ' + str(info.error))
64
-
65
- print('Desktop info:', info)
66
- ```
67
-
68
- ---
69
-
70
- ### Perform a Computer Action (e.g., Mouse Click)
71
-
72
- ```python
73
- action_result = client.execute_computer_action(
74
- "your-desktop-id",
75
- {
76
- "type": "click_mouse",
77
- "x": 100,
78
- "y": 150
79
- }
80
- )
81
-
82
- if hasattr(action_result, 'error') and action_result.error:
83
- raise Exception('Action failed: ' + str(action_result.error))
84
-
85
- print('Action result:', action_result)
86
- ```
87
-
88
- ---
89
-
90
- ### Run a Bash Command
91
-
92
- ```python
93
- bash_result = client.execute_bash_action(
94
- "your-desktop-id",
95
- "echo Hello, world!"
96
- )
97
-
98
- if hasattr(bash_result, 'error') and bash_result.error:
99
- raise Exception('Bash command failed: ' + str(bash_result.error))
100
-
101
- print('Bash output:', getattr(bash_result, 'output', bash_result))
102
- ```
103
-
104
- ---
105
-
106
- ## Async Usage
107
-
108
- All methods are also available as async variants (prefixed with `async_`). Example:
109
-
110
- ```python
111
- import asyncio
112
- from cyberdesk import CyberdeskClient
113
-
114
- async def main():
115
- client = CyberdeskClient(api_key="YOUR_API_KEY")
116
- result = await client.async_launch_desktop(timeout_ms=10000)
117
- print(result)
118
- # ... use other async_ methods as needed
119
-
120
- asyncio.run(main())
121
- ```
122
-
123
- ---
124
-
125
- ## Type Hints and Models
126
-
127
- All request/response types are available from the generated models:
128
-
129
- ```python
130
- from openapi_client.api_reference_client.models import PostV1DesktopBody, PostV1DesktopIdBashActionBody
131
- ```
132
-
133
- ---
134
-
135
- ## License
136
-
137
- [MIT](LICENSE)
cyberdesk-0.2.1/README.md DELETED
@@ -1,122 +0,0 @@
1
- # cyberdesk
2
-
3
- [![PyPI version](https://badge.fury.io/py/cyberdesk.svg)](https://badge.fury.io/py/cyberdesk)
4
-
5
- The official Python SDK for Cyberdesk.
6
-
7
- ## Installation
8
-
9
- ```bash
10
- pip install cyberdesk
11
- ```
12
-
13
- ## Usage
14
-
15
- First, create a Cyberdesk client instance with your API key:
16
-
17
- ```python
18
- from cyberdesk import CyberdeskClient
19
-
20
- client = CyberdeskClient(api_key="YOUR_API_KEY")
21
- ```
22
-
23
- ---
24
-
25
- ### Launch a Desktop
26
-
27
- ```python
28
- result = client.launch_desktop(timeout_ms=10000) # Optional: set a timeout for the desktop session
29
-
30
- # Error handling example
31
- if hasattr(result, 'error') and result.error:
32
- raise Exception('Failed to launch desktop: ' + str(result.error))
33
-
34
- # Success
35
- if hasattr(result, 'id'):
36
- desktop_id = result.id
37
- print('Launched desktop with ID:', desktop_id)
38
- ```
39
-
40
- ---
41
-
42
- ### Get Desktop Info
43
-
44
- ```python
45
- info = client.get_desktop("your-desktop-id")
46
-
47
- if hasattr(info, 'error') and info.error:
48
- raise Exception('Failed to get desktop info: ' + str(info.error))
49
-
50
- print('Desktop info:', info)
51
- ```
52
-
53
- ---
54
-
55
- ### Perform a Computer Action (e.g., Mouse Click)
56
-
57
- ```python
58
- action_result = client.execute_computer_action(
59
- "your-desktop-id",
60
- {
61
- "type": "click_mouse",
62
- "x": 100,
63
- "y": 150
64
- }
65
- )
66
-
67
- if hasattr(action_result, 'error') and action_result.error:
68
- raise Exception('Action failed: ' + str(action_result.error))
69
-
70
- print('Action result:', action_result)
71
- ```
72
-
73
- ---
74
-
75
- ### Run a Bash Command
76
-
77
- ```python
78
- bash_result = client.execute_bash_action(
79
- "your-desktop-id",
80
- "echo Hello, world!"
81
- )
82
-
83
- if hasattr(bash_result, 'error') and bash_result.error:
84
- raise Exception('Bash command failed: ' + str(bash_result.error))
85
-
86
- print('Bash output:', getattr(bash_result, 'output', bash_result))
87
- ```
88
-
89
- ---
90
-
91
- ## Async Usage
92
-
93
- All methods are also available as async variants (prefixed with `async_`). Example:
94
-
95
- ```python
96
- import asyncio
97
- from cyberdesk import CyberdeskClient
98
-
99
- async def main():
100
- client = CyberdeskClient(api_key="YOUR_API_KEY")
101
- result = await client.async_launch_desktop(timeout_ms=10000)
102
- print(result)
103
- # ... use other async_ methods as needed
104
-
105
- asyncio.run(main())
106
- ```
107
-
108
- ---
109
-
110
- ## Type Hints and Models
111
-
112
- All request/response types are available from the generated models:
113
-
114
- ```python
115
- from openapi_client.api_reference_client.models import PostV1DesktopBody, PostV1DesktopIdBashActionBody
116
- ```
117
-
118
- ---
119
-
120
- ## License
121
-
122
- [MIT](LICENSE)
@@ -1 +0,0 @@
1
- from .client import CyberdeskClient
@@ -1,108 +0,0 @@
1
- """
2
- Cyberdesk Python SDK wrapper client.
3
- """
4
-
5
- from openapi_client.api_reference_client.client import Client
6
- from openapi_client.api_reference_client.api.desktop import (
7
- get_v1_desktop_id,
8
- post_v1_desktop,
9
- post_v1_desktop_id_stop,
10
- post_v1_desktop_id_computer_action,
11
- post_v1_desktop_id_bash_action,
12
- )
13
- from openapi_client.api_reference_client.models import (
14
- PostV1DesktopBody,
15
- PostV1DesktopIdBashActionBody,
16
- PostV1DesktopIdComputerActionClickMouseAction,
17
- PostV1DesktopIdComputerActionDragMouseAction,
18
- PostV1DesktopIdComputerActionGetCursorPositionAction,
19
- PostV1DesktopIdComputerActionMoveMouseAction,
20
- PostV1DesktopIdComputerActionPressKeysAction,
21
- PostV1DesktopIdComputerActionScreenshotAction,
22
- PostV1DesktopIdComputerActionScrollAction,
23
- PostV1DesktopIdComputerActionTypeTextAction,
24
- PostV1DesktopIdComputerActionWaitAction,
25
- )
26
-
27
- class CyberdeskClient:
28
- """
29
- Wrapper client for the Cyberdesk API.
30
- Provides both synchronous and asynchronous methods.
31
- """
32
- def __init__(self, api_key: str, base_url: str = "https://api.cyberdesk.io"):
33
- self.api_key = api_key
34
- self.client = Client(base_url=base_url, headers={"x-api-key": api_key})
35
-
36
- def get_desktop(self, id: str):
37
- """Synchronous: Get details of a specific desktop instance."""
38
- return get_v1_desktop_id.sync(id=id, client=self.client, x_api_key=self.api_key)
39
-
40
- async def async_get_desktop(self, id: str):
41
- """Async: Get details of a specific desktop instance. Use with 'await'."""
42
- return await get_v1_desktop_id.asyncio(id=id, client=self.client, x_api_key=self.api_key)
43
-
44
- def launch_desktop(self, timeout_ms: int = None):
45
- """Synchronous: Create a new virtual desktop instance."""
46
- body = PostV1DesktopBody(timeout_ms=timeout_ms) if timeout_ms is not None else PostV1DesktopBody()
47
- return post_v1_desktop.sync(client=self.client, body=body, x_api_key=self.api_key)
48
-
49
- async def async_launch_desktop(self, timeout_ms: int = None):
50
- """Async: Create a new virtual desktop instance. Use with 'await'."""
51
- body = PostV1DesktopBody(timeout_ms=timeout_ms) if timeout_ms is not None else PostV1DesktopBody()
52
- return await post_v1_desktop.asyncio(client=self.client, body=body, x_api_key=self.api_key)
53
-
54
- def terminate_desktop(self, id: str):
55
- """Synchronous: Stop a running desktop instance."""
56
- return post_v1_desktop_id_stop.sync(id=id, client=self.client, x_api_key=self.api_key)
57
-
58
- async def async_terminate_desktop(self, id: str):
59
- """Async: Stop a running desktop instance. Use with 'await'."""
60
- return await post_v1_desktop_id_stop.asyncio(id=id, client=self.client, x_api_key=self.api_key)
61
-
62
- def execute_computer_action(self, id: str, action: dict):
63
- """Synchronous: Perform an action on the desktop (mouse, keyboard, etc)."""
64
- action_type = action.get("type")
65
- model_cls = {
66
- "click_mouse": PostV1DesktopIdComputerActionClickMouseAction,
67
- "scroll": PostV1DesktopIdComputerActionScrollAction,
68
- "move_mouse": PostV1DesktopIdComputerActionMoveMouseAction,
69
- "drag_mouse": PostV1DesktopIdComputerActionDragMouseAction,
70
- "type": PostV1DesktopIdComputerActionTypeTextAction,
71
- "press_keys": PostV1DesktopIdComputerActionPressKeysAction,
72
- "wait": PostV1DesktopIdComputerActionWaitAction,
73
- "screenshot": PostV1DesktopIdComputerActionScreenshotAction,
74
- "get_cursor_position": PostV1DesktopIdComputerActionGetCursorPositionAction,
75
- }.get(action_type)
76
- if model_cls is None:
77
- raise ValueError(f"Unknown computer action type: {action_type}")
78
- model = model_cls.from_dict(action)
79
- return post_v1_desktop_id_computer_action.sync(id=id, client=self.client, body=model, x_api_key=self.api_key)
80
-
81
- async def async_execute_computer_action(self, id: str, action: dict):
82
- """Async: Perform an action on the desktop (mouse, keyboard, etc). Use with 'await'."""
83
- action_type = action.get("type")
84
- model_cls = {
85
- "click_mouse": PostV1DesktopIdComputerActionClickMouseAction,
86
- "scroll": PostV1DesktopIdComputerActionScrollAction,
87
- "move_mouse": PostV1DesktopIdComputerActionMoveMouseAction,
88
- "drag_mouse": PostV1DesktopIdComputerActionDragMouseAction,
89
- "type": PostV1DesktopIdComputerActionTypeTextAction,
90
- "press_keys": PostV1DesktopIdComputerActionPressKeysAction,
91
- "wait": PostV1DesktopIdComputerActionWaitAction,
92
- "screenshot": PostV1DesktopIdComputerActionScreenshotAction,
93
- "get_cursor_position": PostV1DesktopIdComputerActionGetCursorPositionAction,
94
- }.get(action_type)
95
- if model_cls is None:
96
- raise ValueError(f"Unknown computer action type: {action_type}")
97
- model = model_cls.from_dict(action)
98
- return await post_v1_desktop_id_computer_action.asyncio(id=id, client=self.client, body=model, x_api_key=self.api_key)
99
-
100
- def execute_bash_action(self, id: str, command: str):
101
- """Synchronous: Execute a bash command on the desktop."""
102
- body = PostV1DesktopIdBashActionBody(command=command)
103
- return post_v1_desktop_id_bash_action.sync(id=id, client=self.client, body=body, x_api_key=self.api_key)
104
-
105
- async def async_execute_bash_action(self, id: str, command: str):
106
- """Async: Execute a bash command on the desktop. Use with 'await'."""
107
- body = PostV1DesktopIdBashActionBody(command=command)
108
- return await post_v1_desktop_id_bash_action.asyncio(id=id, client=self.client, body=body, x_api_key=self.api_key)
@@ -1,137 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: cyberdesk
3
- Version: 0.2.1
4
- Summary: The official Python SDK for Cyberdesk
5
- Author-email: Cyberdesk Team <dev@cyberdesk.io>
6
- License-Expression: MIT
7
- Description-Content-Type: text/markdown
8
- License-File: LICENSE
9
- Requires-Dist: httpx
10
- Provides-Extra: dev
11
- Requires-Dist: openapi-python-client; extra == "dev"
12
- Requires-Dist: build; extra == "dev"
13
- Requires-Dist: twine; extra == "dev"
14
- Dynamic: license-file
15
-
16
- # cyberdesk
17
-
18
- [![PyPI version](https://badge.fury.io/py/cyberdesk.svg)](https://badge.fury.io/py/cyberdesk)
19
-
20
- The official Python SDK for Cyberdesk.
21
-
22
- ## Installation
23
-
24
- ```bash
25
- pip install cyberdesk
26
- ```
27
-
28
- ## Usage
29
-
30
- First, create a Cyberdesk client instance with your API key:
31
-
32
- ```python
33
- from cyberdesk import CyberdeskClient
34
-
35
- client = CyberdeskClient(api_key="YOUR_API_KEY")
36
- ```
37
-
38
- ---
39
-
40
- ### Launch a Desktop
41
-
42
- ```python
43
- result = client.launch_desktop(timeout_ms=10000) # Optional: set a timeout for the desktop session
44
-
45
- # Error handling example
46
- if hasattr(result, 'error') and result.error:
47
- raise Exception('Failed to launch desktop: ' + str(result.error))
48
-
49
- # Success
50
- if hasattr(result, 'id'):
51
- desktop_id = result.id
52
- print('Launched desktop with ID:', desktop_id)
53
- ```
54
-
55
- ---
56
-
57
- ### Get Desktop Info
58
-
59
- ```python
60
- info = client.get_desktop("your-desktop-id")
61
-
62
- if hasattr(info, 'error') and info.error:
63
- raise Exception('Failed to get desktop info: ' + str(info.error))
64
-
65
- print('Desktop info:', info)
66
- ```
67
-
68
- ---
69
-
70
- ### Perform a Computer Action (e.g., Mouse Click)
71
-
72
- ```python
73
- action_result = client.execute_computer_action(
74
- "your-desktop-id",
75
- {
76
- "type": "click_mouse",
77
- "x": 100,
78
- "y": 150
79
- }
80
- )
81
-
82
- if hasattr(action_result, 'error') and action_result.error:
83
- raise Exception('Action failed: ' + str(action_result.error))
84
-
85
- print('Action result:', action_result)
86
- ```
87
-
88
- ---
89
-
90
- ### Run a Bash Command
91
-
92
- ```python
93
- bash_result = client.execute_bash_action(
94
- "your-desktop-id",
95
- "echo Hello, world!"
96
- )
97
-
98
- if hasattr(bash_result, 'error') and bash_result.error:
99
- raise Exception('Bash command failed: ' + str(bash_result.error))
100
-
101
- print('Bash output:', getattr(bash_result, 'output', bash_result))
102
- ```
103
-
104
- ---
105
-
106
- ## Async Usage
107
-
108
- All methods are also available as async variants (prefixed with `async_`). Example:
109
-
110
- ```python
111
- import asyncio
112
- from cyberdesk import CyberdeskClient
113
-
114
- async def main():
115
- client = CyberdeskClient(api_key="YOUR_API_KEY")
116
- result = await client.async_launch_desktop(timeout_ms=10000)
117
- print(result)
118
- # ... use other async_ methods as needed
119
-
120
- asyncio.run(main())
121
- ```
122
-
123
- ---
124
-
125
- ## Type Hints and Models
126
-
127
- All request/response types are available from the generated models:
128
-
129
- ```python
130
- from openapi_client.api_reference_client.models import PostV1DesktopBody, PostV1DesktopIdBashActionBody
131
- ```
132
-
133
- ---
134
-
135
- ## License
136
-
137
- [MIT](LICENSE)
File without changes
File without changes