Host, relay and devices

Unattended host setup, the cua-relay directory client, and this device's enrollment on the relay.

Set this machine up for unattended access, and reach account machines through the relay. Spaces.hosts lists your computers that provide Spaces (SpacesHost), with their limits and how busy each one is.

Host#

This machine as an unattended-access host.

MethodDescription
newHost state under cua_home (default $CUA_HOME or ~/.cua).
configureChanges what this machine shares: its own desktop, and whether it creates Spaces for your other devices (and their limits).
migrate_servicemacOS: moves the host service from the old LaunchAgent to the Cua Spaces app (its own login item, "Cua Spaces"), keeping this machine's registration, id and Spaces; puts the old one back if the helper does not take over (the outcome says so).
pause_signed_outPause relay sharing while nobody is signed in to the owner's account: the host leaves the relay and stays off it (also across a restart) with its setup kept.
removeUnregister, uninstall the service and delete the host state.
resume_signed_inResume relay sharing paused by Host.pause_signed_out once account (the signed-in account's id or email) is signed in; refused when it is not the machine's owner.
setupInstalls and starts the host service (relay mode needs account_token).
start_sharingStart sharing again.
statusCurrent state.
stop_sharingStop sharing (cut clients, refuse new ones).

Host.new#

Host state under cua_home (default $CUA_HOME or ~/.cua).

Host(cua_home: Optional[str])
ParameterTypeDefault
cua_homeOption<String>required

Returns Host

Host.configure#

Changes what this machine shares: its own desktop, and whether it creates Spaces for your other devices (and their limits). Turning the desktop on or off restarts the host service.

async def configure(self, change: HostSettingsChange) -> HostStatus
ParameterTypeDefault
changeHostSettingsChangerequired

Returns HostStatus · Async · Raises CuaError

Host.migrate_service#

macOS: moves the host service from the old LaunchAgent to the Cua Spaces app (its own login item, "Cua Spaces"), keeping this machine's registration, id and Spaces; puts the old one back if the helper does not take over (the outcome says so). app_version: a failed move is not tried again by itself with the same version; force tries anyway.

async def migrate_service(self, force: bool, app_version: str) -> HostServiceMigration
ParameterTypeDefault
forceboolrequired
app_versionStringrequired

Returns HostServiceMigration · Async · Raises CuaError

Host.pause_signed_out#

Pause relay sharing while nobody is signed in to the owner's account: the host leaves the relay and stays off it (also across a restart) with its setup kept. Direct mode is left alone.

async def pause_signed_out(self) -> HostStatus

Returns HostStatus · Async · Raises CuaError

Host.remove#

Unregister, uninstall the service and delete the host state.

async def remove(self) -> None

Async · Raises CuaError

Host.resume_signed_in#

Resume relay sharing paused by Host.pause_signed_out once account (the signed-in account's id or email) is signed in; refused when it is not the machine's owner.

async def resume_signed_in(self, account: str) -> HostStatus
ParameterTypeDefault
accountStringrequired

Returns HostStatus · Async · Raises CuaError

Host.setup#

Installs and starts the host service (relay mode needs account_token).

async def setup(self, options: HostSetupOptions, account_token: Optional[str]) -> HostStatus
ParameterTypeDefault
optionsHostSetupOptionsrequired
account_tokenOption<String>required

Returns HostStatus · Async · Raises CuaError

Host.start_sharing#

Start sharing again.

async def start_sharing(self) -> HostStatus

Returns HostStatus · Async · Raises CuaError

Host.status#

Current state.

async def status(self) -> HostStatus

Returns HostStatus · Async · Raises CuaError

Host.stop_sharing#

Stop sharing (cut clients, refuse new ones).

async def stop_sharing(self) -> HostStatus

Returns HostStatus · Async · Raises CuaError

Relay#

The signed-in account's view of a cua-relay.

MethodDescription
newA relay (None = the relay cua uses: CUA_RELAY_URL, else this machine's host setup, else https://relay.cua.ai) seen as the account behind account_token (a cua.ai access token).
connectConnects to a machine's spacesd through <relay>/m/<id>, with the account token as bearer (the relay swaps it for its signed identity).
machineOne machine.
machinesMachines the account owns or that are shared with it.
start_sharingAccepts clients again.
stop_sharingCuts every client of a machine the account owns and refuses new ones.
AccessorReturnsDescription
url()StringNormalized relay base URL.

Relay.new#

A relay (None = the relay cua uses: CUA_RELAY_URL, else this machine's host setup, else https://relay.cua.ai) seen as the account behind account_token (a cua.ai access token).

Relay(relay_url: Optional[str], account_token: str)
ParameterTypeDefault
relay_urlOption<String>required
account_tokenStringrequired

Returns Relay · Raises CuaError

Relay.connect#

Connects to a machine's spacesd through <relay>/m/<id>, with the account token as bearer (the relay swaps it for its signed identity).

async def connect(self, machine_id: str) -> SpacesdClient
ParameterTypeDefault
machine_idStringrequired

Returns SpacesdClient · Async · Raises CuaError

Relay.machine#

One machine.

async def machine(self, machine_id: str) -> RelayMachine
ParameterTypeDefault
machine_idStringrequired

Returns RelayMachine · Async · Raises CuaError

Relay.machines#

Machines the account owns or that are shared with it.

async def machines(self) -> List[RelayMachine]

Returns Vec<RelayMachine> · Async · Raises CuaError

Relay.start_sharing#

Accepts clients again.

async def start_sharing(self, machine_id: str) -> RelayMachine
ParameterTypeDefault
machine_idStringrequired

Returns RelayMachine · Async · Raises CuaError

Relay.stop_sharing#

Cuts every client of a machine the account owns and refuses new ones.

async def stop_sharing(self, machine_id: str) -> RelayMachine
ParameterTypeDefault
machine_idStringrequired

Returns RelayMachine · Async · Raises CuaError

SpacesHost record#

One of your machines that provides Spaces (Spaces.hosts).

Returned by Spaces.hosts.

FieldTypeDefaultDescription
idStringWhat on="host:<id>" takes: the relay machine id, or the name a direct host was added as.
nameStringIts name.
viaStringrelay or direct.
onlineboolIt answered.
osStringIts operating system (macos, linux, windows), when it answered.
limitsVec<SpacesHostLimit>Its limits, when it answered.
loadOption<SpacesHostLoad>How busy it is, when it answered and reports it.

SpacesHostLimit record#

One limit of a host that provides Spaces and how much of it is used.

FieldTypeDefaultDescription
resourceStringspaces (every Space it provides) or macos_vms.
usedu32In use now.
limitu32The limit (0: none).
reasonStringWhy the limit exists, for people.

SpacesHostLoad record#

How busy one of your machines is (its job runner's view).

FieldTypeDefaultDescription
millicpus_total / millicpusTotalu32CPU it offers, in thousandths.
millicpus_free / millicpusFreeu32Of that, free.
memory_total_mb / memoryTotalMbu64Memory it offers (MiB).
memory_free_mb / memoryFreeMbu64Of that, free.
spacesu32Spaces running there.
problemStringWhy it takes nothing now (empty: it does).
kindsVec<String>The kinds it creates (container, vm, microvm), as it reports them; empty when it does not say.

HostAccessRecord record#

One access to this machine.

FieldTypeDefaultDescription
at_ms / atMsi64Epoch ms.
viaStringrelay, viewer or token.
whoStringWho.
whatStringWhat they used (a service name, or MCP).

HostPermission record#

A macOS privacy pane the user must grant.

FieldTypeDefaultDescription
idStringscreen-recording or accessibility.
titleStringTitle.
settings_url / settingsUrlStringx-apple.systempreferences: URL.
instructionsStringInstructions.

HostProvidedSpace record#

A Space this machine provides to one of your devices.

FieldTypeDefaultDescription
relay_machine / relayMachineStringThe relay machine it is reached as (relay:<machine>).
local_space / localSpaceStringThe Space on this machine (local:<name>).
nameStringDisplay name.
imageStringThe image, as requested.
osStringlinux, macos (empty when unknown).
kindStringcontainer or vm.
created_by / createdByStringWho created it.
created_at_ms / createdAtMsi64Epoch ms.

HostServiceMigration record#

What Host.migrate_service did.

Returned by Host.migrate_service.

FieldTypeDefaultDescription
outcomeStringmigrated, switched, cleaned-up, rolled-back, kept or not-needed.
detailStringIn words.
permissions_needed / permissionsNeededboolmacOS will ask for Screen Recording and Accessibility for Cua Spaces Helper.

HostSettingsChange record#

A change to this machine's Spaces settings (None keeps a value).

FieldTypeDefaultDescription
share_desktop / shareDesktopOption<bool>NoneShare this desktop.
provide_spaces / provideSpacesOption<bool>NoneProvide Spaces.
max_spaces / maxSpacesOption<u32>NoneProvided Spaces at once (0: no limit).
max_macos_vms / maxMacosVmsOption<u32>NonemacOS VMs at once (0 to 2, Apple's license).
max_memory_gb / maxMemoryGbOption<u32>NoneMemory the provided Spaces may use in total, in GB (0: no limit).
max_disk_gb / maxDiskGbOption<u32>NoneDisk the provided Spaces may use in total, in GB (0: no limit).
max_run_minutes / maxRunMinutesOption<u32>NoneHow long a provided Space may run, in minutes (0: no limit).

HostSetupOptions record#

cua host setup options.

FieldTypeDefaultDescription
modeOption<String>relay (default) or direct.
relay_url / relayUrlOption<String>Relay URL (relay mode; default CUA_RELAY_URL / https://relay.cua.ai).
directOption<String>ip:port (direct mode; default 0.0.0.0:3211).
nameOption<String>Display name (default: host name).
allowVec<String>Accounts (ids or emails) allowed besides the owner.
driver_bin / driverBinOption<String>Driver binary (else CUA_SPACESD_BIN, bundled, or download).
runnerOption<String>auto, systemd, launchd, windows-task or process.
profileOption<String>Nonedesktop (share this desktop; the default) or spare (do not share the desktop; provide Spaces). The two settings below override it.
share_desktop / shareDesktopOption<bool>NoneShare this machine's own desktop as a Space.
provide_spaces / provideSpacesOption<bool>NoneCreate Spaces for your enrolled devices on this machine (relay mode). None: on for a machine set up for the first time through the relay; a machine set up before keeps its setting.

HostSpacesAuditRecord record#

One line of this machine's Spaces audit (remote creates, deletes, refusals and settings changes).

FieldTypeDefaultDescription
at_ms / atMsi64Epoch ms.
actionStringcreate, delete, refused, failed or config.
whoStringWho (an account, or local).
spaceStringThe relay machine or Space.
detailStringDetail.

HostStatus record#

Host status.

Returned by Host.configure, Host.pause_signed_out, Host.resume_signed_in, Host.setup, Host.start_sharing, Host.status, Host.stop_sharing.

FieldTypeDefaultDescription
configuredboolSet up.
modeOption<String>relay or direct.
relay_url / relayUrlOption<String>Relay URL.
direct_url / directUrlOption<String>Direct URL.
env_token_path / envTokenPathOption<String>Env token file (direct mode).
machine_id / machineIdOption<String>Machine id.
nameOption<String>Name.
sharingboolAccepting clients.
service_installed / serviceInstalledboolService installed.
service_running / serviceRunningboolService running.
service_kind / serviceKindStringRunner kind.
onlineOption<bool>Online at the relay.
clientsVec<RelayClientInfo>Connected clients.
allowVec<String>Allowlist.
permissionsVec<HostPermission>Permission panes (macOS).
errorOption<String>Relay error.
recent_access / recentAccessVec<HostAccessRecord>[]Who reached this machine recently, newest first (the driver's hash-chained access log).
access_log_error / accessLogErrorOption<String>NoneSet when the access log does not verify (edited or truncated).
share_desktop / shareDesktopbooltrueThis machine's desktop is a Space.
provide_spaces / provideSpacesboolfalseThis machine provides Spaces to your other devices.
max_spaces / maxSpacesu320Provided Spaces at once (0: no limit).
max_macos_vms / maxMacosVmsu320macOS VMs at once (at most two).
max_memory_gb / maxMemoryGbu320Memory the provided Spaces may use in total, in GB (0: no limit).
max_disk_gb / maxDiskGbu320Disk the provided Spaces may use in total, in GB (0: no limit).
max_run_minutes / maxRunMinutesu320How long a provided Space may run, in minutes (0: no limit).
used_memory_gb / usedMemoryGbu320What the provided Spaces were given now, in GB.
used_disk_gb / usedDiskGbu320
total_memory_gb / totalMemoryGbu320This machine's own memory and disk, in GB (0: not known).
total_disk_gb / totalDiskGbu320
provided_spaces / providedSpacesVec<HostProvidedSpace>[]The Spaces this machine provides now.
spaces_audit / spacesAuditVec<HostSpacesAuditRecord>[]The Spaces audit, newest first.
spaces_audit_error / spacesAuditErrorOption<String>NoneSet when the Spaces audit does not verify.
paused_signed_out / pausedSignedOutboolfalseRelay sharing is paused until the owner signs in again (Host.pause_signed_out).
ownerOption<String>NoneThe account this machine is registered to (relay mode): its id.
owner_email / ownerEmailOption<String>NoneThe owner's email, when the relay gave one.
helper_available / helperAvailableboolfalsemacOS: a Cua Spaces app that can run the host service is installed, so the host service can run as it.
legacy_service / legacyServiceboolfalsemacOS: the old hand-written LaunchAgent is still there.

PairingCode record#

A one-time code that adds a machine to the account ("Add a machine" by link or QR code).

Returned by Devices.create_pairing_code, Devices.pairing_codes.

FieldTypeDefaultDescription
idStringpc_… (to revoke it).
codeOption<String>XXXX-XXXX-XXXX: only when just made.
urlOption<String>https://cua.ai/add/<code> (the link and the QR code): only when just made.
install_sh / installShOption<String>curl … | sh -s -- --pair <code> (macOS, Linux): only when just made.
install_powershell / installPowershellOption<String>The PowerShell one-liner (Windows): only when just made.
stateStringactive, used, revoked or expired.
teamOption<String>Team the machine is added for.
created_at / createdAtu64Unix seconds.
expires_at / expiresAtu64Unix seconds.
used_at / usedAtOption<u64>When a machine used it.
machineOption<String>The machine it added (relay machine id).

RelayClientInfo record#

Somebody connected to a machine through the relay.

FieldTypeDefaultDescription
idStringUser id.
emailOption<String>Email, when shared by the identity provider.
nameOption<String>Display name.
streamsu32Open streams.
sinceu64Unix seconds of the first open stream.

RelayMachine record#

A machine of the account's relay directory (relay:<id>).

Returned by Devices.confirm_machine, Devices.rename_machine, Relay.machine, Relay.machines, Relay.start_sharing, Relay.stop_sharing.

FieldTypeDefaultDescription
idStringMachine id.
space_id / spaceIdStringrelay:<id>.
nameStringDisplay name.
owner_id / ownerIdStringOwner account id.
owner_email / ownerEmailOption<String>Owner email.
roleStringowner or shared.
onlineboolConnected to the relay.
sharingboolAccepting clients.
versionStringspacesd version.
urlString<relay>/m/<id>.
allowVec<String>Allowlist (owner view only).
clientsVec<RelayClientInfo>Connected clients.
confirmedboolRegistered with an enrolled device's signature or MFA, or confirmed since from one; true for anything a relay registered before this check existed. false shows the machine as "new" until an enrolled device confirms it (Devices.confirm_machine) (S5).
teamOption<String>The team you reach it through, for a team machine not shared with you directly.
provides_spaces / providesSpacesOption<bool>It creates Spaces for its owner's devices, when it said so at registration (None from a host or relay that predates it).

This device on the relay#

auth.devices(relay_url, name) returns this device on the relay, its key in the session's credential store (shared with the cua CLI and daemon). A device lists and reaches the account's machines once enrolled: right after a fresh sign-in (a sign-in through Auth.begin_login re-registers a device that already has a key), or by a one-time code approved from an enrolled device (cua devices approve). A new key of the same machine replaces its old record. Enrollment lasts 30 days, then one approval or a fresh sign-in re-verifies it. Nothing here prompts; gate approve behind presence in your UI.

Devices#

This device as a client of the signed-in account on a relay: its enrollment, the account's other devices and its audit log. The device key lives in the session's vault (shared with the cua CLI and daemon). Nothing here prompts: approving is the caller's to gate behind presence.

Returned by Auth.devices.

MethodDescription
approveApproves the device showing code, or re-verifies device_id, from this enrolled device.
check_enrolledWhether the relay lets this device open a session now (enrolled), asked afresh.
confirm_machineVouches for machine_id, a machine that registered without an enrolled device's signature or MFA (from this enrolled device) (S5).
create_pairing_codeMakes a one-time code (link, QR, install commands) that adds another computer to the account, or to team (from this enrolled device).
device_idThis device's id, when it has a key (no network).
enrollRegisters this device (creating its key on first use).
pairing_codesThe account's pairing codes, newest first (without the codes).
renameRenames a device (from this enrolled device).
rename_machineRenames machine_id, a machine the account owns, on the relay (from this enrolled device).
revokeRevokes a device (from this enrolled device).
revoke_pairing_codeRevokes an unused pairing code (pc_…).
snapshotThe account's devices, the grace period, the newest audit_limit audit events and the machines' names.
resolve_default_spaceWhere the default Space resolves now: the first online entry of the default, the fallback order, then this computer (its own relay machine id, when it has one).
set_spaces_settingsReplaces the account's default Space settings (the whole object; updated_at is set by the relay).
spaces_settingsThe account's default Space and fallback order.
AccessorReturnsDescription
relay_url()StringThe relay base URL.

Devices.approve#

Approves the device showing code, or re-verifies device_id, from this enrolled device.

async def approve(self, code: Optional[str], device_id: Optional[str]) -> RelayDevice
ParameterTypeDefault
codeOption<String>required
device_idOption<String>required

Returns RelayDevice · Async · Raises CuaError

Devices.check_enrolled#

Whether the relay lets this device open a session now (enrolled), asked afresh. Polled while waiting for an approval.

async def check_enrolled(self) -> bool

Returns bool · Async

Devices.confirm_machine#

Vouches for machine_id, a machine that registered without an enrolled device's signature or MFA (from this enrolled device) (S5). Clears RelayMachine.confirmed's "new" flag for every account member, not just this device.

async def confirm_machine(self, machine_id: str) -> RelayMachine
ParameterTypeDefault
machine_idStringrequired

Returns RelayMachine · Async · Raises CuaError

Devices.create_pairing_code#

Makes a one-time code (link, QR, install commands) that adds another computer to the account, or to team (from this enrolled device). It expires after ttl_secs (30 minutes when None).

async def create_pairing_code(self, team: Optional[str], ttl_secs: Optional[int]) -> PairingCode
ParameterTypeDefault
teamOption<String>required
ttl_secsOption<u64>required

Returns PairingCode · Async · Raises CuaError

Devices.device_id#

This device's id, when it has a key (no network).

def device_id(self) -> Optional[str]

Returns Option<String> · Raises CuaError

Devices.enroll#

Registers this device (creating its key on first use). Right after a fresh sign-in it is enrolled at once (replacing this machine's older device key, if any); otherwise the result carries a one-time code to approve from an enrolled device.

async def enroll(self) -> DeviceEnrollment

Returns DeviceEnrollment · Async · Raises CuaError

Devices.pairing_codes#

The account's pairing codes, newest first (without the codes).

async def pairing_codes(self) -> List[PairingCode]

Returns Vec<PairingCode> · Async · Raises CuaError

Devices.rename#

Renames a device (from this enrolled device).

async def rename(self, id: str, name: str) -> RelayDevice
ParameterTypeDefault
idStringrequired
nameStringrequired

Returns RelayDevice · Async · Raises CuaError

Devices.rename_machine#

Renames machine_id, a machine the account owns, on the relay (from this enrolled device). When it is this machine's own registration, its host setup takes the new name too.

async def rename_machine(self, machine_id: str, name: str) -> RelayMachine
ParameterTypeDefault
machine_idStringrequired
nameStringrequired

Returns RelayMachine · Async · Raises CuaError

Devices.revoke#

Revokes a device (from this enrolled device). Revoking this device also deletes its key.

async def revoke(self, id: str) -> RelayDevice
ParameterTypeDefault
idStringrequired

Returns RelayDevice · Async · Raises CuaError

Devices.revoke_pairing_code#

Revokes an unused pairing code (pc_…).

async def revoke_pairing_code(self, id: str) -> None
ParameterTypeDefault
idStringrequired

Async · Raises CuaError

Devices.snapshot#

The account's devices, the grace period, the newest audit_limit audit events and the machines' names. Only the device list must succeed; the rest is empty when the relay refuses it.

async def snapshot(self, audit_limit: int) -> DevicesSnapshot
ParameterTypeDefault
audit_limitu32required

Returns DevicesSnapshot · Async · Raises CuaError

DevicesSnapshot record#

Everything the Devices page reads, in one call.

Returned by Devices.snapshot.

FieldTypeDefaultDescription
local_device_id / localDeviceIdOption<String>This device's id, when it has a key.
devicesVec<RelayDevice>The account's devices (this one marked current once enrolled).
enforce_after / enforceAfterOption<u64>End of the relay's grace period for unenrolled devices.
auditVec<RelayAuditEvent>The account's audit log, newest last (empty when the relay refuses).
machine_names / machineNamesHashMap<String, String>Machine ids to names (empty when this device cannot list them).
machinesVec<RelayMachine>The account's relay machines, RelayMachine.confirmed included (S5; empty when this device cannot list them, same as machine_names).

RelayDevice record#

A client device of the account, as the relay lists it.

Returned by Devices.approve, Devices.rename, Devices.revoke.

FieldTypeDefaultDescription
idStringdev_….
nameStringDisplay name.
stateStringpending, enrolled, expired or revoked.
platformStringOperating system it reported (macos, windows, linux); empty when unknown.
created_at / createdAtu64Registered at (Unix seconds).
enrolled_until / enrolledUntilOption<u64>Re-verification due at (Unix seconds).
last_seen / lastSeenOption<u64>Last session (Unix seconds).
currentboolThis device.

RelayAuditEvent record#

One event of the account's audit log.

FieldTypeDefaultDescription
tsu64Unix seconds.
kindStringKind (machine_access, device_enrolled, share_added, ...).
deviceOption<String>Acting device.
machineOption<String>Machine id.
subjectOption<String>Other party.
detailOption<String>Detail.

DeviceEnrollment record#

Devices.enroll's result.

Returned by Devices.enroll.

FieldTypeDefaultDescription
deviceRelayDeviceThis device.
enrolledboolEnrolled now (right after a fresh sign-in).
codeOption<String>The one-time code to approve from an enrolled device otherwise.

Computer health#

Spaces.machine_health asks a computer's cua daemon to check it (this computer with None, another of yours by id or name over the relay, the mesh or its direct address). The Computers page shows the warnings and failures as the computer's issues; cua doctor --machine prints them.

Check a computer#

Methods of Spaces.

Spaces.machine_health#

A machine's health as its own cua daemon checks it: Local Network access (and which app macOS holds responsible), free disk, virtualization, memory left by running Spaces, the permissions sharing its desktop needs. machine: another of your machines, by id or name (asked over the relay, the mesh or its direct address); None for this one. Read-only; fails plainly when that machine is offline, not yours, or runs a Cua that predates the check.

async def machine_health(self, machine: Optional[str]) -> MachineHealth
ParameterTypeDefault
machineOption<String>required

Returns MachineHealth · Async · Raises CuaError

MachineHealth record#

A machine's health as its own cua daemon checks it.

Returned by Spaces.machine_health.

FieldTypeDefaultDescription
cua_version / cuaVersionStringThe Cua version of the daemon that checked.
osStringmacos, linux, windows.
checksVec<MachineHealthCheck>Every check, in order.
report_json / reportJsonStringThe whole report as JSON (the schema cua doctor --json writes).

MachineHealthCheck record#

One check of a machine's health (Spaces.machine_health).

FieldTypeDefaultDescription
idStringmachine.local_network, machine.disk, machine.virtualization, machine.memory, machine.permissions.<id>.
statusStringpass, warn, fail or skip.
messageStringWhat it found, in one line.
remediationStringWhat to do about a warning or failure.
factsHashMap<String, String>What a UI needs to word it and offer its fix (app, settings_url, free_gb, ...).