Files
t3code/infra/relay

T3 Code Cloud Relay

Warning

T3 Code Cloud is currently in private beta. Join the waitlist in the app under Settings > T3 Cloud.

The relay is the hosted control plane for T3 Code Cloud. It helps clients discover and connect to remote environments, manages the cloud-side records needed for those connections, and delivers optional mobile notifications and Live Activities.

The relay is intentionally not in the hot path for normal T3 Code traffic. After a client connects, regular API and WebSocket traffic goes directly between that client and the selected environment. See the cloud architecture overview for the larger system design.

Responsibilities

The relay currently owns:

  • Linking T3 Code environments to a cloud account.
  • Provisioning and tracking managed environment endpoints.
  • Issuing short-lived credentials used to connect clients to linked environments.
  • Listing linked environments and registered mobile devices for an account.
  • Registering mobile notification preferences and APNs tokens.
  • Receiving published agent activity and delivering notifications or Live Activity updates.
  • Persisting relay state and exposing relay-specific traces for diagnostics.

The environment server and relay have separate credentials and trust boundaries. Read Environment Authentication Profile before changing token, credential, or authorization behavior.

Code Map

  • alchemy.run.ts defines the deployed Alchemy stack.
  • src/worker.ts wires Cloudflare bindings, runtime layers, queues, and HTTP APIs.
  • src/http/Api.ts contains the relay HTTP handlers and authentication boundaries.
  • src/environments contains environment linking, credentials, endpoint provisioning, and connection flows.
  • src/agentActivity contains mobile device registration, activity state, APNs delivery, and queue processing.
  • src/auth contains relay token and DPoP proof handling.
  • src/persistence/schema.ts defines persisted relay state. Keep schema and migration changes together.

Shared request and response schemas live in packages/contracts/src/relay.ts. Shared client-side relay calls live in packages/client-runtime/src/managedRelay.ts.

Working Locally

Install dependencies from the repository root, then run relay-focused checks from this directory:

bun install
cd infra/relay
bun run test
bun run typecheck

To run a smaller test set while iterating:

bun run test src/environments/EnvironmentLinker.test.ts

Before considering a change complete, run the repository-wide checks from the root:

bun fmt
bun lint
bun typecheck

Backend changes should include tests. Prefer testing the real business logic with external dependencies represented at their boundary rather than mocking internal behavior.

Deployment

The relay deploys through Alchemy:

cd infra/relay
bun run deploy

The stack provisions the Cloudflare Worker and queues, managed endpoint resources, database connectivity, and relay tracing resources. Runtime secrets include Clerk and APNs credentials.

See: