Shares

Links to a port, a file or a folder that open on your other signed-in devices.

Cua.share(target, access, ttl_seconds, name) makes a link the cua daemon owns and serves, shares lists them, stop_share and stop_all_shares end them and check_share opens a link once as its owner. share_tcp makes a public TCP address for a port in a Space (the tcp-shares experiment); approve_share, deny_share, share_settings, set_share_settings and remove_share_edge manage it. See Share a link to anything you run.

Share methods#

Methods of Cua.

Cua.share#

Shares target and returns a link that opens on the owner's other signed-in devices, never a localhost link: a port ("3000"), a port in a Space ("space:dev:3000"), or a file or folder ("./report.html", read-only; relative paths resolve against this process's directory). access defaults to private; a public share lasts one hour unless ttl_seconds (60 to 86400) says otherwise. The cua daemon owns the share, so it keeps working after this process exits.

async def share(self, target: str, access: Optional[ShareAccess] = None, ttl_seconds: Optional[int] = None, name: Optional[str] = None) -> Share
ParameterTypeDefault
targetStringrequired
accessOption<ShareAccess>None
ttl_secondsOption<u32>None
nameOption<String>None

Returns Share · Async · Raises CuaError

Cua.shares#

The active shares, newest first.

async def shares(self) -> List[Share]

Returns Vec<Share> · Async · Raises CuaError

Cua.stop_share#

Stops a share (its id or its name). The link stops working at once. Returns the ids stopped.

async def stop_share(self, id: str) -> List[str]
ParameterTypeDefault
idStringrequired

Returns Vec<String> · Async · Raises CuaError

Cua.stop_all_shares#

Stops every share. Returns the ids stopped.

async def stop_all_shares(self) -> List[str]

Returns Vec<String> · Async · Raises CuaError

Cua.check_share#

Opens a share's link once, as its owner, so a link is known to work before it is handed to anyone. path is below the link.

async def check_share(self, id: str, path: Optional[str] = None) -> ShareCheck
ParameterTypeDefault
idStringrequired
pathOption<String>None

Returns ShareCheck · Async · Raises CuaError

Cua.share_tcp#

Shares a raw TCP service in a Space (a game server, for example) at a public address anyone can connect to, and returns it (tcp_connect_with). target is a port in a Space ("space:mc:25565"); inside a Space, a bare port ("25565") is its own. service ("minecraft") adds a name people can type instead of the address. Lasts 24 hours unless ttl_seconds (60 to 86400) says less. It reaches only that one port of that Space; admin and remote-access ports are refused. An experiment (Public TCP shares), off unless turned on.

route is auto (default: the Space's own host in your cloud, else a share edge in your linked cloud, else Cua's relay), host, edge or relay. allow limits who may connect (CIDRs). check_host (Minecraft) drops connections that did not dial this address. consent agrees to a share edge's cost now; without it the first share through a new edge comes back waiting until approve_share.

async def share_tcp(self, target: str, service: Optional[str] = None, ttl_seconds: Optional[int] = None, name: Optional[str] = None, route: Optional[str] = None, allow: Optional[List[str]] = None, check_host: bool = False, consent: bool = False) -> Share
ParameterTypeDefault
targetStringrequired
serviceOption<String>None
ttl_secondsOption<u32>None
nameOption<String>None
routeOption<String>None
allowOption<Vec<String>>None
check_hostboolfalse
consentboolfalse

Returns Share · Async · Raises CuaError

Cua.approve_share#

