@0perator/operator 0.1.154 → 0.1.155

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/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ Operator is AXE's terminal coding agent (npm `@0perator/operator`), running on A
4
4
  Newest first. Every release bumps `src/cli.tsx` VERSION + `package.json`, adds an entry here, and ships to
5
5
  npm + both git remotes (memjar/kode, axetechnologies/kode). Test counts are the full suite at that release.
6
6
 
7
+ ## 0.1.155 — 2026-09-29 — sandbox: Linux bubblewrap parity (sandboxed-exec Phase 2)
8
+ - `KODE_SANDBOX=workspace|strict` now sandboxes shell execution on **Linux** (bubblewrap), not just macOS
9
+ (seatbelt). `hasSandboxExec()` is darwin-only, so on the Linux fleet (jl2/jl3/AXeServer/droplets)
10
+ `wrapShell` fell through to plain bash — the modes were a **silent no-op** there. New `hasBubblewrap()`
11
+ (Linux-only) + `bwrapArgs(mode)` map the SAME `DENY_WRITE`/`SECRET_READ` lists + allow-roots to bwrap
12
+ bind-mount namespaces (protected paths → `--ro-bind`, secrets → `--tmpfs`/`/dev/null` mask, strict →
13
+ whole-FS `--ro-bind / /` + writable allow-roots + `--unshare-net`). `wrapShell`/`wrapInteractiveShell`
14
+ try seatbelt → bwrap → plain bash; **macOS behavior unchanged** (seatbelt still wins). Absent on thin
15
+ images (Alpine) → falls back to plain bash, JS write-guards still apply. **Runtime-validated on a real
16
+ Linux node** (Ubuntu 24.04, bubblewrap 0.9.0, canary-only, pkg purged): strict masks secret reads + cuts
17
+ network + confines writes; workspace allows network but keeps secret masking + protected-path read-only.
18
+ Design + validation: `_ai-docs/architecture/sandboxed-code-execution.md`; decision:
19
+ `_ai-docs/decisions/2026-09-29-linux-bubblewrap.md`. Suite 703 green (+4).
20
+
7
21
  ## 0.1.154 — 2026-09-29 — engine: per-session persistent shell (sandboxed-exec Phase 1)
8
22
  - The `bash`/`shell_exec` persistent shell is now **per session**, not one process-wide singleton. Before, the
9
23
  foreground and every background sub-agent shared ONE bash: a sub-agent's `cd`/`export` corrupted the
@@ -179,6 +179,40 @@ export function seatbeltProfile(mode) {
179
179
  }
180
180
  return `(version 1)(allow default)(deny file-write* ${denySub} ${denyFiles})${denyRead}`;
181
181
  }
182
+ /** Bubblewrap (bwrap) argv enforcing the SAME intent as seatbeltProfile(), for the Linux fleet where
183
+ * macOS sandbox-exec doesn't exist — hasSandboxExec() hardcodes false off-darwin, so KODE_SANDBOX=
184
+ * workspace|strict was a silent no-op on Linux (jl2/jl3/AXeServer) until this. bwrap is namespace /
185
+ * bind-mount based, not a rule profile, so the same denylists map to mounts (bwrap applies them
186
+ * left-to-right, later wins): protected write-paths are re-bound read-only, secret paths are masked
187
+ * (empty tmpfs / /dev/null so reads can't exfil), and strict makes the whole FS read-only except the
188
+ * allow-roots and cuts the network. Returns the args BEFORE the `/bin/bash …` argv. Exported for unit
189
+ * tests. NOTE: kernel enforcement must be validated on a real Linux node — untestable on macOS/JL1. */
190
+ export function bwrapArgs(mode) {
191
+ const a = [];
192
+ if (mode === "strict") {
193
+ a.push("--ro-bind", "/", "/"); // whole FS read-only …
194
+ a.push("--proc", "/proc", "--dev", "/dev");
195
+ for (const root of allowedWriteRoots())
196
+ a.push("--bind-try", root, root); // … except the allow-roots
197
+ a.push("--unshare-net"); // strict: no network
198
+ }
199
+ else {
200
+ a.push("--bind", "/", "/"); // workspace: FS writable …
201
+ a.push("--proc", "/proc", "--dev", "/dev");
202
+ for (const d of DENY_WRITE_SUBPATHS)
203
+ a.push("--ro-bind-try", resolve(d), resolve(d)); // … protected dirs read-only
204
+ for (const f of DENY_WRITE_FILES)
205
+ a.push("--ro-bind-try", "/dev/null", resolve(f)); // protected files masked
206
+ }
207
+ // Read-containment (BOTH modes): mask secret dirs with an empty tmpfs, secret files with /dev/null,
208
+ // so a shell command can't read + exfil credentials. Placed last so it wins over the writable binds.
209
+ for (const d of SECRET_READ_SUBPATHS)
210
+ a.push("--tmpfs", resolve(d));
211
+ for (const f of SECRET_READ_FILES)
212
+ a.push("--ro-bind", "/dev/null", resolve(f));
213
+ a.push("--die-with-parent");
214
+ return a;
215
+ }
182
216
  let _sbExec = null; // cache: is sandbox-exec present on this host?
