Commit Graph
841 Commits
Author SHA1 Message Date
Neil 554bf8fd98 perf(cloud): the image carries OpenCode's config-dir install; a fresh home gets a copy, so the first launch never fetches 2026-11-15 03:10:34 -08:00
Neil 55b366e468 cloud: renumber the environment region migration to 0062 (0061 landed concurrently) 2026-11-15 02:56:55 -08:00
Neil b729b1cc5f Merge pull request #777 from nwparker/cloud/nearest-region
cloud: default new workspaces and environments to the nearest served region
2026-11-15 02:56:39 -08:00
Neil 7b83e9d94b Merge pull request #775 from nwparker/cloud/opencode-prewarm-plugins
perf(cloud): OpenCode boot first run waits for the plugin dir
2026-11-15 02:49:53 -08:00
Neil 8a9e198923 cloud: log each desktop create's region order 2026-11-15 02:48:00 -08:00
Neil 840c8319f1 Merge pull request #770 from nwparker/cloud/create-gh-access-step
feat(cloud): CREATE-GH-STEP GitHub access step in the create wizard
2026-11-15 02:45:45 -08:00
Neil a94ca739f3 cloud: start new workspaces and environments in the served region nearest the caller
A create or new environment with nothing pinned used to start in pdx1 whatever the caller's location,
and every frame of a remote session paid that round trip. Now the sandbox-control Worker ranks the
served regions (the default and its fallbacks with an active golden) by distance from Cloudflare's
request geolocation and starts in the nearest.

- Explicit regions (request, API project) and an environment's build region stay authoritative.
- Environments record their region (migration 0061): builds, golden refreshes, staleness and the
  security floor use it, so snapshots stay bootable and workspaces from them stay together. Legacy
  environments (NULL) live in the default region as before.
- Automatic environments live where the create that made them ran.
- The capacity fallback tries the next nearest served region.
- The warm pool keeps VMs in every served region.
- VERCEL_NEAREST_REGION=off restores default-region-only.
- Desktop: the workspace card's Details shows the region (e.g. Portland (pdx1)).
2026-11-15 02:45:42 -08:00
Neil 917f44bc62 Merge pull request #759 from nwparker/cloud/settings-cloud-signins
feat(settings): Orca Cloud agent sign-ins move to Settings › Orca Cloud
2026-11-15 02:38:06 -08:00
Neil 58aa8c02ad perf(cloud): OpenCode's boot first run waits for Orca's plugin dir, so it also installs the plugin SDK 2026-11-15 01:12:59 -08:00
Neil d88c87f17d fix(sandbox-control): a boot from an older environment snapshot starts with this Worker's entry points (probe folded into the runtime refresh command; install only when behind) 2026-11-15 01:06:08 -08:00
Neil 8efca5e240 test: typed deadline table 2026-11-15 00:48:28 -08:00
Neil 4886fa4d6a test: non-null deadline lookups 2026-11-15 00:45:24 -08:00
Neil a9a28e6aae fix(sandbox-control): bound a create's pre-insert phases and name a stuck one (phase_timeout log; environment/entitlement fail at 20 s, a slow pool claim is only logged) 2026-11-15 00:45:08 -08:00
Neil e8313a82af chore(cloud): CODEX-RELAY register the relay's vitest runner 2026-11-15 00:25:51 -08:00
Neil 5a895dcedc feat(cloud): CREATE-GH-STEP GitHub access step in the create wizard
Ask for Orca GitHub App access while the sandbox starts, not in a toast afterwards.

