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.

304 KB
Raw Blame
# This file was autogenerated by some hot garbage in the `uniffi` crate.
# Trust me, you don't want to mess with it!

# Common helper code.
#
# Ideally this would live in a separate .py file where it can be unittested etc
# in isolation, and perhaps even published as a re-useable package.
#
# However, it's important that the details of how this helper code works (e.g. the
# way that different builtin types are passed across the FFI) exactly match what's
# expected by the rust code on the other side of the interface. In practice right
# now that means coming from the exact some version of `uniffi` that was used to
# compile the rust component. The easiest way to ensure this is to bundle the Python
# helpers directly inline like we're doing here.

from __future__ import annotations
import os
import sys
import ctypes
from dataclasses import dataclass
import enum
import struct
import contextlib
import datetime
import threading
import itertools
import traceback
import typing
import platform


# Used for default argument values
_DEFAULT = object() # type: typing.Any


class _UniffiRustBuffer(ctypes.Structure):
    _fields_ = [
        ("capacity", ctypes.c_uint64),
        ("len", ctypes.c_uint64),
        ("data", ctypes.POINTER(ctypes.c_char)),
    ]

    @staticmethod
    def default():
        return _UniffiRustBuffer(0, 0, None)

    @staticmethod
    def alloc(size):
        return _uniffi_rust_call(_UniffiLib.ffi_cua_driver_contract_rustbuffer_alloc, size)

    @staticmethod
    def reserve(rbuf, additional):
        return _uniffi_rust_call(_UniffiLib.ffi_cua_driver_contract_rustbuffer_reserve, rbuf, additional)

    def free(self):
        return _uniffi_rust_call(_UniffiLib.ffi_cua_driver_contract_rustbuffer_free, self)

    def __str__(self):
        return "_UniffiRustBuffer(capacity={}, len={}, data={})".format(
            self.capacity,
            self.len,
            self.data[0:self.len]
        )

    @contextlib.contextmanager
    def alloc_with_builder(*args):
        """Context-manger to allocate a buffer using a _UniffiRustBufferBuilder.

        The allocated buffer will be automatically freed if an error occurs, ensuring that
        we don't accidentally leak it.
        """
        builder = _UniffiRustBufferBuilder()
        try:
            yield builder
        except:
            builder.discard()
            raise

    @contextlib.contextmanager
    def consume_with_stream(self):
        """Context-manager to consume a buffer using a _UniffiRustBufferStream.

        The _UniffiRustBuffer will be freed once the context-manager exits, ensuring that we don't
        leak it even if an error occurs.
        """
        try:
            s = _UniffiRustBufferStream.from_rust_buffer(self)
            yield s
            if s.remaining() != 0:
                raise RuntimeError(f"junk data left in buffer at end of consume_with_stream {s.remaining()}")
        finally:
            self.free()

    @contextlib.contextmanager
    def read_with_stream(self):
        """Context-manager to read a buffer using a _UniffiRustBufferStream.

        This is like consume_with_stream, but doesn't free the buffer afterwards.
        It should only be used with borrowed `_UniffiRustBuffer` data.
        """
        s = _UniffiRustBufferStream.from_rust_buffer(self)
        yield s
        if s.remaining() != 0:
            raise RuntimeError(f"junk data left in buffer at end of read_with_stream {s.remaining()}")

class _UniffiForeignBytes(ctypes.Structure):
    _fields_ = [
        ("len", ctypes.c_int32),
        ("data", ctypes.POINTER(ctypes.c_char)),
    ]

    def __str__(self):
        return "_UniffiForeignBytes(len={}, data={})".format(self.len, self.data[0:self.len])


class _UniffiRustBufferStream:
    """
    Helper for structured reading of bytes from a _UniffiRustBuffer
    """

    def __init__(self, data, len):
        self.data = data
        self.len = len
        self.offset = 0

    @classmethod
    def from_rust_buffer(cls, buf):
        return cls(buf.data, buf.len)

    def remaining(self):
        return self.len - self.offset

    def _unpack_from(self, size, format):
        if self.offset + size > self.len:
            raise InternalError("read past end of rust buffer")
        value = struct.unpack(format, self.data[self.offset:self.offset+size])[0]
        self.offset += size
        return value

    def read(self, size):
        if self.offset + size > self.len:
            raise InternalError("read past end of rust buffer")
        data = self.data[self.offset:self.offset+size]
        self.offset += size
        return data

    def read_i8(self):
        return self._unpack_from(1, ">b")

    def read_u8(self):
        return self._unpack_from(1, ">B")

    def read_i16(self):
        return self._unpack_from(2, ">h")

    def read_u16(self):
        return self._unpack_from(2, ">H")

    def read_i32(self):
        return self._unpack_from(4, ">i")

    def read_u32(self):
        return self._unpack_from(4, ">I")

    def read_i64(self):
        return self._unpack_from(8, ">q")

    def read_u64(self):
        return self._unpack_from(8, ">Q")

    def read_float(self):
        v = self._unpack_from(4, ">f")
        return v

    def read_double(self):
        return self._unpack_from(8, ">d")

class _UniffiRustBufferBuilder:
    """
    Helper for structured writing of bytes into a _UniffiRustBuffer.
    """

    def __init__(self):
        self.rbuf = _UniffiRustBuffer.alloc(16)
        self.rbuf.len = 0

    def finalize(self):
        rbuf = self.rbuf
        self.rbuf = None
        return rbuf

    def discard(self):
        if self.rbuf is not None:
            rbuf = self.finalize()
            rbuf.free()

    @contextlib.contextmanager
    def _reserve(self, num_bytes):
        if self.rbuf.len + num_bytes > self.rbuf.capacity:
            self.rbuf = _UniffiRustBuffer.reserve(self.rbuf, num_bytes)
        yield None
        self.rbuf.len += num_bytes

    def _pack_into(self, size, format, value):
        with self._reserve(size):
            # XXX TODO: I feel like I should be able to use `struct.pack_into` here but can't figure it out.
            for i, byte in enumerate(struct.pack(format, value)):
                self.rbuf.data[self.rbuf.len + i] = byte

    def write(self, value):
        with self._reserve(len(value)):
            for i, byte in enumerate(value):
                self.rbuf.data[self.rbuf.len + i] = byte

    def write_i8(self, v):
        self._pack_into(1, ">b", v)

    def write_u8(self, v):
        self._pack_into(1, ">B", v)

    def write_i16(self, v):
        self._pack_into(2, ">h", v)

    def write_u16(self, v):
        self._pack_into(2, ">H", v)

    def write_i32(self, v):
        self._pack_into(4, ">i", v)

    def write_u32(self, v):
        self._pack_into(4, ">I", v)

    def write_i64(self, v):
        self._pack_into(8, ">q", v)

    def write_u64(self, v):
        self._pack_into(8, ">Q", v)

    def write_float(self, v):
        self._pack_into(4, ">f", v)

    def write_double(self, v):
        self._pack_into(8, ">d", v)

    def write_c_size_t(self, v):
        self._pack_into(ctypes.sizeof(ctypes.c_size_t) , "@N", v)
# A handful of classes and functions to support the generated data structures.
# This would be a good candidate for isolating in its own ffi-support lib.

class InternalError(Exception):
    pass

class _UniffiRustCallStatus(ctypes.Structure):
    """
    Error runtime.
    """
    _fields_ = [
        ("code", ctypes.c_int8),
        ("error_buf", _UniffiRustBuffer),
    ]

    # These match the values from the uniffi::rustcalls module
    CALL_SUCCESS = 0
    CALL_ERROR = 1
    CALL_UNEXPECTED_ERROR = 2

    @staticmethod
    def default():
        return _UniffiRustCallStatus(code=_UniffiRustCallStatus.CALL_SUCCESS, error_buf=_UniffiRustBuffer.default())

    def __str__(self):
        if self.code == _UniffiRustCallStatus.CALL_SUCCESS:
            return "_UniffiRustCallStatus(CALL_SUCCESS)"
        elif self.code == _UniffiRustCallStatus.CALL_ERROR:
            return "_UniffiRustCallStatus(CALL_ERROR)"
        elif self.code == _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR:
            return "_UniffiRustCallStatus(CALL_UNEXPECTED_ERROR)"
        else:
            return "_UniffiRustCallStatus(<invalid code>)"

def _uniffi_rust_call(fn, *args):
    # Call a rust function
    return _uniffi_rust_call_with_error(None, fn, *args)

def _uniffi_rust_call_with_error(error_ffi_converter, fn, *args):
    # Call a rust function and handle any errors
    #
    # This function is used for rust calls that return Result<> and therefore can set the CALL_ERROR status code.
    # error_ffi_converter must be set to the _UniffiConverter for the error class that corresponds to the result.
    call_status = _UniffiRustCallStatus.default()

    args_with_error = args + (ctypes.byref(call_status),)
    result = fn(*args_with_error)
    _uniffi_check_call_status(error_ffi_converter, call_status)
    return result

def _uniffi_check_call_status(error_ffi_converter, call_status):
    if call_status.code == _UniffiRustCallStatus.CALL_SUCCESS:
        pass
    elif call_status.code == _UniffiRustCallStatus.CALL_ERROR:
        if error_ffi_converter is None:
            call_status.error_buf.free()
            raise InternalError("_uniffi_rust_call_with_error: CALL_ERROR, but error_ffi_converter is None")
        else:
            raise error_ffi_converter.lift(call_status.error_buf)
    elif call_status.code == _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR:
        # When the rust code sees a panic, it tries to construct a _UniffiRustBuffer
        # with the message.  But if that code panics, then it just sends back
        # an empty buffer.
        if call_status.error_buf.len > 0:
            msg = _UniffiFfiConverterString.lift(call_status.error_buf)
        else:
            msg = "Unknown rust panic"
        raise InternalError(msg)
    else:
        raise InternalError("Invalid _UniffiRustCallStatus code: {}".format(
            call_status.code))

def _uniffi_trait_interface_call(call_status, make_call, write_return_value):
    try:
        return write_return_value(make_call())
    except Exception as e:
        call_status.code = _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR
        call_status.error_buf = _UniffiFfiConverterString.lower(repr(e))

def _uniffi_trait_interface_call_with_error(call_status, make_call, write_return_value, error_type, lower_error):
    try:
        try:
            return write_return_value(make_call())
        except error_type as e:
            call_status.code = _UniffiRustCallStatus.CALL_ERROR
            call_status.error_buf = lower_error(e)
    except Exception as e:
        call_status.code = _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR
        call_status.error_buf = _UniffiFfiConverterString.lower(repr(e))
# Initial value and increment amount for handles.
# These ensure that Python-generated handles always have the lowest bit set
_UNIFFI_HANDLEMAP_INITIAL = 1
_UNIFFI_HANDLEMAP_DELTA = 2

class _UniffiHandleMap:
    """
    A map where inserting, getting and removing data is synchronized with a lock.
    """

    def __init__(self):
        # type Handle = int
        self._map = {}  # type: Dict[Handle, Any]
        self._lock = threading.Lock()
        self._counter = _UNIFFI_HANDLEMAP_INITIAL

    def insert(self, obj):
        with self._lock:
            return self._insert(obj)

    """Low-level insert, this assumes `self._lock` is held."""
    def _insert(self, obj):
        handle = self._counter
        self._counter += _UNIFFI_HANDLEMAP_DELTA
        self._map[handle] = obj
        return handle

    def get(self, handle):
        try:
            with self._lock:
                return self._map[handle]
        except KeyError:
            raise InternalError(f"_UniffiHandleMap.get: Invalid handle {handle}")

    def clone(self, handle):
        try:
            with self._lock:
                obj = self._map[handle]
                return self._insert(obj)
        except KeyError:
            raise InternalError(f"_UniffiHandleMap.clone: Invalid handle {handle}")

    def remove(self, handle):
        try:
            with self._lock:
                return self._map.pop(handle)
        except KeyError:
            raise InternalError(f"_UniffiHandleMap.remove: Invalid handle: {handle}")

    def __len__(self):
        return len(self._map)
# Types conforming to `_UniffiConverterPrimitive` pass themselves directly over the FFI.
class _UniffiConverterPrimitive:
    @classmethod
    def lift(cls, value):
        return value

    @classmethod
    def lower(cls, value):
        return value

class _UniffiConverterPrimitiveInt(_UniffiConverterPrimitive):
    @classmethod
    def check_lower(cls, value):
        try:
            value = value.__index__()
        except Exception:
            raise TypeError("'{}' object cannot be interpreted as an integer".format(type(value).__name__))
        if not isinstance(value, int):
            raise TypeError("__index__ returned non-int (type {})".format(type(value).__name__))
        if not cls.VALUE_MIN <= value < cls.VALUE_MAX:
            raise ValueError("{} requires {} <= value < {}".format(cls.CLASS_NAME, cls.VALUE_MIN, cls.VALUE_MAX))

class _UniffiConverterPrimitiveFloat(_UniffiConverterPrimitive):
    @classmethod
    def check_lower(cls, value):
        try:
            value = value.__float__()
        except Exception:
            raise TypeError("must be real number, not {}".format(type(value).__name__))
        if not isinstance(value, float):
            raise TypeError("__float__ returned non-float (type {})".format(type(value).__name__))

# Helper class for wrapper types that will always go through a _UniffiRustBuffer.
# Classes should inherit from this and implement the `read` and `write` static methods.
class _UniffiConverterRustBuffer:
    @classmethod
    def lift(cls, rbuf):
        with rbuf.consume_with_stream() as stream:
            return cls.read(stream)

    @classmethod
    def lower(cls, value):
        with _UniffiRustBuffer.alloc_with_builder() as builder:
            cls.write(value, builder)
            return builder.finalize()

# Contains loading, initialization code, and the FFI Function declarations.
# Define some ctypes FFI types that we use in the library

"""
Function pointer for a Rust task, which a callback function that takes a opaque pointer
"""
_UNIFFI_RUST_TASK = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int8)

def _uniffi_future_callback_t(return_type):
    """
    Factory function to create callback function types for async functions
    """
    return ctypes.CFUNCTYPE(None, ctypes.c_uint64, return_type, _UniffiRustCallStatus)

def _uniffi_load_indirect():
    """
    This is how we find and load the dynamic library provided by the component.
    For now we just look it up by name.
    """
    if sys.platform == "darwin":
        libname = "lib{}.dylib"
    elif sys.platform.startswith("win"):
        # As of python3.8, ctypes does not seem to search $PATH when loading DLLs.
        # We could use `os.add_dll_directory` to configure the search path, but
        # it doesn't feel right to mess with application-wide settings. Let's
        # assume that the `.dll` is next to the `.py` file and load by full path.
        libname = os.path.join(
            os.path.dirname(__file__),
            "{}.dll",
        )
    else:
        # Anything else must be an ELF platform - Linux, *BSD, Solaris/illumos
        libname = "lib{}.so"

    libname = libname.format("cua_driver_sdk")
    path = os.path.join(os.path.dirname(__file__), libname)
    lib = ctypes.cdll.LoadLibrary(path)
    return lib

def _uniffi_check_contract_api_version(lib):
    # Get the bindings contract version from our ComponentInterface
    bindings_contract_version = 30
    # Get the scaffolding contract version by calling the into the dylib
    scaffolding_contract_version = lib.ffi_cua_driver_contract_uniffi_contract_version()
    if bindings_contract_version != scaffolding_contract_version:
        raise InternalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")

def _uniffi_check_api_checksums(lib):
    pass

# A ctypes library to expose the extern-C FFI definitions.
# This is an implementation detail which will be called internally by the public API.

