diff --git a/cloud/apps/sandbox-control/src/entitlements.ts b/cloud/apps/sandbox-control/src/entitlements.ts index 5eb71ae2664..fe4624e0300 100644 --- a/cloud/apps/sandbox-control/src/entitlements.ts +++ b/cloud/apps/sandbox-control/src/entitlements.ts @@ -61,6 +61,24 @@ export const STOP_RUNNING_REASONS: ReadonlySet = new Set([ 'payment_grace_expired' ]) +/** Dev operator test accounts (`dev:*`, see auth.ts) never reach billing outside prod. */ +export function withDevAccountBypass(env: Env, client: EntitlementClient): EntitlementClient { + if (env.SANDBOX_ENV === 'prod') { + return client + } + return { + checkStart: (request) => + request.accountId.startsWith('dev:') + ? Promise.resolve({ allow: true, reason: null, suspendRunning: false }) + : client.checkStart(request), + reportUsage: (segment) => + segment.accountId.startsWith('dev:') + ? Promise.resolve({ canStartSandbox: true, reason: null, suspendRunning: false }) + : client.reportUsage(segment), + listSuspensions: () => client.listSuspensions() + } +} + export function createEntitlementClient( env: Env, doFetch: typeof fetch = env.BILLING ? (input, init) => env.BILLING!.fetch(input, init) : fetch diff --git a/cloud/apps/sandbox-control/src/index.ts b/cloud/apps/sandbox-control/src/index.ts index f34e9f270a9..b467fd39730 100644 --- a/cloud/apps/sandbox-control/src/index.ts +++ b/cloud/apps/sandbox-control/src/index.ts @@ -9,7 +9,12 @@ // Vercel network-policy forwardURL target (Vercel sandbox OIDC): /v1/egress/proxy import { authenticateDesktop } from './auth' import { NO_CREDENTIALS, handleEgressProxy, type CredentialBroker } from './egress-proxy' -import { BillingUnavailableError, createEntitlementClient, type EntitlementClient } from './entitlements' +import { + BillingUnavailableError, + createEntitlementClient, + withDevAccountBypass, + type EntitlementClient +} from './entitlements' import type { Env } from './env' import { LifecycleError, @@ -99,10 +104,14 @@ function githubManifestStart(url: URL): Response { } const state = crypto.randomUUID() const escaped = JSON.stringify(manifest).replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<') + console.log(JSON.stringify({ event: 'github_manifest_start' })) + // No auto-submit: some browsers drop scripted cross-site POSTs, and GitHub still needs its own click. return html( - `
` + - `
` + - '' + '

Create the Orca Cloud (dev) GitHub App

' + + '

1. Click the button. 2. On GitHub, scroll down and click Create GitHub App for stablyai.

' + + `
` + + `` + + '
' ) } @@ -160,7 +169,7 @@ function lifecycleDeps(env: Env, deps: Deps): LifecycleDeps | null { projectId: env.VERCEL_PROJECT_ID!, baseUrl: env.VERCEL_API_BASE }), - entitlements: deps.entitlements ?? createEntitlementClient(env), + entitlements: deps.entitlements ?? withDevAccountBypass(env, createEntitlementClient(env)), github: deps.github ?? githubMinter(env), now: deps.now ?? Date.now, config: { diff --git a/cloud/apps/sandbox-control/wrangler.dev.jsonc b/cloud/apps/sandbox-control/wrangler.dev.jsonc index b6334b814dd..4a33ce81af8 100644 --- a/cloud/apps/sandbox-control/wrangler.dev.jsonc +++ b/cloud/apps/sandbox-control/wrangler.dev.jsonc @@ -29,7 +29,7 @@ "VERCEL_PROJECT_ID": "prj_SkVtv6zJurF9dUHpfTRy4v9avwPq", "VERCEL_REGION": "iad1", "BILLING_URL": "https://orca-billing-dev.lovecast.workers.dev", - "GOLDEN_SNAPSHOT_ID": "snap_aaJmS6etH8vyrTSxOQxPU7lx02QZ", + // GOLDEN_SNAPSHOT_ID: unset until an image is built (image/build-golden-image.ts); lifecycle routes answer 503 meanwhile. "EGRESS_PROXY_URL": "https://orca-sandbox-control-dev.lovecast.workers.dev/v1/egress/proxy" } } diff --git a/cloud/docs/vercel-driver-design.md b/cloud/docs/vercel-driver-design.md index 06e6a0bb5da..9bec21d5468 100644 --- a/cloud/docs/vercel-driver-design.md +++ b/cloud/docs/vercel-driver-design.md @@ -150,6 +150,14 @@ Compiled per sandbox by `compileNetworkPolicy()`: - Per-account authorization on every route (row `account_id` must equal the caller's); ids are random. - Strict zod bodies, 16 KiB limit, no redirects on provider calls, provider error bodies dropped. +GitHub App + billing dev (2026-11-09): app "Orca Cloud (dev)" (stablyai, id 5677658, +https://github.com/apps/orca-cloud-dev; contents/pull_requests write, metadata read, no webhook) created by the +manifest flow; key only as a Worker secret. From a real sandbox via the dev Worker: private repo cloned at create +(6.6s total), real `git push` of a new branch in 1.0s with the transform-injected repo token, `gh` and Node fetch to +api.github.com through the forwardURL proxy with a minted token (200, ~1s), no token on the VM disk. Billing dev is +reached over a service binding (same-account workers.dev fetches fail with 1042): an account without a subscription +gets 403 `no_subscription`; the cron's suspensions poll runs clean. `dev:*` operator accounts bypass billing outside prod. + ## Built (mock-tested) and next wiring - (b) `src/main/environment-providers/*`, `src/main/hosted-sandbox/*` — driver, client, contract kit, recipe adapter.