Lets a waiting share go live (an agent's public share, or the first through a share edge). always: its Space may share without asking from now on.

async def approve_share(self, id: str, always: bool = False) -> Share
ParameterTypeDefault
idStringrequired
alwaysboolfalse

Returns Share · Async · Raises CuaError

Cua.deny_share#

Turns down a waiting share.

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

Async · Raises CuaError

Cua.share_settings#

The share settings, with today's data and the share edge.

async def share_settings(self) -> ShareSettings

Returns ShareSettings · Async · Raises CuaError

Cua.set_share_settings#

Saves the share settings (the read-only fields are ignored).

async def set_share_settings(self, settings: ShareSettings) -> ShareSettings
ParameterTypeDefault
settingsShareSettingsrequired

Returns ShareSettings · Async · Raises CuaError

Cua.remove_share_edge#

Removes the share edge from your cloud now. Returns the ids of the shares that ended with it.

async def remove_share_edge(self) -> List[str]

Returns Vec<String> · Async · Raises CuaError

Share record#

One share.

Returned by Cua.approve_share, Cua.share, Cua.share_tcp, Cua.shares.

FieldTypeDefaultDescription
idStringHandle for Shares.stop (share-...).
urlStringThe link.
nameOption<String>Name for lists.
accessShareAccessWho may open it.
kindStringport, space_port, file or dir.
targetStringWhat it serves (port 3000, space:dev:3000, a path).
ownerStringThe account that made it.
created_at_unix / createdAtUnixOption<i64>When it was made (unix seconds).
expires_at_unix / expiresAtUnixOption<i64>When it ends (unix seconds); none: until stopped.
noticesVec<String>Limits of this link worth showing next to it (for example that browsers cannot open it yet).
tcp_connect_with / tcpConnectWithOption<String>A public TCP share: what people connect to (a name they can type, or host:port). None: an HTTP link.
tcp_address / tcpAddressOption<String>A public TCP share: its host:port.
routeOption<String>A public TCP share: how people reach it, host (the Space's own host in your cloud), edge (a share edge in your cloud) or relay (Cua).
route_line / routeLineOption<String>The plain line for that route ("Through your AWS account").
allowVec<String>Who may connect (CIDRs); empty: anyone.
waitingOption<String>Set while the share waits for its owner: approval or consent.
waiting_text / waitingTextOption<String>What to show the owner while it waits.

ShareAccess enum#

Who may open a share.

ShareAccess.PRIVATE
ShareAccess.TEAM
ShareAccess.PUBLIC
VariantDescription
PrivateOnly the owner's cua.ai account, on any of the owner's devices.
TeamMembers of the owner's team.
PublicAnyone with the link, until it expires or is stopped.

ShareCheck record#

What opening a link once returned.

Returned by Cua.check_share.

FieldTypeDefaultDescription
okbool2xx.
statusu32HTTP status (0: the link could not be opened).
viaStringlink (the real link, through the relay, as the owner) or local.
detailStringA short human line.

ShareLanding enum#

Where public TCP shares land.

ShareLanding.AUTO
ShareLanding.ONLY_MY_CLOUD
ShareLanding.ALLOW_RELAY
VariantDescription
AutoThe Space's own cloud host, else a share edge, else Cua's relay.
OnlyMyCloudOnly through your own clouds.
AllowRelayCua's relay unless the Space runs on its own cloud host.

ShareSettings record#

The share settings.

Returned by Cua.set_share_settings, Cua.share_settings.

FieldTypeDefaultDescription
landingShareLandingWhere public TCP shares land.
relay_fallback / relayFallbackboolWhether Cua's relay may carry public TCP shares at all.
daily_cap_mib / dailyCapMibu64The most data public TCP shares move in a day, in MiB (0: no cap).
default_allow / defaultAllowVec<String>The allowlist new shares start with (CIDRs; empty: anyone).
approve_agent_shares / approveAgentSharesboolAsk before an agent's share goes public.
always_allow_spaces / alwaysAllowSpacesVec<String>Spaces whose agents may share without asking.
edge_consent / edgeConsentVec<String>Clouds you agreed may hold a share edge.
used_today / usedTodayu64Bytes public TCP shares moved today (read only).
edge_cloud / edgeCloudOption<String>The share edge's cloud and host, when there is one (read only).
edge_host / edgeHostOption<String>The share edge's address (read only).
edge_monthly_usd / edgeMonthlyUsdOption<f64>About what the edge costs a month, in US dollars (read only).