Files
orca/cloud/apps/sandbox-control/wrangler.dev.jsonc
T
Neil 919b6259bb feat(cloud): CODEX-RELAY chatgpt.com egress through a Cloud Run relay
chatgpt.com answers Cloudflare Workers' egress with a 403 "Unable to load site" page, so Codex via
the Orca account could never get an answer through the egress proxy (#767 made that a printed
error). Cloud Run's egress is answered normally (probed, then deleted).

- cloud/apps/chatgpt-relay: a dependency-free Node relay. chatgpt.com only, the same Codex path
  pinning as the Worker (shared sandbox-control/src/codex-paths.ts), SSE streamed chunk by chunk,
  no WebSocket upgrades, hop and Cloud Run headers dropped, logs without headers, bodies or queries.
- Cloud Run IAM authenticates the Worker: one invoker service account (run.invoker on the relay
  only); the Worker mints a Google ID token for the relay URL and sends it in
  X-Serverless-Authorization, so the swapped ChatGPT Authorization passes through untouched.
- sandbox-control: CHATGPT_RELAY_URL + CHATGPT_RELAY_SERVICE_ACCOUNT route the egress proxy's
  chatgpt.com fetches through the relay; unset, chatgpt.com goes direct as before. A relay
  sign-in failure answers Codex a 503 JSON detail instead of reaching chatgpt.com.
- cloud/infra/chatgpt-relay: Terraform (staging backend applied; production is a runbook step).
2026-11-15 00:21:38 -08:00

94 lines
6.2 KiB
JSON