Server (sandbox-control):
- GET /v1/github/repo-access answers `push`: ok | not_installed | repo_not_selected |
  not_connected, with `configureUrl` (the installation's settings page) for repo_not_selected.
  A public repo that can't push now gets an install URL too.
- GitHub installation lookups (repo and new owner lookup) cached in D1 (migration 0061):
  found 60 s, 404 15 s, dropped by installation / installation_repositories webhooks and the
  setup return. The owner lookup never holds the answer (3 s cap, errors read as not_installed).

Desktop:
- "GitHub access" row after Start sandbox, checked when the create starts (parallel, so no
  latency when access is fine). Missing: Install GitHub App / Add repository on GitHub /
  Copy request for an owner, plus Skip for now ("You can pull; pushes need access later").
  Polls (2 s for 3 min, then 10 s; on focus) and auto-advances on grant.
- The create holds before Open workspace only while the step asks and the sheet is on screen.
- Skip remembered per repo on this device; later creates show it skipped (Set up) without
  holding; forgotten once the repo has access.
- A grant that lands after the sandbox started calls applyCloudGitHubAccessToSandbox, a stub
  until gh-access's live refresh lands.
2026-11-15 00:25:15 -08:00
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
Neil 0ec974fd13 Merge pull request #768 from nwparker/cloud/agent-config-deps-prewarm
perf(cloud): OpenCode's first run happens at boot, not on the first launch
2026-11-15 00:21:15 -08:00
Neil 767919684b perf(cloud): OpenCode's first run happens at boot, not on the first launch
OpenCode's first run in a VM installs its plugin SDK into ~/.config/opencode, creates its database and fetches its model list (first launch 5.2 s vs 2.7 s warm; in a pane on a fresh VM ~11 s, with the opencode process starting 0.7 s after the click, so the time is OpenCode's own). orca-sandbox-start now runs `opencode models` (does all of it, no credentials, exits) in the background at nice 19 right after orca-sandbox-env writes the config, only while ~/.config/opencode/node_modules is missing (once per disk; wakes skip it).
2026-11-15 00:17:47 -08:00
Neil 85f5283d98 feat(settings): Orca Cloud agent sign-ins move to Settings › Orca Cloud › Cloud agent sign-ins
Neil: an Orca Cloud part inside Settings › Agent accounts was confusing. The Claude and ChatGPT
sign-ins for cloud workspaces (set up, paste a token, renew, remove) are now their own page in the
Orca Cloud group, right after Account & billing. Agent accounts keeps This computer and Hosts and
one row, "Orca Cloud sign-ins live in Orca Cloud settings", that opens the new page.

Every deep link moves with it: Renew in Settings, the sign-in sheet's footer, the host panel, and
old links to pane 'accounts' at 'orca-cloud' / 'accounts-orca-cloud' (resolveCloudAgentSignInsTarget).
Copy that sent people to "Settings → Agent accounts" for Orca Cloud now says "Settings → Cloud agent
sign-ins" (new i18n keys so stale translations don't point at the old place), including
sandbox-control's expired-Claude and RS-4 Codex messages. Search: the Orca Cloud keywords
(subscription, chatgpt, setup-token, renew) move to the new page. Behavior is unchanged.
2026-11-15 00:17:40 -08:00
Neil dca419d3fd fix(cloud): CODEX-EGRESS-BLOCKED say so when chatgpt.com refuses the egress proxy
chatgpt.com answers every request from Cloudflare Workers' egress IPs with a 403 "Unable to load
site" HTML page, whatever the token (verified from a throwaway Worker; the same request from
elsewhere gets a normal 401). Codex via the Orca account goes through the Worker egress proxy, so
it got that page on /responses and /wham/usage: "Working…" without an answer, and /status had no
limits.

