pi-microsandbox 0.1.0
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/LICENSE +21 -0
- package/README.md +120 -0
- package/SECURITY.md +58 -0
- package/docs/commands.md +38 -0
- package/docs/configuration.md +80 -0
- package/docs/development.md +119 -0
- package/docs/getting-started.md +66 -0
- package/docs/images.md +190 -0
- package/docs/safety.md +39 -0
- package/docs/storage.md +57 -0
- package/docs/troubleshooting.md +20 -0
- package/extensions/pi-msb/command.ts +532 -0
- package/extensions/pi-msb/config.ts +771 -0
- package/extensions/pi-msb/control.ts +803 -0
- package/extensions/pi-msb/footer.ts +191 -0
- package/extensions/pi-msb/git.ts +256 -0
- package/extensions/pi-msb/index.ts +156 -0
- package/extensions/pi-msb/labels.ts +321 -0
- package/extensions/pi-msb/locks.ts +292 -0
- package/extensions/pi-msb/operations-exec.ts +434 -0
- package/extensions/pi-msb/operations.ts +321 -0
- package/extensions/pi-msb/prune.ts +232 -0
- package/extensions/pi-msb/sandbox-manager.ts +702 -0
- package/extensions/pi-msb/skill-access.ts +164 -0
- package/extensions/pi-msb/storage.ts +332 -0
- package/extensions/pi-msb/tools.ts +417 -0
- package/extensions/pi-msb/transport.ts +518 -0
- package/extensions/pi-msb/types.ts +436 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 pi-microsandbox contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# pi-microsandbox
|
|
2
|
+
|
|
3
|
+
**Let your agents work. Stop babysitting every command.**
|
|
4
|
+
|
|
5
|
+
Give an agent a task and get on with your day. Give a few agents different tasks
|
|
6
|
+
and let them work in parallel. Come back to review the results.
|
|
7
|
+
|
|
8
|
+
pi-microsandbox uses [Microsandbox](https://microsandbox.dev/) to run
|
|
9
|
+
[Pi](https://github.com/earendil-works/pi)'s file and shell tools in lightweight
|
|
10
|
+
microVMs. Microsandbox is an open-source, local-first runtime for isolating
|
|
11
|
+
untrusted workloads, with a separate Linux kernel for each sandbox.
|
|
12
|
+
|
|
13
|
+
In Git mode, each separate Pi session gets its own workspace instead of editing
|
|
14
|
+
your host checkout. Each project can define its own environment and safety
|
|
15
|
+
boundaries. Set them up once, then let the agents get to work.
|
|
16
|
+
|
|
17
|
+
[Get started](#get-started) · [Documentation](#documentation) · [Releases](https://github.com/hcohe/pi-microsandbox/releases)
|
|
18
|
+
|
|
19
|
+
## Less supervision. More work getting done.
|
|
20
|
+
|
|
21
|
+
- Run multiple agents in separate Pi sessions. Git mode keeps their workspaces apart, so ordinary sandboxed edits don't collide in your host checkout.
|
|
22
|
+
- Let routine file and shell work happen inside the sandbox. Host execution stays an explicit escape, with approval required while the sandbox is active.
|
|
23
|
+
- Step away without throwing away the work. Git-mode files survive sandbox shutdown, ready when you resume the matching session.
|
|
24
|
+
- If the sandbox can't start, routed tools stop by default. They don't quietly run on your host instead.
|
|
25
|
+
|
|
26
|
+
You still review what the agents produce. The point is to spend your attention
|
|
27
|
+
on the results, rather than supervise every step along the way.
|
|
28
|
+
|
|
29
|
+
## Every project gets its own boundaries
|
|
30
|
+
|
|
31
|
+
Your frontend app and your internal service don't need the same sandbox.
|
|
32
|
+
Choose a [published variant or custom image](docs/images.md) with the tools a
|
|
33
|
+
project needs, allow only the network hosts it should reach, and configure its
|
|
34
|
+
file mounts and secrets. Another project can have a completely different setup,
|
|
35
|
+
including no network access.
|
|
36
|
+
|
|
37
|
+
Keep your everyday defaults in global config and project-specific settings in
|
|
38
|
+
`.pi-msb.toml`. Trusted project config layers over those defaults; environment
|
|
39
|
+
variables and session overrides let you adjust a particular run without
|
|
40
|
+
rewriting the project's setup.
|
|
41
|
+
|
|
42
|
+
The agent gets an environment built for the job. You don't have to make the
|
|
43
|
+
same decisions every time you start it.
|
|
44
|
+
|
|
45
|
+
[Configure your project's sandbox →](docs/configuration.md)
|
|
46
|
+
|
|
47
|
+
## Get started
|
|
48
|
+
|
|
49
|
+
You'll need Pi, **Node.js 22.19.0+**, and either an Apple Silicon Mac or Linux
|
|
50
|
+
with accessible KVM. Installation also needs Python and a C/C++ build toolchain;
|
|
51
|
+
keep lifecycle scripts and optional dependencies enabled.
|
|
52
|
+
[Full requirements and installation help →](docs/getting-started.md)
|
|
53
|
+
|
|
54
|
+
Install the Microsandbox CLI first:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
curl -fsSL https://install.microsandbox.dev | sh
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
For alternate installation methods and any Microsandbox-specific setup,
|
|
61
|
+
runtime, or troubleshooting details, use the official
|
|
62
|
+
[Microsandbox documentation](https://docs.microsandbox.dev/). The documentation
|
|
63
|
+
in this repository covers the Pi integration.
|
|
64
|
+
|
|
65
|
+
Then install pi-microsandbox:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
pi install npm:pi-microsandbox
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
From a Git repository, start Pi with its own isolated workspace:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
PI_MSB_MODE=git pi
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Git mode starts from committed `HEAD`. Commit any changes you want the agent to
|
|
78
|
+
see first; untracked files such as `.env` and uncommitted edits stay out of the
|
|
79
|
+
initial copy. An existing retained workspace is reused for a matching session.
|
|
80
|
+
|
|
81
|
+
Once you're in Pi:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
/msb status
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Give Pi a task. To work on another task in parallel, start a separate Pi session
|
|
88
|
+
with the same command in another terminal. Each session gets its own Git-mode
|
|
89
|
+
workspace.
|
|
90
|
+
|
|
91
|
+
When you're ready to review an agent's work, export a file to a new destination:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
/msb export src/example.ts --to ../sandbox-review
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Exports ask for confirmation and won't overwrite existing destinations.
|
|
98
|
+
See [storage and retained work](docs/storage.md) for the details.
|
|
99
|
+
|
|
100
|
+
> **Choose your boundary.** The default storage mode is `direct`, which writes
|
|
101
|
+
> to your host directory. The command above explicitly selects `git` isolation.
|
|
102
|
+
> `/msb off` turns sandboxing off; `fallback_mode = "host"` opts into automatic
|
|
103
|
+
> host execution after a failure. Neither is sandboxed.
|
|
104
|
+
|
|
105
|
+
## Documentation
|
|
106
|
+
|
|
107
|
+
| When you want to… | Read |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| Install or check host support | [Getting started](docs/getting-started.md) |
|
|
110
|
+
| Choose a workspace mode or recover retained work | [Storage](docs/storage.md) |
|
|
111
|
+
| Choose an image variant or build a custom image | [Images](docs/images.md) |
|
|
112
|
+
| Set up networking, secrets, mounts, or other options | [Configuration](docs/configuration.md) |
|
|
113
|
+
| Look up an `/msb` command | [Command reference](docs/commands.md) |
|
|
114
|
+
| Understand the isolation boundary and host access | [Safety model](docs/safety.md) |
|
|
115
|
+
| Fix a sandbox that won't start | [Troubleshooting](docs/troubleshooting.md) |
|
|
116
|
+
| Run tests or work on the extension | [Development](docs/development.md) |
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
[MIT license](LICENSE) · [Report a bug](https://github.com/hcohe/pi-microsandbox/issues) · [Report a security issue privately](SECURITY.md)
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
Before the first npm publication, security fixes are made only on the `main`
|
|
6
|
+
branch. After publication, only the latest version of `pi-microsandbox`
|
|
7
|
+
published on npm is supported. Older releases and unreleased forks are not
|
|
8
|
+
supported; users should upgrade before reporting a problem that may already be
|
|
9
|
+
fixed.
|
|
10
|
+
|
|
11
|
+
## Report a vulnerability privately
|
|
12
|
+
|
|
13
|
+
Do not open a public issue, discussion, or pull request for a suspected
|
|
14
|
+
vulnerability. Use GitHub's private vulnerability reporting for this repository:
|
|
15
|
+
|
|
16
|
+
<https://github.com/hcohe/pi-microsandbox/security/advisories/new>
|
|
17
|
+
|
|
18
|
+
In the repository UI, this is **Security → Advisories → Report a
|
|
19
|
+
vulnerability**. This route is available to outside reporters after the
|
|
20
|
+
repository is public and private vulnerability reporting has been enabled. While
|
|
21
|
+
the repository remains private, only people who already have appropriate
|
|
22
|
+
repository access can use its private security-advisory workflow. If the link is
|
|
23
|
+
not available, do not substitute a public report or disclose the issue in a
|
|
24
|
+
public channel.
|
|
25
|
+
|
|
26
|
+
A useful report includes the affected pi-microsandbox version or commit, Pi and
|
|
27
|
+
Node.js versions, host operating system and architecture, virtualization setup,
|
|
28
|
+
impact, and minimal reproduction steps. State whether the behavior requires a
|
|
29
|
+
particular storage mode, network policy, fallback setting, or host-execution
|
|
30
|
+
approval.
|
|
31
|
+
|
|
32
|
+
## Keep sensitive data out of reports
|
|
33
|
+
|
|
34
|
+
Provide only the minimum redacted evidence needed to reproduce the issue. Do
|
|
35
|
+
not include:
|
|
36
|
+
|
|
37
|
+
- passwords, API keys, npm tokens, cloud credentials, signing material, or
|
|
38
|
+
unredacted environment variables;
|
|
39
|
+
- resolved secret values from `$ENV:` or `$FILE:` references;
|
|
40
|
+
- complete sandbox logs, configuration dumps, session files, or command output
|
|
41
|
+
that may contain secrets;
|
|
42
|
+
- retained-volume contents, source code, `.env` files, or other private user
|
|
43
|
+
data that is not essential to the report.
|
|
44
|
+
|
|
45
|
+
If a real secret may have been exposed, revoke or rotate it first. Use synthetic
|
|
46
|
+
values in the reproduction and describe omitted material rather than attaching
|
|
47
|
+
it. Remember that GitHub advisory participants can read uploaded artifacts, so
|
|
48
|
+
a private report is not a reason to include unnecessary secrets.
|
|
49
|
+
|
|
50
|
+
## What happens next
|
|
51
|
+
|
|
52
|
+
Maintainers will review the private report, ask for redacted clarification when
|
|
53
|
+
needed, validate the impact, and coordinate a fix and disclosure through the
|
|
54
|
+
GitHub advisory. A confirmed issue may result in a patched npm release, a GitHub
|
|
55
|
+
security advisory, and release notes. GitHub Releases are the canonical
|
|
56
|
+
changelog. Response and remediation times depend on severity, reproducibility,
|
|
57
|
+
and maintainer availability; this policy does not promise a fixed response
|
|
58
|
+
time.
|
package/docs/commands.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Command reference
|
|
2
|
+
|
|
3
|
+
[Back to README](../README.md)
|
|
4
|
+
|
|
5
|
+
The extension registers `/msb`:
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
/msb status
|
|
9
|
+
/msb on | off | reload
|
|
10
|
+
/msb prune
|
|
11
|
+
/msb volumes ls
|
|
12
|
+
/msb volumes rm <managed-name> [--yes]
|
|
13
|
+
/msb export <paths...> [--to dir] [--yes]
|
|
14
|
+
/msb logs [tail-lines]
|
|
15
|
+
/msb config
|
|
16
|
+
/msb set <key> <value>
|
|
17
|
+
/msb unset <key>
|
|
18
|
+
/msb reset
|
|
19
|
+
/msb network allow <host...> | deny
|
|
20
|
+
/msb seal
|
|
21
|
+
/msb mount add <json|hostPath guestPath [--readonly]>
|
|
22
|
+
/msb mount rm <guest-path>
|
|
23
|
+
/msb help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`/msb status` reports the full sandbox name, mode, image, PID, age, branch/SHA,
|
|
27
|
+
and retained volume metadata when available. Six-character IDs in UI text are
|
|
28
|
+
display abbreviations only. `/msb prune` walks all SDK list pages and reports
|
|
29
|
+
removed, kept, and error entries; **volumes are never pruned**.
|
|
30
|
+
|
|
31
|
+
Volume removal is the sole destructive volume path. It requires a managed,
|
|
32
|
+
unmounted volume and an owner lock. Confirmation displays path, branch, last
|
|
33
|
+
commit, and dirty-count metadata; use `--yes` only when the command is running
|
|
34
|
+
without UI and the target has already been verified. Export rejects paths outside
|
|
35
|
+
the project and existing destinations; it also requires confirmation or
|
|
36
|
+
`--yes`.
|
|
37
|
+
|
|
38
|
+
For the narrow exceptions to sandboxed file reads, see [host-read exceptions](safety.md#host-read-exceptions).
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
[Back to README](../README.md)
|
|
4
|
+
|
|
5
|
+
The precedence is defaults < global < trusted project < environment < session
|
|
6
|
+
CLI overrides. Global configuration is `$XDG_CONFIG_HOME/pi-msb/config.toml`
|
|
7
|
+
(or `~/.config/pi-msb/config.toml`) plus the optional `PI_MSB_CONFIG_FILE` in
|
|
8
|
+
the same layer. A trusted project may use the nearest `.pi-msb.toml` or
|
|
9
|
+
`<Pi CONFIG_DIR_NAME>/msb.toml`, stopping at the Git root. Untrusted project
|
|
10
|
+
configuration is ignored with a warning.
|
|
11
|
+
|
|
12
|
+
TOML uses snake_case; environment variables use `PI_MSB_` with `__` for nesting.
|
|
13
|
+
The following is a small project example:
|
|
14
|
+
|
|
15
|
+
```toml
|
|
16
|
+
# .pi-msb.toml
|
|
17
|
+
mode = "git"
|
|
18
|
+
image = "ghcr.io/hcohe/pi-microsandbox:1.0.0@sha256:00ea1e0911189815614e8a8eee36d1fd64f0f1edb39492e0bda9f273c834e59f"
|
|
19
|
+
pull_policy = "if-missing"
|
|
20
|
+
bootstrap_tools = "auto"
|
|
21
|
+
idle_timeout_sec = 600
|
|
22
|
+
fallback_mode = "block"
|
|
23
|
+
show_footer = true # Default; set false to hide the MSB footer status.
|
|
24
|
+
|
|
25
|
+
[network]
|
|
26
|
+
mode = "default" # default | open | allowlist | deny
|
|
27
|
+
allow_dns = true
|
|
28
|
+
|
|
29
|
+
# Project secrets should use references, not literals.
|
|
30
|
+
[[secrets]]
|
|
31
|
+
env = "NPM_TOKEN"
|
|
32
|
+
value = "$ENV:NPM_TOKEN"
|
|
33
|
+
allow_hosts = ["registry.npmjs.org"]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Important configuration behavior:
|
|
37
|
+
|
|
38
|
+
- `show_footer = true` uses Pi's single custom-footer slot so the MSB status can
|
|
39
|
+
appear in the upper-right corner. It replaces Pi's built-in footer (or another
|
|
40
|
+
extension's custom footer), preserves the standard location, usage, model,
|
|
41
|
+
and shared status fields, but cannot show Pi-only indicators such as the
|
|
42
|
+
auto-compaction and experimental-feature markers.
|
|
43
|
+
- The default image is the complete Node.js, Python, Rust, and Go `1.0.0`
|
|
44
|
+
variant, pinned to its immutable multi-platform digest. Image releases have
|
|
45
|
+
an independent version stream; the initial package remains `0.1.0`. The
|
|
46
|
+
default `pull_policy = "if-missing"` pulls only when that exact reference is
|
|
47
|
+
absent from the Microsandbox cache. `"always"` and `"never"` are also
|
|
48
|
+
supported.
|
|
49
|
+
See [Images](images.md) for all published variants, exact tag patterns,
|
|
50
|
+
contents, custom image workflows, and the required guest commands.
|
|
51
|
+
`bootstrap_tools = "auto"` probes those commands and uses noninteractive
|
|
52
|
+
`apt-get` under the configured network policy when a custom image is missing
|
|
53
|
+
them. `false` blocks with the missing command list instead.
|
|
54
|
+
- `network.mode = "default"` leaves the SDK's default policy in place. `open`
|
|
55
|
+
allows all network traffic, including private/host access; `allowlist` is
|
|
56
|
+
default-deny with configured host/DNS rules; `deny` disables networking.
|
|
57
|
+
Published ports default to loopback unless a bind address is specified.
|
|
58
|
+
- Secrets require a non-empty `allow_hosts` list. `$ENV:NAME` and `$FILE:path`
|
|
59
|
+
references are resolved only while constructing the SDK builder. Effective
|
|
60
|
+
config, warnings, errors, and `/msb config` redact literal values.
|
|
61
|
+
- Directory/file mounts have absolute guest paths. Project mounts outside the
|
|
62
|
+
repository must be read-only unless a global/session policy authorizes the
|
|
63
|
+
write. Mounts may not overlap or shadow the project mount or reserved `/tmp`.
|
|
64
|
+
- The legacy `host_ro_allowlist` is converted to canonical read-only mounts and
|
|
65
|
+
emits a deprecation warning.
|
|
66
|
+
|
|
67
|
+
Useful environment controls include:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
PI_MSB_DISABLE=1 # explicit host/off mode
|
|
71
|
+
PI_MSB_MODE=none # nested scalar example
|
|
72
|
+
PI_MSB_PULL_POLICY=always # recheck mutable custom image tags on creation
|
|
73
|
+
PI_MSB_NETWORK__MODE=deny # nested environment key
|
|
74
|
+
PI_MSB_FALLBACK_MODE=host # opt into automatic host fallback
|
|
75
|
+
PI_MSB_SHOW_FOOTER=false # hide the MSB status from Pi's footer
|
|
76
|
+
PI_MSB_ROUTE_TOOLS='read,write' # POSIX delimiter for simple arrays
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Do not put resolved secret values in session overrides, logs, issue reports, or
|
|
80
|
+
shell history.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Development and releases
|
|
2
|
+
|
|
3
|
+
[Back to README](../README.md)
|
|
4
|
+
|
|
5
|
+
This release requires Node.js 22.19.0 or newer. The development toolchain pins Pi 0.84.4, and the runtime dependency is pinned exactly to `microsandbox` 0.6.16.
|
|
6
|
+
|
|
7
|
+
## Local development
|
|
8
|
+
|
|
9
|
+
To test from source without installing the npm package globally:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
git clone https://github.com/hcohe/pi-microsandbox.git
|
|
13
|
+
cd pi-microsandbox
|
|
14
|
+
|
|
15
|
+
# fs-ext must compile during installation; do not use --ignore-scripts.
|
|
16
|
+
npm ci
|
|
17
|
+
npm run typecheck
|
|
18
|
+
npm test
|
|
19
|
+
npm run smoke # extension-load smoke; no sandbox starts
|
|
20
|
+
npm run check # all three commands above
|
|
21
|
+
npm audit --omit=dev
|
|
22
|
+
npm pack --dry-run --json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The smoke and unit tests do not require KVM, image pulls, or a live sandbox.
|
|
26
|
+
The boot-speed check and live matrix below are explicit VM tests.
|
|
27
|
+
|
|
28
|
+
## Boot speed regression test
|
|
29
|
+
|
|
30
|
+
With [`just`](https://just.systems/) installed, measure the awaited sandbox boot
|
|
31
|
+
path against its regression limit:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
just test-boot-speed
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The tool performs one unmeasured warm-up, then three fresh boots using the
|
|
38
|
+
default prepared image. It forces direct mode, disables guest networking and
|
|
39
|
+
stale-resource pruning, and sets `bootstrap_tools = false` so the result
|
|
40
|
+
measures repeat boot and readiness rather than an image pull or package install.
|
|
41
|
+
The p95 must be at most 2,000 ms. Every sandbox is shut down and removed. If
|
|
42
|
+
lifecycle cleanup fails, the test fails and retains its reported `.tmp` directory
|
|
43
|
+
for recovery instead of claiming success.
|
|
44
|
+
|
|
45
|
+
Run the tool directly to change the image, sample count, warm-ups, or limit:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
node --experimental-strip-types scripts/test-boot-speed.mjs \
|
|
49
|
+
--image ghcr.io/hcohe/pi-microsandbox:latest \
|
|
50
|
+
--warmups 1 \
|
|
51
|
+
--runs 5 \
|
|
52
|
+
--max-ms 2000
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Use `--json` for machine-readable output and `--help` for the complete option
|
|
56
|
+
list. This is a real VM test and requires the same host virtualization support
|
|
57
|
+
as the live matrix.
|
|
58
|
+
|
|
59
|
+
## Live test matrix
|
|
60
|
+
|
|
61
|
+
From a source checkout, the live matrix is opt-in because it can pull an image,
|
|
62
|
+
start VMs, create retained resources, and use network and disk capacity. Run it
|
|
63
|
+
only from a trusted checkout on a disposable test host after reviewing the
|
|
64
|
+
script:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
PI_MSB_LIVE_TEST=1 ./scripts/e2e-smoke.sh
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Without that variable the script prints a `SKIP` line for every scenario and
|
|
71
|
+
exits successfully; this skip path does not validate virtualization. If
|
|
72
|
+
virtualization is unavailable, it prints the reason and skips the matrix rather
|
|
73
|
+
than reporting false failures. Set `PI_MSB_LIVE_IMAGE` to select the main live
|
|
74
|
+
test image; the default is `ghcr.io/hcohe/pi-microsandbox:latest`.
|
|
75
|
+
The prepared-image scenario boots all six latest variant tags under
|
|
76
|
+
`network.mode = "deny"` with bootstrap disabled. Set
|
|
77
|
+
`PI_MSB_LIVE_PREPARED_IMAGES` to a comma-separated image cohort, or use the
|
|
78
|
+
legacy singular `PI_MSB_LIVE_PREPARED_IMAGE` to test one image. The live matrix
|
|
79
|
+
uses `pull_policy = "always"` intentionally so mutable development tags cannot
|
|
80
|
+
remain stale on the self-hosted runner. Review the output to confirm that all 16 scenarios report
|
|
81
|
+
`PASS`, not `SKIP`.
|
|
82
|
+
|
|
83
|
+
## Image development
|
|
84
|
+
|
|
85
|
+
The image workflow derives the `base`, `node`, `python`, `rust`, `go`, and
|
|
86
|
+
`default` build matrix from `default-image/variants.json`. Pull requests build
|
|
87
|
+
and verify all six variants for AMD64 and ARM64. Main-branch builds publish each
|
|
88
|
+
variant's mutable latest tag and a commit-specific tag. Release builds pin the
|
|
89
|
+
Ubuntu image digest and one dated apt snapshot for all variants, while published
|
|
90
|
+
images restore normal apt sources for project use. See [Images](images.md#add-a-language-variant)
|
|
91
|
+
for the modular installer and verifier architecture, contribution rules, and
|
|
92
|
+
local validation commands.
|
|
93
|
+
|
|
94
|
+
## Releases
|
|
95
|
+
|
|
96
|
+
[GitHub Releases](https://github.com/hcohe/pi-microsandbox/releases) are the
|
|
97
|
+
canonical changelog. The first npm publication is a human-run local publish of
|
|
98
|
+
the reviewed tarball with interactive npm 2FA. Subsequent releases publish
|
|
99
|
+
directly to npm with OIDC only after a maintainer publishes the matching GitHub
|
|
100
|
+
Release and approves the protected `npm` GitHub Environment. Release automation
|
|
101
|
+
must not use a long-lived npm token.
|
|
102
|
+
|
|
103
|
+
The sandbox image workflow publishes all six AMD64 and ARM64 variants to
|
|
104
|
+
`ghcr.io/hcohe/pi-microsandbox`. An `image-vX.Y.Z` Git tag publishes the
|
|
105
|
+
write-once image cohort: `base-X.Y.Z`, `node-X.Y.Z`, `python-X.Y.Z`,
|
|
106
|
+
`rust-X.Y.Z`, `go-X.Y.Z`, and `X.Y.Z` for the default variant. Package tags
|
|
107
|
+
remain `vX.Y.Z` and never start image builds. Manual image workflow runs validate
|
|
108
|
+
only. The workflow refuses to overwrite an existing version tag.
|
|
109
|
+
|
|
110
|
+
Image and package releases are independent. Publish and verify an image cohort
|
|
111
|
+
before changing the extension default to its `VERSION@sha256:DIGEST` reference.
|
|
112
|
+
For the initial release, publish `image-v1.0.0`, pin its default-image digest,
|
|
113
|
+
then release package `v0.1.0`. The npm workflow requires that digest-qualified
|
|
114
|
+
reference, checks it against the public default tag, checks every variant and
|
|
115
|
+
both platforms against the image tag commit, and verifies image provenance
|
|
116
|
+
before publishing. A package
|
|
117
|
+
administrator must make the GHCR package public before the package release so
|
|
118
|
+
both release verification and Microsandbox can pull it without registry
|
|
119
|
+
credentials.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Installation and requirements
|
|
2
|
+
|
|
3
|
+
[Back to README](../README.md)
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
Pi must be installed and running on Node.js 22.19.0 or newer. Live sandboxes
|
|
8
|
+
require one of these hosts:
|
|
9
|
+
|
|
10
|
+
| Host | Architecture | Virtualization requirement |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| macOS | Apple Silicon (arm64) | Apple virtualization support available to the process |
|
|
13
|
+
| Linux | x86_64 or arm64 (GNU) | KVM enabled, with `/dev/kvm` accessible to the process |
|
|
14
|
+
|
|
15
|
+
Windows and Intel macOS are not supported by pi-microsandbox. The upstream
|
|
16
|
+
microsandbox runtime has preview Windows support, but this package deliberately
|
|
17
|
+
declares only macOS and Linux. A Linux container or virtual machine also needs
|
|
18
|
+
KVM passthrough or nested virtualization; many hosted environments do not
|
|
19
|
+
provide it. Package loading and non-live tests do not require virtualization.
|
|
20
|
+
|
|
21
|
+
Installation must run lifecycle scripts and include optional dependencies:
|
|
22
|
+
|
|
23
|
+
- `fs-ext@2.1.1` compiles a native node-gyp module. Install Python and a working
|
|
24
|
+
C/C++ build toolchain (`xcode-select --install` on macOS, or a compiler,
|
|
25
|
+
`make`, and Python 3 on Linux).
|
|
26
|
+
- `microsandbox@0.6.16` installs its matching native addon and runtime binaries
|
|
27
|
+
through an optional platform package. Do not use `--ignore-scripts` or omit
|
|
28
|
+
optional dependencies when installing pi-microsandbox.
|
|
29
|
+
|
|
30
|
+
If the platform package is missing, reinstall with optional dependencies
|
|
31
|
+
enabled, install the matching microsandbox platform package, or set `MSB_PATH`
|
|
32
|
+
to a working `msb` binary. These alternatives do not remove the host
|
|
33
|
+
virtualization requirement.
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
Install the package for the current user with Pi:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pi install npm:pi-microsandbox
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Before starting a sandbox, review [configuration](configuration.md) and choose a
|
|
44
|
+
[published variant or custom image](images.md) if the versioned default image
|
|
45
|
+
does not fit the project.
|
|
46
|
+
|
|
47
|
+
For a first load, explicit off mode lets you inspect the installation without
|
|
48
|
+
starting virtualization:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
PI_MSB_DISABLE=1 pi
|
|
52
|
+
# In Pi:
|
|
53
|
+
/msb status
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Off mode is **not sandboxed**: Pi's tools run directly on the host. Remove
|
|
57
|
+
`PI_MSB_DISABLE` only after reviewing the configuration and host prerequisites.
|
|
58
|
+
For an unavailable or failed sandbox, the default `fallback_mode = "block"`
|
|
59
|
+
blocks routed tools rather than silently running them on the host. Keep that
|
|
60
|
+
default for a fail-closed setup. `fallback_mode = "host"` is an explicit,
|
|
61
|
+
visibly labelled opt-in to automatic unsandboxed execution.
|
|
62
|
+
|
|
63
|
+
The public package is named `pi-microsandbox`. Existing technical interfaces
|
|
64
|
+
retain the shorter `msb` name for compatibility, including `/msb`,
|
|
65
|
+
`PI_MSB_*`, `.pi-msb.toml`, configuration directories, and managed-resource
|
|
66
|
+
labels. Existing configuration and retained resources therefore keep working.
|