fix(cloud): GitHub App setup page, dev-account billing bypass, live push results (#21)

* fix(cloud): GitHub App manifest page uses a visible submit button

* feat(cloud): dev operator accounts bypass billing outside prod; GitHub App push results
This commit is contained in:
Neil
2026-11-09 04:30:14 -08:00
committed by Neil
parent 8fb42f939a
commit 7be2308c33
4 changed files with 41 additions and 6 deletions
@@ -61,6 +61,24 @@ export const STOP_RUNNING_REASONS: ReadonlySet<string> = 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
+14 -5
View File
@@ -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('&', '&amp;').replaceAll('"', '&quot;').replaceAll('<', '&lt;')
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(
`<form id=f method=post action="https://github.com/organizations/stablyai/settings/apps/new?state=${state}">` +
`<input type=hidden name=manifest value="${escaped}"><button>Create “Orca Cloud (dev)” on stablyai</button></form>` +
'<script>document.getElementById("f").submit()</script>'
'<h2>Create the Orca Cloud (dev) GitHub App</h2>' +
'<p>1. Click the button. 2. On GitHub, scroll down and click <b>Create GitHub App for stablyai</b>.</p>' +
`<form method=post action="https://github.com/organizations/stablyai/settings/apps/new?state=${state}">` +
`<input type=hidden name=manifest value="${escaped}">` +
'<button type=submit style="font-size:18px;padding:10px 18px">Continue to GitHub</button></form>'
)
}
@@ -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: {
@@ -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"
}
}
+8
View File
@@ -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.