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| Parameter | Type | Default |
|---|---|---|
target | String | required |
access | Option<ShareAccess> | None |
ttl_seconds | Option<u32> | None |
name | Option<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]| Parameter | Type | Default |
|---|---|---|
id | String | required |
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| Parameter | Type | Default |
|---|---|---|
id | String | required |
path | Option<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| Parameter | Type | Default |
|---|---|---|
target | String | required |
service | Option<String> | None |
ttl_seconds | Option<u32> | None |
name | Option<String> | None |
route | Option<String> | None |
allow | Option<Vec<String>> | None |
check_host | bool | false |
consent | bool | false |
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| Parameter | Type | Default |
|---|---|---|
id | String | required |
always | bool | false |
Returns Share · Async · Raises CuaError
Cua.deny_share#
Turns down a waiting share.
async def deny_share(self, id: str) -> None| Parameter | Type | Default |
|---|---|---|
id | String | required |
Async · Raises CuaError
Cua.share_settings#
The share settings, with today's data and the share edge.
async def share_settings(self) -> ShareSettingsReturns 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| Parameter | Type | Default |
|---|---|---|
settings | ShareSettings | required |
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.
| Field | Type | Default | Description |
|---|---|---|---|
id | String | Handle for Shares.stop (share-...). | |
url | String | The link. | |
name | Option<String> | Name for lists. | |
access | ShareAccess | Who may open it. | |
kind | String | port, space_port, file or dir. | |
target | String | What it serves (port 3000, space:dev:3000, a path). | |
owner | String | The account that made it. | |
created_at_unix / createdAtUnix | Option<i64> | When it was made (unix seconds). | |
expires_at_unix / expiresAtUnix | Option<i64> | When it ends (unix seconds); none: until stopped. | |
notices | Vec<String> | Limits of this link worth showing next to it (for example that browsers cannot open it yet). | |
tcp_connect_with / tcpConnectWith | Option<String> | A public TCP share: what people connect to (a name they can type, or host:port). None: an HTTP link. | |
tcp_address / tcpAddress | Option<String> | A public TCP share: its host:port. | |
route | Option<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 / routeLine | Option<String> | The plain line for that route ("Through your AWS account"). | |
allow | Vec<String> | Who may connect (CIDRs); empty: anyone. | |
waiting | Option<String> | Set while the share waits for its owner: approval or consent. | |
waiting_text / waitingText | Option<String> | What to show the owner while it waits. |
ShareAccess enum#
Who may open a share.
ShareAccess.PRIVATE
ShareAccess.TEAM
ShareAccess.PUBLIC| Variant | Description |
|---|---|
Private | Only the owner's cua.ai account, on any of the owner's devices. |
Team | Members of the owner's team. |
Public | Anyone with the link, until it expires or is stopped. |
ShareCheck record#
What opening a link once returned.
Returned by Cua.check_share.
| Field | Type | Default | Description |
|---|---|---|---|
ok | bool | 2xx. | |
status | u32 | HTTP status (0: the link could not be opened). | |
via | String | link (the real link, through the relay, as the owner) or local. | |
detail | String | A short human line. |
ShareLanding enum#
Where public TCP shares land.
ShareLanding.AUTO
ShareLanding.ONLY_MY_CLOUD
ShareLanding.ALLOW_RELAY| Variant | Description |
|---|---|
Auto | The Space's own cloud host, else a share edge, else Cua's relay. |
OnlyMyCloud | Only through your own clouds. |
AllowRelay | Cua'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.
| Field | Type | Default | Description |
|---|---|---|---|
landing | ShareLanding | Where public TCP shares land. | |
relay_fallback / relayFallback | bool | Whether Cua's relay may carry public TCP shares at all. | |
daily_cap_mib / dailyCapMib | u64 | The most data public TCP shares move in a day, in MiB (0: no cap). | |
default_allow / defaultAllow | Vec<String> | The allowlist new shares start with (CIDRs; empty: anyone). | |
approve_agent_shares / approveAgentShares | bool | Ask before an agent's share goes public. | |
always_allow_spaces / alwaysAllowSpaces | Vec<String> | Spaces whose agents may share without asking. | |
edge_consent / edgeConsent | Vec<String> | Clouds you agreed may hold a share edge. | |
used_today / usedToday | u64 | Bytes public TCP shares moved today (read only). | |
edge_cloud / edgeCloud | Option<String> | The share edge's cloud and host, when there is one (read only). | |
edge_host / edgeHost | Option<String> | The share edge's address (read only). | |
edge_monthly_usd / edgeMonthlyUsd | Option<f64> | About what the edge costs a month, in US dollars (read only). |