Run Amp threads on instabox sandboxes as Amp orbs
Merged
CA
19h ago+5919+5919+0123456789012345678901234567890123456789-28-28-01234567890123456789
Adds Amp orbs: InstaADE makes the user's instabox workspace an orb provider for Amp, so each Amp thread runs on its own instabox sandbox. Setup is one click on a paid plan. It needs no change to the instabox backend or to Amp. See docs/amp-orbs.md.
How it works
- Provider sandbox. Setup makes
amp-orb-provider(smallest size, auto sleep off, metadatainstabox-role=amp-orb-provider). It installsamp-orbsand three systemd units, then runsamp orb provider /usr/local/bin/amp-orbsas a service. - Dispatch program (
src-tauri/assets/amp-orbs/amp-orbs, bash). Amp calls it withORB_OPERATION:spawnfinds or creates the thread's orb sandbox, named by Amp's orb IDamp-<thread UUID>, from the project's snapshot, else the newest base snapshot. When the thread picked an orb type (ORB_TYPE), the orb gets that type's size:small,medium,large,xlarge/xxlarge(Amp's size names,a1.optional) or<vCPUs>x<GB>. instabox snapshots are size-locked, so a mismatched orb is resized withinstabox resize --restartbefore Amp starts. An unknown type fails before any sandbox; a new orb that cannot get its size is deleted. Without types: 4 vCPU / 8 GB, as before. Then it startsamp orb bootstrapthere.pausesaves a snapshot when Amp asks for one, then suspends the orb.deletedeletes the orb.- It only touches sandboxes with
instabox-role=amp-orband the matchingamp-orb-id. - The app finds the provider and orbs only in sandboxes whose
orgIdis the workspace's; a sandbox without anorgIdis in no workspace.
- Orb image.
instabox snapshot importimports Amp's official orb image asamp-orb-base-<time>. A daily timer imports it again. The import's builder sandbox isamp-orb-builder-<provider id>: the program and removal delete only a builder with that exact name and the import's mark, never an import of the user's. - instabox key. Setup makes a workspace key with machine and image scopes for 365 days. It goes to the provider through exec env with
noHistory, never in the command text. The install saves it in/etc/amp-orbs/key(root only, read by systemd) and runs the installers in a new process without it. Repair rotates it. The app renews it in its last 30 days, in the workspace the read was for, also when the user switched workspaces meanwhile.- Setups that run at once (two admins, two apps) cannot leave an extra key or a revoked one installed. The provider installs one key at a time (
flock) and keeps the newest key, ranked by expiry then id (orbs::key_rank). Each setup lists the keys after its install and revokes only keys older than its own, and its own key when the provider kept a newer one.
- Setups that run at once (two admins, two apps) cannot leave an extra key or a revoked one installed. The provider installs one key at a time (
- Tools on the provider. instabox CLI 0.8.522, installed only when its npm tarball has the hash InstaADE knows (
orbs::INSTABOX_CLI). Amp's CLI from npm, unpinned. - Sign-in. A terminal opens on the provider. It runs
amp login,amp orb provider create instaboxandset-default, so the user copies no token. - Removal refuses while orbs are left. It stops dispatch on the provider and checks the orbs again, then deletes the orb snapshots and the import builder with the user's sign-in, revokes every
Amp orbskey, and deletes the provider. Each step must succeed, and a second removal finishes what a failed one left.- The stop takes the install lock and marks the provider as being removed. For 30 minutes, a setup, repair or renewal in another app changes nothing on it, so none starts dispatch again or installs a key. The keys are listed after the stop.
- It deletes only snapshots named as
amp-orbsnames them (amp-orb-base-<time>,amp-orb-snap-<project>-<time>[-<tag>]), never a user's snapshot that only starts alike.
- Provider token.
amp-orbs-connectkeeps the token thatamp orb provider create instaboxsaved for the Amp server in use, in/var/lib/amp-orbs/provider-token(0600). The provider runs with that token only.
UI
- An offer above the list in Amp mode, and Settings → Amp orbs.
- The Amp orbs page: setup steps, costs, the sign-in terminal, status, Rebuild image, Remove.
- Provider and orb rows show their role. Orbs have no ADE, power or delete; Open thread opens the thread at ampcode.com. The tray leaves both out.
- Free plan: the page asks for a paid plan.
API client
create_org_api_key,org_api_keysandrevoke_org_api_key(POST/GET/DELETE /v1/orgs/{id}/keys).delete_snapshot(DELETE /v1/snapshots/{id}).ExecRequestgainsenvsandnoHistory.
End-to-end run (2026-12-04 PST, Team workspace, real Amp account)
- Setup, install, key isolation (
/etc/amp-orbs/keyroot 0600, not in the env file), sign-in, token saved underorb-provider-token@https://ampcode.com/, service active: OK. - Orb image import:
amp-orb-base-1796416451ready. - A thread on an orb (
amp -ox … --orb-provider instabox): spawn in 15.9 s, 4 vCPU / 8 GB from the base snapshot,amp orb bootstraprunning. Archive → pause in 2.8 s; delete → sandbox deleted in 2.2 s. - Found by the run and fixed here: Amp's orb ID is
amp-<thread UUID>, notamp-T-<UUID>, so Open thread did not show. - Not yet run: a project thread (snapshot on pause), orb types against real Amp, Remove.
Verify
bun run typecheck,bun run test(255 passed),bun run build.cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo test: 1040 passed.ade::orca::tests::slow_servers_share_one_deadline_and_one_not_read_hides_no_workfails under full-suite load locally, also on main, and passes alone.- The script tests run the dispatch program against a fake
instabox,ampandsystemctl. - Browser preview:
?orbs=setup|signin|connected|free.docs/amp-orbs.mdhas screenshots of it and an Orb sizes section.
🤖 Generated with Claude Code