@orggem/mini-pod 0.0.0-stage → 0.1.3
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 +15 -2
- package/bin/sandbox-cli.js +2 -0
- package/bin/sandboxd.js +2 -0
- package/launcher.js +124 -0
- package/package.json +31 -4
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# mini-pod on npm
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Install the CLI and daemon with Node.js 18 or later. As checked on 2026-11-29,
|
|
4
|
+
npm `latest` is **0.1.0**, while GitHub provides **v0.1.2**. See
|
|
5
|
+
[release status](https://github.com/OrgGem/mini-pod/blob/main/docs/status.md)
|
|
6
|
+
before choosing a distribution; the v0.1.2 npm publish job failed.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install -g @orggem/mini-pod
|
|
10
|
+
sandbox-cli --help
|
|
11
|
+
sandboxd --help
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Prebuilt binaries are provided for Windows x64, Linux x64/arm64 (glibc), and macOS x64/arm64. Alpine Linux and other musl-based systems are not supported by these binaries. Do not omit optional dependencies when installing the package.
|
|
15
|
+
|
|
16
|
+
The npm package does not include QEMU or a signed guest runtime bundle. Install or supply those separately, start `sandboxd serve` with a trusted bundle and public key, then connect with `sandbox-cli`. See the [mini-pod README](https://github.com/OrgGem/mini-pod#readme) for configuration and examples.
|
package/bin/sandboxd.js
ADDED
package/launcher.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const os = require('node:os');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { spawn } = require('node:child_process');
|
|
6
|
+
|
|
7
|
+
const packages = new Set([
|
|
8
|
+
'win32-x64',
|
|
9
|
+
'linux-x64',
|
|
10
|
+
'linux-arm64',
|
|
11
|
+
'darwin-x64',
|
|
12
|
+
'darwin-arm64',
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
function platformPackage(platform, arch, glibcVersion) {
|
|
16
|
+
const target = `${platform}-${arch}`;
|
|
17
|
+
if (!packages.has(target)) {
|
|
18
|
+
throw new Error(`Unsupported platform: ${target}`);
|
|
19
|
+
}
|
|
20
|
+
if (platform === 'linux' && !glibcVersion) {
|
|
21
|
+
throw new Error('Linux binaries require glibc; musl/Alpine is not supported.');
|
|
22
|
+
}
|
|
23
|
+
return `@orggem/mini-pod-${target}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function watchedSignals(platform) {
|
|
27
|
+
return platform === 'win32'
|
|
28
|
+
? ['SIGINT', 'SIGBREAK', 'SIGTERM', 'SIGHUP']
|
|
29
|
+
: ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function shouldForwardSignal(platform, signal, win32InterruptCount) {
|
|
33
|
+
if (platform !== 'win32') {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
// On Windows inherited console `Ctrl+C` / `Ctrl+Break` deliver `CTRL_C_EVENT` /
|
|
37
|
+
// `CTRL_BREAK_EVENT` directly to the Rust child so it can clean up VMs and exit cleanly;
|
|
38
|
+
// `child.kill` calls `TerminateProcess` (hard kill). Let the first interrupt pass gracefully and
|
|
39
|
+
// escalate on repeat interrupts or `SIGTERM`.
|
|
40
|
+
if (signal === 'SIGINT' || signal === 'SIGBREAK') {
|
|
41
|
+
return win32InterruptCount > 1;
|
|
42
|
+
}
|
|
43
|
+
if (signal === 'SIGHUP') {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function exitCodeForSignal(signal) {
|
|
50
|
+
const signo = os.constants.signals[signal];
|
|
51
|
+
return typeof signo === 'number' ? 128 + signo : 1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function run(command) {
|
|
55
|
+
try {
|
|
56
|
+
const glibcVersion = process.platform === 'linux'
|
|
57
|
+
? process.report.getReport().header.glibcVersionRuntime
|
|
58
|
+
: undefined;
|
|
59
|
+
const packageName = platformPackage(process.platform, process.arch, glibcVersion);
|
|
60
|
+
let packageJson;
|
|
61
|
+
try {
|
|
62
|
+
packageJson = require.resolve(`${packageName}/package.json`);
|
|
63
|
+
} catch (err) {
|
|
64
|
+
if (err.code !== 'MODULE_NOT_FOUND') throw err;
|
|
65
|
+
throw new Error(`The ${packageName} binary package is missing. Reinstall with optional dependencies enabled.`);
|
|
66
|
+
}
|
|
67
|
+
const executable = path.join(path.dirname(packageJson), 'bin', command + (process.platform === 'win32' ? '.exe' : ''));
|
|
68
|
+
const child = spawn(executable, process.argv.slice(2), { stdio: 'inherit' });
|
|
69
|
+
let win32InterruptCount = 0;
|
|
70
|
+
const signalHandlers = [];
|
|
71
|
+
for (const sig of watchedSignals(process.platform)) {
|
|
72
|
+
const handler = () => {
|
|
73
|
+
if (process.platform === 'win32' && (sig === 'SIGINT' || sig === 'SIGBREAK')) {
|
|
74
|
+
win32InterruptCount += 1;
|
|
75
|
+
}
|
|
76
|
+
if (
|
|
77
|
+
child.exitCode === null
|
|
78
|
+
&& child.signalCode === null
|
|
79
|
+
&& shouldForwardSignal(process.platform, sig, win32InterruptCount)
|
|
80
|
+
) {
|
|
81
|
+
try {
|
|
82
|
+
child.kill(sig);
|
|
83
|
+
} catch {
|
|
84
|
+
// Ignore errors if the child already exited between check and signal delivery.
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
signalHandlers.push([sig, handler]);
|
|
89
|
+
process.on(sig, handler);
|
|
90
|
+
}
|
|
91
|
+
const cleanupSignals = () => {
|
|
92
|
+
for (const [sig, handler] of signalHandlers) {
|
|
93
|
+
process.off(sig, handler);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
child.on('error', err => {
|
|
98
|
+
cleanupSignals();
|
|
99
|
+
console.error(`${command}: ${err.message}`);
|
|
100
|
+
process.exitCode = 1;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
child.on('exit', (code, signal) => {
|
|
104
|
+
cleanupSignals();
|
|
105
|
+
if (signal) {
|
|
106
|
+
process.exitCode = exitCodeForSignal(signal);
|
|
107
|
+
if (process.platform !== 'win32') {
|
|
108
|
+
try {
|
|
109
|
+
process.kill(process.pid, signal);
|
|
110
|
+
} catch {
|
|
111
|
+
// Fall back to `process.exitCode` set above if signal re-delivery fails.
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
process.exitCode = code ?? 1;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
} catch (err) {
|
|
119
|
+
console.error(`${command}: ${err.message}`);
|
|
120
|
+
process.exitCode = 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
module.exports = { platformPackage, run, watchedSignals, shouldForwardSignal, exitCodeForSignal };
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orggem/mini-pod",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Command-line client and daemon for the mini-pod sandbox runtime",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/OrgGem/mini-pod.git",
|
|
9
|
+
"directory": "npm"
|
|
10
|
+
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"sandbox-cli": "bin/sandbox-cli.js",
|
|
16
|
+
"sandboxd": "bin/sandboxd.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin",
|
|
20
|
+
"launcher.js",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"optionalDependencies": {
|
|
24
|
+
"@orggem/mini-pod-win32-x64": "0.1.3",
|
|
25
|
+
"@orggem/mini-pod-linux-x64": "0.1.3",
|
|
26
|
+
"@orggem/mini-pod-linux-arm64": "0.1.3",
|
|
27
|
+
"@orggem/mini-pod-darwin-x64": "0.1.3",
|
|
28
|
+
"@orggem/mini-pod-darwin-arm64": "0.1.3"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|