183
217
  async function hasSandboxExec() {
184
218
  if (_sbExec !== null)
@@ -194,13 +228,31 @@ async function hasSandboxExec() {
194
228
  return (_sbExec = false);
195
229
  }
196
230
  }
231
+ let _bwrap = null; // cache: is bubblewrap (bwrap) present on this Linux host?
232
+ async function hasBubblewrap() {
233
+ if (_bwrap !== null)
234
+ return _bwrap;
235
+ if (process.platform !== "linux")
236
+ return (_bwrap = false); // Linux-only; macOS uses sandbox-exec above
237
+ try {
238
+ const { execFile } = await import("node:child_process");
239
+ await new Promise((res, rej) => execFile("bwrap", ["--version"], (e) => (e ? rej(e) : res())));
240
+ return (_bwrap = true);
241
+ }
242
+ catch {
243
+ return (_bwrap = false); // absent (e.g. Alpine/thin images) → fall back to plain bash; JS guards still apply
244
+ }
245
+ }
197
246
  /** Wrap a shell command for `execFile` under the OS sandbox. Returns the argv to run: under an active
198
247
  * sandbox on macOS it's `sandbox-exec -p <profile> /bin/bash -c <command>`; otherwise the plain bash
199
248
  * invocation (the JS write-guards still protect the file tools). */
200
249
  export async function wrapShell(command) {
201
250
  const mode = sandboxMode();
202
- if (mode !== "off" && (await hasSandboxExec())) {
203
- return { file: "/usr/bin/sandbox-exec", args: ["-p", seatbeltProfile(mode), "/bin/bash", "-c", command] };
251
+ if (mode !== "off") {
252
+ if (await hasSandboxExec())
253
+ return { file: "/usr/bin/sandbox-exec", args: ["-p", seatbeltProfile(mode), "/bin/bash", "-c", command] };
254
+ if (await hasBubblewrap())
255
+ return { file: "bwrap", args: [...bwrapArgs(mode), "/bin/bash", "-c", command] };
204
256
  }
205
257
  return { file: "/bin/bash", args: ["-c", command] };
206
258
  }
@@ -210,8 +262,11 @@ export async function wrapShell(command) {
210
262
  * noise; the session drives framing itself with a sentinel. */
211
263
  export async function wrapInteractiveShell() {
212
264
  const mode = sandboxMode();
213
- if (mode !== "off" && (await hasSandboxExec())) {
214
- return { file: "/usr/bin/sandbox-exec", args: ["-p", seatbeltProfile(mode), "/bin/bash", "-s"] };
265
+ if (mode !== "off") {
266
+ if (await hasSandboxExec())
267
+ return { file: "/usr/bin/sandbox-exec", args: ["-p", seatbeltProfile(mode), "/bin/bash", "-s"] };
268
+ if (await hasBubblewrap())
269
+ return { file: "bwrap", args: [...bwrapArgs(mode), "/bin/bash", "-s"] };
215
270
  }
216
271
  return { file: "/bin/bash", args: ["-s"] };
217
272
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.154",
3
+ "version": "0.1.155",
4
4
  "description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
5
5
  "type": "module",
6
6
  "bin": {