{
"$schema": "node_modules/wrangler/config-schema.json",
// DEV deployment only (workers.dev, no custom domain). Deploy:
// wrangler deploy -c wrangler.dev.jsonc
// Secrets (wrangler secret put -c wrangler.dev.jsonc, never here): VERCEL_TOKEN, SANDBOX_DEV_JWKS,
// EGRESS_DEV_STATIC_AUTHORIZATION, CONTROL_PLANE_TOKEN (same value as on
// orca-billing-dev), GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY (PKCS#8), SECRETS_KMS_SERVICE_ACCOUNT and
// SECRETS_KEK_WRAPPED (SEC-3 KMS, see the vars below; no plaintext SECRETS_KEK), OPERATOR_TOKEN (/v1/internal/*), GITHUB_STATE_SECRET; for the GitHub connect flow also
// GITHUB_APP_CLIENT_ID + GITHUB_APP_CLIENT_SECRET (app settings → generate a client secret).
"name": "orca-sandbox-control-dev",
"main": "src/index.ts",
"compatibility_date": "2026-11-01",
"workers_dev": true,
// Keep the Worker's logs (provider_stall, grant_failed, lifecycle_timing) so a stall leaves evidence.
"observability": { "enabled": true },
// Preview aliases (wrangler versions upload --preview-alias) must stay reachable for pre-merge VM tests.
"preview_urls": true,
"d1_databases": [
{
"binding": "SANDBOX_DB",
"database_name": "orca-sandbox-control-dev",
"database_id": "e9f259e9-94b3-4e18-a132-2d807693a498",
"migrations_dir": "migrations"
}
],
// ENV-STALE: each golden build's orcad bundle; booting sandboxes behind the active golden install it.
"r2_buckets": [{ "binding": "RUNTIME_BUNDLES", "bucket_name": "orca-sandbox-runtime-dev" }],
// Same-account Workers cannot call each other over workers.dev (error 1042); BILLING_URL names the origin.
"services": [{ "binding": "BILLING", "service": "orca-billing-dev" }],
// Every minute for routines (src/routines); the rest of the cron work runs on minute % 5 == 0.
// Environment builds advance on Durable Object alarms (EnvironmentBuildRunner), not on readers. The
// runner is its own Worker (wrangler.build-runner.dev.jsonc, deployed first): a Worker implementing a
// Durable Object gets no preview URLs. v2 deletes the class this Worker hosted until then; its only
// state was each build's alarm, and the cron below re-arms every unfinished build within a minute.
// v2 below was applied in a deploy with no binding (Cloudflare error 10061 refuses a delete-class migration
// while any binding names the class, even one with script_name); the binding now points at the runner Worker.
"durable_objects": {
"bindings": [{ "name": "ENV_BUILD_RUNNER", "class_name": "EnvironmentBuildRunner", "script_name": "orca-sandbox-build-runner-dev" }]
},
"migrations": [
{ "tag": "env-build-runner-v1", "new_sqlite_classes": ["EnvironmentBuildRunner"] },
{ "tag": "env-build-runner-v2", "deleted_classes": ["EnvironmentBuildRunner"] }
],
"triggers": { "crons": ["* * * * *"] },
"vars": {
"SANDBOX_ENV": "dev",
// ENV-BUILD-CHURN: goldens rotate per merge on dev; refresh one environment at most every 6 h.
"ENV_REFRESH_MIN_INTERVAL_HOURS": "6",
// Flag S1 (contract D10/D11): Claude via the person's Orca account. Dev only until Neil's S1 sign-off.
"AGENT_ACCOUNTS_CLAUDE": "on",
// Flag S2: Codex via the account broker (broker sandbox, lease refresher, placeholder auth.json). Dev only
// until Neil's S2 sign-off; the kill switch is AGENT_ACCOUNTS_CODEX_DISABLED=1.
"AGENT_ACCOUNTS_CODEX": "on",
"SANDBOX_POOL_SIZE": "2",
// Dev only (ignored unless SANDBOX_ENV is dev): these dev accounts hit the real billing gate.
"SANDBOX_DEV_BILLING_ENFORCE_PREFIX": "dev:billing-test-",
// The golden orcad tracks this branch (host RPCs ship there first); rebuilt when HEAD touches VM code.
"GOLDEN_IMAGE_SOURCE": "git:https://github.com/nwparker/orca-private#cloud/integration",
"SANDBOX_JWT_AUDIENCE": "orca-sandbox",
"SANDBOX_JWKS_URL": "https://login.onorca.dev/.well-known/jwks.json",
"SANDBOX_AUTH_ISSUER": "https://login.onorca.dev",
// Dev only: also trust Orca Cloud auth STAGING sandbox tokens (billing dev trusts staging too).
"SANDBOX_STAGING_JWKS_URL": "https://auth-staging.onorca.dev/.well-known/jwks.json",
"SANDBOX_STAGING_AUTH_ISSUER": "https://auth-staging.onorca.dev",
"VERCEL_TEAM_ID": "team_c5IO9DfEYAxKEUgMxrbEtO0a",
"VERCEL_PROJECT_ID": "prj_SkVtv6zJurF9dUHpfTRy4v9avwPq",
"VERCEL_REGION": "pdx1",
"VERCEL_FALLBACK_REGIONS": "iad1",
"BILLING_URL": "https://orca-billing-dev.lovecast.workers.dev",
// Golden image from image/build-golden-image.ts; lifecycle routes answer 503 without one.
"GOLDEN_SNAPSHOT_ID": "snap_vpcmcCAgTtISiTZgsCosOlThQbFd",
// Snapshots are region-locked: the seed is an iad1 image; pdx1 builds its first image from source.
"GOLDEN_SNAPSHOT_REGION": "iad1",
"GITHUB_APP_SLUG": "orca-cloud-dev",
// Cloud setup pages (staging auth): GitHub installs started from a setup session return there.
"CLOUD_SETUP_ORIGIN": "https://auth-staging.onorca.dev",
// Auth's internal API (staging auth is the one that pushes to this Worker): the live "is this
// person in the team" check before a workspace changes owner. Unset = hand-offs refused.
"AUTH_INTERNAL_ORIGIN": "https://auth-staging.onorca.dev",
"EGRESS_PROXY_URL": "https://orca-sandbox-control-dev.lovecast.workers.dev/v1/egress/proxy",
// CODEX-RELAY: chatgpt.com refuses Workers' egress; its requests go through this Cloud Run relay
// (cloud/infra/chatgpt-relay, staging). Secret CHATGPT_RELAY_SERVICE_ACCOUNT holds its invoker key.
"CHATGPT_RELAY_URL": "https://orca-chatgpt-relay-gjzz5mc7ka-uc.a.run.app",
// SEC-3 phase 1: the secret store's KEK comes out of Cloud KMS (src/secrets-kms.ts); the Worker
// holds only the KMS-wrapped KEK (secret SECRETS_KEK_WRAPPED, AAD orca-secrets-kek:<SECRETS_KEK_ID>)
// and a service account that can only decrypt with this key (secret SECRETS_KMS_SERVICE_ACCOUNT).
// KMS down or denied = 503 secrets_unavailable, no fallback. Key, SA and escrow: cloud/infra/secrets-kms.
// SECRETS_KEK_ID and SECRETS_KEK_WRAPPED change together, in one deploy, or rows stop opening.
"SECRETS_KEK_SOURCE": "kms",
"SECRETS_KMS_KEY": "projects/onorca-cloud-staging/locations/us/keyRings/orca-secrets/cryptoKeys/secrets-kek",
"SECRETS_KEK_ID": "k2"
}
}