feat(infra): support Codex API key authentication
This commit is contained in:
1 parent
18c8101084
commit
8535bb3d67
4 files changed
+94
-25
No files matched your search
@@ -23,8 +23,9 @@ import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsL
|
||||
import { searchableSetting } from "./settingsSearch";
|
||||
|
||||
const RENDER_DEPLOY_URL =
|
||||
"https://dashboard.render.com/blueprint/new?repo=https%3A%2F%2Fgithub.com%2Fpingdotgg%2Ft3code&branch=feat%2Frender-cloud-environment";
|
||||
"https://render.com/deploy?repo=https%3A%2F%2Fgithub.com%2Fpingdotgg%2Ft3code%2Ftree%2Ffeat%2Frender-cloud-environment";
|
||||
const CODEX_LOGIN_COMMAND = "codex login --device-auth";
|
||||
type RenderAuthenticationMode = "api-key" | "subscription";
|
||||
|
||||
function pairingInput(value: string): { readonly host: string; readonly pairingCode: string } {
|
||||
const url = new URL(value.trim());
|
||||
@@ -113,6 +114,7 @@ export function CloudEnvironmentsSettings() {
|
||||
const [pairing, setPairing] = useState(false);
|
||||
const [pairError, setPairError] = useState<string | null>(null);
|
||||
const [busyEnvironmentId, setBusyEnvironmentId] = useState<EnvironmentId | null>(null);
|
||||
const [authenticationMode, setAuthenticationMode] = useState<RenderAuthenticationMode>("api-key");
|
||||
const renderEnvironments = useMemo(
|
||||
() => environments.filter((environment) => cloudEnvironmentProvider(environment) === "render"),
|
||||
[environments],
|
||||
@@ -189,18 +191,76 @@ export function CloudEnvironmentsSettings() {
|
||||
<SettingsRow
|
||||
title="Powered by Render"
|
||||
description="Creates a temporary free cloud machine for the demo."
|
||||
control={
|
||||
<Button
|
||||
size="sm"
|
||||
render={<a href={RENDER_DEPLOY_URL} target="_blank" rel="noreferrer" />}
|
||||
>
|
||||
Deploy on Render
|
||||
<ExternalLinkIcon className="size-3.5" />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection title="Authenticate and deploy">
|
||||
<div className="px-3 sm:px-4">
|
||||
<div
|
||||
role="tablist"
|
||||
aria-label="Codex authentication method"
|
||||
className="inline-flex rounded-lg border border-border/70 bg-muted/20 p-1"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={authenticationMode === "api-key"}
|
||||
className="rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground aria-selected:bg-background aria-selected:text-foreground aria-selected:shadow-xs"
|
||||
onClick={() => setAuthenticationMode("api-key")}
|
||||
>
|
||||
OpenAI API key
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={authenticationMode === "subscription"}
|
||||
className="rounded-md px-3 py-1.5 text-xs font-medium text-muted-foreground aria-selected:bg-background aria-selected:text-foreground aria-selected:shadow-xs"
|
||||
onClick={() => setAuthenticationMode("subscription")}
|
||||
>
|
||||
ChatGPT subscription
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{authenticationMode === "api-key" ? (
|
||||
<div role="tabpanel">
|
||||
<SettingsRow
|
||||
title="OpenAI API key"
|
||||
description="Render asks for OPENAI_API_KEY before deploying and stores it as a secret. Codex is authenticated automatically when the service starts."
|
||||
status="API usage is billed by OpenAI separately from Render."
|
||||
control={
|
||||
<Button
|
||||
size="sm"
|
||||
render={<a href={RENDER_DEPLOY_URL} target="_blank" rel="noreferrer" />}
|
||||
>
|
||||
Deploy with API key
|
||||
<ExternalLinkIcon className="size-3.5" />
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div role="tabpanel">
|
||||
<SettingsRow
|
||||
title="ChatGPT subscription"
|
||||
description="Deploy without an API key. After pairing and cloning a project, run this in its T3 terminal and complete the device login."
|
||||
status="Free instances forget this login when they restart or spin down."
|
||||
control={
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
render={<a href={RENDER_DEPLOY_URL} target="_blank" rel="noreferrer" />}
|
||||
>
|
||||
Deploy for subscription
|
||||
<ExternalLinkIcon className="size-3.5" />
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
<CopyCommand command={CODEX_LOGIN_COMMAND} />
|
||||
</SettingsRow>
|
||||
</div>
|
||||
)}
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection title="Connect">
|
||||
<SettingsRow
|
||||
title="Pair URL"
|
||||
@@ -250,13 +310,6 @@ export function CloudEnvironmentsSettings() {
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<SettingsRow
|
||||
title="Authenticate Codex"
|
||||
description="After cloning, open that project's terminal and run this once. Then start an agent."
|
||||
status="Free instances forget this login when they restart or spin down."
|
||||
>
|
||||
<CopyCommand command={CODEX_LOGIN_COMMAND} />
|
||||
</SettingsRow>
|
||||
</SettingsSection>
|
||||
</SettingsPageContainer>
|
||||
);
|
||||
|
||||
+17
-8
@@ -14,21 +14,26 @@ The root [`render.yaml`](../../render.yaml) creates:
|
||||
|
||||
- a Docker web service containing T3 Code, Codex, Claude Code, Git, and the GitHub CLI;
|
||||
- an ephemeral `/data` workspace for T3 Code state, provider credentials, and repositories;
|
||||
- an optional `OPENAI_API_KEY` secret prompt for automatic Codex authentication;
|
||||
- a health check against T3 Code's public environment descriptor.
|
||||
|
||||
## Deploy
|
||||
|
||||
1. In the Render Dashboard, choose **New → Blueprint**.
|
||||
2. Connect this repository and select the branch you want to deploy.
|
||||
3. Deploy the Blueprint and wait for the service health check to pass.
|
||||
4. Open the service logs and copy the `Pair URL` printed during startup. Treat this URL like a
|
||||
3. Choose an authentication method:
|
||||
- **OpenAI API key:** enter `OPENAI_API_KEY` in Render's secret prompt. Startup authenticates
|
||||
Codex automatically.
|
||||
- **ChatGPT subscription:** skip the optional API key, then use device login after cloning.
|
||||
4. Deploy the Blueprint and wait for the service health check to pass.
|
||||
5. Open the service logs and copy the `Pair URL` printed during startup. Treat this URL like a
|
||||
password: it contains a one-time pairing credential.
|
||||
5. Open the URL in a browser, or paste it under **Settings → Cloud environments → Pair URL**.
|
||||
6. Open the Command Palette and choose **Add Project → Cloud environments → Render cloud
|
||||
6. Open the URL in a browser, or paste it under **Settings → Cloud environments → Pair URL**.
|
||||
7. Open the Command Palette and choose **Add Project → Cloud environments → Render cloud
|
||||
environment**. Paste a public GitHub URL. T3 Code clones it directly into the Render workspace;
|
||||
there is no local destination picker.
|
||||
7. Open the project terminal, run `codex login --device-auth`, complete the device login, and start
|
||||
an agent.
|
||||
8. API-key deployments are ready immediately. For subscription authentication, open the project
|
||||
terminal, run `codex login --device-auth`, complete the device login, and start an agent.
|
||||
|
||||
Repositories are selected after pairing rather than baked into the Blueprint. Each clone is stored
|
||||
under `/data/workspace` for the current Free-instance session.
|
||||
@@ -42,8 +47,12 @@ pull request is merged. Update the `branch` field in `render.yaml` if you rename
|
||||
|
||||
## Provider Authentication
|
||||
|
||||
The Blueprint does not ask for an OpenAI API key. Free instances do not include Render Shell access,
|
||||
so clone a public project, open its T3 Code terminal, and run:
|
||||
For API-key authentication, the Blueprint declares `OPENAI_API_KEY` with `sync: false`. Render asks
|
||||
for it during the initial deployment and stores it as a secret; the value is never committed to the
|
||||
repository. The startup script pipes it to `codex login --with-api-key` and removes it from the
|
||||
server process environment afterward.
|
||||
|
||||
For ChatGPT subscription authentication, clone a public project, open its T3 Code terminal, and run:
|
||||
|
||||
```sh
|
||||
codex login --device-auth
|
||||
|
||||
@@ -26,6 +26,11 @@ export T3CODE_WORKSPACE_DIR="$workspace_dir"
|
||||
|
||||
mkdir -p "$t3_home" "$workspace_dir" "$codex_home" "$claude_config_dir"
|
||||
|
||||
if [ -n "${OPENAI_API_KEY:-}" ]; then
|
||||
printf '%s\n' "$OPENAI_API_KEY" | codex login --with-api-key
|
||||
unset OPENAI_API_KEY
|
||||
fi
|
||||
|
||||
if [ -n "${GH_TOKEN:-}" ]; then
|
||||
gh auth setup-git
|
||||
fi
|
||||
|
||||
@@ -18,3 +18,5 @@ services:
|
||||
value: /data/workspace
|
||||
- key: T3CODE_PAIRING_TTL
|
||||
value: 24h
|
||||
- key: OPENAI_API_KEY
|
||||
sync: false
|
||||
Reference in new issue
Block a user