Spaces
The Spaces registry: create, add, resolve, delete and remove Spaces.
The Spaces registry: create, add, resolve, delete and remove Spaces.
cua.spaces() returns the Spaces registry. Create a Space where on says (local or cloud), or add an existing machine by URL, then open a Space.
Spaces#The Spaces registry: add a machine by URL, claim a Fleet Space,
provision a local one, and get Space handles.
Returned by Cua.spaces.
| Method | Description |
|---|---|
add | Adds a Space by URL (http(s)://host:port, host:port, or a Space id such as local:<name>) after a GetCapabilities handshake. |
add_with_service | Spaces.add, naming the service a plain MCP endpoint is registered under (default mcp). |
call_tool_json | Calls any Spaces MCP tool with JSON arguments (the implementation cua daemon mcp serves). |
cancel_create | Cancels a create that is still running: space is the create's create_id, the id the Space will have (local:<name>, carried by every progress report) or its name. |
create | Creates a Space where options.on says (the user default when unset): a new sandbox registered as a Space. |
create_with_progress | Spaces.create, reporting what it does to listener (pulling the image, booting, waiting for cua-spacesd, connecting) until the Space is ready. |
delete | Deletes a Space's sandbox and forgets it (a Space added by address is only forgotten). |
gpu_support | The GPU options each runtime of on (local by default, or cloud) offers on this host: Lume's "GPU acceleration" for macOS VMs (experimental, Apple silicon), QEMU's virgl and containers' NVIDIA GPUs on Linux. |
hosts | Your machines that provide Spaces (the account's relay hosts, then the hosts added by their Tailscale or LAN address), each asked for its limits: what create takes as on="host:<id>". |
list | Registered Spaces. |
list_tools_json | The Spaces MCP tools/list result as JSON (the contract). |
relay_register | Publishes space on the cua.ai relay as a machine of the signed-in account, the way cua host setup publishes this computer: the Space's own driver dials out, so the account's other devices (a phone off this network) reach it as relay:<machine>, and nobody else until it is shared. |
relay_unregister | Takes space off the relay (its driver leaves; every share goes). |
remove | Unregisters a Space (the sandbox is not touched). |
resolve | Resolves an id, legacy id, URL or display name. |
space | A connected handle to a registered Space. |
start | Turns a Space on again: resumes a suspended one, boots a stopped one (a Space one of your machines provides joins the relay again), and leaves a running one as it is. |
stop | Turns a Space off the way its provider can (SpaceInfo.power): suspends it, keeping its memory (a local container or QEMU VM), or stops it, keeping its disk (a local Lume VM; a Space one of your machines provides, which that machine stops). |
agent_capabilities | What every agent harness is and cannot do (agent_capabilities), as JSON. |
agent_pause | Pauses a persistent agent: run, routines and (local) Space. |
agent_resume | Resumes a paused persistent agent; with prompt, starts a run. |
cloud_connect | Connects a cloud account (after the checks cloud_test runs). |
cloud_disconnect | Forgets a connected cloud (nothing in it is deleted). |
cloud_status | Your clouds: found credentials, the connected account and region, what each can run at what hourly cost, and what Cua created there. |
cloud_sweep | What Cua left in your clouds (expired Spaces, resources whose Space is gone; with all, everything Cua created there). |
cloud_test | Checks a cloud account without creating anything. |
computer_access | Per-agent computer grants (of one agent, or all). |
computer_access_grant | Lets one persistent agent use one of the user's computers (asks for presence). |
computer_access_revoke | Takes a persistent agent's computer access back (every machine when machine is empty). |
notifications | The notifications feed, newest first. |
notifications_ack | Marks notifications read (every one when ids is empty). |
notify_user | Posts a notification to the Cua app. |
persistent_agent_create | Creates a persistent agent: harness working in space, its home at agents/<name>/ in the Cua Volume. |
persistent_agent_remove | Forgets a persistent agent (its home stays in the drive). |
persistent_agent_save | Saves a persistent agent's home into the drive now. |
persistent_agent_send | Gives a persistent agent a turn: a follow-up to its idle run, or a new run with its home restored. |
persistent_agents | Every persistent agent. |
routine_add | Adds a routine. |
routine_remove | Deletes a routine. |
routine_set_enabled | Turns a routine on or off. |
routines | Routines (of one agent, or all). |
volume_approve | volume_approve: the request becomes a grant (with presence). |
volume_audit | volume_audit: the newest events (default 50) and whether the log verified. |
volume_cache_clear | volume_cache_clear: drops every cached block. |
volume_cache_set | volume_cache_set: the cache's size cap (at least 256 MiB). |
volume_cache_stats | volume_cache_stats: the block cache's size, cap and hit rate. |
volume_delete | volume_delete: a delete marker (history stays). |
volume_deny | volume_deny. |
volume_grant | volume_grant: widens principal's access (agent:<name> or space:<id>, mode r or rw). |
volume_grants | volume_grants: live grants (every grant with all). |
volume_history | volume_history: a file's versions, newest first. |
volume_ls | volume_ls: a folder's immediate children (default the root). |
volume_mount | volume_mount: turns the mount on (kept across restarts) and mounts. |
volume_mount_status | volume_mount_status: whether the drive is mounted as a volume. |
volume_read | volume_read: a file (or one of its versions). |
volume_request_access | volume_request_access: agent asks the user for more access. |
volume_requests | volume_requests: requests waiting for the user. |
volume_restore | volume_restore: makes an old version current again. |
volume_revoke | volume_revoke. |
volume_storage | volume_storage: where the drive keeps its bytes. |
volume_storage_set | volume_storage_set: tests, and unless dry_run saves and switches to, a storage backend (live, no restart). |
volume_sync_events | volume_sync_events: events after since_seq, waiting up to wait_ms (at most 30000) for one. |
volume_sync_resolve | volume_sync_resolve: clears a conflict from the list (files stay). |
volume_sync_status | volume_sync_status: devices, pending uploads and conflicts. |
volume_unmount | volume_unmount: turns the mount off; pending uploads land first. |
volume_write | volume_write: a new version of a file. |
Spaces.add#Adds a Space by URL (http(s)://host:port, host:port, or a
Space id such as local:<name>) after a GetCapabilities handshake. Any other MCP
endpoint (http://host:8765/mcp) becomes a Space with one MCP
service, mcp, and no spacesd capabilities.
async def add(self, url: str, token: Optional[str], name: Optional[str]) -> SpaceInfo| Parameter | Type | Default |
|---|---|---|
url | String | required |
token | Option<String> | required |
name | Option<String> | required |
Returns SpaceInfo · Async · Raises CuaError
Example
import asyncio
import cua
async def main():
spaces = cua.embedded().spaces()
info = await spaces.add("http://10.0.0.5:3211", "TOKEN", "lab") # a machine running cua-spacesd
space = await spaces.space(info.id)
out = await space.bash("echo hi", None)
print([info.provider, out.stdout, out.exit_code])
asyncio.run(main())Spaces.add_with_service#Spaces.add, naming the service a plain MCP endpoint is
registered under (default mcp).
async def add_with_service(self, url: str, token: Optional[str], name: Optional[str], service: Optional[str]) -> SpaceInfo| Parameter | Type | Default |
|---|---|---|
url | String | required |
token | Option<String> | required |
name | Option<String> | required |
service | Option<String> | required |
Returns SpaceInfo · Async · Raises CuaError
Spaces.call_tool_json#Calls any Spaces MCP tool with JSON arguments (the implementation
cua daemon mcp serves). Tool errors are returned, not raised.
async def call_tool_json(self, tool: str, arguments_json: Optional[str]) -> SpaceToolResult| Parameter | Type | Default |
|---|---|---|
tool | String | required |
arguments_json | Option<String> | required |
Returns SpaceToolResult · Async · Raises CuaError
Spaces.cancel_create#Cancels a create that is still running: space is the create's
create_id, the id the Space will have (local:<name>, carried by
every progress report) or its name. The work in flight stops (an
image download, a boot, a claim, a relay registration) and what the
create made is removed (its VM or container and disks, its cloud
claim, its relay machine); nothing that existed before is touched.
Finished image downloads stay cached, so the next create resumes.
Returns once the clean-up is done; the create itself fails with
Cancelled. Idempotent: a second call says not_creating. Works
for a create another process runs, and one a daemon restart cut off.
async def cancel_create(self, space: str) -> SpaceCancelOutcome| Parameter | Type | Default |
|---|---|---|
space | String | required |
Returns SpaceCancelOutcome · Async · Raises CuaError (Cancelled)
Spaces.create#Creates a Space where options.on says (the user default when
unset): a new sandbox registered as a Space. An existing machine is
added with Spaces.add.
async def create(self, options: SpaceCreateOptions) -> SpaceCreateResult| Parameter | Type | Default |
|---|---|---|
options | SpaceCreateOptions | required |
Returns SpaceCreateResult · Async · Raises CuaError
Spaces.create_with_progress#Spaces.create, reporting what it does to listener (pulling
the image, booting, waiting for cua-spacesd, connecting) until the
Space is ready. Always waits (options.wait is ignored). Through a
daemon that predates progress, the listener hears only ready.
async def create_with_progress(self, options: SpaceCreateOptions, listener: SpaceCreateListener) -> SpaceCreateResult| Parameter | Type | Default |
|---|---|---|
options | SpaceCreateOptions | required |
listener | SpaceCreateListener | required |
Returns SpaceCreateResult · Async · Raises CuaError
Spaces.delete#Deletes a Space's sandbox and forgets it (a Space added by address is only forgotten). Returns what happened.
async def delete(self, space: str) -> str| Parameter | Type | Default |
|---|---|---|
space | String | required |
Returns String · Async · Raises CuaError
Spaces.gpu_support#The GPU options each runtime of on (local by default, or
cloud) offers on this host: Lume's "GPU acceleration" for macOS
VMs (experimental, Apple silicon), QEMU's virgl and containers'
NVIDIA GPUs on Linux. A runtime with no option says why.
async def gpu_support(self, on: Optional[str]) -> List[GpuSupport]| Parameter | Type | Default |
|---|---|---|
on | Option<String> | required |
Returns Vec<GpuSupport> · Async · Raises CuaError
Spaces.hosts#Your machines that provide Spaces (the account's relay hosts, then
the hosts added by their Tailscale or LAN address), each asked for
its limits: what create takes as on="host:<id>". One that does
not answer is listed offline when it provided a Space before.
async def hosts(self) -> List[SpacesHost]Returns Vec<SpacesHost> · Async · Raises CuaError
Spaces.list#Registered Spaces.
async def list(self) -> List[SpaceInfo]Returns Vec<SpaceInfo> · Async · Raises CuaError
Spaces.list_tools_json#The Spaces MCP tools/list result as JSON (the contract).
async def list_tools_json(self) -> strReturns String · Async · Raises CuaError
Spaces.relay_register#Publishes space on the cua.ai relay as a machine of the signed-in
account, the way cua host setup publishes this computer: the
Space's own driver dials out, so the account's other devices (a
phone off this network) reach it as relay:<machine>, and nobody
else until it is shared. Idempotent.
async def relay_register(self, space: str) -> SpaceRelayRegistration| Parameter | Type | Default |
|---|---|---|
space | String | required |
Returns SpaceRelayRegistration · Async · Raises CuaError
Spaces.relay_unregister#Takes space off the relay (its driver leaves; every share goes).
Returns false when it was not on the relay.
async def relay_unregister(self, space: str) -> bool| Parameter | Type | Default |
|---|---|---|
space | String | required |
Returns bool · Async · Raises CuaError
Spaces.remove#Unregisters a Space (the sandbox is not touched).
async def remove(self, space: str) -> None| Parameter | Type | Default |
|---|---|---|
space | String | required |
Async · Raises CuaError
Spaces.resolve#Resolves an id, legacy id, URL or display name.
async def resolve(self, space: str) -> SpaceInfo| Parameter | Type | Default |
|---|---|---|
space | String | required |
Returns SpaceInfo · Async · Raises CuaError
Spaces.space#A connected handle to a registered Space.
async def space(self, space: str) -> Space| Parameter | Type | Default |
|---|---|---|
space | String | required |
Returns Space · Async · Raises CuaError
Spaces.start#Turns a Space on again: resumes a suspended one, boots a stopped one (a Space one of your machines provides joins the relay again), and leaves a running one as it is. Returns once it answers (bounded).
async def start(self, space: str) -> SpacePowerReport| Parameter | Type | Default |
|---|---|---|
space | String | required |
Returns SpacePowerReport · Async · Raises CuaError
Spaces.stop#Turns a Space off the way its provider can (SpaceInfo.power):
suspends it, keeping its memory (a local container or QEMU VM), or
stops it, keeping its disk (a local Lume VM; a Space one of your
machines provides, which that machine stops). A cloud Space, a Space
added by address and your own computers cannot be turned off.
async def stop(self, space: str) -> SpacePowerReport| Parameter | Type | Default |
|---|---|---|
space | String | required |
Returns SpacePowerReport · Async · Raises CuaError
SpaceInfo record#A registered Space.
Returned by Space.info, Spaces.add, Spaces.add_with_service, Spaces.list, Spaces.resolve.
| Field | Type | Default | Description |
|---|---|---|---|
id | String | Id, for example direct:10.0.0.5:3211 or cloud:<name> (the sandbox ref scheme). | |
name | String | Display name. | |
provider | String | cloud, local, direct or relay (the location words). | |
spacesd_version / spacesdVersion | String | spacesd version at the last handshake. | |
features | Vec<String> | Supported features at the last handshake. | |
os | String | Guest OS family at the last handshake: linux, macos, windows, or empty when not reported. | |
os_name / osName | String | Guest OS product or distribution at the last handshake ("Ubuntu", "macOS"), or empty when not reported. | |
os_pretty_name / osPrettyName | String | The guest's full OS string at the last handshake ("Ubuntu 24.04.3 LTS", "macOS 26.5.2 (25F84)"), or empty from older drivers. | |
image | String | The image the sandbox runs ("ghcr.io/trycua/linux:24.04"), or empty when unknown (a Space added by address). | |
image_digest / imageDigest | String | The digest of the variant that runs ("sha256:..."), or empty. | |
kind | String | container or vm, or empty when unknown. | |
arch | String | The guest's CPU architecture (arm64, amd64), or empty when unknown. | |
services | Vec<String> | Declared services (never env), reachable with list_tools / call_tool (service). A Space without cua-spacesd has an empty features list and only these. | |
added_at / addedAt | Option<String> | When it was added (RFC 3339). | |
host | String | For a Space one of your machines provides (created with on="host:<machine>"): that host's relay machine id; empty otherwise. Lists group these Spaces under their host. | |
host_name / hostName | String | The host's display name, when known. | |
power | String | How it turns off and on again (Spaces.stop, Spaces.start): suspend (its memory is kept), stop (its disk is kept), or empty when it cannot (a cloud Space, a Space added by address). | |
power_state / powerState | String | running, suspended or stopped as cua last recorded it; empty when unknown (a Space one of your machines provides answers while it runs). | |
cloud | String | A Space in your own cloud: the provider (aws, gcp, modal); empty otherwise. | |
cloud_place / cloudPlace | String | Where it runs ("AWS · us-west-2"). | |
cloud_delete / cloudDelete | String | How delete would delete it permanently from here: here (this device created it), host:<machine> (the device that created it, through the relay) or elsewhere (only there; remove keeps it). Empty for other Spaces. |
SpacePowerReport record#What Spaces.stop or Spaces.start did.
Returned by Spaces.start, Spaces.stop.
| Field | Type | Default | Description |
|---|---|---|---|
space | String | The Space. | |
state | String | running, suspended or stopped: the state it is in now. | |
power | String | How it turns off: suspend (its memory is kept) or stop (its disk is kept). | |
message | String | What happened, for people. |
spaces_tool_methods#Which SDK method covers each Spaces contract tool. Language test suites check every listed method exists on the generated class.
def spaces_tool_methods() -> List[SpacesToolMethod]Returns Vec<SpacesToolMethod>
SpacesToolMethod record#One row of SPACES_TOOL_METHODS.
Returned by spaces_tool_methods.
| Field | Type | Default | Description |
|---|---|---|---|
tool | String | Contract tool name. | |
method | String | Class.method (Rust / Python spelling; camelCase in TS, Swift and Kotlin). |