kern-sandbox 0.2.15 → 0.2.17
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 +5 -0
- package/index.js +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
**Run AI-generated code in a real sandbox, one fresh box per call, in about 4 ms.**
|
|
4
4
|
|
|
5
|
+
That 4 ms is the BOX. A trivial `run_code` costs more, because an interpreter has to start
|
|
6
|
+
inside it: about 16 ms for Python on the machine this was measured on, of which ~12 is CPython
|
|
7
|
+
itself (a bare `python3 -c` on the host already costs ~8). The two numbers answer two different
|
|
8
|
+
questions, and quoting one where the other belongs is how a benchmark becomes a lie.
|
|
9
|
+
|
|
5
10
|
`kern-sandbox` is the Node and TypeScript binding for **[kern](https://getkern.dev)**: a rootless,
|
|
6
11
|
kernel-enforced sandbox out of one static binary, with no daemon, no VM and no cloud. An agent's
|
|
7
12
|
tool-call, a model's generated snippet, a CI step: code that runs before anyone reads it gets its own
|
package/index.js
CHANGED
|
@@ -36,7 +36,7 @@ const crypto = require("crypto");
|
|
|
36
36
|
const zlib = require("zlib");
|
|
37
37
|
const { spawn, spawnSync } = require("child_process");
|
|
38
38
|
|
|
39
|
-
const VERSION = "0.2.
|
|
39
|
+
const VERSION = "0.2.17";
|
|
40
40
|
|
|
41
41
|
const DEFAULT_IMAGE = "python:3.12-slim";
|
|
42
42
|
const WORKSPACE = "/workspace"; // where the persistent workspace is mounted inside every box
|
|
@@ -1789,10 +1789,17 @@ class Sandbox {
|
|
|
1789
1789
|
detail = reason || "the box could not execute it";
|
|
1790
1790
|
}
|
|
1791
1791
|
fault = sandboxFault("exec_failed", `'${what}' could not be started in the box: ${detail}`);
|
|
1792
|
-
} else if (
|
|
1792
|
+
} else if (fault && fault.type === "startup_failed" && (boxStarted || stdout.trim())) {
|
|
1793
1793
|
// kern signalled the box STARTED, so a `startup_failed` here is only the stderr heuristic
|
|
1794
1794
|
// matching a marker the WORKLOAD wrote (code-based faults are decided first). The box
|
|
1795
1795
|
// demonstrably ran: this is the workload's own non-zero exit - reclassify to a normal result.
|
|
1796
|
+
//
|
|
1797
|
+
// STDOUT IS THE SECOND WITNESS, and it is here because the first one can be absent. MEASURED
|
|
1798
|
+
// with a KERN_BIN wrapper that closes `KERN_STARTED_FD` before exec'ing the real kern: the box
|
|
1799
|
+
// ran, printed, exited 1 with `error: forged` on stderr, and came back `startup_failed`. The
|
|
1800
|
+
// same hole is open on any kern too old to write the byte. A box that never started cannot
|
|
1801
|
+
// print, and every genuine startup failure measured returns stdout EMPTY, so this is only ever
|
|
1802
|
+
// read as evidence FOR a box having run, never against: a silent workload loses nothing.
|
|
1796
1803
|
fault = null;
|
|
1797
1804
|
}
|
|
1798
1805
|
// A box that FAILED TO START ran no user code, so REJECT rather than resolve a hollow
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kern-sandbox",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "kern is a fast, rootless sandbox and virtual resource runtime for any workload, including untrusted and AI-generated code; kern-sandbox is its Node/TypeScript binding. Run untrusted or agent-generated code (Python/JS/Bash) in a real, kernel-enforced box in single-digit milliseconds, with no cloud, no account and no VM.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sandbox",
|