The proxy now recognises a provider edge's own refusal (403, text/html, server: cloudflare) on
routes that define an answer for it, logs egress_upstream_blocked, and answers Codex in ChatGPT's
error shape so Codex prints a plain message. The block says nothing about the credential: no
status hook, so no refresh and no revoke. This doesn't make Codex work; routing chatgpt.com around
the Worker is a separate decision.
2026-11-15 00:09:55 -08:00
Neil c24f97588e fix(sandbox-control): 20 s provider deadline, one retry for stalled reads; dev Worker keeps its logs
team-lead follow-up to #762: lookups/updates now fail at 20 s; a GET that hits the deadline is asked once more (a stalled write is never repeated: it may have landed); each stall logs provider_stall with the call's shape. orca-sandbox-control-dev turns on Workers observability so provider_stall, grant_failed and lifecycle_timing are retained.
2026-11-14 23:40:25 -08:00
Neil 6f1bbcfc55 Merge pull request #763 from nwparker/cloud/golden-agent-prefetch
perf(golden): prefetch the agent CLIs into the page cache at boot
2026-11-14 23:22:32 -08:00
Neil 6a02019931 chore(golden): regenerate the Worker-embedded VM scripts 2026-11-14 23:20:02 -08:00
Neil 845e495128 perf(golden): prefetch the agent CLIs into the page cache at boot
A fresh VM pages the agent CLIs in lazily from its snapshot, so the first agent launch paid for it (OpenCode 11 s cold vs 3.75 s warm in the same VM, n71). orca-sandbox-start now reads the claude, codex and opencode packages (files over 256 KB) in the background at nice 19 / idle IO, detached, after orcad starts; never on the ready path. Best effort.
2026-11-14 23:17:54 -08:00
Neil 027fc090d5 fix(sandbox-control): deadlines on every Vercel API call; slow grants log their phases
Two dev failures (n70/n71) were the Worker waiting on a stalled Vercel API connection with no
client-side deadline: a create spent ~2 min before its write-ahead insert ("Start sandbox" stuck),
and POST /v1/team/workspaces/:id/grants (opening a new workspace on this computer) hung its full
120 s (wallTime 119995 ms, no response) although its VM command is bounded at 45 s.

- Every provider request now has a deadline: 30 s for lookups and updates, 60 s to boot a VM,
  5 min to snapshot, a command's own timeout + 20 s, and 3 h only for an explicit unbounded wait
  on a build's exit. A stall becomes a provider error the callers already handle (grant_failed,
  the create fallback), instead of an open-ended wait.
- issueGrant logs its phases (session, grant command, member git) when it takes over 10 s, and
  logs grant_failed with its timings and error, so the next slow open names its phase.
2026-11-14 23:14:24 -08:00
Neil 6b05760eb7 fix(cloud): GH-ANON-403 member GitHub identities no longer 403 anonymous git to github.com
A workspace on a public repo the Orca GitHub App isn't installed on gets no App token, so its git
sends no credential. When a member had connected GitHub, their placeholder rules made github.com a
credential host, and compileNetworkPolicy ended it with the firewall's 403: the doctor's
`git ls-remote origin HEAD` failed ("This workspace can't reach <repo> on GitHub right now"), and so
did every plain fetch and pull.

- With no App token, the member github.com route is allowUnclaimed. With a token the workspace git
  route keeps github.com fail-closed as before. api.github.com is unchanged.
- A wake rewrites the policy when member identities apply: a resumed session keeps its last
  policy, so a workspace created before this fix would otherwise keep the 403.
2026-11-14 22:12:45 -08:00
Neil 786e3064e3 Merge pull request #753 from nwparker/cloud/secrets-kms-dev
SEC-3: KMS-wrapped secrets KEK on dev (Terraform root + plaintext-KEK migration opt-in)
2026-11-14 21:24:39 -08:00
Neil 2400ca2cd9 Merge pull request #750 from nwparker/cloud/snapshot-leaks
fix(sandbox-control): no snapshot leaks on any delete path; nothing deletes a snapshot still in use
2026-11-14 21:10:13 -08:00
Neil f637ad8cfb Merge pull request #752 from nwparker/cloud/share-ws-keepalive
fix(sandbox-control): share-link WebSockets get a keepalive ping under Vercel's ~340 s idle cut
2026-11-14 21:08:14 -08:00
Neil 797aaeb178 feat(sandbox-control): SEC-3 KMS turn-on for dev: Terraform root for the KEK wrap key, plaintext-KEK migration opt-in
- cloud/infra/secrets-kms: own Terraform root and state (terraform/secrets-kms) for the Cloud KMS key
  that wraps the secret-store KEK, the Worker's decrypt-only service account, KMS/Secret Manager
  data-access audit logs and the KEK escrow secret. Applied to onorca-cloud-staging (dev Worker).
- SECRETS_KEK_PLAINTEXT_RETIRED_ID: in kms mode, also open rows under that id with the plaintext
  SECRETS_KEK as a retired key, only after KMS handed over the active KEK. Neither dev nor prod has a
  copy of its KEK outside Cloudflare, so the KEK can't be wrapped; this lets the rewrap sweep move
  rows onto a new KMS-held KEK instead. Never seals, never stands in for KMS (tests).
