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 clipboard read and write primitives (#2764)

Francesco Bonaccib8fb6d1218d8
diff --git a/docs/content/docs/reference/cua-driver/mcp-tools.mdx b/docs/content/docs/reference/cua-driver/mcp-tools.mdx
index 2b58ca955a..58848b4059 100644
--- a/docs/content/docs/reference/cua-driver/mcp-tools.mdx
+++ b/docs/content/docs/reference/cua-driver/mcp-tools.mdx
@@ -12,7 +12,7 @@ description: Reference for every MCP tool Cua Driver exposes
import { Callout } from 'fumadocs-ui/components/callout';
-`cua-driver` exposes 50 MCP tools through a single stdio server (`cua-driver mcp`). Every tool is also callable from the shell as `cua-driver <name> '<JSON-args>'`.
+`cua-driver` exposes 52 MCP tools through a single stdio server (`cua-driver mcp`). Every tool is also callable from the shell as `cua-driver <name> '<JSON-args>'`.
Tool names are `snake_case`. Responses are MCP `CallTool.Result` envelopes: a text content block prefixed with a `✅` summary (or the error reason on failure), plus optional image or structured-content blocks on tools that produce them. See the [CLI reference](/reference/cua-driver/cli-reference) for CLI-specific options like `--socket` and `--screenshot-out-file`.
@@ -372,7 +372,7 @@ Press a key combination — e.g. `["cmd", "c"]` for Copy, `["cmd", "shift", "4"]
• `background` (default): post the combo to the target pid WITHOUT fronting or raising it — uses the macOS 14+ auth-message envelope so Chromium/Electron accept it as trusted live input. No focus steal. `window_id` here only targets the combo; it does not raise.
• `foreground`: briefly front the window (NSMenu path, &lt; 1 ms via SLPSSetFrontProcessWithOptions) so native menu key-equivalents (Cmd+Z, Cmd+W) dispatch, then restore the prior frontmost — the explicit escalation for menu-bar shortcuts on non-Chromium apps that ignore a background combo. With x,y, the focused field receives the chord through the foreground HID queue (needed by native Chromium fields such as the omnibox). Requires window_id.
-A combo is never driver-verifiable (no read-back) → effect:"unverifiable"; confirm via screenshot. NOTE: a keyboard combo does NOT focus a text field — to type into a backgrounded Electron input, establish real renderer focus with a PIXEL click first, then `type_text` (do not reach for a clipboard + Cmd+V dance).
+A combo is never driver-verifiable (no read-back) → effect:"unverifiable"; confirm via screenshot. NOTE: a keyboard combo does NOT focus a text field — to type into a backgrounded Electron input, establish real renderer focus with a PIXEL click first, then `type_text`. If an app only accepts paste, call `clipboard_write`, then `clipboard_read` and verify its types (and text when applicable) before selecting or replacing editor content; only then send Cmd+V.
Recognized modifiers: cmd/command, shift, option/alt, ctrl/control, fn. Non-modifier keys use the same vocabulary as `press_key`. Order: modifiers first, one non-modifier last.
@@ -512,6 +512,29 @@ Actions:
{"action":"execute_javascript"}
```
+## Clipboard tools
+
+### `clipboard_read`
+
+List available system clipboard types and optionally return privacy-sensitive plain text. Clipboard content is never retained in telemetry.
+
+**Arguments:**
+
+- `include_text` (boolean, optional): Return plain-text clipboard content in addition to the available types.
+Clipboard content is privacy-sensitive and is never retained in telemetry. default: `false`
+- `session` (string, optional): Optional session id.
+
+### `clipboard_write`
+
+Replace the system clipboard with exactly one value: plain text, an image from an absolute local path, or a file URL from an absolute local path. Returns the available types for read-back before paste.
+
+**Arguments:**
+
+- `file_path` (string, optional): Absolute path to a local file to place on the clipboard as a file URL.
+- `image_path` (string, optional): Absolute path to a local image to place on the clipboard.
+- `session` (string, optional): Optional session id.
+- `text` (string, optional): Plain text to place on the clipboard.
+
## Recording tools
### `start_recording`
diff --git a/libs/cua-driver/contract/README.md b/libs/cua-driver/contract/README.md
index 59721e67ce..695fd6ffb3 100644
--- a/libs/cua-driver/contract/README.md
+++ b/libs/cua-driver/contract/README.md
@@ -31,6 +31,8 @@ It also covers the portable whole-desktop loop:
- `click` with the required `scope="desktop"`
- `drag` and `scroll` in native desktop coordinates
- `type_text`, `press_key`, and `hotkey` against the foreground application
+- `clipboard_read` for available types and opt-in plain-text readback
+- `clipboard_write` for text, image, and file-URL clipboard content
The canonical session-owned cursor slice is shared exactly by MCP and both
generated SDKs:
@@ -85,7 +87,7 @@ Compatibility is tracked separately at each boundary:
| Field | Current | Meaning |
| --- | --- | --- |
-| `contract_version` | `0.4.0` | Generated manifest and typed SDK shape |
+| `contract_version` | `0.5.0` | Generated manifest and typed SDK shape |
| `tools_list_schema_version` | `1` | cua-driver `tools/list` extension shape |
| `capability_version` | `1` | Additive capability-token vocabulary |
| `mcp_protocol_version` | `2025-06-18` | MCP initialization protocol served to agent runtimes |
diff --git a/libs/cua-driver/contract/manifest.json b/libs/cua-driver/contract/manifest.json
index 720a580048..72e8022462 100644
--- a/libs/cua-driver/contract/manifest.json
+++ b/libs/cua-driver/contract/manifest.json
@@ -1,7 +1,7 @@
{
"generated_notice": "Generated by cua-contract-gen; do not edit by hand.",
"experimental": true,
- "contract_version": "0.4.0",
+ "contract_version": "0.5.0",
"tools_list_schema_version": "1",
"capability_version": "1",
"mcp_protocol_version": "2025-06-18",
@@ -181,6 +181,163 @@
"type": "object"
}
},
+ {
+ "name": "clipboard_read",
+ "description": "List available system clipboard types and optionally return privacy-sensitive plain text. Clipboard content is never retained in telemetry.",
+ "platforms": [
+ "macos",
+ "windows",
+ "linux"
+ ],
+ "capabilities": [
+ "clipboard.read",
+ "clipboard.types"
+ ],
+ "annotations": {
+ "read_only": true,
+ "destructive": false,
+ "idempotent": false,
+ "open_world": false
+ },
+ "schema_mode": "canonical_runtime",
+ "cursor_semantics": {
+ "action": "observe"
+ },
+ "input_schema": {
+ "additionalProperties": false,
+ "properties": {
+ "include_text": {
+ "default": false,
+ "description": "Return plain-text clipboard content in addition to the available types.\nClipboard content is privacy-sensitive and is never retained in telemetry.",
+ "type": "boolean"
+ },
+ "session": {
+ "description": "Optional session id.",
+ "type": "string"
+ }
+ },
+ "required": [],
+ "type": "object"
+ },
+ "success_output_schema": {
+ "additionalProperties": true,
+ "properties": {
+ "content_redacted_from_telemetry": {
+ "type": "boolean"
+ },
+ "privacy_sensitive": {
+ "type": "boolean"
+ },
+ "supported": {
+ "type": "boolean"
+ },
+ "text": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "types": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ }
+ },
+ "required": [
+ "supported",
+ "types",
+ "text",
+ "privacy_sensitive",
+ "content_redacted_from_telemetry"
+ ],
+ "type": "object"
+ }
+ },
+ {
+ "name": "clipboard_write",
+ "description": "Replace the system clipboard with exactly one value: plain text, an image from an absolute local path, or a file URL from an absolute local path. Returns the available types for read-back before paste.",
+ "platforms": [
+ "macos",
+ "windows",
+ "linux"
+ ],
+ "capabilities": [
+ "clipboard.write",
+ "clipboard.write.text",
+ "clipboard.write.image",
+ "clipboard.write.file_url",
+ "clipboard.types"
+ ],
+ "annotations": {
+ "read_only": false,
+ "destructive": true,
+ "idempotent": true,
+ "open_world": false
+ },
+ "schema_mode": "canonical_runtime",
+ "cursor_semantics": {
+ "action": "text"
+ },
+ "input_schema": {
+ "additionalProperties": false,
+ "properties": {
+ "file_path": {
+ "description": "Absolute path to a local file to place on the clipboard as a file URL.",
+ "type": "string"
+ },
+ "image_path": {
+ "description": "Absolute path to a local image to place on the clipboard.",
+ "type": "string"
+ },
+ "session": {
+ "description": "Optional session id.",
+ "type": "string"
+ },
+ "text": {
+ "description": "Plain text to place on the clipboard.",
+ "type": "string"
+ }
+ },
+ "required": [],
+ "type": "object"
+ },
+ "success_output_schema": {
+ "additionalProperties": true,
+ "properties": {
+ "content_redacted_from_telemetry": {
+ "type": "boolean"
+ },
+ "privacy_sensitive": {
+ "type": "boolean"
+ },
+ "supported": {
+ "type": "boolean"
+ },
+ "types": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "written_type": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "supported",
+ "written_type",
+ "types",
+ "privacy_sensitive",
+ "content_redacted_from_telemetry"
+ ],
+ "type": "object"
+ }
+ },
{
"name": "drag",
"description": "Drag between two absolute points in get_desktop_state coordinates.",
diff --git a/libs/cua-driver/python/src/cua_driver/_native.py b/libs/cua-driver/python/src/cua_driver/_native.py
index 478041bfa5..3026d68021 100644
--- a/libs/cua-driver/python/src/cua_driver/_native.py
+++ b/libs/cua-driver/python/src/cua_driver/_native.py
@@ -520,6 +520,10 @@ 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_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_clipboard_read() != 58238:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_write() != 8399:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
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_end_session() != 18486:
@@ -574,6 +578,10 @@ 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_method_cuadriversession_click() != 22303:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_read() != 23560:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_write() != 45732:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_close() != 58108:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_drag() != 5854:
@@ -1099,6 +1107,16 @@ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_click.argtypes = (
cua_driver._native_contract._UniffiRustBuffer,
)
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_click.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_clipboard_read.argtypes = (
+ ctypes.c_uint64,
+ cua_driver._native_contract._UniffiRustBuffer,
+)
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_clipboard_read.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_clipboard_write.argtypes = (
+ ctypes.c_uint64,
+ cua_driver._native_contract._UniffiRustBuffer,
+)
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_clipboard_write.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_drag.argtypes = (
ctypes.c_uint64,
cua_driver._native_contract._UniffiRustBuffer,
@@ -1232,6 +1250,16 @@ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriversession_click.argtypes = (
cua_driver._native_contract._UniffiRustBuffer,
)
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriversession_click.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriversession_clipboard_read.argtypes = (
+ ctypes.c_uint64,
+ cua_driver._native_contract._UniffiRustBuffer,
+)
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriversession_clipboard_read.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriversession_clipboard_write.argtypes = (
+ ctypes.c_uint64,
+ cua_driver._native_contract._UniffiRustBuffer,
+)
+_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriversession_clipboard_write.restype = ctypes.c_uint64
_UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriversession_close.argtypes = (
ctypes.c_uint64,
ctypes.POINTER(_UniffiRustCallStatus),
@@ -1439,6 +1467,12 @@ _UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_call_tool.restype = c
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_click.argtypes = (
)
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_click.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_read.argtypes = (
+)
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_read.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_write.argtypes = (
+)
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_write.restype = ctypes.c_uint16
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_drag.argtypes = (
)
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriver_drag.restype = ctypes.c_uint16
@@ -1520,6 +1554,12 @@ _UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_call_tool.rest
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_click.argtypes = (
)
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_click.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_read.argtypes = (
+)
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_read.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_write.argtypes = (
+)
+_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_write.restype = ctypes.c_uint16
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_close.argtypes = (
)
_UniffiLib.uniffi_cua_driver_sdk_checksum_method_cuadriversession_close.restype = ctypes.c_uint16
@@ -4068,6 +4108,10 @@ class _UniffiFfiConverterTypeSdkClientKind(_UniffiConverterRustBuffer):
+
+
+
+
@@ -4084,6 +4128,10 @@ class CuaDriverProtocol(typing.Protocol):
raise NotImplementedError
async def click(self, input: cua_driver._native_contract.ClickInput) -> ToolResult:
raise NotImplementedError
+ async def clipboard_read(self, input: cua_driver._native_contract.ClipboardReadInput) -> ToolResult:
+ raise NotImplementedError
+ async def clipboard_write(self, input: cua_driver._native_contract.ClipboardWriteInput) -> ToolResult:
+ raise NotImplementedError
async def drag(self, input: cua_driver._native_contract.DragInput) -> ToolResult:
raise NotImplementedError
async def end_session(self, input: cua_driver._native_contract.EndSessionInput) -> cua_driver._native_contract.EndSessionOutput:
@@ -4527,6 +4575,40 @@ class CuaDriver(CuaDriverProtocol):
_uniffi_lift_return,
_uniffi_error_converter,
)
+ async def clipboard_read(self, input: cua_driver._native_contract.ClipboardReadInput) -> ToolResult:
+
+ cua_driver._native_contract._UniffiFfiConverterTypeClipboardReadInput.check_lower(input)
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ cua_driver._native_contract._UniffiFfiConverterTypeClipboardReadInput.lower(input),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
+ _uniffi_error_converter = _UniffiFfiConverterTypeDriverError
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_clipboard_read(*_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 clipboard_write(self, input: cua_driver._native_contract.ClipboardWriteInput) -> ToolResult:
+
+ cua_driver._native_contract._UniffiFfiConverterTypeClipboardWriteInput.check_lower(input)
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ cua_driver._native_contract._UniffiFfiConverterTypeClipboardWriteInput.lower(input),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
+ _uniffi_error_converter = _UniffiFfiConverterTypeDriverError
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriver_clipboard_write(*_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 drag(self, input: cua_driver._native_contract.DragInput) -> ToolResult:
cua_driver._native_contract._UniffiFfiConverterTypeDragInput.check_lower(input)
@@ -4971,6 +5053,10 @@ class CuaDriverSessionProtocol(typing.Protocol):
raise NotImplementedError
async def click(self, input: cua_driver._native_contract.ClickInput) -> ToolResult:
raise NotImplementedError
+ async def clipboard_read(self, input: cua_driver._native_contract.ClipboardReadInput) -> ToolResult:
+ raise NotImplementedError
+ async def clipboard_write(self, input: cua_driver._native_contract.ClipboardWriteInput) -> ToolResult:
+ raise NotImplementedError
def close(self, ) -> None:
"""
Revoke the session-bound authority and release its native handle.
@@ -5077,6 +5163,40 @@ class CuaDriverSession(CuaDriverSessionProtocol):
_uniffi_lift_return,
_uniffi_error_converter,
)
+ async def clipboard_read(self, input: cua_driver._native_contract.ClipboardReadInput) -> ToolResult:
+
+ cua_driver._native_contract._UniffiFfiConverterTypeClipboardReadInput.check_lower(input)
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ cua_driver._native_contract._UniffiFfiConverterTypeClipboardReadInput.lower(input),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
+ _uniffi_error_converter = _UniffiFfiConverterTypeDriverError
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriversession_clipboard_read(*_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 clipboard_write(self, input: cua_driver._native_contract.ClipboardWriteInput) -> ToolResult:
+
+ cua_driver._native_contract._UniffiFfiConverterTypeClipboardWriteInput.check_lower(input)
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ cua_driver._native_contract._UniffiFfiConverterTypeClipboardWriteInput.lower(input),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeToolResult.lift
+ _uniffi_error_converter = _UniffiFfiConverterTypeDriverError
+ return await _uniffi_rust_call_async(
+ _UniffiLib.uniffi_cua_driver_sdk_fn_method_cuadriversession_clipboard_write(*_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 close(self, ) -> None:
"""
Revoke the session-bound authority and release its native handle.
diff --git a/libs/cua-driver/python/src/cua_driver/_native_contract.py b/libs/cua-driver/python/src/cua_driver/_native_contract.py
index ff855b2838..1f702a2f0f 100644
--- a/libs/cua-driver/python/src/cua_driver/_native_contract.py
+++ b/libs/cua-driver/python/src/cua_driver/_native_contract.py
@@ -1700,6 +1700,242 @@ class _UniffiFfiConverterTypeClickInput(_UniffiConverterRustBuffer):
_UniffiFfiConverterOptionalTypeClickButton.write(value.button, buf)
_UniffiFfiConverterOptionalUInt32.write(value.count, buf)
+class _UniffiFfiConverterBoolean:
+ @classmethod
+ def check_lower(cls, value):
+ return not not value
+
+ @classmethod
+ def lower(cls, value):
+ return 1 if value else 0
+
+ @staticmethod
+ def lift(value):
+ return value != 0
+
+ @classmethod
+ def read(cls, buf):
+ return cls.lift(buf.read_u8())
+
+ @classmethod
+ def write(cls, value, buf):
+ buf.write_u8(value)
+
+@dataclass
+class ClipboardReadInput:
+ def __init__(self, *, include_text:bool, session:typing.Optional[str]):
+ self.include_text = include_text
+ self.session = session
+
+
+
+
+ def __str__(self):
+ return "ClipboardReadInput(include_text={}, session={})".format(self.include_text, self.session)
+ def __eq__(self, other):
+ if self.include_text != other.include_text:
+ return False
+ if self.session != other.session:
+ return False
+ return True
+
+class _UniffiFfiConverterTypeClipboardReadInput(_UniffiConverterRustBuffer):
+ @staticmethod
+ def read(buf):
+ return ClipboardReadInput(
+ include_text=_UniffiFfiConverterBoolean.read(buf),
+ session=_UniffiFfiConverterOptionalString.read(buf),
+ )
+
+ @staticmethod
+ def check_lower(value):
+ _UniffiFfiConverterBoolean.check_lower(value.include_text)
+ _UniffiFfiConverterOptionalString.check_lower(value.session)
+
+ @staticmethod
+ def write(value, buf):
+ _UniffiFfiConverterBoolean.write(value.include_text, buf)
+ _UniffiFfiConverterOptionalString.write(value.session, buf)
+
+class _UniffiFfiConverterSequenceString(_UniffiConverterRustBuffer):
+ @classmethod
+ def check_lower(cls, value):
+ for item in value:
+ _UniffiFfiConverterString.check_lower(item)
+
+ @classmethod
+ def write(cls, value, buf):
+ items = len(value)
+ buf.write_i32(items)
+ for item in value:
+ _UniffiFfiConverterString.write(item, buf)
+
+ @classmethod
+ def read(cls, buf):
+ count = buf.read_i32()
+ if count < 0:
+ raise InternalError("Unexpected negative sequence length")
+
+ return [
+ _UniffiFfiConverterString.read(buf) for i in range(count)
+ ]
+
+@dataclass
+class ClipboardReadOutput:
+ def __init__(self, *, supported:bool, types:typing.List[str], text:typing.Optional[str], privacy_sensitive:bool, content_redacted_from_telemetry:bool):
+ self.supported = supported
+ self.types = types
+ self.text = text
+ self.privacy_sensitive = privacy_sensitive
+ self.content_redacted_from_telemetry = content_redacted_from_telemetry
+
+
+
+
+ def __str__(self):
+ return "ClipboardReadOutput(supported={}, types={}, text={}, privacy_sensitive={}, content_redacted_from_telemetry={})".format(self.supported, self.types, self.text, self.privacy_sensitive, self.content_redacted_from_telemetry)
+ def __eq__(self, other):
+ if self.supported != other.supported:
+ return False
+ if self.types != other.types:
+ return False
+ if self.text != other.text:
+ return False
+ if self.privacy_sensitive != other.privacy_sensitive:
+ return False
+ if self.content_redacted_from_telemetry != other.content_redacted_from_telemetry:
+ return False
+ return True
+
+class _UniffiFfiConverterTypeClipboardReadOutput(_UniffiConverterRustBuffer):
+ @staticmethod
+ def read(buf):
+ return ClipboardReadOutput(
+ supported=_UniffiFfiConverterBoolean.read(buf),
+ types=_UniffiFfiConverterSequenceString.read(buf),
+ text=_UniffiFfiConverterOptionalString.read(buf),
+ privacy_sensitive=_UniffiFfiConverterBoolean.read(buf),
+ content_redacted_from_telemetry=_UniffiFfiConverterBoolean.read(buf),
+ )
+
+ @staticmethod
+ def check_lower(value):
+ _UniffiFfiConverterBoolean.check_lower(value.supported)
+ _UniffiFfiConverterSequenceString.check_lower(value.types)
+ _UniffiFfiConverterOptionalString.check_lower(value.text)
+ _UniffiFfiConverterBoolean.check_lower(value.privacy_sensitive)
+ _UniffiFfiConverterBoolean.check_lower(value.content_redacted_from_telemetry)
+
+ @staticmethod
+ def write(value, buf):
+ _UniffiFfiConverterBoolean.write(value.supported, buf)
+ _UniffiFfiConverterSequenceString.write(value.types, buf)
+ _UniffiFfiConverterOptionalString.write(value.text, buf)
+ _UniffiFfiConverterBoolean.write(value.privacy_sensitive, buf)
+ _UniffiFfiConverterBoolean.write(value.content_redacted_from_telemetry, buf)
+
+@dataclass
+class ClipboardWriteInput:
+ def __init__(self, *, text:typing.Optional[str], image_path:typing.Optional[str], file_path:typing.Optional[str], session:typing.Optional[str]):
+ self.text = text
+ self.image_path = image_path
+ self.file_path = file_path
+ self.session = session
+
+
+
+
+ def __str__(self):
+ return "ClipboardWriteInput(text={}, image_path={}, file_path={}, session={})".format(self.text, self.image_path, self.file_path, self.session)
+ def __eq__(self, other):
+ if self.text != other.text:
+ return False
+ if self.image_path != other.image_path:
+ return False
+ if self.file_path != other.file_path:
+ return False
+ if self.session != other.session:
+ return False
+ return True
+
+class _UniffiFfiConverterTypeClipboardWriteInput(_UniffiConverterRustBuffer):
+ @staticmethod
+ def read(buf):
+ return ClipboardWriteInput(
+ text=_UniffiFfiConverterOptionalString.read(buf),
+ image_path=_UniffiFfiConverterOptionalString.read(buf),
+ file_path=_UniffiFfiConverterOptionalString.read(buf),
+ session=_UniffiFfiConverterOptionalString.read(buf),
+ )
+
+ @staticmethod
+ def check_lower(value):
+ _UniffiFfiConverterOptionalString.check_lower(value.text)
+ _UniffiFfiConverterOptionalString.check_lower(value.image_path)
+ _UniffiFfiConverterOptionalString.check_lower(value.file_path)
+ _UniffiFfiConverterOptionalString.check_lower(value.session)
+
+ @staticmethod
+ def write(value, buf):
+ _UniffiFfiConverterOptionalString.write(value.text, buf)
+ _UniffiFfiConverterOptionalString.write(value.image_path, buf)
+ _UniffiFfiConverterOptionalString.write(value.file_path, buf)
+ _UniffiFfiConverterOptionalString.write(value.session, buf)
+
+@dataclass
+class ClipboardWriteOutput:
+ def __init__(self, *, supported:bool, written_type:str, types:typing.List[str], privacy_sensitive:bool, content_redacted_from_telemetry:bool):
+ self.supported = supported
+ self.written_type = written_type
+ self.types = types
+ self.privacy_sensitive = privacy_sensitive
+ self.content_redacted_from_telemetry = content_redacted_from_telemetry
+
+
+
+
+ def __str__(self):
+ return "ClipboardWriteOutput(supported={}, written_type={}, types={}, privacy_sensitive={}, content_redacted_from_telemetry={})".format(self.supported, self.written_type, self.types, self.privacy_sensitive, self.content_redacted_from_telemetry)
+ def __eq__(self, other):
+ if self.supported != other.supported:
+ return False
+ if self.written_type != other.written_type:
+ return False
+ if self.types != other.types:
+ return False
+ if self.privacy_sensitive != other.privacy_sensitive:
+ return False
+ if self.content_redacted_from_telemetry != other.content_redacted_from_telemetry:
+ return False
+ return True
+
+class _UniffiFfiConverterTypeClipboardWriteOutput(_UniffiConverterRustBuffer):
+ @staticmethod
+ def read(buf):
+ return ClipboardWriteOutput(
+ supported=_UniffiFfiConverterBoolean.read(buf),
+ written_type=_UniffiFfiConverterString.read(buf),
+ types=_UniffiFfiConverterSequenceString.read(buf),
+ privacy_sensitive=_UniffiFfiConverterBoolean.read(buf),
+ content_redacted_from_telemetry=_UniffiFfiConverterBoolean.read(buf),
+ )
+
+ @staticmethod
+ def check_lower(value):
+ _UniffiFfiConverterBoolean.check_lower(value.supported)
+ _UniffiFfiConverterString.check_lower(value.written_type)
+ _UniffiFfiConverterSequenceString.check_lower(value.types)
+ _UniffiFfiConverterBoolean.check_lower(value.privacy_sensitive)
+ _UniffiFfiConverterBoolean.check_lower(value.content_redacted_from_telemetry)
+
+ @staticmethod
+ def write(value, buf):
+ _UniffiFfiConverterBoolean.write(value.supported, buf)
+ _UniffiFfiConverterString.write(value.written_type, buf)
+ _UniffiFfiConverterSequenceString.write(value.types, buf)
+ _UniffiFfiConverterBoolean.write(value.privacy_sensitive, buf)
+ _UniffiFfiConverterBoolean.write(value.content_redacted_from_telemetry, buf)
+
@dataclass
class CursorMotionOutput:
def __init__(self, *, start_handle:float, end_handle:float, arc_size:float, arc_flow:float, spring:float, glide_duration_ms:float, dwell_after_click_ms:float, idle_hide_ms:float, turn_radius:float):
@@ -2072,29 +2308,6 @@ class _UniffiFfiConverterTypeCursorAction(_UniffiConverterRustBuffer):
-class _UniffiFfiConverterSequenceString(_UniffiConverterRustBuffer):
- @classmethod
- def check_lower(cls, value):
- for item in value:
- _UniffiFfiConverterString.check_lower(item)
-
- @classmethod
- def write(cls, value, buf):
- items = len(value)
- buf.write_i32(items)
- for item in value:
- _UniffiFfiConverterString.write(item, buf)
-
- @classmethod
- def read(cls, buf):
- count = buf.read_i32()
- if count < 0:
- raise InternalError("Unexpected negative sequence length")
-
- return [
- _UniffiFfiConverterString.read(buf) for i in range(count)
- ]
-
class _UniffiFfiConverterUInt64(_UniffiConverterPrimitiveInt):
CLASS_NAME = "u64"
VALUE_MIN = 0
@@ -2338,27 +2551,6 @@ class _UniffiFfiConverterTypeElementSelector(_UniffiConverterRustBuffer):
_UniffiFfiConverterOptionalString.write(value.role, buf)
_UniffiFfiConverterOptionalString.write(value.label_contains, buf)
-class _UniffiFfiConverterBoolean:
- @classmethod
- def check_lower(cls, value):
- return not not value
-
- @classmethod
- def lower(cls, value):
- return 1 if value else 0
-
- @staticmethod
- def lift(value):
- return value != 0
-
- @classmethod
- def read(cls, buf):
- return cls.lift(buf.read_u8())
-
- @classmethod
- def write(cls, value, buf):
- buf.write_u8(value)
-
class _UniffiFfiConverterOptionalBoolean(_UniffiConverterRustBuffer):
@classmethod
def check_lower(cls, value):
@@ -4418,6 +4610,10 @@ __all__ = [
"ActionResult",
"BoundsExpectation",
"ClickInput",
+ "ClipboardReadInput",
+ "ClipboardReadOutput",
+ "ClipboardWriteInput",
+ "ClipboardWriteOutput",
"CursorMotionOutput",
"CursorPointOutput",
"CursorThemeOutput",
diff --git a/libs/cua-driver/python/tests/test_uniffi_loader.py b/libs/cua-driver/python/tests/test_uniffi_loader.py
index b470158243..3addb1ba4b 100644
--- a/libs/cua-driver/python/tests/test_uniffi_loader.py
+++ b/libs/cua-driver/python/tests/test_uniffi_loader.py
@@ -58,7 +58,7 @@ while True:
if request["method"] == "metadata":
result = {
"driver_version": "0.10.0",
- "contract_version": "0.4.0",
+ "contract_version": "0.5.0",
"tools_list_schema_version": "1",
"capability_version": "1",
"mcp_protocol_version": "2025-06-18",
@@ -142,7 +142,7 @@ except FileNotFoundError:
if request["method"] == "metadata":
result = {
"driver_version": "0.12.6",
- "contract_version": "0.4.0",
+ "contract_version": "0.5.0",
"tools_list_schema_version": "1",
"capability_version": "1",
"mcp_protocol_version": "2025-06-18",
diff --git a/libs/cua-driver/rust/Cargo.lock b/libs/cua-driver/rust/Cargo.lock
index 766293f8f1..da13c9fbcf 100644
--- a/libs/cua-driver/rust/Cargo.lock
+++ b/libs/cua-driver/rust/Cargo.lock
@@ -505,7 +505,16 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f"
dependencies = [
- "objc2",
+ "objc2 0.5.2",
+]
+
+[[package]]
+name = "block2"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5"
+dependencies = [
+ "objc2 0.6.4",
]
[[package]]
@@ -759,6 +768,33 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
+[[package]]
+name = "clipboard-rs"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d1c988a897ea030e32f0668c90b0192800e0c561b3d941fc366f9ad5a1bf26ba"
+dependencies = [
+ "clipboard-win",
+ "image",
+ "objc2 0.6.4",
+ "objc2-app-kit 0.3.2",
+ "objc2-foundation 0.3.2",
+ "objc2-ui-kit",
+ "windows 0.59.0",
+ "wl-clipboard-rs",
+ "x11rb",
+]
+
+[[package]]
+name = "clipboard-win"
+version = "5.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bde03770d3df201d4fb868f2c9c59e66a3e4e2bd06692a0fe701e7103c7e84d4"
+dependencies = [
+ "error-code",
+ "windows-win",
+]
+
[[package]]
name = "cobs"
version = "0.3.0"
@@ -927,6 +963,12 @@ version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
+[[package]]
+name = "crunchy"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
+
[[package]]
name = "crypto-common"
version = "0.1.7"
@@ -1045,7 +1087,7 @@ version = "0.14.2"
dependencies = [
"core-foundation",
"libc",
- "objc2-app-kit",
+ "objc2-app-kit 0.2.2",
"serde",
"serde_json",
"tempfile",
@@ -1146,6 +1188,16 @@ dependencies = [
"windows-sys 0.48.0",
]
+[[package]]
+name = "dispatch2"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"
+dependencies = [
+ "bitflags 2.11.1",
+ "objc2 0.6.4",
+]
+
[[package]]
name = "displaydoc"
version = "0.2.5"
@@ -1278,6 +1330,12 @@ dependencies = [
"windows-sys 0.61.2",
]
+[[package]]
+name = "error-code"
+version = "3.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dea2df4cf52843e0452895c455a1a2cfbb842a1e7329671acf418fdc53ed4c59"
+
[[package]]
name = "evdev"
version = "0.12.2"
@@ -1329,6 +1387,12 @@ version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6"
+[[package]]
+name = "fax"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a"
+
[[package]]
name = "fdeflate"
version = "0.3.7"
@@ -1354,6 +1418,12 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
+[[package]]
+name = "fixedbitset"
+version = "0.5.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
+
[[package]]
name = "flate2"
version = "1.1.9"
@@ -1668,6 +1738,17 @@ dependencies = [
"scroll",
]
+[[package]]
+name = "half"
+version = "2.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
+dependencies = [
+ "cfg-if",
+ "crunchy",
+ "zerocopy",
+]
+
[[package]]
name = "hash32"
version = "0.2.1"
@@ -1895,6 +1976,7 @@ dependencies = [
"moxcms",
"num-traits",
"png",
+ "tiff",
"zune-core",
"zune-jpeg",
]
@@ -2267,6 +2349,15 @@ dependencies = [
"minimal-lexical",
]
+[[package]]
+name = "nom"
+version = "8.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
+dependencies = [
+ "memchr",
+]
+
[[package]]
name = "nu-ansi-term"
version = "0.50.3"
@@ -2376,6 +2467,15 @@ dependencies = [
"objc2-encode",
]
+[[package]]
+name = "objc2"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f"
+dependencies = [
+ "objc2-encode",
+]
+
[[package]]
name = "objc2-app-kit"
version = "0.2.2"
@@ -2383,13 +2483,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff"
dependencies = [
"bitflags 2.11.1",
- "block2",
+ "block2 0.5.1",
+ "libc",
+ "objc2 0.5.2",
+ "objc2-core-data 0.2.2",
+ "objc2-core-image 0.2.2",
+ "objc2-foundation 0.2.2",
+ "objc2-quartz-core 0.2.2",
+]
+
+[[package]]
+name = "objc2-app-kit"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
+dependencies = [
+ "bitflags 2.11.1",
+ "block2 0.6.2",
"libc",
- "objc2",
- "objc2-core-data",
- "objc2-core-image",
- "objc2-foundation",
- "objc2-quartz-core",
+ "objc2 0.6.4",
+ "objc2-cloud-kit",
+ "objc2-core-data 0.3.2",
+ "objc2-core-foundation",
+ "objc2-core-graphics",
+ "objc2-core-image 0.3.2",
+ "objc2-core-text",
+ "objc2-core-video",
+ "objc2-foundation 0.3.2",
+ "objc2-quartz-core 0.3.2",
+]
+
+[[package]]
+name = "objc2-cloud-kit"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c"
+dependencies = [
+ "bitflags 2.11.1",
+ "objc2 0.6.4",
+ "objc2-foundation 0.3.2",
]
[[package]]
@@ -2399,9 +2531,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef"
dependencies = [
"bitflags 2.11.1",
- "block2",
- "objc2",
- "objc2-foundation",
+ "block2 0.5.1",
+ "objc2 0.5.2",
+ "objc2-foundation 0.2.2",
+]
+
+[[package]]
+name = "objc2-core-data"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa"
+dependencies = [
+ "bitflags 2.11.1",
+ "objc2 0.6.4",
+ "objc2-foundation 0.3.2",
+]
+
+[[package]]
+name = "objc2-core-foundation"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
+dependencies = [
+ "bitflags 2.11.1",
+ "dispatch2",
+ "objc2 0.6.4",
+]
+
+[[package]]
+name = "objc2-core-graphics"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807"
+dependencies = [
+ "bitflags 2.11.1",
+ "dispatch2",
+ "objc2 0.6.4",
+ "objc2-core-foundation",
+ "objc2-io-surface",
]
[[package]]
@@ -2410,12 +2577,57 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80"
dependencies = [
- "block2",
- "objc2",
- "objc2-foundation",
+ "block2 0.5.1",
+ "objc2 0.5.2",
+ "objc2-foundation 0.2.2",
"objc2-metal",
]
+[[package]]
+name = "objc2-core-image"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006"
+dependencies = [
+ "objc2 0.6.4",
+ "objc2-foundation 0.3.2",
+]
+
+[[package]]
+name = "objc2-core-location"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca347214e24bc973fc025fd0d36ebb179ff30536ed1f80252706db19ee452009"
+dependencies = [
+ "objc2 0.6.4",
+ "objc2-foundation 0.3.2",
+]
+
+[[package]]
+name = "objc2-core-text"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d"
+dependencies = [
+ "bitflags 2.11.1",
+ "objc2 0.6.4",
+ "objc2-core-foundation",
+ "objc2-core-graphics",
+]
+
+[[package]]
+name = "objc2-core-video"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6"
+dependencies = [
+ "bitflags 2.11.1",
+ "objc2 0.6.4",
+ "objc2-core-foundation",
+ "objc2-core-graphics",
+ "objc2-io-surface",
+]
+
[[package]]
name = "objc2-encode"
version = "4.1.0"
@@ -2429,9 +2641,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8"
dependencies = [
"bitflags 2.11.1",
- "block2",
+ "block2 0.5.1",
"libc",
- "objc2",
+ "objc2 0.5.2",
+]
+
+[[package]]
+name = "objc2-foundation"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
+dependencies = [
+ "bitflags 2.11.1",
+ "block2 0.6.2",
+ "libc",
+ "objc2 0.6.4",
+ "objc2-core-foundation",
+]
+
+[[package]]
+name = "objc2-io-surface"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d"
+dependencies = [
+ "bitflags 2.11.1",
+ "objc2 0.6.4",
+ "objc2-core-foundation",
]
[[package]]
@@ -2441,9 +2677,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6"
dependencies = [
"bitflags 2.11.1",
- "block2",
- "objc2",
- "objc2-foundation",
+ "block2 0.5.1",
+ "objc2 0.5.2",
+ "objc2-foundation 0.2.2",
]
[[package]]
@@ -2453,12 +2689,55 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a"
dependencies = [
"bitflags 2.11.1",
- "block2",
- "objc2",
- "objc2-foundation",
+ "block2 0.5.1",
+ "objc2 0.5.2",
+ "objc2-foundation 0.2.2",
"objc2-metal",
]
+[[package]]
+name = "objc2-quartz-core"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f"
+dependencies = [
+ "bitflags 2.11.1",
+ "objc2 0.6.4",
+ "objc2-core-foundation",
+ "objc2-foundation 0.3.2",
+]
+
+[[package]]
+name = "objc2-ui-kit"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22"
+dependencies = [
+ "bitflags 2.11.1",
+ "block2 0.6.2",
+ "objc2 0.6.4",
+ "objc2-cloud-kit",
+ "objc2-core-data 0.3.2",
+ "objc2-core-foundation",
+ "objc2-core-graphics",
+ "objc2-core-image 0.3.2",
+ "objc2-core-location",
+ "objc2-core-text",
+ "objc2-foundation 0.3.2",
+ "objc2-quartz-core 0.3.2",
+ "objc2-user-notifications",
+]
+
+[[package]]
+name = "objc2-user-notifications"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9df9128cbbfef73cda168416ccf7f837b62737d748333bfe9ab71c245d76613e"
+dependencies = [
+ "objc2 0.6.4",
+ "objc2-foundation 0.3.2",
+]
+
[[package]]
name = "once_cell"
version = "1.21.4"
@@ -2530,6 +2809,16 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "os_pipe"
+version = "1.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.2",
+]
+
[[package]]
name = "outref"
version = "0.5.2"
@@ -2571,6 +2860,17 @@ version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
+[[package]]
+name = "petgraph"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455"
+dependencies = [
+ "fixedbitset",
+ "hashbrown 0.15.5",
+ "indexmap",
+]
+
[[package]]
name = "phf"
version = "0.12.1"
@@ -2665,6 +2965,7 @@ dependencies = [
"atspi",
"base64",
"calloop",
+ "clipboard-rs",
"crossbeam-channel",
"cua-driver-contract",
"cua-driver-core",
@@ -2705,7 +3006,8 @@ dependencies = [
"anyhow",
"async-trait",
"base64",
- "block2",
+ "block2 0.5.1",
+ "clipboard-rs",
"core-foundation",
"core-graphics",
"cua-driver-contract",
@@ -2716,10 +3018,10 @@ dependencies = [
"image",
"indexmap",
"libc",
- "objc2",
- "objc2-app-kit",
- "objc2-foundation",
- "objc2-quartz-core",
+ "objc2 0.5.2",
+ "objc2-app-kit 0.2.2",
+ "objc2-foundation 0.2.2",
+ "objc2-quartz-core 0.2.2",
"pip-preview",
"screencapturekit",
"serde",
@@ -2739,6 +3041,7 @@ dependencies = [
"anyhow",
"async-trait",
"base64",
+ "clipboard-rs",
"cua-driver-contract",
"cua-driver-core",
"cursor-overlay",
@@ -2852,6 +3155,12 @@ version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0c5ccf5294c6ccd63a74f1565028353830a9c2f5eb0c682c355c471726a6e3f"
+[[package]]
+name = "quick-error"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
+
[[package]]
name = "quick-xml"
version = "0.39.4"
@@ -3635,6 +3944,20 @@ dependencies = [
"cfg-if",
]
+[[package]]
+name = "tiff"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52"
+dependencies = [
+ "fax",
+ "flate2",
+ "half",
+ "quick-error",
+ "weezl",
+ "zune-jpeg",
+]
+
[[package]]
name = "time"
version = "0.3.47"
@@ -3917,6 +4240,17 @@ dependencies = [
"tracing-log",
]
+[[package]]
+name = "tree_magic_mini"
+version = "3.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6"
+dependencies = [
+ "memchr",
+ "nom 8.0.0",
+ "petgraph",
+]
+
[[package]]
name = "ttf-parser"
version = "0.21.1"
@@ -4461,6 +4795,12 @@ dependencies = [
"nom 7.1.3",
]
+[[package]]
+name = "weezl"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
+
[[package]]
name = "winapi"
version = "0.3.9"
@@ -4493,6 +4833,16 @@ dependencies = [
"windows-targets 0.52.6",
]
+[[package]]
+name = "windows"
+version = "0.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f919aee0a93304be7f62e8e5027811bbba96bcb1de84d6618be56e43f8a32a1"
+dependencies = [
+ "windows-core 0.59.0",
+ "windows-targets 0.53.5",
+]
+
[[package]]
name = "windows"
version = "0.61.3"
@@ -4528,6 +4878,19 @@ dependencies = [
"windows-targets 0.52.6",
]
+[[package]]
+name = "windows-core"
+version = "0.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "810ce18ed2112484b0d4e15d022e5f598113e220c53e373fb31e67e21670c1ce"
+dependencies = [
+ "windows-implement 0.59.0",
+ "windows-interface 0.59.3",
+ "windows-result 0.3.4",
+ "windows-strings 0.3.1",
+ "windows-targets 0.53.5",
+]
+
[[package]]
name = "windows-core"
version = "0.61.2"
@@ -4563,6 +4926,17 @@ dependencies = [
"syn",
]
+[[package]]
+name = "windows-implement"
+version = "0.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "83577b051e2f49a058c308f17f273b570a6a758386fc291b5f6a934dd84e48c1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "windows-implement"
version = "0.60.2"
@@ -4646,6 +5020,15 @@ dependencies = [
"windows-targets 0.52.6",
]
+[[package]]
+name = "windows-strings"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319"
+dependencies = [
+ "windows-link 0.1.3",
+]
+
[[package]]
name = "windows-strings"
version = "0.4.2"
@@ -4706,13 +5089,30 @@ dependencies = [
"windows_aarch64_gnullvm 0.52.6",
"windows_aarch64_msvc 0.52.6",
"windows_i686_gnu 0.52.6",
- "windows_i686_gnullvm",
+ "windows_i686_gnullvm 0.52.6",
"windows_i686_msvc 0.52.6",
"windows_x86_64_gnu 0.52.6",
"windows_x86_64_gnullvm 0.52.6",
"windows_x86_64_msvc 0.52.6",
]
+[[package]]
+name = "windows-targets"
+version = "0.53.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
+dependencies = [
+ "windows-link 0.2.1",
+ "windows_aarch64_gnullvm 0.53.1",
+ "windows_aarch64_msvc 0.53.1",
+ "windows_i686_gnu 0.53.1",
+ "windows_i686_gnullvm 0.53.1",
+ "windows_i686_msvc 0.53.1",
+ "windows_x86_64_gnu 0.53.1",
+ "windows_x86_64_gnullvm 0.53.1",
+ "windows_x86_64_msvc 0.53.1",
+]
+
[[package]]
name = "windows-threading"
version = "0.1.0"
@@ -4722,6 +5122,15 @@ dependencies = [
"windows-link 0.1.3",
]
+[[package]]
+name = "windows-win"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "58e23e33622b3b52f948049acbec9bcc34bf6e26d74176b88941f213c75cf2dc"
+dependencies = [
+ "error-code",
+]
+
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
@@ -4734,6 +5143,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
+
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
@@ -4746,6 +5161,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
+
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
@@ -4758,12 +5179,24 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+[[package]]
+name = "windows_i686_gnu"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
+
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
+
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
@@ -4776,6 +5209,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+[[package]]
+name = "windows_i686_msvc"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
+
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
@@ -4788,6 +5227,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
+
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
@@ -4800,6 +5245,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
+
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
@@ -4812,6 +5263,12 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.53.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
+
[[package]]
name = "winnow"
version = "0.7.15"
@@ -4934,6 +5391,24 @@ dependencies = [
"wasmparser",
]
+[[package]]
+name = "wl-clipboard-rs"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e9651471a32e87d96ef3a127715382b2d11cc7c8bb9822ded8a7cc94072eb0a3"
+dependencies = [
+ "libc",
+ "log",
+ "os_pipe",
+ "rustix",
+ "thiserror 2.0.18",
+ "tree_magic_mini",
+ "wayland-backend",
+ "wayland-client",
+ "wayland-protocols",
+ "wayland-protocols-wlr",
+]
+
[[package]]
name = "writeable"
version = "0.6.3"
diff --git a/libs/cua-driver/rust/Skills/cua-driver/MACOS.md b/libs/cua-driver/rust/Skills/cua-driver/MACOS.md
index 11320fce7b..da67519cb4 100644
--- a/libs/cua-driver/rust/Skills/cua-driver/MACOS.md
+++ b/libs/cua-driver/rust/Skills/cua-driver/MACOS.md
@@ -389,8 +389,10 @@ UIKit renderer the real keyboard focus the AX layer can't, then types
into the now-focused field. Read `x,y` straight off the screenshot in
the `get_window_state` response (same convention as `click`). This is
the one-call replacement for the old two-step "pixel-click then
-`type_text`" — and you do **not** reach for a clipboard + `Cmd+V`
-dance.
+`type_text`". Prefer this direct route. If an application only accepts paste,
+call `clipboard_write`, then `clipboard_read` and verify the returned types
+(and text when applicable) **before** selecting or replacing existing editor
+content. Send Cmd+V only after that read-back succeeds.
0. **If the control is CLOSED, open it first.** A px focus-click won't
reliably _open and focus_ a closed control (a search button, a
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/desktop.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/desktop.rs
index fffcdea163..d22ef92cfd 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/desktop.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/desktop.rs
@@ -8,11 +8,11 @@
//! do not replace the richer platform-owned runtime schemas.
use crate::{
- ActionResult, ClickInput, CursorAction, CursorPositionOutput, CursorSemantics,
- DesktopStateOutput, DragInput, GetCursorPositionInput, GetDesktopStateInput,
- GetScreenSizeInput, HotkeyInput, MoveCursorInput, Platform, PressKeyInput, SchemaMode,
- ScreenSizeOutput, ScrollInput, ToolAnnotations, ToolContract, ToolInput, ToolOutput,
- TypeTextInput,
+ ActionResult, ClickInput, ClipboardReadInput, ClipboardReadOutput, ClipboardWriteInput,
+ ClipboardWriteOutput, CursorAction, CursorPositionOutput, CursorSemantics, DesktopStateOutput,
+ DragInput, GetCursorPositionInput, GetDesktopStateInput, GetScreenSizeInput, HotkeyInput,
+ MoveCursorInput, Platform, PressKeyInput, SchemaMode, ScreenSizeOutput, ScrollInput,
+ ToolAnnotations, ToolContract, ToolInput, ToolOutput, TypeTextInput,
};
const ALL_PLATFORMS: [Platform; 3] = [Platform::Macos, Platform::Windows, Platform::Linux];
@@ -26,6 +26,8 @@ pub fn contracts() -> Vec<ToolContract> {
click(),
drag(),
scroll(),
+ clipboard_read(),
+ clipboard_write(),
type_text(),
press_key(),
hotkey(),
@@ -80,6 +82,40 @@ pub(crate) fn validate_list_windows_output(value: serde_json::Value) -> Result<(
Ok(())
}
+fn clipboard_read() -> ToolContract {
+ let mut contract = contract::<ClipboardReadInput, ClipboardReadOutput>(
+ "clipboard_read",
+ "List available system clipboard types and optionally return privacy-sensitive plain text. Clipboard content is never retained in telemetry.",
+ &["clipboard.read", "clipboard.types"],
+ ToolAnnotations {
+ read_only: true,
+ destructive: false,
+ idempotent: false,
+ open_world: false,
+ },
+ CursorAction::Observe,
+ );
+ contract.schema_mode = SchemaMode::CanonicalRuntime;
+ contract
+}
+
+fn clipboard_write() -> ToolContract {
+ let mut contract = contract::<ClipboardWriteInput, ClipboardWriteOutput>(
+ "clipboard_write",
+ "Replace the system clipboard with exactly one value: plain text, an image from an absolute local path, or a file URL from an absolute local path. Returns the available types for read-back before paste.",
+ &["clipboard.write", "clipboard.write.text", "clipboard.write.image", "clipboard.write.file_url", "clipboard.types"],
+ ToolAnnotations {
+ read_only: false,
+ destructive: true,
+ idempotent: true,
+ open_world: false,
+ },
+ CursorAction::Text,
+ );
+ contract.schema_mode = SchemaMode::CanonicalRuntime;
+ contract
+}
+
fn contract<I: ToolInput, O: ToolOutput>(
name: &str,
description: &str,
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs
index 49986da6c9..54806c5c03 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs
@@ -509,6 +509,48 @@ impl ToolInput for TypeTextInput {
const TOOL_NAME: &'static str = "type_text";
}
+#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, uniffi::Record)]
+#[serde(deny_unknown_fields)]
+pub struct ClipboardReadInput {
+ /// Return plain-text clipboard content in addition to the available types.
+ /// Clipboard content is privacy-sensitive and is never retained in telemetry.
+ #[serde(default)]
+ pub include_text: bool,
+ /// Optional session id.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schemars(schema_with = "string_schema")]
+ pub session: Option<String>,
+}
+
+impl ToolInput for ClipboardReadInput {
+ const TOOL_NAME: &'static str = "clipboard_read";
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, uniffi::Record)]
+#[serde(deny_unknown_fields)]
+pub struct ClipboardWriteInput {
+ /// Plain text to place on the clipboard.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schemars(schema_with = "string_schema")]
+ pub text: Option<String>,
+ /// Absolute path to a local image to place on the clipboard.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schemars(schema_with = "string_schema")]
+ pub image_path: Option<String>,
+ /// Absolute path to a local file to place on the clipboard as a file URL.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schemars(schema_with = "string_schema")]
+ pub file_path: Option<String>,
+ /// Optional session id.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[schemars(schema_with = "string_schema")]
+ pub session: Option<String>,
+}
+
+impl ToolInput for ClipboardWriteInput {
+ const TOOL_NAME: &'static str = "clipboard_write";
+}
+
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, uniffi::Record)]
#[serde(deny_unknown_fields)]
pub struct PressKeyInput {
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs
index 8c598f904f..0629649750 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs
@@ -27,21 +27,21 @@ pub use cursor::{
CursorSemantics, CursorTarget, CursorThemeSelection,
};
pub use inputs::{
- CaptureScope, ClickButton, ClickInput, DesktopScope, DragInput, EndSessionInput,
- EscalateSessionInput, EscalationReason, GetAgentCursorStateInput, GetCursorPositionInput,
- GetDesktopStateInput, GetScreenSizeInput, GetSessionStateInput, HotkeyInput, MoveCursorInput,
- PressKeyInput, ScrollBy, ScrollDirection, ScrollInput, SetAgentCursorEnabledInput,
- SetAgentCursorMotionInput, SetAgentCursorThemeInput, StartSessionInput, ToolInput,
- TypeTextInput,
+ CaptureScope, ClickButton, ClickInput, ClipboardReadInput, ClipboardWriteInput, DesktopScope,
+ DragInput, EndSessionInput, EscalateSessionInput, EscalationReason, GetAgentCursorStateInput,
+ GetCursorPositionInput, GetDesktopStateInput, GetScreenSizeInput, GetSessionStateInput,
+ HotkeyInput, MoveCursorInput, PressKeyInput, ScrollBy, ScrollDirection, ScrollInput,
+ SetAgentCursorEnabledInput, SetAgentCursorMotionInput, SetAgentCursorThemeInput,
+ StartSessionInput, ToolInput, TypeTextInput,
};
pub use outputs::{
ActionDelivery, ActionDeliveryMode, ActionEffect, ActionEscalation, ActionEscalationReason,
ActionEscalationTarget, ActionEvidence, ActionEvidenceKind, ActionResult,
- ActionResultValidationError, ActionRoute, CursorMotionOutput, CursorPointOutput,
- CursorPositionOutput, CursorThemeOutput, CursorVisualOutput, DesktopStateOutput,
- EffectiveScope, EndSessionOutput, GetAgentCursorStateOutput, ScreenSizeOutput,
- SessionStateOutput, SetAgentCursorEnabledOutput, SetAgentCursorMotionOutput,
- SetAgentCursorThemeOutput, StartSessionOutput, ToolOutput,
+ ActionResultValidationError, ActionRoute, ClipboardReadOutput, ClipboardWriteOutput,
+ CursorMotionOutput, CursorPointOutput, CursorPositionOutput, CursorThemeOutput,
+ CursorVisualOutput, DesktopStateOutput, EffectiveScope, EndSessionOutput,
+ GetAgentCursorStateOutput, ScreenSizeOutput, SessionStateOutput, SetAgentCursorEnabledOutput,
+ SetAgentCursorMotionOutput, SetAgentCursorThemeOutput, StartSessionOutput, ToolOutput,
};
pub use verification::{
BoundsExpectation, ElementPredicate, ElementSelector, PredicateOutcome, StatePredicate,
@@ -56,7 +56,7 @@ pub const TOOLS_LIST_SCHEMA_VERSION: &str = "1";
pub const CAPABILITY_VERSION: &str = "1";
/// Shape version for the checked-in generated client contract.
-pub const CONTRACT_VERSION: &str = "0.4.0";
+pub const CONTRACT_VERSION: &str = "0.5.0";
/// MCP protocol version used by current cua-driver clients.
pub const MCP_PROTOCOL_VERSION: &str = "2025-06-18";
@@ -291,7 +291,7 @@ mod tests {
let mut sorted = names.clone();
sorted.sort_unstable();
assert_eq!(names, sorted);
- assert_eq!(manifest.contract_version, "0.4.0");
+ assert_eq!(manifest.contract_version, "0.5.0");
assert!(manifest.experimental);
}
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs
index de90b7f2bc..468c764a36 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs
@@ -263,6 +263,52 @@ pub struct CursorPositionOutput {
impl ToolOutput for CursorPositionOutput {}
+#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq, uniffi::Record)]
+pub struct ClipboardReadOutput {
+ pub supported: bool,
+ pub types: Vec<String>,
+ #[schemars(required, schema_with = "nullable_string_schema")]
+ pub text: Option<String>,
+ pub privacy_sensitive: bool,
+ pub content_redacted_from_telemetry: bool,
+}
+
+impl ToolOutput for ClipboardReadOutput {
+ fn validate(&self) -> Result<(), String> {
+ if !self.supported {
+ return Err("successful clipboard reads must be supported".into());
+ }
+ if !self.privacy_sensitive || !self.content_redacted_from_telemetry {
+ return Err("clipboard privacy metadata must remain enabled".into());
+ }
+ Ok(())
+ }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq, uniffi::Record)]
+pub struct ClipboardWriteOutput {
+ pub supported: bool,
+ pub written_type: String,
+ pub types: Vec<String>,
+ pub privacy_sensitive: bool,
+ pub content_redacted_from_telemetry: bool,
+}
+
+impl ToolOutput for ClipboardWriteOutput {
+ fn validate(&self) -> Result<(), String> {
+ if !self.supported {
+ return Err("successful clipboard writes must be supported".into());
+ }
+ if !matches!(self.written_type.as_str(), "text" | "image" | "file_url") {
+ return Err("written_type must be text, image, or file_url".into());
+ }
+ if !self.privacy_sensitive || !self.content_redacted_from_telemetry {
+ return Err("clipboard privacy metadata must remain enabled".into());
+ }
+ Ok(())
+ }
+}
+
#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, PartialEq, Eq, uniffi::Enum)]
#[serde(rename_all = "snake_case")]
pub enum ActionEffect {
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs
index bb10b41591..34afab88bf 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/authorization.rs
@@ -576,22 +576,30 @@ pub const ENFORCEMENT_ADAPTERS: &[EnforcementAdapterDescriptor] = &[
EnforcementAdapterDescriptor {
id: "clipboard",
operations: &["clipboard_read", "clipboard_write"],
- state: RiskEnforcement::NotExposed,
- risk_class: RiskClass::Unclassified,
+ state: RiskEnforcement::Active,
+ risk_class: RiskClass::R2,
resource_kind: "system_clipboard",
- scope_keys: &[],
- grant_type: None,
- idle_ttl_seconds: None,
- absolute_ttl_seconds: None,
- authorization_requirement: "required_before_exposure",
- revocation_triggers: &[],
- refusal_code: None,
- authorization_source: "capability_not_exposed",
- enforcement_by_mode: AdapterEnforcement::uniform(RiskEnforcement::NotExposed),
+ scope_keys: &[
+ "daemon_generation",
+ "public_session",
+ "operation",
+ "content_kind",
+ "permission_mode",
+ "managed_policy_sha256",
+ "user_policy_sha256",
+ ],
+ grant_type: Some("protected_resource_grant"),
+ idle_ttl_seconds: Some(30 * 60),
+ absolute_ttl_seconds: Some(8 * 60 * 60),
+ authorization_requirement: "manifest_only_in_bounded",
+ revocation_triggers: SESSION_REVOCATION,
+ refusal_code: Some("authorization_required"),
+ authorization_source: "built_in_standard; manifest_in_bounded; trusted_unrestricted_mode",
+ enforcement_by_mode: AdapterEnforcement::uniform(RiskEnforcement::Active),
behavior_by_mode: AdapterModeBehavior::new(
- ModeBehavior::Deny,
- ModeBehavior::Deny,
- ModeBehavior::Deny,
+ ModeBehavior::Allow,
+ ModeBehavior::Manifest,
+ ModeBehavior::Allow,
),
},
EnforcementAdapterDescriptor {
@@ -713,6 +721,10 @@ pub fn enforcement_adapters_for_call(
add("desktop_input");
}
+ if matches!(tool, "clipboard_read" | "clipboard_write") {
+ add("clipboard");
+ }
+
let writes_screenshot = matches!(tool, "get_desktop_state" | "get_window_state")
&& args
.get("screenshot_out_file")
@@ -726,6 +738,9 @@ pub fn enforcement_adapters_for_call(
| "stop_recording"
| "replay_trajectory"
) || writes_screenshot
+ || (tool == "clipboard_write"
+ && (args.get("image_path").and_then(Value::as_str).is_some()
+ || args.get("file_path").and_then(Value::as_str).is_some()))
|| (tool == "install_ffmpeg" && args.get("confirm").and_then(Value::as_bool) == Some(true))
{
add("file_transfer_and_output");
@@ -837,10 +852,13 @@ pub fn advertised_risk_for(tool: &str) -> RiskAssessment {
| "set_agent_cursor_motion"
| "set_agent_cursor_theme" => RiskClass::R1,
+ "clipboard_write" => RiskClass::R1,
+
// Surfaces that can reveal or control sensitive local/authenticated
// state. Active adapters still decide their exact resource scope at
// the canonical registry boundary before platform dispatch.
"zoom"
+ | "clipboard_read"
| "list_apps"
| "list_windows"
| "debug_window_info"
@@ -959,7 +977,8 @@ pub fn classify_tool_call(tool: &str, args: &Value) -> RiskAssessment {
| "debug_window_info"
| "get_browser_state"
| "escalate_session"
- | "zoom" => RiskAssessment {
+ | "zoom"
+ | "clipboard_read" => RiskAssessment {
class: RiskClass::R2,
enforcement: RiskEnforcement::Active,
operation_sensitive: true,
@@ -982,6 +1001,17 @@ pub fn classify_tool_call(tool: &str, args: &Value) -> RiskAssessment {
enforcement: RiskEnforcement::Active,
operation_sensitive: true,
},
+ "clipboard_write" => RiskAssessment {
+ class: if args.get("image_path").and_then(Value::as_str).is_some()
+ || args.get("file_path").and_then(Value::as_str).is_some()
+ {
+ RiskClass::R3
+ } else {
+ RiskClass::R1
+ },
+ enforcement: RiskEnforcement::Active,
+ operation_sensitive: true,
+ },
"install_ffmpeg" => {
let confirmed = args.get("confirm").and_then(Value::as_bool) == Some(true);
RiskAssessment {
@@ -1489,6 +1519,29 @@ mod tests {
}
}
+ #[test]
+ fn clipboard_risk_distinguishes_reads_text_writes_and_local_files() {
+ let read = classify_tool_call("clipboard_read", &serde_json::json!({}));
+ assert_eq!(read.class, RiskClass::R2);
+ assert_eq!(read.enforcement, RiskEnforcement::Active);
+
+ let text = classify_tool_call(
+ "clipboard_write",
+ &serde_json::json!({"text": "private content"}),
+ );
+ assert_eq!(text.class, RiskClass::R1);
+ assert_eq!(text.enforcement, RiskEnforcement::Active);
+
+ for args in [
+ serde_json::json!({"image_path": "/tmp/private-content"}),
+ serde_json::json!({"file_path": "/tmp/private-content"}),
+ ] {
+ let file = classify_tool_call("clipboard_write", &args);
+ assert_eq!(file.class, RiskClass::R3);
+ assert_eq!(file.enforcement, RiskEnforcement::Active);
+ }
+ }
+
#[test]
fn verify_state_is_bounded_observation_not_file_egress() {
for args in [
@@ -1563,6 +1616,7 @@ mod tests {
"process_control",
"os_permission_prompt",
"driver_configuration",
+ "clipboard",
]
);
assert_eq!(
@@ -1571,7 +1625,7 @@ mod tests {
);
assert_eq!(
adapter_ids_with_state(RiskEnforcement::NotExposed),
- vec!["clipboard", "devices", "shell_and_network"]
+ vec!["devices", "shell_and_network"]
);
assert_eq!(
adapter_ids_with_state_for_mode(PermissionMode::Standard, RiskEnforcement::Active),
@@ -1586,6 +1640,7 @@ mod tests {
"process_control",
"os_permission_prompt",
"driver_configuration",
+ "clipboard",
]
);
@@ -1616,6 +1671,7 @@ mod tests {
"browser_consequential_action",
"browser_bound_input",
"driver_configuration",
+ "clipboard",
] {
assert_eq!(behavior(id, PermissionMode::Standard), ModeBehavior::Allow);
assert_eq!(
@@ -1723,6 +1779,23 @@ mod tests {
ids("set_config", serde_json::json!({})),
vec!["driver_configuration"]
);
+ assert_eq!(
+ ids("clipboard_read", serde_json::json!({})),
+ vec!["clipboard"]
+ );
+ assert_eq!(
+ ids("clipboard_write", serde_json::json!({"text": "private"})),
+ vec!["clipboard"]
+ );
+ for args in [
+ serde_json::json!({"image_path": "/tmp/private-content"}),
+ serde_json::json!({"file_path": "/tmp/private-content"}),
+ ] {
+ assert_eq!(
+ ids("clipboard_write", args),
+ vec!["clipboard", "file_transfer_and_output"]
+ );
+ }
}
#[test]
@@ -1740,7 +1813,8 @@ mod tests {
"browser_bound_input",
"process_control",
"os_permission_prompt",
- "driver_configuration"
+ "driver_configuration",
+ "clipboard"
])
);
assert_eq!(
@@ -1749,7 +1823,7 @@ mod tests {
);
assert_eq!(
status["not_exposed_risk_enforcement"],
- serde_json::json!(["clipboard", "devices", "shell_and_network"])
+ serde_json::json!(["devices", "shell_and_network"])
);
assert_eq!(
status["effective_active_risk_enforcement"],
@@ -1763,7 +1837,8 @@ mod tests {
"browser_bound_input",
"process_control",
"os_permission_prompt",
- "driver_configuration"
+ "driver_configuration",
+ "clipboard"
])
);
assert_eq!(
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/clipboard.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/clipboard.rs
new file mode 100644
index 0000000000..613812b04d
--- /dev/null
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/clipboard.rs
@@ -0,0 +1,303 @@
+//! Cross-platform clipboard tools and platform backend seam.
+
+use std::sync::Arc;
+
+use async_trait::async_trait;
+use cua_driver_contract::{
+ ClipboardReadInput, ClipboardReadOutput, ClipboardWriteInput, ClipboardWriteOutput,
+};
+use serde_json::Value;
+
+use crate::{
+ protocol::ToolResult,
+ tool::{Tool, ToolDef, ToolRegistry},
+ tool_args::parse_typed_input,
+};
+
+pub trait ClipboardBackend: Send + Sync {
+ fn available_formats(&self) -> Result<Vec<String>, String>;
+ fn read_text(&self) -> Result<Option<String>, String>;
+ fn write_text(&self, text: String) -> Result<(), String>;
+ fn write_image(&self, absolute_path: &str) -> Result<(), String>;
+ fn write_file_url(&self, absolute_path: &str) -> Result<(), String>;
+}
+
+pub fn register_clipboard_tools(registry: &mut ToolRegistry, backend: Arc<dyn ClipboardBackend>) {
+ registry.register(Box::new(ClipboardReadTool {
+ backend: backend.clone(),
+ }));
+ registry.register(Box::new(ClipboardWriteTool { backend }));
+}
+
+fn contract_def(name: &str) -> ToolDef {
+ let contract = cua_driver_contract::tool_contract(name)
+ .unwrap_or_else(|| panic!("missing {name} clipboard contract"));
+ ToolDef::from_contract(&contract)
+}
+
+fn normalize_types(mut types: Vec<String>) -> Vec<String> {
+ types.sort();
+ types.dedup();
+ types
+}
+
+fn unavailable(operation: &str, error: impl Into<String>) -> ToolResult {
+ let message = error.into();
+ ToolResult::error(format!("Clipboard {operation} is unavailable: {message}")).with_structured(
+ serde_json::json!({
+ "supported": false,
+ "capability": format!("clipboard.{operation}"),
+ "status": "unavailable",
+ "error_code": "clipboard_unavailable",
+ "privacy_sensitive": true,
+ "content_redacted_from_telemetry": true,
+ }),
+ )
+}
+
+pub struct ClipboardReadTool {
+ backend: Arc<dyn ClipboardBackend>,
+}
+
+static READ_DEF: std::sync::OnceLock<ToolDef> = std::sync::OnceLock::new();
+
+#[async_trait]
+impl Tool for ClipboardReadTool {
+ fn def(&self) -> &ToolDef {
+ READ_DEF.get_or_init(|| contract_def("clipboard_read"))
+ }
+
+ async fn invoke(&self, args: Value) -> ToolResult {
+ let input = match parse_typed_input::<ClipboardReadInput>("clipboard_read", args) {
+ Ok(input) => input,
+ Err(result) => return result,
+ };
+ let backend = self.backend.clone();
+ let result = tokio::task::spawn_blocking(move || {
+ let types = normalize_types(backend.available_formats()?);
+ let text = if input.include_text {
+ backend.read_text()?
+ } else {
+ None
+ };
+ Ok::<_, String>((types, text))
+ })
+ .await;
+
+ let (types, text) = match result {
+ Ok(Ok(value)) => value,
+ Ok(Err(error)) => return unavailable("read", error),
+ Err(error) => return unavailable("read", format!("worker failed: {error}")),
+ };
+ let output = ClipboardReadOutput {
+ supported: true,
+ types,
+ text,
+ privacy_sensitive: true,
+ content_redacted_from_telemetry: true,
+ };
+ ToolResult::text(format!(
+ "Clipboard read succeeded ({} available type(s); text {}).",
+ output.types.len(),
+ if input.include_text {
+ "requested"
+ } else {
+ "omitted"
+ }
+ ))
+ .with_structured(serde_json::to_value(output).expect("clipboard output serializes"))
+ }
+}
+
+pub struct ClipboardWriteTool {
+ backend: Arc<dyn ClipboardBackend>,
+}
+
+static WRITE_DEF: std::sync::OnceLock<ToolDef> = std::sync::OnceLock::new();
+
+#[async_trait]
+impl Tool for ClipboardWriteTool {
+ fn def(&self) -> &ToolDef {
+ WRITE_DEF.get_or_init(|| contract_def("clipboard_write"))
+ }
+
+ async fn invoke(&self, args: Value) -> ToolResult {
+ let input = match parse_typed_input::<ClipboardWriteInput>("clipboard_write", args) {
+ Ok(input) => input,
+ Err(result) => return result,
+ };
+ let supplied = usize::from(input.text.is_some())
+ + usize::from(input.image_path.is_some())
+ + usize::from(input.file_path.is_some());
+ if supplied != 1 {
+ return ToolResult::error(
+ "clipboard_write requires exactly one of text, image_path, or file_path",
+ );
+ }
+
+ let backend = self.backend.clone();
+ let result = tokio::task::spawn_blocking(move || {
+ let written_type = if let Some(text) = input.text {
+ backend.write_text(text)?;
+ "text"
+ } else if let Some(path) = input.image_path {
+ backend.write_image(&path)?;
+ "image"
+ } else if let Some(path) = input.file_path {
+ backend.write_file_url(&path)?;
+ "file_url"
+ } else {
+ unreachable!("exactly one clipboard value was checked above")
+ };
+ let types = normalize_types(backend.available_formats()?);
+ Ok::<_, String>((written_type, types))
+ })
+ .await;
+
+ let (written_type, types) = match result {
+ Ok(Ok(value)) => value,
+ Ok(Err(error)) => return unavailable("write", error),
+ Err(error) => return unavailable("write", format!("worker failed: {error}")),
+ };
+ let output = ClipboardWriteOutput {
+ supported: true,
+ written_type: written_type.into(),
+ types,
+ privacy_sensitive: true,
+ content_redacted_from_telemetry: true,
+ };
+ ToolResult::text(format!(
+ "Clipboard write succeeded as {written_type}; inspect structuredContent.types before paste."
+ ))
+ .with_structured(serde_json::to_value(output).expect("clipboard output serializes"))
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use std::sync::Mutex;
+
+ #[derive(Default)]
+ struct FakeClipboard {
+ value: Mutex<Option<(String, String)>>,
+ }
+
+ struct UnavailableClipboard;
+
+ impl ClipboardBackend for UnavailableClipboard {
+ fn available_formats(&self) -> Result<Vec<String>, String> {
+ Err("no display clipboard provider".into())
+ }
+
+ fn read_text(&self) -> Result<Option<String>, String> {
+ Err("no display clipboard provider".into())
+ }
+
+ fn write_text(&self, _text: String) -> Result<(), String> {
+ Err("no display clipboard provider".into())
+ }
+
+ fn write_image(&self, _absolute_path: &str) -> Result<(), String> {
+ Err("no display clipboard provider".into())
+ }
+
+ fn write_file_url(&self, _absolute_path: &str) -> Result<(), String> {
+ Err("no display clipboard provider".into())
+ }
+ }
+
+ impl ClipboardBackend for FakeClipboard {
+ fn available_formats(&self) -> Result<Vec<String>, String> {
+ Ok(self
+ .value
+ .lock()
+ .unwrap()
+ .as_ref()
+ .map(|(kind, _)| vec![kind.clone(), kind.clone()])
+ .unwrap_or_default())
+ }
+
+ fn read_text(&self) -> Result<Option<String>, String> {
+ Ok(self
+ .value
+ .lock()
+ .unwrap()
+ .as_ref()
+ .filter(|(kind, _)| kind == "text/plain")
+ .map(|(_, value)| value.clone()))
+ }
+
+ fn write_text(&self, text: String) -> Result<(), String> {
+ *self.value.lock().unwrap() = Some(("text/plain".into(), text));
+ Ok(())
+ }
+
+ fn write_image(&self, absolute_path: &str) -> Result<(), String> {
+ *self.value.lock().unwrap() = Some(("image/png".into(), absolute_path.into()));
+ Ok(())
+ }
+
+ fn write_file_url(&self, absolute_path: &str) -> Result<(), String> {
+ *self.value.lock().unwrap() = Some(("text/uri-list".into(), absolute_path.into()));
+ Ok(())
+ }
+ }
+
+ #[tokio::test]
+ async fn text_round_trip_returns_types_and_privacy_metadata() {
+ let backend: Arc<dyn ClipboardBackend> = Arc::new(FakeClipboard::default());
+ let write = ClipboardWriteTool {
+ backend: backend.clone(),
+ }
+ .invoke(serde_json::json!({"text": "private value"}))
+ .await;
+ assert_ne!(write.is_error, Some(true));
+ assert_eq!(
+ write.structured_content.as_ref().unwrap()["types"],
+ serde_json::json!(["text/plain"])
+ );
+
+ let read = ClipboardReadTool { backend }
+ .invoke(serde_json::json!({"include_text": true}))
+ .await;
+ let output = read.structured_content.unwrap();
+ assert_eq!(output["text"], "private value");
+ assert_eq!(output["privacy_sensitive"], true);
+ assert_eq!(output["content_redacted_from_telemetry"], true);
+ }
+
+ #[tokio::test]
+ async fn write_requires_exactly_one_value() {
+ for args in [
+ serde_json::json!({}),
+ serde_json::json!({"text": "x", "file_path": "/tmp/x"}),
+ ] {
+ let result = ClipboardWriteTool {
+ backend: Arc::new(FakeClipboard::default()),
+ }
+ .invoke(args)
+ .await;
+ assert_eq!(result.is_error, Some(true));
+ }
+ }
+
+ #[tokio::test]
+ async fn unavailable_backend_returns_an_explicit_content_free_status() {
+ let result = ClipboardReadTool {
+ backend: Arc::new(UnavailableClipboard),
+ }
+ .invoke(serde_json::json!({}))
+ .await;
+ assert_eq!(result.is_error, Some(true));
+ let output = result.structured_content.unwrap();
+ assert_eq!(output["supported"], false);
+ assert_eq!(output["status"], "unavailable");
+ assert_eq!(output["error_code"], "clipboard_unavailable");
+ assert_eq!(output["content_redacted_from_telemetry"], true);
+ assert!(output
+ .to_string()
+ .find("no display clipboard provider")
+ .is_none());
+ }
+}
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/lib.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/lib.rs
index 882958b947..08df5e915f 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/lib.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/lib.rs
@@ -51,6 +51,7 @@ pub mod browser;
pub mod capture_mode;
pub mod capture_scope;
pub mod cdp;
+pub mod clipboard;
pub mod consent;
pub mod cursor_events;
pub mod cursor_sampler;
diff --git a/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs b/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs
index 809adf8c21..581d4cf5c9 100644
--- a/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-core/src/tool.rs
@@ -1111,6 +1111,19 @@ impl ToolRegistry {
return protected_consent_refusal(error);
}
}
+ if has_adapter("clipboard") {
+ if let Err(error) = self
+ .authorize_clipboard(
+ resolved_name,
+ &public_args,
+ context,
+ runtime_session.as_deref(),
+ )
+ .await
+ {
+ return protected_consent_refusal(error);
+ }
+ }
if has_adapter("file_transfer_and_output") {
if let Err(refusal) = self
.authorize_file_transfer(
@@ -1704,6 +1717,59 @@ impl ToolRegistry {
Ok(())
}
+ async fn authorize_clipboard(
+ &self,
+ tool_name: &str,
+ args: &Value,
+ context: &crate::session_authorization::EffectiveAuthorizationContext,
+ lifecycle_session: Option<&str>,
+ ) -> Result<(), crate::consent::ConsentError> {
+ if context.mode() != crate::authorization::PermissionMode::Bounded {
+ return Ok(());
+ }
+ let (operation, content_kind, summary) = if tool_name == "clipboard_read" {
+ (
+ "read",
+ if args.get("include_text").and_then(Value::as_bool) == Some(true) {
+ "text_and_types"
+ } else {
+ "types"
+ },
+ "Allow Cua to read the current system clipboard",
+ )
+ } else {
+ let kind = if args.get("text").and_then(Value::as_str).is_some() {
+ "text"
+ } else if args.get("image_path").and_then(Value::as_str).is_some() {
+ "image"
+ } else {
+ "file_url"
+ };
+ (
+ "write",
+ kind,
+ "Allow Cua to replace the current system clipboard",
+ )
+ };
+ self.protected_resource_grants
+ .authorize(
+ context,
+ "clipboard",
+ crate::authorization::RiskClass::R2,
+ lifecycle_session,
+ serde_json::json!({
+ "kind": "system_clipboard",
+ "operation": operation,
+ "content_kind": content_kind,
+ }),
+ &format!("{summary} using {tool_name}"),
+ Duration::from_secs(30 * 60),
+ Duration::from_secs(8 * 60 * 60),
+ )
+ .await
+ .map(|_| ())
+ }
+
async fn authorize_file_transfer(
&self,
tool_name: &str,
@@ -1747,6 +1813,25 @@ impl ToolRegistry {
"Allow Cua to download one file from this browser tab to the exact destination directory".to_owned(),
)
}
+ "clipboard_write" => {
+ let (argument, content_kind) =
+ if args.get("image_path").and_then(Value::as_str).is_some() {
+ ("image_path", "image")
+ } else {
+ ("file_path", "file_url")
+ };
+ let source = canonical_existing_file(required_path_arg(args, argument)?)?;
+ args[argument] = Value::String(source.clone());
+ (
+ serde_json::json!({
+ "kind": "clipboard_local_file",
+ "content_kind": content_kind,
+ "direction": "local_to_clipboard",
+ "canonical_source_path": source,
+ }),
+ format!("Allow Cua to read this exact local {content_kind} into the clipboard"),
+ )
+ }
"get_desktop_state" | "get_window_state" => {
let output =
canonical_proposed_path(required_path_arg(args, "screenshot_out_file")?)?;
@@ -2096,6 +2181,25 @@ fn canonical_upload_files(args: &Value) -> Result<Vec<String>, ToolResult> {
.collect()
}
+fn canonical_existing_file(raw: &str) -> Result<String, ToolResult> {
+ let path = Path::new(raw);
+ if !path.is_absolute() {
+ return Err(protected_scope_refusal(
+ "clipboard file paths must be absolute",
+ ));
+ }
+ let metadata = std::fs::symlink_metadata(path)
+ .map_err(|_| protected_scope_refusal("the exact clipboard path does not exist"))?;
+ if metadata.file_type().is_symlink() || !metadata.is_file() {
+ return Err(protected_scope_refusal(
+ "clipboard paths must name regular files directly, not links or directories",
+ ));
+ }
+ std::fs::canonicalize(path)
+ .map(|path| path.to_string_lossy().into_owned())
+ .map_err(|_| protected_scope_refusal("the clipboard path could not be canonicalized"))
+}
+
/// Resolve a not-yet-created output without creating it before approval.
///
/// The deepest existing ancestor is canonicalized first, so symlinked parents
@@ -3788,6 +3892,13 @@ fn recording_args_for(tool_name: &str, args: &Value) -> Value {
);
}
}
+ "clipboard_write" => {
+ for field in ["text", "image_path", "file_path"] {
+ if arguments.contains_key(field) {
+ arguments.insert(field.to_owned(), Value::String("[redacted]".to_owned()));
+ }
+ }
+ }
"browser_set_input_files" => {
if let Some(count) = arguments
.get("files")
@@ -3938,6 +4049,31 @@ mod capability_tests {
}
}
+ #[test]
+ fn clipboard_write_recording_args_are_content_free() {
+ let recorded = recording_args_for(
+ "clipboard_write",
+ &serde_json::json!({
+ "text": "private text",
+ "image_path": "/private/image.png",
+ "file_path": "/private/document.pdf",
+ "session": "public-session",
+ }),
+ );
+ assert_eq!(recorded["text"], "[redacted]");
+ assert_eq!(recorded["image_path"], "[redacted]");
+ assert_eq!(recorded["file_path"], "[redacted]");
+ assert_eq!(recorded["session"], "public-session");
+ let serialized = recorded.to_string();
+ for forbidden in [
+ "private text",
+ "/private/image.png",
+ "/private/document.pdf",
+ ] {
+ assert!(!serialized.contains(forbidden));
+ }
+ }
+
#[test]
fn existing_profile_prepare_is_a_private_consent_turn() {
assert!(is_existing_profile_prepare(
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 542ec3f2e2..df158f7b58 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
@@ -6,12 +6,12 @@
//! MCP and daemon transports are downstream adapters rather than peer contracts.
use cua_driver_contract::{
- ActionResult, ClickInput, DragInput, EndSessionInput, EndSessionOutput, EscalateSessionInput,
- GetAgentCursorStateInput, GetCursorPositionInput, GetDesktopStateInput, GetScreenSizeInput,
- GetSessionStateInput, HotkeyInput, MoveCursorInput, PressKeyInput, ScrollInput,
- SessionStateOutput, SetAgentCursorEnabledInput, SetAgentCursorMotionInput,
- SetAgentCursorThemeInput, StartSessionInput, StartSessionOutput, ToolInput, TypeTextInput,
- VerifyStateInput, VerifyStateOutput,
+ ActionResult, ClickInput, ClipboardReadInput, ClipboardWriteInput, DragInput, EndSessionInput,
+ EndSessionOutput, EscalateSessionInput, GetAgentCursorStateInput, GetCursorPositionInput,
+ GetDesktopStateInput, GetScreenSizeInput, GetSessionStateInput, HotkeyInput, MoveCursorInput,
+ PressKeyInput, ScrollInput, SessionStateOutput, SetAgentCursorEnabledInput,
+ SetAgentCursorMotionInput, SetAgentCursorThemeInput, StartSessionInput, StartSessionOutput,
+ ToolInput, TypeTextInput, VerifyStateInput, VerifyStateOutput,
};
use cua_driver_core::daemon::{
is_daemon_listening, request_daemon_metadata, send_request, socket_path_for_namespace,
@@ -559,6 +559,8 @@ macro_rules! desktop_tool_methods {
click: ClickInput,
drag: DragInput,
scroll: ScrollInput,
+ clipboard_read: ClipboardReadInput,
+ clipboard_write: ClipboardWriteInput,
type_text: TypeTextInput,
press_key: PressKeyInput,
hotkey: HotkeyInput,
diff --git a/libs/cua-driver/rust/crates/platform-linux/Cargo.toml b/libs/cua-driver/rust/crates/platform-linux/Cargo.toml
index 538f2419d2..61a0af8c9b 100644
--- a/libs/cua-driver/rust/crates/platform-linux/Cargo.toml
+++ b/libs/cua-driver/rust/crates/platform-linux/Cargo.toml
@@ -19,6 +19,7 @@ pip-preview = { path = "../pip-preview" }
tiny-skia = { version = "0.11", default-features = false, features = ["std"] }
[target.'cfg(target_os = "linux")'.dependencies]
+clipboard-rs = { version = "0.3.5", features = ["wayland"] }
# X11 background input + window enumeration
x11rb = { version = "0.13", features = ["xinput", "randr", "xfixes", "composite", "shape", "xtest"] }
x11 = { version = "2.21", features = ["xlib", "xinput", "xtest"] }
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/clipboard.rs b/libs/cua-driver/rust/crates/platform-linux/src/clipboard.rs
new file mode 100644
index 0000000000..f6a930f434
--- /dev/null
+++ b/libs/cua-driver/rust/crates/platform-linux/src/clipboard.rs
@@ -0,0 +1,108 @@
+use std::{path::Path, sync::Mutex};
+
+use clipboard_rs::{common::RustImage, Clipboard, ClipboardContext, ContentFormat};
+use cua_driver_core::clipboard::ClipboardBackend;
+
+pub struct LinuxClipboard {
+ context: Result<Mutex<ClipboardContext>, String>,
+}
+
+impl LinuxClipboard {
+ pub fn new() -> Self {
+ Self {
+ context: ClipboardContext::new()
+ .map(Mutex::new)
+ .map_err(|error| error.to_string()),
+ }
+ }
+
+ fn context(&self) -> Result<std::sync::MutexGuard<'_, ClipboardContext>, String> {
+ self.context
+ .as_ref()
+ .map_err(Clone::clone)?
+ .lock()
+ .map_err(|_| "clipboard lock was poisoned".to_owned())
+ }
+}
+
+fn absolute_existing_file(path: &str) -> Result<String, String> {
+ let path = Path::new(path);
+ if !path.is_absolute() {
+ return Err("clipboard file paths must be absolute".into());
+ }
+ let canonical = path.canonicalize().map_err(|error| error.to_string())?;
+ if !canonical.is_file() {
+ return Err("clipboard path must identify an existing file".into());
+ }
+ Ok(canonical.to_string_lossy().into_owned())
+}
+
+impl ClipboardBackend for LinuxClipboard {
+ fn available_formats(&self) -> Result<Vec<String>, String> {
+ self.context()?
+ .available_formats()
+ .map_err(|e| e.to_string())
+ }
+
+ fn read_text(&self) -> Result<Option<String>, String> {
+ let context = self.context()?;
+ if context.has(ContentFormat::Text) {
+ context.get_text().map(Some).map_err(|e| e.to_string())
+ } else {
+ Ok(None)
+ }
+ }
+
+ fn write_text(&self, text: String) -> Result<(), String> {
+ self.context()?.set_text(text).map_err(|e| e.to_string())
+ }
+
+ fn write_image(&self, absolute_path: &str) -> Result<(), String> {
+ let path = absolute_existing_file(absolute_path)?;
+ let image = clipboard_rs::RustImageData::from_path(&path).map_err(|e| e.to_string())?;
+ self.context()?.set_image(image).map_err(|e| e.to_string())
+ }
+
+ fn write_file_url(&self, absolute_path: &str) -> Result<(), String> {
+ let path = absolute_existing_file(absolute_path)?;
+ self.context()?
+ .set_files(vec![path])
+ .map_err(|e| e.to_string())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn rejects_relative_local_paths_before_clipboard_access() {
+ let backend = LinuxClipboard::new();
+ assert!(backend
+ .write_file_url("relative.txt")
+ .unwrap_err()
+ .contains("absolute"));
+ assert!(backend
+ .write_image("relative.png")
+ .unwrap_err()
+ .contains("absolute"));
+ }
+
+ #[test]
+ fn native_clipboard_round_trips_text_when_ci_has_a_display() {
+ if std::env::var_os("CI").is_none() {
+ return;
+ }
+ let backend = LinuxClipboard::new();
+ if backend.available_formats().is_err() {
+ return;
+ }
+ backend
+ .write_text("cua-driver clipboard test".into())
+ .unwrap();
+ assert_eq!(
+ backend.read_text().unwrap().as_deref(),
+ Some("cua-driver clipboard test")
+ );
+ }
+}
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/lib.rs b/libs/cua-driver/rust/crates/platform-linux/src/lib.rs
index 77a65cb645..ae2523898f 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/lib.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/lib.rs
@@ -43,6 +43,8 @@ pub mod installed_apps;
#[cfg(target_os = "linux")]
pub mod capture;
+#[cfg(target_os = "linux")]
+mod clipboard;
#[cfg(target_os = "linux")]
pub mod atspi;
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
index 57b4184c9f..14bd9fbdaf 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs
@@ -7189,6 +7189,10 @@ pub fn build_registry_with_provider(
));
r.register(pid_window_guarded(SetValueTool, &pid_window_candidates));
r.register(pid_window_guarded(ScrollTool, &pid_window_candidates));
+ cua_driver_core::clipboard::register_clipboard_tools(
+ &mut r,
+ Arc::new(crate::clipboard::LinuxClipboard::new()),
+ );
// `screenshot` removed - see the matching comment in
// platform-windows/src/tools/impl_.rs::build_registry. Canonical
// screenshot path is `get_window_state` (it always returns a screenshot now).
diff --git a/libs/cua-driver/rust/crates/platform-macos/Cargo.toml b/libs/cua-driver/rust/crates/platform-macos/Cargo.toml
index 629a4f5408..ea9b14f2e7 100644
--- a/libs/cua-driver/rust/crates/platform-macos/Cargo.toml
+++ b/libs/cua-driver/rust/crates/platform-macos/Cargo.toml
@@ -24,6 +24,7 @@ cursor-overlay = { path = "../cursor-overlay" }
pip-preview = { path = "../pip-preview" }
[target.'cfg(target_os = "macos")'.dependencies]
+clipboard-rs = "0.3.5"
# macOS system bindings
core-foundation = "0.10"
core-graphics = { version = "0.24", features = ["highsierra", "elcapitan"] }
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/clipboard.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/clipboard.rs
new file mode 100644
index 0000000000..1d48a87cb9
--- /dev/null
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/clipboard.rs
@@ -0,0 +1,130 @@
+use std::{path::Path, sync::Mutex};
+
+use clipboard_rs::{common::RustImage, Clipboard, ClipboardContext, ContentFormat};
+use cua_driver_core::clipboard::ClipboardBackend;
+
+pub struct MacosClipboard {
+ context: Result<Mutex<ClipboardContext>, String>,
+}
+
+impl MacosClipboard {
+ pub fn new() -> Self {
+ Self {
+ context: ClipboardContext::new()
+ .map(Mutex::new)
+ .map_err(|error| error.to_string()),
+ }
+ }
+
+ fn context(&self) -> Result<std::sync::MutexGuard<'_, ClipboardContext>, String> {
+ self.context
+ .as_ref()
+ .map_err(Clone::clone)?
+ .lock()
+ .map_err(|_| "clipboard lock was poisoned".to_owned())
+ }
+}
+
+fn absolute_existing_file(path: &str) -> Result<String, String> {
+ let path = Path::new(path);
+ if !path.is_absolute() {
+ return Err("clipboard file paths must be absolute".into());
+ }
+ let canonical = path.canonicalize().map_err(|error| error.to_string())?;
+ if !canonical.is_file() {
+ return Err("clipboard path must identify an existing file".into());
+ }
+ Ok(canonical.to_string_lossy().into_owned())
+}
+
+impl ClipboardBackend for MacosClipboard {
+ fn available_formats(&self) -> Result<Vec<String>, String> {
+ self.context()?
+ .available_formats()
+ .map_err(|e| e.to_string())
+ }
+
+ fn read_text(&self) -> Result<Option<String>, String> {
+ let context = self.context()?;
+ if context.has(ContentFormat::Text) {
+ context.get_text().map(Some).map_err(|e| e.to_string())
+ } else {
+ Ok(None)
+ }
+ }
+
+ fn write_text(&self, text: String) -> Result<(), String> {
+ self.context()?.set_text(text).map_err(|e| e.to_string())
+ }
+
+ fn write_image(&self, absolute_path: &str) -> Result<(), String> {
+ let path = absolute_existing_file(absolute_path)?;
+ let image = clipboard_rs::RustImageData::from_path(&path).map_err(|e| e.to_string())?;
+ self.context()?.set_image(image).map_err(|e| e.to_string())
+ }
+
+ fn write_file_url(&self, absolute_path: &str) -> Result<(), String> {
+ let path = absolute_existing_file(absolute_path)?;
+ self.context()?
+ .set_files(vec![path])
+ .map_err(|e| e.to_string())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn rejects_relative_local_paths_before_clipboard_access() {
+ let backend = MacosClipboard::new();
+ assert!(backend
+ .write_file_url("relative.txt")
+ .unwrap_err()
+ .contains("absolute"));
+ assert!(backend
+ .write_image("relative.png")
+ .unwrap_err()
+ .contains("absolute"));
+ }
+
+ #[test]
+ fn native_clipboard_round_trips_text_png_and_file_url_in_ci() {
+ if std::env::var_os("CI").is_none() {
+ return;
+ }
+ let backend = MacosClipboard::new();
+ let original_text = backend.read_text().ok().flatten();
+ backend
+ .write_text("cua-driver clipboard test".into())
+ .unwrap();
+ assert_eq!(
+ backend.read_text().unwrap().as_deref(),
+ Some("cua-driver clipboard test")
+ );
+
+ let png =
+ std::env::temp_dir().join(format!("cua-driver-clipboard-{}.png", std::process::id()));
+ image::RgbaImage::from_pixel(1, 1, image::Rgba([1, 2, 3, 255]))
+ .save(&png)
+ .unwrap();
+ backend.write_image(png.to_str().unwrap()).unwrap();
+ let image_types = backend.available_formats().unwrap();
+ assert!(image_types.iter().any(|kind| {
+ matches!(kind.as_str(), "public.png" | "public.tiff")
+ || kind.to_ascii_lowercase().contains("image")
+ }));
+
+ backend.write_file_url(png.to_str().unwrap()).unwrap();
+ let file_types = backend.available_formats().unwrap();
+ assert!(file_types.iter().any(|kind| {
+ kind == "public.file-url"
+ || kind.to_ascii_lowercase().contains("file")
+ || kind.to_ascii_lowercase().contains("uri")
+ }));
+ if let Some(text) = original_text {
+ backend.write_text(text).unwrap();
+ }
+ let _ = std::fs::remove_file(png);
+ }
+}
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/hotkey.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/hotkey.rs
index fa1b4474b3..ccaa6f8243 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/hotkey.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/hotkey.rs
@@ -49,8 +49,10 @@ fn def() -> &'static ToolDef {
A combo is never driver-verifiable (no read-back) → effect:\"unverifiable\"; \
confirm via screenshot. NOTE: a keyboard combo does NOT focus a text \
field — to type into a backgrounded Electron input, establish real \
- renderer focus with a PIXEL click first, then `type_text` (do not reach \
- for a clipboard + Cmd+V dance).\n\n\
+ renderer focus with a PIXEL click first, then `type_text`. If an app only \
+ accepts paste, call `clipboard_write`, then `clipboard_read` and verify its \
+ types (and text when applicable) before selecting or replacing editor content; \
+ only then send Cmd+V.\n\n\
Recognized modifiers: cmd/command, shift, option/alt, ctrl/control, fn. \
Non-modifier keys use the same vocabulary as `press_key`. Order: \
modifiers first, one non-modifier last."
diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/mod.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/mod.rs
index 3a3115eae9..f0fdfbd21c 100644
--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/mod.rs
+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/mod.rs
@@ -2,6 +2,7 @@
mod bring_to_front;
mod click;
+mod clipboard;
mod double_click;
mod drag;
mod get_window_state;
@@ -763,6 +764,10 @@ pub fn register_all(
scroll::ScrollTool::new(state.clone()),
&pid_window_candidates,
));
+ cua_driver_core::clipboard::register_clipboard_tools(
+ registry,
+ Arc::new(clipboard::MacosClipboard::new()),
+ );
// The standalone `screenshot` tool was removed (#1692). The pixel-grounding
// screenshot the Claude Code computer-use compat loop relies on now comes
// from `get_window_state` (which always returns BOTH the tree AND a
diff --git a/libs/cua-driver/rust/crates/platform-windows/Cargo.toml b/libs/cua-driver/rust/crates/platform-windows/Cargo.toml
index b85ff0cbcb..96fb8fd274 100644
--- a/libs/cua-driver/rust/crates/platform-windows/Cargo.toml
+++ b/libs/cua-driver/rust/crates/platform-windows/Cargo.toml
@@ -23,6 +23,7 @@ indexmap = "2"
tiny-skia = { version = "0.11", default-features = false, features = ["std"] }
[target.'cfg(target_os = "windows")'.dependencies]
+clipboard-rs = "0.3.5"
image = { workspace = true }
windows = { version = "0.58", features = [
"Win32_Foundation",
diff --git a/libs/cua-driver/rust/crates/platform-windows/src/clipboard.rs b/libs/cua-driver/rust/crates/platform-windows/src/clipboard.rs
new file mode 100644
index 0000000000..2f8a85d3e0
--- /dev/null
+++ b/libs/cua-driver/rust/crates/platform-windows/src/clipboard.rs
@@ -0,0 +1,105 @@
+use std::{path::Path, sync::Mutex};
+
+use clipboard_rs::{common::RustImage, Clipboard, ClipboardContext, ContentFormat};
+use cua_driver_core::clipboard::ClipboardBackend;
+
+pub struct WindowsClipboard {
+ context: Result<Mutex<ClipboardContext>, String>,
+}
+
+impl WindowsClipboard {
+ pub fn new() -> Self {
+ Self {
+ context: ClipboardContext::new()
+ .map(Mutex::new)
+ .map_err(|error| error.to_string()),
+ }
+ }
+
+ fn context(&self) -> Result<std::sync::MutexGuard<'_, ClipboardContext>, String> {
+ self.context
+ .as_ref()
+ .map_err(Clone::clone)?
+ .lock()
+ .map_err(|_| "clipboard lock was poisoned".to_owned())
+ }
+}
+
+fn absolute_existing_file(path: &str) -> Result<String, String> {
+ let path = Path::new(path);
+ if !path.is_absolute() {
+ return Err("clipboard file paths must be absolute".into());
+ }
+ let canonical = path.canonicalize().map_err(|error| error.to_string())?;
+ if !canonical.is_file() {
+ return Err("clipboard path must identify an existing file".into());
+ }
+ Ok(canonical.to_string_lossy().into_owned())
+}
+
+impl ClipboardBackend for WindowsClipboard {
+ fn available_formats(&self) -> Result<Vec<String>, String> {
+ self.context()?
+ .available_formats()
+ .map_err(|e| e.to_string())
+ }
+
+ fn read_text(&self) -> Result<Option<String>, String> {
+ let context = self.context()?;
+ if context.has(ContentFormat::Text) {
+ context.get_text().map(Some).map_err(|e| e.to_string())
+ } else {
+ Ok(None)
+ }
+ }
+
+ fn write_text(&self, text: String) -> Result<(), String> {
+ self.context()?.set_text(text).map_err(|e| e.to_string())
+ }
+
+ fn write_image(&self, absolute_path: &str) -> Result<(), String> {
+ let path = absolute_existing_file(absolute_path)?;
+ let image = clipboard_rs::RustImageData::from_path(&path).map_err(|e| e.to_string())?;
+ self.context()?.set_image(image).map_err(|e| e.to_string())
+ }
+
+ fn write_file_url(&self, absolute_path: &str) -> Result<(), String> {
+ let path = absolute_existing_file(absolute_path)?;
+ self.context()?
+ .set_files(vec![path])
+ .map_err(|e| e.to_string())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn rejects_relative_local_paths_before_clipboard_access() {
+ let backend = WindowsClipboard::new();
+ assert!(backend
+ .write_file_url("relative.txt")
+ .unwrap_err()
+ .contains("absolute"));
+ assert!(backend
+ .write_image("relative.png")
+ .unwrap_err()
+ .contains("absolute"));
+ }
+
+ #[test]
+ fn native_clipboard_round_trips_text_in_ci() {
+ if std::env::var_os("CI").is_none() {
+ return;
+ }
+ let backend = WindowsClipboard::new();
+ backend
+ .write_text("cua-driver clipboard test".into())
+ .unwrap();
+ assert_eq!(
+ backend.read_text().unwrap().as_deref(),
+ Some("cua-driver clipboard test")
+ );
+ }
+}
diff --git a/libs/cua-driver/rust/crates/platform-windows/src/lib.rs b/libs/cua-driver/rust/crates/platform-windows/src/lib.rs
index 98fc222269..060ffc1d41 100644
--- a/libs/cua-driver/rust/crates/platform-windows/src/lib.rs
+++ b/libs/cua-driver/rust/crates/platform-windows/src/lib.rs
@@ -65,6 +65,8 @@ pub mod input;
#[cfg(target_os = "windows")]
pub mod capture;
+#[cfg(target_os = "windows")]
+mod clipboard;
#[cfg(target_os = "windows")]
pub mod wgc;
diff --git a/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs b/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
index adbd7e8db1..cc8af0494e 100644
--- a/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
+++ b/libs/cua-driver/rust/crates/platform-windows/src/tools/impl_.rs
@@ -8760,6 +8760,10 @@ pub fn build_registry_with_provider(
},
&pid_window_candidates,
));
+ cua_driver_core::clipboard::register_clipboard_tools(
+ &mut r,
+ Arc::new(crate::clipboard::WindowsClipboard::new()),
+ );
// `screenshot` / `ScreenshotCompatTool` removed from the tool surface
// — `get_window_state` (which now always returns a screenshot) is the
// single canonical path for getting a window screenshot. Reasons:
diff --git a/libs/cua-driver/typescript/src/native/cua_driver_contract.ts b/libs/cua-driver/typescript/src/native/cua_driver_contract.ts
index 6831aff82b..d8a932475f 100644
--- a/libs/cua-driver/typescript/src/native/cua_driver_contract.ts
+++ b/libs/cua-driver/typescript/src/native/cua_driver_contract.ts
@@ -608,6 +608,229 @@ const FfiConverterTypeClickInput = (() => {
return new FFIConverter();
})();
+export type ClipboardReadInput = {
+ /**
+ * Return plain-text clipboard content in addition to the available types.
+ * Clipboard content is privacy-sensitive and is never retained in telemetry.
+ */
+ includeText: boolean,
+ /**
+ * Optional session id.
+ */
+ session?: string
+}
+
+/**
+ * Generated factory for {@link ClipboardReadInput} record objects.
+ */
+export const ClipboardReadInput = (() => {
+ const defaults = () => ({
+ });
+ const create = (() => {
+ return uniffiCreateRecord<ClipboardReadInput, ReturnType<typeof defaults>>(defaults);
+ })();
+ return Object.freeze({
+ create,
+ new: create,
+ defaults: () => Object.freeze(defaults()) as Partial<ClipboardReadInput>,
+ });
+})();
+
+const FfiConverterTypeClipboardReadInput = (() => {
+ type TypeName = ClipboardReadInput;
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
+ read(from: RustBuffer): TypeName {
+ return {
+ includeText: FfiConverterBool.read(from),
+ session: FfiConverterOptionalString.read(from)
+ };
+ }
+ write(value: TypeName, into: RustBuffer): void {
+ FfiConverterBool.write(value.includeText, into);
+ FfiConverterOptionalString.write(value.session, into);
+ }
+ allocationSize(value: TypeName): number {
+ return FfiConverterBool.allocationSize(value.includeText) +
+ FfiConverterOptionalString.allocationSize(value.session);
+
+ }
+ };
+ return new FFIConverter();
+})();
+
+export type ClipboardReadOutput = {
+ supported: boolean,
+ types: Array<string>,
+ text?: string,
+ privacySensitive: boolean,
+ contentRedactedFromTelemetry: boolean
+}
+
+/**
+ * Generated factory for {@link ClipboardReadOutput} record objects.
+ */
+export const ClipboardReadOutput = (() => {
+ const defaults = () => ({
+ });
+ const create = (() => {
+ return uniffiCreateRecord<ClipboardReadOutput, ReturnType<typeof defaults>>(defaults);
+ })();
+ return Object.freeze({
+ create,
+ new: create,
+ defaults: () => Object.freeze(defaults()) as Partial<ClipboardReadOutput>,
+ });
+})();
+
+const FfiConverterTypeClipboardReadOutput = (() => {
+ type TypeName = ClipboardReadOutput;
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
+ read(from: RustBuffer): TypeName {
+ return {
+ supported: FfiConverterBool.read(from),
+ types: FfiConverterSequenceString.read(from),
+ text: FfiConverterOptionalString.read(from),
+ privacySensitive: FfiConverterBool.read(from),
+ contentRedactedFromTelemetry: FfiConverterBool.read(from)
+ };
+ }
+ write(value: TypeName, into: RustBuffer): void {
+ FfiConverterBool.write(value.supported, into);
+ FfiConverterSequenceString.write(value.types, into);
+ FfiConverterOptionalString.write(value.text, into);
+ FfiConverterBool.write(value.privacySensitive, into);
+ FfiConverterBool.write(value.contentRedactedFromTelemetry, into);
+ }
+ allocationSize(value: TypeName): number {
+ return FfiConverterBool.allocationSize(value.supported) +
+ FfiConverterSequenceString.allocationSize(value.types) +
+ FfiConverterOptionalString.allocationSize(value.text) +
+ FfiConverterBool.allocationSize(value.privacySensitive) +
+ FfiConverterBool.allocationSize(value.contentRedactedFromTelemetry);
+
+ }
+ };
+ return new FFIConverter();
+})();
+
+export type ClipboardWriteInput = {
+ /**
+ * Plain text to place on the clipboard.
+ */
+ text?: string,
+ /**
+ * Absolute path to a local image to place on the clipboard.
+ */
+ imagePath?: string,
+ /**
+ * Absolute path to a local file to place on the clipboard as a file URL.
+ */
+ filePath?: string,
+ /**
+ * Optional session id.
+ */
+ session?: string
+}
+
+/**
+ * Generated factory for {@link ClipboardWriteInput} record objects.
+ */
+export const ClipboardWriteInput = (() => {
+ const defaults = () => ({
+ });
+ const create = (() => {
+ return uniffiCreateRecord<ClipboardWriteInput, ReturnType<typeof defaults>>(defaults);
+ })();
+ return Object.freeze({
+ create,
+ new: create,
+ defaults: () => Object.freeze(defaults()) as Partial<ClipboardWriteInput>,
+ });
+})();
+
+const FfiConverterTypeClipboardWriteInput = (() => {
+ type TypeName = ClipboardWriteInput;
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
+ read(from: RustBuffer): TypeName {
+ return {
+ text: FfiConverterOptionalString.read(from),
+ imagePath: FfiConverterOptionalString.read(from),
+ filePath: FfiConverterOptionalString.read(from),
+ session: FfiConverterOptionalString.read(from)
+ };
+ }
+ write(value: TypeName, into: RustBuffer): void {
+ FfiConverterOptionalString.write(value.text, into);
+ FfiConverterOptionalString.write(value.imagePath, into);
+ FfiConverterOptionalString.write(value.filePath, into);
+ FfiConverterOptionalString.write(value.session, into);
+ }
+ allocationSize(value: TypeName): number {
+ return FfiConverterOptionalString.allocationSize(value.text) +
+ FfiConverterOptionalString.allocationSize(value.imagePath) +
+ FfiConverterOptionalString.allocationSize(value.filePath) +
+ FfiConverterOptionalString.allocationSize(value.session);
+
+ }
+ };
+ return new FFIConverter();
+})();
+
+export type ClipboardWriteOutput = {
+ supported: boolean,
+ writtenType: string,
+ types: Array<string>,
+ privacySensitive: boolean,
+ contentRedactedFromTelemetry: boolean
+}
+
+/**
+ * Generated factory for {@link ClipboardWriteOutput} record objects.
+ */
+export const ClipboardWriteOutput = (() => {
+ const defaults = () => ({
+ });
+ const create = (() => {
+ return uniffiCreateRecord<ClipboardWriteOutput, ReturnType<typeof defaults>>(defaults);
+ })();
+ return Object.freeze({
+ create,
+ new: create,
+ defaults: () => Object.freeze(defaults()) as Partial<ClipboardWriteOutput>,
+ });
+})();
+
+const FfiConverterTypeClipboardWriteOutput = (() => {
+ type TypeName = ClipboardWriteOutput;
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
+ read(from: RustBuffer): TypeName {
+ return {
+ supported: FfiConverterBool.read(from),
+ writtenType: FfiConverterString.read(from),
+ types: FfiConverterSequenceString.read(from),
+ privacySensitive: FfiConverterBool.read(from),
+ contentRedactedFromTelemetry: FfiConverterBool.read(from)
+ };
+ }
+ write(value: TypeName, into: RustBuffer): void {
+ FfiConverterBool.write(value.supported, into);
+ FfiConverterString.write(value.writtenType, into);
+ FfiConverterSequenceString.write(value.types, into);
+ FfiConverterBool.write(value.privacySensitive, into);
+ FfiConverterBool.write(value.contentRedactedFromTelemetry, into);
+ }
+ allocationSize(value: TypeName): number {
+ return FfiConverterBool.allocationSize(value.supported) +
+ FfiConverterString.allocationSize(value.writtenType) +
+ FfiConverterSequenceString.allocationSize(value.types) +
+ FfiConverterBool.allocationSize(value.privacySensitive) +
+ FfiConverterBool.allocationSize(value.contentRedactedFromTelemetry);
+
+ }
+ };
+ return new FFIConverter();
+})();
+
export type CursorMotionOutput = {
startHandle: number,
endHandle: number,
@@ -2957,6 +3180,10 @@ export default Object.freeze({
FfiConverterTypeCaptureScope,
FfiConverterTypeClickButton,
FfiConverterTypeClickInput,
+ FfiConverterTypeClipboardReadInput,
+ FfiConverterTypeClipboardReadOutput,
+ FfiConverterTypeClipboardWriteInput,
+ FfiConverterTypeClipboardWriteOutput,
FfiConverterTypeCursorAction,
FfiConverterTypeCursorMotionOutput,
FfiConverterTypeCursorPointOutput,
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 93a117eda9..a0e386dfcc 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
@@ -423,6 +423,16 @@ const DEFINITIONS = {
ret: FfiType.Handle,
hasRustCallStatus: false,
},
+ "uniffi_cua_driver_sdk_fn_method_cuadriver_clipboard_read": {
+ args: [FfiType.Handle, FfiType.RustBuffer],
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
+ },
+ "uniffi_cua_driver_sdk_fn_method_cuadriver_clipboard_write": {
+ args: [FfiType.Handle, FfiType.RustBuffer],
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
+ },
"uniffi_cua_driver_sdk_fn_method_cuadriver_drag": {
args: [FfiType.Handle, FfiType.RustBuffer],
ret: FfiType.Handle,
@@ -558,6 +568,16 @@ const DEFINITIONS = {
ret: FfiType.Handle,
hasRustCallStatus: false,
},
+ "uniffi_cua_driver_sdk_fn_method_cuadriversession_clipboard_read": {
+ args: [FfiType.Handle, FfiType.RustBuffer],
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
+ },
+ "uniffi_cua_driver_sdk_fn_method_cuadriversession_clipboard_write": {
+ args: [FfiType.Handle, FfiType.RustBuffer],
+ ret: FfiType.Handle,
+ hasRustCallStatus: false,
+ },
"uniffi_cua_driver_sdk_fn_method_cuadriversession_close": {
args: [FfiType.Handle],
ret: FfiType.Void,
@@ -808,6 +828,16 @@ const DEFINITIONS = {
ret: FfiType.UInt16,
hasRustCallStatus: false,
},
+ "uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_read": {
+ args: [],
+ ret: FfiType.UInt16,
+ hasRustCallStatus: false,
+ },
+ "uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_write": {
+ args: [],
+ ret: FfiType.UInt16,
+ hasRustCallStatus: false,
+ },
"uniffi_cua_driver_sdk_checksum_method_cuadriver_drag": {
args: [],
ret: FfiType.UInt16,
@@ -943,6 +973,16 @@ const DEFINITIONS = {
ret: FfiType.UInt16,
hasRustCallStatus: false,
},
+ "uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_read": {
+ args: [],
+ ret: FfiType.UInt16,
+ hasRustCallStatus: false,
+ },
+ "uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_write": {
+ args: [],
+ ret: FfiType.UInt16,
+ hasRustCallStatus: false,
+ },
"uniffi_cua_driver_sdk_checksum_method_cuadriversession_close": {
args: [],
ret: FfiType.UInt16,
@@ -1241,6 +1281,8 @@ interface NativeModuleInterface {
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_clipboard_read(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriver_clipboard_write(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;
@@ -1268,6 +1310,8 @@ interface NativeModuleInterface {
uniffi_cua_driver_sdk_fn_method_cuadriver_verify_state(uniffiSelf: bigint, input: Uint8Array): bigint;
uniffi_cua_driver_sdk_fn_method_cuadriversession_call_tool(uniffiSelf: bigint, name: Uint8Array, argumentsJson: Uint8Array): bigint;
uniffi_cua_driver_sdk_fn_method_cuadriversession_click(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriversession_clipboard_read(uniffiSelf: bigint, input: Uint8Array): bigint;
+ uniffi_cua_driver_sdk_fn_method_cuadriversession_clipboard_write(uniffiSelf: bigint, input: Uint8Array): bigint;
uniffi_cua_driver_sdk_fn_method_cuadriversession_close(uniffiSelf: bigint, uniffi_out_err: UniffiRustCallStatus): void;
uniffi_cua_driver_sdk_fn_method_cuadriversession_drag(uniffiSelf: bigint, input: Uint8Array): bigint;
uniffi_cua_driver_sdk_fn_method_cuadriversession_end_session(uniffiSelf: bigint, input: Uint8Array): bigint;
@@ -1318,6 +1362,8 @@ interface NativeModuleInterface {
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_clipboard_read(): number;
+ uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_write(): 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;
@@ -1345,6 +1391,8 @@ interface NativeModuleInterface {
uniffi_cua_driver_sdk_checksum_method_cuadriver_verify_state(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriversession_call_tool(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriversession_click(): number;
+ uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_read(): number;
+ uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_write(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriversession_close(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriversession_drag(): number;
uniffi_cua_driver_sdk_checksum_method_cuadriversession_end_session(): 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 2c2ea5aad3..d88b02dc32 100644
--- a/libs/cua-driver/typescript/src/native/cua_driver_sdk.ts
+++ b/libs/cua-driver/typescript/src/native/cua_driver_sdk.ts
@@ -6,12 +6,12 @@
import nativeModule from "./cua_driver_sdk-ffi.js";
import { type UniffiRustFutureContinuationCallback, type UniffiForeignFutureDroppedCallback, type UniffiForeignFutureDroppedCallbackStruct, type UniffiVTableCallbackInterfaceCuaDriverSdkDriverActivityObserver, type UniffiForeignFutureResultRustBuffer, type UniffiForeignFutureCompleterustBuffer, type UniffiVTableCallbackInterfaceCuaDriverSdkDriverAuthorizationHost,
} from "./cua_driver_sdk-ffi.js";
-import { type ActionResult, type ClickInput, type DragInput, type EndSessionInput, type EndSessionOutput, type EscalateSessionInput, type GetAgentCursorStateInput, type GetCursorPositionInput, type GetDesktopStateInput, type GetScreenSizeInput, type GetSessionStateInput, type HotkeyInput, type MoveCursorInput, type PressKeyInput, type ScrollInput, type SessionStateOutput, type SetAgentCursorEnabledInput, type SetAgentCursorMotionInput, type SetAgentCursorThemeInput, type StartSessionInput, type StartSessionOutput, type TypeTextInput, type VerifyStateInput, type VerifyStateOutput,
+import { type ActionResult, type ClickInput, type ClipboardReadInput, type ClipboardWriteInput, type DragInput, type EndSessionInput, type EndSessionOutput, type EscalateSessionInput, type GetAgentCursorStateInput, type GetCursorPositionInput, type GetDesktopStateInput, type GetScreenSizeInput, type GetSessionStateInput, type HotkeyInput, type MoveCursorInput, type PressKeyInput, type ScrollInput, type SessionStateOutput, type SetAgentCursorEnabledInput, type SetAgentCursorMotionInput, type SetAgentCursorThemeInput, type StartSessionInput, type StartSessionOutput, type TypeTextInput, type VerifyStateInput, type VerifyStateOutput,
} from "./cua_driver_contract.js";
import { type FfiConverter, type UniffiByteArray, type UniffiGcObject, type UniffiHandle, type UniffiObjectFactory, type UniffiReferenceHolder, type UniffiRustCallStatus, AbstractFfiConverterByteArray, FfiConverterArray, FfiConverterBool, FfiConverterInt32, FfiConverterObject, FfiConverterObjectWithCallbacks, FfiConverterOptional, FfiConverterUInt32, FfiConverterUInt64, FfiConverterUInt8, RustBuffer, UniffiAbstractObject, UniffiEnum, UniffiError, UniffiInternalError, UniffiResult, UniffiRustCaller, destructorGuardSymbol, pointerLiteralSymbol, uniffiCreateFfiConverterString, uniffiCreateRecord, uniffiRustCallAsync, uniffiTraitInterfaceCall, uniffiTraitInterfaceCallAsyncWithError, uniffiTypeNameSymbol, variantOrdinalSymbol,
} from "@ubjs/core";
import uniffiCuaDriverContractModule from "./cua_driver_contract.js";
-const { FfiConverterTypeActionResult, FfiConverterTypeClickInput, FfiConverterTypeDragInput, FfiConverterTypeEndSessionInput, FfiConverterTypeEndSessionOutput, FfiConverterTypeEscalateSessionInput, FfiConverterTypeGetAgentCursorStateInput, FfiConverterTypeGetCursorPositionInput, FfiConverterTypeGetDesktopStateInput, FfiConverterTypeGetScreenSizeInput, FfiConverterTypeGetSessionStateInput, FfiConverterTypeHotkeyInput, FfiConverterTypeMoveCursorInput, FfiConverterTypePressKeyInput, FfiConverterTypeScrollInput, FfiConverterTypeSessionStateOutput, FfiConverterTypeSetAgentCursorEnabledInput, FfiConverterTypeSetAgentCursorMotionInput, FfiConverterTypeSetAgentCursorThemeInput, FfiConverterTypeStartSessionInput, FfiConverterTypeStartSessionOutput, FfiConverterTypeTypeTextInput, FfiConverterTypeVerifyStateInput, FfiConverterTypeVerifyStateOutput } = uniffiCuaDriverContractModule.converters;
+const { FfiConverterTypeActionResult, FfiConverterTypeClickInput, FfiConverterTypeClipboardReadInput, FfiConverterTypeClipboardWriteInput, FfiConverterTypeDragInput, FfiConverterTypeEndSessionInput, FfiConverterTypeEndSessionOutput, FfiConverterTypeEscalateSessionInput, FfiConverterTypeGetAgentCursorStateInput, FfiConverterTypeGetCursorPositionInput, FfiConverterTypeGetDesktopStateInput, FfiConverterTypeGetScreenSizeInput, FfiConverterTypeGetSessionStateInput, FfiConverterTypeHotkeyInput, FfiConverterTypeMoveCursorInput, FfiConverterTypePressKeyInput, FfiConverterTypeScrollInput, FfiConverterTypeSessionStateOutput, FfiConverterTypeSetAgentCursorEnabledInput, FfiConverterTypeSetAgentCursorMotionInput, FfiConverterTypeSetAgentCursorThemeInput, FfiConverterTypeStartSessionInput, FfiConverterTypeStartSessionOutput, FfiConverterTypeTypeTextInput, FfiConverterTypeVerifyStateInput, FfiConverterTypeVerifyStateOutput } = uniffiCuaDriverContractModule.converters;
const uniffiCaller = new UniffiRustCaller(() => ({ code: 0 }));
const uniffiIsDebug =
@@ -2537,6 +2537,8 @@ export interface CuaDriverLike {
*/
callTool(name: string, argumentsJson: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
click(input: ClickInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ clipboardRead(input: ClipboardReadInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ clipboardWrite(input: ClipboardWriteInput, 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>;
@@ -2907,6 +2909,70 @@ private constructor(pointer: UniffiHandle) {
}
}
+ async clipboardRead(input: ClipboardReadInput, 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_clipboard_read(
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeClipboardReadInput.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;
+ }
+ }
+
+ async clipboardWrite(input: ClipboardWriteInput, 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_clipboard_write(
+ uniffiTypeCuaDriverObjectFactory.clonePointer(this),FfiConverterTypeClipboardWriteInput.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;
+ }
+ }
+
async drag(input: DragInput, asyncOpts_?: { signal: AbortSignal }): Promise<ToolResult> /*throws*/ {
const __stack = uniffiIsDebug ? new Error().stack : undefined;
try {
@@ -3731,6 +3797,8 @@ export interface CuaDriverSessionLike {
callTool(name: string, argumentsJson: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
click(input: ClickInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ clipboardRead(input: ClipboardReadInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
+ clipboardWrite(input: ClipboardWriteInput, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<ToolResult>;
/**
* Revoke the session-bound authority and release its native handle.
*
@@ -3842,6 +3910,70 @@ private constructor(pointer: UniffiHandle) {
}
}
+ async clipboardRead(input: ClipboardReadInput, 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_cuadriversession_clipboard_read(
+ uniffiTypeCuaDriverSessionObjectFactory.clonePointer(this),FfiConverterTypeClipboardReadInput.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;
+ }
+ }
+
+ async clipboardWrite(input: ClipboardWriteInput, 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_cuadriversession_clipboard_write(
+ uniffiTypeCuaDriverSessionObjectFactory.clonePointer(this),FfiConverterTypeClipboardWriteInput.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;
+ }
+ }
+
/**
* Revoke the session-bound authority and release its native handle.
*
@@ -5299,6 +5431,12 @@ function uniffiEnsureInitialized() {
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_clipboard_read() !== 58238) {
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_read");
+ }
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_write() !== 8399) {
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_clipboard_write");
+ }
if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriver_drag() !== 25742) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriver_drag");
}
@@ -5380,6 +5518,12 @@ function uniffiEnsureInitialized() {
if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriversession_click() !== 22303) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriversession_click");
}
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_read() !== 23560) {
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_read");
+ }
+ if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_write() !== 45732) {
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriversession_clipboard_write");
+ }
if (nativeModule().uniffi_cua_driver_sdk_checksum_method_cuadriversession_close() !== 58108) {
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_cua_driver_sdk_checksum_method_cuadriversession_close");
}
diff --git a/libs/cua-driver/typescript/test/electron-main-fixture.mjs b/libs/cua-driver/typescript/test/electron-main-fixture.mjs
index 0361e41db1..78cffe0f00 100644
--- a/libs/cua-driver/typescript/test/electron-main-fixture.mjs
+++ b/libs/cua-driver/typescript/test/electron-main-fixture.mjs
@@ -27,7 +27,7 @@ const server = net.createServer(socket => {
const request = JSON.parse(buffer.split("\\n", 1)[0]);
const result = request.method === "metadata" ? {
driver_version: ${JSON.stringify(packageVersion)},
- contract_version: hostBundleId.endsWith(".failure") ? "incompatible" : "0.4.0",
+ contract_version: hostBundleId.endsWith(".failure") ? "incompatible" : "0.5.0",
tools_list_schema_version: "1",
capability_version: "1",
mcp_protocol_version: "2025-06-18",
diff --git a/libs/cua-driver/typescript/test/native-daemon-fixture.mjs b/libs/cua-driver/typescript/test/native-daemon-fixture.mjs
index 95e078e553..2fb0bdb7f1 100644
--- a/libs/cua-driver/typescript/test/native-daemon-fixture.mjs
+++ b/libs/cua-driver/typescript/test/native-daemon-fixture.mjs
@@ -18,7 +18,7 @@ const server = net.createServer((connection) => {
ok: true,
result: {
driver_version: "0.12.6",
- contract_version: "0.4.0",
+ contract_version: "0.5.0",
tools_list_schema_version: "1",
capability_version: "1",
mcp_protocol_version: "2025-06-18",
diff --git a/libs/cua-driver/typescript/test/native-loader.test.mjs b/libs/cua-driver/typescript/test/native-loader.test.mjs
index b110b6f39b..c65388e062 100644
--- a/libs/cua-driver/typescript/test/native-loader.test.mjs
+++ b/libs/cua-driver/typescript/test/native-loader.test.mjs
@@ -53,7 +53,7 @@ const server = net.createServer(socket => {
const request = JSON.parse(buffer.split("\\n", 1)[0]);
const result = request.method === "metadata" ? {
driver_version: "0.10.0",
- contract_version: "0.4.0",
+ contract_version: "0.5.0",
tools_list_schema_version: "1",
capability_version: "1",
mcp_protocol_version: "2025-06-18",
diff --git a/scripts/docs-generators/cua-driver.ts b/scripts/docs-generators/cua-driver.ts
index d921e52530..06338ed4a8 100644
--- a/scripts/docs-generators/cua-driver.ts
+++ b/scripts/docs-generators/cua-driver.ts
@@ -643,6 +643,10 @@ export function generateMCPToolsMDX(docs: MCPDocumentation, releasedVersion: str
title: 'Browser tools',
tools: ['page'],
},
+ {
+ title: 'Clipboard tools',
+ tools: ['clipboard_read', 'clipboard_write'],
+ },
{
title: 'Recording tools',
tools: ['start_recording', 'stop_recording', 'replay_trajectory'],