feat(cloud): add headless cloud CLI control plane#2905
Merged
juliusmarminge merged 21 commits intoJun 4, 2026
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
t3 cloud link,t3 cloud status, andt3 cloud unlinkfor headless T3 Cloud managementBehavior
t3 cloud linkworks when no T3 server is running. It installs the managedcloudflaredbinary, completes Clerk OAuth authorization, stores desired exposure, and tells the user that the nextt3 serveort3 startwill expose the tunnel. When a server is already reachable, it reconciles immediately.t3 cloud unlinkdisables desired exposure first, asks a reachable server to stop its managed connector, and best-effort revokes the relay-side environment record.Testing
bun fmtbun lintbun typecheckbun run testStack
Stacked on #2837.
Note
High Risk
Touches authentication, persisted credentials, relay linking, and automatic outbound reconciliation on server startup; misconfiguration could affect exposure or startup behavior.
Overview
Adds a headless
t3 cloudCLI (login,link,status,unlink,logout) gated on build-time public config (T3CODE_CLERK_CLI_OAUTH_CLIENT_ID, relay URL, Clerk publishable key). The CLI uses Clerk PKCE OAuth with tokens in the secret store, persists desired exposure separately from a running server, and can install managedcloudflaredbefore linking.On server startup, if exposure was requested,
reconcileDesiredCloudLinkcompletes the relay environment link using the stored CLI credential (no new HTTP reconcile route). Release builds and.env.examplenow require the CLI OAuth client ID; release workflow passes it into desktop/CLI builds.Desktop/web Clerk API calls allow only hosts derived from the publishable key (replacing hardcoded suffix checks). The desktop app opens off-origin navigations (e.g. OAuth) in the system browser and adapts Clerk connected-account flows to the native
t3code://callback bridge.Reviewed by Cursor Bugbot for commit b8989d6. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add headless CLI OAuth control plane for T3 Cloud link and relay management
t3 cloudCLI subcommand that is conditionally available based on build-time public config (T3CODE_CLERK_CLI_OAUTH_CLIENT_ID, relay URL, Clerk publishable key); when config is absent the subcommand exits with a help errorCloudCliTokenManagerto store, retrieve, and exchange CLI OAuth (PKCE) credentials inServerSecretStore, andCliStateto track and clear the desired-cloud-link flag and all persisted relay secretsreconcileDesiredCloudLinkin cloud/http.ts: on server startup, if a desired-link flag is set, the server automatically completes the relay link using the stored CLI credential without requiring an HTTP endpointmakeDesktopClerkExternalAccountAdapterin desktopClerkExternalAccounts.ts that interceptscreateExternalAccountandreauthorizecalls to use a native bridge callback URL and reloads the user on completionrelayAuthutilities (clerkFrontendApiHostnameFromPublishableKey,isAllowedClerkFrontendApiHostname) instead of hardcoded suffix checksMacroscope summarized b8989d6.