- wrangler.dev.jsonc: SECRETS_KEK_SOURCE=kms, SECRETS_KMS_KEY, SECRETS_KEK_ID=k2.
2026-11-14 20:58:28 -08:00
Neil 0148e0c48c fix(sandbox-control): share-link WebSockets get a keepalive ping under Vercel's ~340 s idle cut
Every Orca socket into orcad already gets a WS ping every 10-15 s (orcad's server heartbeat and the
desktop's client liveness). Share links were the gap: the in-VM share proxy piped upgraded sockets raw, so
a preview app's silent WebSocket was closed by Vercel after ~340 s (1006), well before the link's
deadline. The proxy now follows the app's frame boundaries and, after 30 s with no traffic either way,
sends the visitor an empty ping frame between two frames (never inside one). Only 101 upgrades to
websocket get pings; other upgrade protocols stay a raw pipe.

VM script: reaches live VMs through the boot-time entry-point sync (new stamp), and the next golden.
2026-11-14 20:57:31 -08:00
Neil 44595111e2 fix(sandbox-control): a retried sandbox command never runs twice (agent messages, launches)
Vercel's command POST has no idempotency key, so a retry after a lost answer (dropped connection, gateway
5xx, a Worker that died mid-request) can start the command again (vercel/sandbox#363). Message delivery
did exactly that: a transient failure re-queued the message and the cron typed it into the agent again,
or launched a second agent.

- command-once.ts: an in-VM guard with a per-id ledger (mkdir claim, recorded exit + output). A repeat of
  the same id waits for and replays the first run; a dead first run reports an unknown outcome; a failed
  run is forgotten so a retry runs for real. runCommandOnce retries uncertain provider failures with the
  same id (never a 4xx that proves the command did not start).
- deliverMessage uses msg-<id> for send/launch; an unknown outcome fails the message
  (delivery_outcome_unknown) instead of re-sending.
- POST /messages and POST /sessions take Idempotency-Key (same semantics as workspace create); a session
  create taking over a died attempt replays the first launch.
- The REST client keeps sending each command POST exactly once (test).
2026-11-14 20:57:30 -08:00
Neil bde0bed3ce fix(sandbox-control): no snapshot leaks on any delete path, and nothing deletes a snapshot still in use
- snapshot-refs.ts: one check for what live things still boot from (goldens of any live status, pool
  images, active environment builds, live workspaces' own snapshots, and a live workspace's boot image
  until it has a snapshot of its own).
- Retired goldens beyond the rollback and deleted environments' builds are marked deleted only after the
  provider delete succeeded (a failed delete used to be marked and leaked for good), and are deferred
  while in use. A new hourly housekeeping step (sweepReleasedSnapshots) retries both.
- Team delete marks the team's environments deleted, so their build snapshots are freed (they leaked).
- Environment prune skips a build a live workspace still boots from.
- Orphan sweeps (per box and project-wide automatic) also respect pool and boot-image references.
- The golden smoke box is non-persistent: it no longer leaves a ~325 MB automatic snapshot behind.
2026-11-14 20:57:17 -08:00
Neil f2888317b4 feat(cloud): plans dialog before the web console; billing serves each plan's card copy
"Plan & billing", "Upgrade to Orca Cloud", "Choose plan" and every "Compare plans" now open an
in-app plans dialog first: the team's plan and status (trial hours left, active with hours and
seats, payment failed, or no plan with the trial billing offers), then billing's plan cards (Team
with a monthly/annual toggle, Enterprise with contact sales). "Continue in browser" opens the
console's billing page through the existing sign-in ticket. Members see the same plan info with
"Ask a team admin to upgrade" (Plan & billing is back in their account menu, read-only). Read-only:
no checkout, usage history or admin settings return to the desktop.

