Auth and telemetry
Sign-in, the credential store the SDK, the CLI and the daemon share, and the telemetry switches.
cua.auth() signs in and reads the shared session. Cloud calls use it when no client credentials are configured.
Python programs usually use the high-level API instead: cua_sandbox.configure().
Auth#
Sign-in and the shared session.
Returned by Cua.auth.
| Method | Description |
|---|---|
access_token | A valid access token (refreshed when it expires within a minute, or when force). |
begin_login | Starts a sign-in. |
devices | This device on relay_url (None = the relay cua uses: CUA_RELAY_URL, else this machine's host setup, else https://relay.cua.ai) as the signed-in account, shown as name (default: this computer's name). |
logout | Revokes (best effort) and removes the session, and unlinks usage data from the account. |
status | The stored session (no network). |
Auth.access_token#
A valid access token (refreshed when it expires within a minute, or
when force). Unauthenticated when not signed in.
async def access_token(self, force: bool) -> str| Parameter | Type | Default |
|---|---|---|
force | bool | required |
Returns String · Async · Raises CuaError (Unauthenticated)
Auth.begin_login#
Starts a sign-in. flow: auto (default: browser, else device
code), browser or device.
async def begin_login(self, flow: Optional[str]) -> LoginAttempt| Parameter | Type | Default |
|---|---|---|
flow | Option<String> | required |
Returns LoginAttempt · Async · Raises CuaError
Auth.devices#
This device on relay_url (None = the relay cua uses:
CUA_RELAY_URL, else this machine's host setup, else
https://relay.cua.ai) as the signed-in account, shown as name
(default: this computer's name).
def devices(self, relay_url: Optional[str], name: Optional[str]) -> Devices| Parameter | Type | Default |
|---|---|---|
relay_url | Option<String> | required |
name | Option<String> | required |
Returns Devices · Raises CuaError
Auth.logout#
Revokes (best effort) and removes the session, and unlinks usage data from the account. Returns whether one existed.
async def logout(self) -> boolReturns bool · Async · Raises CuaError
Auth.status#
The stored session (no network).
def status(self) -> AuthStatusReturns AuthStatus · Raises CuaError
LoginAttempt#
A started sign-in. Show url (and user_code), then await wait().
Returned by Auth.begin_login.
| Method | Description |
|---|---|
wait | Waits for the user, stores the session and returns who signed in. |
| Accessor | Returns | Description |
|---|---|---|
method() | LoginMethod | Browser or device. |
note() | Option<String> | Why a device code is used although browser sign-in was asked for. |
url() | String | The URL to open. |
user_code() | Option<String> | Device flow: the code to enter. |
LoginAttempt.wait#
Waits for the user, stores the session and returns who signed in. Only the first call waits; later calls fail.
This device then registers with the relay (the one cua uses:
CUA_RELAY_URL, else this machine's host setup, else relay.cua.ai),
creating its device key on first use, so the fresh sign-in enrolls
or re-verifies it without an approval. That step is best effort and
never fails the sign-in.
async def wait(self) -> AuthIdentityReturns AuthIdentity · Async · Raises CuaError
AuthIdentity record#
Who is signed in (from token claims; display only).
Returned by LoginAttempt.wait.
| Field | Type | Default | Description |
|---|---|---|---|
username | Option<String> | preferred_username. | |
email | Option<String> | email. | |
name | Option<String> | name. | |
subject | Option<String> | sub. | |
display | Option<String> | One display string (email, else username, else subject). |
AuthStatus record#
The stored session, read without network access.
Returned by Auth.status.
| Field | Type | Default | Description |
|---|---|---|---|
logged_in / loggedIn | bool | A session is stored. | |
identity | Option<AuthIdentity> | Who. | |
expires_at / expiresAt | Option<String> | RFC 3339 expiry of the current access token (it refreshes itself). | |
store | String | Where credentials live. |
LoginMethod enum#
How a sign-in proceeds.
LoginMethod.BROWSER
LoginMethod.DEVICE| Variant | Description |
|---|---|
Browser | Open url in a browser on this machine; it redirects back here. |
Device | Open url on any device and enter user_code. |
may_have_session#
Whether a cua auth login session may be stored, decided without
reading the OS credential vault (the non-secret session marker, or the
file store's file). Implicit callers (the default sandbox listing) check
this before reading the session; an explicit read of a session stored
before markers existed writes the marker.
def may_have_session() -> boolReturns bool
Telemetry#
What is collected and never collected: Telemetry and privacy. These calls read and change the same switches as cua telemetry; the SDK records its own events.
telemetry_status#
Telemetry state, and exactly what every event carries.
def telemetry_status() -> TelemetryStatusReturns TelemetryStatus
telemetry_set_enabled#
Turns usage telemetry on or off for this machine ($CUA_HOME/config.toml,
the same switch as cua telemetry off and the Spaces app setting). The
environment (DO_NOT_TRACK, CUA_TELEMETRY) still wins.
def telemetry_set_enabled(enabled: bool) -> TelemetryStatus| Parameter | Type | Default |
|---|---|---|
enabled | bool | required |
Returns TelemetryStatus · Raises CuaError
telemetry_show_last#
The last limit events queued or sent from this machine, exactly as
sent, as JSON ([{status, payload}]).
def telemetry_show_last(limit: int) -> str| Parameter | Type | Default |
|---|---|---|
limit | u32 | required |
Returns String
telemetry_schema_json#
Every event and property that may be sent, as JSON.
def telemetry_schema_json() -> strReturns String
telemetry_reset_id#
Deletes the anonymous install id and its salt.
def telemetry_reset_id() -> NoneRaises CuaError
StreamStatsReport record#
One stream session's aggregate stats (sampled).
| Field | Type | Default | Description |
|---|---|---|---|
transport | String | quic, webrtc, websocket or grpc. | |
codec | String | h264, hevc, av1, vp8, vp9, jpeg or png. | |
hw_decode / hwDecode | Option<bool> | Hardware decode (None: not decoded here). | |
avg_fps / avgFps | f64 | ||
p95_latency_ms / p95LatencyMs | Option<f64> | p95 input-to-present or control round trip, ms. | |
height | u32 | Stream height in pixels. | |
duration_ms / durationMs | u64 |
TelemetryLinkNotice record#
The one-time notice for machines that saw the older "anonymous" wording, shown before anything is linked to the account. Both buttons close it; the second also turns usage data off.
Returned by telemetry_link_notice.
| Field | Type | Default | Description |
|---|---|---|---|
title | String | ||
body | String | ||
ok_label / okLabel | String | Keeps usage data on ("Got it"). | |
turn_off_label / turnOffLabel | String | Turns usage data off ("Turn off usage data"). | |
details_label / detailsLabel | String | The link to what is collected. | |
docs_url / docsUrl | String |
TelemetryStatus record#
Telemetry state.
Returned by telemetry_set_enabled, telemetry_status.
| Field | Type | Default | Description |
|---|---|---|---|
enabled | bool | Usage events may be sent. | |
source | String | Why (env CUA_TELEMETRY, env DO_NOT_TRACK, config <path>, CI environment ..., default). | |
source_kind / sourceKind | String | do_not_track, env, legacy_env, config, ci or default. | |
is_ci / isCi | bool | Running in CI. | |
install_id / installId | Option<String> | The first 8 characters of the anonymous install id, if one exists. | |
notice_shown / noticeShown | bool | The first-run notice was shown on this machine. | |
endpoint | String | Where batches go. | |
product | String | Which Cua program events are attributed to. | |
envelope_json / envelopeJson | String | The exact properties every event carries, as JSON. |
telemetry_acknowledge_link_notice#
The person closed the linking notice (either button). Linking starts with the app's next launch, never in the process that showed it.
def telemetry_acknowledge_link_notice() -> Nonetelemetry_acknowledge_notice#
Records that the first-run notice was shown in the app's UI (nothing is
sent from a machine before that). Apps that show the notice themselves
call telemetry_use_app_notice first so the SDK does not print it.
def telemetry_acknowledge_notice() -> Nonetelemetry_flush#
Sends queued events now, waiting at most timeout_ms; anything left
is kept on disk for a later process.
def telemetry_flush(timeout_ms: int) -> None| Parameter | Type | Default |
|---|---|---|
timeout_ms | u32 | required |
telemetry_link_notice#
The one-time linking notice's words.
def telemetry_link_notice() -> TelemetryLinkNoticeReturns TelemetryLinkNotice
telemetry_link_notice_due#
Whether the app should show the one-time linking notice now: usage data is on, the account offered linking, and this machine has not shown it.
def telemetry_link_notice_due() -> boolReturns bool
telemetry_link_state#
Where linking stands: off, not_offered, notice_due or linked.
def telemetry_link_state() -> strReturns String
telemetry_notice_text#
The first-run notice text (an app shows it in its own UI, then calls
telemetry_acknowledge_notice).
def telemetry_notice_text() -> strReturns String
telemetry_record_bench_run#
Records a finished cua-bench run: the taskset (catalog name, else
custom), the aggregate success rate (0 to 1, bucketed), the task count
(bucketed) and the outcome (ok, error, cancelled).
def telemetry_record_bench_run(taskset: str, success_rate: Optional[float], task_count: int, outcome: str) -> bool| Parameter | Type | Default |
|---|---|---|
taskset | String | required |
success_rate | Option<f64> | required |
task_count | u64 | required |
outcome | String | required |
Returns bool
telemetry_record_feature#
Records use of a Spaces app feature (fixed names: space_create_local,
teleport_drop, ... see the docs). Returns whether it was queued;
unknown names are dropped.
def telemetry_record_feature(feature: str) -> bool| Parameter | Type | Default |
|---|---|---|
feature | String | required |
Returns bool
telemetry_record_onboarding_step#
Records an install or onboarding funnel step (fixed names:
onboarding_shown, signed_in, first_space_created, ...; first_*
steps count once per install). Returns whether it was queued.
def telemetry_record_onboarding_step(step: str, ok: bool) -> bool| Parameter | Type | Default |
|---|---|---|
step | String | required |
ok | bool | required |
Returns bool
telemetry_record_stream_stats#
Records one stream session's aggregate stats (bucketed and sampled).
def telemetry_record_stream_stats(stats: StreamStatsReport) -> bool| Parameter | Type | Default |
|---|---|---|
stats | StreamStatsReport | required |
Returns bool
telemetry_set_surface#
Names the SDK surface events are attributed to. Bindings call it at
import: sdk_python, sdk_typescript, sdk_swift, sdk_kotlin;
apps pass their own product (spaces_app). Unknown names are ignored.
def telemetry_set_surface(surface: str, version: str) -> None| Parameter | Type | Default |
|---|---|---|
surface | String | required |
version | String | required |
telemetry_sync_account#
Asks the Spaces API for the signed-in account's opaque id and hands it to telemetry (none unlinks). Call at launch and after a sign-in; the SDK's own sign-in already does. Returns the link state. Best effort: offline or signed out, nothing changes.
async def telemetry_sync_account() -> strReturns String · Async
telemetry_use_app_notice#
The host app shows the first-run notice itself (no stderr notice).
def telemetry_use_app_notice() -> None