Repository navigation
feat(sandbox): add setup amp for Amp self-hosted orbs - #104
Merged
Merged
Conversation
createos sandbox setup amp runs Amp's orb provider so each Amp thread gets its own sandbox: spawn creates or resumes it, pause keeps disk and memory, delete removes it. Orbs boot from an amp-orb template built on first use from an embedded Dockerfile, falling back to devbox:1 plus in-place setup while it is not ready. The API has no lookup by name and lists every sandbox ever made, so orbs are found by listing each live status. Jobs for one orb are serialized with flock and bounded by one deadline under Amp's 5 min. ORB_TOKEN travels in a request body, with debug logging off for it. amp_e2e_test.go (build tag e2e) drives the real binary live: 41 checks including pause/resume races and an unreachable API.
A real Amp thread on devbox:1 answered 'Node.js: command not found'. /usr/local/bin/node there links into /root (mode 700), so root saw Node and the orb's user did not, and setup skipped the install. Setup now judges each tool as user. The e2e test checks tools as user too. Installing Node also took up to 165 s. archive.ubuntu.com answers from 9 servers, and 2 of them need 15-30 s for one small file. Ubuntu orbs now use mirrors.edge.kernel.org (0.09 s steady) with 10 s apt timeouts and 3 retries.
End-user setup for 'createos sandbox setup amp', written from a real run against Amp: workspace and provider creation, token handling, what the provider prints, lifecycle timings, troubleshooting.
From a Codex review of PR #104: - One wrapper per --shape/--template, so two providers under one account never run each other's settings. - Let amp drain running jobs on stop: wait the full job deadline, not 10 s, before killing it. A stop on request now exits 0, not with 'context canceled'. - Guide: set the token file to 0600 even when it already exists.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
createos sandbox setup ampruns Amp's self-hosted orb provider on CreateOS. Each Amp thread gets its own sandbox:spawncreates or resumes it,pausekeeps disk and memory,deleteremoves it.End-user guide:
docs/amp.md.How it works
Same two-halves shape as
setup orca:amp, and the token, writes a one-line wrapper to~/.createos/amp-dispatch-<shape>-<template>(Amp takes a program path, not a command line; one file per setting so two providers never share one), then runsamp orb provideron it.--dispatch): run by Amp once per job, selected byORB_OPERATION.resolveSandboxRef(200 newest) misses old paused orbs?status=filters server-side)ORB_IDis longeramp-+ 18 hex ofsha256(ORB_ID)ORB_TOKEN="",AMP_URL=""FROM nodeops/sandbox:*, noCOPY/ADDamp-orb.Dockerfilerebuilds Amp's image contract withRUN; built on first use,devbox:1+ in-place setup as fallbackflock(released by the kernel even on SIGKILL)ORB_TOKENdevbox:1,/usr/local/bin/nodelinks into/root(0700): root sees Node, the orb'suserdoes notuserarchive.ubuntu.com: 2 of 9 servers take 15–30 s per small file, turning a 4 s install into ~3 minmirrors.edge.kernel.org(0.09 s steady), apt timeout 10 s, 3 retriesTesting
Unit tests (7): naming, flag validation, the wrapper's exact argv (path with a space and a quote), one wrapper per setting, template rules, setup packages matching the Dockerfile, the lock.
Live e2e (
amp_e2e_test.go, build tage2e, sogo test ./...never creates sandboxes): builds the binary and drives it the way Amp does. 43/43 checks on 3 parallel runs (2 on thedevbox:1fallback, 1 on a ready template): every job, repeats, unreachable API, stale-bootstrap cleanup,AMP_URL, disk and memory across pause, spawn-during-pausing, pause-during-resuming, tools usable byuser.Real Amp thread in tmux, with a real provider token:
usergolangci-lint0 issues; builds for Windows (setup amprefuses there); gosec adds nothing new.govulncheck reports 19 Go stdlib issues for the pinned Go 1.26.3, identical on
main. Not from this change; bumping Go is a separate fix.Known issues / not in this PR
FROM-only, ~0.7 s, empty log), so every orb bootsdevbox:1and sets up in place. Reported to the control-plane owner with template id and request ids. Nothing needed here once it is fixed.ORB_SNAPSHOT_IDis ignored (allowed by Amp's contract). No Desktop tab.Mesh
Docs page
Integrations/Amp.mdxadded increateos-v2-landing(committed locally, not pushed).createos-plugincarries nothing for Amp.