Everything shown is billing's: names, Stripe prices, seat pricing, feature bullets and trial terms
from GET /v1/plans, now also each plan's tagline, feature-list lead and button label (new optional
catalog `marketing`, unversioned copy, plus `omitFeatures` so Enterprise stops advertising egress
controls). Main's lenient parse keeps a newer or older service safe; without the catalog the
entitlement's offers stand in, and with neither the dialog says plans didn't load and still offers
the console. While billing loads the title is neutral, so a paying team never sees an upsell flash.

Settings > Account's billing row opens the dialog ("View plans"); "Update payment method" still
goes straight to the console.
2026-11-14 16:37:59 -08:00
Neil 8104f84b94 billing: record one plan start per Checkout
One Checkout sends checkout.session.completed, customer.subscription.created and invoice.paid,
often concurrently; each that re-read the row before another wrote it saw the plan start and
pushed billing.plan_started with its own 'at', so the event ids differed and the team's audit
log showed it twice. A plan starting or ending now carries a once key (subscription id and
period start), so every racer pushes the same event id and the control plane's INSERT OR IGNORE
keeps one.
2026-11-14 03:45:08 -08:00
Neil b9a2ff9896 feat(billing): Checkout and the Customer Portal started from the web console return to its billing page
POST /v1/billing/checkout and /portal accept returnTo: 'console'. The return URL is built from
this Worker's CONSOLE_URL (else the setup pages' auth origin, which forwards /console) and the
caller's own team, never from the request. Desktop-started flows keep the /return handoff page.
2026-11-14 02:18:51 -08:00
Neil f1573ece1c test(billing): use the real help@stably.ai inbox in supportUrl fixtures (orca.dev has no MX) (#740) 2026-11-14 02:01:12 -08:00
Neil 84a776923c docs(cloud): sandbox-control typecheck split pinned by path; README on why raw tsc shows imported diagnostics 2026-11-13 11:16:23 -08:00
Neil ec679a8f52 fix(cloud): sandbox-control typecheck to zero (SANDBOX-CONTROL-TYPECHECK) 2026-11-13 11:14:50 -08:00
Neil d20dc4e20a feat(cloud): TRANSFER-SLOW-N60 a completed owner hand-off logs how long each step took 2026-11-13 11:04:44 -08:00
Neil 46f081f336 Merge pull request #703 from nwparker/cloud/g9-claude-key-tail
fix(cloud): G9 never write a real ANTHROPIC_API_KEY tail into ~/.claude.json
2026-11-13 10:33:28 -08:00
Neil 648f5bb67f feat(cloud): OWNER-TRANSFER previous-owner notices expire after 90 days and go with a deleted team 2026-11-13 07:39:07 -08:00
Neil a58aad5522 Merge pull request #713 from nwparker/cloud/owner-transfer-notify
feat(cloud): OWNER-TRANSFER tell the previous owner; expose the owner-changed mark
2026-11-13 07:27:20 -08:00
Neil 881b82e401 Merge pull request #711 from nwparker/create-speed/snap404-skip-deleted
fix(cloud): the fresh-build 404 retry never runs for a create its owner deleted
2026-11-13 07:16:53 -08:00
Neil 04457ec384 fix(cloud): OWNER-TRANSFER an email answer with no mode is not a delivery (sso-scim review) 2026-11-13 07:15:58 -08:00
Neil 8026ca98af feat(cloud): OWNER-TRANSFER tell the previous owner (notice in Orca, email asked of auth, audit row); expose the owner-changed mark 2026-11-13 07:14:33 -08:00
Neil 950a8165c8 Merge pull request #691 from nwparker/cloud/ep10-cancel-on-delete
feat(billing): EP-10 team delete can cancel a plan that's already set to end (cancel-now)
2026-11-13 07:11:50 -08:00
Neil 7922504e4b fix(cloud): the fresh-build 404 retry never runs for a create its owner deleted 2026-11-13 06:59:42 -08:00
Neil e05dee2312 Merge remote-tracking branch 'private/cloud/integration' into cloud/env-build-churn 2026-11-13 06:50:47 -08:00
Neil 59ed67dd0c Merge pull request #689 from nwparker/cloud/ep9-billing-mint-org
fix(cloud): EP-9 billing tokens name the team this device shows (cross-device active-team leak)
2026-11-13 06:49:21 -08:00