_UniffiLib = _uniffi_load_indirect()
_UniffiLib.ffi_cua_driver_contract_rustbuffer_alloc.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rustbuffer_alloc.restype = _UniffiRustBuffer
_UniffiLib.ffi_cua_driver_contract_rustbuffer_from_bytes.argtypes = (
    _UniffiForeignBytes,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rustbuffer_from_bytes.restype = _UniffiRustBuffer
_UniffiLib.ffi_cua_driver_contract_rustbuffer_free.argtypes = (
    _UniffiRustBuffer,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rustbuffer_free.restype = None
_UniffiLib.ffi_cua_driver_contract_rustbuffer_reserve.argtypes = (
    _UniffiRustBuffer,
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rustbuffer_reserve.restype = _UniffiRustBuffer
_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.c_int8,
)
_UNIFFI_FOREIGN_FUTURE_DROPPED_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64,
)
class _UniffiForeignFutureDroppedCallbackStruct(ctypes.Structure):
    _fields_ = [
        ("handle", ctypes.c_uint64),
        ("free", _UNIFFI_FOREIGN_FUTURE_DROPPED_CALLBACK),
    ]
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_u8.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_u8.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_u8.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_u8.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_u8.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_u8.restype = ctypes.c_uint8
_UniffiLib.ffi_cua_driver_contract_rust_future_free_u8.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_u8.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_i8.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_i8.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_i8.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_i8.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_i8.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_i8.restype = ctypes.c_int8
_UniffiLib.ffi_cua_driver_contract_rust_future_free_i8.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_i8.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_u16.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_u16.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_u16.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_u16.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_u16.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_u16.restype = ctypes.c_uint16
_UniffiLib.ffi_cua_driver_contract_rust_future_free_u16.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_u16.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_i16.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_i16.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_i16.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_i16.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_i16.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_i16.restype = ctypes.c_int16
_UniffiLib.ffi_cua_driver_contract_rust_future_free_i16.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_i16.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_u32.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_u32.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_u32.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_u32.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_u32.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_u32.restype = ctypes.c_uint32
_UniffiLib.ffi_cua_driver_contract_rust_future_free_u32.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_u32.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_i32.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_i32.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_i32.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_i32.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_i32.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_i32.restype = ctypes.c_int32
_UniffiLib.ffi_cua_driver_contract_rust_future_free_i32.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_i32.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_u64.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_u64.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_u64.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_u64.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_u64.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_u64.restype = ctypes.c_uint64
_UniffiLib.ffi_cua_driver_contract_rust_future_free_u64.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_u64.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_i64.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_i64.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_i64.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_i64.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_i64.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_i64.restype = ctypes.c_int64
_UniffiLib.ffi_cua_driver_contract_rust_future_free_i64.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_i64.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_f32.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_f32.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_f32.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_f32.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_f32.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_f32.restype = ctypes.c_float
_UniffiLib.ffi_cua_driver_contract_rust_future_free_f32.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_f32.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_f64.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_f64.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_f64.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_f64.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_f64.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_f64.restype = ctypes.c_double
_UniffiLib.ffi_cua_driver_contract_rust_future_free_f64.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_f64.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_rust_buffer.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_rust_buffer.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_rust_buffer.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_rust_buffer.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_rust_buffer.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_rust_buffer.restype = _UniffiRustBuffer
_UniffiLib.ffi_cua_driver_contract_rust_future_free_rust_buffer.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_rust_buffer.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_void.argtypes = (
    ctypes.c_uint64,
    _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_poll_void.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_void.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_cancel_void.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_void.argtypes = (
    ctypes.c_uint64,
    ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.ffi_cua_driver_contract_rust_future_complete_void.restype = None
_UniffiLib.ffi_cua_driver_contract_rust_future_free_void.argtypes = (
    ctypes.c_uint64,
)
_UniffiLib.ffi_cua_driver_contract_rust_future_free_void.restype = None
_UniffiLib.ffi_cua_driver_contract_uniffi_contract_version.argtypes = (
)
_UniffiLib.ffi_cua_driver_contract_uniffi_contract_version.restype = ctypes.c_uint32

_uniffi_check_contract_api_version(_UniffiLib)
# _uniffi_check_api_checksums(_UniffiLib)



# Public interface members begin here.







class ActionDeliveryMode(enum.Enum):

    BACKGROUND = 0

    FOREGROUND = 1

    NOT_APPLICABLE = 2

    UNKNOWN = 3



class _UniffiFfiConverterTypeActionDeliveryMode(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ActionDeliveryMode.BACKGROUND
        if variant == 2:
            return ActionDeliveryMode.FOREGROUND
        if variant == 3:
            return ActionDeliveryMode.NOT_APPLICABLE
        if variant == 4:
            return ActionDeliveryMode.UNKNOWN
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == ActionDeliveryMode.BACKGROUND:
            return
        if value == ActionDeliveryMode.FOREGROUND:
            return
        if value == ActionDeliveryMode.NOT_APPLICABLE:
            return
        if value == ActionDeliveryMode.UNKNOWN:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == ActionDeliveryMode.BACKGROUND:
            buf.write_i32(1)
        if value == ActionDeliveryMode.FOREGROUND:
            buf.write_i32(2)
        if value == ActionDeliveryMode.NOT_APPLICABLE:
            buf.write_i32(3)
        if value == ActionDeliveryMode.UNKNOWN:
            buf.write_i32(4)



class _UniffiFfiConverterUInt32(_UniffiConverterPrimitiveInt):
    CLASS_NAME = "u32"
    VALUE_MIN = 0
    VALUE_MAX = 2**32

    @staticmethod
    def read(buf):
        return buf.read_u32()

    @staticmethod
    def write(value, buf):
        buf.write_u32(value)

class _UniffiFfiConverterOptionalUInt32(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterUInt32.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterUInt32.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterUInt32.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class ActionDelivery:
    def __init__(self, *, mode:ActionDeliveryMode, delivered_count:typing.Optional[int]):
        self.mode = mode
        self.delivered_count = delivered_count




    def __str__(self):
        return "ActionDelivery(mode={}, delivered_count={})".format(self.mode, self.delivered_count)
    def __eq__(self, other):
        if self.mode != other.mode:
            return False
        if self.delivered_count != other.delivered_count:
            return False
        return True

class _UniffiFfiConverterTypeActionDelivery(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ActionDelivery(
            mode=_UniffiFfiConverterTypeActionDeliveryMode.read(buf),
            delivered_count=_UniffiFfiConverterOptionalUInt32.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterTypeActionDeliveryMode.check_lower(value.mode)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.delivered_count)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterTypeActionDeliveryMode.write(value.mode, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.delivered_count, buf)

class _UniffiFfiConverterString:
    @staticmethod
    def check_lower(value):
        if not isinstance(value, str):
            raise TypeError("argument must be str, not {}".format(type(value).__name__))
        return value

    @staticmethod
    def read(buf):
        size = buf.read_i32()
        if size < 0:
            raise InternalError("Unexpected negative string length")
        utf8_bytes = buf.read(size)
        return utf8_bytes.decode("utf-8")

    @staticmethod
    def write(value, buf):
        utf8_bytes = value.encode("utf-8")
        buf.write_i32(len(utf8_bytes))
        buf.write(utf8_bytes)

    @staticmethod
    def lift(buf):
        with buf.consume_with_stream() as stream:
            return stream.read(stream.remaining()).decode("utf-8")

    @staticmethod
    def lower(value):
        with _UniffiRustBuffer.alloc_with_builder() as builder:
            builder.write(value.encode("utf-8"))
            return builder.finalize()

class _UniffiFfiConverterOptionalString(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterString.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterString.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterString.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class ActionError:
    """
    Why a `refused` action sent no input, and what to do instead.
"""
    def __init__(self, *, code:str, hint:typing.Optional[str]):
        self.code = code
        self.hint = hint




    def __str__(self):
        return "ActionError(code={}, hint={})".format(self.code, self.hint)
    def __eq__(self, other):
        if self.code != other.code:
            return False
        if self.hint != other.hint:
            return False
        return True

class _UniffiFfiConverterTypeActionError(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ActionError(
            code=_UniffiFfiConverterString.read(buf),
            hint=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.code)
        _UniffiFfiConverterOptionalString.check_lower(value.hint)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.code, buf)
        _UniffiFfiConverterOptionalString.write(value.hint, buf)






class ActionEscalationTarget(enum.Enum):

    PIXEL = 0

    FOREGROUND = 1

    PAGE = 2

    SESSION = 3



class _UniffiFfiConverterTypeActionEscalationTarget(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ActionEscalationTarget.PIXEL
        if variant == 2:
            return ActionEscalationTarget.FOREGROUND
        if variant == 3:
            return ActionEscalationTarget.PAGE
        if variant == 4:
            return ActionEscalationTarget.SESSION
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == ActionEscalationTarget.PIXEL:
            return
        if value == ActionEscalationTarget.FOREGROUND:
            return
        if value == ActionEscalationTarget.PAGE:
            return
        if value == ActionEscalationTarget.SESSION:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == ActionEscalationTarget.PIXEL:
            buf.write_i32(1)
        if value == ActionEscalationTarget.FOREGROUND:
            buf.write_i32(2)
        if value == ActionEscalationTarget.PAGE:
            buf.write_i32(3)
        if value == ActionEscalationTarget.SESSION:
            buf.write_i32(4)








class ActionEscalationReason(enum.Enum):

    ROUTE_UNAVAILABLE = 0

    DELIVERY_FAILED = 1

    EFFECT_UNCONFIRMED = 2

    SUSPECTED_NOOP = 3

    PERMISSION_REQUIRED = 4



class _UniffiFfiConverterTypeActionEscalationReason(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ActionEscalationReason.ROUTE_UNAVAILABLE
        if variant == 2:
            return ActionEscalationReason.DELIVERY_FAILED
        if variant == 3:
            return ActionEscalationReason.EFFECT_UNCONFIRMED
        if variant == 4:
            return ActionEscalationReason.SUSPECTED_NOOP
        if variant == 5:
            return ActionEscalationReason.PERMISSION_REQUIRED
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == ActionEscalationReason.ROUTE_UNAVAILABLE:
            return
        if value == ActionEscalationReason.DELIVERY_FAILED:
            return
        if value == ActionEscalationReason.EFFECT_UNCONFIRMED:
            return
        if value == ActionEscalationReason.SUSPECTED_NOOP:
            return
        if value == ActionEscalationReason.PERMISSION_REQUIRED:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == ActionEscalationReason.ROUTE_UNAVAILABLE:
            buf.write_i32(1)
        if value == ActionEscalationReason.DELIVERY_FAILED:
            buf.write_i32(2)
        if value == ActionEscalationReason.EFFECT_UNCONFIRMED:
            buf.write_i32(3)
        if value == ActionEscalationReason.SUSPECTED_NOOP:
            buf.write_i32(4)
        if value == ActionEscalationReason.PERMISSION_REQUIRED:
            buf.write_i32(5)



@dataclass
class ActionEscalation:
    def __init__(self, *, target:ActionEscalationTarget, reason:ActionEscalationReason):
        self.target = target
        self.reason = reason




    def __str__(self):
        return "ActionEscalation(target={}, reason={})".format(self.target, self.reason)
    def __eq__(self, other):
        if self.target != other.target:
            return False
        if self.reason != other.reason:
            return False
        return True

class _UniffiFfiConverterTypeActionEscalation(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ActionEscalation(
            target=_UniffiFfiConverterTypeActionEscalationTarget.read(buf),
            reason=_UniffiFfiConverterTypeActionEscalationReason.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterTypeActionEscalationTarget.check_lower(value.target)
        _UniffiFfiConverterTypeActionEscalationReason.check_lower(value.reason)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterTypeActionEscalationTarget.write(value.target, buf)
        _UniffiFfiConverterTypeActionEscalationReason.write(value.reason, buf)






class ActionEvidenceKind(enum.Enum):

    VALUE_READBACK = 0

    WINDOW_CHANGE = 1



class _UniffiFfiConverterTypeActionEvidenceKind(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ActionEvidenceKind.VALUE_READBACK
        if variant == 2:
            return ActionEvidenceKind.WINDOW_CHANGE
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == ActionEvidenceKind.VALUE_READBACK:
            return
        if value == ActionEvidenceKind.WINDOW_CHANGE:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == ActionEvidenceKind.VALUE_READBACK:
            buf.write_i32(1)
        if value == ActionEvidenceKind.WINDOW_CHANGE:
            buf.write_i32(2)



@dataclass
class ActionEvidence:
    def __init__(self, *, kind:ActionEvidenceKind, detail:typing.Optional[str]):
        self.kind = kind
        self.detail = detail




    def __str__(self):
        return "ActionEvidence(kind={}, detail={})".format(self.kind, self.detail)
    def __eq__(self, other):
        if self.kind != other.kind:
            return False
        if self.detail != other.detail:
            return False
        return True

class _UniffiFfiConverterTypeActionEvidence(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ActionEvidence(
            kind=_UniffiFfiConverterTypeActionEvidenceKind.read(buf),
            detail=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterTypeActionEvidenceKind.check_lower(value.kind)
        _UniffiFfiConverterOptionalString.check_lower(value.detail)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterTypeActionEvidenceKind.write(value.kind, buf)
        _UniffiFfiConverterOptionalString.write(value.detail, buf)

@dataclass
class ActionNextCall:
    """
    A call an agent can make next: `{tool, arguments}`.
"""
    def __init__(self, *, tool:str, arguments:str):
        self.tool = tool
        self.arguments = arguments




    def __str__(self):
        return "ActionNextCall(tool={}, arguments={})".format(self.tool, self.arguments)
    def __eq__(self, other):
        if self.tool != other.tool:
            return False
        if self.arguments != other.arguments:
            return False
        return True

class _UniffiFfiConverterTypeActionNextCall(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ActionNextCall(
            tool=_UniffiFfiConverterString.read(buf),
            arguments=_UniffiFfiConverterString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.tool)
        _UniffiFfiConverterString.check_lower(value.arguments)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.tool, buf)
        _UniffiFfiConverterString.write(value.arguments, buf)






class ActionEffect(enum.Enum):

    CONFIRMED = 0

    PARTIAL = 1

    UNVERIFIABLE = 2

    SUSPECTED_NOOP = 3

    REFUSED = 4



class _UniffiFfiConverterTypeActionEffect(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ActionEffect.CONFIRMED
        if variant == 2:
            return ActionEffect.PARTIAL
        if variant == 3:
            return ActionEffect.UNVERIFIABLE
        if variant == 4:
            return ActionEffect.SUSPECTED_NOOP
        if variant == 5:
            return ActionEffect.REFUSED
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == ActionEffect.CONFIRMED:
            return
        if value == ActionEffect.PARTIAL:
            return
        if value == ActionEffect.UNVERIFIABLE:
            return
        if value == ActionEffect.SUSPECTED_NOOP:
            return
        if value == ActionEffect.REFUSED:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == ActionEffect.CONFIRMED:
            buf.write_i32(1)
        if value == ActionEffect.PARTIAL:
            buf.write_i32(2)
        if value == ActionEffect.UNVERIFIABLE:
            buf.write_i32(3)
        if value == ActionEffect.SUSPECTED_NOOP:
            buf.write_i32(4)
        if value == ActionEffect.REFUSED:
            buf.write_i32(5)








class ActionRoute(enum.Enum):

    ACCESSIBILITY = 0

    SYNTHETIC_EVENTS = 1

    GLOBAL_INPUT = 2

    SYSTEM_API = 3

    DOM = 4

    TRUSTED_INPUT = 5



class _UniffiFfiConverterTypeActionRoute(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ActionRoute.ACCESSIBILITY
        if variant == 2:
            return ActionRoute.SYNTHETIC_EVENTS
        if variant == 3:
            return ActionRoute.GLOBAL_INPUT
        if variant == 4:
            return ActionRoute.SYSTEM_API
        if variant == 5:
            return ActionRoute.DOM
        if variant == 6:
            return ActionRoute.TRUSTED_INPUT
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == ActionRoute.ACCESSIBILITY:
            return
        if value == ActionRoute.SYNTHETIC_EVENTS:
            return
        if value == ActionRoute.GLOBAL_INPUT:
            return
        if value == ActionRoute.SYSTEM_API:
            return
        if value == ActionRoute.DOM:
            return
        if value == ActionRoute.TRUSTED_INPUT:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == ActionRoute.ACCESSIBILITY:
            buf.write_i32(1)
        if value == ActionRoute.SYNTHETIC_EVENTS:
            buf.write_i32(2)
        if value == ActionRoute.GLOBAL_INPUT:
            buf.write_i32(3)
        if value == ActionRoute.SYSTEM_API:
            buf.write_i32(4)
        if value == ActionRoute.DOM:
            buf.write_i32(5)
        if value == ActionRoute.TRUSTED_INPUT:
            buf.write_i32(6)



class _UniffiFfiConverterOptionalTypeActionDelivery(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeActionDelivery.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeActionDelivery.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeActionDelivery.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterSequenceTypeActionEvidence(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypeActionEvidence.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypeActionEvidence.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypeActionEvidence.read(buf) for i in range(count)
        ]

class _UniffiFfiConverterOptionalSequenceTypeActionEvidence(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterSequenceTypeActionEvidence.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterSequenceTypeActionEvidence.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterSequenceTypeActionEvidence.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterOptionalTypeActionEscalation(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeActionEscalation.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeActionEscalation.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeActionEscalation.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterOptionalTypeActionError(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeActionError.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeActionError.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeActionError.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterOptionalTypeActionNextCall(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeActionNextCall.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeActionNextCall.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeActionNextCall.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class ActionResult:
    def __init__(self, *, effect:ActionEffect, route:ActionRoute, delivery:typing.Optional[ActionDelivery], evidence:typing.Optional[typing.List[ActionEvidence]], escalation:typing.Optional[ActionEscalation], summary:typing.Optional[str], error:typing.Optional[ActionError], hint:typing.Optional[str], next_call:typing.Optional[ActionNextCall], fast_path:typing.Optional[str]):
        self.effect = effect
        self.route = route
        self.delivery = delivery
        self.evidence = evidence
        self.escalation = escalation
        self.summary = summary
        self.error = error
        self.hint = hint
        self.next_call = next_call
        self.fast_path = fast_path




    def __str__(self):
        return "ActionResult(effect={}, route={}, delivery={}, evidence={}, escalation={}, summary={}, error={}, hint={}, next_call={}, fast_path={})".format(self.effect, self.route, self.delivery, self.evidence, self.escalation, self.summary, self.error, self.hint, self.next_call, self.fast_path)
    def __eq__(self, other):
        if self.effect != other.effect:
            return False
        if self.route != other.route:
            return False
        if self.delivery != other.delivery:
            return False
        if self.evidence != other.evidence:
            return False
        if self.escalation != other.escalation:
            return False
        if self.summary != other.summary:
            return False
        if self.error != other.error:
            return False
        if self.hint != other.hint:
            return False
        if self.next_call != other.next_call:
            return False
        if self.fast_path != other.fast_path:
            return False
        return True

class _UniffiFfiConverterTypeActionResult(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ActionResult(
            effect=_UniffiFfiConverterTypeActionEffect.read(buf),
            route=_UniffiFfiConverterTypeActionRoute.read(buf),
            delivery=_UniffiFfiConverterOptionalTypeActionDelivery.read(buf),
            evidence=_UniffiFfiConverterOptionalSequenceTypeActionEvidence.read(buf),
            escalation=_UniffiFfiConverterOptionalTypeActionEscalation.read(buf),
            summary=_UniffiFfiConverterOptionalString.read(buf),
            error=_UniffiFfiConverterOptionalTypeActionError.read(buf),
            hint=_UniffiFfiConverterOptionalString.read(buf),
            next_call=_UniffiFfiConverterOptionalTypeActionNextCall.read(buf),
            fast_path=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterTypeActionEffect.check_lower(value.effect)
        _UniffiFfiConverterTypeActionRoute.check_lower(value.route)
        _UniffiFfiConverterOptionalTypeActionDelivery.check_lower(value.delivery)
        _UniffiFfiConverterOptionalSequenceTypeActionEvidence.check_lower(value.evidence)
        _UniffiFfiConverterOptionalTypeActionEscalation.check_lower(value.escalation)
        _UniffiFfiConverterOptionalString.check_lower(value.summary)
        _UniffiFfiConverterOptionalTypeActionError.check_lower(value.error)
        _UniffiFfiConverterOptionalString.check_lower(value.hint)
        _UniffiFfiConverterOptionalTypeActionNextCall.check_lower(value.next_call)
        _UniffiFfiConverterOptionalString.check_lower(value.fast_path)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterTypeActionEffect.write(value.effect, buf)
        _UniffiFfiConverterTypeActionRoute.write(value.route, buf)
        _UniffiFfiConverterOptionalTypeActionDelivery.write(value.delivery, buf)
        _UniffiFfiConverterOptionalSequenceTypeActionEvidence.write(value.evidence, buf)
        _UniffiFfiConverterOptionalTypeActionEscalation.write(value.escalation, buf)
        _UniffiFfiConverterOptionalString.write(value.summary, buf)
        _UniffiFfiConverterOptionalTypeActionError.write(value.error, buf)
        _UniffiFfiConverterOptionalString.write(value.hint, buf)
        _UniffiFfiConverterOptionalTypeActionNextCall.write(value.next_call, buf)
        _UniffiFfiConverterOptionalString.write(value.fast_path, 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 AppInfo:
    def __init__(self, *, pid:int, name:str, running:bool, active:bool, bundle_id:typing.Optional[str], launch_path:typing.Optional[str], kind:typing.Optional[str], last_used:typing.Optional[str]):
        self.pid = pid
        self.name = name
        self.running = running
        self.active = active
        self.bundle_id = bundle_id
        self.launch_path = launch_path
        self.kind = kind
        self.last_used = last_used




    def __str__(self):
        return "AppInfo(pid={}, name={}, running={}, active={}, bundle_id={}, launch_path={}, kind={}, last_used={})".format(self.pid, self.name, self.running, self.active, self.bundle_id, self.launch_path, self.kind, self.last_used)
    def __eq__(self, other):
        if self.pid != other.pid:
            return False
        if self.name != other.name:
            return False
        if self.running != other.running:
            return False
        if self.active != other.active:
            return False
        if self.bundle_id != other.bundle_id:
            return False
        if self.launch_path != other.launch_path:
            return False
        if self.kind != other.kind:
            return False
        if self.last_used != other.last_used:
            return False
        return True

class _UniffiFfiConverterTypeAppInfo(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return AppInfo(
            pid=_UniffiFfiConverterUInt32.read(buf),
            name=_UniffiFfiConverterString.read(buf),
            running=_UniffiFfiConverterBoolean.read(buf),
            active=_UniffiFfiConverterBoolean.read(buf),
            bundle_id=_UniffiFfiConverterOptionalString.read(buf),
            launch_path=_UniffiFfiConverterOptionalString.read(buf),
            kind=_UniffiFfiConverterOptionalString.read(buf),
            last_used=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterUInt32.check_lower(value.pid)
        _UniffiFfiConverterString.check_lower(value.name)
        _UniffiFfiConverterBoolean.check_lower(value.running)
        _UniffiFfiConverterBoolean.check_lower(value.active)
        _UniffiFfiConverterOptionalString.check_lower(value.bundle_id)
        _UniffiFfiConverterOptionalString.check_lower(value.launch_path)
        _UniffiFfiConverterOptionalString.check_lower(value.kind)
        _UniffiFfiConverterOptionalString.check_lower(value.last_used)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterUInt32.write(value.pid, buf)
        _UniffiFfiConverterString.write(value.name, buf)
        _UniffiFfiConverterBoolean.write(value.running, buf)
        _UniffiFfiConverterBoolean.write(value.active, buf)
        _UniffiFfiConverterOptionalString.write(value.bundle_id, buf)
        _UniffiFfiConverterOptionalString.write(value.launch_path, buf)
        _UniffiFfiConverterOptionalString.write(value.kind, buf)
        _UniffiFfiConverterOptionalString.write(value.last_used, buf)

class _UniffiFfiConverterFloat64(_UniffiConverterPrimitiveFloat):
    @staticmethod
    def read(buf):
        return buf.read_double()

    @staticmethod
    def write(value, buf):
        buf.write_double(value)

class _UniffiFfiConverterOptionalFloat64(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterFloat64.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterFloat64.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterFloat64.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class BoundsExpectation:
    def __init__(self, *, x:float, y:float, width:float, height:float, tolerance_px:typing.Optional[float]):
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.tolerance_px = tolerance_px




    def __str__(self):
        return "BoundsExpectation(x={}, y={}, width={}, height={}, tolerance_px={})".format(self.x, self.y, self.width, self.height, self.tolerance_px)
    def __eq__(self, other):
        if self.x != other.x:
            return False
        if self.y != other.y:
            return False
        if self.width != other.width:
            return False
        if self.height != other.height:
            return False
        if self.tolerance_px != other.tolerance_px:
            return False
        return True

class _UniffiFfiConverterTypeBoundsExpectation(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return BoundsExpectation(
            x=_UniffiFfiConverterFloat64.read(buf),
            y=_UniffiFfiConverterFloat64.read(buf),
            width=_UniffiFfiConverterFloat64.read(buf),
            height=_UniffiFfiConverterFloat64.read(buf),
            tolerance_px=_UniffiFfiConverterOptionalFloat64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterFloat64.check_lower(value.x)
        _UniffiFfiConverterFloat64.check_lower(value.y)
        _UniffiFfiConverterFloat64.check_lower(value.width)
        _UniffiFfiConverterFloat64.check_lower(value.height)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.tolerance_px)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterFloat64.write(value.x, buf)
        _UniffiFfiConverterFloat64.write(value.y, buf)
        _UniffiFfiConverterFloat64.write(value.width, buf)
        _UniffiFfiConverterFloat64.write(value.height, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.tolerance_px, buf)

class _UniffiFfiConverterUInt64(_UniffiConverterPrimitiveInt):
    CLASS_NAME = "u64"
    VALUE_MIN = 0
    VALUE_MAX = 2**64

    @staticmethod
    def read(buf):
        return buf.read_u64()

    @staticmethod
    def write(value, buf):
        buf.write_u64(value)






class ActionTarget:
    """
    Exact capture/input target selected independently for each action.

    `display_id="primary"` is the portable desktop target in this release.
    Platforms that cannot address another display reject it explicitly rather
    than silently changing coordinate spaces.
"""
    def __init__(self):
        raise RuntimeError("ActionTarget cannot be instantiated directly")

    # Each enum variant is a nested class of the enum itself.
    @dataclass
    class WINDOW:

        def __init__(self, pid:int, window_id:int):
            self.pid = pid


            self.window_id = window_id


            pass





        def __str__(self):
            return "ActionTarget.WINDOW(pid={}, window_id={})".format(self.pid, self.window_id)
        def __eq__(self, other):
            if not isinstance(other, ActionTarget):
                return NotImplemented
            if not other.is_WINDOW():
                return False
            if self.pid != other.pid:
                return False
            if self.window_id != other.window_id:
                return False
            return True

    @dataclass
    class DESKTOP:

        def __init__(self, display_id:str):
            self.display_id = display_id


            pass





        def __str__(self):
            return "ActionTarget.DESKTOP(display_id={})".format(self.display_id)
        def __eq__(self, other):
            if not isinstance(other, ActionTarget):
                return NotImplemented
            if not other.is_DESKTOP():
                return False
            if self.display_id != other.display_id:
                return False
            return True



    # For each variant, we have `is_NAME` and `is_name` methods for easily checking
    # whether an instance is that variant.
    def is_WINDOW(self) -> bool:
        return isinstance(self, ActionTarget.WINDOW)
    def is_window(self) -> bool:
        return isinstance(self, ActionTarget.WINDOW)
    def is_DESKTOP(self) -> bool:
        return isinstance(self, ActionTarget.DESKTOP)
    def is_desktop(self) -> bool:
        return isinstance(self, ActionTarget.DESKTOP)


# Now, a little trick - we make each nested variant class be a subclass of the main
# enum class, so that method calls and instance checks etc will work intuitively.
# We might be able to do this a little more neatly with a metaclass, but this'll do.
ActionTarget.WINDOW = type("ActionTarget.WINDOW", (ActionTarget.WINDOW, ActionTarget,), {})  # type: ignore
ActionTarget.DESKTOP = type("ActionTarget.DESKTOP", (ActionTarget.DESKTOP, ActionTarget,), {})  # type: ignore




class _UniffiFfiConverterTypeActionTarget(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ActionTarget.WINDOW(
                _UniffiFfiConverterUInt32.read(buf),
                _UniffiFfiConverterUInt64.read(buf),
            )
        if variant == 2:
            return ActionTarget.DESKTOP(
                _UniffiFfiConverterString.read(buf),
            )
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value.is_WINDOW():
            _UniffiFfiConverterUInt32.check_lower(value.pid)
            _UniffiFfiConverterUInt64.check_lower(value.window_id)
            return
        if value.is_DESKTOP():
            _UniffiFfiConverterString.check_lower(value.display_id)
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value.is_WINDOW():
            buf.write_i32(1)
            _UniffiFfiConverterUInt32.write(value.pid, buf)
            _UniffiFfiConverterUInt64.write(value.window_id, buf)
        if value.is_DESKTOP():
            buf.write_i32(2)
            _UniffiFfiConverterString.write(value.display_id, buf)








class ClickPosition:
    def __init__(self):
        raise RuntimeError("ClickPosition cannot be instantiated directly")

    # Each enum variant is a nested class of the enum itself.
    @dataclass
    class COORDINATES:

        def __init__(self, x:float, y:float):
            self.x = x


            self.y = y


            pass





        def __str__(self):
            return "ClickPosition.COORDINATES(x={}, y={})".format(self.x, self.y)
        def __eq__(self, other):
            if not isinstance(other, ClickPosition):
                return NotImplemented
            if not other.is_COORDINATES():
                return False
            if self.x != other.x:
                return False
            if self.y != other.y:
                return False
            return True

    @dataclass
    class ELEMENT:

        def __init__(self, element_token:str):
            self.element_token = element_token


            pass





        def __str__(self):
            return "ClickPosition.ELEMENT(element_token={})".format(self.element_token)
        def __eq__(self, other):
            if not isinstance(other, ClickPosition):
                return NotImplemented
            if not other.is_ELEMENT():
                return False
            if self.element_token != other.element_token:
                return False
            return True

    @dataclass
    class CAPTURED_COORDINATES:

        def __init__(self, x:float, y:float, capture_id:str):
            self.x = x


            self.y = y


            self.capture_id = capture_id


            pass





        def __str__(self):
            return "ClickPosition.CAPTURED_COORDINATES(x={}, y={}, capture_id={})".format(self.x, self.y, self.capture_id)
        def __eq__(self, other):
            if not isinstance(other, ClickPosition):
                return NotImplemented
            if not other.is_CAPTURED_COORDINATES():
                return False
            if self.x != other.x:
                return False
            if self.y != other.y:
                return False
            if self.capture_id != other.capture_id:
                return False
            return True



    # For each variant, we have `is_NAME` and `is_name` methods for easily checking
    # whether an instance is that variant.
    def is_COORDINATES(self) -> bool:
        return isinstance(self, ClickPosition.COORDINATES)
    def is_coordinates(self) -> bool:
        return isinstance(self, ClickPosition.COORDINATES)
    def is_ELEMENT(self) -> bool:
        return isinstance(self, ClickPosition.ELEMENT)
    def is_element(self) -> bool:
        return isinstance(self, ClickPosition.ELEMENT)
    def is_CAPTURED_COORDINATES(self) -> bool:
        return isinstance(self, ClickPosition.CAPTURED_COORDINATES)
    def is_captured_coordinates(self) -> bool:
        return isinstance(self, ClickPosition.CAPTURED_COORDINATES)


# Now, a little trick - we make each nested variant class be a subclass of the main
# enum class, so that method calls and instance checks etc will work intuitively.
# We might be able to do this a little more neatly with a metaclass, but this'll do.
ClickPosition.COORDINATES = type("ClickPosition.COORDINATES", (ClickPosition.COORDINATES, ClickPosition,), {})  # type: ignore
ClickPosition.ELEMENT = type("ClickPosition.ELEMENT", (ClickPosition.ELEMENT, ClickPosition,), {})  # type: ignore
ClickPosition.CAPTURED_COORDINATES = type("ClickPosition.CAPTURED_COORDINATES", (ClickPosition.CAPTURED_COORDINATES, ClickPosition,), {})  # type: ignore




class _UniffiFfiConverterTypeClickPosition(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ClickPosition.COORDINATES(
                _UniffiFfiConverterFloat64.read(buf),
                _UniffiFfiConverterFloat64.read(buf),
            )
        if variant == 2:
            return ClickPosition.ELEMENT(
                _UniffiFfiConverterString.read(buf),
            )
        if variant == 3:
            return ClickPosition.CAPTURED_COORDINATES(
                _UniffiFfiConverterFloat64.read(buf),
                _UniffiFfiConverterFloat64.read(buf),
                _UniffiFfiConverterString.read(buf),
            )
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value.is_COORDINATES():
            _UniffiFfiConverterFloat64.check_lower(value.x)
            _UniffiFfiConverterFloat64.check_lower(value.y)
            return
        if value.is_ELEMENT():
            _UniffiFfiConverterString.check_lower(value.element_token)
            return
        if value.is_CAPTURED_COORDINATES():
            _UniffiFfiConverterFloat64.check_lower(value.x)
            _UniffiFfiConverterFloat64.check_lower(value.y)
            _UniffiFfiConverterString.check_lower(value.capture_id)
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value.is_COORDINATES():
            buf.write_i32(1)
            _UniffiFfiConverterFloat64.write(value.x, buf)
            _UniffiFfiConverterFloat64.write(value.y, buf)
        if value.is_ELEMENT():
            buf.write_i32(2)
            _UniffiFfiConverterString.write(value.element_token, buf)
        if value.is_CAPTURED_COORDINATES():
            buf.write_i32(3)
            _UniffiFfiConverterFloat64.write(value.x, buf)
            _UniffiFfiConverterFloat64.write(value.y, buf)
            _UniffiFfiConverterString.write(value.capture_id, buf)








class InputDeliveryMode(enum.Enum):

    BACKGROUND = 0

    FOREGROUND = 1



class _UniffiFfiConverterTypeInputDeliveryMode(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return InputDeliveryMode.BACKGROUND
        if variant == 2:
            return InputDeliveryMode.FOREGROUND
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == InputDeliveryMode.BACKGROUND:
            return
        if value == InputDeliveryMode.FOREGROUND:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == InputDeliveryMode.BACKGROUND:
            buf.write_i32(1)
        if value == InputDeliveryMode.FOREGROUND:
            buf.write_i32(2)








class ClickButton(enum.Enum):

    LEFT = 0

    RIGHT = 1

    MIDDLE = 2



class _UniffiFfiConverterTypeClickButton(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ClickButton.LEFT
        if variant == 2:
            return ClickButton.RIGHT
        if variant == 3:
            return ClickButton.MIDDLE
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == ClickButton.LEFT:
            return
        if value == ClickButton.RIGHT:
            return
        if value == ClickButton.MIDDLE:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == ClickButton.LEFT:
            buf.write_i32(1)
        if value == ClickButton.RIGHT:
            buf.write_i32(2)
        if value == ClickButton.MIDDLE:
            buf.write_i32(3)



class _UniffiFfiConverterOptionalTypeClickButton(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeClickButton.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeClickButton.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeClickButton.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class ClickInput:
    def __init__(self, *, target:ActionTarget, position:ClickPosition, delivery_mode:InputDeliveryMode, session:typing.Optional[str], button:typing.Optional[ClickButton], count:typing.Optional[int]):
        self.target = target
        self.position = position
        self.delivery_mode = delivery_mode
        self.session = session
        self.button = button
        self.count = count




    def __str__(self):
        return "ClickInput(target={}, position={}, delivery_mode={}, session={}, button={}, count={})".format(self.target, self.position, self.delivery_mode, self.session, self.button, self.count)
    def __eq__(self, other):
        if self.target != other.target:
            return False
        if self.position != other.position:
            return False
        if self.delivery_mode != other.delivery_mode:
            return False
        if self.session != other.session:
            return False
        if self.button != other.button:
            return False
        if self.count != other.count:
            return False
        return True

class _UniffiFfiConverterTypeClickInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ClickInput(
            target=_UniffiFfiConverterTypeActionTarget.read(buf),
            position=_UniffiFfiConverterTypeClickPosition.read(buf),
            delivery_mode=_UniffiFfiConverterTypeInputDeliveryMode.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
            button=_UniffiFfiConverterOptionalTypeClickButton.read(buf),
            count=_UniffiFfiConverterOptionalUInt32.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterTypeActionTarget.check_lower(value.target)
        _UniffiFfiConverterTypeClickPosition.check_lower(value.position)
        _UniffiFfiConverterTypeInputDeliveryMode.check_lower(value.delivery_mode)
        _UniffiFfiConverterOptionalString.check_lower(value.session)
        _UniffiFfiConverterOptionalTypeClickButton.check_lower(value.button)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.count)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterTypeActionTarget.write(value.target, buf)
        _UniffiFfiConverterTypeClickPosition.write(value.position, buf)
        _UniffiFfiConverterTypeInputDeliveryMode.write(value.delivery_mode, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)
        _UniffiFfiConverterOptionalTypeClickButton.write(value.button, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.count, buf)

@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)






class CursorEffectSetting(enum.Enum):
    """
    One cursor effect: `on`, `off`, or `default` (the style's own setting).
"""

    ON = 0

    OFF = 1

    DEFAULT = 2



class _UniffiFfiConverterTypeCursorEffectSetting(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return CursorEffectSetting.ON
        if variant == 2:
            return CursorEffectSetting.OFF
        if variant == 3:
            return CursorEffectSetting.DEFAULT
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if type(value) is bool:
            value = CursorEffectSetting.ON if value else CursorEffectSetting.OFF
        if value == CursorEffectSetting.ON:
            return
        if value == CursorEffectSetting.OFF:
            return
        if value == CursorEffectSetting.DEFAULT:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if type(value) is bool:
            value = CursorEffectSetting.ON if value else CursorEffectSetting.OFF
        if value == CursorEffectSetting.ON:
            buf.write_i32(1)
        if value == CursorEffectSetting.OFF:
            buf.write_i32(2)
        if value == CursorEffectSetting.DEFAULT:
            buf.write_i32(3)



class _UniffiFfiConverterOptionalTypeCursorEffectSetting(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeCursorEffectSetting.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeCursorEffectSetting.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeCursorEffectSetting.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class CursorMotionEffects:
    """
    Per-effect overrides for the agent cursor. An omitted field keeps the current setting.
    `on` and `off` set it; `default` restores the style default.
"""
    def __init__(self, *, trail:typing.Optional[typing.Union[CursorEffectSetting, bool]], glow:typing.Optional[typing.Union[CursorEffectSetting, bool]], magnet:typing.Optional[typing.Union[CursorEffectSetting, bool]], ripple:typing.Optional[typing.Union[CursorEffectSetting, bool]], squish:typing.Optional[typing.Union[CursorEffectSetting, bool]]):
        self.trail = trail
        self.glow = glow
        self.magnet = magnet
        self.ripple = ripple
        self.squish = squish




    def __str__(self):
        return "CursorMotionEffects(trail={}, glow={}, magnet={}, ripple={}, squish={})".format(self.trail, self.glow, self.magnet, self.ripple, self.squish)
    def __eq__(self, other):
        if self.trail != other.trail:
            return False
        if self.glow != other.glow:
            return False
        if self.magnet != other.magnet:
            return False
        if self.ripple != other.ripple:
            return False
        if self.squish != other.squish:
            return False
        return True

class _UniffiFfiConverterTypeCursorMotionEffects(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return CursorMotionEffects(
            trail=_UniffiFfiConverterOptionalTypeCursorEffectSetting.read(buf),
            glow=_UniffiFfiConverterOptionalTypeCursorEffectSetting.read(buf),
            magnet=_UniffiFfiConverterOptionalTypeCursorEffectSetting.read(buf),
            ripple=_UniffiFfiConverterOptionalTypeCursorEffectSetting.read(buf),
            squish=_UniffiFfiConverterOptionalTypeCursorEffectSetting.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalTypeCursorEffectSetting.check_lower(value.trail)
        _UniffiFfiConverterOptionalTypeCursorEffectSetting.check_lower(value.glow)
        _UniffiFfiConverterOptionalTypeCursorEffectSetting.check_lower(value.magnet)
        _UniffiFfiConverterOptionalTypeCursorEffectSetting.check_lower(value.ripple)
        _UniffiFfiConverterOptionalTypeCursorEffectSetting.check_lower(value.squish)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalTypeCursorEffectSetting.write(value.trail, buf)
        _UniffiFfiConverterOptionalTypeCursorEffectSetting.write(value.glow, buf)
        _UniffiFfiConverterOptionalTypeCursorEffectSetting.write(value.magnet, buf)
        _UniffiFfiConverterOptionalTypeCursorEffectSetting.write(value.ripple, buf)
        _UniffiFfiConverterOptionalTypeCursorEffectSetting.write(value.squish, buf)

@dataclass
class CursorMotionEffectsOutput:
    """
    Effects in use after applying overrides to the style's defaults.
"""
    def __init__(self, *, trail:bool, glow:bool, magnet:bool, ripple:bool, squish:bool):
        self.trail = trail
        self.glow = glow
        self.magnet = magnet
        self.ripple = ripple
        self.squish = squish




    def __str__(self):
        return "CursorMotionEffectsOutput(trail={}, glow={}, magnet={}, ripple={}, squish={})".format(self.trail, self.glow, self.magnet, self.ripple, self.squish)
    def __eq__(self, other):
        if self.trail != other.trail:
            return False
        if self.glow != other.glow:
            return False
        if self.magnet != other.magnet:
            return False
        if self.ripple != other.ripple:
            return False
        if self.squish != other.squish:
            return False
        return True

class _UniffiFfiConverterTypeCursorMotionEffectsOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return CursorMotionEffectsOutput(
            trail=_UniffiFfiConverterBoolean.read(buf),
            glow=_UniffiFfiConverterBoolean.read(buf),
            magnet=_UniffiFfiConverterBoolean.read(buf),
            ripple=_UniffiFfiConverterBoolean.read(buf),
            squish=_UniffiFfiConverterBoolean.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterBoolean.check_lower(value.trail)
        _UniffiFfiConverterBoolean.check_lower(value.glow)
        _UniffiFfiConverterBoolean.check_lower(value.magnet)
        _UniffiFfiConverterBoolean.check_lower(value.ripple)
        _UniffiFfiConverterBoolean.check_lower(value.squish)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterBoolean.write(value.trail, buf)
        _UniffiFfiConverterBoolean.write(value.glow, buf)
        _UniffiFfiConverterBoolean.write(value.magnet, buf)
        _UniffiFfiConverterBoolean.write(value.ripple, buf)
        _UniffiFfiConverterBoolean.write(value.squish, buf)






class CursorMotionStyle(enum.Enum):

    SIGNATURE_ARC = 0

    SPRING_SETTLE = 1

    MAGNETIC = 2

    COMET_SWOOP = 3

    ADAPTIVE = 4

    CLASSIC = 5



class _UniffiFfiConverterTypeCursorMotionStyle(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return CursorMotionStyle.SIGNATURE_ARC
        if variant == 2:
            return CursorMotionStyle.SPRING_SETTLE
        if variant == 3:
            return CursorMotionStyle.MAGNETIC
        if variant == 4:
            return CursorMotionStyle.COMET_SWOOP
        if variant == 5:
            return CursorMotionStyle.ADAPTIVE
        if variant == 6:
            return CursorMotionStyle.CLASSIC
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == CursorMotionStyle.SIGNATURE_ARC:
            return
        if value == CursorMotionStyle.SPRING_SETTLE:
            return
        if value == CursorMotionStyle.MAGNETIC:
            return
        if value == CursorMotionStyle.COMET_SWOOP:
            return
        if value == CursorMotionStyle.ADAPTIVE:
            return
        if value == CursorMotionStyle.CLASSIC:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == CursorMotionStyle.SIGNATURE_ARC:
            buf.write_i32(1)
        if value == CursorMotionStyle.SPRING_SETTLE:
            buf.write_i32(2)
        if value == CursorMotionStyle.MAGNETIC:
            buf.write_i32(3)
        if value == CursorMotionStyle.COMET_SWOOP:
            buf.write_i32(4)
        if value == CursorMotionStyle.ADAPTIVE:
            buf.write_i32(5)
        if value == CursorMotionStyle.CLASSIC:
            buf.write_i32(6)



class _UniffiFfiConverterOptionalTypeCursorMotionStyle(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeCursorMotionStyle.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeCursorMotionStyle.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeCursorMotionStyle.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")






class CursorMotionTiming(enum.Enum):

    NATIVE = 0

    FITTS = 1

    FIXED = 2

    RELAXED = 3

    STEADY = 4

    CALM = 5

    DELIBERATE = 6



class _UniffiFfiConverterTypeCursorMotionTiming(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return CursorMotionTiming.NATIVE
        if variant == 2:
            return CursorMotionTiming.FITTS
        if variant == 3:
            return CursorMotionTiming.FIXED
        if variant == 4:
            return CursorMotionTiming.RELAXED
        if variant == 5:
            return CursorMotionTiming.STEADY
        if variant == 6:
            return CursorMotionTiming.CALM
        if variant == 7:
            return CursorMotionTiming.DELIBERATE
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == CursorMotionTiming.NATIVE:
            return
        if value == CursorMotionTiming.FITTS:
            return
        if value == CursorMotionTiming.FIXED:
            return
        if value == CursorMotionTiming.RELAXED:
            return
        if value == CursorMotionTiming.STEADY:
            return
        if value == CursorMotionTiming.CALM:
            return
        if value == CursorMotionTiming.DELIBERATE:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == CursorMotionTiming.NATIVE:
            buf.write_i32(1)
        if value == CursorMotionTiming.FITTS:
            buf.write_i32(2)
        if value == CursorMotionTiming.FIXED:
            buf.write_i32(3)
        if value == CursorMotionTiming.RELAXED:
            buf.write_i32(4)
        if value == CursorMotionTiming.STEADY:
            buf.write_i32(5)
        if value == CursorMotionTiming.CALM:
            buf.write_i32(6)
        if value == CursorMotionTiming.DELIBERATE:
            buf.write_i32(7)



class _UniffiFfiConverterOptionalTypeCursorMotionTiming(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeCursorMotionTiming.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeCursorMotionTiming.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeCursorMotionTiming.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterOptionalTypeCursorMotionEffectsOutput(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeCursorMotionEffectsOutput.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeCursorMotionEffectsOutput.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeCursorMotionEffectsOutput.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@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, style:typing.Optional[CursorMotionStyle], timing:typing.Optional[CursorMotionTiming], effects:typing.Optional[CursorMotionEffectsOutput]):
        self.start_handle = start_handle
        self.end_handle = end_handle
        self.arc_size = arc_size
        self.arc_flow = arc_flow
        self.spring = spring
        self.glide_duration_ms = glide_duration_ms
        self.dwell_after_click_ms = dwell_after_click_ms
        self.idle_hide_ms = idle_hide_ms
        self.turn_radius = turn_radius
        self.style = style
        self.timing = timing
        self.effects = effects




    def __str__(self):
        return "CursorMotionOutput(start_handle={}, end_handle={}, arc_size={}, arc_flow={}, spring={}, glide_duration_ms={}, dwell_after_click_ms={}, idle_hide_ms={}, turn_radius={}, style={}, timing={}, effects={})".format(self.start_handle, self.end_handle, self.arc_size, self.arc_flow, self.spring, self.glide_duration_ms, self.dwell_after_click_ms, self.idle_hide_ms, self.turn_radius, self.style, self.timing, self.effects)
    def __eq__(self, other):
        if self.start_handle != other.start_handle:
            return False
        if self.end_handle != other.end_handle:
            return False
        if self.arc_size != other.arc_size:
            return False
        if self.arc_flow != other.arc_flow:
            return False
        if self.spring != other.spring:
            return False
        if self.glide_duration_ms != other.glide_duration_ms:
            return False
        if self.dwell_after_click_ms != other.dwell_after_click_ms:
            return False
        if self.idle_hide_ms != other.idle_hide_ms:
            return False
        if self.turn_radius != other.turn_radius:
            return False
        if self.style != other.style:
            return False
        if self.timing != other.timing:
            return False
        if self.effects != other.effects:
            return False
        return True

class _UniffiFfiConverterTypeCursorMotionOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return CursorMotionOutput(
            start_handle=_UniffiFfiConverterFloat64.read(buf),
            end_handle=_UniffiFfiConverterFloat64.read(buf),
            arc_size=_UniffiFfiConverterFloat64.read(buf),
            arc_flow=_UniffiFfiConverterFloat64.read(buf),
            spring=_UniffiFfiConverterFloat64.read(buf),
            glide_duration_ms=_UniffiFfiConverterFloat64.read(buf),
            dwell_after_click_ms=_UniffiFfiConverterFloat64.read(buf),
            idle_hide_ms=_UniffiFfiConverterFloat64.read(buf),
            turn_radius=_UniffiFfiConverterFloat64.read(buf),
            style=_UniffiFfiConverterOptionalTypeCursorMotionStyle.read(buf),
            timing=_UniffiFfiConverterOptionalTypeCursorMotionTiming.read(buf),
            effects=_UniffiFfiConverterOptionalTypeCursorMotionEffectsOutput.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterFloat64.check_lower(value.start_handle)
        _UniffiFfiConverterFloat64.check_lower(value.end_handle)
        _UniffiFfiConverterFloat64.check_lower(value.arc_size)
        _UniffiFfiConverterFloat64.check_lower(value.arc_flow)
        _UniffiFfiConverterFloat64.check_lower(value.spring)
        _UniffiFfiConverterFloat64.check_lower(value.glide_duration_ms)
        _UniffiFfiConverterFloat64.check_lower(value.dwell_after_click_ms)
        _UniffiFfiConverterFloat64.check_lower(value.idle_hide_ms)
        _UniffiFfiConverterFloat64.check_lower(value.turn_radius)
        _UniffiFfiConverterOptionalTypeCursorMotionStyle.check_lower(value.style)
        _UniffiFfiConverterOptionalTypeCursorMotionTiming.check_lower(value.timing)
        _UniffiFfiConverterOptionalTypeCursorMotionEffectsOutput.check_lower(value.effects)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterFloat64.write(value.start_handle, buf)
        _UniffiFfiConverterFloat64.write(value.end_handle, buf)
        _UniffiFfiConverterFloat64.write(value.arc_size, buf)
        _UniffiFfiConverterFloat64.write(value.arc_flow, buf)
        _UniffiFfiConverterFloat64.write(value.spring, buf)
        _UniffiFfiConverterFloat64.write(value.glide_duration_ms, buf)
        _UniffiFfiConverterFloat64.write(value.dwell_after_click_ms, buf)
        _UniffiFfiConverterFloat64.write(value.idle_hide_ms, buf)
        _UniffiFfiConverterFloat64.write(value.turn_radius, buf)
        _UniffiFfiConverterOptionalTypeCursorMotionStyle.write(value.style, buf)
        _UniffiFfiConverterOptionalTypeCursorMotionTiming.write(value.timing, buf)
        _UniffiFfiConverterOptionalTypeCursorMotionEffectsOutput.write(value.effects, buf)

class _UniffiFfiConverterOptionalTypeCursorMotionEffects(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeCursorMotionEffects.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeCursorMotionEffects.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeCursorMotionEffects.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class CursorMotionSelection:
    """
    Cursor motion for a session, with the fields of `set_agent_cursor_motion` minus `session`.
    Omitted or null fields keep the saved default (`cursor.motion.*` in the driver config), then
    the built-in `signature_arc`.
"""
    def __init__(self, *, style:typing.Optional[CursorMotionStyle], timing:typing.Optional[CursorMotionTiming], effects:typing.Optional[CursorMotionEffects], start_handle:typing.Optional[float], end_handle:typing.Optional[float], arc_size:typing.Optional[float], arc_flow:typing.Optional[float], spring:typing.Optional[float], glide_duration_ms:typing.Optional[float], dwell_after_click_ms:typing.Optional[float], idle_hide_ms:typing.Optional[float], turn_radius:typing.Optional[float]):
        self.style = style
        self.timing = timing
        self.effects = effects
        self.start_handle = start_handle
        self.end_handle = end_handle
        self.arc_size = arc_size
        self.arc_flow = arc_flow
        self.spring = spring
        self.glide_duration_ms = glide_duration_ms
        self.dwell_after_click_ms = dwell_after_click_ms
        self.idle_hide_ms = idle_hide_ms
        self.turn_radius = turn_radius




    def __str__(self):
        return "CursorMotionSelection(style={}, timing={}, effects={}, start_handle={}, end_handle={}, arc_size={}, arc_flow={}, spring={}, glide_duration_ms={}, dwell_after_click_ms={}, idle_hide_ms={}, turn_radius={})".format(self.style, self.timing, self.effects, self.start_handle, self.end_handle, self.arc_size, self.arc_flow, self.spring, self.glide_duration_ms, self.dwell_after_click_ms, self.idle_hide_ms, self.turn_radius)
    def __eq__(self, other):
        if self.style != other.style:
            return False
        if self.timing != other.timing:
            return False
        if self.effects != other.effects:
            return False
        if self.start_handle != other.start_handle:
            return False
        if self.end_handle != other.end_handle:
            return False
        if self.arc_size != other.arc_size:
            return False
        if self.arc_flow != other.arc_flow:
            return False
        if self.spring != other.spring:
            return False
        if self.glide_duration_ms != other.glide_duration_ms:
            return False
        if self.dwell_after_click_ms != other.dwell_after_click_ms:
            return False
        if self.idle_hide_ms != other.idle_hide_ms:
            return False
        if self.turn_radius != other.turn_radius:
            return False
        return True

class _UniffiFfiConverterTypeCursorMotionSelection(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return CursorMotionSelection(
            style=_UniffiFfiConverterOptionalTypeCursorMotionStyle.read(buf),
            timing=_UniffiFfiConverterOptionalTypeCursorMotionTiming.read(buf),
            effects=_UniffiFfiConverterOptionalTypeCursorMotionEffects.read(buf),
            start_handle=_UniffiFfiConverterOptionalFloat64.read(buf),
            end_handle=_UniffiFfiConverterOptionalFloat64.read(buf),
            arc_size=_UniffiFfiConverterOptionalFloat64.read(buf),
            arc_flow=_UniffiFfiConverterOptionalFloat64.read(buf),
            spring=_UniffiFfiConverterOptionalFloat64.read(buf),
            glide_duration_ms=_UniffiFfiConverterOptionalFloat64.read(buf),
            dwell_after_click_ms=_UniffiFfiConverterOptionalFloat64.read(buf),
            idle_hide_ms=_UniffiFfiConverterOptionalFloat64.read(buf),
            turn_radius=_UniffiFfiConverterOptionalFloat64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalTypeCursorMotionStyle.check_lower(value.style)
        _UniffiFfiConverterOptionalTypeCursorMotionTiming.check_lower(value.timing)
        _UniffiFfiConverterOptionalTypeCursorMotionEffects.check_lower(value.effects)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.start_handle)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.end_handle)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.arc_size)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.arc_flow)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.spring)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.glide_duration_ms)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.dwell_after_click_ms)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.idle_hide_ms)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.turn_radius)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalTypeCursorMotionStyle.write(value.style, buf)
        _UniffiFfiConverterOptionalTypeCursorMotionTiming.write(value.timing, buf)
        _UniffiFfiConverterOptionalTypeCursorMotionEffects.write(value.effects, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.start_handle, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.end_handle, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.arc_size, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.arc_flow, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.spring, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.glide_duration_ms, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.dwell_after_click_ms, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.idle_hide_ms, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.turn_radius, buf)

@dataclass
class CursorPointOutput:
    def __init__(self, *, x:float, y:float):
        self.x = x
        self.y = y




    def __str__(self):
        return "CursorPointOutput(x={}, y={})".format(self.x, self.y)
    def __eq__(self, other):
        if self.x != other.x:
            return False
        if self.y != other.y:
            return False
        return True

class _UniffiFfiConverterTypeCursorPointOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return CursorPointOutput(
            x=_UniffiFfiConverterFloat64.read(buf),
            y=_UniffiFfiConverterFloat64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterFloat64.check_lower(value.x)
        _UniffiFfiConverterFloat64.check_lower(value.y)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterFloat64.write(value.x, buf)
        _UniffiFfiConverterFloat64.write(value.y, buf)






class CursorReducedMotion(enum.Enum):

    AUTO = 0

    ON = 1

    OFF = 2



class _UniffiFfiConverterTypeCursorReducedMotion(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return CursorReducedMotion.AUTO
        if variant == 2:
            return CursorReducedMotion.ON
        if variant == 3:
            return CursorReducedMotion.OFF
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == CursorReducedMotion.AUTO:
            return
        if value == CursorReducedMotion.ON:
            return
        if value == CursorReducedMotion.OFF:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == CursorReducedMotion.AUTO:
            buf.write_i32(1)
        if value == CursorReducedMotion.ON:
            buf.write_i32(2)
        if value == CursorReducedMotion.OFF:
            buf.write_i32(3)



@dataclass
class CursorThemeOutput:
    def __init__(self, *, id:str, version:str, profile:str, reduced_motion:CursorReducedMotion, fallback:typing.Optional[str]):
        self.id = id
        self.version = version
        self.profile = profile
        self.reduced_motion = reduced_motion
        self.fallback = fallback




    def __str__(self):
        return "CursorThemeOutput(id={}, version={}, profile={}, reduced_motion={}, fallback={})".format(self.id, self.version, self.profile, self.reduced_motion, self.fallback)
    def __eq__(self, other):
        if self.id != other.id:
            return False
        if self.version != other.version:
            return False
        if self.profile != other.profile:
            return False
        if self.reduced_motion != other.reduced_motion:
            return False
        if self.fallback != other.fallback:
            return False
        return True

class _UniffiFfiConverterTypeCursorThemeOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return CursorThemeOutput(
            id=_UniffiFfiConverterString.read(buf),
            version=_UniffiFfiConverterString.read(buf),
            profile=_UniffiFfiConverterString.read(buf),
            reduced_motion=_UniffiFfiConverterTypeCursorReducedMotion.read(buf),
            fallback=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.id)
        _UniffiFfiConverterString.check_lower(value.version)
        _UniffiFfiConverterString.check_lower(value.profile)
        _UniffiFfiConverterTypeCursorReducedMotion.check_lower(value.reduced_motion)
        _UniffiFfiConverterOptionalString.check_lower(value.fallback)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.id, buf)
        _UniffiFfiConverterString.write(value.version, buf)
        _UniffiFfiConverterString.write(value.profile, buf)
        _UniffiFfiConverterTypeCursorReducedMotion.write(value.reduced_motion, buf)
        _UniffiFfiConverterOptionalString.write(value.fallback, buf)

@dataclass
class CursorThemeSelection:
    def __init__(self, *, theme_id:str, reduced_motion:CursorReducedMotion):
        self.theme_id = theme_id
        self.reduced_motion = reduced_motion




    def __str__(self):
        return "CursorThemeSelection(theme_id={}, reduced_motion={})".format(self.theme_id, self.reduced_motion)
    def __eq__(self, other):
        if self.theme_id != other.theme_id:
            return False
        if self.reduced_motion != other.reduced_motion:
            return False
        return True

class _UniffiFfiConverterTypeCursorThemeSelection(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return CursorThemeSelection(
            theme_id=_UniffiFfiConverterString.read(buf),
            reduced_motion=_UniffiFfiConverterTypeCursorReducedMotion.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.theme_id)
        _UniffiFfiConverterTypeCursorReducedMotion.check_lower(value.reduced_motion)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.theme_id, buf)
        _UniffiFfiConverterTypeCursorReducedMotion.write(value.reduced_motion, buf)






class CursorAction(enum.Enum):

    IDLE = 0

    OBSERVE = 1

    CLICK = 2

    DRAG = 3

    SCROLL = 4

    TEXT = 5

    KEY = 6

    NAVIGATE = 7

    APP = 8

    TRANSFER = 9

    RECORD = 10

    SYSTEM = 11



class _UniffiFfiConverterTypeCursorAction(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return CursorAction.IDLE
        if variant == 2:
            return CursorAction.OBSERVE
        if variant == 3:
            return CursorAction.CLICK
        if variant == 4:
            return CursorAction.DRAG
        if variant == 5:
            return CursorAction.SCROLL
        if variant == 6:
            return CursorAction.TEXT
        if variant == 7:
            return CursorAction.KEY
        if variant == 8:
            return CursorAction.NAVIGATE
        if variant == 9:
            return CursorAction.APP
        if variant == 10:
            return CursorAction.TRANSFER
        if variant == 11:
            return CursorAction.RECORD
        if variant == 12:
            return CursorAction.SYSTEM
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == CursorAction.IDLE:
            return
        if value == CursorAction.OBSERVE:
            return
        if value == CursorAction.CLICK:
            return
        if value == CursorAction.DRAG:
            return
        if value == CursorAction.SCROLL:
            return
        if value == CursorAction.TEXT:
            return
        if value == CursorAction.KEY:
            return
        if value == CursorAction.NAVIGATE:
            return
        if value == CursorAction.APP:
            return
        if value == CursorAction.TRANSFER:
            return
        if value == CursorAction.RECORD:
            return
        if value == CursorAction.SYSTEM:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == CursorAction.IDLE:
            buf.write_i32(1)
        if value == CursorAction.OBSERVE:
            buf.write_i32(2)
        if value == CursorAction.CLICK:
            buf.write_i32(3)
        if value == CursorAction.DRAG:
            buf.write_i32(4)
        if value == CursorAction.SCROLL:
            buf.write_i32(5)
        if value == CursorAction.TEXT:
            buf.write_i32(6)
        if value == CursorAction.KEY:
            buf.write_i32(7)
        if value == CursorAction.NAVIGATE:
            buf.write_i32(8)
        if value == CursorAction.APP:
            buf.write_i32(9)
        if value == CursorAction.TRANSFER:
            buf.write_i32(10)
        if value == CursorAction.RECORD:
            buf.write_i32(11)
        if value == CursorAction.SYSTEM:
            buf.write_i32(12)



@dataclass
class CursorVisualOutput:
    def __init__(self, *, requested_action:CursorAction, resolved_action:CursorAction, modifiers:typing.List[str], phase:str, frame:int, preempted_count:int):
        self.requested_action = requested_action
        self.resolved_action = resolved_action
        self.modifiers = modifiers
        self.phase = phase
        self.frame = frame
        self.preempted_count = preempted_count




    def __str__(self):
        return "CursorVisualOutput(requested_action={}, resolved_action={}, modifiers={}, phase={}, frame={}, preempted_count={})".format(self.requested_action, self.resolved_action, self.modifiers, self.phase, self.frame, self.preempted_count)
    def __eq__(self, other):
        if self.requested_action != other.requested_action:
            return False
        if self.resolved_action != other.resolved_action:
            return False
        if self.modifiers != other.modifiers:
            return False
        if self.phase != other.phase:
            return False
        if self.frame != other.frame:
            return False
        if self.preempted_count != other.preempted_count:
            return False
        return True

class _UniffiFfiConverterTypeCursorVisualOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return CursorVisualOutput(
            requested_action=_UniffiFfiConverterTypeCursorAction.read(buf),
            resolved_action=_UniffiFfiConverterTypeCursorAction.read(buf),
            modifiers=_UniffiFfiConverterSequenceString.read(buf),
            phase=_UniffiFfiConverterString.read(buf),
            frame=_UniffiFfiConverterUInt64.read(buf),
            preempted_count=_UniffiFfiConverterUInt64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterTypeCursorAction.check_lower(value.requested_action)
        _UniffiFfiConverterTypeCursorAction.check_lower(value.resolved_action)
        _UniffiFfiConverterSequenceString.check_lower(value.modifiers)
        _UniffiFfiConverterString.check_lower(value.phase)
        _UniffiFfiConverterUInt64.check_lower(value.frame)
        _UniffiFfiConverterUInt64.check_lower(value.preempted_count)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterTypeCursorAction.write(value.requested_action, buf)
        _UniffiFfiConverterTypeCursorAction.write(value.resolved_action, buf)
        _UniffiFfiConverterSequenceString.write(value.modifiers, buf)
        _UniffiFfiConverterString.write(value.phase, buf)
        _UniffiFfiConverterUInt64.write(value.frame, buf)
        _UniffiFfiConverterUInt64.write(value.preempted_count, buf)

class _UniffiFfiConverterOptionalTypeActionTarget(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeActionTarget.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeActionTarget.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeActionTarget.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")






class DesktopScope(enum.Enum):

    DESKTOP = 0



class _UniffiFfiConverterTypeDesktopScope(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return DesktopScope.DESKTOP
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == DesktopScope.DESKTOP:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == DesktopScope.DESKTOP:
            buf.write_i32(1)



class _UniffiFfiConverterOptionalTypeDesktopScope(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeDesktopScope.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeDesktopScope.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeDesktopScope.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterOptionalUInt64(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterUInt64.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterUInt64.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterUInt64.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterOptionalSequenceString(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterSequenceString.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterSequenceString.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterSequenceString.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class DragInput:
    def __init__(self, *, from_x:float, from_y:float, to_x:float, to_y:float, target:typing.Optional[ActionTarget], scope:typing.Optional[DesktopScope], session:typing.Optional[str], duration_ms:typing.Optional[int], steps:typing.Optional[int], button:typing.Optional[ClickButton], modifier:typing.Optional[typing.List[str]]):
        self.from_x = from_x
        self.from_y = from_y
        self.to_x = to_x
        self.to_y = to_y
        self.target = target
        self.scope = scope
        self.session = session
        self.duration_ms = duration_ms
        self.steps = steps
        self.button = button
        self.modifier = modifier




    def __str__(self):
        return "DragInput(from_x={}, from_y={}, to_x={}, to_y={}, target={}, scope={}, session={}, duration_ms={}, steps={}, button={}, modifier={})".format(self.from_x, self.from_y, self.to_x, self.to_y, self.target, self.scope, self.session, self.duration_ms, self.steps, self.button, self.modifier)
    def __eq__(self, other):
        if self.from_x != other.from_x:
            return False
        if self.from_y != other.from_y:
            return False
        if self.to_x != other.to_x:
            return False
        if self.to_y != other.to_y:
            return False
        if self.target != other.target:
            return False
        if self.scope != other.scope:
            return False
        if self.session != other.session:
            return False
        if self.duration_ms != other.duration_ms:
            return False
        if self.steps != other.steps:
            return False
        if self.button != other.button:
            return False
        if self.modifier != other.modifier:
            return False
        return True

class _UniffiFfiConverterTypeDragInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return DragInput(
            from_x=_UniffiFfiConverterFloat64.read(buf),
            from_y=_UniffiFfiConverterFloat64.read(buf),
            to_x=_UniffiFfiConverterFloat64.read(buf),
            to_y=_UniffiFfiConverterFloat64.read(buf),
            target=_UniffiFfiConverterOptionalTypeActionTarget.read(buf),
            scope=_UniffiFfiConverterOptionalTypeDesktopScope.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
            duration_ms=_UniffiFfiConverterOptionalUInt64.read(buf),
            steps=_UniffiFfiConverterOptionalUInt64.read(buf),
            button=_UniffiFfiConverterOptionalTypeClickButton.read(buf),
            modifier=_UniffiFfiConverterOptionalSequenceString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterFloat64.check_lower(value.from_x)
        _UniffiFfiConverterFloat64.check_lower(value.from_y)
        _UniffiFfiConverterFloat64.check_lower(value.to_x)
        _UniffiFfiConverterFloat64.check_lower(value.to_y)
        _UniffiFfiConverterOptionalTypeActionTarget.check_lower(value.target)
        _UniffiFfiConverterOptionalTypeDesktopScope.check_lower(value.scope)
        _UniffiFfiConverterOptionalString.check_lower(value.session)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.duration_ms)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.steps)
        _UniffiFfiConverterOptionalTypeClickButton.check_lower(value.button)
        _UniffiFfiConverterOptionalSequenceString.check_lower(value.modifier)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterFloat64.write(value.from_x, buf)
        _UniffiFfiConverterFloat64.write(value.from_y, buf)
        _UniffiFfiConverterFloat64.write(value.to_x, buf)
        _UniffiFfiConverterFloat64.write(value.to_y, buf)
        _UniffiFfiConverterOptionalTypeActionTarget.write(value.target, buf)
        _UniffiFfiConverterOptionalTypeDesktopScope.write(value.scope, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.duration_ms, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.steps, buf)
        _UniffiFfiConverterOptionalTypeClickButton.write(value.button, buf)
        _UniffiFfiConverterOptionalSequenceString.write(value.modifier, buf)

@dataclass
class ElementFrame:
    def __init__(self, *, x:float, y:float, w:float, h:float):
        self.x = x
        self.y = y
        self.w = w
        self.h = h




    def __str__(self):
        return "ElementFrame(x={}, y={}, w={}, h={})".format(self.x, self.y, self.w, self.h)
    def __eq__(self, other):
        if self.x != other.x:
            return False
        if self.y != other.y:
            return False
        if self.w != other.w:
            return False
        if self.h != other.h:
            return False
        return True

class _UniffiFfiConverterTypeElementFrame(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ElementFrame(
            x=_UniffiFfiConverterFloat64.read(buf),
            y=_UniffiFfiConverterFloat64.read(buf),
            w=_UniffiFfiConverterFloat64.read(buf),
            h=_UniffiFfiConverterFloat64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterFloat64.check_lower(value.x)
        _UniffiFfiConverterFloat64.check_lower(value.y)
        _UniffiFfiConverterFloat64.check_lower(value.w)
        _UniffiFfiConverterFloat64.check_lower(value.h)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterFloat64.write(value.x, buf)
        _UniffiFfiConverterFloat64.write(value.y, buf)
        _UniffiFfiConverterFloat64.write(value.w, buf)
        _UniffiFfiConverterFloat64.write(value.h, buf)

@dataclass
class ElementSelector:
    def __init__(self, *, role:typing.Optional[str], label_contains:typing.Optional[str]):
        self.role = role
        self.label_contains = label_contains




    def __str__(self):
        return "ElementSelector(role={}, label_contains={})".format(self.role, self.label_contains)
    def __eq__(self, other):
        if self.role != other.role:
            return False
        if self.label_contains != other.label_contains:
            return False
        return True

class _UniffiFfiConverterTypeElementSelector(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ElementSelector(
            role=_UniffiFfiConverterOptionalString.read(buf),
            label_contains=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalString.check_lower(value.role)
        _UniffiFfiConverterOptionalString.check_lower(value.label_contains)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalString.write(value.role, buf)
        _UniffiFfiConverterOptionalString.write(value.label_contains, buf)

class _UniffiFfiConverterOptionalBoolean(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterBoolean.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterBoolean.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterBoolean.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class ElementPredicate:
    def __init__(self, *, selector:ElementSelector, exists:typing.Optional[bool], value_equals:typing.Optional[str], enabled:typing.Optional[bool], selected:typing.Optional[bool]):
        self.selector = selector
        self.exists = exists
        self.value_equals = value_equals
        self.enabled = enabled
        self.selected = selected




    def __str__(self):
        return "ElementPredicate(selector={}, exists={}, value_equals={}, enabled={}, selected={})".format(self.selector, self.exists, self.value_equals, self.enabled, self.selected)
    def __eq__(self, other):
        if self.selector != other.selector:
            return False
        if self.exists != other.exists:
            return False
        if self.value_equals != other.value_equals:
            return False
        if self.enabled != other.enabled:
            return False
        if self.selected != other.selected:
            return False
        return True

class _UniffiFfiConverterTypeElementPredicate(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ElementPredicate(
            selector=_UniffiFfiConverterTypeElementSelector.read(buf),
            exists=_UniffiFfiConverterOptionalBoolean.read(buf),
            value_equals=_UniffiFfiConverterOptionalString.read(buf),
            enabled=_UniffiFfiConverterOptionalBoolean.read(buf),
            selected=_UniffiFfiConverterOptionalBoolean.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterTypeElementSelector.check_lower(value.selector)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.exists)
        _UniffiFfiConverterOptionalString.check_lower(value.value_equals)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.enabled)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.selected)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterTypeElementSelector.write(value.selector, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.exists, buf)
        _UniffiFfiConverterOptionalString.write(value.value_equals, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.enabled, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.selected, buf)

@dataclass
class EndSessionInput:
    def __init__(self, *, session:typing.Optional[str]):
        self.session = session




    def __str__(self):
        return "EndSessionInput(session={})".format(self.session)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeEndSessionInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return EndSessionInput(
            session=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalString.write(value.session, buf)

@dataclass
class EndSessionOutput:
    """
    Successful structured result returned by `end_session`.
"""
    def __init__(self, *, session:str, active:bool):
        self.session = session
        self.active = active




    def __str__(self):
        return "EndSessionOutput(session={}, active={})".format(self.session, self.active)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.active != other.active:
            return False
        return True

class _UniffiFfiConverterTypeEndSessionOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return EndSessionOutput(
            session=_UniffiFfiConverterString.read(buf),
            active=_UniffiFfiConverterBoolean.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)
        _UniffiFfiConverterBoolean.check_lower(value.active)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)
        _UniffiFfiConverterBoolean.write(value.active, buf)






class EscalationReason(enum.Enum):

    AX_TREE_PIXEL_MISMATCH = 0

    BACKGROUND_DELIVERY_FAILED = 1

    FOREGROUND_INEFFECTIVE = 2

    NO_WINDOW_TARGET = 3

    OTHER = 4



class _UniffiFfiConverterTypeEscalationReason(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return EscalationReason.AX_TREE_PIXEL_MISMATCH
        if variant == 2:
            return EscalationReason.BACKGROUND_DELIVERY_FAILED
        if variant == 3:
            return EscalationReason.FOREGROUND_INEFFECTIVE
        if variant == 4:
            return EscalationReason.NO_WINDOW_TARGET
        if variant == 5:
            return EscalationReason.OTHER
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == EscalationReason.AX_TREE_PIXEL_MISMATCH:
            return
        if value == EscalationReason.BACKGROUND_DELIVERY_FAILED:
            return
        if value == EscalationReason.FOREGROUND_INEFFECTIVE:
            return
        if value == EscalationReason.NO_WINDOW_TARGET:
            return
        if value == EscalationReason.OTHER:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == EscalationReason.AX_TREE_PIXEL_MISMATCH:
            buf.write_i32(1)
        if value == EscalationReason.BACKGROUND_DELIVERY_FAILED:
            buf.write_i32(2)
        if value == EscalationReason.FOREGROUND_INEFFECTIVE:
            buf.write_i32(3)
        if value == EscalationReason.NO_WINDOW_TARGET:
            buf.write_i32(4)
        if value == EscalationReason.OTHER:
            buf.write_i32(5)



@dataclass
class EscalateSessionInput:
    def __init__(self, *, session:str, reason:EscalationReason, detail:typing.Optional[str]):
        self.session = session
        self.reason = reason
        self.detail = detail




    def __str__(self):
        return "EscalateSessionInput(session={}, reason={}, detail={})".format(self.session, self.reason, self.detail)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.reason != other.reason:
            return False
        if self.detail != other.detail:
            return False
        return True

class _UniffiFfiConverterTypeEscalateSessionInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return EscalateSessionInput(
            session=_UniffiFfiConverterString.read(buf),
            reason=_UniffiFfiConverterTypeEscalationReason.read(buf),
            detail=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)
        _UniffiFfiConverterTypeEscalationReason.check_lower(value.reason)
        _UniffiFfiConverterOptionalString.check_lower(value.detail)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)
        _UniffiFfiConverterTypeEscalationReason.write(value.reason, buf)
        _UniffiFfiConverterOptionalString.write(value.detail, buf)

@dataclass
class GetAgentCursorStateInput:
    def __init__(self, *, session:str):
        self.session = session




    def __str__(self):
        return "GetAgentCursorStateInput(session={})".format(self.session)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeGetAgentCursorStateInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return GetAgentCursorStateInput(
            session=_UniffiFfiConverterString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)

class _UniffiFfiConverterOptionalTypeCursorPointOutput(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeCursorPointOutput.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeCursorPointOutput.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeCursorPointOutput.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class GetAgentCursorStateOutput:
    def __init__(self, *, session:str, enabled:bool, position:typing.Optional[CursorPointOutput], theme:CursorThemeOutput, visual_state:CursorVisualOutput, motion:CursorMotionOutput):
        self.session = session
        self.enabled = enabled
        self.position = position
        self.theme = theme
        self.visual_state = visual_state
        self.motion = motion




    def __str__(self):
        return "GetAgentCursorStateOutput(session={}, enabled={}, position={}, theme={}, visual_state={}, motion={})".format(self.session, self.enabled, self.position, self.theme, self.visual_state, self.motion)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.enabled != other.enabled:
            return False
        if self.position != other.position:
            return False
        if self.theme != other.theme:
            return False
        if self.visual_state != other.visual_state:
            return False
        if self.motion != other.motion:
            return False
        return True

class _UniffiFfiConverterTypeGetAgentCursorStateOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return GetAgentCursorStateOutput(
            session=_UniffiFfiConverterString.read(buf),
            enabled=_UniffiFfiConverterBoolean.read(buf),
            position=_UniffiFfiConverterOptionalTypeCursorPointOutput.read(buf),
            theme=_UniffiFfiConverterTypeCursorThemeOutput.read(buf),
            visual_state=_UniffiFfiConverterTypeCursorVisualOutput.read(buf),
            motion=_UniffiFfiConverterTypeCursorMotionOutput.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)
        _UniffiFfiConverterBoolean.check_lower(value.enabled)
        _UniffiFfiConverterOptionalTypeCursorPointOutput.check_lower(value.position)
        _UniffiFfiConverterTypeCursorThemeOutput.check_lower(value.theme)
        _UniffiFfiConverterTypeCursorVisualOutput.check_lower(value.visual_state)
        _UniffiFfiConverterTypeCursorMotionOutput.check_lower(value.motion)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)
        _UniffiFfiConverterBoolean.write(value.enabled, buf)
        _UniffiFfiConverterOptionalTypeCursorPointOutput.write(value.position, buf)
        _UniffiFfiConverterTypeCursorThemeOutput.write(value.theme, buf)
        _UniffiFfiConverterTypeCursorVisualOutput.write(value.visual_state, buf)
        _UniffiFfiConverterTypeCursorMotionOutput.write(value.motion, buf)

@dataclass
class GetCursorPositionInput:
    def __init__(self, *, session:typing.Optional[str]):
        self.session = session




    def __str__(self):
        return "GetCursorPositionInput(session={})".format(self.session)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeGetCursorPositionInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return GetCursorPositionInput(
            session=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalString.write(value.session, buf)

@dataclass
class GetDesktopStateInput:
    def __init__(self, *, session:typing.Optional[str], screenshot_out_file:typing.Optional[str], max_image_dimension:typing.Optional[int] = _DEFAULT):
        self.session = session
        self.screenshot_out_file = screenshot_out_file
        if max_image_dimension is _DEFAULT:
            self.max_image_dimension = None
        else:
            self.max_image_dimension = max_image_dimension




    def __str__(self):
        return "GetDesktopStateInput(session={}, screenshot_out_file={}, max_image_dimension={})".format(self.session, self.screenshot_out_file, self.max_image_dimension)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.screenshot_out_file != other.screenshot_out_file:
            return False
        if self.max_image_dimension != other.max_image_dimension:
            return False
        return True

class _UniffiFfiConverterTypeGetDesktopStateInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return GetDesktopStateInput(
            session=_UniffiFfiConverterOptionalString.read(buf),
            screenshot_out_file=_UniffiFfiConverterOptionalString.read(buf),
            max_image_dimension=_UniffiFfiConverterOptionalUInt32.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalString.check_lower(value.session)
        _UniffiFfiConverterOptionalString.check_lower(value.screenshot_out_file)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.max_image_dimension)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalString.write(value.session, buf)
        _UniffiFfiConverterOptionalString.write(value.screenshot_out_file, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.max_image_dimension, buf)

@dataclass
class GetScreenSizeInput:
    def __init__(self, *, session:typing.Optional[str]):
        self.session = session




    def __str__(self):
        return "GetScreenSizeInput(session={})".format(self.session)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeGetScreenSizeInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return GetScreenSizeInput(
            session=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalString.write(value.session, buf)

@dataclass
class GetSessionInput:
    def __init__(self, *, session:typing.Optional[str]):
        self.session = session




    def __str__(self):
        return "GetSessionInput(session={})".format(self.session)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeGetSessionInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return GetSessionInput(
            session=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalString.write(value.session, buf)

@dataclass
class GetSessionStateInput:
    def __init__(self, *, session:typing.Optional[str]):
        self.session = session




    def __str__(self):
        return "GetSessionStateInput(session={})".format(self.session)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeGetSessionStateInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return GetSessionStateInput(
            session=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalString.write(value.session, buf)

@dataclass
class GetWindowStateInput:
    def __init__(self, *, pid:int, window_id:int, session:typing.Optional[str], query:typing.Optional[str], include_accessibility_tree:typing.Optional[bool], include_screenshot:typing.Optional[bool], screenshot_out_file:typing.Optional[str], max_elements:typing.Optional[int], max_depth:typing.Optional[int], max_dimension:typing.Optional[int], max_image_dimension:typing.Optional[int], timeout_ms:typing.Optional[int] = _DEFAULT, tree_format:typing.Optional[str] = _DEFAULT, since:typing.Optional[str] = _DEFAULT, verbose:typing.Optional[bool] = _DEFAULT, full_output:typing.Optional[bool] = _DEFAULT):
        self.pid = pid
        self.window_id = window_id
        self.session = session
        self.query = query
        self.include_accessibility_tree = include_accessibility_tree
        self.include_screenshot = include_screenshot
        self.screenshot_out_file = screenshot_out_file
        self.max_elements = max_elements
        self.max_depth = max_depth
        self.max_dimension = max_dimension
        self.max_image_dimension = max_image_dimension
        if timeout_ms is _DEFAULT:
            self.timeout_ms = None
        else:
            self.timeout_ms = timeout_ms
        if tree_format is _DEFAULT:
            self.tree_format = None
        else:
            self.tree_format = tree_format
        if since is _DEFAULT:
            self.since = None
        else:
            self.since = since
        if verbose is _DEFAULT:
            self.verbose = None
        else:
            self.verbose = verbose
        if full_output is _DEFAULT:
            self.full_output = None
        else:
            self.full_output = full_output




    def __str__(self):
        return "GetWindowStateInput(pid={}, window_id={}, session={}, query={}, include_accessibility_tree={}, include_screenshot={}, screenshot_out_file={}, max_elements={}, max_depth={}, max_dimension={}, max_image_dimension={}, timeout_ms={}, tree_format={}, since={}, verbose={}, full_output={})".format(self.pid, self.window_id, self.session, self.query, self.include_accessibility_tree, self.include_screenshot, self.screenshot_out_file, self.max_elements, self.max_depth, self.max_dimension, self.max_image_dimension, self.timeout_ms, self.tree_format, self.since, self.verbose, self.full_output)
    def __eq__(self, other):
        if self.pid != other.pid:
            return False
        if self.window_id != other.window_id:
            return False
        if self.session != other.session:
            return False
        if self.query != other.query:
            return False
        if self.include_accessibility_tree != other.include_accessibility_tree:
            return False
        if self.include_screenshot != other.include_screenshot:
            return False
        if self.screenshot_out_file != other.screenshot_out_file:
            return False
        if self.max_elements != other.max_elements:
            return False
        if self.max_depth != other.max_depth:
            return False
        if self.max_dimension != other.max_dimension:
            return False
        if self.max_image_dimension != other.max_image_dimension:
            return False
        if self.timeout_ms != other.timeout_ms:
            return False
        if self.tree_format != other.tree_format:
            return False
        if self.since != other.since:
            return False
        if self.verbose != other.verbose:
            return False
        if self.full_output != other.full_output:
            return False
        return True

class _UniffiFfiConverterTypeGetWindowStateInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return GetWindowStateInput(
            pid=_UniffiFfiConverterUInt32.read(buf),
            window_id=_UniffiFfiConverterUInt64.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
            query=_UniffiFfiConverterOptionalString.read(buf),
            include_accessibility_tree=_UniffiFfiConverterOptionalBoolean.read(buf),
            include_screenshot=_UniffiFfiConverterOptionalBoolean.read(buf),
            screenshot_out_file=_UniffiFfiConverterOptionalString.read(buf),
            max_elements=_UniffiFfiConverterOptionalUInt32.read(buf),
            max_depth=_UniffiFfiConverterOptionalUInt32.read(buf),
            max_dimension=_UniffiFfiConverterOptionalUInt32.read(buf),
            max_image_dimension=_UniffiFfiConverterOptionalUInt32.read(buf),
            timeout_ms=_UniffiFfiConverterOptionalUInt32.read(buf),
            tree_format=_UniffiFfiConverterOptionalString.read(buf),
            since=_UniffiFfiConverterOptionalString.read(buf),
            verbose=_UniffiFfiConverterOptionalBoolean.read(buf),
            full_output=_UniffiFfiConverterOptionalBoolean.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterUInt32.check_lower(value.pid)
        _UniffiFfiConverterUInt64.check_lower(value.window_id)
        _UniffiFfiConverterOptionalString.check_lower(value.session)
        _UniffiFfiConverterOptionalString.check_lower(value.query)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.include_accessibility_tree)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.include_screenshot)
        _UniffiFfiConverterOptionalString.check_lower(value.screenshot_out_file)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.max_elements)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.max_depth)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.max_dimension)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.max_image_dimension)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.timeout_ms)
        _UniffiFfiConverterOptionalString.check_lower(value.tree_format)
        _UniffiFfiConverterOptionalString.check_lower(value.since)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.verbose)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.full_output)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterUInt32.write(value.pid, buf)
        _UniffiFfiConverterUInt64.write(value.window_id, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)
        _UniffiFfiConverterOptionalString.write(value.query, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.include_accessibility_tree, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.include_screenshot, buf)
        _UniffiFfiConverterOptionalString.write(value.screenshot_out_file, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.max_elements, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.max_depth, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.max_dimension, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.max_image_dimension, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.timeout_ms, buf)
        _UniffiFfiConverterOptionalString.write(value.tree_format, buf)
        _UniffiFfiConverterOptionalString.write(value.since, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.verbose, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.full_output, buf)

@dataclass
class HotkeyInput:
    def __init__(self, *, keys:typing.List[str], target:typing.Optional[ActionTarget], scope:typing.Optional[DesktopScope], session:typing.Optional[str]):
        self.keys = keys
        self.target = target
        self.scope = scope
        self.session = session




    def __str__(self):
        return "HotkeyInput(keys={}, target={}, scope={}, session={})".format(self.keys, self.target, self.scope, self.session)
    def __eq__(self, other):
        if self.keys != other.keys:
            return False
        if self.target != other.target:
            return False
        if self.scope != other.scope:
            return False
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeHotkeyInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return HotkeyInput(
            keys=_UniffiFfiConverterSequenceString.read(buf),
            target=_UniffiFfiConverterOptionalTypeActionTarget.read(buf),
            scope=_UniffiFfiConverterOptionalTypeDesktopScope.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterSequenceString.check_lower(value.keys)
        _UniffiFfiConverterOptionalTypeActionTarget.check_lower(value.target)
        _UniffiFfiConverterOptionalTypeDesktopScope.check_lower(value.scope)
        _UniffiFfiConverterOptionalString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterSequenceString.write(value.keys, buf)
        _UniffiFfiConverterOptionalTypeActionTarget.write(value.target, buf)
        _UniffiFfiConverterOptionalTypeDesktopScope.write(value.scope, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)

@dataclass
class InvokeMenuInput:
    """
    Exact, immediate-child application menu path to resolve and invoke through
    the operating system's accessibility API. Path labels are matched after
    trimming surrounding whitespace and otherwise remain case-sensitive. On
    macOS, three periods in a label also match the ellipsis character that
    native menu titles use (`Save As...` finds `Save As…`).
"""
    def __init__(self, *, pid:int, window_id:int, path:typing.List[str], session:typing.Optional[str]):
        self.pid = pid
        self.window_id = window_id
        self.path = path
        self.session = session




    def __str__(self):
        return "InvokeMenuInput(pid={}, window_id={}, path={}, session={})".format(self.pid, self.window_id, self.path, self.session)
    def __eq__(self, other):
        if self.pid != other.pid:
            return False
        if self.window_id != other.window_id:
            return False
        if self.path != other.path:
            return False
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeInvokeMenuInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return InvokeMenuInput(
            pid=_UniffiFfiConverterUInt32.read(buf),
            window_id=_UniffiFfiConverterUInt64.read(buf),
            path=_UniffiFfiConverterSequenceString.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterUInt32.check_lower(value.pid)
        _UniffiFfiConverterUInt64.check_lower(value.window_id)
        _UniffiFfiConverterSequenceString.check_lower(value.path)
        _UniffiFfiConverterOptionalString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterUInt32.write(value.pid, buf)
        _UniffiFfiConverterUInt64.write(value.window_id, buf)
        _UniffiFfiConverterSequenceString.write(value.path, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)

@dataclass
class ListAppsInput:





    def __str__(self):
        return "ListAppsInput()".format()
    def __eq__(self, other):
        return True

class _UniffiFfiConverterTypeListAppsInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ListAppsInput(
        )

    @staticmethod
    def check_lower(value):
        pass

    @staticmethod
    def write(value, buf):
        pass

class _UniffiFfiConverterSequenceTypeAppInfo(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypeAppInfo.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypeAppInfo.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypeAppInfo.read(buf) for i in range(count)
        ]

@dataclass
class ListAppsOutput:
    def __init__(self, *, apps:typing.List[AppInfo]):
        self.apps = apps




    def __str__(self):
        return "ListAppsOutput(apps={})".format(self.apps)
    def __eq__(self, other):
        if self.apps != other.apps:
            return False
        return True

class _UniffiFfiConverterTypeListAppsOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ListAppsOutput(
            apps=_UniffiFfiConverterSequenceTypeAppInfo.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterSequenceTypeAppInfo.check_lower(value.apps)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterSequenceTypeAppInfo.write(value.apps, buf)

@dataclass
class ListSessionsInput:
    def __init__(self, *, limit:typing.Optional[int], cursor:typing.Optional[str]):
        self.limit = limit
        self.cursor = cursor




    def __str__(self):
        return "ListSessionsInput(limit={}, cursor={})".format(self.limit, self.cursor)
    def __eq__(self, other):
        if self.limit != other.limit:
            return False
        if self.cursor != other.cursor:
            return False
        return True

class _UniffiFfiConverterTypeListSessionsInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ListSessionsInput(
            limit=_UniffiFfiConverterOptionalUInt32.read(buf),
            cursor=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalUInt32.check_lower(value.limit)
        _UniffiFfiConverterOptionalString.check_lower(value.cursor)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalUInt32.write(value.limit, buf)
        _UniffiFfiConverterOptionalString.write(value.cursor, buf)






class SessionLifecycleState(enum.Enum):

    ACTIVE = 0

    ENDING = 1



class _UniffiFfiConverterTypeSessionLifecycleState(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return SessionLifecycleState.ACTIVE
        if variant == 2:
            return SessionLifecycleState.ENDING
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == SessionLifecycleState.ACTIVE:
            return
        if value == SessionLifecycleState.ENDING:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == SessionLifecycleState.ACTIVE:
            buf.write_i32(1)
        if value == SessionLifecycleState.ENDING:
            buf.write_i32(2)








class SessionClientKindOutput(enum.Enum):

    CLI = 0

    DIRECT = 1

    MCP = 2

    PYTHON_SDK = 3

    TYPESCRIPT_SDK = 4



class _UniffiFfiConverterTypeSessionClientKindOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return SessionClientKindOutput.CLI
        if variant == 2:
            return SessionClientKindOutput.DIRECT
        if variant == 3:
            return SessionClientKindOutput.MCP
        if variant == 4:
            return SessionClientKindOutput.PYTHON_SDK
        if variant == 5:
            return SessionClientKindOutput.TYPESCRIPT_SDK
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == SessionClientKindOutput.CLI:
            return
        if value == SessionClientKindOutput.DIRECT:
            return
        if value == SessionClientKindOutput.MCP:
            return
        if value == SessionClientKindOutput.PYTHON_SDK:
            return
        if value == SessionClientKindOutput.TYPESCRIPT_SDK:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == SessionClientKindOutput.CLI:
            buf.write_i32(1)
        if value == SessionClientKindOutput.DIRECT:
            buf.write_i32(2)
        if value == SessionClientKindOutput.MCP:
            buf.write_i32(3)
        if value == SessionClientKindOutput.PYTHON_SDK:
            buf.write_i32(4)
        if value == SessionClientKindOutput.TYPESCRIPT_SDK:
            buf.write_i32(5)








class SessionTransportOutput(enum.Enum):

    CLI = 0

    DAEMON = 1

    MCP_STDIO = 2

    MCP_HTTP = 3



class _UniffiFfiConverterTypeSessionTransportOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return SessionTransportOutput.CLI
        if variant == 2:
            return SessionTransportOutput.DAEMON
        if variant == 3:
            return SessionTransportOutput.MCP_STDIO
        if variant == 4:
            return SessionTransportOutput.MCP_HTTP
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == SessionTransportOutput.CLI:
            return
        if value == SessionTransportOutput.DAEMON:
            return
        if value == SessionTransportOutput.MCP_STDIO:
            return
        if value == SessionTransportOutput.MCP_HTTP:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == SessionTransportOutput.CLI:
            buf.write_i32(1)
        if value == SessionTransportOutput.DAEMON:
            buf.write_i32(2)
        if value == SessionTransportOutput.MCP_STDIO:
            buf.write_i32(3)
        if value == SessionTransportOutput.MCP_HTTP:
            buf.write_i32(4)



@dataclass
class SessionOutput:
    """
    Content-free lifecycle state safe for an ordinary agent transport.
"""
    def __init__(self, *, session:typing.Optional[str], implicit:bool, state:SessionLifecycleState, client_kind:SessionClientKindOutput, transport:SessionTransportOutput, cursor_visible:bool, recording_active:bool, idle_seconds:int, expires_in_seconds:int):
        self.session = session
        self.implicit = implicit
        self.state = state
        self.client_kind = client_kind
        self.transport = transport
        self.cursor_visible = cursor_visible
        self.recording_active = recording_active
        self.idle_seconds = idle_seconds
        self.expires_in_seconds = expires_in_seconds




    def __str__(self):
        return "SessionOutput(session={}, implicit={}, state={}, client_kind={}, transport={}, cursor_visible={}, recording_active={}, idle_seconds={}, expires_in_seconds={})".format(self.session, self.implicit, self.state, self.client_kind, self.transport, self.cursor_visible, self.recording_active, self.idle_seconds, self.expires_in_seconds)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.implicit != other.implicit:
            return False
        if self.state != other.state:
            return False
        if self.client_kind != other.client_kind:
            return False
        if self.transport != other.transport:
            return False
        if self.cursor_visible != other.cursor_visible:
            return False
        if self.recording_active != other.recording_active:
            return False
        if self.idle_seconds != other.idle_seconds:
            return False
        if self.expires_in_seconds != other.expires_in_seconds:
            return False
        return True

class _UniffiFfiConverterTypeSessionOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return SessionOutput(
            session=_UniffiFfiConverterOptionalString.read(buf),
            implicit=_UniffiFfiConverterBoolean.read(buf),
            state=_UniffiFfiConverterTypeSessionLifecycleState.read(buf),
            client_kind=_UniffiFfiConverterTypeSessionClientKindOutput.read(buf),
            transport=_UniffiFfiConverterTypeSessionTransportOutput.read(buf),
            cursor_visible=_UniffiFfiConverterBoolean.read(buf),
            recording_active=_UniffiFfiConverterBoolean.read(buf),
            idle_seconds=_UniffiFfiConverterUInt64.read(buf),
            expires_in_seconds=_UniffiFfiConverterUInt64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalString.check_lower(value.session)
        _UniffiFfiConverterBoolean.check_lower(value.implicit)
        _UniffiFfiConverterTypeSessionLifecycleState.check_lower(value.state)
        _UniffiFfiConverterTypeSessionClientKindOutput.check_lower(value.client_kind)
        _UniffiFfiConverterTypeSessionTransportOutput.check_lower(value.transport)
        _UniffiFfiConverterBoolean.check_lower(value.cursor_visible)
        _UniffiFfiConverterBoolean.check_lower(value.recording_active)
        _UniffiFfiConverterUInt64.check_lower(value.idle_seconds)
        _UniffiFfiConverterUInt64.check_lower(value.expires_in_seconds)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalString.write(value.session, buf)
        _UniffiFfiConverterBoolean.write(value.implicit, buf)
        _UniffiFfiConverterTypeSessionLifecycleState.write(value.state, buf)
        _UniffiFfiConverterTypeSessionClientKindOutput.write(value.client_kind, buf)
        _UniffiFfiConverterTypeSessionTransportOutput.write(value.transport, buf)
        _UniffiFfiConverterBoolean.write(value.cursor_visible, buf)
        _UniffiFfiConverterBoolean.write(value.recording_active, buf)
        _UniffiFfiConverterUInt64.write(value.idle_seconds, buf)
        _UniffiFfiConverterUInt64.write(value.expires_in_seconds, buf)

class _UniffiFfiConverterSequenceTypeSessionOutput(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypeSessionOutput.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypeSessionOutput.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypeSessionOutput.read(buf) for i in range(count)
        ]

@dataclass
class ListSessionsOutput:
    def __init__(self, *, sessions:typing.List[SessionOutput], next_cursor:typing.Optional[str]):
        self.sessions = sessions
        self.next_cursor = next_cursor




    def __str__(self):
        return "ListSessionsOutput(sessions={}, next_cursor={})".format(self.sessions, self.next_cursor)
    def __eq__(self, other):
        if self.sessions != other.sessions:
            return False
        if self.next_cursor != other.next_cursor:
            return False
        return True

class _UniffiFfiConverterTypeListSessionsOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ListSessionsOutput(
            sessions=_UniffiFfiConverterSequenceTypeSessionOutput.read(buf),
            next_cursor=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterSequenceTypeSessionOutput.check_lower(value.sessions)
        _UniffiFfiConverterOptionalString.check_lower(value.next_cursor)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterSequenceTypeSessionOutput.write(value.sessions, buf)
        _UniffiFfiConverterOptionalString.write(value.next_cursor, buf)

@dataclass
class ListWindowsInput:
    def __init__(self, *, pid:typing.Optional[int], on_screen_only:typing.Optional[bool]):
        self.pid = pid
        self.on_screen_only = on_screen_only




    def __str__(self):
        return "ListWindowsInput(pid={}, on_screen_only={})".format(self.pid, self.on_screen_only)
    def __eq__(self, other):
        if self.pid != other.pid:
            return False
        if self.on_screen_only != other.on_screen_only:
            return False
        return True

class _UniffiFfiConverterTypeListWindowsInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ListWindowsInput(
            pid=_UniffiFfiConverterOptionalUInt32.read(buf),
            on_screen_only=_UniffiFfiConverterOptionalBoolean.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalUInt32.check_lower(value.pid)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.on_screen_only)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalUInt32.write(value.pid, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.on_screen_only, buf)

@dataclass
class WindowBounds:
    def __init__(self, *, x:float, y:float, width:float, height:float):
        self.x = x
        self.y = y
        self.width = width
        self.height = height




    def __str__(self):
        return "WindowBounds(x={}, y={}, width={}, height={})".format(self.x, self.y, self.width, self.height)
    def __eq__(self, other):
        if self.x != other.x:
            return False
        if self.y != other.y:
            return False
        if self.width != other.width:
            return False
        if self.height != other.height:
            return False
        return True

class _UniffiFfiConverterTypeWindowBounds(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return WindowBounds(
            x=_UniffiFfiConverterFloat64.read(buf),
            y=_UniffiFfiConverterFloat64.read(buf),
            width=_UniffiFfiConverterFloat64.read(buf),
            height=_UniffiFfiConverterFloat64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterFloat64.check_lower(value.x)
        _UniffiFfiConverterFloat64.check_lower(value.y)
        _UniffiFfiConverterFloat64.check_lower(value.width)
        _UniffiFfiConverterFloat64.check_lower(value.height)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterFloat64.write(value.x, buf)
        _UniffiFfiConverterFloat64.write(value.y, buf)
        _UniffiFfiConverterFloat64.write(value.width, buf)
        _UniffiFfiConverterFloat64.write(value.height, buf)

class _UniffiFfiConverterInt64(_UniffiConverterPrimitiveInt):
    CLASS_NAME = "i64"
    VALUE_MIN = -2**63
    VALUE_MAX = 2**63

    @staticmethod
    def read(buf):
        return buf.read_i64()

    @staticmethod
    def write(value, buf):
        buf.write_i64(value)

class _UniffiFfiConverterOptionalInt64(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterInt64.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterInt64.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterInt64.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterInt32(_UniffiConverterPrimitiveInt):
    CLASS_NAME = "i32"
    VALUE_MIN = -2**31
    VALUE_MAX = 2**31

    @staticmethod
    def read(buf):
        return buf.read_i32()

    @staticmethod
    def write(value, buf):
        buf.write_i32(value)

class _UniffiFfiConverterOptionalInt32(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterInt32.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterInt32.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterInt32.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterSequenceUInt64(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterUInt64.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterUInt64.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterUInt64.read(buf) for i in range(count)
        ]

class _UniffiFfiConverterOptionalSequenceUInt64(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterSequenceUInt64.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterSequenceUInt64.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterSequenceUInt64.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class WindowInfo:
    def __init__(self, *, window_id:int, pid:typing.Optional[int], app_name:str, title:str, bounds:WindowBounds, is_on_screen:bool, z_index:typing.Optional[int], layer:typing.Optional[int], minimized:typing.Optional[bool], current_space_id:typing.Optional[int], on_current_space:typing.Optional[bool], space_ids:typing.Optional[typing.List[int]]):
        self.window_id = window_id
        self.pid = pid
        self.app_name = app_name
        self.title = title
        self.bounds = bounds
        self.is_on_screen = is_on_screen
        self.z_index = z_index
        self.layer = layer
        self.minimized = minimized
        self.current_space_id = current_space_id
        self.on_current_space = on_current_space
        self.space_ids = space_ids




    def __str__(self):
        return "WindowInfo(window_id={}, pid={}, app_name={}, title={}, bounds={}, is_on_screen={}, z_index={}, layer={}, minimized={}, current_space_id={}, on_current_space={}, space_ids={})".format(self.window_id, self.pid, self.app_name, self.title, self.bounds, self.is_on_screen, self.z_index, self.layer, self.minimized, self.current_space_id, self.on_current_space, self.space_ids)
    def __eq__(self, other):
        if self.window_id != other.window_id:
            return False
        if self.pid != other.pid:
            return False
        if self.app_name != other.app_name:
            return False
        if self.title != other.title:
            return False
        if self.bounds != other.bounds:
            return False
        if self.is_on_screen != other.is_on_screen:
            return False
        if self.z_index != other.z_index:
            return False
        if self.layer != other.layer:
            return False
        if self.minimized != other.minimized:
            return False
        if self.current_space_id != other.current_space_id:
            return False
        if self.on_current_space != other.on_current_space:
            return False
        if self.space_ids != other.space_ids:
            return False
        return True

class _UniffiFfiConverterTypeWindowInfo(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return WindowInfo(
            window_id=_UniffiFfiConverterUInt64.read(buf),
            pid=_UniffiFfiConverterOptionalUInt32.read(buf),
            app_name=_UniffiFfiConverterString.read(buf),
            title=_UniffiFfiConverterString.read(buf),
            bounds=_UniffiFfiConverterTypeWindowBounds.read(buf),
            is_on_screen=_UniffiFfiConverterBoolean.read(buf),
            z_index=_UniffiFfiConverterOptionalInt64.read(buf),
            layer=_UniffiFfiConverterOptionalInt32.read(buf),
            minimized=_UniffiFfiConverterOptionalBoolean.read(buf),
            current_space_id=_UniffiFfiConverterOptionalUInt64.read(buf),
            on_current_space=_UniffiFfiConverterOptionalBoolean.read(buf),
            space_ids=_UniffiFfiConverterOptionalSequenceUInt64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterUInt64.check_lower(value.window_id)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.pid)
        _UniffiFfiConverterString.check_lower(value.app_name)
        _UniffiFfiConverterString.check_lower(value.title)
        _UniffiFfiConverterTypeWindowBounds.check_lower(value.bounds)
        _UniffiFfiConverterBoolean.check_lower(value.is_on_screen)
        _UniffiFfiConverterOptionalInt64.check_lower(value.z_index)
        _UniffiFfiConverterOptionalInt32.check_lower(value.layer)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.minimized)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.current_space_id)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.on_current_space)
        _UniffiFfiConverterOptionalSequenceUInt64.check_lower(value.space_ids)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterUInt64.write(value.window_id, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.pid, buf)
        _UniffiFfiConverterString.write(value.app_name, buf)
        _UniffiFfiConverterString.write(value.title, buf)
        _UniffiFfiConverterTypeWindowBounds.write(value.bounds, buf)
        _UniffiFfiConverterBoolean.write(value.is_on_screen, buf)
        _UniffiFfiConverterOptionalInt64.write(value.z_index, buf)
        _UniffiFfiConverterOptionalInt32.write(value.layer, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.minimized, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.current_space_id, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.on_current_space, buf)
        _UniffiFfiConverterOptionalSequenceUInt64.write(value.space_ids, buf)

class _UniffiFfiConverterSequenceTypeWindowInfo(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypeWindowInfo.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypeWindowInfo.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypeWindowInfo.read(buf) for i in range(count)
        ]

@dataclass
class ListWindowsOutput:
    def __init__(self, *, windows:typing.List[WindowInfo], current_space_id:typing.Optional[int]):
        self.windows = windows
        self.current_space_id = current_space_id




    def __str__(self):
        return "ListWindowsOutput(windows={}, current_space_id={})".format(self.windows, self.current_space_id)
    def __eq__(self, other):
        if self.windows != other.windows:
            return False
        if self.current_space_id != other.current_space_id:
            return False
        return True

class _UniffiFfiConverterTypeListWindowsOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ListWindowsOutput(
            windows=_UniffiFfiConverterSequenceTypeWindowInfo.read(buf),
            current_space_id=_UniffiFfiConverterOptionalUInt64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterSequenceTypeWindowInfo.check_lower(value.windows)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.current_space_id)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterSequenceTypeWindowInfo.write(value.windows, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.current_space_id, buf)

@dataclass
class MoveCursorInput:
    def __init__(self, *, x:float, y:float, target:typing.Optional[ActionTarget], scope:typing.Optional[DesktopScope], session:typing.Optional[str]):
        self.x = x
        self.y = y
        self.target = target
        self.scope = scope
        self.session = session




    def __str__(self):
        return "MoveCursorInput(x={}, y={}, target={}, scope={}, session={})".format(self.x, self.y, self.target, self.scope, self.session)
    def __eq__(self, other):
        if self.x != other.x:
            return False
        if self.y != other.y:
            return False
        if self.target != other.target:
            return False
        if self.scope != other.scope:
            return False
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeMoveCursorInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return MoveCursorInput(
            x=_UniffiFfiConverterFloat64.read(buf),
            y=_UniffiFfiConverterFloat64.read(buf),
            target=_UniffiFfiConverterOptionalTypeActionTarget.read(buf),
            scope=_UniffiFfiConverterOptionalTypeDesktopScope.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterFloat64.check_lower(value.x)
        _UniffiFfiConverterFloat64.check_lower(value.y)
        _UniffiFfiConverterOptionalTypeActionTarget.check_lower(value.target)
        _UniffiFfiConverterOptionalTypeDesktopScope.check_lower(value.scope)
        _UniffiFfiConverterOptionalString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterFloat64.write(value.x, buf)
        _UniffiFfiConverterFloat64.write(value.y, buf)
        _UniffiFfiConverterOptionalTypeActionTarget.write(value.target, buf)
        _UniffiFfiConverterOptionalTypeDesktopScope.write(value.scope, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)






class VisualRegionKind(enum.Enum):

    TEXT = 0

    ICON = 1



class _UniffiFfiConverterTypeVisualRegionKind(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return VisualRegionKind.TEXT
        if variant == 2:
            return VisualRegionKind.ICON
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == VisualRegionKind.TEXT:
            return
        if value == VisualRegionKind.ICON:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == VisualRegionKind.TEXT:
            buf.write_i32(1)
        if value == VisualRegionKind.ICON:
            buf.write_i32(2)



class _UniffiFfiConverterSequenceTypeVisualRegionKind(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypeVisualRegionKind.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypeVisualRegionKind.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypeVisualRegionKind.read(buf) for i in range(count)
        ]

class _UniffiFfiConverterOptionalSequenceTypeVisualRegionKind(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterSequenceTypeVisualRegionKind.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterSequenceTypeVisualRegionKind.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterSequenceTypeVisualRegionKind.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class ParseVisualRegionsOptions:
    """
    Optional, model-neutral controls for one bounded parse.
"""
    def __init__(self, *, kinds:typing.Optional[typing.List[VisualRegionKind]], min_confidence:typing.Optional[float], max_regions:typing.Optional[int]):
        self.kinds = kinds
        self.min_confidence = min_confidence
        self.max_regions = max_regions




    def __str__(self):
        return "ParseVisualRegionsOptions(kinds={}, min_confidence={}, max_regions={})".format(self.kinds, self.min_confidence, self.max_regions)
    def __eq__(self, other):
        if self.kinds != other.kinds:
            return False
        if self.min_confidence != other.min_confidence:
            return False
        if self.max_regions != other.max_regions:
            return False
        return True

class _UniffiFfiConverterTypeParseVisualRegionsOptions(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ParseVisualRegionsOptions(
            kinds=_UniffiFfiConverterOptionalSequenceTypeVisualRegionKind.read(buf),
            min_confidence=_UniffiFfiConverterOptionalFloat64.read(buf),
            max_regions=_UniffiFfiConverterOptionalUInt32.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalSequenceTypeVisualRegionKind.check_lower(value.kinds)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.min_confidence)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.max_regions)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalSequenceTypeVisualRegionKind.write(value.kinds, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.min_confidence, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.max_regions, buf)

@dataclass
class ParseVisualRegionsInput:
    """
    Parse one immutable screenshot capture. Pass the `capture_id` returned by
    `get_window_state` or `get_desktop_state`; the Driver capture registry
    resolves it to the exact pixels and action-coordinate transform.
"""
    def __init__(self, *, capture_id:str, options:ParseVisualRegionsOptions):
        self.capture_id = capture_id
        self.options = options




    def __str__(self):
        return "ParseVisualRegionsInput(capture_id={}, options={})".format(self.capture_id, self.options)
    def __eq__(self, other):
        if self.capture_id != other.capture_id:
            return False
        if self.options != other.options:
            return False
        return True

class _UniffiFfiConverterTypeParseVisualRegionsInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ParseVisualRegionsInput(
            capture_id=_UniffiFfiConverterString.read(buf),
            options=_UniffiFfiConverterTypeParseVisualRegionsOptions.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.capture_id)
        _UniffiFfiConverterTypeParseVisualRegionsOptions.check_lower(value.options)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.capture_id, buf)
        _UniffiFfiConverterTypeParseVisualRegionsOptions.write(value.options, buf)






class VisualCaptureSource:
    """
    Exact screen content that produced the immutable capture.
"""
    def __init__(self):
        raise RuntimeError("VisualCaptureSource cannot be instantiated directly")

    # Each enum variant is a nested class of the enum itself.
    @dataclass
    class WINDOW:

        def __init__(self, pid:int, window_id:int):
            self.pid = pid


            self.window_id = window_id


            pass





        def __str__(self):
            return "VisualCaptureSource.WINDOW(pid={}, window_id={})".format(self.pid, self.window_id)
        def __eq__(self, other):
            if not isinstance(other, VisualCaptureSource):
                return NotImplemented
            if not other.is_WINDOW():
                return False
            if self.pid != other.pid:
                return False
            if self.window_id != other.window_id:
                return False
            return True

    @dataclass
    class PRIMARY_DESKTOP:

        def __init__(self, display_id:str):
            self.display_id = display_id


            pass





        def __str__(self):
            return "VisualCaptureSource.PRIMARY_DESKTOP(display_id={})".format(self.display_id)
        def __eq__(self, other):
            if not isinstance(other, VisualCaptureSource):
                return NotImplemented
            if not other.is_PRIMARY_DESKTOP():
                return False
            if self.display_id != other.display_id:
                return False
            return True



    # For each variant, we have `is_NAME` and `is_name` methods for easily checking
    # whether an instance is that variant.
    def is_WINDOW(self) -> bool:
        return isinstance(self, VisualCaptureSource.WINDOW)
    def is_window(self) -> bool:
        return isinstance(self, VisualCaptureSource.WINDOW)
    def is_PRIMARY_DESKTOP(self) -> bool:
        return isinstance(self, VisualCaptureSource.PRIMARY_DESKTOP)
    def is_primary_desktop(self) -> bool:
        return isinstance(self, VisualCaptureSource.PRIMARY_DESKTOP)


# Now, a little trick - we make each nested variant class be a subclass of the main
# enum class, so that method calls and instance checks etc will work intuitively.
# We might be able to do this a little more neatly with a metaclass, but this'll do.
VisualCaptureSource.WINDOW = type("VisualCaptureSource.WINDOW", (VisualCaptureSource.WINDOW, VisualCaptureSource,), {})  # type: ignore
VisualCaptureSource.PRIMARY_DESKTOP = type("VisualCaptureSource.PRIMARY_DESKTOP", (VisualCaptureSource.PRIMARY_DESKTOP, VisualCaptureSource,), {})  # type: ignore




class _UniffiFfiConverterTypeVisualCaptureSource(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return VisualCaptureSource.WINDOW(
                _UniffiFfiConverterUInt32.read(buf),
                _UniffiFfiConverterUInt64.read(buf),
            )
        if variant == 2:
            return VisualCaptureSource.PRIMARY_DESKTOP(
                _UniffiFfiConverterString.read(buf),
            )
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value.is_WINDOW():
            _UniffiFfiConverterUInt32.check_lower(value.pid)
            _UniffiFfiConverterUInt64.check_lower(value.window_id)
            return
        if value.is_PRIMARY_DESKTOP():
            _UniffiFfiConverterString.check_lower(value.display_id)
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value.is_WINDOW():
            buf.write_i32(1)
            _UniffiFfiConverterUInt32.write(value.pid, buf)
            _UniffiFfiConverterUInt64.write(value.window_id, buf)
        if value.is_PRIMARY_DESKTOP():
            buf.write_i32(2)
            _UniffiFfiConverterString.write(value.display_id, buf)



@dataclass
class VisualScreenshotReference:
    """
    Screenshot identity and geometry retained by the Driver capture registry.
"""
    def __init__(self, *, reference:str, width:int, height:int, mime_type:str, sha256:typing.Optional[str]):
        self.reference = reference
        self.width = width
        self.height = height
        self.mime_type = mime_type
        self.sha256 = sha256




    def __str__(self):
        return "VisualScreenshotReference(reference={}, width={}, height={}, mime_type={}, sha256={})".format(self.reference, self.width, self.height, self.mime_type, self.sha256)
    def __eq__(self, other):
        if self.reference != other.reference:
            return False
        if self.width != other.width:
            return False
        if self.height != other.height:
            return False
        if self.mime_type != other.mime_type:
            return False
        if self.sha256 != other.sha256:
            return False
        return True

class _UniffiFfiConverterTypeVisualScreenshotReference(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return VisualScreenshotReference(
            reference=_UniffiFfiConverterString.read(buf),
            width=_UniffiFfiConverterUInt32.read(buf),
            height=_UniffiFfiConverterUInt32.read(buf),
            mime_type=_UniffiFfiConverterString.read(buf),
            sha256=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.reference)
        _UniffiFfiConverterUInt32.check_lower(value.width)
        _UniffiFfiConverterUInt32.check_lower(value.height)
        _UniffiFfiConverterString.check_lower(value.mime_type)
        _UniffiFfiConverterOptionalString.check_lower(value.sha256)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.reference, buf)
        _UniffiFfiConverterUInt32.write(value.width, buf)
        _UniffiFfiConverterUInt32.write(value.height, buf)
        _UniffiFfiConverterString.write(value.mime_type, buf)
        _UniffiFfiConverterOptionalString.write(value.sha256, buf)






class VisualActionCoordinateSpace:
    """
    Normative mapping from source screenshot pixels to Driver action coordinates.

    Screenshot coordinates always originate at the encoded PNG's top-left; X
    increases right and Y increases down. The affine form maps a source point
    `(px, py)` exactly as:

    `action_x = m11 * px + m12 * py + tx`

    `action_y = m21 * px + m22 * py + ty`
"""
    def __init__(self):
        raise RuntimeError("VisualActionCoordinateSpace cannot be instantiated directly")

    # Each enum variant is a nested class of the enum itself.
    @dataclass
    class SCREENSHOT_PIXELS:
        """
        Action coordinates are the same physical pixel coordinates as the PNG.
"""

        def __init__(self, ):
            pass





        def __str__(self):
            return "VisualActionCoordinateSpace.SCREENSHOT_PIXELS()".format()
        def __eq__(self, other):
            if not isinstance(other, VisualActionCoordinateSpace):
                return NotImplemented
            if not other.is_SCREENSHOT_PIXELS():
                return False
            return True

    @dataclass
    class AFFINE:
        """
        Lossless six-coefficient affine transform retained by the capture registry.
"""

        def __init__(self, m11:float, m12:float, m21:float, m22:float, tx:float, ty:float):
            self.m11 = m11


            self.m12 = m12


            self.m21 = m21


            self.m22 = m22


            self.tx = tx


            self.ty = ty


            pass





        def __str__(self):
            return "VisualActionCoordinateSpace.AFFINE(m11={}, m12={}, m21={}, m22={}, tx={}, ty={})".format(self.m11, self.m12, self.m21, self.m22, self.tx, self.ty)
        def __eq__(self, other):
            if not isinstance(other, VisualActionCoordinateSpace):
                return NotImplemented
            if not other.is_AFFINE():
                return False
            if self.m11 != other.m11:
                return False
            if self.m12 != other.m12:
                return False
            if self.m21 != other.m21:
                return False
            if self.m22 != other.m22:
                return False
            if self.tx != other.tx:
                return False
            if self.ty != other.ty:
                return False
            return True



    # For each variant, we have `is_NAME` and `is_name` methods for easily checking
    # whether an instance is that variant.
    def is_SCREENSHOT_PIXELS(self) -> bool:
        return isinstance(self, VisualActionCoordinateSpace.SCREENSHOT_PIXELS)
    def is_screenshot_pixels(self) -> bool:
        return isinstance(self, VisualActionCoordinateSpace.SCREENSHOT_PIXELS)
    def is_AFFINE(self) -> bool:
        return isinstance(self, VisualActionCoordinateSpace.AFFINE)
    def is_affine(self) -> bool:
        return isinstance(self, VisualActionCoordinateSpace.AFFINE)


# Now, a little trick - we make each nested variant class be a subclass of the main
# enum class, so that method calls and instance checks etc will work intuitively.
# We might be able to do this a little more neatly with a metaclass, but this'll do.
VisualActionCoordinateSpace.SCREENSHOT_PIXELS = type("VisualActionCoordinateSpace.SCREENSHOT_PIXELS", (VisualActionCoordinateSpace.SCREENSHOT_PIXELS, VisualActionCoordinateSpace,), {})  # type: ignore
VisualActionCoordinateSpace.AFFINE = type("VisualActionCoordinateSpace.AFFINE", (VisualActionCoordinateSpace.AFFINE, VisualActionCoordinateSpace,), {})  # type: ignore




class _UniffiFfiConverterTypeVisualActionCoordinateSpace(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return VisualActionCoordinateSpace.SCREENSHOT_PIXELS(
            )
        if variant == 2:
            return VisualActionCoordinateSpace.AFFINE(
                _UniffiFfiConverterFloat64.read(buf),
                _UniffiFfiConverterFloat64.read(buf),
                _UniffiFfiConverterFloat64.read(buf),
                _UniffiFfiConverterFloat64.read(buf),
                _UniffiFfiConverterFloat64.read(buf),
                _UniffiFfiConverterFloat64.read(buf),
            )
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value.is_SCREENSHOT_PIXELS():
            return
        if value.is_AFFINE():
            _UniffiFfiConverterFloat64.check_lower(value.m11)
            _UniffiFfiConverterFloat64.check_lower(value.m12)
            _UniffiFfiConverterFloat64.check_lower(value.m21)
            _UniffiFfiConverterFloat64.check_lower(value.m22)
            _UniffiFfiConverterFloat64.check_lower(value.tx)
            _UniffiFfiConverterFloat64.check_lower(value.ty)
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value.is_SCREENSHOT_PIXELS():
            buf.write_i32(1)
        if value.is_AFFINE():
            buf.write_i32(2)
            _UniffiFfiConverterFloat64.write(value.m11, buf)
            _UniffiFfiConverterFloat64.write(value.m12, buf)
            _UniffiFfiConverterFloat64.write(value.m21, buf)
            _UniffiFfiConverterFloat64.write(value.m22, buf)
            _UniffiFfiConverterFloat64.write(value.tx, buf)
            _UniffiFfiConverterFloat64.write(value.ty, buf)



@dataclass
class VisualCaptureProvenance:
    """
    Immutable capture provenance echoed by a parse result.
"""
    def __init__(self, *, capture_id:str, source:VisualCaptureSource, screenshot:VisualScreenshotReference, action_coordinate_space:VisualActionCoordinateSpace, captured_at:typing.Optional[str]):
        self.capture_id = capture_id
        self.source = source
        self.screenshot = screenshot
        self.action_coordinate_space = action_coordinate_space
        self.captured_at = captured_at




    def __str__(self):
        return "VisualCaptureProvenance(capture_id={}, source={}, screenshot={}, action_coordinate_space={}, captured_at={})".format(self.capture_id, self.source, self.screenshot, self.action_coordinate_space, self.captured_at)
    def __eq__(self, other):
        if self.capture_id != other.capture_id:
            return False
        if self.source != other.source:
            return False
        if self.screenshot != other.screenshot:
            return False
        if self.action_coordinate_space != other.action_coordinate_space:
            return False
        if self.captured_at != other.captured_at:
            return False
        return True

class _UniffiFfiConverterTypeVisualCaptureProvenance(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return VisualCaptureProvenance(
            capture_id=_UniffiFfiConverterString.read(buf),
            source=_UniffiFfiConverterTypeVisualCaptureSource.read(buf),
            screenshot=_UniffiFfiConverterTypeVisualScreenshotReference.read(buf),
            action_coordinate_space=_UniffiFfiConverterTypeVisualActionCoordinateSpace.read(buf),
            captured_at=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.capture_id)
        _UniffiFfiConverterTypeVisualCaptureSource.check_lower(value.source)
        _UniffiFfiConverterTypeVisualScreenshotReference.check_lower(value.screenshot)
        _UniffiFfiConverterTypeVisualActionCoordinateSpace.check_lower(value.action_coordinate_space)
        _UniffiFfiConverterOptionalString.check_lower(value.captured_at)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.capture_id, buf)
        _UniffiFfiConverterTypeVisualCaptureSource.write(value.source, buf)
        _UniffiFfiConverterTypeVisualScreenshotReference.write(value.screenshot, buf)
        _UniffiFfiConverterTypeVisualActionCoordinateSpace.write(value.action_coordinate_space, buf)
        _UniffiFfiConverterOptionalString.write(value.captured_at, buf)

@dataclass
class VisualParserMetadata:
    """
    Identity of the extension and model that produced a result.
"""
    def __init__(self, *, extension_id:str, extension_version:str, model_id:str, model_version:str, runtime:typing.Optional[str], backend:typing.Optional[str], model_source_revision:typing.Optional[str], model_manifest_sha256:typing.Optional[str], onnx_runtime_version:typing.Optional[str], onnx_runtime_library_sha256:typing.Optional[str], fixture_sha256:typing.Optional[str]):
        self.extension_id = extension_id
        self.extension_version = extension_version
        self.model_id = model_id
        self.model_version = model_version
        self.runtime = runtime
        self.backend = backend
        self.model_source_revision = model_source_revision
        self.model_manifest_sha256 = model_manifest_sha256
        self.onnx_runtime_version = onnx_runtime_version
        self.onnx_runtime_library_sha256 = onnx_runtime_library_sha256
        self.fixture_sha256 = fixture_sha256




    def __str__(self):
        return "VisualParserMetadata(extension_id={}, extension_version={}, model_id={}, model_version={}, runtime={}, backend={}, model_source_revision={}, model_manifest_sha256={}, onnx_runtime_version={}, onnx_runtime_library_sha256={}, fixture_sha256={})".format(self.extension_id, self.extension_version, self.model_id, self.model_version, self.runtime, self.backend, self.model_source_revision, self.model_manifest_sha256, self.onnx_runtime_version, self.onnx_runtime_library_sha256, self.fixture_sha256)
    def __eq__(self, other):
        if self.extension_id != other.extension_id:
            return False
        if self.extension_version != other.extension_version:
            return False
        if self.model_id != other.model_id:
            return False
        if self.model_version != other.model_version:
            return False
        if self.runtime != other.runtime:
            return False
        if self.backend != other.backend:
            return False
        if self.model_source_revision != other.model_source_revision:
            return False
        if self.model_manifest_sha256 != other.model_manifest_sha256:
            return False
        if self.onnx_runtime_version != other.onnx_runtime_version:
            return False
        if self.onnx_runtime_library_sha256 != other.onnx_runtime_library_sha256:
            return False
        if self.fixture_sha256 != other.fixture_sha256:
            return False
        return True

class _UniffiFfiConverterTypeVisualParserMetadata(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return VisualParserMetadata(
            extension_id=_UniffiFfiConverterString.read(buf),
            extension_version=_UniffiFfiConverterString.read(buf),
            model_id=_UniffiFfiConverterString.read(buf),
            model_version=_UniffiFfiConverterString.read(buf),
            runtime=_UniffiFfiConverterOptionalString.read(buf),
            backend=_UniffiFfiConverterOptionalString.read(buf),
            model_source_revision=_UniffiFfiConverterOptionalString.read(buf),
            model_manifest_sha256=_UniffiFfiConverterOptionalString.read(buf),
            onnx_runtime_version=_UniffiFfiConverterOptionalString.read(buf),
            onnx_runtime_library_sha256=_UniffiFfiConverterOptionalString.read(buf),
            fixture_sha256=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.extension_id)
        _UniffiFfiConverterString.check_lower(value.extension_version)
        _UniffiFfiConverterString.check_lower(value.model_id)
        _UniffiFfiConverterString.check_lower(value.model_version)
        _UniffiFfiConverterOptionalString.check_lower(value.runtime)
        _UniffiFfiConverterOptionalString.check_lower(value.backend)
        _UniffiFfiConverterOptionalString.check_lower(value.model_source_revision)
        _UniffiFfiConverterOptionalString.check_lower(value.model_manifest_sha256)
        _UniffiFfiConverterOptionalString.check_lower(value.onnx_runtime_version)
        _UniffiFfiConverterOptionalString.check_lower(value.onnx_runtime_library_sha256)
        _UniffiFfiConverterOptionalString.check_lower(value.fixture_sha256)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.extension_id, buf)
        _UniffiFfiConverterString.write(value.extension_version, buf)
        _UniffiFfiConverterString.write(value.model_id, buf)
        _UniffiFfiConverterString.write(value.model_version, buf)
        _UniffiFfiConverterOptionalString.write(value.runtime, buf)
        _UniffiFfiConverterOptionalString.write(value.backend, buf)
        _UniffiFfiConverterOptionalString.write(value.model_source_revision, buf)
        _UniffiFfiConverterOptionalString.write(value.model_manifest_sha256, buf)
        _UniffiFfiConverterOptionalString.write(value.onnx_runtime_version, buf)
        _UniffiFfiConverterOptionalString.write(value.onnx_runtime_library_sha256, buf)
        _UniffiFfiConverterOptionalString.write(value.fixture_sha256, buf)

@dataclass
class VisualRegionBounds:
    """
    Integer pixel-edge bounds `[x, x + width) x [y, y + height)`.

    `x` and `y` name the left and top pixel edges. The right and bottom edges
    are excluded. A region therefore covers every pixel whose center lies in
    this half-open box; its geometric center may lie between pixels.
"""
    def __init__(self, *, x:int, y:int, width:int, height:int):
        self.x = x
        self.y = y
        self.width = width
        self.height = height




    def __str__(self):
        return "VisualRegionBounds(x={}, y={}, width={}, height={})".format(self.x, self.y, self.width, self.height)
    def __eq__(self, other):
        if self.x != other.x:
            return False
        if self.y != other.y:
            return False
        if self.width != other.width:
            return False
        if self.height != other.height:
            return False
        return True

class _UniffiFfiConverterTypeVisualRegionBounds(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return VisualRegionBounds(
            x=_UniffiFfiConverterUInt32.read(buf),
            y=_UniffiFfiConverterUInt32.read(buf),
            width=_UniffiFfiConverterUInt32.read(buf),
            height=_UniffiFfiConverterUInt32.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterUInt32.check_lower(value.x)
        _UniffiFfiConverterUInt32.check_lower(value.y)
        _UniffiFfiConverterUInt32.check_lower(value.width)
        _UniffiFfiConverterUInt32.check_lower(value.height)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterUInt32.write(value.x, buf)
        _UniffiFfiConverterUInt32.write(value.y, buf)
        _UniffiFfiConverterUInt32.write(value.width, buf)
        _UniffiFfiConverterUInt32.write(value.height, buf)

@dataclass
class VisualRegion:
    """
    One parser-observed region in the exact source screenshot pixel space.
"""
    def __init__(self, *, id:str, kind:VisualRegionKind, bounds:VisualRegionBounds, text:typing.Optional[str], label:typing.Optional[str], confidence:float, interactive:bool, parent_id:typing.Optional[str], group_id:typing.Optional[str], reading_order:typing.Optional[int]):
        self.id = id
        self.kind = kind
        self.bounds = bounds
        self.text = text
        self.label = label
        self.confidence = confidence
        self.interactive = interactive
        self.parent_id = parent_id
        self.group_id = group_id
        self.reading_order = reading_order




    def __str__(self):
        return "VisualRegion(id={}, kind={}, bounds={}, text={}, label={}, confidence={}, interactive={}, parent_id={}, group_id={}, reading_order={})".format(self.id, self.kind, self.bounds, self.text, self.label, self.confidence, self.interactive, self.parent_id, self.group_id, self.reading_order)
    def __eq__(self, other):
        if self.id != other.id:
            return False
        if self.kind != other.kind:
            return False
        if self.bounds != other.bounds:
            return False
        if self.text != other.text:
            return False
        if self.label != other.label:
            return False
        if self.confidence != other.confidence:
            return False
        if self.interactive != other.interactive:
            return False
        if self.parent_id != other.parent_id:
            return False
        if self.group_id != other.group_id:
            return False
        if self.reading_order != other.reading_order:
            return False
        return True

class _UniffiFfiConverterTypeVisualRegion(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return VisualRegion(
            id=_UniffiFfiConverterString.read(buf),
            kind=_UniffiFfiConverterTypeVisualRegionKind.read(buf),
            bounds=_UniffiFfiConverterTypeVisualRegionBounds.read(buf),
            text=_UniffiFfiConverterOptionalString.read(buf),
            label=_UniffiFfiConverterOptionalString.read(buf),
            confidence=_UniffiFfiConverterFloat64.read(buf),
            interactive=_UniffiFfiConverterBoolean.read(buf),
            parent_id=_UniffiFfiConverterOptionalString.read(buf),
            group_id=_UniffiFfiConverterOptionalString.read(buf),
            reading_order=_UniffiFfiConverterOptionalUInt32.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.id)
        _UniffiFfiConverterTypeVisualRegionKind.check_lower(value.kind)
        _UniffiFfiConverterTypeVisualRegionBounds.check_lower(value.bounds)
        _UniffiFfiConverterOptionalString.check_lower(value.text)
        _UniffiFfiConverterOptionalString.check_lower(value.label)
        _UniffiFfiConverterFloat64.check_lower(value.confidence)
        _UniffiFfiConverterBoolean.check_lower(value.interactive)
        _UniffiFfiConverterOptionalString.check_lower(value.parent_id)
        _UniffiFfiConverterOptionalString.check_lower(value.group_id)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.reading_order)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.id, buf)
        _UniffiFfiConverterTypeVisualRegionKind.write(value.kind, buf)
        _UniffiFfiConverterTypeVisualRegionBounds.write(value.bounds, buf)
        _UniffiFfiConverterOptionalString.write(value.text, buf)
        _UniffiFfiConverterOptionalString.write(value.label, buf)
        _UniffiFfiConverterFloat64.write(value.confidence, buf)
        _UniffiFfiConverterBoolean.write(value.interactive, buf)
        _UniffiFfiConverterOptionalString.write(value.parent_id, buf)
        _UniffiFfiConverterOptionalString.write(value.group_id, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.reading_order, buf)

class _UniffiFfiConverterSequenceTypeVisualRegion(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypeVisualRegion.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypeVisualRegion.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypeVisualRegion.read(buf) for i in range(count)
        ]

@dataclass
class VisualParseWarning:
    def __init__(self, *, code:str, message:str, detail:typing.Optional[str]):
        self.code = code
        self.message = message
        self.detail = detail




    def __str__(self):
        return "VisualParseWarning(code={}, message={}, detail={})".format(self.code, self.message, self.detail)
    def __eq__(self, other):
        if self.code != other.code:
            return False
        if self.message != other.message:
            return False
        if self.detail != other.detail:
            return False
        return True

class _UniffiFfiConverterTypeVisualParseWarning(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return VisualParseWarning(
            code=_UniffiFfiConverterString.read(buf),
            message=_UniffiFfiConverterString.read(buf),
            detail=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.code)
        _UniffiFfiConverterString.check_lower(value.message)
        _UniffiFfiConverterOptionalString.check_lower(value.detail)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.code, buf)
        _UniffiFfiConverterString.write(value.message, buf)
        _UniffiFfiConverterOptionalString.write(value.detail, buf)

class _UniffiFfiConverterSequenceTypeVisualParseWarning(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypeVisualParseWarning.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypeVisualParseWarning.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypeVisualParseWarning.read(buf) for i in range(count)
        ]

@dataclass
class VisualParseTiming:
    def __init__(self, *, duration_ms:int, preprocess_ms:typing.Optional[int], inference_ms:typing.Optional[int]):
        self.duration_ms = duration_ms
        self.preprocess_ms = preprocess_ms
        self.inference_ms = inference_ms




    def __str__(self):
        return "VisualParseTiming(duration_ms={}, preprocess_ms={}, inference_ms={})".format(self.duration_ms, self.preprocess_ms, self.inference_ms)
    def __eq__(self, other):
        if self.duration_ms != other.duration_ms:
            return False
        if self.preprocess_ms != other.preprocess_ms:
            return False
        if self.inference_ms != other.inference_ms:
            return False
        return True

class _UniffiFfiConverterTypeVisualParseTiming(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return VisualParseTiming(
            duration_ms=_UniffiFfiConverterUInt64.read(buf),
            preprocess_ms=_UniffiFfiConverterOptionalUInt64.read(buf),
            inference_ms=_UniffiFfiConverterOptionalUInt64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterUInt64.check_lower(value.duration_ms)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.preprocess_ms)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.inference_ms)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterUInt64.write(value.duration_ms, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.preprocess_ms, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.inference_ms, buf)

@dataclass
class ParseVisualRegionsOutput:
    def __init__(self, *, schema:str, capture:VisualCaptureProvenance, parser:VisualParserMetadata, regions:typing.List[VisualRegion], warnings:typing.List[VisualParseWarning], timing:VisualParseTiming, request_id:typing.Optional[str]):
        self.schema = schema
        self.capture = capture
        self.parser = parser
        self.regions = regions
        self.warnings = warnings
        self.timing = timing
        self.request_id = request_id




    def __str__(self):
        return "ParseVisualRegionsOutput(schema={}, capture={}, parser={}, regions={}, warnings={}, timing={}, request_id={})".format(self.schema, self.capture, self.parser, self.regions, self.warnings, self.timing, self.request_id)
    def __eq__(self, other):
        if self.schema != other.schema:
            return False
        if self.capture != other.capture:
            return False
        if self.parser != other.parser:
            return False
        if self.regions != other.regions:
            return False
        if self.warnings != other.warnings:
            return False
        if self.timing != other.timing:
            return False
        if self.request_id != other.request_id:
            return False
        return True

class _UniffiFfiConverterTypeParseVisualRegionsOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ParseVisualRegionsOutput(
            schema=_UniffiFfiConverterString.read(buf),
            capture=_UniffiFfiConverterTypeVisualCaptureProvenance.read(buf),
            parser=_UniffiFfiConverterTypeVisualParserMetadata.read(buf),
            regions=_UniffiFfiConverterSequenceTypeVisualRegion.read(buf),
            warnings=_UniffiFfiConverterSequenceTypeVisualParseWarning.read(buf),
            timing=_UniffiFfiConverterTypeVisualParseTiming.read(buf),
            request_id=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.schema)
        _UniffiFfiConverterTypeVisualCaptureProvenance.check_lower(value.capture)
        _UniffiFfiConverterTypeVisualParserMetadata.check_lower(value.parser)
        _UniffiFfiConverterSequenceTypeVisualRegion.check_lower(value.regions)
        _UniffiFfiConverterSequenceTypeVisualParseWarning.check_lower(value.warnings)
        _UniffiFfiConverterTypeVisualParseTiming.check_lower(value.timing)
        _UniffiFfiConverterOptionalString.check_lower(value.request_id)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.schema, buf)
        _UniffiFfiConverterTypeVisualCaptureProvenance.write(value.capture, buf)
        _UniffiFfiConverterTypeVisualParserMetadata.write(value.parser, buf)
        _UniffiFfiConverterSequenceTypeVisualRegion.write(value.regions, buf)
        _UniffiFfiConverterSequenceTypeVisualParseWarning.write(value.warnings, buf)
        _UniffiFfiConverterTypeVisualParseTiming.write(value.timing, buf)
        _UniffiFfiConverterOptionalString.write(value.request_id, buf)






class VerificationStatus(enum.Enum):

    SATISFIED = 0

    UNSATISFIED = 1

    UNKNOWN = 2



class _UniffiFfiConverterTypeVerificationStatus(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return VerificationStatus.SATISFIED
        if variant == 2:
            return VerificationStatus.UNSATISFIED
        if variant == 3:
            return VerificationStatus.UNKNOWN
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == VerificationStatus.SATISFIED:
            return
        if value == VerificationStatus.UNSATISFIED:
            return
        if value == VerificationStatus.UNKNOWN:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == VerificationStatus.SATISFIED:
            buf.write_i32(1)
        if value == VerificationStatus.UNSATISFIED:
            buf.write_i32(2)
        if value == VerificationStatus.UNKNOWN:
            buf.write_i32(3)








class UnknownReason(enum.Enum):

    INVALID_PREDICATE = 0

    UNSUPPORTED_PREDICATE = 1

    UNTRUSTED_SOURCE = 2

    MULTI_MATCH = 3

    TARGET_MISSING = 4

    OBSERVATION_UNAVAILABLE = 5

    STABILITY_UNPROVEN = 6



class _UniffiFfiConverterTypeUnknownReason(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return UnknownReason.INVALID_PREDICATE
        if variant == 2:
            return UnknownReason.UNSUPPORTED_PREDICATE
        if variant == 3:
            return UnknownReason.UNTRUSTED_SOURCE
        if variant == 4:
            return UnknownReason.MULTI_MATCH
        if variant == 5:
            return UnknownReason.TARGET_MISSING
        if variant == 6:
            return UnknownReason.OBSERVATION_UNAVAILABLE
        if variant == 7:
            return UnknownReason.STABILITY_UNPROVEN
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == UnknownReason.INVALID_PREDICATE:
            return
        if value == UnknownReason.UNSUPPORTED_PREDICATE:
            return
        if value == UnknownReason.UNTRUSTED_SOURCE:
            return
        if value == UnknownReason.MULTI_MATCH:
            return
        if value == UnknownReason.TARGET_MISSING:
            return
        if value == UnknownReason.OBSERVATION_UNAVAILABLE:
            return
        if value == UnknownReason.STABILITY_UNPROVEN:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == UnknownReason.INVALID_PREDICATE:
            buf.write_i32(1)
        if value == UnknownReason.UNSUPPORTED_PREDICATE:
            buf.write_i32(2)
        if value == UnknownReason.UNTRUSTED_SOURCE:
            buf.write_i32(3)
        if value == UnknownReason.MULTI_MATCH:
            buf.write_i32(4)
        if value == UnknownReason.TARGET_MISSING:
            buf.write_i32(5)
        if value == UnknownReason.OBSERVATION_UNAVAILABLE:
            buf.write_i32(6)
        if value == UnknownReason.STABILITY_UNPROVEN:
            buf.write_i32(7)



class _UniffiFfiConverterOptionalTypeUnknownReason(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeUnknownReason.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeUnknownReason.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeUnknownReason.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class PredicateOutcome:
    def __init__(self, *, index:int, status:VerificationStatus, unknown_reason:typing.Optional[UnknownReason], observed_json:typing.Optional[str]):
        self.index = index
        self.status = status
        self.unknown_reason = unknown_reason
        self.observed_json = observed_json




    def __str__(self):
        return "PredicateOutcome(index={}, status={}, unknown_reason={}, observed_json={})".format(self.index, self.status, self.unknown_reason, self.observed_json)
    def __eq__(self, other):
        if self.index != other.index:
            return False
        if self.status != other.status:
            return False
        if self.unknown_reason != other.unknown_reason:
            return False
        if self.observed_json != other.observed_json:
            return False
        return True

class _UniffiFfiConverterTypePredicateOutcome(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return PredicateOutcome(
            index=_UniffiFfiConverterUInt64.read(buf),
            status=_UniffiFfiConverterTypeVerificationStatus.read(buf),
            unknown_reason=_UniffiFfiConverterOptionalTypeUnknownReason.read(buf),
            observed_json=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterUInt64.check_lower(value.index)
        _UniffiFfiConverterTypeVerificationStatus.check_lower(value.status)
        _UniffiFfiConverterOptionalTypeUnknownReason.check_lower(value.unknown_reason)
        _UniffiFfiConverterOptionalString.check_lower(value.observed_json)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterUInt64.write(value.index, buf)
        _UniffiFfiConverterTypeVerificationStatus.write(value.status, buf)
        _UniffiFfiConverterOptionalTypeUnknownReason.write(value.unknown_reason, buf)
        _UniffiFfiConverterOptionalString.write(value.observed_json, buf)

@dataclass
class PressKeyInput:
    def __init__(self, *, key:str, target:typing.Optional[ActionTarget], scope:typing.Optional[DesktopScope], session:typing.Optional[str], modifiers:typing.Optional[typing.List[str]]):
        self.key = key
        self.target = target
        self.scope = scope
        self.session = session
        self.modifiers = modifiers




    def __str__(self):
        return "PressKeyInput(key={}, target={}, scope={}, session={}, modifiers={})".format(self.key, self.target, self.scope, self.session, self.modifiers)
    def __eq__(self, other):
        if self.key != other.key:
            return False
        if self.target != other.target:
            return False
        if self.scope != other.scope:
            return False
        if self.session != other.session:
            return False
        if self.modifiers != other.modifiers:
            return False
        return True

class _UniffiFfiConverterTypePressKeyInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return PressKeyInput(
            key=_UniffiFfiConverterString.read(buf),
            target=_UniffiFfiConverterOptionalTypeActionTarget.read(buf),
            scope=_UniffiFfiConverterOptionalTypeDesktopScope.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
            modifiers=_UniffiFfiConverterOptionalSequenceString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.key)
        _UniffiFfiConverterOptionalTypeActionTarget.check_lower(value.target)
        _UniffiFfiConverterOptionalTypeDesktopScope.check_lower(value.scope)
        _UniffiFfiConverterOptionalString.check_lower(value.session)
        _UniffiFfiConverterOptionalSequenceString.check_lower(value.modifiers)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.key, buf)
        _UniffiFfiConverterOptionalTypeActionTarget.write(value.target, buf)
        _UniffiFfiConverterOptionalTypeDesktopScope.write(value.scope, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)
        _UniffiFfiConverterOptionalSequenceString.write(value.modifiers, buf)






class ScrollDirection(enum.Enum):

    UP = 0

    DOWN = 1

    LEFT = 2

    RIGHT = 3



class _UniffiFfiConverterTypeScrollDirection(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ScrollDirection.UP
        if variant == 2:
            return ScrollDirection.DOWN
        if variant == 3:
            return ScrollDirection.LEFT
        if variant == 4:
            return ScrollDirection.RIGHT
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == ScrollDirection.UP:
            return
        if value == ScrollDirection.DOWN:
            return
        if value == ScrollDirection.LEFT:
            return
        if value == ScrollDirection.RIGHT:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == ScrollDirection.UP:
            buf.write_i32(1)
        if value == ScrollDirection.DOWN:
            buf.write_i32(2)
        if value == ScrollDirection.LEFT:
            buf.write_i32(3)
        if value == ScrollDirection.RIGHT:
            buf.write_i32(4)








class ScrollBy(enum.Enum):

    LINE = 0

    PAGE = 1



class _UniffiFfiConverterTypeScrollBy(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return ScrollBy.LINE
        if variant == 2:
            return ScrollBy.PAGE
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == ScrollBy.LINE:
            return
        if value == ScrollBy.PAGE:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == ScrollBy.LINE:
            buf.write_i32(1)
        if value == ScrollBy.PAGE:
            buf.write_i32(2)



class _UniffiFfiConverterOptionalTypeScrollBy(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeScrollBy.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeScrollBy.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeScrollBy.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class ScrollInput:
    def __init__(self, *, x:float, y:float, direction:ScrollDirection, target:typing.Optional[ActionTarget], scope:typing.Optional[DesktopScope], session:typing.Optional[str], by:typing.Optional[ScrollBy], amount:typing.Optional[int]):
        self.x = x
        self.y = y
        self.direction = direction
        self.target = target
        self.scope = scope
        self.session = session
        self.by = by
        self.amount = amount




    def __str__(self):
        return "ScrollInput(x={}, y={}, direction={}, target={}, scope={}, session={}, by={}, amount={})".format(self.x, self.y, self.direction, self.target, self.scope, self.session, self.by, self.amount)
    def __eq__(self, other):
        if self.x != other.x:
            return False
        if self.y != other.y:
            return False
        if self.direction != other.direction:
            return False
        if self.target != other.target:
            return False
        if self.scope != other.scope:
            return False
        if self.session != other.session:
            return False
        if self.by != other.by:
            return False
        if self.amount != other.amount:
            return False
        return True

class _UniffiFfiConverterTypeScrollInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return ScrollInput(
            x=_UniffiFfiConverterFloat64.read(buf),
            y=_UniffiFfiConverterFloat64.read(buf),
            direction=_UniffiFfiConverterTypeScrollDirection.read(buf),
            target=_UniffiFfiConverterOptionalTypeActionTarget.read(buf),
            scope=_UniffiFfiConverterOptionalTypeDesktopScope.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
            by=_UniffiFfiConverterOptionalTypeScrollBy.read(buf),
            amount=_UniffiFfiConverterOptionalUInt64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterFloat64.check_lower(value.x)
        _UniffiFfiConverterFloat64.check_lower(value.y)
        _UniffiFfiConverterTypeScrollDirection.check_lower(value.direction)
        _UniffiFfiConverterOptionalTypeActionTarget.check_lower(value.target)
        _UniffiFfiConverterOptionalTypeDesktopScope.check_lower(value.scope)
        _UniffiFfiConverterOptionalString.check_lower(value.session)
        _UniffiFfiConverterOptionalTypeScrollBy.check_lower(value.by)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.amount)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterFloat64.write(value.x, buf)
        _UniffiFfiConverterFloat64.write(value.y, buf)
        _UniffiFfiConverterTypeScrollDirection.write(value.direction, buf)
        _UniffiFfiConverterOptionalTypeActionTarget.write(value.target, buf)
        _UniffiFfiConverterOptionalTypeDesktopScope.write(value.scope, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)
        _UniffiFfiConverterOptionalTypeScrollBy.write(value.by, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.amount, buf)






class CaptureScope(enum.Enum):

    AUTO = 0

    WINDOW = 1

    DESKTOP = 2



class _UniffiFfiConverterTypeCaptureScope(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return CaptureScope.AUTO
        if variant == 2:
            return CaptureScope.WINDOW
        if variant == 3:
            return CaptureScope.DESKTOP
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == CaptureScope.AUTO:
            return
        if value == CaptureScope.WINDOW:
            return
        if value == CaptureScope.DESKTOP:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == CaptureScope.AUTO:
            buf.write_i32(1)
        if value == CaptureScope.WINDOW:
            buf.write_i32(2)
        if value == CaptureScope.DESKTOP:
            buf.write_i32(3)








class EffectiveScope(enum.Enum):

    WINDOW = 0

    DESKTOP = 1



class _UniffiFfiConverterTypeEffectiveScope(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return EffectiveScope.WINDOW
        if variant == 2:
            return EffectiveScope.DESKTOP
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == EffectiveScope.WINDOW:
            return
        if value == EffectiveScope.DESKTOP:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == EffectiveScope.WINDOW:
            buf.write_i32(1)
        if value == EffectiveScope.DESKTOP:
            buf.write_i32(2)



class _UniffiFfiConverterOptionalTypeEscalationReason(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeEscalationReason.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeEscalationReason.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeEscalationReason.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class SessionStateOutput:
    """
    Successful structured result shared by session state and escalation tools.
"""
    def __init__(self, *, session:str, capture_scope:CaptureScope, effective_scope:EffectiveScope, desktop_capture_authorized:bool, desktop_unlocked:bool, escalation_reason:typing.Optional[EscalationReason], escalation_detail:typing.Optional[str]):
        self.session = session
        self.capture_scope = capture_scope
        self.effective_scope = effective_scope
        self.desktop_capture_authorized = desktop_capture_authorized
        self.desktop_unlocked = desktop_unlocked
        self.escalation_reason = escalation_reason
        self.escalation_detail = escalation_detail




    def __str__(self):
        return "SessionStateOutput(session={}, capture_scope={}, effective_scope={}, desktop_capture_authorized={}, desktop_unlocked={}, escalation_reason={}, escalation_detail={})".format(self.session, self.capture_scope, self.effective_scope, self.desktop_capture_authorized, self.desktop_unlocked, self.escalation_reason, self.escalation_detail)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.capture_scope != other.capture_scope:
            return False
        if self.effective_scope != other.effective_scope:
            return False
        if self.desktop_capture_authorized != other.desktop_capture_authorized:
            return False
        if self.desktop_unlocked != other.desktop_unlocked:
            return False
        if self.escalation_reason != other.escalation_reason:
            return False
        if self.escalation_detail != other.escalation_detail:
            return False
        return True

class _UniffiFfiConverterTypeSessionStateOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return SessionStateOutput(
            session=_UniffiFfiConverterString.read(buf),
            capture_scope=_UniffiFfiConverterTypeCaptureScope.read(buf),
            effective_scope=_UniffiFfiConverterTypeEffectiveScope.read(buf),
            desktop_capture_authorized=_UniffiFfiConverterBoolean.read(buf),
            desktop_unlocked=_UniffiFfiConverterBoolean.read(buf),
            escalation_reason=_UniffiFfiConverterOptionalTypeEscalationReason.read(buf),
            escalation_detail=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)
        _UniffiFfiConverterTypeCaptureScope.check_lower(value.capture_scope)
        _UniffiFfiConverterTypeEffectiveScope.check_lower(value.effective_scope)
        _UniffiFfiConverterBoolean.check_lower(value.desktop_capture_authorized)
        _UniffiFfiConverterBoolean.check_lower(value.desktop_unlocked)
        _UniffiFfiConverterOptionalTypeEscalationReason.check_lower(value.escalation_reason)
        _UniffiFfiConverterOptionalString.check_lower(value.escalation_detail)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)
        _UniffiFfiConverterTypeCaptureScope.write(value.capture_scope, buf)
        _UniffiFfiConverterTypeEffectiveScope.write(value.effective_scope, buf)
        _UniffiFfiConverterBoolean.write(value.desktop_capture_authorized, buf)
        _UniffiFfiConverterBoolean.write(value.desktop_unlocked, buf)
        _UniffiFfiConverterOptionalTypeEscalationReason.write(value.escalation_reason, buf)
        _UniffiFfiConverterOptionalString.write(value.escalation_detail, buf)

@dataclass
class SetAgentCursorEnabledInput:
    def __init__(self, *, session:str, enabled:bool):
        self.session = session
        self.enabled = enabled




    def __str__(self):
        return "SetAgentCursorEnabledInput(session={}, enabled={})".format(self.session, self.enabled)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.enabled != other.enabled:
            return False
        return True

class _UniffiFfiConverterTypeSetAgentCursorEnabledInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return SetAgentCursorEnabledInput(
            session=_UniffiFfiConverterString.read(buf),
            enabled=_UniffiFfiConverterBoolean.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)
        _UniffiFfiConverterBoolean.check_lower(value.enabled)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)
        _UniffiFfiConverterBoolean.write(value.enabled, buf)

@dataclass
class SetAgentCursorEnabledOutput:
    def __init__(self, *, session:str, enabled:bool):
        self.session = session
        self.enabled = enabled




    def __str__(self):
        return "SetAgentCursorEnabledOutput(session={}, enabled={})".format(self.session, self.enabled)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.enabled != other.enabled:
            return False
        return True

class _UniffiFfiConverterTypeSetAgentCursorEnabledOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return SetAgentCursorEnabledOutput(
            session=_UniffiFfiConverterString.read(buf),
            enabled=_UniffiFfiConverterBoolean.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)
        _UniffiFfiConverterBoolean.check_lower(value.enabled)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)
        _UniffiFfiConverterBoolean.write(value.enabled, buf)

@dataclass
class SetAgentCursorMotionInput:
    def __init__(self, *, session:str, style:typing.Optional[CursorMotionStyle], timing:typing.Optional[CursorMotionTiming], effects:typing.Optional[CursorMotionEffects], start_handle:typing.Optional[float], end_handle:typing.Optional[float], arc_size:typing.Optional[float], arc_flow:typing.Optional[float], spring:typing.Optional[float], glide_duration_ms:typing.Optional[float], dwell_after_click_ms:typing.Optional[float], idle_hide_ms:typing.Optional[float], turn_radius:typing.Optional[float]):
        self.session = session
        self.style = style
        self.timing = timing
        self.effects = effects
        self.start_handle = start_handle
        self.end_handle = end_handle
        self.arc_size = arc_size
        self.arc_flow = arc_flow
        self.spring = spring
        self.glide_duration_ms = glide_duration_ms
        self.dwell_after_click_ms = dwell_after_click_ms
        self.idle_hide_ms = idle_hide_ms
        self.turn_radius = turn_radius




    def __str__(self):
        return "SetAgentCursorMotionInput(session={}, style={}, timing={}, effects={}, start_handle={}, end_handle={}, arc_size={}, arc_flow={}, spring={}, glide_duration_ms={}, dwell_after_click_ms={}, idle_hide_ms={}, turn_radius={})".format(self.session, self.style, self.timing, self.effects, self.start_handle, self.end_handle, self.arc_size, self.arc_flow, self.spring, self.glide_duration_ms, self.dwell_after_click_ms, self.idle_hide_ms, self.turn_radius)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.style != other.style:
            return False
        if self.timing != other.timing:
            return False
        if self.effects != other.effects:
            return False
        if self.start_handle != other.start_handle:
            return False
        if self.end_handle != other.end_handle:
            return False
        if self.arc_size != other.arc_size:
            return False
        if self.arc_flow != other.arc_flow:
            return False
        if self.spring != other.spring:
            return False
        if self.glide_duration_ms != other.glide_duration_ms:
            return False
        if self.dwell_after_click_ms != other.dwell_after_click_ms:
            return False
        if self.idle_hide_ms != other.idle_hide_ms:
            return False
        if self.turn_radius != other.turn_radius:
            return False
        return True

class _UniffiFfiConverterTypeSetAgentCursorMotionInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return SetAgentCursorMotionInput(
            session=_UniffiFfiConverterString.read(buf),
            style=_UniffiFfiConverterOptionalTypeCursorMotionStyle.read(buf),
            timing=_UniffiFfiConverterOptionalTypeCursorMotionTiming.read(buf),
            effects=_UniffiFfiConverterOptionalTypeCursorMotionEffects.read(buf),
            start_handle=_UniffiFfiConverterOptionalFloat64.read(buf),
            end_handle=_UniffiFfiConverterOptionalFloat64.read(buf),
            arc_size=_UniffiFfiConverterOptionalFloat64.read(buf),
            arc_flow=_UniffiFfiConverterOptionalFloat64.read(buf),
            spring=_UniffiFfiConverterOptionalFloat64.read(buf),
            glide_duration_ms=_UniffiFfiConverterOptionalFloat64.read(buf),
            dwell_after_click_ms=_UniffiFfiConverterOptionalFloat64.read(buf),
            idle_hide_ms=_UniffiFfiConverterOptionalFloat64.read(buf),
            turn_radius=_UniffiFfiConverterOptionalFloat64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)
        _UniffiFfiConverterOptionalTypeCursorMotionStyle.check_lower(value.style)
        _UniffiFfiConverterOptionalTypeCursorMotionTiming.check_lower(value.timing)
        _UniffiFfiConverterOptionalTypeCursorMotionEffects.check_lower(value.effects)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.start_handle)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.end_handle)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.arc_size)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.arc_flow)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.spring)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.glide_duration_ms)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.dwell_after_click_ms)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.idle_hide_ms)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.turn_radius)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)
        _UniffiFfiConverterOptionalTypeCursorMotionStyle.write(value.style, buf)
        _UniffiFfiConverterOptionalTypeCursorMotionTiming.write(value.timing, buf)
        _UniffiFfiConverterOptionalTypeCursorMotionEffects.write(value.effects, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.start_handle, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.end_handle, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.arc_size, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.arc_flow, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.spring, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.glide_duration_ms, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.dwell_after_click_ms, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.idle_hide_ms, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.turn_radius, buf)

@dataclass
class SetAgentCursorMotionOutput:
    def __init__(self, *, session:str, motion:CursorMotionOutput):
        self.session = session
        self.motion = motion




    def __str__(self):
        return "SetAgentCursorMotionOutput(session={}, motion={})".format(self.session, self.motion)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.motion != other.motion:
            return False
        return True

class _UniffiFfiConverterTypeSetAgentCursorMotionOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return SetAgentCursorMotionOutput(
            session=_UniffiFfiConverterString.read(buf),
            motion=_UniffiFfiConverterTypeCursorMotionOutput.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)
        _UniffiFfiConverterTypeCursorMotionOutput.check_lower(value.motion)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)
        _UniffiFfiConverterTypeCursorMotionOutput.write(value.motion, buf)

@dataclass
class SetAgentCursorThemeInput:
    def __init__(self, *, session:str, theme_id:str, reduced_motion:CursorReducedMotion):
        self.session = session
        self.theme_id = theme_id
        self.reduced_motion = reduced_motion




    def __str__(self):
        return "SetAgentCursorThemeInput(session={}, theme_id={}, reduced_motion={})".format(self.session, self.theme_id, self.reduced_motion)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.theme_id != other.theme_id:
            return False
        if self.reduced_motion != other.reduced_motion:
            return False
        return True

class _UniffiFfiConverterTypeSetAgentCursorThemeInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return SetAgentCursorThemeInput(
            session=_UniffiFfiConverterString.read(buf),
            theme_id=_UniffiFfiConverterString.read(buf),
            reduced_motion=_UniffiFfiConverterTypeCursorReducedMotion.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)
        _UniffiFfiConverterString.check_lower(value.theme_id)
        _UniffiFfiConverterTypeCursorReducedMotion.check_lower(value.reduced_motion)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)
        _UniffiFfiConverterString.write(value.theme_id, buf)
        _UniffiFfiConverterTypeCursorReducedMotion.write(value.reduced_motion, buf)

@dataclass
class SetAgentCursorThemeOutput:
    def __init__(self, *, session:str, theme:CursorThemeOutput):
        self.session = session
        self.theme = theme




    def __str__(self):
        return "SetAgentCursorThemeOutput(session={}, theme={})".format(self.session, self.theme)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.theme != other.theme:
            return False
        return True

class _UniffiFfiConverterTypeSetAgentCursorThemeOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return SetAgentCursorThemeOutput(
            session=_UniffiFfiConverterString.read(buf),
            theme=_UniffiFfiConverterTypeCursorThemeOutput.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.session)
        _UniffiFfiConverterTypeCursorThemeOutput.check_lower(value.theme)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.session, buf)
        _UniffiFfiConverterTypeCursorThemeOutput.write(value.theme, buf)

@dataclass
class SetWindowFrameInput:
    def __init__(self, *, pid:int, window_id:int, x:float, y:float, width:float, height:float, session:typing.Optional[str]):
        self.pid = pid
        self.window_id = window_id
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.session = session




    def __str__(self):
        return "SetWindowFrameInput(pid={}, window_id={}, x={}, y={}, width={}, height={}, session={})".format(self.pid, self.window_id, self.x, self.y, self.width, self.height, self.session)
    def __eq__(self, other):
        if self.pid != other.pid:
            return False
        if self.window_id != other.window_id:
            return False
        if self.x != other.x:
            return False
        if self.y != other.y:
            return False
        if self.width != other.width:
            return False
        if self.height != other.height:
            return False
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeSetWindowFrameInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return SetWindowFrameInput(
            pid=_UniffiFfiConverterUInt32.read(buf),
            window_id=_UniffiFfiConverterUInt64.read(buf),
            x=_UniffiFfiConverterFloat64.read(buf),
            y=_UniffiFfiConverterFloat64.read(buf),
            width=_UniffiFfiConverterFloat64.read(buf),
            height=_UniffiFfiConverterFloat64.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterUInt32.check_lower(value.pid)
        _UniffiFfiConverterUInt64.check_lower(value.window_id)
        _UniffiFfiConverterFloat64.check_lower(value.x)
        _UniffiFfiConverterFloat64.check_lower(value.y)
        _UniffiFfiConverterFloat64.check_lower(value.width)
        _UniffiFfiConverterFloat64.check_lower(value.height)
        _UniffiFfiConverterOptionalString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterUInt32.write(value.pid, buf)
        _UniffiFfiConverterUInt64.write(value.window_id, buf)
        _UniffiFfiConverterFloat64.write(value.x, buf)
        _UniffiFfiConverterFloat64.write(value.y, buf)
        _UniffiFfiConverterFloat64.write(value.width, buf)
        _UniffiFfiConverterFloat64.write(value.height, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)

@dataclass
class SnapshotImage:
    def __init__(self, *, mime_type:str, data_base64:str):
        self.mime_type = mime_type
        self.data_base64 = data_base64




    def __str__(self):
        return "SnapshotImage(mime_type={}, data_base64={})".format(self.mime_type, self.data_base64)
    def __eq__(self, other):
        if self.mime_type != other.mime_type:
            return False
        if self.data_base64 != other.data_base64:
            return False
        return True

class _UniffiFfiConverterTypeSnapshotImage(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return SnapshotImage(
            mime_type=_UniffiFfiConverterString.read(buf),
            data_base64=_UniffiFfiConverterString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.mime_type)
        _UniffiFfiConverterString.check_lower(value.data_base64)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.mime_type, buf)
        _UniffiFfiConverterString.write(value.data_base64, buf)

class _UniffiFfiConverterOptionalTypeCaptureScope(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeCaptureScope.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeCaptureScope.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeCaptureScope.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterOptionalTypeCursorThemeSelection(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeCursorThemeSelection.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeCursorThemeSelection.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeCursorThemeSelection.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterOptionalTypeCursorMotionSelection(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeCursorMotionSelection.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeCursorMotionSelection.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeCursorMotionSelection.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class StartSessionInput:
    def __init__(self, *, session:typing.Optional[str], capture_scope:typing.Optional[CaptureScope], cursor_theme:typing.Optional[CursorThemeSelection], cursor_motion:typing.Optional[CursorMotionSelection]):
        self.session = session
        self.capture_scope = capture_scope
        self.cursor_theme = cursor_theme
        self.cursor_motion = cursor_motion




    def __str__(self):
        return "StartSessionInput(session={}, capture_scope={}, cursor_theme={}, cursor_motion={})".format(self.session, self.capture_scope, self.cursor_theme, self.cursor_motion)
    def __eq__(self, other):
        if self.session != other.session:
            return False
        if self.capture_scope != other.capture_scope:
            return False
        if self.cursor_theme != other.cursor_theme:
            return False
        if self.cursor_motion != other.cursor_motion:
            return False
        return True

class _UniffiFfiConverterTypeStartSessionInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return StartSessionInput(
            session=_UniffiFfiConverterOptionalString.read(buf),
            capture_scope=_UniffiFfiConverterOptionalTypeCaptureScope.read(buf),
            cursor_theme=_UniffiFfiConverterOptionalTypeCursorThemeSelection.read(buf),
            cursor_motion=_UniffiFfiConverterOptionalTypeCursorMotionSelection.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalString.check_lower(value.session)
        _UniffiFfiConverterOptionalTypeCaptureScope.check_lower(value.capture_scope)
        _UniffiFfiConverterOptionalTypeCursorThemeSelection.check_lower(value.cursor_theme)
        _UniffiFfiConverterOptionalTypeCursorMotionSelection.check_lower(value.cursor_motion)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalString.write(value.session, buf)
        _UniffiFfiConverterOptionalTypeCaptureScope.write(value.capture_scope, buf)
        _UniffiFfiConverterOptionalTypeCursorThemeSelection.write(value.cursor_theme, buf)
        _UniffiFfiConverterOptionalTypeCursorMotionSelection.write(value.cursor_motion, buf)

@dataclass
class StartSessionOutput:
    """
    Successful structured result returned by `start_session`.
"""
    def __init__(self, *, state:SessionStateOutput, active:bool, revived:bool, cursor_motion:typing.Optional[CursorMotionSelection]):
        self.state = state
        self.active = active
        self.revived = revived
        self.cursor_motion = cursor_motion




    def __str__(self):
        return "StartSessionOutput(state={}, active={}, revived={}, cursor_motion={})".format(self.state, self.active, self.revived, self.cursor_motion)
    def __eq__(self, other):
        if self.state != other.state:
            return False
        if self.active != other.active:
            return False
        if self.revived != other.revived:
            return False
        if self.cursor_motion != other.cursor_motion:
            return False
        return True

class _UniffiFfiConverterTypeStartSessionOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return StartSessionOutput(
            state=_UniffiFfiConverterTypeSessionStateOutput.read(buf),
            active=_UniffiFfiConverterBoolean.read(buf),
            revived=_UniffiFfiConverterBoolean.read(buf),
            cursor_motion=_UniffiFfiConverterOptionalTypeCursorMotionSelection.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterTypeSessionStateOutput.check_lower(value.state)
        _UniffiFfiConverterBoolean.check_lower(value.active)
        _UniffiFfiConverterBoolean.check_lower(value.revived)
        _UniffiFfiConverterOptionalTypeCursorMotionSelection.check_lower(value.cursor_motion)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterTypeSessionStateOutput.write(value.state, buf)
        _UniffiFfiConverterBoolean.write(value.active, buf)
        _UniffiFfiConverterBoolean.write(value.revived, buf)
        _UniffiFfiConverterOptionalTypeCursorMotionSelection.write(value.cursor_motion, buf)

class _UniffiFfiConverterOptionalTypeBoundsExpectation(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeBoundsExpectation.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeBoundsExpectation.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeBoundsExpectation.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class WindowPredicate:
    def __init__(self, *, exists:typing.Optional[bool], bounds:typing.Optional[BoundsExpectation]):
        self.exists = exists
        self.bounds = bounds




    def __str__(self):
        return "WindowPredicate(exists={}, bounds={})".format(self.exists, self.bounds)
    def __eq__(self, other):
        if self.exists != other.exists:
            return False
        if self.bounds != other.bounds:
            return False
        return True

class _UniffiFfiConverterTypeWindowPredicate(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return WindowPredicate(
            exists=_UniffiFfiConverterOptionalBoolean.read(buf),
            bounds=_UniffiFfiConverterOptionalTypeBoundsExpectation.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalBoolean.check_lower(value.exists)
        _UniffiFfiConverterOptionalTypeBoundsExpectation.check_lower(value.bounds)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalBoolean.write(value.exists, buf)
        _UniffiFfiConverterOptionalTypeBoundsExpectation.write(value.bounds, buf)

class _UniffiFfiConverterOptionalTypeWindowPredicate(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeWindowPredicate.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeWindowPredicate.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeWindowPredicate.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterOptionalTypeElementPredicate(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeElementPredicate.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeElementPredicate.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeElementPredicate.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class StatePredicate:
    def __init__(self, *, window:typing.Optional[WindowPredicate], element:typing.Optional[ElementPredicate]):
        self.window = window
        self.element = element




    def __str__(self):
        return "StatePredicate(window={}, element={})".format(self.window, self.element)
    def __eq__(self, other):
        if self.window != other.window:
            return False
        if self.element != other.element:
            return False
        return True

class _UniffiFfiConverterTypeStatePredicate(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return StatePredicate(
            window=_UniffiFfiConverterOptionalTypeWindowPredicate.read(buf),
            element=_UniffiFfiConverterOptionalTypeElementPredicate.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterOptionalTypeWindowPredicate.check_lower(value.window)
        _UniffiFfiConverterOptionalTypeElementPredicate.check_lower(value.element)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterOptionalTypeWindowPredicate.write(value.window, buf)
        _UniffiFfiConverterOptionalTypeElementPredicate.write(value.element, buf)

@dataclass
class TypeTextInput:
    def __init__(self, *, text:str, target:typing.Optional[ActionTarget], scope:typing.Optional[DesktopScope], session:typing.Optional[str]):
        self.text = text
        self.target = target
        self.scope = scope
        self.session = session




    def __str__(self):
        return "TypeTextInput(text={}, target={}, scope={}, session={})".format(self.text, self.target, self.scope, self.session)
    def __eq__(self, other):
        if self.text != other.text:
            return False
        if self.target != other.target:
            return False
        if self.scope != other.scope:
            return False
        if self.session != other.session:
            return False
        return True

class _UniffiFfiConverterTypeTypeTextInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return TypeTextInput(
            text=_UniffiFfiConverterString.read(buf),
            target=_UniffiFfiConverterOptionalTypeActionTarget.read(buf),
            scope=_UniffiFfiConverterOptionalTypeDesktopScope.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterString.check_lower(value.text)
        _UniffiFfiConverterOptionalTypeActionTarget.check_lower(value.target)
        _UniffiFfiConverterOptionalTypeDesktopScope.check_lower(value.scope)
        _UniffiFfiConverterOptionalString.check_lower(value.session)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterString.write(value.text, buf)
        _UniffiFfiConverterOptionalTypeActionTarget.write(value.target, buf)
        _UniffiFfiConverterOptionalTypeDesktopScope.write(value.scope, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)

class _UniffiFfiConverterSequenceTypeStatePredicate(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypeStatePredicate.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypeStatePredicate.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypeStatePredicate.read(buf) for i in range(count)
        ]

@dataclass
class VerifyStateInput:
    def __init__(self, *, pid:int, window_id:int, expect:typing.List[StatePredicate], session:typing.Optional[str], timeout_ms:typing.Optional[int], stable_samples:typing.Optional[int], include_screenshot:typing.Optional[bool]):
        self.pid = pid
        self.window_id = window_id
        self.expect = expect
        self.session = session
        self.timeout_ms = timeout_ms
        self.stable_samples = stable_samples
        self.include_screenshot = include_screenshot




    def __str__(self):
        return "VerifyStateInput(pid={}, window_id={}, expect={}, session={}, timeout_ms={}, stable_samples={}, include_screenshot={})".format(self.pid, self.window_id, self.expect, self.session, self.timeout_ms, self.stable_samples, self.include_screenshot)
    def __eq__(self, other):
        if self.pid != other.pid:
            return False
        if self.window_id != other.window_id:
            return False
        if self.expect != other.expect:
            return False
        if self.session != other.session:
            return False
        if self.timeout_ms != other.timeout_ms:
            return False
        if self.stable_samples != other.stable_samples:
            return False
        if self.include_screenshot != other.include_screenshot:
            return False
        return True

class _UniffiFfiConverterTypeVerifyStateInput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return VerifyStateInput(
            pid=_UniffiFfiConverterInt64.read(buf),
            window_id=_UniffiFfiConverterUInt64.read(buf),
            expect=_UniffiFfiConverterSequenceTypeStatePredicate.read(buf),
            session=_UniffiFfiConverterOptionalString.read(buf),
            timeout_ms=_UniffiFfiConverterOptionalUInt64.read(buf),
            stable_samples=_UniffiFfiConverterOptionalUInt64.read(buf),
            include_screenshot=_UniffiFfiConverterOptionalBoolean.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterInt64.check_lower(value.pid)
        _UniffiFfiConverterUInt64.check_lower(value.window_id)
        _UniffiFfiConverterSequenceTypeStatePredicate.check_lower(value.expect)
        _UniffiFfiConverterOptionalString.check_lower(value.session)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.timeout_ms)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.stable_samples)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.include_screenshot)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterInt64.write(value.pid, buf)
        _UniffiFfiConverterUInt64.write(value.window_id, buf)
        _UniffiFfiConverterSequenceTypeStatePredicate.write(value.expect, buf)
        _UniffiFfiConverterOptionalString.write(value.session, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.timeout_ms, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.stable_samples, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.include_screenshot, buf)

class _UniffiFfiConverterSequenceTypePredicateOutcome(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypePredicateOutcome.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypePredicateOutcome.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypePredicateOutcome.read(buf) for i in range(count)
        ]

@dataclass
class VerifyStateOutput:
    def __init__(self, *, status:VerificationStatus, stable:bool, elapsed_ms:int, samples:int, predicates:typing.List[PredicateOutcome]):
        self.status = status
        self.stable = stable
        self.elapsed_ms = elapsed_ms
        self.samples = samples
        self.predicates = predicates




    def __str__(self):
        return "VerifyStateOutput(status={}, stable={}, elapsed_ms={}, samples={}, predicates={})".format(self.status, self.stable, self.elapsed_ms, self.samples, self.predicates)
    def __eq__(self, other):
        if self.status != other.status:
            return False
        if self.stable != other.stable:
            return False
        if self.elapsed_ms != other.elapsed_ms:
            return False
        if self.samples != other.samples:
            return False
        if self.predicates != other.predicates:
            return False
        return True

class _UniffiFfiConverterTypeVerifyStateOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return VerifyStateOutput(
            status=_UniffiFfiConverterTypeVerificationStatus.read(buf),
            stable=_UniffiFfiConverterBoolean.read(buf),
            elapsed_ms=_UniffiFfiConverterUInt64.read(buf),
            samples=_UniffiFfiConverterUInt64.read(buf),
            predicates=_UniffiFfiConverterSequenceTypePredicateOutcome.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterTypeVerificationStatus.check_lower(value.status)
        _UniffiFfiConverterBoolean.check_lower(value.stable)
        _UniffiFfiConverterUInt64.check_lower(value.elapsed_ms)
        _UniffiFfiConverterUInt64.check_lower(value.samples)
        _UniffiFfiConverterSequenceTypePredicateOutcome.check_lower(value.predicates)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterTypeVerificationStatus.write(value.status, buf)
        _UniffiFfiConverterBoolean.write(value.stable, buf)
        _UniffiFfiConverterUInt64.write(value.elapsed_ms, buf)
        _UniffiFfiConverterUInt64.write(value.samples, buf)
        _UniffiFfiConverterSequenceTypePredicateOutcome.write(value.predicates, buf)






class VisualParseErrorCode(enum.Enum):
    """
    Stable machine-readable failures for capture lookup and visual parsing.
"""

    NOT_INSTALLED = 0

    CAPTURE_NOT_FOUND = 1

    CAPTURE_EXPIRED = 2

    CAPTURE_STALE = 3

    CAPTURE_GENERATION_MISMATCH = 4

    UNSUPPORTED_TARGET = 5

    UNSUPPORTED_PLATFORM = 6

    INCOMPATIBLE_PROTOCOL = 7

    INVALID_FRAME = 8

    WORKER_LAUNCH_FAILED = 9

    WORKER_CRASHED = 10

    WORKER_CANCELLED = 11

    TIMEOUT = 12

    RESOURCE_LIMIT_EXCEEDED = 13

    ARTIFACT_INVALID = 14

    INFERENCE_FAILED = 15



class _UniffiFfiConverterTypeVisualParseErrorCode(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return VisualParseErrorCode.NOT_INSTALLED
        if variant == 2:
            return VisualParseErrorCode.CAPTURE_NOT_FOUND
        if variant == 3:
            return VisualParseErrorCode.CAPTURE_EXPIRED
        if variant == 4:
            return VisualParseErrorCode.CAPTURE_STALE
        if variant == 5:
            return VisualParseErrorCode.CAPTURE_GENERATION_MISMATCH
        if variant == 6:
            return VisualParseErrorCode.UNSUPPORTED_TARGET
        if variant == 7:
            return VisualParseErrorCode.UNSUPPORTED_PLATFORM
        if variant == 8:
            return VisualParseErrorCode.INCOMPATIBLE_PROTOCOL
        if variant == 9:
            return VisualParseErrorCode.INVALID_FRAME
        if variant == 10:
            return VisualParseErrorCode.WORKER_LAUNCH_FAILED
        if variant == 11:
            return VisualParseErrorCode.WORKER_CRASHED
        if variant == 12:
            return VisualParseErrorCode.WORKER_CANCELLED
        if variant == 13:
            return VisualParseErrorCode.TIMEOUT
        if variant == 14:
            return VisualParseErrorCode.RESOURCE_LIMIT_EXCEEDED
        if variant == 15:
            return VisualParseErrorCode.ARTIFACT_INVALID
        if variant == 16:
            return VisualParseErrorCode.INFERENCE_FAILED
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == VisualParseErrorCode.NOT_INSTALLED:
            return
        if value == VisualParseErrorCode.CAPTURE_NOT_FOUND:
            return
        if value == VisualParseErrorCode.CAPTURE_EXPIRED:
            return
        if value == VisualParseErrorCode.CAPTURE_STALE:
            return
        if value == VisualParseErrorCode.CAPTURE_GENERATION_MISMATCH:
            return
        if value == VisualParseErrorCode.UNSUPPORTED_TARGET:
            return
        if value == VisualParseErrorCode.UNSUPPORTED_PLATFORM:
            return
        if value == VisualParseErrorCode.INCOMPATIBLE_PROTOCOL:
            return
        if value == VisualParseErrorCode.INVALID_FRAME:
            return
        if value == VisualParseErrorCode.WORKER_LAUNCH_FAILED:
            return
        if value == VisualParseErrorCode.WORKER_CRASHED:
            return
        if value == VisualParseErrorCode.WORKER_CANCELLED:
            return
        if value == VisualParseErrorCode.TIMEOUT:
            return
        if value == VisualParseErrorCode.RESOURCE_LIMIT_EXCEEDED:
            return
        if value == VisualParseErrorCode.ARTIFACT_INVALID:
            return
        if value == VisualParseErrorCode.INFERENCE_FAILED:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == VisualParseErrorCode.NOT_INSTALLED:
            buf.write_i32(1)
        if value == VisualParseErrorCode.CAPTURE_NOT_FOUND:
            buf.write_i32(2)
        if value == VisualParseErrorCode.CAPTURE_EXPIRED:
            buf.write_i32(3)
        if value == VisualParseErrorCode.CAPTURE_STALE:
            buf.write_i32(4)
        if value == VisualParseErrorCode.CAPTURE_GENERATION_MISMATCH:
            buf.write_i32(5)
        if value == VisualParseErrorCode.UNSUPPORTED_TARGET:
            buf.write_i32(6)
        if value == VisualParseErrorCode.UNSUPPORTED_PLATFORM:
            buf.write_i32(7)
        if value == VisualParseErrorCode.INCOMPATIBLE_PROTOCOL:
            buf.write_i32(8)
        if value == VisualParseErrorCode.INVALID_FRAME:
            buf.write_i32(9)
        if value == VisualParseErrorCode.WORKER_LAUNCH_FAILED:
            buf.write_i32(10)
        if value == VisualParseErrorCode.WORKER_CRASHED:
            buf.write_i32(11)
        if value == VisualParseErrorCode.WORKER_CANCELLED:
            buf.write_i32(12)
        if value == VisualParseErrorCode.TIMEOUT:
            buf.write_i32(13)
        if value == VisualParseErrorCode.RESOURCE_LIMIT_EXCEEDED:
            buf.write_i32(14)
        if value == VisualParseErrorCode.ARTIFACT_INVALID:
            buf.write_i32(15)
        if value == VisualParseErrorCode.INFERENCE_FAILED:
            buf.write_i32(16)



@dataclass
class VisualParseError:
    def __init__(self, *, code:VisualParseErrorCode, message:str, retryable:bool, detail:typing.Optional[str]):
        self.code = code
        self.message = message
        self.retryable = retryable
        self.detail = detail




    def __str__(self):
        return "VisualParseError(code={}, message={}, retryable={}, detail={})".format(self.code, self.message, self.retryable, self.detail)
    def __eq__(self, other):
        if self.code != other.code:
            return False
        if self.message != other.message:
            return False
        if self.retryable != other.retryable:
            return False
        if self.detail != other.detail:
            return False
        return True

class _UniffiFfiConverterTypeVisualParseError(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return VisualParseError(
            code=_UniffiFfiConverterTypeVisualParseErrorCode.read(buf),
            message=_UniffiFfiConverterString.read(buf),
            retryable=_UniffiFfiConverterBoolean.read(buf),
            detail=_UniffiFfiConverterOptionalString.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterTypeVisualParseErrorCode.check_lower(value.code)
        _UniffiFfiConverterString.check_lower(value.message)
        _UniffiFfiConverterBoolean.check_lower(value.retryable)
        _UniffiFfiConverterOptionalString.check_lower(value.detail)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterTypeVisualParseErrorCode.write(value.code, buf)
        _UniffiFfiConverterString.write(value.message, buf)
        _UniffiFfiConverterBoolean.write(value.retryable, buf)
        _UniffiFfiConverterOptionalString.write(value.detail, buf)

class _UniffiFfiConverterOptionalTypeElementFrame(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeElementFrame.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeElementFrame.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeElementFrame.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

@dataclass
class WindowElement:
    def __init__(self, *, element_index:int, role:str, depth:int, element_token:typing.Optional[str], label:typing.Optional[str], value:typing.Optional[str], value_description:typing.Optional[str], enabled:typing.Optional[bool], selected:typing.Optional[bool], in_web_content:typing.Optional[bool], actions:typing.Optional[typing.List[str]], parent_index:typing.Optional[int], frame:typing.Optional[ElementFrame], min:typing.Optional[float], max:typing.Optional[float]):
        self.element_index = element_index
        self.role = role
        self.depth = depth
        self.element_token = element_token
        self.label = label
        self.value = value
        self.value_description = value_description
        self.enabled = enabled
        self.selected = selected
        self.in_web_content = in_web_content
        self.actions = actions
        self.parent_index = parent_index
        self.frame = frame
        self.min = min
        self.max = max




    def __str__(self):
        return "WindowElement(element_index={}, role={}, depth={}, element_token={}, label={}, value={}, value_description={}, enabled={}, selected={}, in_web_content={}, actions={}, parent_index={}, frame={}, min={}, max={})".format(self.element_index, self.role, self.depth, self.element_token, self.label, self.value, self.value_description, self.enabled, self.selected, self.in_web_content, self.actions, self.parent_index, self.frame, self.min, self.max)
    def __eq__(self, other):
        if self.element_index != other.element_index:
            return False
        if self.role != other.role:
            return False
        if self.depth != other.depth:
            return False
        if self.element_token != other.element_token:
            return False
        if self.label != other.label:
            return False
        if self.value != other.value:
            return False
        if self.value_description != other.value_description:
            return False
        if self.enabled != other.enabled:
            return False
        if self.selected != other.selected:
            return False
        if self.in_web_content != other.in_web_content:
            return False
        if self.actions != other.actions:
            return False
        if self.parent_index != other.parent_index:
            return False
        if self.frame != other.frame:
            return False
        if self.min != other.min:
            return False
        if self.max != other.max:
            return False
        return True

class _UniffiFfiConverterTypeWindowElement(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return WindowElement(
            element_index=_UniffiFfiConverterUInt64.read(buf),
            role=_UniffiFfiConverterString.read(buf),
            depth=_UniffiFfiConverterUInt32.read(buf),
            element_token=_UniffiFfiConverterOptionalString.read(buf),
            label=_UniffiFfiConverterOptionalString.read(buf),
            value=_UniffiFfiConverterOptionalString.read(buf),
            value_description=_UniffiFfiConverterOptionalString.read(buf),
            enabled=_UniffiFfiConverterOptionalBoolean.read(buf),
            selected=_UniffiFfiConverterOptionalBoolean.read(buf),
            in_web_content=_UniffiFfiConverterOptionalBoolean.read(buf),
            actions=_UniffiFfiConverterOptionalSequenceString.read(buf),
            parent_index=_UniffiFfiConverterOptionalUInt64.read(buf),
            frame=_UniffiFfiConverterOptionalTypeElementFrame.read(buf),
            min=_UniffiFfiConverterOptionalFloat64.read(buf),
            max=_UniffiFfiConverterOptionalFloat64.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterUInt64.check_lower(value.element_index)
        _UniffiFfiConverterString.check_lower(value.role)
        _UniffiFfiConverterUInt32.check_lower(value.depth)
        _UniffiFfiConverterOptionalString.check_lower(value.element_token)
        _UniffiFfiConverterOptionalString.check_lower(value.label)
        _UniffiFfiConverterOptionalString.check_lower(value.value)
        _UniffiFfiConverterOptionalString.check_lower(value.value_description)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.enabled)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.selected)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.in_web_content)
        _UniffiFfiConverterOptionalSequenceString.check_lower(value.actions)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.parent_index)
        _UniffiFfiConverterOptionalTypeElementFrame.check_lower(value.frame)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.min)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.max)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterUInt64.write(value.element_index, buf)
        _UniffiFfiConverterString.write(value.role, buf)
        _UniffiFfiConverterUInt32.write(value.depth, buf)
        _UniffiFfiConverterOptionalString.write(value.element_token, buf)
        _UniffiFfiConverterOptionalString.write(value.label, buf)
        _UniffiFfiConverterOptionalString.write(value.value, buf)
        _UniffiFfiConverterOptionalString.write(value.value_description, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.enabled, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.selected, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.in_web_content, buf)
        _UniffiFfiConverterOptionalSequenceString.write(value.actions, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.parent_index, buf)
        _UniffiFfiConverterOptionalTypeElementFrame.write(value.frame, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.min, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.max, buf)

class _UniffiFfiConverterSequenceTypeWindowElement(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypeWindowElement.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypeWindowElement.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypeWindowElement.read(buf) for i in range(count)
        ]

class _UniffiFfiConverterOptionalSequenceTypeWindowElement(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterSequenceTypeWindowElement.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterSequenceTypeWindowElement.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterSequenceTypeWindowElement.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterOptionalTypeWindowBounds(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        if value is not None:
            _UniffiFfiConverterTypeWindowBounds.check_lower(value)

    @classmethod
    def write(cls, value, buf):
        if value is None:
            buf.write_u8(0)
            return

        buf.write_u8(1)
        _UniffiFfiConverterTypeWindowBounds.write(value, buf)

    @classmethod
    def read(cls, buf):
        flag = buf.read_u8()
        if flag == 0:
            return None
        elif flag == 1:
            return _UniffiFfiConverterTypeWindowBounds.read(buf)
        else:
            raise InternalError("Unexpected flag byte for optional type")

class _UniffiFfiConverterSequenceTypeSnapshotImage(_UniffiConverterRustBuffer):
    @classmethod
    def check_lower(cls, value):
        for item in value:
            _UniffiFfiConverterTypeSnapshotImage.check_lower(item)

    @classmethod
    def write(cls, value, buf):
        items = len(value)
        buf.write_i32(items)
        for item in value:
            _UniffiFfiConverterTypeSnapshotImage.write(item, buf)

    @classmethod
    def read(cls, buf):
        count = buf.read_i32()
        if count < 0:
            raise InternalError("Unexpected negative sequence length")

        return [
            _UniffiFfiConverterTypeSnapshotImage.read(buf) for i in range(count)
        ]

@dataclass
class WindowStateOutput:
    def __init__(self, *, pid:int, window_id:int, snapshot_id:typing.Optional[str], app_name:typing.Optional[str], window_title:typing.Optional[str], tree_markdown:typing.Optional[str], elements:typing.Optional[typing.List[WindowElement]], element_count:typing.Optional[int], total_element_count:typing.Optional[int], returned_element_count:typing.Optional[int], filtered_element_count:typing.Optional[int], elements_complete:typing.Optional[bool], degraded:typing.Optional[bool], degraded_reason:typing.Optional[str], truncated:typing.Optional[bool], truncation_reason:typing.Optional[str], truncation_hint:typing.Optional[str], tree_format:typing.Optional[str], since:typing.Optional[str], since_status:typing.Optional[str], tree_diff:typing.Optional[str], screenshot_width:typing.Optional[int], screenshot_height:typing.Optional[int], screenshot_scale:typing.Optional[float], screenshot_mime_type:typing.Optional[str], screenshot_file_path:typing.Optional[str], screenshot_frame_valid:typing.Optional[bool], window_bounds:typing.Optional[WindowBounds], images:typing.List[SnapshotImage]):
        self.pid = pid
        self.window_id = window_id
        self.snapshot_id = snapshot_id
        self.app_name = app_name
        self.window_title = window_title
        self.tree_markdown = tree_markdown
        self.elements = elements
        self.element_count = element_count
        self.total_element_count = total_element_count
        self.returned_element_count = returned_element_count
        self.filtered_element_count = filtered_element_count
        self.elements_complete = elements_complete
        self.degraded = degraded
        self.degraded_reason = degraded_reason
        self.truncated = truncated
        self.truncation_reason = truncation_reason
        self.truncation_hint = truncation_hint
        self.tree_format = tree_format
        self.since = since
        self.since_status = since_status
        self.tree_diff = tree_diff
        self.screenshot_width = screenshot_width
        self.screenshot_height = screenshot_height
        self.screenshot_scale = screenshot_scale
        self.screenshot_mime_type = screenshot_mime_type
        self.screenshot_file_path = screenshot_file_path
        self.screenshot_frame_valid = screenshot_frame_valid
        self.window_bounds = window_bounds
        self.images = images




    def __str__(self):
        return "WindowStateOutput(pid={}, window_id={}, snapshot_id={}, app_name={}, window_title={}, tree_markdown={}, elements={}, element_count={}, total_element_count={}, returned_element_count={}, filtered_element_count={}, elements_complete={}, degraded={}, degraded_reason={}, truncated={}, truncation_reason={}, truncation_hint={}, tree_format={}, since={}, since_status={}, tree_diff={}, screenshot_width={}, screenshot_height={}, screenshot_scale={}, screenshot_mime_type={}, screenshot_file_path={}, screenshot_frame_valid={}, window_bounds={}, images={})".format(self.pid, self.window_id, self.snapshot_id, self.app_name, self.window_title, self.tree_markdown, self.elements, self.element_count, self.total_element_count, self.returned_element_count, self.filtered_element_count, self.elements_complete, self.degraded, self.degraded_reason, self.truncated, self.truncation_reason, self.truncation_hint, self.tree_format, self.since, self.since_status, self.tree_diff, self.screenshot_width, self.screenshot_height, self.screenshot_scale, self.screenshot_mime_type, self.screenshot_file_path, self.screenshot_frame_valid, self.window_bounds, self.images)
    def __eq__(self, other):
        if self.pid != other.pid:
            return False
        if self.window_id != other.window_id:
            return False
        if self.snapshot_id != other.snapshot_id:
            return False
        if self.app_name != other.app_name:
            return False
        if self.window_title != other.window_title:
            return False
        if self.tree_markdown != other.tree_markdown:
            return False
        if self.elements != other.elements:
            return False
        if self.element_count != other.element_count:
            return False
        if self.total_element_count != other.total_element_count:
            return False
        if self.returned_element_count != other.returned_element_count:
            return False
        if self.filtered_element_count != other.filtered_element_count:
            return False
        if self.elements_complete != other.elements_complete:
            return False
        if self.degraded != other.degraded:
            return False
        if self.degraded_reason != other.degraded_reason:
            return False
        if self.truncated != other.truncated:
            return False
        if self.truncation_reason != other.truncation_reason:
            return False
        if self.truncation_hint != other.truncation_hint:
            return False
        if self.tree_format != other.tree_format:
            return False
        if self.since != other.since:
            return False
        if self.since_status != other.since_status:
            return False
        if self.tree_diff != other.tree_diff:
            return False
        if self.screenshot_width != other.screenshot_width:
            return False
        if self.screenshot_height != other.screenshot_height:
            return False
        if self.screenshot_scale != other.screenshot_scale:
            return False
        if self.screenshot_mime_type != other.screenshot_mime_type:
            return False
        if self.screenshot_file_path != other.screenshot_file_path:
            return False
        if self.screenshot_frame_valid != other.screenshot_frame_valid:
            return False
        if self.window_bounds != other.window_bounds:
            return False
        if self.images != other.images:
            return False
        return True

class _UniffiFfiConverterTypeWindowStateOutput(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        return WindowStateOutput(
            pid=_UniffiFfiConverterUInt32.read(buf),
            window_id=_UniffiFfiConverterUInt64.read(buf),
            snapshot_id=_UniffiFfiConverterOptionalString.read(buf),
            app_name=_UniffiFfiConverterOptionalString.read(buf),
            window_title=_UniffiFfiConverterOptionalString.read(buf),
            tree_markdown=_UniffiFfiConverterOptionalString.read(buf),
            elements=_UniffiFfiConverterOptionalSequenceTypeWindowElement.read(buf),
            element_count=_UniffiFfiConverterOptionalUInt64.read(buf),
            total_element_count=_UniffiFfiConverterOptionalUInt64.read(buf),
            returned_element_count=_UniffiFfiConverterOptionalUInt64.read(buf),
            filtered_element_count=_UniffiFfiConverterOptionalUInt64.read(buf),
            elements_complete=_UniffiFfiConverterOptionalBoolean.read(buf),
            degraded=_UniffiFfiConverterOptionalBoolean.read(buf),
            degraded_reason=_UniffiFfiConverterOptionalString.read(buf),
            truncated=_UniffiFfiConverterOptionalBoolean.read(buf),
            truncation_reason=_UniffiFfiConverterOptionalString.read(buf),
            truncation_hint=_UniffiFfiConverterOptionalString.read(buf),
            tree_format=_UniffiFfiConverterOptionalString.read(buf),
            since=_UniffiFfiConverterOptionalString.read(buf),
            since_status=_UniffiFfiConverterOptionalString.read(buf),
            tree_diff=_UniffiFfiConverterOptionalString.read(buf),
            screenshot_width=_UniffiFfiConverterOptionalUInt32.read(buf),
            screenshot_height=_UniffiFfiConverterOptionalUInt32.read(buf),
            screenshot_scale=_UniffiFfiConverterOptionalFloat64.read(buf),
            screenshot_mime_type=_UniffiFfiConverterOptionalString.read(buf),
            screenshot_file_path=_UniffiFfiConverterOptionalString.read(buf),
            screenshot_frame_valid=_UniffiFfiConverterOptionalBoolean.read(buf),
            window_bounds=_UniffiFfiConverterOptionalTypeWindowBounds.read(buf),
            images=_UniffiFfiConverterSequenceTypeSnapshotImage.read(buf),
        )

    @staticmethod
    def check_lower(value):
        _UniffiFfiConverterUInt32.check_lower(value.pid)
        _UniffiFfiConverterUInt64.check_lower(value.window_id)
        _UniffiFfiConverterOptionalString.check_lower(value.snapshot_id)
        _UniffiFfiConverterOptionalString.check_lower(value.app_name)
        _UniffiFfiConverterOptionalString.check_lower(value.window_title)
        _UniffiFfiConverterOptionalString.check_lower(value.tree_markdown)
        _UniffiFfiConverterOptionalSequenceTypeWindowElement.check_lower(value.elements)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.element_count)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.total_element_count)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.returned_element_count)
        _UniffiFfiConverterOptionalUInt64.check_lower(value.filtered_element_count)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.elements_complete)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.degraded)
        _UniffiFfiConverterOptionalString.check_lower(value.degraded_reason)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.truncated)
        _UniffiFfiConverterOptionalString.check_lower(value.truncation_reason)
        _UniffiFfiConverterOptionalString.check_lower(value.truncation_hint)
        _UniffiFfiConverterOptionalString.check_lower(value.tree_format)
        _UniffiFfiConverterOptionalString.check_lower(value.since)
        _UniffiFfiConverterOptionalString.check_lower(value.since_status)
        _UniffiFfiConverterOptionalString.check_lower(value.tree_diff)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.screenshot_width)
        _UniffiFfiConverterOptionalUInt32.check_lower(value.screenshot_height)
        _UniffiFfiConverterOptionalFloat64.check_lower(value.screenshot_scale)
        _UniffiFfiConverterOptionalString.check_lower(value.screenshot_mime_type)
        _UniffiFfiConverterOptionalString.check_lower(value.screenshot_file_path)
        _UniffiFfiConverterOptionalBoolean.check_lower(value.screenshot_frame_valid)
        _UniffiFfiConverterOptionalTypeWindowBounds.check_lower(value.window_bounds)
        _UniffiFfiConverterSequenceTypeSnapshotImage.check_lower(value.images)

    @staticmethod
    def write(value, buf):
        _UniffiFfiConverterUInt32.write(value.pid, buf)
        _UniffiFfiConverterUInt64.write(value.window_id, buf)
        _UniffiFfiConverterOptionalString.write(value.snapshot_id, buf)
        _UniffiFfiConverterOptionalString.write(value.app_name, buf)
        _UniffiFfiConverterOptionalString.write(value.window_title, buf)
        _UniffiFfiConverterOptionalString.write(value.tree_markdown, buf)
        _UniffiFfiConverterOptionalSequenceTypeWindowElement.write(value.elements, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.element_count, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.total_element_count, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.returned_element_count, buf)
        _UniffiFfiConverterOptionalUInt64.write(value.filtered_element_count, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.elements_complete, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.degraded, buf)
        _UniffiFfiConverterOptionalString.write(value.degraded_reason, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.truncated, buf)
        _UniffiFfiConverterOptionalString.write(value.truncation_reason, buf)
        _UniffiFfiConverterOptionalString.write(value.truncation_hint, buf)
        _UniffiFfiConverterOptionalString.write(value.tree_format, buf)
        _UniffiFfiConverterOptionalString.write(value.since, buf)
        _UniffiFfiConverterOptionalString.write(value.since_status, buf)
        _UniffiFfiConverterOptionalString.write(value.tree_diff, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.screenshot_width, buf)
        _UniffiFfiConverterOptionalUInt32.write(value.screenshot_height, buf)
        _UniffiFfiConverterOptionalFloat64.write(value.screenshot_scale, buf)
        _UniffiFfiConverterOptionalString.write(value.screenshot_mime_type, buf)
        _UniffiFfiConverterOptionalString.write(value.screenshot_file_path, buf)
        _UniffiFfiConverterOptionalBoolean.write(value.screenshot_frame_valid, buf)
        _UniffiFfiConverterOptionalTypeWindowBounds.write(value.window_bounds, buf)
        _UniffiFfiConverterSequenceTypeSnapshotImage.write(value.images, buf)






class Platform(enum.Enum):

    MACOS = 0

    WINDOWS = 1

    LINUX = 2



class _UniffiFfiConverterTypePlatform(_UniffiConverterRustBuffer):
    @staticmethod
    def read(buf):
        variant = buf.read_i32()
        if variant == 1:
            return Platform.MACOS
        if variant == 2:
            return Platform.WINDOWS
        if variant == 3:
            return Platform.LINUX
        raise InternalError("Raw enum value doesn't match any cases")

    @staticmethod
    def check_lower(value):
        if value == Platform.MACOS:
            return
        if value == Platform.WINDOWS:
            return
        if value == Platform.LINUX:
            return
        raise ValueError(value)

    @staticmethod
    def write(value, buf):
        if value == Platform.MACOS:
            buf.write_i32(1)
        if value == Platform.WINDOWS:
            buf.write_i32(2)
        if value == Platform.LINUX:
            buf.write_i32(3)



class _UniffiFfiConverterUInt8(_UniffiConverterPrimitiveInt):
    CLASS_NAME = "u8"
    VALUE_MIN = 0
    VALUE_MAX = 2**8

    @staticmethod
    def read(buf):
        return buf.read_u8()

    @staticmethod
    def write(value, buf):
        buf.write_u8(value)

__all__ = [
    "InternalError",
    "ActionDeliveryMode",
    "ActionEscalationTarget",
    "ActionEscalationReason",
    "ActionEvidenceKind",
    "ActionEffect",
    "ActionRoute",
    "ActionTarget",
    "ClickPosition",
    "InputDeliveryMode",
    "ClickButton",
    "CursorEffectSetting",
    "CursorMotionStyle",
    "CursorMotionTiming",
    "CursorReducedMotion",
    "CursorAction",
    "DesktopScope",
    "EscalationReason",
    "SessionLifecycleState",
    "SessionClientKindOutput",
    "SessionTransportOutput",
    "VisualRegionKind",
    "VisualCaptureSource",
    "VisualActionCoordinateSpace",
    "VerificationStatus",
    "UnknownReason",
    "ScrollDirection",
    "ScrollBy",
    "CaptureScope",
    "EffectiveScope",
    "VisualParseErrorCode",
    "Platform",
    "ActionDelivery",
    "ActionError",
    "ActionEscalation",
    "ActionEvidence",
    "ActionNextCall",
    "ActionResult",
    "AppInfo",
    "BoundsExpectation",
    "ClickInput",
    "ClipboardReadInput",
    "ClipboardReadOutput",
    "ClipboardWriteInput",
    "ClipboardWriteOutput",
    "CursorMotionEffects",
    "CursorMotionEffectsOutput",
    "CursorMotionOutput",
    "CursorMotionSelection",
    "CursorPointOutput",
    "CursorThemeOutput",
    "CursorThemeSelection",
    "CursorVisualOutput",
    "DragInput",
    "ElementFrame",
    "ElementSelector",
    "ElementPredicate",
    "EndSessionInput",
    "EndSessionOutput",
    "EscalateSessionInput",
    "GetAgentCursorStateInput",
    "GetAgentCursorStateOutput",
    "GetCursorPositionInput",
    "GetDesktopStateInput",
    "GetScreenSizeInput",
    "GetSessionInput",
    "GetSessionStateInput",
    "GetWindowStateInput",
    "HotkeyInput",
    "InvokeMenuInput",
    "ListAppsInput",
    "ListAppsOutput",
    "ListSessionsInput",
    "SessionOutput",
    "ListSessionsOutput",
    "ListWindowsInput",
    "WindowBounds",
    "WindowInfo",
    "ListWindowsOutput",
    "MoveCursorInput",
    "ParseVisualRegionsOptions",
    "ParseVisualRegionsInput",
    "VisualScreenshotReference",
    "VisualCaptureProvenance",
    "VisualParserMetadata",
    "VisualRegionBounds",
    "VisualRegion",
    "VisualParseWarning",
    "VisualParseTiming",
    "ParseVisualRegionsOutput",
    "PredicateOutcome",
    "PressKeyInput",
    "ScrollInput",
    "SessionStateOutput",
    "SetAgentCursorEnabledInput",
    "SetAgentCursorEnabledOutput",
    "SetAgentCursorMotionInput",
    "SetAgentCursorMotionOutput",
    "SetAgentCursorThemeInput",
    "SetAgentCursorThemeOutput",
    "SetWindowFrameInput",
    "SnapshotImage",
    "StartSessionInput",
    "StartSessionOutput",
    "WindowPredicate",
    "StatePredicate",
    "TypeTextInput",
    "VerifyStateInput",
    "VerifyStateOutput",
    "VisualParseError",
    "WindowElement",
    "WindowStateOutput",
]