The relay server for aux4/remote: a websocket hub that lets machines register under a name and lets callers run commands on them (aux4 remote <machine> <cmd...>), without either side opening an inbound port. Authentication is aux4 SSO — every connection presents its aux4 access token, validated against /userinfo, and machine names are scoped per aux4 account. It is a plain aux4/api package (config.ws) with no cloud-specific code or .aux4 metadata, so the exact same package runs three ways:
aux4 aux4 cloud-remote server start (a long-lived aux4/api process).aux4 aux4 cloud deploy), where aux4/api runs eachwebsocket event as its own Lambda invocation behind API Gateway v2 — there is no local port at all.
aux4/api websocket server can run.aux4 aux4 pkger install aux4/cloud-remote
# server-config.yaml
config:
relay:
port: 8420
aux4 aux4 cloud-remote server start --configFile server-config.yaml --config relay --scope aux4
Machines then connect with aux4 aux4 remote connect and callers run commands with aux4 remote <machine> <cmd...> — both from the aux4/remote package, both authenticated with the caller's own aux4 login. See that package's README for the full client-side flow.
The package ships its own config.yaml with the config.ws route already wired, so a plain deploy carries the websocket route with no extra configuration:
aux4 aux4 cloud deploy aux4/cloud-remote --scope <your-scope>
The deploy's build detects config.ws in this package's config.yaml and builds it as an api-type (API Gateway + Lambda) machine automatically — package/.aux4 carries no cloud-specific field or deploy metadata at all; the plain package is what makes it deployable. --server start/stop are not used on a cloud deploy — the platform starts aux4 api start for you per the api-type runtime contract.
Once deployed, the relay is reachable at the stable websocket URL wss://<scope>.<domain>/<vm-name> (e.g. wss://aux4.aux4.cloud/cloud-remote), regardless of which underlying Lambda instance ends up handling a given connection or message. A machine connects with aux4 aux4 remote connect --server wss://<scope>.<domain>/<vm-name> ..., and a caller targets the same URL with aux4 remote <machine> <cmd...> --server wss://<scope>.<domain>/<vm-name>.
If you are deploying to a non-production SSO environment, set AUX4_SSO_URL (e.g. https://dev.sso.aux4.io) as an environment variable on the deployed machine — see Environment Variables below.
config:
relay:
port: 8420 # default: 8420 (local mode only)
There is no machine/token map to configure — every connection authenticates with its own aux4 access token.
$connect, $disconnect, the default route) is wired in this package's ownconfig.yaml, pointing at internal aux4 aux4 cloud-remote hook connect|disconnect|message commands (hidden from --help). Routing through the installed aux4 CLI rather than a baked-in binary path means the exact same config works locally and inside a cloud VM image, wherever the package ends up installed.
/userinfo endpoint(AUX4_SSO_URL, default https://sso.aux4.io) whenever the relay needs to know who it belongs to. A named machine (one that sent X-Machine-Name at $connect) is validated once at $connect and its sub/email recorded as that connection's principal; an invalid or expired token gets the connection dropped immediately. A caller (no machine name) is stateless on the relay instead: it re-sends the same bearer token in the body of every hello/exec/list message it sends, and the relay re-validates it (and derives the principal from it) on each one, rather than looking the caller up by connectionId. Either way, results are cached briefly (60s, keyed by a hash of the token — never the token itself) so a client that reconnects, or a caller that sends several messages, does not hit SSO every time.
AUX4_CLOUD_SCOPE on a clouddeploy (set automatically by the platform from the deployment's own scope), or --scope on a local server start. At $connect, after the token itself is validated, the relay checks that the principal's own token carries that scope in its scopes claim; a principal who is not a member is dropped immediately, same as an invalid token. This applies to a named machine and a bare caller alike — both connect through the same $connect route. Fails closed: if the relay's own scope is not configured, every connection is denied rather than the relay running open to any valid aux4 user.
list/exec request isalways authorized against the principal its own message's token resolves to — never anything else the message claims — so one aux4 account can never see or run commands on another account's machines, even on the same relay. Every exec dispatch records which connection it actually went to and which connection must receive the reply; a machine's output/exit reply is only routed onward when the connection sending it is the exact connection that exec was dispatched to, and always goes to the recorded caller — never to a connectionId the reply merely claims to be for. This means one registered machine can never forge an output/exit for a command it was not actually asked to run, even if it is otherwise a legitimately registered machine under some account.
aux4 api start locally, orits own Lambda invocation on a cloud deploy — so the relay keeps its connection registry (which connectionId is a registered machine of which principal and machine name, and the short SSO cache) in a shared store rather than in memory. A bare caller is never written to this registry at all — see Authentication above — which is what lets hello reply immediately instead of depending on a $connect write becoming visible to whichever concurrent instance ends up handling the caller's first message (the two can be, and on a cloud deploy's multiple Lambda instances often are, different processes with their own view of the state).
--dataDir (default ./.aux4-cloud-remote),guarded by a simple file lock.
automatically for this package — no manual setup needed. A local JSON file cannot be shared between the multiple concurrent Lambda instances a cloud deploy actually runs on, which is what this backend is for.
two modes, chosen automatically:
AUX4_REMOTE_PORT set): aux4/api's own HTTP management API,POST/DELETE 127.0.0.1:<port>/@connections/:id.
AUX4_REMOTE_PORT unset): AWS API Gateway's Management API(PostToConnection/DeleteConnection) at https://{domainName}/{stage}, signed with AWS SigV4 using the standard AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN/AWS_REGION environment variables the platform already injects, and the execute-api:ManageConnections permission it already grants the VM's execution role whenever config.ws is present — no manual IAM changes needed.
exec message is routed to the target machine's connection, and the relay records whichconnection the command actually went to and which connection is waiting on the result. The machine still echoes the caller's connectionId back on its output/exit replies (for aux4/remote client compatibility), but the relay no longer trusts that value for routing — it only forwards a reply when it comes from the exact connection the command was dispatched to, and always delivers it to the recorded caller. The record is intentionally not deleted the moment exit is relayed — output and exit are independent messages, each handled by its own process/invocation, so nothing guarantees they finish in the order the target sent them in; deleting the record immediately on exit could make a still-in-flight output for a message the target actually sent first find no record and be dropped. It expires on its own TTL (one hour) instead. If a target machine disconnects mid-command, the relay does not interrupt a caller already waiting on it — the caller's own command timeout is what ends the wait in that case.
output message carries a stream field ("stdout" or "stderr") alongside its data,forwarded unchanged from the target to the caller, so the caller writes each chunk to the matching local stream instead of merging everything into one. This field is additive: an older relay or client that does not know about it simply omits/ignores it, and a caller that receives an output message with no stream set treats it as stdout — the 0.3.x/0.4.x wire format stays compatible in both directions.
alongside the principal it resolved to.
wss:// (TLS, the defaultfor both a custom domain and the default execute-api domain) in anything but a fully trusted private network.
is not the enforcement point for what a machine will run — that is each machine's own expose policy, configured on the aux4/remote side.
AUX4_SSO_URL — SSO base URL to validate client tokens against. Default https://sso.aux4.io; setto https://dev.sso.aux4.io (or your own) explicitly on a dev deploy — never hardcoded.
AUX4_REMOTE_DATA_DIR — directory holding the relay's connection registry (local file-backed modeonly). Set internally by aux4 aux4 cloud-remote server start.
AUX4_REMOTE_PORT — the relay's own port (local mode only); unset is what selects API GatewayManagement API mode on a cloud deploy. Set internally by server start.
CLOUD_STORE_TABLE / CLOUD_STORE_PK — set by the aux4 cloud deploy platform. Their presence selectsthe DynamoDB registry backend instead of the local JSON file; not meant to be set by hand.
AUX4_CLOUD_SCOPE — the aux4 scope this relay belongs to; only members of this scope may connect (seeScope membership gate above). Injected automatically on an aux4 cloud deploy; set by --scope on a local server start. Connections are denied while this is unset.