Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

feat(cua-driver): add true in-process SDK runtime (#2461)

Francesco Bonacci617508a7ae12
diff --git a/.github/workflows/ci-cua-driver-contract-clients.yml b/.github/workflows/ci-cua-driver-contract-clients.yml
index cf619d9749..eaac14e957 100644
--- a/.github/workflows/ci-cua-driver-contract-clients.yml
+++ b/.github/workflows/ci-cua-driver-contract-clients.yml
@@ -99,6 +99,12 @@ jobs:
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
with:
workspaces: "libs/cua-driver/rust -> target"
+ - name: Install Linux build dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y --no-install-recommends \
+ clang pkg-config libdbus-1-dev libpipewire-0.3-dev libspa-0.2-dev \
+ libei-dev libxkbcommon-dev libx11-dev libxi-dev libxtst-dev libxext-dev
- uses: actions/setup-python@v5
with:
python-version: "3.12"
diff --git a/libs/cua-driver/docs/uniffi-sdk-implementation-journal.md b/libs/cua-driver/docs/uniffi-sdk-implementation-journal.md
index 450d940126..743bde38bc 100644
--- a/libs/cua-driver/docs/uniffi-sdk-implementation-journal.md
+++ b/libs/cua-driver/docs/uniffi-sdk-implementation-journal.md
@@ -1,6 +1,11 @@
# UniFFI imported-SDK implementation journal
-Status: package-root SDK cleanup validated locally; pull-request exact-head CI pending
+Status: historical baseline plus RFC 2447 migration log
+
+The original sections below record the daemon-client SDK shipped in 0.11.0.
+[RFC 2447](../../../rfcs/2447-cua-driver-native-core-and-mcp-adapter.md)
+supersedes that topology: the public typed SDK now owns the platform runtime,
+and daemon/MCP hosting is migrating downstream of it.
## Definition of done
@@ -50,6 +55,24 @@ The product boundary is reflected directly in packaging:
## Verification log
+### RFC 2447 first implementation slice (2026-07-22)
+
+- `CuaDriver.create()` constructs the platform runtime in the importing process;
+ it neither launches `cua-driver` nor opens daemon IPC.
+- `cua-driver serve` constructs that same SDK-owned runtime and temporarily
+ exposes its private registry through the existing compatibility transport.
+- Python and TypeScript package roots select their binding client kind for both
+ `create()` and the transitional `connect()` path.
+- SDK operations are generated as asynchronous Python and TypeScript methods.
+- Rust SDK tests passed: 11 tests, including typed inventory parity,
+ same-process PID identity, idempotent shutdown, and daemon compatibility.
+- Python loader tests passed: 3 tests across in-process and daemon modes.
+- Node loader tests passed: 4 tests across in-process and daemon modes; the
+ Electron lifecycle fixture remains a separate release-matrix check.
+- Local macOS tests required a test-copy rpath for the Command Line Tools
+ `swift-5.5` runtime. No rpath mutation is checked in or applied to release
+ artifacts.
+
### Rust and contract
- `cargo check --locked --workspace --all-targets` passed. Existing
diff --git a/libs/cua-driver/docs/why-cua-driver-uses-mcp-instead-of-uniffi.md b/libs/cua-driver/docs/why-cua-driver-uses-mcp-instead-of-uniffi.md
index 79c5c4c090..f8042423f0 100644
--- a/libs/cua-driver/docs/why-cua-driver-uses-mcp-instead-of-uniffi.md
+++ b/libs/cua-driver/docs/why-cua-driver-uses-mcp-instead-of-uniffi.md
@@ -1,9 +1,15 @@
# Cua Driver integration surfaces: MCP/CLI and SDK bindings
-Status: accepted and implemented as an experimental imported-SDK vertical slice
+Status: superseded in part by RFC 2447
Decision date: 2026-07-21
+> This document preserves the rationale for the 0.11.0 daemon-client SDK.
+> [RFC 2447](../../../rfcs/2447-cua-driver-native-core-and-mcp-adapter.md)
+> keeps MCP as the agent boundary but replaces the imported SDK topology with a
+> same-process runtime and makes MCP a downstream SDK consumer. Where this
+> document says the SDK is only a daemon client, RFC 2447 is authoritative.
+
This document separates two Cua products that were previously discussed as if
they were one: Cua as a tool used by an agent, and Cua as an API imported by an
application. MCP and UniFFI solve different boundaries in those products and
diff --git a/libs/cua-driver/python/README.md b/libs/cua-driver/python/README.md
index acdcdcdebd..429ed2a1d1 100644
--- a/libs/cua-driver/python/README.md
+++ b/libs/cua-driver/python/README.md
@@ -19,9 +19,9 @@ cua-driver mcp
```
The removed pre-release MCP facade used `CuaDriver.stdio()`,
-`AsyncCuaDriver`, `*Args`, and transport classes. Application code migrates to
-the synchronous Rust-backed methods shown below; agent code removes the Cua
-package import and supplies `cua-driver mcp` to its agent SDK.
+`AsyncCuaDriver`, `*Args`, and transport classes. Application code imports the
+typed Rust-backed SDK shown below; agent code supplies `cua-driver mcp` to its
+agent SDK.
## Installation
@@ -29,12 +29,14 @@ Install and usage docs live at https://cua.ai/docs/how-to-guides/driver/install
and https://cua.ai/docs/reference/cua-driver/mcp-tools.
The wheel contains generated UniFFI bindings, a platform-specific Rust SDK
-library, and the `cua-driver` executable. The daemon must be running and have
-the required OS permissions before SDK calls are made.
+library, and the `cua-driver` executable. `CuaDriver.create()` loads the runtime
+in the importing process and does not require the executable or daemon.
## SDK example
```python
+import asyncio
+
from cua_driver import (
CaptureScope,
CuaDriver,
@@ -43,29 +45,43 @@ from cua_driver import (
StartSessionInput,
)
-driver = CuaDriver.connect(None) # or pass an explicit daemon socket path
-driver.start_session(
- StartSessionInput(session="demo", capture_scope=CaptureScope.DESKTOP)
-)
-try:
- desktop = driver.get_desktop_state(
- GetDesktopStateInput(session="demo", screenshot_out_file=None)
+async def main() -> None:
+ driver = CuaDriver.create()
+ await driver.start_session(
+ StartSessionInput(session="demo", capture_scope=CaptureScope.DESKTOP)
)
- print(desktop.images[0].mime_type)
-finally:
- driver.end_session(EndSessionInput(session="demo"))
+ try:
+ desktop = await driver.get_desktop_state(
+ GetDesktopStateInput(session="demo", screenshot_out_file=None)
+ )
+ print(desktop.images[0].mime_type)
+ finally:
+ await driver.end_session(EndSessionInput(session="demo"))
+ await driver.shutdown()
+
+
+asyncio.run(main())
```
-The SDK is currently synchronous. Desktop calls return a typed `ToolResult`
-with text, images, verification/error metadata, and `structured_json` /
-`raw_json` for platform-extensible results. Session lifecycle calls return
-dedicated generated records.
+SDK operations are asynchronous. Desktop calls return a typed `ToolResult` with
+text, images, verification/error metadata, and `structured_json` / `raw_json`
+for platform-extensible results. Session lifecycle calls return dedicated
+generated records.
+
+`CuaDriver.connect(socket_path)` remains available while existing applications
+migrate. It exposes the same methods over the installed daemon, but it does not
+provide a second SDK contract.
+
+`shutdown()` closes admission, waits for already admitted operations to finish,
+and is idempotent. Calls started after shutdown fail with `DriverError.Shutdown`.
+Destroying a binding handle releases native resources, but orderly applications
+should still await `shutdown()`.
-## Embedded application host
+## Daemon-backed MCP host
-Python applications can own the same Rust lifecycle object as Node clients.
-The regular `CuaDriver` interface is unchanged; only the socket comes from the
-embedded host:
+Applications that must also expose MCP to an external agent can own a private
+daemon child. The child provides a stable permission identity and session
+lifetime for short-lived or external clients:
```python
import asyncio
@@ -83,7 +99,7 @@ async def main() -> None:
try:
# Application calls use driver. An agent runtime can launch
# connection.mcp.command with connection.mcp.args and environment.
- print(driver.metadata())
+ print(await driver.metadata())
finally:
del driver
await host.stop()
diff --git a/libs/cua-driver/python/src/cua_driver/__init__.py b/libs/cua-driver/python/src/cua_driver/__init__.py
index 078297c599..b44e6237d7 100644
--- a/libs/cua-driver/python/src/cua_driver/__init__.py
+++ b/libs/cua-driver/python/src/cua_driver/__init__.py
@@ -9,7 +9,9 @@ __version__ = "0.11.0" # x-release-please-version
from ._native import (
CuaDriver as _NativeCuaDriver,
DriverError,
+ DriverExecutionMode,
DriverMetadata,
+ DriverOptions,
EmbeddedCuaDriverHost,
EmbeddedDriverConnection,
EmbeddedDriverError,
@@ -63,7 +65,14 @@ def _connect_python_sdk(cls, socket_path):
return cls.connect_with_client_kind(socket_path, SdkClientKind.PYTHON)
+def _create_python_sdk(cls, options=None):
+ """Create the canonical same-process SDK runtime for Python."""
+
+ return cls.create_with_client_kind(options, SdkClientKind.PYTHON)
+
+
_NativeCuaDriver.connect = classmethod(_connect_python_sdk)
+_NativeCuaDriver.create = classmethod(_create_python_sdk)
CuaDriver = _NativeCuaDriver
__all__ = [
@@ -74,7 +83,9 @@ __all__ = [
"DesktopScope",
"DragInput",
"DriverError",
+ "DriverExecutionMode",
"DriverMetadata",
+ "DriverOptions",
"EmbeddedCuaDriverHost",
"EmbeddedDriverConnection",
"EmbeddedDriverError",
diff --git a/libs/cua-driver/python/src/cua_driver/_native.py b/libs/cua-driver/python/src/cua_driver/_native.py
index 5ce7a56da7..76fb63492f 100644
--- a/libs/cua-driver/python/src/cua_driver/_native.py
+++ b/libs/cua-driver/python/src/cua_driver/_native.py
@@ -486,47 +486,55 @@ def _uniffi_check_api_checksums(lib):
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cua_driver_sdk_checksum_func_request_mac_os_permissions() != 61823:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect() != 42154:
+ if lib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect() != 60859:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect_with_client_kind() != 43287:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_call_tool() != 31445:
+ if lib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create() != 15191:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_click() != 34118:
+ if lib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create_with_client_kind() != 3630:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_drag() != 35252:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_call_tool() != 8122:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_end_session() != 33990:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_click() != 56077:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_escalate_session() != 37358:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_drag() != 25742:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_get_cursor_position() != 54043:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_end_session() != 18486:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_get_desktop_state() != 32992:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_escalate_session() != 6924:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_get_screen_size() != 15250:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_execution_mode() != 2639:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_get_session_state() != 51055:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_get_cursor_position() != 34285:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_hotkey() != 3135:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_get_desktop_state() != 65084:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_get_screen_size() != 55616:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_get_session_state() != 49966:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_hotkey() != 53333:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_is_available() != 42961:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_list_tools_json() != 43987:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_list_tools_json() != 36787:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_metadata() != 50371:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_metadata() != 55026:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_move_cursor() != 11209:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_move_cursor() != 18320:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_press_key() != 17425:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_press_key() != 63712:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_scroll() != 21614:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_scroll() != 52290:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_socket_path() != 24461:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_shutdown() != 36331:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_start_session() != 53509:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_socket_path() != 48126:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
- if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_type_text() != 19673:
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_start_session() != 45055:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_type_text() != 25156:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cua_driver_sdk_checksum_constructor_embeddedcuadriverhost_new() != 10108:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
@@ -850,67 +858,73 @@ _UniffiLib.uniffi_cua_driver_sdk_fn_constructor_cuadriver_connect_with_client_ki
ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.uniffi_cua_driver_sdk_fn_constructor_cuadriver_connect_with_client_kind.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cua_driver_sdk_fn_constructor_cuadriver_create.argtypes = (
+ _UniffiRustBuffer,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cua_driver_sdk_fn_constructor_cuadriver_create.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cua_driver_sdk_fn_constructor_cuadriver_create_with_client_kind.argtypes = (
+ _UniffiRustBuffer,
+ _UniffiRustBuffer,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cua_driver_sdk_fn_constructor_cuadriver_create_with_client_kind.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_call_tool.argtypes = (
ctypes.c_uint64,
_UniffiRustBuffer,
_UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_call_tool.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_call_tool.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_click.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_click.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_click.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_drag.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_drag.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_drag.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_end_session.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_end_session.restype = cua_driver._native_contract._UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_end_session.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_escalate_session.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
+)
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_escalate_session.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_execution_mode.argtypes = (
+ ctypes.c_uint64,
ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_escalate_session.restype = cua_driver._native_contract._UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_execution_mode.restype = _UniffiRustBuffer
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_cursor_position.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_cursor_position.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_cursor_position.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_desktop_state.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_desktop_state.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_desktop_state.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_screen_size.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_screen_size.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_screen_size.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_session_state.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_session_state.restype = cua_driver._native_contract._UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_session_state.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_hotkey.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_hotkey.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_hotkey.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_is_available.argtypes = (
ctypes.c_uint64,
ctypes.POINTER(_UniffiRustCallStatus),
@@ -918,32 +932,31 @@ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_is_available.argtypes = (
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_is_available.restype = ctypes.c_int8
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_list_tools_json.argtypes = (
ctypes.c_uint64,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_list_tools_json.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_list_tools_json.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_metadata.argtypes = (
ctypes.c_uint64,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_metadata.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_metadata.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_move_cursor.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_move_cursor.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_move_cursor.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_press_key.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_press_key.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_press_key.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_scroll.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_scroll.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_scroll.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_shutdown.argtypes = (
+ ctypes.c_uint64,
+)
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_shutdown.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_socket_path.argtypes = (
ctypes.c_uint64,
ctypes.POINTER(_UniffiRustCallStatus),
@@ -952,15 +965,13 @@ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_socket_path.restype = _Unif
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_start_session.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_start_session.restype = cua_driver._native_contract._UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_start_session.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_type_text.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
- ctypes.POINTER(_UniffiRustCallStatus),
)
-_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_type_text.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_type_text.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_constructor_embeddedcuadriverhost_new.argtypes = (
_UniffiRustBuffer,
_UniffiRustBuffer,
@@ -1017,6 +1028,12 @@ _UniffiLib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect.restype
_UniffiLib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect_with_client_kind.argtypes = (
)
_UniffiLib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect_with_client_kind.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create.argtypes = (
+)
+_UniffiLib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create_with_client_kind.argtypes = (
+)
+_UniffiLib.uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create_with_client_kind.restype = ctypes.c_uint16
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_call_tool.argtypes = (
)
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_call_tool.restype = ctypes.c_uint16
@@ -1032,6 +1049,9 @@ _UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_end_session.restype =
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_escalate_session.argtypes = (
)
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_escalate_session.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_execution_mode.argtypes = (
+)
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_execution_mode.restype = ctypes.c_uint16
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_get_cursor_position.argtypes = (
)
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_get_cursor_position.restype = ctypes.c_uint16
@@ -1065,6 +1085,9 @@ _UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_press_key.restype = c
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_scroll.argtypes = (
)
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_scroll.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_shutdown.argtypes = (
+)
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_shutdown.restype = ctypes.c_uint16
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_socket_path.argtypes = (
)
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_socket_path.restype = ctypes.c_uint16
@@ -1336,6 +1359,39 @@ class _UniffiFfiConverterTypeDriverMetadata(_UniffiConverterRustBuffer):
_UniffiFfiConverterBoolean.write(value.embedded, buf)
_UniffiFfiConverterOptionalString.write(value.host_bundle_id, buf)
+@dataclass
+class DriverOptions:
+ """
+ Options for a same-process Cua Driver SDK runtime.
+"""
+ def __init__(self, *, claude_code_compatibility:bool):
+ self.claude_code_compatibility = claude_code_compatibility
+
+
+
+
+ def __str__(self):
+ return "DriverOptions(claude_code_compatibility={})".format(self.claude_code_compatibility)
+ def __eq__(self, other):
+ if self.claude_code_compatibility != other.claude_code_compatibility:
+ return False
+ return True
+
+class _UniffiFfiConverterTypeDriverOptions(_UniffiConverterRustBuffer):
+ @staticmethod
+ def read(buf):
+ return DriverOptions(
+ claude_code_compatibility=_UniffiFfiConverterBoolean.read(buf),
+ )
+
+ @staticmethod
+ def check_lower(value):
+ _UniffiFfiConverterBoolean.check_lower(value.claude_code_compatibility)
+
+ @staticmethod
+ def write(value, buf):
+ _UniffiFfiConverterBoolean.write(value.claude_code_compatibility, buf)
+
class _UniffiFfiConverterSequenceString(_UniffiConverterRustBuffer):
@classmethod
def check_lower(cls, value):
@@ -2086,6 +2142,14 @@ class DriverError: # type: ignore
def __repr__(self):
return "DriverError.Tool({})".format(str(self))
_UniffiTempDriverError.Tool = Tool # type: ignore
+ class Shutdown(_UniffiTempDriverError):
+
+ def __init__(self):
+ pass
+
+ def __repr__(self):
+ return "DriverError.Shutdown({})".format(str(self))
+ _UniffiTempDriverError.Shutdown = Shutdown # type: ignore
DriverError = _UniffiTempDriverError # type: ignore
del _UniffiTempDriverError
@@ -2119,6 +2183,9 @@ class _UniffiFfiConverterTypeDriverError(_UniffiConverterRustBuffer):
_UniffiFfiConverterString.read(buf),
_UniffiFfiConverterString.read(buf),
)
+ if variant == 6:
+ return DriverError.Shutdown(
+ )
raise InternalError("Raw enum value doesn't match any cases")
@staticmethod
@@ -2142,6 +2209,8 @@ class _UniffiFfiConverterTypeDriverError(_UniffiConverterRustBuffer):
_UniffiFfiConverterString.check_lower(value.message)
_UniffiFfiConverterString.check_lower(value.error_code)
return
+ if isinstance(value, DriverError.Shutdown):
+ return
@staticmethod
def write(value, buf):
@@ -2164,6 +2233,51 @@ class _UniffiFfiConverterTypeDriverError(_UniffiConverterRustBuffer):
_UniffiFfiConverterString.write(value.tool, buf)
_UniffiFfiConverterString.write(value.message, buf)
_UniffiFfiConverterString.write(value.error_code, buf)
+ if isinstance(value, DriverError.Shutdown):
+ buf.write_i32(6)
+
+
+
+
+
+
+class DriverExecutionMode(enum.Enum):
+ """
+ Process topology used by this SDK object.
+"""
+
+ EMBEDDED = 0
+
+ DAEMON = 1
+
+
+
+class _UniffiFfiConverterTypeDriverExecutionMode(_UniffiConverterRustBuffer):
+ @staticmethod
+ def read(buf):
+ variant = buf.read_i32()
+ if variant == 1:
+ return DriverExecutionMode.EMBEDDED
+ if variant == 2:
+ return DriverExecutionMode.DAEMON
+ raise InternalError("Raw enum value doesn't match any cases")
+
+ @staticmethod
+ def check_lower(value):
+ if value == DriverExecutionMode.EMBEDDED:
+ return
+ if value == DriverExecutionMode.DAEMON:
+ return
+ raise ValueError(value)
+
+ @staticmethod
+ def write(value, buf):
+ if value == DriverExecutionMode.EMBEDDED:
+ buf.write_i32(1)
+ if value == DriverExecutionMode.DAEMON:
+ buf.write_i32(2)
+
+
@@ -2507,47 +2621,63 @@ class _UniffiFfiConverterTypeSdkClientKind(_UniffiConverterRustBuffer):
class CuaDriverProtocol(typing.Protocol):
- def call_tool(self, name: str,arguments_json: str) -> ToolResult:
+ async def call_tool(self, name: str,arguments_json: str) -> ToolResult:
"""
- Escape hatch for forward-compatible tools and application-owned server
- adapters. Typed methods below serialize the same canonical Rust inputs.
+ Temporary compatibility escape hatch. New application code should use
+ the typed methods; MCP servers own generic discovery and invocation.
"""
raise NotImplementedError
- def click(self, input: cua_driver._native_contract.ClickInput) -> ToolResult:
+ async def click(self, input: cua_driver._native_contract.ClickInput) -> ToolResult:
+ raise NotImplementedError
+ async def drag(self, input: cua_driver._native_contract.DragInput) -> ToolResult:
raise NotImplementedError
- def drag(self, input: cua_driver._native_contract.DragInput) -> ToolResult:
+ async def end_session(self, input: cua_driver._native_contract.EndSessionInput) -> cua_driver._native_contract.EndSessionOutput:
raise NotImplementedError
- def end_session(self, input: cua_driver._native_contract.EndSessionInput) -> cua_driver._native_contract.EndSessionOutput:
+ async def escalate_session(self, input: cua_driver._native_contract.EscalateSessionInput) -> cua_driver._native_contract.SessionStateOutput:
raise NotImplementedError
- def escalate_session(self, input: cua_driver._native_contract.EscalateSessionInput) -> cua_driver._native_contract.SessionStateOutput:
+ def execution_mode(self, ) -> DriverExecutionMode:
raise NotImplementedError
- def get_cursor_position(self, input: cua_driver._native_contract.GetCursorPositionInput) -> ToolResult:
+ async def get_cursor_position(self, input: cua_driver._native_contract.GetCursorPositionInput) -> ToolResult:
raise NotImplementedError
- def get_desktop_state(self, input: cua_driver._native_contract.GetDesktopStateInput) -> ToolResult:
+ async def get_desktop_state(self, input: cua_driver._native_contract.GetDesktopStateInput) -> ToolResult:
raise NotImplementedError
- def get_screen_size(self, input: cua_driver._native_contract.GetScreenSizeInput) -> ToolResult:
+ async def get_screen_size(self, input: cua_driver._native_contract.GetScreenSizeInput) -> ToolResult:
raise NotImplementedError
- def get_session_state(self, input: cua_driver._native_contract.GetSessionStateInput) -> cua_driver._native_contract.SessionStateOutput:
+ async def get_session_state(self, input: cua_driver._native_contract.GetSessionStateInput) -> cua_driver._native_contract.SessionStateOutput:
raise NotImplementedError
- def hotkey(self, input: cua_driver._native_contract.HotkeyInput) -> ToolResult:
+ async def hotkey(self, input: cua_driver._native_contract.HotkeyInput) -> ToolResult:
raise NotImplementedError
def is_available(self, ) -> bool:
raise NotImplementedError
- def list_tools_json(self, ) -> str:
+ async def list_tools_json(self, ) -> str:
+ """
+ Temporary compatibility discovery surface for adapters migrating to
+ the typed SDK contract.
+"""
+ raise NotImplementedError
+ async def metadata(self, ) -> DriverMetadata:
raise NotImplementedError
- def metadata(self, ) -> DriverMetadata:
+ async def move_cursor(self, input: cua_driver._native_contract.MoveCursorInput) -> ToolResult:
raise NotImplementedError
- def move_cursor(self, input: cua_driver._native_contract.MoveCursorInput) -> ToolResult:
+ async def press_key(self, input: cua_driver._native_contract.PressKeyInput) -> ToolResult:
raise NotImplementedError
- def press_key(self, input: cua_driver._native_contract.PressKeyInput) -> ToolResult:
+ async def scroll(self, input: cua_driver._native_contract.ScrollInput) -> ToolResult:
raise NotImplementedError
- def scroll(self, input: cua_driver._native_contract.ScrollInput) -> ToolResult:
+ async def shutdown(self, ) -> None:
+ """
+ Stop accepting new embedded operations. Repeated calls are harmless;
+ daemon compatibility clients do not own the daemon and therefore no-op.
+"""
raise NotImplementedError
def socket_path(self, ) -> str:
+ """
+ Compatibility accessor. Embedded runtimes have no socket and return an
+ empty string; new code should branch on [`Self::execution_mode`].
+"""
raise NotImplementedError
- def start_session(self, input: cua_driver._native_contract.StartSessionInput) -> cua_driver._native_contract.StartSessionOutput:
+ async def start_session(self, input: cua_driver._native_contract.StartSessionInput) -> cua_driver._native_contract.StartSessionOutput:
raise NotImplementedError
- def type_text(self, input: cua_driver._native_contract.TypeTextInput) -> ToolResult:
+ async def type_text(self, input: cua_driver._native_contract.TypeTextInput) -> ToolResult:
raise NotImplementedError
class CuaDriver(CuaDriverProtocol):
@@ -2557,7 +2687,7 @@ class CuaDriver(CuaDriverProtocol):
def connect(cls, socket_path: typing.Optional[str]) -> CuaDriver:
"""
Connect to the default installed daemon or an explicitly selected socket.
- Construction does not launch a process or perform I/O.
+ This is the temporary compatibility path for released socket clients.
"""
_UniffiFfiConverterOptionalString.check_lower(socket_path)
@@ -2594,6 +2724,47 @@ class CuaDriver(CuaDriverProtocol):
*_uniffi_lowered_args,
)
return cls._uniffi_make_instance(_uniffi_ffi_result)
+ @classmethod
+ def create(cls, options: typing.Optional[DriverOptions]) -> CuaDriver:
+ """
+ Create a same-process driver runtime. This constructor never launches
+ `cua-driver` and never opens daemon IPC.
+"""
+
+ _UniffiFfiConverterOptionalTypeDriverOptions.check_lower(options)
+ _uniffi_lowered_args = (
+ _UniffiFfiConverterOptionalTypeDriverOptions.lower(options),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeCuaDriver.lift
+ _uniffi_error_converter = _UniffiFfiConverterTypeDriverError
+ _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ _uniffi_error_converter,
+ _UniffiLib.uniffi_cua_driver_sdk_fn_constructor_cuadriver_create,
+ *_uniffi_lowered_args,
+ )
+ return cls._uniffi_make_instance(_uniffi_ffi_result)
+ @classmethod
+ def create_with_client_kind(cls, options: typing.Optional[DriverOptions],client_kind: SdkClientKind) -> CuaDriver:
+ """
+ Language-package entry point for the same-process runtime. The wrapper
+ at each package root selects the client kind automatically.
+"""
+
+ _UniffiFfiConverterOptionalTypeDriverOptions.check_lower(options)
+
+ _UniffiFfiConverterTypeSdkClientKind.check_lower(client_kind)
+ _uniffi_lowered_args = (
+ _UniffiFfiConverterOptionalTypeDriverOptions.lower(options),
+ _UniffiFfiConverterTypeSdkClientKind.lower(client_kind),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeCuaDriver.lift
+ _uniffi_error_converter = _UniffiFfiConverterTypeDriverError
+ _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ _uniffi_error_converter,
+ _UniffiLib.uniffi_cua_driver_sdk_fn_constructor_cuadriver_create_with_client_kind,
+ *_uniffi_lowered_args,
+ )
+ return cls._uniffi_make_instance(_uniffi_ffi_result)
def __init__(self, *args, **kwargs):
raise ValueError("This class has no default constructor")
@@ -2615,10 +2786,10 @@ class CuaDriver(CuaDriverProtocol):
inst = cls.__new__(cls)
inst._handle = handle
return inst
- def call_tool(self, name: str,arguments_json: str) -> ToolResult:
+ async def call_tool(self, name: str,arguments_json: str) -> ToolResult:
"""
- Escape hatch for forward-compatible tools and application-owned server
- adapters. Typed methods below serialize the same canonical Rust inputs.
+ Temporary compatibility escape hatch. New application code should use
+ the typed methods; MCP servers own generic discovery and invocation.
"""
_UniffiFfiConverterString.check_lower(name)
@@ -2631,13 +2802,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_call_tool(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_call_tool,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def click(self, input: cua_driver._native_contract.ClickInput) -> ToolResult:
+ async def click(self, input: cua_driver._native_contract.ClickInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypeClickInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2646,13 +2819,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_click(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_click,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def drag(self, input: cua_driver._native_contract.DragInput) -> ToolResult:
+ async def drag(self, input: cua_driver._native_contract.DragInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypeDragInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2661,13 +2836,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_drag(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_drag,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def end_session(self, input: cua_driver._native_contract.EndSessionInput) -> cua_driver._native_contract.EndSessionOutput:
+ async def end_session(self, input: cua_driver._native_contract.EndSessionInput) -> cua_driver._native_contract.EndSessionOutput:
cua_driver._native_contract._UniffiFfiConverterTypeEndSessionInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2676,13 +2853,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = cua_driver._native_contract._UniffiFfiConverterTypeEndSessionOutput.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_end_session(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_end_session,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def escalate_session(self, input: cua_driver._native_contract.EscalateSessionInput) -> cua_driver._native_contract.SessionStateOutput:
+ async def escalate_session(self, input: cua_driver._native_contract.EscalateSessionInput) -> cua_driver._native_contract.SessionStateOutput:
cua_driver._native_contract._UniffiFfiConverterTypeEscalateSessionInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2691,13 +2870,27 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = cua_driver._native_contract._UniffiFfiConverterTypeSessionStateOutput.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_escalate_session(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
+ _uniffi_error_converter,
+ )
+ def execution_mode(self, ) -> DriverExecutionMode:
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeDriverExecutionMode.lift
+ _uniffi_error_converter = None
_uniffi_ffi_result = _uniffi_rust_call_with_error(
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_escalate_session,
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_execution_mode,
*_uniffi_lowered_args,
)
return _uniffi_lift_return(_uniffi_ffi_result)
- def get_cursor_position(self, input: cua_driver._native_contract.GetCursorPositionInput) -> ToolResult:
+ async def get_cursor_position(self, input: cua_driver._native_contract.GetCursorPositionInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypeGetCursorPositionInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2706,13 +2899,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_cursor_position(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_cursor_position,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def get_desktop_state(self, input: cua_driver._native_contract.GetDesktopStateInput) -> ToolResult:
+ async def get_desktop_state(self, input: cua_driver._native_contract.GetDesktopStateInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypeGetDesktopStateInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2721,13 +2916,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_desktop_state(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_desktop_state,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def get_screen_size(self, input: cua_driver._native_contract.GetScreenSizeInput) -> ToolResult:
+ async def get_screen_size(self, input: cua_driver._native_contract.GetScreenSizeInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypeGetScreenSizeInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2736,13 +2933,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_screen_size(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_screen_size,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def get_session_state(self, input: cua_driver._native_contract.GetSessionStateInput) -> cua_driver._native_contract.SessionStateOutput:
+ async def get_session_state(self, input: cua_driver._native_contract.GetSessionStateInput) -> cua_driver._native_contract.SessionStateOutput:
cua_driver._native_contract._UniffiFfiConverterTypeGetSessionStateInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2751,13 +2950,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = cua_driver._native_contract._UniffiFfiConverterTypeSessionStateOutput.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_session_state(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_get_session_state,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def hotkey(self, input: cua_driver._native_contract.HotkeyInput) -> ToolResult:
+ async def hotkey(self, input: cua_driver._native_contract.HotkeyInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypeHotkeyInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2766,12 +2967,14 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_hotkey(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_hotkey,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
def is_available(self, ) -> bool:
_uniffi_lowered_args = (
self._uniffi_clone_handle(),
@@ -2784,31 +2987,39 @@ class CuaDriver(CuaDriverProtocol):
*_uniffi_lowered_args,
)
return _uniffi_lift_return(_uniffi_ffi_result)
- def list_tools_json(self, ) -> str:
+ async def list_tools_json(self, ) -> str:
+ """
+ Temporary compatibility discovery surface for adapters migrating to
+ the typed SDK contract.
+"""
_uniffi_lowered_args = (
self._uniffi_clone_handle(),
)
_uniffi_lift_return = _UniffiFfiConverterString.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_list_tools_json(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_list_tools_json,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def metadata(self, ) -> DriverMetadata:
+ async def metadata(self, ) -> DriverMetadata:
_uniffi_lowered_args = (
self._uniffi_clone_handle(),
)
_uniffi_lift_return = _UniffiFfiConverterTypeDriverMetadata.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_metadata(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_metadata,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def move_cursor(self, input: cua_driver._native_contract.MoveCursorInput) -> ToolResult:
+ async def move_cursor(self, input: cua_driver._native_contract.MoveCursorInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypeMoveCursorInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2817,13 +3028,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_move_cursor(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_move_cursor,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def press_key(self, input: cua_driver._native_contract.PressKeyInput) -> ToolResult:
+ async def press_key(self, input: cua_driver._native_contract.PressKeyInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypePressKeyInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2832,13 +3045,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_press_key(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_press_key,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def scroll(self, input: cua_driver._native_contract.ScrollInput) -> ToolResult:
+ async def scroll(self, input: cua_driver._native_contract.ScrollInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypeScrollInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2847,13 +3062,37 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_scroll(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
+ _uniffi_error_converter,
+ )
+ async def shutdown(self, ) -> None:
+ """
+ Stop accepting new embedded operations. Repeated calls are harmless;
+ daemon compatibility clients do not own the daemon and therefore no-op.
+"""
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ )
+ _uniffi_lift_return = lambda val: None
+ _uniffi_error_converter = _UniffiFfiConverterTypeDriverError
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_shutdown(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_void,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_void,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_void,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_scroll,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
def socket_path(self, ) -> str:
+ """
+ Compatibility accessor. Embedded runtimes have no socket and return an
+ empty string; new code should branch on [`Self::execution_mode`].
+"""
_uniffi_lowered_args = (
self._uniffi_clone_handle(),
)
@@ -2865,7 +3104,7 @@ class CuaDriver(CuaDriverProtocol):
*_uniffi_lowered_args,
)
return _uniffi_lift_return(_uniffi_ffi_result)
- def start_session(self, input: cua_driver._native_contract.StartSessionInput) -> cua_driver._native_contract.StartSessionOutput:
+ async def start_session(self, input: cua_driver._native_contract.StartSessionInput) -> cua_driver._native_contract.StartSessionOutput:
cua_driver._native_contract._UniffiFfiConverterTypeStartSessionInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2874,13 +3113,15 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = cua_driver._native_contract._UniffiFfiConverterTypeStartSessionOutput.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_start_session(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_start_session,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
- def type_text(self, input: cua_driver._native_contract.TypeTextInput) -> ToolResult:
+ async def type_text(self, input: cua_driver._native_contract.TypeTextInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypeTypeTextInput.check_lower(input)
_uniffi_lowered_args = (
@@ -2889,12 +3130,14 @@ class CuaDriver(CuaDriverProtocol):
)
_uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
_uniffi_error_converter = _UniffiFfiConverterTypeDriverError
- _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_type_text(*_uniffi_lowered_args),
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ _UniffiLib.ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ _uniffi_lift_return,
_uniffi_error_converter,
- _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_type_text,
- *_uniffi_lowered_args,
)
- return _uniffi_lift_return(_uniffi_ffi_result)
@@ -3144,6 +3387,31 @@ class _UniffiFfiConverterUInt8(_UniffiConverterPrimitiveInt):
@staticmethod
def write(value, buf):
buf.write_u8(value)
+
+class _UniffiFfiConverterOptionalTypeDriverOptions(_UniffiConverterRustBuffer):
+ @classmethod
+ def check_lower(cls, value):
+ if value is not None:
+ _UniffiFfiConverterTypeDriverOptions.check_lower(value)
+
+ @classmethod
+ def write(cls, value, buf):
+ if value is None:
+ buf.write_u8(0)
+ return
+
+ buf.write_u8(1)
+ _UniffiFfiConverterTypeDriverOptions.write(value, buf)
+
+ @classmethod
+ def read(cls, buf):
+ flag = buf.read_u8()
+ if flag == 0:
+ return None
+ elif flag == 1:
+ return _UniffiFfiConverterTypeDriverOptions.read(buf)
+ else:
+ raise InternalError("Unexpected flag byte for optional type")
def current_mac_os_permission_status() -> MacOsPermissionStatus:
_uniffi_lowered_args = (
)
@@ -3182,10 +3450,12 @@ __all__ = [
"InternalError",
"EmbeddedPermissionMode",
"DriverError",
+ "DriverExecutionMode",
"EmbeddedDriverError",
"EmbeddedDriverHostState",
"SdkClientKind",
"DriverMetadata",
+ "DriverOptions",
"EmbeddedEnvironmentVariable",
"EmbeddedMcpConfiguration",
"EmbeddedDriverConnection",
diff --git a/libs/cua-driver/python/tests/test_uniffi_loader.py b/libs/cua-driver/python/tests/test_uniffi_loader.py
index b3675c83e6..952e6e11fc 100644
--- a/libs/cua-driver/python/tests/test_uniffi_loader.py
+++ b/libs/cua-driver/python/tests/test_uniffi_loader.py
@@ -85,14 +85,14 @@ except FileNotFoundError:
)
connection = await host.start()
driver = CuaDriver.connect(connection.socket_path)
- metadata = driver.metadata()
+ metadata = await driver.metadata()
self.assertTrue(metadata.embedded)
self.assertEqual(metadata.pid, connection.pid)
self.assertEqual(
metadata.host_bundle_id, "com.example.python-embedded"
)
self.assertEqual(
- json.loads(driver.list_tools_json()),
+ json.loads(await driver.list_tools_json()),
{"tools": [{"name": "embedded_fixture"}]},
)
await host.stop()
@@ -167,8 +167,12 @@ except FileNotFoundError:
"hotkey",
}
self.assertTrue(all(hasattr(driver, name) for name in expected_methods))
- result = driver.get_desktop_state(
- GetDesktopStateInput(session="python-run", screenshot_out_file=None)
+ result = asyncio.run(
+ driver.get_desktop_state(
+ GetDesktopStateInput(
+ session="python-run", screenshot_out_file=None
+ )
+ )
)
server.join(timeout=5)
listener.close()
@@ -180,6 +184,22 @@ except FileNotFoundError:
self.assertEqual(captured[0]["args"], {"session": "python-run"})
self.assertEqual(captured[0]["client_kind"], "python_sdk")
+ def test_generated_python_sdk_can_own_the_runtime_in_process(self) -> None:
+ from cua_driver import CuaDriver, DriverExecutionMode
+
+ async def scenario() -> None:
+ driver = CuaDriver.create()
+ self.assertEqual(driver.execution_mode(), DriverExecutionMode.EMBEDDED)
+ self.assertEqual(driver.socket_path(), "")
+ self.assertTrue(driver.is_available())
+ metadata = await driver.metadata()
+ self.assertTrue(metadata.embedded)
+ self.assertEqual(metadata.pid, os.getpid())
+ await driver.shutdown()
+ self.assertFalse(driver.is_available())
+
+ asyncio.run(scenario())
+
if os.environ.get("CUA_DRIVER_REQUIRE_UNIFFI") == "1" and not LIBRARY.exists():
raise RuntimeError(f"required staged UniFFI library is missing: {LIBRARY}")
diff --git a/libs/cua-driver/rust/Cargo.lock b/libs/cua-driver/rust/Cargo.lock
index 3d5b30fb62..5fe987a8c2 100644
--- a/libs/cua-driver/rust/Cargo.lock
+++ b/libs/cua-driver/rust/Cargo.lock
@@ -945,11 +945,16 @@ dependencies = [
"core-foundation",
"cua-driver-contract",
"cua-driver-core",
+ "cursor-overlay",
+ "platform-linux",
+ "platform-macos",
+ "platform-windows",
"serde",
"serde_json",
"tempfile",
"thiserror 1.0.69",
"tokio",
+ "tracing",
"uniffi",
"uuid",
]
diff --git a/libs/cua-driver/rust/Skills/cua-driver/EMBEDDING.md b/libs/cua-driver/rust/Skills/cua-driver/EMBEDDING.md
index f975b6f5c3..3dbe96780c 100644
--- a/libs/cua-driver/rust/Skills/cua-driver/EMBEDDING.md
+++ b/libs/cua-driver/rust/Skills/cua-driver/EMBEDDING.md
@@ -1,4 +1,4 @@
-# Embedding cua-driver in your agent harness without introducing new permissions
+# Embedding cua-driver in your application without introducing new permissions
This guide is for teams shipping a macOS app (an "agent harness") that wants
cua-driver's background computer-use and agent-cursor overlay **inside their
@@ -6,7 +6,7 @@ own app**, without shipping a second app bundle and without their users ever
seeing a second macOS permission prompt. Your app requests Accessibility and
Screen Recording once; the embedded driver inherits those grants.
-A working reference host lives in the cua repo at
+A working daemon-host reference lives in the cua repo at
`libs/cua-driver/rust/examples/embedded-host-macos/`
(https://github.com/trycua/cua). This doc ships standalone in the skill
pack, so the path is given rather than a relative link.
@@ -40,7 +40,30 @@ non-sandboxed host, which is typical for agent harnesses; a sandboxed host
spawning a non-sandboxed helper raises separate App Sandbox questions that
embedded mode does not address.
-## Launching in embedded mode
+## Preferred application SDK: same-process runtime
+
+Python and TypeScript applications should normally import the packaged SDK and
+create `CuaDriver` directly. This path does not start an executable or open a
+socket, and TCC checks execute as the importing application:
+
+```ts
+import { CuaDriver } from '@trycua/cua-driver';
+
+const driver = CuaDriver.create(undefined);
+try {
+ const metadata = await driver.metadata();
+ // Invoke typed driver operations here.
+} finally {
+ await driver.shutdown();
+ driver.uniffiDestroy();
+}
+```
+
+Use the daemon-backed host below only when the application must also provide a
+stable MCP endpoint to an external agent, coordinate external clients, or keep
+the automation runtime isolated from the application process.
+
+## Launching the daemon-backed host
```sh
# env var form — set by the host on the child process
@@ -99,7 +122,7 @@ selects unrestricted mode and records the acknowledgement. The older
`autonomous` mode name remains accepted as an alias for `bounded` during
migration.
-### Node and Electron hosts
+### Node and Electron daemon hosts
Use the embedded host in `@trycua/cua-driver` instead of implementing process
and socket management in every host. It starts a private daemon directly, waits
diff --git a/libs/cua-driver/rust/crates/cua-driver-sdk/Cargo.toml b/libs/cua-driver/rust/crates/cua-driver-sdk/Cargo.toml
index 51cc8b181a..68c40d18a1 100644
--- a/libs/cua-driver/rust/crates/cua-driver-sdk/Cargo.toml
+++ b/libs/cua-driver/rust/crates/cua-driver-sdk/Cargo.toml
@@ -5,7 +5,7 @@ edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
-description = "UniFFI-backed imported SDK for the Cua Driver daemon"
+description = "Canonical typed SDK and UniFFI boundary for Cua Driver"
publish = false
[lib]
@@ -18,12 +18,27 @@ serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
+tracing = { workspace = true }
uniffi = { workspace = true, features = ["tokio"] }
uuid = { workspace = true }
+cursor-overlay = { path = "../cursor-overlay" }
[target.'cfg(target_os = "macos")'.dependencies]
+platform-macos = { path = "../platform-macos" }
core-foundation = "0.10"
+[target.'cfg(target_os = "windows")'.dependencies]
+platform-windows = { path = "../platform-windows" }
+
+[target.'cfg(target_os = "linux")'.dependencies]
+platform-linux = { path = "../platform-linux" }
+
+[features]
+default = []
+portal-input = ["platform-linux/portal-input"]
+portal-capture = ["platform-linux/portal-capture"]
+portal-libei = ["portal-input", "portal-capture"]
+
[dev-dependencies]
tempfile = "3"
uniffi = { workspace = true, features = ["bindgen"] }
diff --git a/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs b/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs
index 451e4b1927..520ce8d4ef 100644
--- a/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-sdk/src/lib.rs
@@ -1,9 +1,9 @@
-//! Canonical Rust implementation for imported Cua Driver SDKs.
+//! Canonical typed Cua Driver SDK and UniFFI export boundary.
//!
-//! This library intentionally talks to the existing daemon rather than
-//! embedding the platform automation engine. Python and Node bindings therefore
-//! share one implementation while retaining the daemon's permission ownership,
-//! session state, policy enforcement, and platform event-loop constraints.
+//! [`CuaDriver::create`] owns the platform runtime in the importing process.
+//! [`CuaDriver::connect`] remains a temporary compatibility constructor for the
+//! released daemon-client topology. Both paths expose the same typed operations;
+//! MCP and daemon transports are downstream adapters rather than peer contracts.
use cua_driver_contract::{
ClickInput, DragInput, EndSessionInput, EndSessionOutput, EscalateSessionInput,
@@ -21,7 +21,9 @@ use std::sync::Arc;
use thiserror::Error;
mod embedded;
+mod runtime;
pub use embedded::*;
+use runtime::{DriverRuntime, RuntimeOptions};
#[derive(Debug, Clone, PartialEq, Eq, uniffi::Record)]
pub struct ImageContent {
@@ -188,14 +190,55 @@ pub enum DriverError {
message: String,
error_code: String,
},
+ #[error("the Cua Driver SDK has been shut down")]
+ Shutdown,
}
#[derive(uniffi::Object)]
pub struct CuaDriver {
- socket_path: String,
+ backend: DriverBackend,
client_kind: DaemonClientKind,
}
+enum DriverBackend {
+ Embedded(Arc<DriverRuntime>),
+ Daemon { socket_path: String },
+}
+
+/// Process topology used by this SDK object.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Enum)]
+pub enum DriverExecutionMode {
+ Embedded,
+ Daemon,
+}
+
+/// Options for a same-process Cua Driver SDK runtime.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Record)]
+pub struct DriverOptions {
+ /// Preserve the temporary reduced screenshot surface used by older Claude
+ /// Code integrations. New applications should leave this false.
+ pub claude_code_compatibility: bool,
+}
+
+impl Default for DriverOptions {
+ fn default() -> Self {
+ Self {
+ claude_code_compatibility: false,
+ }
+ }
+}
+
+/// Rust-only host configuration used by the standalone daemon. Language
+/// bindings intentionally receive the smaller [`DriverOptions`] record.
+pub struct DriverHostOptions {
+ pub cursor: cursor_overlay::CursorConfig,
+ pub claude_code_compatibility: bool,
+ pub prepare_desktop_environment: bool,
+ /// Temporary compatibility hook for daemon-only administrative tools.
+ /// Desktop operations must live behind the typed SDK contract instead.
+ pub register_host_tools: Option<fn(&mut cua_driver_core::tool::ToolRegistry)>,
+}
+
/// Runtime that imported the shared UniFFI SDK library. The language package
/// selects this automatically at its root entry point; callers do not need to
/// supply telemetry metadata.
@@ -233,11 +276,11 @@ macro_rules! desktop_tool_methods {
macro_rules! define_desktop_tool_methods {
($($method:ident: $input:ty,)*) => {
- #[uniffi::export]
+ #[uniffi::export(async_runtime = "tokio")]
impl CuaDriver {
$(
- pub fn $method(&self, input: $input) -> Result<ToolResult, DriverError> {
- self.invoke_typed(<$input as ToolInput>::TOOL_NAME, input)
+ pub async fn $method(&self, input: $input) -> Result<ToolResult, DriverError> {
+ self.invoke_typed(<$input as ToolInput>::TOOL_NAME, input).await
}
)*
}
@@ -261,8 +304,38 @@ desktop_tool_methods!(define_exported_tool_names);
#[uniffi::export]
impl CuaDriver {
+ /// Create a same-process driver runtime. This constructor never launches
+ /// `cua-driver` and never opens daemon IPC.
+ #[uniffi::constructor]
+ pub fn create(options: Option<DriverOptions>) -> Result<Arc<Self>, DriverError> {
+ let options = options.unwrap_or_default();
+ Ok(Arc::new(Self {
+ backend: DriverBackend::Embedded(Arc::new(DriverRuntime::create(
+ RuntimeOptions::embedded(options.claude_code_compatibility),
+ ))),
+ client_kind: DaemonClientKind::Unknown,
+ }))
+ }
+
+ /// Language-package entry point for the same-process runtime. The wrapper
+ /// at each package root selects the client kind automatically.
+ #[uniffi::constructor]
+ pub fn create_with_client_kind(
+ options: Option<DriverOptions>,
+ client_kind: SdkClientKind,
+ ) -> Result<Arc<Self>, DriverError> {
+ let driver = Self::create(options)?;
+ let DriverBackend::Embedded(runtime) = &driver.backend else {
+ unreachable!("create always returns an embedded runtime")
+ };
+ Ok(Arc::new(Self {
+ backend: DriverBackend::Embedded(runtime.clone()),
+ client_kind: client_kind.into(),
+ }))
+ }
+
/// Connect to the default installed daemon or an explicitly selected socket.
- /// Construction does not launch a process or perform I/O.
+ /// This is the temporary compatibility path for released socket clients.
#[uniffi::constructor]
pub fn connect(socket_path: Option<String>) -> Result<Arc<Self>, DriverError> {
let socket_path = socket_path.unwrap_or_else(|| socket_path_for_namespace("cua-driver"));
@@ -272,7 +345,7 @@ impl CuaDriver {
});
}
Ok(Arc::new(Self {
- socket_path,
+ backend: DriverBackend::Daemon { socket_path },
client_kind: DaemonClientKind::Unknown,
}))
}
@@ -285,154 +358,288 @@ impl CuaDriver {
client_kind: SdkClientKind,
) -> Result<Arc<Self>, DriverError> {
let driver = Self::connect(socket_path)?;
+ let DriverBackend::Daemon { socket_path } = &driver.backend else {
+ unreachable!("connect always returns a daemon client")
+ };
Ok(Arc::new(Self {
- socket_path: driver.socket_path.clone(),
+ backend: DriverBackend::Daemon {
+ socket_path: socket_path.clone(),
+ },
client_kind: client_kind.into(),
}))
}
+ pub fn execution_mode(&self) -> DriverExecutionMode {
+ match &self.backend {
+ DriverBackend::Embedded(_) => DriverExecutionMode::Embedded,
+ DriverBackend::Daemon { .. } => DriverExecutionMode::Daemon,
+ }
+ }
+
+ /// Compatibility accessor. Embedded runtimes have no socket and return an
+ /// empty string; new code should branch on [`Self::execution_mode`].
pub fn socket_path(&self) -> String {
- self.socket_path.clone()
+ match &self.backend {
+ DriverBackend::Embedded(_) => String::new(),
+ DriverBackend::Daemon { socket_path } => socket_path.clone(),
+ }
}
pub fn is_available(&self) -> bool {
- is_daemon_listening(&self.socket_path)
+ match &self.backend {
+ DriverBackend::Embedded(runtime) => runtime.is_running(),
+ DriverBackend::Daemon { socket_path } => is_daemon_listening(socket_path),
+ }
}
+}
- pub fn metadata(&self) -> Result<DriverMetadata, DriverError> {
- let metadata =
- request_daemon_metadata(&self.socket_path).map_err(|error| DriverError::Transport {
- socket_path: self.socket_path.clone(),
- reason: error.to_string(),
- })?;
- Ok(DriverMetadata {
- driver_version: metadata.driver_version,
- contract_version: metadata.contract_version,
- tools_list_schema_version: metadata.tools_list_schema_version,
- capability_version: metadata.capability_version,
- mcp_protocol_version: metadata.mcp_protocol_version,
- pid: metadata.pid,
- embedded: metadata.embedded,
- host_bundle_id: metadata.host_bundle_id,
+impl CuaDriver {
+ /// Construct the same SDK-owned runtime for the standalone daemon host.
+ /// This Rust-only entry point keeps CLI presentation options out of the
+ /// generated language contract.
+ pub fn create_for_host(options: DriverHostOptions) -> Arc<Self> {
+ Arc::new(Self {
+ backend: DriverBackend::Embedded(Arc::new(DriverRuntime::create(RuntimeOptions {
+ cursor: options.cursor,
+ compatibility_mode: options.claude_code_compatibility,
+ prepare_desktop_environment: options.prepare_desktop_environment,
+ register_host_tools: options.register_host_tools,
+ }))),
+ client_kind: DaemonClientKind::Unknown,
})
}
- /// Escape hatch for forward-compatible tools and application-owned server
- /// adapters. Typed methods below serialize the same canonical Rust inputs.
- pub fn call_tool(
+ /// Transitional adapter for the released private daemon protocol and the
+ /// current MCP host. It is intentionally not exported through UniFFI and
+ /// will disappear when the official MCP adapter owns generic dispatch.
+ #[doc(hidden)]
+ pub fn compatibility_registry(&self) -> Option<Arc<cua_driver_core::tool::ToolRegistry>> {
+ match &self.backend {
+ DriverBackend::Embedded(runtime) => Some(runtime.registry()),
+ DriverBackend::Daemon { .. } => None,
+ }
+ }
+}
+
+#[uniffi::export(async_runtime = "tokio")]
+impl CuaDriver {
+ pub async fn metadata(&self) -> Result<DriverMetadata, DriverError> {
+ match &self.backend {
+ DriverBackend::Embedded(runtime) => {
+ if !runtime.is_running() {
+ return Err(DriverError::Shutdown);
+ }
+ Ok(DriverMetadata {
+ driver_version: env!("CARGO_PKG_VERSION").into(),
+ contract_version: cua_driver_contract::CONTRACT_VERSION.into(),
+ tools_list_schema_version: cua_driver_contract::TOOLS_LIST_SCHEMA_VERSION
+ .into(),
+ capability_version: cua_driver_contract::CAPABILITY_VERSION.into(),
+ mcp_protocol_version: cua_driver_contract::MCP_PROTOCOL_VERSION.into(),
+ pid: std::process::id(),
+ embedded: true,
+ host_bundle_id: None,
+ })
+ }
+ DriverBackend::Daemon { socket_path } => {
+ let socket_path = socket_path.clone();
+ let request_path = socket_path.clone();
+ let metadata =
+ tokio::task::spawn_blocking(move || request_daemon_metadata(&request_path))
+ .await
+ .map_err(|error| DriverError::Protocol {
+ reason: format!("metadata task failed: {error}"),
+ })?
+ .map_err(|error| DriverError::Transport {
+ socket_path,
+ reason: error.to_string(),
+ })?;
+ Ok(DriverMetadata {
+ driver_version: metadata.driver_version,
+ contract_version: metadata.contract_version,
+ tools_list_schema_version: metadata.tools_list_schema_version,
+ capability_version: metadata.capability_version,
+ mcp_protocol_version: metadata.mcp_protocol_version,
+ pid: metadata.pid,
+ embedded: metadata.embedded,
+ host_bundle_id: metadata.host_bundle_id,
+ })
+ }
+ }
+ }
+
+ /// Temporary compatibility escape hatch. New application code should use
+ /// the typed methods; MCP servers own generic discovery and invocation.
+ pub async fn call_tool(
&self,
name: String,
arguments_json: String,
) -> Result<ToolResult, DriverError> {
let arguments = parse_arguments(&name, &arguments_json)?;
- self.invoke(&name, arguments)
+ self.invoke(&name, arguments).await
}
- pub fn list_tools_json(&self) -> Result<String, DriverError> {
- let request = DaemonRequest {
- method: "list".into(),
- name: None,
- args: None,
- session_id: None,
- observation_origin: Some(ToolObservationOrigin::Direct),
- client_kind: Some(self.client_kind),
- };
- let response =
- send_request(&self.socket_path, &request).map_err(|error| DriverError::Transport {
- socket_path: self.socket_path.clone(),
- reason: error.to_string(),
- })?;
- if !response.ok {
- return Err(DriverError::Protocol {
- reason: response
- .error
- .unwrap_or_else(|| "list request failed".into()),
- });
- }
- serde_json::to_string(&response.result.unwrap_or(Value::Null)).map_err(|error| {
- DriverError::Protocol {
- reason: error.to_string(),
+ /// Temporary compatibility discovery surface for adapters migrating to
+ /// the typed SDK contract.
+ pub async fn list_tools_json(&self) -> Result<String, DriverError> {
+ let result = match &self.backend {
+ DriverBackend::Embedded(runtime) => {
+ runtime.tools_list().ok_or(DriverError::Shutdown)?
+ }
+ DriverBackend::Daemon { socket_path } => {
+ let socket_path = socket_path.clone();
+ let request_path = socket_path.clone();
+ let request = DaemonRequest {
+ method: "list".into(),
+ name: None,
+ args: None,
+ session_id: None,
+ observation_origin: Some(ToolObservationOrigin::Direct),
+ client_kind: Some(self.client_kind),
+ };
+ let response =
+ tokio::task::spawn_blocking(move || send_request(&request_path, &request))
+ .await
+ .map_err(|error| DriverError::Protocol {
+ reason: format!("list task failed: {error}"),
+ })?
+ .map_err(|error| DriverError::Transport {
+ socket_path,
+ reason: error.to_string(),
+ })?;
+ if !response.ok {
+ return Err(DriverError::Protocol {
+ reason: response
+ .error
+ .unwrap_or_else(|| "list request failed".into()),
+ });
+ }
+ response.result.unwrap_or(Value::Null)
}
+ };
+ serde_json::to_string(&result).map_err(|error| DriverError::Protocol {
+ reason: error.to_string(),
})
}
- pub fn start_session(
+ pub async fn start_session(
&self,
input: StartSessionInput,
) -> Result<StartSessionOutput, DriverError> {
self.invoke_typed(StartSessionInput::TOOL_NAME, input)
- .and_then(|result| result.typed_success(StartSessionInput::TOOL_NAME))
+ .await?
+ .typed_success(StartSessionInput::TOOL_NAME)
}
- pub fn escalate_session(
+ pub async fn escalate_session(
&self,
input: EscalateSessionInput,
) -> Result<SessionStateOutput, DriverError> {
self.invoke_typed(EscalateSessionInput::TOOL_NAME, input)
- .and_then(|result| result.typed_success(EscalateSessionInput::TOOL_NAME))
+ .await?
+ .typed_success(EscalateSessionInput::TOOL_NAME)
}
- pub fn get_session_state(
+ pub async fn get_session_state(
&self,
input: GetSessionStateInput,
) -> Result<SessionStateOutput, DriverError> {
self.invoke_typed(GetSessionStateInput::TOOL_NAME, input)
- .and_then(|result| result.typed_success(GetSessionStateInput::TOOL_NAME))
+ .await?
+ .typed_success(GetSessionStateInput::TOOL_NAME)
}
- pub fn end_session(&self, input: EndSessionInput) -> Result<EndSessionOutput, DriverError> {
+ pub async fn end_session(
+ &self,
+ input: EndSessionInput,
+ ) -> Result<EndSessionOutput, DriverError> {
self.invoke_typed(EndSessionInput::TOOL_NAME, input)
- .and_then(|result| result.typed_success(EndSessionInput::TOOL_NAME))
+ .await?
+ .typed_success(EndSessionInput::TOOL_NAME)
+ }
+
+ /// Stop accepting new embedded operations. Repeated calls are harmless;
+ /// daemon compatibility clients do not own the daemon and therefore no-op.
+ pub async fn shutdown(&self) -> Result<(), DriverError> {
+ if let DriverBackend::Embedded(runtime) = &self.backend {
+ runtime.shutdown().await;
+ }
+ Ok(())
}
}
desktop_tool_methods!(define_desktop_tool_methods);
impl CuaDriver {
- fn invoke_typed<T: Serialize>(&self, name: &str, input: T) -> Result<ToolResult, DriverError> {
+ async fn invoke_typed<T: Serialize>(
+ &self,
+ name: &str,
+ input: T,
+ ) -> Result<ToolResult, DriverError> {
let arguments =
serde_json::to_value(input).map_err(|error| DriverError::InvalidArguments {
tool: name.into(),
reason: error.to_string(),
})?;
- self.invoke(name, arguments)
+ self.invoke(name, arguments).await
}
- fn invoke(&self, name: &str, arguments: Value) -> Result<ToolResult, DriverError> {
+ async fn invoke(&self, name: &str, arguments: Value) -> Result<ToolResult, DriverError> {
if !arguments.is_object() {
return Err(DriverError::InvalidArguments {
tool: name.into(),
reason: "arguments must be a JSON object".into(),
});
}
- let request = DaemonRequest {
- method: "call".into(),
- name: Some(name.into()),
- args: Some(arguments),
- session_id: None,
- observation_origin: Some(ToolObservationOrigin::Direct),
- client_kind: Some(self.client_kind),
+ let raw = match &self.backend {
+ DriverBackend::Embedded(runtime) => {
+ let result = runtime
+ .invoke(name, arguments)
+ .await
+ .ok_or(DriverError::Shutdown)?;
+ serde_json::to_value(result).map_err(|error| DriverError::Protocol {
+ reason: format!("serialize {name} result: {error}"),
+ })?
+ }
+ DriverBackend::Daemon { socket_path } => {
+ let socket_path = socket_path.clone();
+ let request_path = socket_path.clone();
+ let request = DaemonRequest {
+ method: "call".into(),
+ name: Some(name.into()),
+ args: Some(arguments),
+ session_id: None,
+ observation_origin: Some(ToolObservationOrigin::Direct),
+ client_kind: Some(self.client_kind),
+ };
+ let response =
+ tokio::task::spawn_blocking(move || send_request(&request_path, &request))
+ .await
+ .map_err(|error| DriverError::Protocol {
+ reason: format!("{name} transport task failed: {error}"),
+ })?
+ .map_err(|error| DriverError::Transport {
+ socket_path,
+ reason: error.to_string(),
+ })?;
+ if !response.ok {
+ return Err(DriverError::Tool {
+ tool: name.into(),
+ message: response
+ .error
+ .unwrap_or_else(|| "daemon rejected the request".into()),
+ error_code: response
+ .exit_code
+ .map(|code| code.to_string())
+ .unwrap_or_default(),
+ });
+ }
+ response.result.ok_or_else(|| DriverError::Protocol {
+ reason: format!("{name} response omitted result"),
+ })?
+ }
};
- let response =
- send_request(&self.socket_path, &request).map_err(|error| DriverError::Transport {
- socket_path: self.socket_path.clone(),
- reason: error.to_string(),
- })?;
- if !response.ok {
- return Err(DriverError::Tool {
- tool: name.into(),
- message: response
- .error
- .unwrap_or_else(|| "daemon rejected the request".into()),
- error_code: response
- .exit_code
- .map(|code| code.to_string())
- .unwrap_or_default(),
- });
- }
- normalize_result(response.result.ok_or_else(|| DriverError::Protocol {
- reason: format!("{name} response omitted result"),
- })?)
+ normalize_result(raw)
}
}
@@ -571,8 +778,38 @@ mod tests {
(directory, socket.to_string_lossy().into_owned(), handle)
}
- #[test]
- fn typed_desktop_call_serializes_contract_and_normalizes_result() {
+ #[tokio::test]
+ async fn embedded_runtime_owns_tools_without_daemon_ipc_and_shuts_down_idempotently() {
+ let driver = CuaDriver::create(None).unwrap();
+ assert_eq!(driver.execution_mode(), DriverExecutionMode::Embedded);
+ assert!(driver.socket_path().is_empty());
+ assert!(driver.is_available());
+
+ let metadata = driver.metadata().await.unwrap();
+ assert!(metadata.embedded);
+ assert_eq!(metadata.pid, std::process::id());
+ let listed: Value = serde_json::from_str(&driver.list_tools_json().await.unwrap()).unwrap();
+ let names = listed["tools"]
+ .as_array()
+ .unwrap()
+ .iter()
+ .filter_map(|tool| tool["name"].as_str())
+ .collect::<std::collections::BTreeSet<_>>();
+ for published in EXPORTED_TOOL_NAMES {
+ assert!(names.contains(published), "missing {published}");
+ }
+
+ driver.shutdown().await.unwrap();
+ driver.shutdown().await.unwrap();
+ assert!(!driver.is_available());
+ assert!(matches!(
+ driver.list_tools_json().await,
+ Err(DriverError::Shutdown)
+ ));
+ }
+
+ #[tokio::test]
+ async fn typed_desktop_call_serializes_contract_and_normalizes_result() {
let response = serde_json::json!({
"ok": true,
"result": {
@@ -592,6 +829,7 @@ mod tests {
session: Some("run-1".into()),
screenshot_out_file: None,
})
+ .await
.unwrap();
assert_eq!(result.text, "captured");
assert_eq!(result.images[0].mime_type, "image/png");
@@ -605,15 +843,15 @@ mod tests {
assert_eq!(request["client_kind"], "python_sdk");
}
- #[test]
- fn tool_discovery_uses_the_shared_direct_daemon_protocol() {
+ #[tokio::test]
+ async fn tool_discovery_uses_the_shared_direct_daemon_protocol() {
let response = serde_json::json!({
"ok": true,
"result": [{"name": "get_desktop_state"}]
});
let (_directory, socket, server) = serve_once(response);
let driver = CuaDriver::connect(Some(socket)).unwrap();
- let tools: Value = serde_json::from_str(&driver.list_tools_json().unwrap()).unwrap();
+ let tools: Value = serde_json::from_str(&driver.list_tools_json().await.unwrap()).unwrap();
assert_eq!(tools[0]["name"], "get_desktop_state");
let request = server.join().unwrap();
@@ -622,8 +860,8 @@ mod tests {
assert_eq!(request["client_kind"], "unknown");
}
- #[test]
- fn session_method_returns_the_canonical_typed_output() {
+ #[tokio::test]
+ async fn session_method_returns_the_canonical_typed_output() {
let response = serde_json::json!({
"ok": true,
"result": {
@@ -648,6 +886,7 @@ mod tests {
session: "run-2".into(),
capture_scope: Some(cua_driver_contract::CaptureScope::Auto),
})
+ .await
.unwrap();
assert!(output.active);
assert_eq!(output.state.session, "run-2");
diff --git a/libs/cua-driver/rust/crates/cua-driver-sdk/src/runtime.rs b/libs/cua-driver/rust/crates/cua-driver-sdk/src/runtime.rs
new file mode 100644
index 0000000000..cf5e9aa365
--- /dev/null
+++ b/libs/cua-driver/rust/crates/cua-driver-sdk/src/runtime.rs
@@ -0,0 +1,206 @@
+//! Private platform-runtime composition behind the public SDK boundary.
+//!
+//! This is deliberately not a second public interface. Both imported SDK
+//! objects and the daemon host construct the same runtime here; transport
+//! adapters are downstream consumers of `CuaDriver`.
+
+use cua_driver_core::{protocol::ToolResult as CoreToolResult, tool::ToolRegistry};
+use cursor_overlay::CursorConfig;
+use serde_json::Value;
+use std::sync::{
+ atomic::{AtomicBool, Ordering},
+ Arc,
+};
+
+#[derive(Debug, Clone)]
+pub(crate) struct RuntimeOptions {
+ pub cursor: CursorConfig,
+ pub compatibility_mode: bool,
+ #[cfg_attr(not(target_os = "linux"), allow(dead_code))]
+ pub prepare_desktop_environment: bool,
+ pub register_host_tools: Option<fn(&mut ToolRegistry)>,
+}
+
+impl RuntimeOptions {
+ pub(crate) fn embedded(compatibility_mode: bool) -> Self {
+ Self {
+ cursor: CursorConfig {
+ enabled: false,
+ ..CursorConfig::default()
+ },
+ compatibility_mode,
+ prepare_desktop_environment: true,
+ register_host_tools: None,
+ }
+ }
+}
+
+pub(crate) struct DriverRuntime {
+ registry: Arc<ToolRegistry>,
+ shutdown: AtomicBool,
+ /// Calls hold a read guard; shutdown takes the write guard after closing
+ /// admission. Therefore shutdown is idempotent and does not return while a
+ /// previously admitted operation is still executing.
+ lifecycle: tokio::sync::RwLock<()>,
+}
+
+impl DriverRuntime {
+ pub(crate) fn create(options: RuntimeOptions) -> Self {
+ let registry = Arc::new(build_registry(&options));
+ registry.init_self_weak();
+ Self {
+ registry,
+ shutdown: AtomicBool::new(false),
+ lifecycle: tokio::sync::RwLock::new(()),
+ }
+ }
+
+ pub(crate) fn is_running(&self) -> bool {
+ !self.shutdown.load(Ordering::Acquire)
+ }
+
+ pub(crate) async fn shutdown(&self) {
+ self.shutdown.store(true, Ordering::Release);
+ let _drained = self.lifecycle.write().await;
+ }
+
+ pub(crate) fn tools_list(&self) -> Option<Value> {
+ self.is_running().then(|| self.registry.tools_list())
+ }
+
+ pub(crate) async fn invoke(&self, name: &str, args: Value) -> Option<CoreToolResult> {
+ if !self.is_running() {
+ return None;
+ }
+ let _operation = self.lifecycle.read().await;
+ if !self.is_running() {
+ return None;
+ }
+ Some(self.registry.invoke(name, args).await)
+ }
+
+ pub(crate) fn registry(&self) -> Arc<ToolRegistry> {
+ self.registry.clone()
+ }
+}
+
+fn build_registry(options: &RuntimeOptions) -> ToolRegistry {
+ #[cfg(target_os = "macos")]
+ let mut registry = {
+ configure_macos_runtime();
+ platform_macos::register_tools_with_cursor(
+ options.cursor.clone(),
+ options.compatibility_mode,
+ )
+ };
+
+ #[cfg(target_os = "windows")]
+ let mut registry = {
+ configure_windows_runtime();
+ platform_windows::register_tools_with_cursor(
+ options.cursor.clone(),
+ options.compatibility_mode,
+ )
+ };
+
+ #[cfg(target_os = "linux")]
+ let mut registry = {
+ configure_linux_runtime(options.prepare_desktop_environment);
+ platform_linux::register_tools_with_cursor(
+ options.cursor.clone(),
+ options.compatibility_mode,
+ )
+ };
+
+ #[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "linux")))]
+ let mut registry = {
+ let _ = options;
+ ToolRegistry::new()
+ };
+
+ if let Some(register_host_tools) = options.register_host_tools {
+ register_host_tools(&mut registry);
+ }
+ registry
+}
+
+#[cfg(target_os = "macos")]
+fn configure_macos_runtime() {
+ cua_driver_core::recording::set_screenshot_fn(|window_id, pid| {
+ if let Some(window_id) = window_id {
+ platform_macos::capture::screenshot_window_bytes(window_id as u32).ok()
+ } else if let Some(pid) = pid {
+ platform_macos::windows::resolve_main_window_id(pid as i32)
+ .ok()
+ .and_then(|window_id| {
+ platform_macos::capture::screenshot_window_bytes(window_id).ok()
+ })
+ } else {
+ platform_macos::capture::screenshot_display_bytes().ok()
+ }
+ });
+ cua_driver_core::recording::set_click_marker_fn(|png_bytes, x, y| {
+ platform_macos::capture::crosshair_png_bytes(png_bytes, x, y).ok()
+ });
+ cua_driver_core::recording::set_ax_snapshot_fn(|window_id, pid| {
+ platform_macos::recording_hooks::app_state_json_for(window_id, pid)
+ });
+ cua_driver_core::recording::set_element_bounds_fn(|window_id, pid, index| {
+ platform_macos::recording_hooks::element_window_local_xy(window_id, pid, index)
+ });
+ cua_driver_core::video::set_video_backend_factory(Box::new(
+ platform_macos::video_sckit::SckitVideoBackendFactory,
+ ));
+}
+
+#[cfg(target_os = "windows")]
+fn configure_windows_runtime() {
+ cua_driver_core::recording::set_classified_screenshot_fn(|window_id, pid| {
+ platform_windows::recording_hooks::screenshot_for_recording(window_id, pid)
+ });
+ cua_driver_core::recording::set_click_marker_fn(|png_bytes, x, y| {
+ platform_windows::capture::crosshair_png_bytes(png_bytes, x, y).ok()
+ });
+ cua_driver_core::recording::set_ax_snapshot_fn(|window_id, pid| {
+ platform_windows::recording_hooks::app_state_json_for(window_id, pid)
+ });
+ cua_driver_core::recording::set_element_bounds_fn(|window_id, pid, index| {
+ platform_windows::recording_hooks::element_window_local_xy(window_id, pid, index)
+ });
+ cua_driver_core::video::set_video_backend_factory(Box::new(
+ cua_driver_core::video_ffmpeg::FfmpegVideoBackendFactory,
+ ));
+}
+
+#[cfg(target_os = "linux")]
+fn configure_linux_runtime(prepare_desktop_environment: bool) {
+ if prepare_desktop_environment {
+ platform_linux::xauth::ensure_xauthority_discovered();
+ platform_linux::session_bus::ensure_session_bus_discovered();
+ platform_linux::a11y::ensure_chromium_accessibility_enabled();
+ if let Err(error) = platform_linux::atspi::ensure_listener_active() {
+ tracing::warn!("could not activate the persistent AT-SPI listener: {error}");
+ }
+ }
+ cua_driver_core::recording::set_screenshot_fn(|window_id, pid| {
+ platform_linux::recording_hooks::screenshot_for_recording(window_id, pid)
+ });
+ cua_driver_core::recording::set_click_marker_fn(|png_bytes, x, y| {
+ platform_linux::capture::crosshair_png_bytes(png_bytes, x, y).ok()
+ });
+ cua_driver_core::recording::set_ax_snapshot_fn(|window_id, pid| {
+ platform_linux::recording_hooks::app_state_json_for(window_id, pid)
+ });
+ cua_driver_core::recording::set_element_bounds_fn(|window_id, pid, index| {
+ platform_linux::recording_hooks::element_window_local_xy(window_id, pid, index)
+ });
+ if platform_linux::wayland::is_wayland() {
+ cua_driver_core::video::set_video_backend_factory(Box::new(
+ platform_linux::video_wayland::WfRecorderVideoBackendFactory,
+ ));
+ } else {
+ cua_driver_core::video::set_video_backend_factory(Box::new(
+ cua_driver_core::video_ffmpeg::FfmpegVideoBackendFactory,
+ ));
+ }
+}
diff --git a/libs/cua-driver/rust/crates/cua-driver/Cargo.toml b/libs/cua-driver/rust/crates/cua-driver/Cargo.toml
index 10aed51c45..3fa4c61fe6 100644
--- a/libs/cua-driver/rust/crates/cua-driver/Cargo.toml
+++ b/libs/cua-driver/rust/crates/cua-driver/Cargo.toml
@@ -17,6 +17,7 @@ anyhow = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
cua-driver-core = { path = "../cua-driver-core" }
+cua-driver-sdk = { path = "../cua-driver-sdk" }
cursor-overlay = { path = "../cursor-overlay" }
pip-preview = { path = "../pip-preview" }
async-trait = "0.1"
@@ -73,7 +74,6 @@ embed-resource = "2"
# response accessors). Dev-only — never linked into the shipped driver.
cua-driver-testkit = { path = "../cua-driver-testkit" }
cua-driver-contract = { path = "../cua-driver-contract" }
-cua-driver-sdk = { path = "../cua-driver-sdk" }
tokio = { workspace = true, features = ["full"] }
image = { workspace = true }
base64 = { workspace = true }
diff --git a/libs/cua-driver/rust/crates/cua-driver/src/main.rs b/libs/cua-driver/rust/crates/cua-driver/src/main.rs
index 4e6eda2116..bd22974ce6 100644
--- a/libs/cua-driver/rust/crates/cua-driver/src/main.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/src/main.rs
@@ -243,24 +243,38 @@ fn maybe_init_pip() {
}
}
-// ── Registry helpers (macOS) ─────────────────────────────────────────────
+// ── Public SDK runtime host ──────────────────────────────────────────────
-/// Build the macOS tool registry and inject the platform-agnostic
-/// `check_for_update` tool. Wrapper lives in the binary crate so the
-/// `cua-driver-core` graph (shared with every `platform-*` crate) stays
-/// free of the `ureq` + rustls + ring deps that the check tool needs.
-#[cfg(target_os = "macos")]
-fn build_macos_registry() -> cua_driver_core::tool::ToolRegistry {
- let mut r = platform_macos::register_tools();
- check_update_tool::register_into(&mut r);
- r
+/// Construct the canonical SDK-owned runtime for the CLI or daemon host.
+/// The private socket and MCP layers consume this object downstream.
+fn build_driver(
+ cursor: cursor_overlay::CursorConfig,
+ compatibility_mode: bool,
+) -> Arc<cua_driver_sdk::CuaDriver> {
+ cua_driver_sdk::CuaDriver::create_for_host(cua_driver_sdk::DriverHostOptions {
+ cursor,
+ claude_code_compatibility: compatibility_mode,
+ prepare_desktop_environment: true,
+ register_host_tools: Some(check_update_tool::register_into),
+ })
}
-#[cfg(target_os = "macos")]
-fn build_macos_registry_with_compat(compat: bool) -> cua_driver_core::tool::ToolRegistry {
- let mut r = platform_macos::register_tools_with_compat(compat);
- check_update_tool::register_into(&mut r);
- r
+fn build_driver_without_cursor() -> Arc<cua_driver_sdk::CuaDriver> {
+ build_driver(
+ cursor_overlay::CursorConfig {
+ enabled: false,
+ ..cursor_overlay::CursorConfig::default()
+ },
+ false,
+ )
+}
+
+fn compatibility_registry(
+ driver: &Arc<cua_driver_sdk::CuaDriver>,
+) -> Arc<cua_driver_core::tool::ToolRegistry> {
+ driver
+ .compatibility_registry()
+ .expect("host driver must own a local runtime")
}
// ── macOS entry-point ─────────────────────────────────────────────────────
@@ -291,11 +305,11 @@ fn main() {
run_telemetry_command(command);
}
cli::Command::ListTools => {
- let reg = Arc::new(build_macos_registry());
+ let reg = compatibility_registry(&build_driver_without_cursor());
cli::run_list_tools(&reg);
}
cli::Command::Describe(name) => {
- let reg = Arc::new(build_macos_registry());
+ let reg = compatibility_registry(&build_driver_without_cursor());
cli::run_describe(&reg, &name);
}
cli::Command::McpConfig { client } => {
@@ -357,29 +371,6 @@ fn main() {
// before any blocking work so the banner can land on stderr
// early in the serve lifecycle.
version_check::maybe_announce_update();
- cua_driver_core::recording::set_screenshot_fn(|window_id, pid| {
- if let Some(wid) = window_id {
- platform_macos::capture::screenshot_window_bytes(wid as u32).ok()
- } else if let Some(p) = pid {
- platform_macos::windows::resolve_main_window_id(p as i32)
- .ok()
- .and_then(|wid| platform_macos::capture::screenshot_window_bytes(wid).ok())
- } else {
- platform_macos::capture::screenshot_display_bytes().ok()
- }
- });
- cua_driver_core::recording::set_click_marker_fn(|png_bytes, cx, cy| {
- platform_macos::capture::crosshair_png_bytes(png_bytes, cx, cy).ok()
- });
- cua_driver_core::recording::set_ax_snapshot_fn(|window_id, pid| {
- platform_macos::recording_hooks::app_state_json_for(window_id, pid)
- });
- cua_driver_core::recording::set_element_bounds_fn(|wid, pid, idx| {
- platform_macos::recording_hooks::element_window_local_xy(wid, pid, idx)
- });
- cua_driver_core::video::set_video_backend_factory(Box::new(
- platform_macos::video_sckit::SckitVideoBackendFactory,
- ));
let pip_cfg = match pip_preview::default_config_path() {
Some(p) => pip_preview::PipConfig::from_args_and_file(&p),
None => pip_preview::PipConfig::from_args(),
@@ -392,17 +383,13 @@ fn main() {
// owns every cursor command and window. Init the channel before spawning
// the serve thread so `run_on_main_thread()` always finds it ready.
let cursor_cfg = cursor_overlay::CursorConfig::from_args();
- if cursor_cfg.enabled {
- platform_macos::cursor::overlay::init(cursor_cfg.clone());
- }
// Honour the compat flag forwarded by the MCP proxy
// (launch_daemon_and_wait passes `serve
// --claude-code-computer-use-compat`). The Serve arm is the daemon
// the proxy talks to, so without this the proxy path always served
// the full screenshot tool regardless of the client's request.
- let reg = Arc::new(build_macos_registry_with_compat(claude_code_compat));
- reg.init_self_weak();
+ let driver = build_driver(cursor_cfg.clone(), claude_code_compat);
let sp = socket.unwrap_or_else(serve::default_socket_path);
let pid_path = serve::default_pid_file_path();
@@ -430,7 +417,7 @@ fn main() {
let serve_handle = std::thread::Builder::new()
.name("cua-serve".into())
.spawn(move || {
- serve::run_serve_cmd(reg, &sp, Some(&pid_path));
+ serve::run_serve_cmd(driver, &sp, Some(&pid_path));
std::process::exit(0);
})
.expect("spawn serve thread");
@@ -534,7 +521,7 @@ fn main() {
cli::run_recording_cmd(&subcommand, &args, socket.as_deref());
}
cli::Command::DumpDocs { pretty, doc_type } => {
- let reg = Arc::new(build_macos_registry());
+ let reg = compatibility_registry(&build_driver_without_cursor());
cli::run_dump_docs_with_type(&reg, pretty, &doc_type);
}
cli::Command::Update { apply, json } => {
@@ -652,12 +639,12 @@ fn main() -> anyhow::Result<()> {
return Ok(());
}
cli::Command::ListTools => {
- let reg = Arc::new(build_registry_no_cursor());
+ let reg = compatibility_registry(&build_driver_without_cursor());
cli::run_list_tools(&reg);
return Ok(());
}
cli::Command::Describe(name) => {
- let reg = Arc::new(build_registry_no_cursor());
+ let reg = compatibility_registry(&build_driver_without_cursor());
cli::run_describe(&reg, &name);
return Ok(());
}
@@ -712,14 +699,13 @@ fn main() -> anyhow::Result<()> {
let _ = no_permissions_gate;
// Serve mode needs the cursor overlay just like MCP mode.
let cursor_cfg = cursor_overlay::CursorConfig::from_args();
- let reg = Arc::new(build_registry(cursor_cfg, claude_code_compat));
- reg.init_self_weak();
+ let driver = build_driver(cursor_cfg, claude_code_compat);
maybe_init_pip();
let sp = socket.unwrap_or_else(serve::default_socket_path);
let pid_path = serve::default_pid_file_path();
// run_serve_cmd builds its own runtime; must run on a fresh thread.
std::thread::spawn(move || {
- serve::run_serve_cmd(reg, &sp, Some(&pid_path));
+ serve::run_serve_cmd(driver, &sp, Some(&pid_path));
})
.join()
.ok();
@@ -754,7 +740,7 @@ fn main() -> anyhow::Result<()> {
return Ok(());
}
cli::Command::DumpDocs { pretty, doc_type } => {
- let reg = Arc::new(build_registry_no_cursor());
+ let reg = compatibility_registry(&build_driver_without_cursor());
cli::run_dump_docs_with_type(&reg, pretty, &doc_type);
return Ok(());
}
@@ -851,203 +837,3 @@ fn main() -> anyhow::Result<()> {
}
}
}
-
-// ── Registry builder (non-macOS) ──────────────────────────────────────────
-
-#[cfg(not(target_os = "macos"))]
-fn build_registry(
- cursor_cfg: cursor_overlay::CursorConfig,
- compat: bool,
-) -> cua_driver_core::tool::ToolRegistry {
- #[cfg(target_os = "windows")]
- {
- cua_driver_core::recording::set_classified_screenshot_fn(|window_id, pid| {
- platform_windows::recording_hooks::screenshot_for_recording(window_id, pid)
- });
- cua_driver_core::recording::set_click_marker_fn(|png_bytes, cx, cy| {
- platform_windows::capture::crosshair_png_bytes(png_bytes, cx, cy).ok()
- });
- cua_driver_core::recording::set_ax_snapshot_fn(|window_id, pid| {
- platform_windows::recording_hooks::app_state_json_for(window_id, pid)
- });
- cua_driver_core::recording::set_element_bounds_fn(|wid, pid, idx| {
- platform_windows::recording_hooks::element_window_local_xy(wid, pid, idx)
- });
- cua_driver_core::video::set_video_backend_factory(Box::new(
- cua_driver_core::video_ffmpeg::FfmpegVideoBackendFactory,
- ));
- {
- let mut r = platform_windows::register_tools_with_cursor(cursor_cfg, compat);
- check_update_tool::register_into(&mut r);
- r
- }
- }
- #[cfg(target_os = "linux")]
- {
- cua_driver_core::recording::set_screenshot_fn(|window_id, pid| {
- platform_linux::recording_hooks::screenshot_for_recording(window_id, pid)
- });
- cua_driver_core::recording::set_click_marker_fn(|png_bytes, cx, cy| {
- platform_linux::capture::crosshair_png_bytes(png_bytes, cx, cy).ok()
- });
- cua_driver_core::recording::set_ax_snapshot_fn(|window_id, pid| {
- platform_linux::recording_hooks::app_state_json_for(window_id, pid)
- });
- cua_driver_core::recording::set_element_bounds_fn(|wid, pid, idx| {
- platform_linux::recording_hooks::element_window_local_xy(wid, pid, idx)
- });
- if platform_linux::wayland::is_wayland() {
- cua_driver_core::video::set_video_backend_factory(Box::new(
- platform_linux::video_wayland::WfRecorderVideoBackendFactory,
- ));
- } else {
- cua_driver_core::video::set_video_backend_factory(Box::new(
- cua_driver_core::video_ffmpeg::FfmpegVideoBackendFactory,
- ));
- }
- // SSH-driven Wayland+Xwayland sessions inherit DISPLAY but not
- // XAUTHORITY; adopt the running X server's auth cookie so X11 tools
- // don't all fail "Authorization required" (#1926). No-op when
- // XAUTHORITY is already set or there's no DISPLAY.
- platform_linux::xauth::ensure_xauthority_discovered();
- // AT-SPI lives on the session bus; when the daemon is started outside
- // the desktop session (container, headless, runuser, systemd system
- // unit) DBUS_SESSION_BUS_ADDRESS is unset and the AT-SPI tree comes back
- // empty. Recover it from /run/user/<uid>/bus or a running session
- // process before the a11y advertise (which itself needs the bus). No-op
- // when already set.
- platform_linux::session_bus::ensure_session_bus_discovered();
- // Turn on Chromium/Electron (and GTK/Qt) accessibility for the session
- // so their AT-SPI trees are visible to get_window_state. Best-effort and
- // idempotent; only on the serve path, not for short-lived CLI calls.
- platform_linux::a11y::ensure_chromium_accessibility_enabled();
- if let Err(error) = platform_linux::atspi::ensure_listener_active() {
- tracing::warn!("could not activate the persistent AT-SPI listener: {error}");
- }
- {
- let mut r = platform_linux::register_tools_with_cursor(cursor_cfg, compat);
- check_update_tool::register_into(&mut r);
- r
- }
- }
- #[cfg(not(any(target_os = "windows", target_os = "linux")))]
- {
- let _ = cursor_cfg;
- let _ = compat;
- let mut r = cua_driver_core::tool::ToolRegistry::new();
- r.register(Box::new(crate::stub::UnsupportedPlatformTool));
- r
- }
-}
-
-/// Build a registry without initialising the cursor overlay.
-/// Used by CLI subcommands (list-tools / describe / call) that don't need the overlay.
-#[cfg(not(target_os = "macos"))]
-fn build_registry_no_cursor() -> cua_driver_core::tool::ToolRegistry {
- let compat = false;
- #[cfg(target_os = "windows")]
- {
- cua_driver_core::recording::set_classified_screenshot_fn(|window_id, pid| {
- platform_windows::recording_hooks::screenshot_for_recording(window_id, pid)
- });
- cua_driver_core::recording::set_click_marker_fn(|png_bytes, cx, cy| {
- platform_windows::capture::crosshair_png_bytes(png_bytes, cx, cy).ok()
- });
- cua_driver_core::recording::set_ax_snapshot_fn(|window_id, pid| {
- platform_windows::recording_hooks::app_state_json_for(window_id, pid)
- });
- cua_driver_core::recording::set_element_bounds_fn(|wid, pid, idx| {
- platform_windows::recording_hooks::element_window_local_xy(wid, pid, idx)
- });
- cua_driver_core::video::set_video_backend_factory(Box::new(
- cua_driver_core::video_ffmpeg::FfmpegVideoBackendFactory,
- ));
- {
- let mut r = platform_windows::register_tools_with_cursor(
- cursor_overlay::CursorConfig {
- enabled: false,
- ..Default::default()
- },
- compat,
- );
- check_update_tool::register_into(&mut r);
- r
- }
- }
- #[cfg(target_os = "linux")]
- {
- platform_linux::xauth::ensure_xauthority_discovered();
- platform_linux::session_bus::ensure_session_bus_discovered();
- platform_linux::a11y::ensure_chromium_accessibility_enabled();
- if let Err(error) = platform_linux::atspi::ensure_listener_active() {
- tracing::warn!("could not activate the persistent AT-SPI listener: {error}");
- }
- cua_driver_core::recording::set_screenshot_fn(|window_id, pid| {
- platform_linux::recording_hooks::screenshot_for_recording(window_id, pid)
- });
- cua_driver_core::recording::set_click_marker_fn(|png_bytes, cx, cy| {
- platform_linux::capture::crosshair_png_bytes(png_bytes, cx, cy).ok()
- });
- cua_driver_core::recording::set_ax_snapshot_fn(|window_id, pid| {
- platform_linux::recording_hooks::app_state_json_for(window_id, pid)
- });
- cua_driver_core::recording::set_element_bounds_fn(|wid, pid, idx| {
- platform_linux::recording_hooks::element_window_local_xy(wid, pid, idx)
- });
- if platform_linux::wayland::is_wayland() {
- cua_driver_core::video::set_video_backend_factory(Box::new(
- platform_linux::video_wayland::WfRecorderVideoBackendFactory,
- ));
- } else {
- cua_driver_core::video::set_video_backend_factory(Box::new(
- cua_driver_core::video_ffmpeg::FfmpegVideoBackendFactory,
- ));
- }
- {
- let mut r = platform_linux::register_tools_with_cursor(
- cursor_overlay::CursorConfig {
- enabled: false,
- ..Default::default()
- },
- compat,
- );
- check_update_tool::register_into(&mut r);
- r
- }
- }
- #[cfg(not(any(target_os = "windows", target_os = "linux")))]
- {
- let _ = compat;
- let mut r = cua_driver_core::tool::ToolRegistry::new();
- r.register(Box::new(crate::stub::UnsupportedPlatformTool));
- r
- }
-}
-
-#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "linux")))]
-mod stub {
- use async_trait::async_trait;
- use cua_driver_core::tool::{Tool, ToolDef, ToolResult};
- use serde_json::Value;
-
- pub struct UnsupportedPlatformTool;
-
- #[async_trait]
- impl Tool for UnsupportedPlatformTool {
- fn def(&self) -> &ToolDef {
- static DEF: std::sync::OnceLock<ToolDef> = std::sync::OnceLock::new();
- DEF.get_or_init(|| ToolDef {
- name: "unsupported_platform".into(),
- description: "This platform is not supported.".into(),
- input_schema: serde_json::json!({"type":"object","properties":{}}),
- read_only: true,
- destructive: false,
- idempotent: true,
- open_world: false,
- })
- }
- async fn invoke(&self, _args: Value) -> ToolResult {
- ToolResult::error("Unsupported platform")
- }
- }
-}
diff --git a/libs/cua-driver/rust/crates/cua-driver/src/serve.rs b/libs/cua-driver/rust/crates/cua-driver/src/serve.rs
index 9a4366de9b..2967464f5e 100644
--- a/libs/cua-driver/rust/crates/cua-driver/src/serve.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/src/serve.rs
@@ -1535,10 +1535,13 @@ pub async fn run_serve(
/// `cua-driver serve` implementation.
pub fn run_serve_cmd(
- registry: std::sync::Arc<cua_driver_core::tool::ToolRegistry>,
+ driver: std::sync::Arc<cua_driver_sdk::CuaDriver>,
socket_path: &str,
pid_file_path: Option<&str>,
) {
+ let registry = driver
+ .compatibility_registry()
+ .expect("daemon host must own the SDK runtime");
let socket_path = socket_path.to_owned();
let pid_file_path = pid_file_path.map(str::to_owned);
diff --git a/libs/cua-driver/rust/crates/cua-driver/tests/embedded_host_sdk_mcp_test.rs b/libs/cua-driver/rust/crates/cua-driver/tests/embedded_host_sdk_mcp_test.rs
index 60947a880f..1404093963 100644
--- a/libs/cua-driver/rust/crates/cua-driver/tests/embedded_host_sdk_mcp_test.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/tests/embedded_host_sdk_mcp_test.rs
@@ -53,7 +53,7 @@ async fn embedded_host_serves_sdk_and_mcp_with_one_contract() {
assert_eq!(host.state(), EmbeddedDriverHostState::Ready);
let sdk = CuaDriver::connect(Some(connection.socket_path.clone())).expect("connect SDK");
- let metadata = sdk.metadata().expect("SDK metadata handshake");
+ let metadata = sdk.metadata().await.expect("SDK metadata handshake");
assert!(metadata.embedded);
assert_eq!(metadata.pid, connection.pid);
assert_eq!(metadata.contract_version, connection.contract_version);
@@ -62,7 +62,7 @@ async fn embedded_host_serves_sdk_and_mcp_with_one_contract() {
Some("com.trycua.embedded-contract-test")
);
let sdk_tools: Value =
- serde_json::from_str(&sdk.list_tools_json().expect("SDK tools/list")).unwrap();
+ serde_json::from_str(&sdk.list_tools_json().await.expect("SDK tools/list")).unwrap();
let mut proxy_command = Command::new(&connection.mcp.command);
proxy_command
@@ -121,6 +121,7 @@ async fn embedded_host_serves_sdk_and_mcp_with_one_contract() {
session: "embedded-sdk-window".into(),
capture_scope: Some(CaptureScope::Window),
})
+ .await
.expect("start SDK-owned session");
assert_eq!(sdk_session.state.capture_scope, CaptureScope::Window);
@@ -155,11 +156,13 @@ async fn embedded_host_serves_sdk_and_mcp_with_one_contract() {
.get_session_state(GetSessionStateInput {
session: "embedded-sdk-window".into(),
})
+ .await
.expect("read SDK session");
let mcp_state = sdk
.get_session_state(GetSessionStateInput {
session: "embedded-mcp-desktop".into(),
})
+ .await
.expect("read MCP-created session through SDK");
assert_eq!(sdk_state.capture_scope, CaptureScope::Window);
assert_eq!(mcp_state.capture_scope, CaptureScope::Desktop);
diff --git a/libs/cua-driver/typescript/README.md b/libs/cua-driver/typescript/README.md
index c0a6fc9e96..3f4a14a1d0 100644
--- a/libs/cua-driver/typescript/README.md
+++ b/libs/cua-driver/typescript/README.md
@@ -4,7 +4,7 @@ Rust-backed TypeScript/Node SDK for Cua Driver client applications.
## Product boundary
-The package root exposes the native daemon SDK:
+The package root exposes the native SDK:
```ts
import { CuaDriver } from "@trycua/cua-driver"
@@ -21,10 +21,10 @@ runtime-neutral MCP clients and should configure the executable directly:
cua-driver mcp
```
-The removed pre-release MCP facade used `CuaDriver.stdio()`, async methods,
-`*Args` interfaces, and a TypeScript stdio transport. Application code migrates
-to the synchronous Rust-backed methods shown below; agent code removes the Cua
-package import and supplies `cua-driver mcp` to its agent SDK.
+The removed pre-release MCP facade used `CuaDriver.stdio()`, `*Args`
+interfaces, and a TypeScript stdio transport. Application code imports the
+typed Rust-backed SDK shown below; agent code supplies `cua-driver mcp` to its
+agent SDK.
## SDK example
@@ -37,8 +37,8 @@ import {
StartSessionInput,
} from "@trycua/cua-driver"
-const driver = CuaDriver.connect(undefined) // default installed daemon socket
-driver.startSession(
+const driver = CuaDriver.create(undefined) // same process; no daemon
+await driver.startSession(
StartSessionInput.new({
session: "demo",
captureScope: CaptureScope.Desktop,
@@ -46,27 +46,37 @@ driver.startSession(
)
try {
- const desktop = driver.getDesktopState(
+ const desktop = await driver.getDesktopState(
GetDesktopStateInput.new({ session: "demo" }),
)
console.log(desktop.images[0]?.mimeType)
} finally {
- driver.endSession(EndSessionInput.new({ session: "demo" }))
+ await driver.endSession(EndSessionInput.new({ session: "demo" }))
+ await driver.shutdown()
driver.uniffiDestroy()
}
```
-The SDK is currently synchronous and requires a native library matching the
-host OS and architecture. Desktop calls return a typed `ToolResult` with text,
+SDK operations are asynchronous and require a native library matching the host
+OS and architecture. Desktop calls return a typed `ToolResult` with text,
images, verification/error metadata, and `structuredJson` / `rawJson` for
-platform-extensible results. Session lifecycle calls return dedicated
-generated records.
+platform-extensible results. Session lifecycle calls return dedicated generated
+records.
-## Embedded Node and Electron hosts
+`CuaDriver.connect(socketPath)` remains available while existing applications
+migrate. It exposes the same methods over the installed daemon, but it does not
+provide a second SDK contract.
-A signed desktop application can bundle `cua-driver`, start it as a direct
-child, and connect both the native SDK and its agent runtime to the same private
-daemon:
+`shutdown()` closes admission, waits for already admitted operations to finish,
+and is idempotent. Calls started after shutdown reject with `DriverError`.
+`uniffiDestroy()` releases the binding handle, but orderly applications should
+await `shutdown()` first.
+
+## Daemon-backed MCP hosts
+
+A signed desktop application that must also expose MCP to an external agent can
+bundle `cua-driver`, start it as a direct child, and connect both application
+code and its agent runtime to the same private daemon:
```ts
import { CuaDriver, EmbeddedCuaDriverHost } from "@trycua/cua-driver"
diff --git a/libs/cua-driver/typescript/src/index.ts b/libs/cua-driver/typescript/src/index.ts
index 8240783c16..0b31f63236 100644
--- a/libs/cua-driver/typescript/src/index.ts
+++ b/libs/cua-driver/typescript/src/index.ts
@@ -6,9 +6,11 @@
*/
import { CuaDriver, SdkClientKind } from "./native/cua_driver_sdk.js"
-// The same native library backs Python and TypeScript. Keep the public
-// CuaDriver.connect signature stable while attaching the importing runtime as
-// a closed, content-free category to direct daemon requests.
+// The same native library backs Python and TypeScript. The package root tags
+// both the canonical same-process constructor and the temporary daemon
+// compatibility constructor with the importing runtime.
+CuaDriver.create = (options) =>
+ CuaDriver.createWithClientKind(options, SdkClientKind.Typescript)
CuaDriver.connect = (socketPath: string | undefined) =>
CuaDriver.connectWithClientKind(socketPath, SdkClientKind.Typescript)
diff --git a/libs/cua-driver/typescript/src/native/cua_driver_sdk-ffi.ts b/libs/cua-driver/typescript/src/native/cua_driver_sdk-ffi.ts
index 3299e85628..854f5b8d53 100644
--- a/libs/cua-driver/typescript/src/native/cua_driver_sdk-ffi.ts
+++ b/libs/cua-driver/typescript/src/native/cua_driver_sdk-ffi.ts
@@ -308,55 +308,70 @@ const DEFINITIONS = {
ret: FfiType.Handle,
hasRustCallStatus: true,
},
+ "uniffi_cua_driver_sdk_fn_constructor_cuadriver_create": {
+ args: [FfiType.RustBuffer],
+ ret: FfiType.Handle,
+ hasRustCallStatus: true,
+ },
+ "uniffi_cua_driver_sdk_fn_constructor_cuadriver_create_with_client_kind": {
+ args: [FfiType.RustBuffer, FfiType.RustBuffer],
+ ret: FfiType.Handle,
+ hasRustCallStatus: true,
+ },
"uniffi_cua_driver_sdk_fn_method_cuadriver_call_tool": {
args: [FfiType.Handle, FfiType.RustBuffer, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_click": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_drag": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_end_session": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_escalate_session": {
args: [FfiType.Handle, FfiType.RustBuffer],
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
+ },
+ "uniffi_cua_driver_sdk_fn_method_cuadriver_execution_mode": {
+ args: [FfiType.Handle],
ret: FfiType.RustBuffer,
hasRustCallStatus: true,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_get_cursor_position": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_get_desktop_state": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_get_screen_size": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_get_session_state": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_hotkey": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_is_available": {
args: [FfiType.Handle],
@@ -365,28 +380,33 @@ const DEFINITIONS = {
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_list_tools_json": {
args: [FfiType.Handle],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_metadata": {
args: [FfiType.Handle],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_move_cursor": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_press_key": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_scroll": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
+ },
+ "uniffi_cua_driver_sdk_fn_method_cuadriver_shutdown": {
+ args: [FfiType.Handle],
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_socket_path": {
args: [FfiType.Handle],
@@ -395,13 +415,13 @@ const DEFINITIONS = {
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_start_session": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_method_cuadriver_type_text": {
args: [FfiType.Handle, FfiType.RustBuffer],
- ret: FfiType.RustBuffer,
- hasRustCallStatus: true,
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
},
"uniffi_cua_driver_sdk_fn_constructor_embeddedcuadriverhost_new": {
args: [FfiType.RustBuffer, FfiType.RustBuffer],
@@ -473,6 +493,16 @@ const DEFINITIONS = {
ret: FfiType.UInt16,
hasRustCallStatus: false,
},
+ "uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create": {
+ args: [],
+ ret: FfiType.UInt16,
+ hasRustCallStatus: false,
+ },
+ "uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create_with_client_kind": {
+ args: [],
+ ret: FfiType.UInt16,
+ hasRustCallStatus: false,
+ },
"uniffi_cua_driver_sdk_checksum_method_cuadriver_call_tool": {
args: [],
ret: FfiType.UInt16,
@@ -498,6 +528,11 @@ const DEFINITIONS = {
ret: FfiType.UInt16,
hasRustCallStatus: false,
},
+ "uniffi_cua_driver_sdk_checksum_method_cuadriver_execution_mode": {
+ args: [],
+ ret: FfiType.UInt16,
+ hasRustCallStatus: false,
+ },
"uniffi_cua_driver_sdk_checksum_method_cuadriver_get_cursor_position": {
args: [],
ret: FfiType.UInt16,
@@ -553,6 +588,11 @@ const DEFINITIONS = {
ret: FfiType.UInt16,
hasRustCallStatus: false,
},
+ "uniffi_cua_driver_sdk_checksum_method_cuadriver_shutdown": {
+ args: [],
+ ret: FfiType.UInt16,
+ hasRustCallStatus: false,
+ },
"uniffi_cua_driver_sdk_checksum_method_cuadriver_socket_path": {
args: [],
ret: FfiType.UInt16,
@@ -687,25 +727,29 @@ interface NativeModuleInterface {
uniffi_cua_driver_sdk_fn_func_request_mac_os_permissions(uniffi_out_err: UniffiRustCallStatus): Uint8Array;
uniffi_cua_driver_sdk_fn_constructor_cuadriver_connect(socketPath: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
uniffi_cua_driver_sdk_fn_constructor_cuadriver_connect_with_client_kind(socketPath: Uint8Array, clientKind: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
- uniffi_cua_driver_sdk_fn_method_cuadriver_call_tool(uniffiSelf: bigint, name: Uint8Array, argumentsJson: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_click(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_drag(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_end_session(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_escalate_session(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_get_cursor_position(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_get_desktop_state(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_get_screen_size(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_get_session_state(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_hotkey(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
+ uniffi_cua_driver_sdk_fn_constructor_cuadriver_create(options: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
+ uniffi_cua_driver_sdk_fn_constructor_cuadriver_create_with_client_kind(options: Uint8Array, clientKind: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_call_tool(uniffiSelf: bigint, name: Uint8Array, argumentsJson: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_click(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_drag(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_end_session(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_escalate_session(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_execution_mode(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_get_cursor_position(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_get_desktop_state(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_get_screen_size(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_get_session_state(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_hotkey(uniffiSelf: bigint, input: Uint8Array): bigint;
uniffi_cua_driver_sdk_fn_method_cuadriver_is_available(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): number;
- uniffi_cua_driver_sdk_fn_method_cuadriver_list_tools_json(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_metadata(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_move_cursor(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_press_key(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_scroll(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_list_tools_json(uniffiSelf: bigint): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_metadata(uniffiSelf: bigint): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_move_cursor(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_press_key(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_scroll(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_shutdown(uniffiSelf: bigint): bigint;
uniffi_cua_driver_sdk_fn_method_cuadriver_socket_path(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_start_session(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
- uniffi_cua_driver_sdk_fn_method_cuadriver_type_text(uniffiSelf: bigint, input: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_start_session(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_type_text(uniffiSelf: bigint, input: Uint8Array): bigint;
uniffi_cua_driver_sdk_fn_constructor_embeddedcuadriverhost_new(binaryPath: Uint8Array, hostBundleId: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
uniffi_cua_driver_sdk_fn_constructor_embeddedcuadriverhost_with_options(options: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
uniffi_cua_driver_sdk_fn_method_embeddedcuadriverhost_connection(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
@@ -720,11 +764,14 @@ interface NativeModuleInterface {
uniffi_cua_driver_sdk_checksum_func_request_mac_os_permissions(): number;
uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect(): number;
uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect_with_client_kind(): number;
+ uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create(): number;
+ uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create_with_client_kind(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_call_tool(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_click(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_drag(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_end_session(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_escalate_session(): number;
+ uniffi_cua_driver_sdk_checksum_method_cuadriver_execution_mode(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_get_cursor_position(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_get_desktop_state(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_get_screen_size(): number;
@@ -736,6 +783,7 @@ interface NativeModuleInterface {
uniffi_cua_driver_sdk_checksum_method_cuadriver_move_cursor(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_press_key(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_scroll(): number;
+ uniffi_cua_driver_sdk_checksum_method_cuadriver_shutdown(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_socket_path(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_start_session(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriver_type_text(): number;
diff --git a/libs/cua-driver/typescript/src/native/cua_driver_sdk.ts b/libs/cua-driver/typescript/src/native/cua_driver_sdk.ts
index f28586a55d..777a41f257 100644
--- a/libs/cua-driver/typescript/src/native/cua_driver_sdk.ts
+++ b/libs/cua-driver/typescript/src/native/cua_driver_sdk.ts
@@ -156,6 +156,52 @@ const FfiConverterTypeDriverMetadata = (() => {
return new FFIConverter();
})();
+/**
+ * Options for a same-process Cua Driver SDK runtime.
+ */
+export type DriverOptions = {
+ /**
+ * Preserve the temporary reduced screenshot surface used by older Claude
+ * Code integrations. New applications should leave this false.
+ */
+ claudeCodeCompatibility: boolean
+}
+
+/**
+ * Generated factory for {@link DriverOptions} record objects.
+ */
+export const DriverOptions = (() => {
+ const defaults = () => ({
+ });
+ const create = (() => {
+ return uniffiCreateRecord<DriverOptions, ReturnType<typeof defaults>>(defaults);
+ })();
+ return Object.freeze({
+ create,
+ new: create,
+ defaults: () => Object.freeze(defaults()) as Partial<DriverOptions>,
+ });
+})();
+
+const FfiConverterTypeDriverOptions = (() => {
+ type TypeName = DriverOptions;
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
+ read(from: RustBuffer): TypeName {
+ return {
+ claudeCodeCompatibility: FfiConverterBool.read(from)
+ };
+ }
+ write(value: TypeName, into: RustBuffer): void {
+ FfiConverterBool.write(value.claudeCodeCompatibility, into);
+ }
+ allocationSize(value: TypeName): number {
+ return FfiConverterBool.allocationSize(value.claudeCodeCompatibility);
+
+ }
+ };
+ return new FFIConverter();
+})();
+
export type EmbeddedEnvironmentVariable = {
name: string,
value: string
@@ -636,7 +682,8 @@ export enum DriverError_Tags {
InvalidArguments = "InvalidArguments",
Transport = "Transport",
Protocol = "Protocol",
- Tool = "Tool"
+ Tool = "Tool",
+ Shutdown = "Shutdown"
}
export const DriverError = (() => {
@@ -835,6 +882,33 @@ Readonly<{tool: string; message: string; errorCode: string}> {
}
+ type Shutdown__interface = {
+ tag: DriverError_Tags.Shutdown
+ };
+ class Shutdown_ extends UniffiError implements Shutdown__interface {
+ /**
+ * @private
+ * This field is private and should not be used, use `tag` instead.
+ */
+ readonly [uniffiTypeNameSymbol] = "DriverError";
+ readonly tag = DriverError_Tags.Shutdown;
+ constructor() {
+ super("DriverError", "Shutdown");
+ }
+
+ static new(): Shutdown_ {
+ return new Shutdown_();
+ }
+
+ static instanceOf(obj: any): obj is Shutdown_ {
+ return obj.tag === DriverError_Tags.Shutdown;
+ }
+ static hasInner(obj: any): obj is Shutdown_ {
+ return false;
+ }
+
+ }
+
function instanceOf(obj: any): obj is DriverError {
return obj[uniffiTypeNameSymbol] === "DriverError";
}
@@ -845,12 +919,13 @@ Readonly<{tool: string; message: string; errorCode: string}> {
InvalidArguments: InvalidArguments_,
Transport: Transport_,
Protocol: Protocol_,
- Tool: Tool_
+ Tool: Tool_,
+ Shutdown: Shutdown_
});
})();
export type DriverError = InstanceType<
- typeof DriverError['Configuration' | 'InvalidArguments' | 'Transport' | 'Protocol' | 'Tool']
+ typeof DriverError['Configuration' | 'InvalidArguments' | 'Transport' | 'Protocol' | 'Tool' | 'Shutdown']
>;
// FfiConverter for enum DriverError
@@ -865,6 +940,7 @@ const FfiConverterTypeDriverError = (() => {
case 3: return new DriverError.Transport({socketPath: FfiConverterString.read(from), reason: FfiConverterString.read(from) });
case 4: return new DriverError.Protocol({reason: FfiConverterString.read(from) });
case 5: return new DriverError.Tool({tool: FfiConverterString.read(from), message: FfiConverterString.read(from), errorCode: FfiConverterString.read(from) });
+ case 6: return new DriverError.Shutdown();
default: throw new UniffiInternalError.UnexpectedEnumCase();
}
}
@@ -904,6 +980,10 @@ const FfiConverterTypeDriverError = (() => {
FfiConverterString.write(inner.errorCode, into);
return;
}
+ case DriverError_Tags.Shutdown: {
+ ordinalConverter.write(6, into);
+ return;
+ }
default:
// Throwing from here means that DriverError_Tags hasn't matched an ordinal.
throw new UniffiInternalError.UnexpectedEnumCase();
@@ -945,9 +1025,44 @@ const FfiConverterTypeDriverError = (() => {
size += FfiConverterString.allocationSize(inner.errorCode);
return size;
}
+ case DriverError_Tags.Shutdown: {
+ return ordinalConverter.allocationSize(6);
+ }
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
+ }
+ }
+ }
+ return new FFIConverter();
+})();
+
+/**
+ * Process topology used by this SDK object.
+ */
+export enum DriverExecutionMode {
+ Embedded,
+ Daemon
+}
+
+const FfiConverterTypeDriverExecutionMode = (() => {
+ const ordinalConverter = FfiConverterInt32;
+ type TypeName = DriverExecutionMode;
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
+ read(from: RustBuffer): TypeName {
+ switch (ordinalConverter.read(from)) {
+ case 1: return DriverExecutionMode.Embedded;
+ case 2: return DriverExecutionMode.Daemon;
default: throw new UniffiInternalError.UnexpectedEnumCase();
}
}
+ write(value: TypeName, into: RustBuffer): void {
+ switch (value) {
+ case DriverExecutionMode.Embedded: return ordinalConverter.write(1, into);
+ case DriverExecutionMode.Daemon: return ordinalConverter.write(2, into);
+ }
+ }
+ allocationSize(value: TypeName): number {
+ return ordinalConverter.allocationSize(0);
+ }
}
return new FFIConverter();
})();
@@ -1488,28 +1603,42 @@ const FfiConverterTypeSdkClientKind = (() => {
export interface CuaDriverLike {
/**
- * Escape hatch for forward-compatible tools and application-owned server
- * adapters. Typed methods below serialize the same canonical Rust inputs.
+ * Temporary compatibility escape hatch. New application code should use
+ * the typed methods; MCP servers own generic discovery and invocation.
*/
- callTool(name: string, argumentsJson: string) /*throws*/: ToolResult;
- click(input: ClickInput) /*throws*/: ToolResult;
- drag(input: DragInput) /*throws*/: ToolResult;
- endSession(input: EndSessionInput) /*throws*/: EndSessionOutput;
- escalateSession(input: EscalateSessionInput) /*throws*/: SessionStateOutput;
- getCursorPosition(input: GetCursorPositionInput) /*throws*/: ToolResult;
- getDesktopState(input: GetDesktopStateInput) /*throws*/: ToolResult;
- getScreenSize(input: GetScreenSizeInput) /*throws*/: ToolResult;
- getSessionState(input: GetSessionStateInput) /*throws*/: SessionStateOutput;
- hotkey(input: HotkeyInput) /*throws*/: ToolResult;
+ callTool(name: string, argumentsJson: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ click(input: ClickInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ drag(input: DragInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ endSession(input: EndSessionInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<EndSessionOutput>;
+ escalateSession(input: EscalateSessionInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<SessionStateOutput>;
+ executionMode(): DriverExecutionMode;
+ getCursorPosition(input: GetCursorPositionInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ getDesktopState(input: GetDesktopStateInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ getScreenSize(input: GetScreenSizeInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ getSessionState(input: GetSessionStateInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<SessionStateOutput>;
+ hotkey(input: HotkeyInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
isAvailable(): boolean;
- listToolsJson() /*throws*/: string;
- metadata() /*throws*/: DriverMetadata;
- moveCursor(input: MoveCursorInput) /*throws*/: ToolResult;
- pressKey(input: PressKeyInput) /*throws*/: ToolResult;
- scroll(input: ScrollInput) /*throws*/: ToolResult;
+/**
+ * Temporary compatibility discovery surface for adapters migrating to
+ * the typed SDK contract.
+ */
+ listToolsJson(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string>;
+ metadata(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<DriverMetadata>;
+ moveCursor(input: MoveCursorInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ pressKey(input: PressKeyInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ scroll(input: ScrollInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+/**
+ * Stop accepting new embedded operations. Repeated calls are harmless;
+ * daemon compatibility clients do not own the daemon and therefore no-op.
+ */
+ shutdown(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
+/**
+ * Compatibility accessor. Embedded runtimes have no socket and return an
+ * empty string; new code should branch on [`Self::execution_mode`].
+ */
socketPath(): string;
- startSession(input: StartSessionInput) /*throws*/: StartSessionOutput;
- typeText(input: TypeTextInput) /*throws*/: ToolResult;
+ startSession(input: StartSessionInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<StartSessionOutput>;
+ typeText(input: TypeTextInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
}
/**
* @deprecated Use `CuaDriverLike` instead.
@@ -1532,7 +1661,7 @@ private constructor(pointer: UniffiHandle) {
/**
* Connect to the default installed daemon or an explicitly selected socket.
- * Construction does not launch a process or perform I/O.
+ * This is the temporary compatibility path for released socket clients.
*/
static connect(socketPath: string | undefined): CuaDriverLike /*throws*/ {
return FfiConverterTypeCuaDriver.lift(uniffiCaller.rustCallWithError(
@@ -1563,201 +1692,380 @@ private constructor(pointer: UniffiHandle) {
));
}
-
-
/**
- * Escape hatch for forward-compatible tools and application-owned server
- * adapters. Typed methods below serialize the same canonical Rust inputs.
+ * Create a same-process driver runtime. This constructor never launches
+ * `cua-driver` and never opens daemon IPC.
*/
- callTool(name: string, argumentsJson: string): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
+ static create(options: DriverOptions | undefined): CuaDriverLike /*throws*/ {
+ return FfiConverterTypeCuaDriver.lift(uniffiCaller.rustCallWithError(
/*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
/*caller:*/ (callStatus) => {
- return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_call_tool(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterString.lower(name, nativeModule().rustbuffer_alloc),
- FfiConverterString.lower(argumentsJson, nativeModule().rustbuffer_alloc),
+ return nativeModule().uniffi_cua_driver_sdk_fn_constructor_cuadriver_create(
+ FfiConverterOptionalTypeDriverOptions.lower(options, nativeModule().rustbuffer_alloc),
callStatus);
},
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
));
}
- click(input: ClickInput): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
+/**
+ * Language-package entry point for the same-process runtime. The wrapper
+ * at each package root selects the client kind automatically.
+ */
+ static createWithClientKind(options: DriverOptions | undefined, clientKind: SdkClientKind): CuaDriverLike /*throws*/ {
+ return FfiConverterTypeCuaDriver.lift(uniffiCaller.rustCallWithError(
/*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
/*caller:*/ (callStatus) => {
- return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_click(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeClickInput.lower(input, nativeModule().rustbuffer_alloc),
+ return nativeModule().uniffi_cua_driver_sdk_fn_constructor_cuadriver_create_with_client_kind(
+ FfiConverterOptionalTypeDriverOptions.lower(options, nativeModule().rustbuffer_alloc),
+ FfiConverterTypeSdkClientKind.lower(clientKind, nativeModule().rustbuffer_alloc),
callStatus);
},
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
));
}
- drag(input: DragInput): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
+
+
+/**
+ * Temporary compatibility escape hatch. New application code should use
+ * the typed methods; MCP servers own generic discovery and invocation.
+ */
+ async callTool(name: string, argumentsJson: string, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
+ return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_call_tool(
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterString.lower(name, nativeModule().rustbuffer_alloc),FfiConverterString.lower(argumentsJson, nativeModule().rustbuffer_alloc)
+ );
+ },
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
}
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
- return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_drag(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeDragInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ throw __error;
+ }
+ }
+
+ async click(input: ClickInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
+ return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_click(
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeClickInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- endSession(input: EndSessionInput): EndSessionOutput /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeEndSessionOutput.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
+ async drag(input: DragInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
+ return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_drag(
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeDragInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
+ },
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
}
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ throw __error;
+ }
+ }
+
+ async endSession(input: EndSessionInput, asyncOpts_?: { signal: AbortSignal }): Promise<EndSessionOutput> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_end_session(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeEndSessionInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeEndSessionInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeEndSessionOutput.lift.bind(FfiConverterTypeEndSessionOutput),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- escalateSession(input: EscalateSessionInput): SessionStateOutput /*throws*/ {
+ async escalateSession(input: EscalateSessionInput, asyncOpts_?: { signal: AbortSignal }): Promise<SessionStateOutput> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
+ return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_escalate_session(
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeEscalateSessionInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
+ },
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeSessionStateOutput.lift.bind(FfiConverterTypeSessionStateOutput),
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
+ }
+
+ executionMode(): DriverExecutionMode {
return ((__rb: Uint8Array) => {
try {
- return FfiConverterTypeSessionStateOutput.lift(__rb);
+ return FfiConverterTypeDriverExecutionMode.lift(__rb);
} finally {
nativeModule().rustbuffer_free(__rb);
}
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
+ })(uniffiCaller.rustCall(
/*caller:*/ (callStatus) => {
- return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_escalate_session(
+ return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_execution_mode(
uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeEscalateSessionInput.lower(input, nativeModule().rustbuffer_alloc),
callStatus);
},
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
));
}
- getCursorPosition(input: GetCursorPositionInput): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async getCursorPosition(input: GetCursorPositionInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_get_cursor_position(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeGetCursorPositionInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeGetCursorPositionInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- getDesktopState(input: GetDesktopStateInput): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async getDesktopState(input: GetDesktopStateInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_get_desktop_state(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeGetDesktopStateInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeGetDesktopStateInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- getScreenSize(input: GetScreenSizeInput): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async getScreenSize(input: GetScreenSizeInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_get_screen_size(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeGetScreenSizeInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeGetScreenSizeInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- getSessionState(input: GetSessionStateInput): SessionStateOutput /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeSessionStateOutput.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async getSessionState(input: GetSessionStateInput, asyncOpts_?: { signal: AbortSignal }): Promise<SessionStateOutput> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_get_session_state(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeGetSessionStateInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeGetSessionStateInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeSessionStateOutput.lift.bind(FfiConverterTypeSessionStateOutput),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- hotkey(input: HotkeyInput): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async hotkey(input: HotkeyInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_hotkey(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeHotkeyInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeHotkeyInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
isAvailable(): boolean {
@@ -1771,99 +2079,205 @@ private constructor(pointer: UniffiHandle) {
));
}
- listToolsJson(): string /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterString.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+/**
+ * Temporary compatibility discovery surface for adapters migrating to
+ * the typed SDK contract.
+ */
+ async listToolsJson(asyncOpts_?: { signal: AbortSignal }): Promise<string> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_list_tools_json(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterString.lift.bind(FfiConverterString),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- metadata(): DriverMetadata /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeDriverMetadata.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async metadata(asyncOpts_?: { signal: AbortSignal }): Promise<DriverMetadata> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_metadata(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeDriverMetadata.lift.bind(FfiConverterTypeDriverMetadata),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- moveCursor(input: MoveCursorInput): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async moveCursor(input: MoveCursorInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_move_cursor(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeMoveCursorInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeMoveCursorInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- pressKey(input: PressKeyInput): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async pressKey(input: PressKeyInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_press_key(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypePressKeyInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypePressKeyInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- scroll(input: ScrollInput): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async scroll(input: ScrollInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_scroll(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeScrollInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeScrollInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
+ }
+
+/**
+ * Stop accepting new embedded operations. Repeated calls are harmless;
+ * daemon compatibility clients do not own the daemon and therefore no-op.
+ */
+ async shutdown(asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
+ return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_shutdown(
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this)
+ );
+ },
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_void,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_void,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_void,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_void,
+ /*liftFunc:*/ (_v) => {},
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
+/**
+ * Compatibility accessor. Embedded runtimes have no socket and return an
+ * empty string; new code should branch on [`Self::execution_mode`].
+ */
socketPath(): string {
return ((__rb: Uint8Array) => {
try {
@@ -1881,42 +2295,68 @@ private constructor(pointer: UniffiHandle) {
));
}
- startSession(input: StartSessionInput): StartSessionOutput /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeStartSessionOutput.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async startSession(input: StartSessionInput, asyncOpts_?: { signal: AbortSignal }): Promise<StartSessionOutput> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_start_session(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeStartSessionInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeStartSessionInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeStartSessionOutput.lift.bind(FfiConverterTypeStartSessionOutput),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
- typeText(input: TypeTextInput): ToolResult /*throws*/ {
- return ((__rb: Uint8Array) => {
- try {
- return FfiConverterTypeToolResult.lift(__rb);
- } finally {
- nativeModule().rustbuffer_free(__rb);
- }
- })(uniffiCaller.rustCallWithError(
- /*liftError:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError),
- /*caller:*/ (callStatus) => {
+ async typeText(input: TypeTextInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
+ try {
+ return await uniffiRustCallAsync(
+ /*rustCaller:*/ uniffiCaller,
+ /*rustFutureFunc:*/ () => {
return nativeModule().uniffi_cua_driver_sdk_fn_method_cuadriver_type_text(
- uniffiTypeCuaDriverObjectFactory.clonePointer(this),
- FfiConverterTypeTypeTextInput.lower(input, nativeModule().rustbuffer_alloc),
- callStatus);
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeTypeTextInput.lower(input, nativeModule().rustbuffer_alloc)
+ );
},
+ /*pollFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_poll_rust_buffer,
+ /*cancelFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_cancel_rust_buffer,
+ /*completeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_complete_rust_buffer,
+ /*freeFunc:*/ nativeModule().ffi_cua_driver_sdk_rust_future_free_rust_buffer,
+ // Async returns always go through the JS-side converter: the
+ // FFI symbol returns the future handle (u64), and the user-level
+ // RustBuffer comes back via the shared `rust_future_complete_*`
+ // export. The bytes the runtime hands back must be deserialized
+ // here using the per-callable return-type converter.
+ /*liftFunc:*/ FfiConverterTypeToolResult.lift.bind(FfiConverterTypeToolResult),
/*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
- ));
+ /*asyncOpts:*/ asyncOpts_,
+ /*errorHandler:*/ FfiConverterTypeDriverError.lift.bind(FfiConverterTypeDriverError)
+ );
+ } catch (__error: any) {
+ if (uniffiIsDebug && __error instanceof Error) {
+ __error.stack = __stack;
+ }
+ throw __error;
+ }
}
@@ -2315,6 +2755,9 @@ const FfiConverterOptionalBoolean = new FfiConverterOptional(FfiConverterBool);
// FfiConverter for EmbeddedDriverConnection | undefined
const FfiConverterOptionalTypeEmbeddedDriverConnection = new FfiConverterOptional(FfiConverterTypeEmbeddedDriverConnection);
+// FfiConverter for DriverOptions | undefined
+const FfiConverterOptionalTypeDriverOptions = new FfiConverterOptional(FfiConverterTypeDriverOptions);
+
/**
* This should be called before anything else.
@@ -2343,67 +2786,79 @@ function uniffiEnsureInitialized() {
if (nativeModule().uniffi_cua_driver_sdk_checksum_func_request_mac_os_permissions() !== 61823) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_func_request_mac_os_permissions");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect() !== 42154) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect() !== 60859) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect");
}
if (nativeModule().uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect_with_client_kind() !== 43287) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_constructor_cuadriver_connect_with_client_kind");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_call_tool() !== 31445) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create() !== 15191) {
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create");
+ }
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create_with_client_kind() !== 3630) {
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_constructor_cuadriver_create_with_client_kind");
+ }
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_call_tool() !== 8122) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_call_tool");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_click() !== 34118) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_click() !== 56077) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_click");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_drag() !== 35252) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_drag() !== 25742) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_drag");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_end_session() !== 33990) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_end_session() !== 18486) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_end_session");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_escalate_session() !== 37358) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_escalate_session() !== 6924) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_escalate_session");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_get_cursor_position() !== 54043) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_execution_mode() !== 2639) {
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_execution_mode");
+ }
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_get_cursor_position() !== 34285) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_get_cursor_position");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_get_desktop_state() !== 32992) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_get_desktop_state() !== 65084) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_get_desktop_state");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_get_screen_size() !== 15250) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_get_screen_size() !== 55616) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_get_screen_size");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_get_session_state() !== 51055) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_get_session_state() !== 49966) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_get_session_state");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_hotkey() !== 3135) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_hotkey() !== 53333) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_hotkey");
}
if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_is_available() !== 42961) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_is_available");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_list_tools_json() !== 43987) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_list_tools_json() !== 36787) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_list_tools_json");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_metadata() !== 50371) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_metadata() !== 55026) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_metadata");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_move_cursor() !== 11209) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_move_cursor() !== 18320) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_move_cursor");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_press_key() !== 17425) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_press_key() !== 63712) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_press_key");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_scroll() !== 21614) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_scroll() !== 52290) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_scroll");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_socket_path() !== 24461) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_shutdown() !== 36331) {
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_shutdown");
+ }
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_socket_path() !== 48126) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_socket_path");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_start_session() !== 53509) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_start_session() !== 45055) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_start_session");
}
- if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_type_text() !== 19673) {
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_type_text() !== 25156) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_type_text");
}
if (nativeModule().uniffi_cua_driver_sdk_checksum_constructor_embeddedcuadriverhost_new() !== 10108) {
@@ -2438,7 +2893,9 @@ export default Object.freeze({
converters: {
FfiConverterTypeCuaDriver,
FfiConverterTypeDriverError,
+ FfiConverterTypeDriverExecutionMode,
FfiConverterTypeDriverMetadata,
+ FfiConverterTypeDriverOptions,
FfiConverterTypeEmbeddedCuaDriverHost,
FfiConverterTypeEmbeddedDriverConnection,
FfiConverterTypeEmbeddedDriverError,
diff --git a/libs/cua-driver/typescript/test/electron-main-fixture.mjs b/libs/cua-driver/typescript/test/electron-main-fixture.mjs
index 5033c67121..7cbeac4c61 100644
--- a/libs/cua-driver/typescript/test/electron-main-fixture.mjs
+++ b/libs/cua-driver/typescript/test/electron-main-fixture.mjs
@@ -70,7 +70,7 @@ try {
const pid = connection.pid
const { CuaDriver } = await import("@trycua/cua-driver")
const driver = CuaDriver.connect(socketPath)
- const tools = JSON.parse(driver.listToolsJson())
+ const tools = JSON.parse(await driver.listToolsJson())
driver.uniffiDestroy()
const result = {
versions: {
diff --git a/libs/cua-driver/typescript/test/electron-main.test.mjs b/libs/cua-driver/typescript/test/electron-main.test.mjs
index 27caeeba46..8d150a500d 100644
--- a/libs/cua-driver/typescript/test/electron-main.test.mjs
+++ b/libs/cua-driver/typescript/test/electron-main.test.mjs
@@ -14,7 +14,7 @@ test(
async () => {
const command = process.platform === "linux" ? "xvfb-run" : electron
const args = process.platform === "linux"
- ? ["-a", electron, path.join(testDirectory, "electron-main-fixture.mjs")]
+ ? ["-a", electron, "--no-sandbox", path.join(testDirectory, "electron-main-fixture.mjs")]
: [path.join(testDirectory, "electron-main-fixture.mjs")]
const child = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"] })
let stdout = ""
@@ -26,7 +26,7 @@ test(
child.on("exit", resolve)
})
- assert.equal(code, 0, stderr)
+ assert.equal(code, 0, `stdout:\n${stdout}\nstderr:\n${stderr}`)
const result = JSON.parse(stdout.trim().split("\n").at(-1))
assert.equal(result.versions.electron, "43.2.0")
assert.equal(result.versions.package, "0.11.0")
diff --git a/libs/cua-driver/typescript/test/native-loader.test.mjs b/libs/cua-driver/typescript/test/native-loader.test.mjs
index 62f325a65a..7032e64349 100644
--- a/libs/cua-driver/typescript/test/native-loader.test.mjs
+++ b/libs/cua-driver/typescript/test/native-loader.test.mjs
@@ -79,7 +79,7 @@ process.stdin.on("end", () => server.close(() => process.exit(0)));
const sdk = await import("@trycua/cua-driver")
const driver = sdk.CuaDriver.connect(connection.socketPath)
assert.equal(driver.socketPath(), connection.socketPath)
- assert.deepEqual(JSON.parse(driver.listToolsJson()), {
+ assert.deepEqual(JSON.parse(await driver.listToolsJson()), {
tools: [{ name: "embedded_fixture" }],
})
driver.uniffiDestroy()
@@ -152,7 +152,7 @@ test(
expectedMethods.every((name) => typeof driver[name] === "function"),
true,
)
- const result = driver.getDesktopState(
+ const result = await driver.getDesktopState(
GetDesktopStateInput.new({ session: "node-run" }),
)
const request = await requestPromise
@@ -170,3 +170,24 @@ test(
}
},
)
+
+test(
+ "generated Node SDK can own the runtime in process",
+ { skip: !existsSync(library), timeout: 10_000 },
+ async () => {
+ const { CuaDriver, DriverExecutionMode } = await import("@trycua/cua-driver")
+ const driver = CuaDriver.create(undefined)
+ try {
+ assert.equal(driver.executionMode(), DriverExecutionMode.Embedded)
+ assert.equal(driver.socketPath(), "")
+ assert.equal(driver.isAvailable(), true)
+ const metadata = await driver.metadata()
+ assert.equal(metadata.embedded, true)
+ assert.equal(metadata.pid, process.pid)
+ await driver.shutdown()
+ assert.equal(driver.isAvailable(), false)
+ } finally {
+ driver.uniffiDestroy()
+ }
+ },
+)
diff --git a/rfcs/2447-cua-driver-native-core-and-mcp-adapter.md b/rfcs/2447-cua-driver-native-core-and-mcp-adapter.md
index 4eadbfe5c2..4d98dbc60e 100644
--- a/rfcs/2447-cua-driver-native-core-and-mcp-adapter.md
+++ b/rfcs/2447-cua-driver-native-core-and-mcp-adapter.md
@@ -8,7 +8,8 @@ created: 2026-07-22
last_updated: 2026-07-22
status: review
discussion: https://github.com/trycua/cua/issues/2447
-implementation: []
+implementation:
+ - https://github.com/trycua/cua/pull/2461
supersedes:
superseded_by:
---
@@ -18,10 +19,10 @@ superseded_by:
## Summary
CUA Driver has one public, typed SDK contract above a native core. The native
-core is the foundation that owns desktop behavior and the binary interface used
-to expose that behavior across language boundaries. The public `CuaDriver` SDK
-is the stable application boundary: native applications consume it directly,
-and generated Python and TypeScript SDKs consume it through the UniFFI/C ABI.
+core is the foundation that owns desktop behavior. A versioned C ABI is the
+implementation-substitution seam, while the public `CuaDriver` SDK is the
+stable application boundary. The safe Rust SDK and generated Python and
+TypeScript SDKs expose the same typed contract above that seam.
MCP is downstream of that SDK. An MCP server is an application of the same
public typed contract available to every application; it is not a peer API to
@@ -46,44 +47,47 @@ implementation into Python and TypeScript.
flowchart LR
- SDK["Public typed<br/>CuaDriver SDK"]
-
- UNIFFI["UniFFI / C ABI"]
-
+ CORE["Private native core<br/><small>Rust today; replaceable</small>"]
+ ABI["Versioned C ABI<br/><small>opaque handles + owned buffers</small>"]
+ RUST["Rust SDK"]
+ UNIFFI["UniFFI bindings"]
PY["Python SDK"]
TS["TypeScript SDK"]
+ DAEMON["Daemon<br/><small>MCP server</small>"]
+ RUSTCLI["CLI<br/><small>SDK direct or MCP client</small>"]
+ STDIO["MCP stdio<br/><small>server / bridge</small>"]
PYMCP["MCP Server<br/><small>(Python)</small>"]
- PYCLI["CLI<br/><small>(Python)</small>"]
-
TSMCP["MCP Server<br/><small>(TypeScript)</small>"]
- TSCLI["CLI<br/><small>(TypeScript)</small>"]
-
- SDK --> UNIFFI
+ CORE --> ABI
+ ABI --> RUST
+ ABI --> UNIFFI
UNIFFI --> PY
UNIFFI --> TS
+ RUST --> DAEMON
+ RUST --> RUSTCLI
+ RUST --> STDIO
PY --> PYMCP
- PY --> PYCLI
-
TS --> TSMCP
- TS --> TSCLI
- classDef sdk fill:#0b7d85,color:#fff,stroke:#05555a,stroke-width:2px;
+ classDef core fill:#0b7d85,color:#fff,stroke:#05555a,stroke-width:2px;
classDef bridge fill:#eef8ef,stroke:#5a9b5a,stroke-width:1.5px;
classDef binding fill:#f7fff7,stroke:#5a9b5a,stroke-width:1.5px;
classDef consumer fill:#eef5ff,stroke:#2563eb,stroke-width:1.5px;
- class SDK sdk;
- class UNIFFI bridge;
- class PY,TS binding;
- class PYMCP,PYCLI,TSMCP,TSCLI consumer;
+ class CORE core;
+ class ABI,UNIFFI bridge;
+ class RUST,PY,TS binding;
+ class DAEMON,RUSTCLI,STDIO,PYMCP,TSMCP consumer;
```
-**Figure 1.** The public typed SDK is the application boundary. Generated
-bindings project that contract into Python and TypeScript, where MCP servers,
-HTTP servers, CLIs, and other applications consume it.
+**Figure 1.** Every language SDK exposes the same typed application contract.
+The versioned C ABI allows the private native core to be replaced without a
+source-level rewrite of downstream Rust, Python, or TypeScript applications.
+MCP servers and CLIs are downstream consumers; MCP stdio is a server or bridge,
+not the product CLI.
## Architecture
@@ -91,16 +95,16 @@ The diagram is read from the foundation upward:
1. The **native core** implements CUA Driver behavior and remains below the
public SDK boundary. It is not a transport endpoint.
-2. The **public typed `CuaDriver` SDK** is the native-facing contract exposed
- by the core. It defines typed operations, inputs, outputs, errors, and
- lifecycle behavior.
-3. The **UniFFI / C ABI** is the generated language bridge from that contract.
- It is light green because it is generated code, not a hand-maintained second
- API.
-4. The **Python SDK** and **TypeScript SDK** are generated bindings that expose
+2. The **versioned C ABI** is Cua's implementation-substitution seam. It uses
+ opaque handles, explicit ownership, and version negotiation.
+3. The **safe Rust `CuaDriver` SDK** wraps that ABI and defines typed
+ operations, inputs, outputs, errors, and lifecycle behavior.
+4. **UniFFI** generates the Python and TypeScript bridge from the canonical
+ typed contract exposed by the safe SDK.
+5. The **Python SDK** and **TypeScript SDK** are generated bindings that expose
the same public typed contract in their respective languages. They are also
light green.
-5. **MCP servers, HTTP servers, CLIs, and applications** are consumers above
+6. **MCP servers, HTTP servers, CLIs, and applications** are consumers above
the SDK. They select a transport or user interface without changing driver
semantics.
@@ -127,12 +131,26 @@ operations to every supported consumer and is the only public path from an
application or adapter to native behavior. A direct native application uses
this SDK without first creating an MCP or HTTP server.
-### UniFFI / C ABI
+### Versioned C ABI and UniFFI
+
+The Cua-owned C ABI bridges the replaceable native core to the safe Rust SDK.
+UniFFI then generates Python and TypeScript bindings for that same canonical
+typed contract. These are binary interoperability layers, not network
+transports and not peer driver contracts.
-UniFFI and the generated C ABI bridge the native SDK into other languages. This
-layer is generated from the SDK contract, preserving one source of truth for
-operation types and semantics. It is a binary interoperability layer, not a
-network transport and not a public replacement for the SDK.
+UniFFI's generated C-callable symbols are an implementation detail, not by
+themselves Cua's stable ABI. Treating them as stable would require a future Zig,
+C++, or other core to reproduce UniFFI checksums, async plumbing, and buffer
+conventions. The explicit ABI must instead define opaque driver handles,
+version negotiation, owned buffers, error/status mapping, async completion and
+cancellation, idempotent destruction, and a rule that native panics never cross
+the boundary.
+
+The first implementation may keep the safe Rust SDK and Rust core in one
+library while this ABI is hardened. That direct path is an internal
+optimization behind the same public SDK API, not a second public contract.
+Before the Rust SDK switches to the ABI, CI must run ABI compatibility,
+ownership, fault, and full SDK conformance tests through both paths.
### Python and TypeScript SDKs
@@ -165,6 +183,11 @@ Python, TypeScript, or a native language, and they receive the same typed
behavior as transport adapters. A CLI can remain local while an MCP or HTTP
adapter makes the contract available to remote clients.
+`cua-driver mcp` is an MCP stdio server or bridge, not “the CLI” in architecture
+terminology. A human/script-oriented CLI either calls the SDK directly or acts
+as an MCP client of a daemon, depending on the required permission identity and
+lifecycle.
+
## Layer Relationships
The dependency direction is fixed:
@@ -173,17 +196,17 @@ The dependency direction is fixed:
MCP adapters, HTTP adapters, CLIs, and applications
|
v
- Public typed CuaDriver SDK
+ Safe typed CuaDriver SDKs
|
v
- UniFFI / C ABI and generated bindings
+ UniFFI bindings / versioned C ABI
|
v
Native core
```
The SDK is the public boundary above the native core. Generated bindings carry
-that boundary to Python and TypeScript. MCP and HTTP both sit above those
-bindings as optional transports, while native applications can call the SDK
-directly. No transport adapter may bypass the SDK to call the native core, and
-no adapter defines a second public driver contract.
+that boundary to Python and TypeScript, and the safe Rust SDK wraps the same ABI.
+MCP and HTTP both sit above those SDKs as optional transports. No transport
+adapter may bypass its language SDK to call the ABI or native core, and no
+adapter defines a second public driver contract.