getzopu 0.0.0-stage → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -2
- package/THIRD_PARTY_NOTICES +48 -0
- package/dist/getzopu.mjs +28068 -0
- package/package.json +37 -4
package/README.md
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Zopu Machine image and development scripts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The only product code baked into a session Machine image (see the repo's `CONTEXT.md` for the Machine vocabulary). Machines are credential-free: `bootstrap` turns boot env into a running sshd and then — via `execve(2)` — the process _becomes_ sshd. Nothing of the CLI lingers.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
### `zopu machine bootstrap`
|
|
8
|
+
|
|
9
|
+
1. Reads `SSH_AUTHORIZED_KEY` from env (passed by the provisioning layer — ticket 5's Box `env`), writes it to `~/.ssh/authorized_keys` (0600).
|
|
10
|
+
2. `ssh-keygen -A` — fresh host keys per Machine (the image bakes none).
|
|
11
|
+
3. Prepares the cache tree on the `/workspace` volume (mkdir `/workspace/.zopu-cache/{npm,bun,pip,browsers,xdg}` + `~` cache-path symlinks) and fires one detached best-effort `cache prune`.
|
|
12
|
+
4. `exec sshd -D -e` — foreground sshd, logs to stderr.
|
|
13
|
+
|
|
14
|
+
Requires node ≥ 24 (`process.execve`).
|
|
15
|
+
|
|
16
|
+
### `zopu machine cache prune [--budget-gib=N]`
|
|
17
|
+
|
|
18
|
+
Brings the disposable caches (npm/bun/pip under `/workspace/.zopu-cache`) back under the combined soft budget (default 2 GiB) by deleting oldest-first. Skips — exit 0 — while an installer process is alive or another prune holds the lock; never touches source trees, `node_modules`, `browsers`/`xdg`, or entries written in the last 10 minutes. Run by the server's idle path before suspend/stop (failure never blocks power-off; older images without the subcommand degrade on stderr only) and once per boot. `ZOPU_CACHE_ROOT` relocates the tree for dev hosts.
|
|
19
|
+
|
|
20
|
+
## The image (`image/Dockerfile`)
|
|
21
|
+
|
|
22
|
+
Debian slim + `openssh-server` (hardened via `sshd_config.d` drop-in: `internal-sftp`, no password auth, root only via key) plus the dev toolchain agent sessions need — and nothing that listens:
|
|
23
|
+
|
|
24
|
+
| Need | On the image |
|
|
25
|
+
| ---------------- | --------------------------------------------------------------------------------------------- |
|
|
26
|
+
| JS runtimes | node 24 (base image), Bun (pinned via `BUN_VERSION`, multi-arch from oven-sh releases) |
|
|
27
|
+
| Python | `python3` + `python3-venv` + `python3-pip` |
|
|
28
|
+
| Build essentials | `build-essential`, `pkg-config` (native npm/pip deps) |
|
|
29
|
+
| Network/fetch | `curl`, `wget`, `jq`, `iputils-ping`, `dnsutils`, `netcat-openbsd`, `rsync`, `openssh-client` |
|
|
30
|
+
| Archive | `zip`, `unzip`, `xz-utils`, `zstd`, `bzip2` |
|
|
31
|
+
| Process/stream | `procps`, `lsof`, `less`, `file`, `tree`, `tmux` |
|
|
32
|
+
| Search/VCS | `git`, `ripgrep` |
|
|
33
|
+
| Headless browser | `chromium` + liberation/Noto-color-emoji fonts, `PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium` |
|
|
34
|
+
|
|
35
|
+
Browsers run headless as root: pass `--no-sandbox` (and `executablePath: "/usr/bin/chromium"` for puppeteer-core; Playwright can use the same binary via `channel: "chrome"` or `executablePath`). No display/VNC, no code-server, no listening servers beyond sshd — the agent reaches the box over the existing SSH channel, which stays the only door.
|
|
36
|
+
|
|
37
|
+
### Caches on the volume, runtimes on the image
|
|
38
|
+
|
|
39
|
+
Disposal caches never fill the rootfs: `/etc/environment` points `NPM_CONFIG_CACHE`, `BUN_INSTALL_CACHE_DIR`, `PIP_CACHE_DIR`, `PLAYWRIGHT_BROWSERS_PATH`, and `XDG_CACHE_HOME` at `/workspace/.zopu-cache/{npm,bun,pip,browsers,xdg}` — on a Machine that tree sits on the 15 GiB `/workspace` volume, and `bootstrap` recreates the dirs plus `~/.npm`, `~/.bun/install/cache`, `~/.cache/pip`, `~/.cache/ms-playwright` symlinks into it at every boot (rootfs resets on stop→start; the volume persists). `zopu machine cache prune [--budget-gib=N]` keeps npm+bun+pip under a combined 2 GiB soft budget (oldest-first; skips — exit 0 — while an installer runs or another prune holds the lock; never touches `browsers`, `xdg`, source trees, node_modules, or entries younger than 10 min). The server runs it on the idle path before suspend/stop, and bootstrap fires one best-effort detached prune per boot.
|
|
40
|
+
|
|
41
|
+
## Local fake Machine (`scripts/dev-machine.sh`)
|
|
42
|
+
|
|
43
|
+
The optional Docker fake Machine exposes SSH on **127.0.0.1:2222** and provisions through `MACHINE_DEV=local`, not the remote broker. The Docker-free default uses port 2230 (below). The tracked image pin (`zopu-threads/src/machine/provisioning.ts`) was removed with the actor package on 2026-11-18; without `MACHINE_DEV_IMAGE` the helper now always builds the local image from `apps/cli`. Re-running the container helper replaces its local container. It does not attach a workspace volume unless explicitly supplied.
|
|
44
|
+
|
|
45
|
+
## Docker-free fake Machine (`scripts/dev-machine-local.sh`)
|
|
46
|
+
|
|
47
|
+
Same contract, no container runtime: a **standalone sshd instance on the host** (default **127.0.0.1:2230**) that the dev profile provisions against. Any Linux host with `openssh-server` qualifies — including a session Box, whose own sshd already owns 2222 (that's why the default differs and why the provisioning dev profile honors `MACHINE_DEV_PORT`). The script shares dev-machine.sh's keypair under `.dev/`, regenerates host keys per run (fresh-boot semantics), writes the managed `MACHINE_DEV*` block (now including `MACHINE_DEV_PORT`) into `apps/server/.env.local`, and needs nothing but sshd — no Docker, no image pull. Teardown: `kill $(cat .dev/sshd-local.pid)`.
|
|
48
|
+
|
|
49
|
+
Trade-offs vs the Docker fake Machine: no isolation (it runs on the host filesystem) and no image-exact rootfs — the host's toolchain plays the Machine. For flow testing (provision → SSH exec → pi extension → git loop) it is equivalent: the host needs git, node, and `zopu` on PATH, which every session Box already has.
|
|
50
|
+
|
|
51
|
+
## Publishing
|
|
52
|
+
|
|
53
|
+
The CLI package is `getzopu` in `apps/cli` (Node 24+), named for its command so that `npx getzopu …`
|
|
54
|
+
needs no `--package`; it provides the `getzopu` and `zopu` executables. Install with
|
|
55
|
+
`npm install -g getzopu`, or run `npx getzopu machines connect` to connect the computer you are on.
|
|
56
|
+
`scripts/publish-cli.sh` builds it, shows what would go out (`npm pack --dry-run`), and publishes
|
|
57
|
+
with `npm publish --access public`; it takes `NPM_TOKEN` from the environment. Nothing is published
|
|
58
|
+
from a tree that is not green on `master`.
|
|
59
|
+
|
|
60
|
+
### Machines
|
|
61
|
+
|
|
62
|
+
`getzopu machines connect [--name <name>] [--url <url>]` pairs the computer when it has no
|
|
63
|
+
credential — a page to sign in to, a six-digit code to type there — keeps the credential in
|
|
64
|
+
`~/.config/zopu/machine/credential.json` (mode `0600`), and then runs the satellite in the
|
|
65
|
+
foreground until Ctrl-C. The satellite (`packages/machines/src/satellite/`) dials out to
|
|
66
|
+
`/ws/machines` with the credential as a bearer, comes back by itself after a drop (at once the
|
|
67
|
+
first time, then on a ladder from 1 s to 30 s), and keeps a journal of every command it ran
|
|
68
|
+
(`~/.config/zopu/machine/journal/`), so a command that outlives a drop is picked up where it was.
|
|
69
|
+
Commands run as the user, in a process group of their own; nothing is scoped.
|
|
70
|
+
`getzopu machines status` says whether the computer is connected; `getzopu machines disconnect`
|
|
71
|
+
revokes it on the server and forgets the credential.
|
|
72
|
+
|
|
73
|
+
The image uses `apps/cli` as its build context and embeds the exact self-contained `dist/getzopu.mjs` plus package metadata. The machine-image publish flow (`../infra/scripts/publish-machine-image.sh`, catalog sync, and the `provisioning.ts` digest pin) was removed with the actor package on 2026-11-18; already-published images keep running, but there is no source pin or publish script until provisioning is rebuilt. Image CMD owns bootstrap, so existing pinned images keep their original boot command until replaced.
|
|
74
|
+
|
|
75
|
+
Every harness open installs the unified CLI over SFTP before git/project work, including no-project threads. SHA-256 checks avoid unnecessary copies; activation is atomic. Thread automation grants remain project-scoped and private. npm publication uses `scripts/publish-cli.sh` with `NPM_TOKEN` supplied privately; only the built artifact and package metadata are published, with no runtime dependencies or lifecycle scripts.
|
|
76
|
+
|
|
77
|
+
### Versioning policy
|
|
78
|
+
|
|
79
|
+
- Image tag ↔ CLI version, one-to-one: image `v0.1.0` baked the then-current CLI at `0.1.0` (the build arg enforces the pairing).
|
|
80
|
+
- Tags are immutable in practice: never re-push an existing tag; cut a new version instead.
|
|
81
|
+
- Deployments pin by digest (the script prints it) — Fly's registry garbage-collects unreferenced tags, and zopu-infra's Catalog (ADR-0015) records the digest as the durable identity anyway.
|
|
82
|
+
|
|
83
|
+
### After a push
|
|
84
|
+
|
|
85
|
+
zopu-infra must run an `imageSync` for repository `zopu-codepi-machine` before `boxCreate` accepts the new tag — the Catalog gate. `catalogOverride` exists as the escape hatch; the sync is the policy.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
This executable bundles portions of @orpc/client, @orpc/shared,
|
|
2
|
+
@orpc/standard-server and @orpc/standard-server-fetch, and of effect.
|
|
3
|
+
|
|
4
|
+
effect
|
|
5
|
+
|
|
6
|
+
MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2023 Effectful Technologies Inc
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
MIT License
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2023 oRPC
|
|
31
|
+
|
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
33
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
34
|
+
in the Software without restriction, including without limitation the rights
|
|
35
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
37
|
+
furnished to do so, subject to the following conditions:
|
|
38
|
+
|
|
39
|
+
The above copyright notice and this permission notice shall be included in all
|
|
40
|
+
copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
SOFTWARE.
|