piroboros 0.2.0 → 0.3.2
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 +46 -0
- package/NOTICE +12 -0
- package/README.md +11 -8
- package/dist/chat/log.js +1 -1
- package/dist/chat/turn.js +0 -15
- package/dist/conclave/pipeline.js +216 -13
- package/dist/config.js +121 -12
- package/dist/diff.js +90 -0
- package/dist/durable.js +1 -1
- package/dist/guard.js +169 -13
- package/dist/learn.js +938 -0
- package/dist/memory/akashic/tools.js +25 -28
- package/dist/memory/mnemosia/conflicts.js +0 -4
- package/dist/memory/mnemosia/orchestrator.js +1 -11
- package/dist/memory/mnemosia/policy.js +0 -3
- package/dist/memory/mnemosia/rank.js +0 -4
- package/dist/memory/mnemosia/rerank.js +3 -30
- package/dist/memory/mnemosia/rollback.js +1 -149
- package/dist/memory/mnemosia/tokens.js +1 -11
- package/dist/memory/mnemosia/tools.js +0 -10
- package/dist/memory/mnemosia/types.js +0 -2
- package/dist/runtime.js +51 -6
- package/dist/search.js +25 -12
- package/dist/shell.js +2 -2
- package/dist/tui/app.js +15 -3
- package/dist/tui/commands.js +5 -2
- package/dist/tui/settings.js +4 -1
- package/dist/tui/thinking/parse.js +0 -3
- package/dist/ws/apply.js +817 -0
- package/dist/ws/cas.js +144 -0
- package/dist/ws/confine.js +194 -0
- package/dist/ws/docker.js +151 -0
- package/dist/ws/git.js +162 -0
- package/dist/ws/lww.js +48 -0
- package/dist/ws/merge.js +129 -0
- package/dist/ws/workspace.js +1596 -0
- package/dist/ws/wsl.js +259 -0
- package/docs/conclave.md +14 -0
- package/docs/configuration.md +10 -4
- package/docs/privacy.md +3 -1
- package/docs/tools.md +43 -1
- package/package.json +1 -2
- package/settings.json.example +3 -1
package/dist/ws/wsl.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
3
|
+
import { posix, win32 } from "node:path";
|
|
4
|
+
import { err, ExecutionError, ok } from "@earendil-works/pi-durable/env";
|
|
5
|
+
import { sgrStripper } from "../shell.js";
|
|
6
|
+
import { bwrapArgs, seccompExec, within } from "./confine.js";
|
|
7
|
+
export class SelfTestError extends Error {
|
|
8
|
+
}
|
|
9
|
+
export function wslDeps() {
|
|
10
|
+
const systemRoot = process.env.SystemRoot ?? "C:\\Windows";
|
|
11
|
+
// Only SystemRoot, WSL_UTF8 and an empty WSLENV: nothing from the Windows environment reaches the distro.
|
|
12
|
+
const env = { SystemRoot: systemRoot, WSL_UTF8: "1", WSLENV: "" };
|
|
13
|
+
return { systemRoot, run: (args, o = {}) => new Promise((done) => {
|
|
14
|
+
const child = spawn(win32.join(systemRoot, "System32", "wsl.exe"), args, { env, stdio: [o.stdin === undefined ? "ignore" : "pipe", "pipe", "pipe"], windowsHide: true });
|
|
15
|
+
const out = [];
|
|
16
|
+
let errs = "";
|
|
17
|
+
let timedOut = false;
|
|
18
|
+
let end;
|
|
19
|
+
let over = false;
|
|
20
|
+
const fin = (code) => { if (over)
|
|
21
|
+
return; over = true; clearTimeout(timer); clearTimeout(end); o.signal?.removeEventListener("abort", kill); done({ code, out: Buffer.concat(out), err: errs, timedOut }); };
|
|
22
|
+
const kill = () => { child.kill(); };
|
|
23
|
+
const timer = o.timeoutMs === undefined ? undefined : setTimeout(() => { timedOut = true; kill(); }, o.timeoutMs);
|
|
24
|
+
o.signal?.addEventListener("abort", kill, { once: true });
|
|
25
|
+
if (o.signal?.aborted)
|
|
26
|
+
kill();
|
|
27
|
+
child.stdout?.on("data", (b) => { if (o.onData !== undefined)
|
|
28
|
+
o.onData(b, "stdout");
|
|
29
|
+
else
|
|
30
|
+
out.push(b); });
|
|
31
|
+
child.stderr?.on("data", (b) => { if (o.onData !== undefined)
|
|
32
|
+
o.onData(b, "stderr");
|
|
33
|
+
else if (errs.length < 4096)
|
|
34
|
+
errs += b.toString("utf8"); });
|
|
35
|
+
child.stdin?.on("error", () => undefined);
|
|
36
|
+
if (o.stdin !== undefined)
|
|
37
|
+
child.stdin?.end(o.stdin);
|
|
38
|
+
child.on("error", (e) => { errs += e.message; fin(null); });
|
|
39
|
+
child.on("close", fin);
|
|
40
|
+
// A descendant holding the pipes open must not keep the call waiting.
|
|
41
|
+
child.on("exit", (code) => { end = setTimeout(() => fin(code), 2000); });
|
|
42
|
+
}) };
|
|
43
|
+
}
|
|
44
|
+
export const via = (w, argv) => [...(w.distro === undefined ? [] : ["--distribution", w.distro]), ...(w.user === undefined ? [] : ["--user", w.user]), "--exec", ...argv];
|
|
45
|
+
const key = (p) => win32.resolve(p).replaceAll("\\", "/").toLowerCase();
|
|
46
|
+
export const posixOf = (p) => p.replaceAll("\\", "/");
|
|
47
|
+
/** A Windows path that may not be bound or mounted: protected, the profile or a direct child of it, or something holding the Workspace root, PIROBOROS_HOME or a deny root. */
|
|
48
|
+
export function wslBad(d, path) {
|
|
49
|
+
const k = key(path);
|
|
50
|
+
const above = (root) => key(root) === k || key(root).startsWith(`${k}/`);
|
|
51
|
+
return !d.allowed(path) || above(d.home) || key(win32.dirname(path)) === key(d.home) || [d.wsRoot, d.piroHome, ...d.deny].some(above);
|
|
52
|
+
}
|
|
53
|
+
/** One call of a constant script; a refusal names the call, the distro or user, or what wsl.exe said. */
|
|
54
|
+
export async function call(d, w, what, script, args = [], timeoutMs = 20_000) {
|
|
55
|
+
const r = await d.run(via(w, ["sh", "-c", script, "sh", ...args]), { timeoutMs });
|
|
56
|
+
if (r.timedOut)
|
|
57
|
+
throw new Error(`${what}: wsl.exe did not answer within ${timeoutMs / 1000} s`);
|
|
58
|
+
if (r.code === null && /ENOENT/u.test(r.err))
|
|
59
|
+
throw new Error("wsl.exe is not available on this machine");
|
|
60
|
+
if (r.code === -1 || r.code === 0xFFFFFFFF)
|
|
61
|
+
throw new Error(`distro ${w.distro ?? "(default)"} or user ${w.user ?? "(default)"} not found`);
|
|
62
|
+
if (r.code !== 0)
|
|
63
|
+
throw new Error(`${what}: exit ${r.code}${r.err === "" ? "" : ` (${r.err.trim().slice(0, 200)})`}`);
|
|
64
|
+
return r.out.toString("utf8");
|
|
65
|
+
}
|
|
66
|
+
const RESOLVE = 'printf "%s\\n" "$WSL_DISTRO_NAME" "$(id -u)" "$(id -g)" "$(id -un)" "$(getent passwd "$(id -un)" | cut -d: -f6)" "$(uname -r)" "$(test -x /usr/bin/bwrap && echo 1)" "$(wslinfo --networking-mode 2>/dev/null)"; cat /proc/self/mounts';
|
|
67
|
+
const LOGIN = 'printf "\\001S"; printf "%s\\0" "$PATH" "${LANG:-C.UTF-8}" "$(readlink -f /etc/resolv.conf)"; printf "\\001E"';
|
|
68
|
+
export const WSLPATH = 'for p; do wslpath -a -u "$p" || echo; done';
|
|
69
|
+
const REALPATH = 'for p; do realpath -e -- "$p" 2>/dev/null || echo; done';
|
|
70
|
+
const PIDRUN = 'echo $$ > "$1"; shift; exec "$@"';
|
|
71
|
+
const KILL = 'kill -KILL "$(cat -- "$1")" 2>/dev/null; rm -f -- "$1"';
|
|
72
|
+
// Runs inside the sandbox: write and remove a file in the Workspace, no auth.json, a readable resolv.conf, no Windows program, no System32, then the
|
|
73
|
+
// node version and what each masked mount lists.
|
|
74
|
+
const SELF_TEST = 'm="$1/.piroboros-selftest"; : > "$m" || { echo "the Workspace is not writable"; exit 1; }; rm -f "$m"; [ ! -e "$2/auth.json" ] || { echo "auth.json is visible"; exit 1; }; [ "$3" = 0 ] || [ -r /etc/resolv.conf ] || { echo "resolv.conf is not readable"; exit 1; }; command -v perl >/dev/null && { perl -e \'socket(S,40,1,0) and exit 1; exit($!+0==97?0:2)\' || { echo "an AF_VSOCK socket can be created"; exit 1; }; }; if "$4" >/dev/null 2>&1; then echo "a Windows program ran"; exit 1; fi; [ ! -e "$5" ] || { echo "the Windows System32 folder is visible"; exit 1; }; echo "node $(node --version 2>/dev/null || echo none)"; shift 5; for m; do echo "mount $m"; ls -A "$m" 2>/dev/null; done; true';
|
|
75
|
+
export const WRAPPER = 'IFS= read -rd "" c; exec bash -c "$c"';
|
|
76
|
+
/** The distro and user (the pinned ones, or the default), refused when bubblewrap (unless `bwrap` is false, for Docker) cannot work there. Also reads the Windows-backed mounts. */
|
|
77
|
+
export async function resolveWsl(d, who, bwrapNeeded = true) {
|
|
78
|
+
const lines = (await call(d, who, "resolving the distro", RESOLVE)).split("\n");
|
|
79
|
+
const [distro = "", uid = "", gid = "", user = "", home = "", kernel = "", bwrap = "", net = ""] = lines;
|
|
80
|
+
if (/^docker-desktop/iu.test(distro))
|
|
81
|
+
throw new Error(`distro ${distro} is Docker Desktop's own and cannot run commands`);
|
|
82
|
+
if (distro === "" || user === "" || home === "")
|
|
83
|
+
throw new Error("the distro did not report its name, user and home");
|
|
84
|
+
if (uid === "0")
|
|
85
|
+
throw new Error(`the default user of ${distro} is root; set a normal default user in the distro`);
|
|
86
|
+
if (!/WSL2/iu.test(kernel))
|
|
87
|
+
throw new Error(`${distro} runs kernel ${kernel}, which is not WSL2 (bubblewrap needs it)`);
|
|
88
|
+
if (bwrapNeeded && bwrap !== "1")
|
|
89
|
+
throw new Error(`bubblewrap is not installed in ${distro} (package bubblewrap)`);
|
|
90
|
+
const unescape = (s) => s.replace(/\\([0-7]{3})/gu, (_, o) => String.fromCharCode(Number.parseInt(o, 8)));
|
|
91
|
+
const mounts = lines.slice(8).map((l) => l.split(" ")).filter((f) => ["9p", "drvfs", "virtiofs"].includes(f[2] ?? "")).map((f) => unescape(f[1] ?? ""));
|
|
92
|
+
return { distro, user, uid, gid, home, net, mounts: ["/mnt", ...new Set(mounts)].filter((m) => m !== "") };
|
|
93
|
+
}
|
|
94
|
+
/** PATH, LANG and the resolv.conf target from the login shell; empty and relative entries and entries under a Windows-backed mount are dropped. */
|
|
95
|
+
async function loginValues(d, who, mounts) {
|
|
96
|
+
const parse = (r) => {
|
|
97
|
+
if (r.timedOut || r.code !== 0)
|
|
98
|
+
return undefined;
|
|
99
|
+
const s = r.out.toString("utf8");
|
|
100
|
+
const i = s.indexOf("\x01S");
|
|
101
|
+
const j = s.lastIndexOf("\x01E");
|
|
102
|
+
const f = i < 0 || j < i ? [] : s.slice(i + 2, j).split("\0");
|
|
103
|
+
return f.length >= 3 ? f : undefined;
|
|
104
|
+
};
|
|
105
|
+
let f = parse(await d.run(via(who, ["bash", "-lc", LOGIN]), { timeoutMs: 10_000 }));
|
|
106
|
+
const fallback = f === undefined;
|
|
107
|
+
f ??= parse(await d.run(via(who, ["env", "LANG=C.UTF-8", "sh", "-c", LOGIN]), { timeoutMs: 10_000 }));
|
|
108
|
+
if (f === undefined)
|
|
109
|
+
throw new Error("reading PATH from the distro failed");
|
|
110
|
+
return { path: (f[0] ?? "").split(":").filter((e) => e.startsWith("/") && !mounts.some((m) => within(m, e))), lang: f[1] || "C.UTF-8", resolv: f[2] ?? "", fallback };
|
|
111
|
+
}
|
|
112
|
+
/** Run `fn` until the paths it asks `real` about are all resolved in the distro (realpath -e, one call per round). */
|
|
113
|
+
async function settled(d, who, fn) {
|
|
114
|
+
const known = new Map();
|
|
115
|
+
for (let round = 0; round < 4; round++) {
|
|
116
|
+
const ask = new Set();
|
|
117
|
+
const out = fn((p) => { if (known.has(p))
|
|
118
|
+
return known.get(p); ask.add(p); return undefined; });
|
|
119
|
+
if (ask.size === 0)
|
|
120
|
+
return out;
|
|
121
|
+
const lines = (await call(d, who, "resolving sandbox paths", REALPATH, [...ask])).split("\n");
|
|
122
|
+
[...ask].forEach((p, i) => known.set(p, lines[i] || undefined));
|
|
123
|
+
}
|
|
124
|
+
throw new Error("resolving sandbox paths did not settle");
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Choose bubblewrap in WSL for the Workspace folder `ws` (a Windows path under `<wsRoot>/<home hash>/<id>`): resolve and pin the distro and user,
|
|
128
|
+
* translate the Windows paths, create the ext4 folders, build the argv and run the self-test. A refusal throws; a failed check throws SelfTestError.
|
|
129
|
+
*/
|
|
130
|
+
export async function wslPick(s, d, ws, p) {
|
|
131
|
+
const w = d.wsl;
|
|
132
|
+
if (/^docker-desktop/iu.test(s.distro ?? ""))
|
|
133
|
+
throw new Error("workspace.wsl.distro names Docker Desktop's own distro, which cannot run commands");
|
|
134
|
+
let info;
|
|
135
|
+
try {
|
|
136
|
+
info = await resolveWsl(w, p.prev === undefined ? { distro: s.distro } : { distro: p.prev.distro, user: p.prev.user });
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (p.prev === undefined)
|
|
140
|
+
throw error;
|
|
141
|
+
info = await resolveWsl(w, { distro: s.distro }).catch(() => { throw error; });
|
|
142
|
+
}
|
|
143
|
+
const who = { distro: info.distro, user: info.user };
|
|
144
|
+
const notice = [];
|
|
145
|
+
if (p.prev !== undefined && (p.prev.distro !== info.distro || p.prev.user !== info.user))
|
|
146
|
+
notice.push(`The earlier sandbox folders of this Workspace stay in ${p.prev.distro} as ${p.prev.user} at ${p.prev.ext4}; remove them there.`);
|
|
147
|
+
// Deny-root check of each Windows path before it is translated.
|
|
148
|
+
for (const x of [ws, ...p.alt])
|
|
149
|
+
if (win32.isAbsolute(x) && !/^[A-Za-z]:[\\/]/u.test(x))
|
|
150
|
+
throw new Error(`${x} is not on a local Windows drive`);
|
|
151
|
+
const alt = p.alt.filter((a) => win32.isAbsolute(a) && !wslBad(d, a));
|
|
152
|
+
const hash = win32.basename(win32.dirname(ws));
|
|
153
|
+
const selftest = win32.join(d.wsRoot, hash, "selftest");
|
|
154
|
+
if (!existsSync(win32.join(selftest, "w.exe"))) {
|
|
155
|
+
mkdirSync(selftest, { recursive: true });
|
|
156
|
+
copyFileSync(win32.join(w.systemRoot, "System32", "whoami.exe"), win32.join(selftest, "w.exe"));
|
|
157
|
+
}
|
|
158
|
+
const system32 = win32.join(w.systemRoot, "System32");
|
|
159
|
+
const wins = [...new Set([ws, d.wsRoot, d.piroHome, ...d.deny, selftest, system32, ...alt])];
|
|
160
|
+
const out = (await call(w, who, "translating paths", WSLPATH, wins.map((x) => win32.resolve(x)))).split("\n");
|
|
161
|
+
const to = new Map(wins.map((x, i) => [x, out[i] ?? ""]));
|
|
162
|
+
const lin = (x) => to.get(x) ?? "";
|
|
163
|
+
for (const x of [ws, ...alt])
|
|
164
|
+
if (!info.mounts.some((m) => within(m, lin(x))))
|
|
165
|
+
throw new Error(`${x} is not on a local Windows drive`);
|
|
166
|
+
const login = await loginValues(w, who, info.mounts);
|
|
167
|
+
const wsLin = lin(ws);
|
|
168
|
+
const ext4 = `${info.home}/.local/state/piroboros-ws/${hash}/${win32.basename(ws)}`;
|
|
169
|
+
const nm = p.places.map((place, i) => [`${ext4}/nm/${i}`, `${wsLin}/${place}`]);
|
|
170
|
+
await call(w, who, "creating the sandbox folders", 'mkdir -p -m 0700 -- "$@"', [`${ext4}/run`, ...nm.map(([src]) => src)]);
|
|
171
|
+
const env = [["PATH", login.path.join(":")], ["HOME", info.home], ["USER", info.user], ["LOGNAME", info.user], ["LANG", login.lang], ["TMPDIR", "/tmp"], ["NO_COLOR", "1"], ["TERM", "dumb"]];
|
|
172
|
+
const c = { ws: wsLin, cwd: wsLin, net: s.network, path: login.path.join(":"), wsl: { mounts: info.mounts, alt: alt.map(lin), nm, env, extra: [] } };
|
|
173
|
+
const test = ["sh", "-c", SELF_TEST, "sh", wsLin, lin(d.piroHome), s.network ? "1" : "0", `${lin(selftest)}/w.exe`, lin(system32), ...info.mounts];
|
|
174
|
+
const built = await settled(w, who, (real) => {
|
|
175
|
+
const dl = { ...d, platform: "linux", home: info.home, piroHome: lin(d.piroHome), wsRoot: lin(d.wsRoot), deny: d.deny.map(lin).filter((x) => x !== ""), allowed: () => true, real, read: () => undefined };
|
|
176
|
+
return { real: bwrapArgs(dl, c, []), test: bwrapArgs(dl, { ...c, wsl: { ...c.wsl, extra: [lin(selftest)] } }, test) };
|
|
177
|
+
});
|
|
178
|
+
const ran = await w.run(via(who, seccompExec("/usr/bin/bwrap", built.test.args)), { timeoutMs: 20_000 });
|
|
179
|
+
const lines = ran.out.toString("utf8").split("\n");
|
|
180
|
+
if (ran.timedOut || ran.code !== 0)
|
|
181
|
+
throw new SelfTestError(ran.timedOut ? "the self-test did not finish within 20 s" : lines[0] || ran.err.trim().split("\n")[0] || "bwrap did not start");
|
|
182
|
+
// Each masked mount may list only the first folder of a bound path inside it.
|
|
183
|
+
const bound = [wsLin, ...c.wsl.alt, lin(selftest), ...nm.map(([, dst]) => dst), login.resolv];
|
|
184
|
+
let mount = "";
|
|
185
|
+
for (const line of lines.slice(1)) {
|
|
186
|
+
if (line.startsWith("mount ")) {
|
|
187
|
+
mount = line.slice(6);
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (mount !== "" && line !== "" && !bound.some((b) => within(mount, b) && b.slice(mount.length + 1).split("/")[0] === line))
|
|
191
|
+
throw new SelfTestError(`${mount} lists ${line}, which is not a bind parent`);
|
|
192
|
+
}
|
|
193
|
+
const have = /^node (.+)$/mu.exec(ran.out.toString("utf8"))?.[1] ?? "none";
|
|
194
|
+
const need = /^>=\s*(\d+\.\d+\.\d+)\s*$/u.exec((() => { try {
|
|
195
|
+
return JSON.parse(readFileSync(win32.join(p.project, "package.json"), "utf8")).engines?.node ?? "";
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return "";
|
|
199
|
+
} })())?.[1];
|
|
200
|
+
// ponytail: only `>=X.Y.Z` is compared; add a semver range check when a project uses another form.
|
|
201
|
+
const lt = (a, b) => { const x = a.replace(/^v/u, "").split(".").map(Number), y = b.split(".").map(Number); for (let i = 0; i < 3; i++)
|
|
202
|
+
if ((x[i] ?? 0) !== (y[i] ?? 0))
|
|
203
|
+
return (x[i] ?? 0) < (y[i] ?? 0); return false; };
|
|
204
|
+
if (need !== undefined && (have === "none" || lt(have, need)))
|
|
205
|
+
notice.push(`Node in ${info.distro} is ${have}; this project needs >=${need}. Install a newer Node in the distro for npm commands.`);
|
|
206
|
+
if (s.network)
|
|
207
|
+
notice.push(`Network: on. Confined commands can reach the WSL VM's network, which includes the Windows host (${info.net === "nat" || info.net === "mirrored" ? `networking mode: ${info.net}` : "through the NAT gateway, or on Windows localhost with mirrored networking"}), and can send any file they can see.`);
|
|
208
|
+
if (p.files > 1000)
|
|
209
|
+
notice.push(`git in the sandbox reads this project through drvfs: the first git status takes about ${Math.round(p.files * 0.0057)} s, later ones about ${(0.5 + p.files * 0.0003).toFixed(1)} s.`);
|
|
210
|
+
const left = [...p.alt.filter((a) => !alt.includes(a)), ...built.real.refused];
|
|
211
|
+
if (left.length > 0)
|
|
212
|
+
notice.push(`Left hidden in the sandbox because they are protected: ${left.join(", ")}`);
|
|
213
|
+
if (login.fallback)
|
|
214
|
+
notice.push(`The login shell of ${info.distro} did not answer, so PATH comes from wsl.exe itself; put toolchain PATH lines in ~/.profile.`);
|
|
215
|
+
return { confine: { name: "bubblewrap", bwrap: "/usr/bin/bwrap", net: s.network, wsl: { ...who, ws: wsLin, ext4, argv: built.real.args, alt: p.alt, places: p.places } }, label: `bubblewrap in WSL (${info.distro})`, notice, alt: alt.map(lin) };
|
|
216
|
+
}
|
|
217
|
+
/** The sandbox folders of a Workspace, removed with the Workspace (exactly the computed path, never one read from Workspace content). */
|
|
218
|
+
export const wslRemove = (d, c) => call(d, c, "removing the sandbox folders", 'rm -rf --one-file-system -- "$1"', [c.ext4]);
|
|
219
|
+
/** Remove the ids under the own home-hash folder of a distro that no open, held or conflicted Workspace names. */
|
|
220
|
+
export async function wslSweep(d, c, keep) {
|
|
221
|
+
const base = posix.dirname(c.ext4);
|
|
222
|
+
for (const name of (await call(d, c, "listing the sandbox folders", 'ls -1A -- "$1" 2>/dev/null || true', [base])).split("\n"))
|
|
223
|
+
if (/^\d+$/u.test(name) && !keep.has(name))
|
|
224
|
+
await call(d, c, "removing a sandbox folder", 'rm -rf --one-file-system -- "$1"', [`${base}/${name}`]);
|
|
225
|
+
}
|
|
226
|
+
let seq = 0;
|
|
227
|
+
/** Run one command of a Workspace in the sandbox: wsl.exe with a constant argv, the command on stdin. Timeout and abort also end bwrap through its PID file. */
|
|
228
|
+
export async function execWsl(w, cwd, command, options, context) {
|
|
229
|
+
const c = w.confine.wsl;
|
|
230
|
+
const d = w.deps.wsl;
|
|
231
|
+
const rel = posixOf(win32.relative(w.ws, cwd));
|
|
232
|
+
// The guard sets GIT_CEILING_DIRECTORIES for a plain Workspace; its value here is the Linux form of the Workspace's parent.
|
|
233
|
+
const ceiling = options?.env?.GIT_CEILING_DIRECTORIES === undefined ? [] : ["--setenv", "GIT_CEILING_DIRECTORIES", posix.dirname(c.ws)];
|
|
234
|
+
const pid = `${c.ext4}/run/${process.pid}-${++seq}.pid`;
|
|
235
|
+
const args = via(c, ["sh", "-c", PIDRUN, "sh", pid, ...seccompExec(w.confine.bwrap, [...c.argv.slice(0, -2), ...ceiling, "--chdir", rel === "" ? c.ws : `${c.ws}/${rel}`, "bash", "-c", WRAPPER])]);
|
|
236
|
+
return wslCommand(d, args, command, options, context, async () => { await call(d, c, "ending the sandbox", KILL, [pid], 10_000).catch(() => ""); }, () => { void call(d, c, "removing the PID file", 'rm -f -- "$1"', [pid]).catch(() => ""); }, `distro ${c.distro} or user ${c.user} not found`);
|
|
237
|
+
}
|
|
238
|
+
/** One wsl.exe call whose stdin is the command (the constant wrapper reads it): output streams to the tool, `kill` runs on timeout or abort, `done` after a normal exit. */
|
|
239
|
+
export async function wslCommand(d, args, command, options, context, kill, done, missing) {
|
|
240
|
+
const strip = sgrStripper();
|
|
241
|
+
const dec = { stdout: new TextDecoder(), stderr: new TextDecoder() };
|
|
242
|
+
const emit = (text, stream) => { const clean = strip.push(text, stream); if (clean !== "")
|
|
243
|
+
options?.onOutput?.(clean, context, { stream }); };
|
|
244
|
+
const r = await d.run(args, { stdin: command, timeoutMs: options?.timeout === undefined ? undefined : options.timeout * 1000, signal: context.abortSignal, onData: (b, stream) => emit(dec[stream].decode(b, { stream: true }), stream) });
|
|
245
|
+
for (const stream of ["stdout", "stderr"]) {
|
|
246
|
+
emit(dec[stream].decode(), stream);
|
|
247
|
+
const rest = strip.flush(stream);
|
|
248
|
+
if (rest !== "")
|
|
249
|
+
options?.onOutput?.(rest, context, { stream });
|
|
250
|
+
}
|
|
251
|
+
if (r.timedOut || context.abortSignal?.aborted) {
|
|
252
|
+
await kill();
|
|
253
|
+
return err(new ExecutionError(r.timedOut ? "timeout" : "aborted", r.timedOut ? `timeout:${options?.timeout}` : "aborted"));
|
|
254
|
+
}
|
|
255
|
+
done();
|
|
256
|
+
if (r.code === null || r.code === -1 || r.code === 0xFFFFFFFF)
|
|
257
|
+
return err(new ExecutionError("spawn_error", `confinement backend unavailable: ${r.code === null ? (r.err.trim() || "wsl.exe did not start") : missing}`));
|
|
258
|
+
return ok({ exitCode: r.code });
|
|
259
|
+
}
|
package/docs/conclave.md
CHANGED
|
@@ -19,3 +19,17 @@ While a pipeline exists, the chat shows a Conclave pane. Each member is `waiting
|
|
|
19
19
|
- Each member's model is `conclave.members.<name>.model`, then `conclave.defaultModel`, then `main`. The choice is made once when the pipeline starts. A member whose model has no credentials fails the start before any member runs. `model:` is not allowed in an agent file, because the model is your choice and belongs in `settings.json`. `thinking`, `maxTurns` and `idleTimeoutMs` can be set per member in `settings.json` as well. The thinking level defaults come from the agent files: Samaela `high`, Vesperia `medium`, Astrelia and Vaelia `low`, the other reviewers `medium`. To give Samaela one model and the others another, set `conclave.members.samaela.model` and `conclave.defaultModel`, as in `settings.json.example`; `/settings conclave.members.samaela` edits the same keys from the chat.
|
|
20
20
|
- While a pipeline runs, the root chat cannot write files or run commands. A chat turn that was started only by member reports cannot either, until you send a message. Reports are treated as untrusted data. Such a turn ends its input with one line from piroboros that tells the model this rule, so it summarizes the reports and points to `/conclave approve` or a reply from you instead of trying a tool that would be refused.
|
|
21
21
|
- If piroboros closes while a pipeline runs, it resumes the pipeline at the next start and says so.
|
|
22
|
+
|
|
23
|
+
## Workspaces
|
|
24
|
+
|
|
25
|
+
Vesperia works in a Workspace by default: a private copy of your project's git-visible files, made when `/conclave approve` starts her. Your project folder is not touched while she runs. When her run ends with the verdict `done`, piroboros merges her changes back, line by line, and `/conclave undo` restores the files from a snapshot taken before the merge.
|
|
26
|
+
|
|
27
|
+
- What is copied: the files git shows for the project (tracked files, and untracked files that are not ignored), and a reduced `.git` so her git commands work. Files with secret-like names (`auth.json`, `.npmrc`, `.env.*`, `*.sqlite`, `token*`, keys and similar) are left out and listed in the start notice. Git-ignored folders such as `dist/` are not copied. `node_modules` is an empty folder in the Workspace, wherever it occurs; she installs into it when she needs it, and nothing under it is merged back. A project without git is copied by a walk with the same exceptions.
|
|
28
|
+
- Her `git push` is disabled in the Workspace and her commits stay there. Nothing she writes into the Workspace's `.git/config` or `.gitattributes` is run by piroboros.
|
|
29
|
+
- A merge writes nothing to your folder when a path conflicts (you changed the same place), and lists the paths and the kinds. A run that ends with another verdict, a cancel, a moved HEAD, 20 or more deletions, a live file over 64 MiB or a failed pre-flight check leaves the Workspace in place as a hold. `/conclave merge` shows every reason and asks once, `/conclave discard` drops the Workspace, `/conclave retry` continues a pipeline that a restart limit parked, and `/conclave status` shows the Workspace and its state.
|
|
30
|
+
- Resolving conflicts. For a text file both of you changed, the Workspace copy gets `<<<<<<< workspace N`, `=======` and `>>>>>>> live N` marker lines, and the report gives the line of each block. Remove the blocks (or copy the live file over the Workspace file) and run `/conclave merge` again; the path stays conflicted while any `<<<<<<< workspace N` or `>>>>>>> live N` line is left; the merge then applies your resolution against the live text it was made from. If you change the live file again in between, that path conflicts again and the markers are rewritten from Vesperia's stored version, so edits to the old markers are lost. A binary file or a deletion conflict is resolved by making the Workspace file equal to the live one. `/conclave merge` with conflicts left asks whether to replace your version of those paths with hers (her deletions delete); yes writes her stored version, not the marker text, and `/conclave undo` restores yours. A path that conflicts because a file and a folder meet, or because the names differ only in case, is not offered that choice; make the Workspace path equal the live one, or discard. A marker block with another number in a tracked file is ordinary text.
|
|
31
|
+
- Approving the same plan again after a conflict or a hold continues in the same Workspace. Files you changed in your folder that she never touched are copied into it first, so her next merge builds on your current files.
|
|
32
|
+
- A `.lww` file in the project root (gitignore-style patterns, `%include` for more files) names paths where the side modified later wins instead of conflicting: the Workspace file's modification time against the live file's, the Workspace on a tie. A path she deleted counts as modified when the deletion was seen, and a path deleted live loses. The report names the rule and the side kept.
|
|
33
|
+
- The merge is not atomic across files. It stores every live path it will change before it writes, replaces each file only after checking its bytes, rolls back when a step fails, and rolls back or finishes at the next start after a crash. A live file over 64 MiB is never merged: copy it yourself before `/conclave merge`, which removes the Workspace afterwards.
|
|
34
|
+
- On Linux with bubblewrap installed, on Windows with bubblewrap in WSL 2, or with a Docker image set in `workspace.docker.image`, her commands run confined: see [Shell confinement](tools.md#shell-confinement). Everywhere else, and when the self-test fails, shell commands are not confined: they run in the Workspace folder but can still read and write any path your account can, including your live project. The start notice and `/conclave status` say which applies. The Workspace keeps her away from your files by where she works, not by a sandbox.
|
|
35
|
+
- A project folder that is a subfolder of a repository, a worktree or a submodule asks once whether she should work in place or on a copy without git. `workspace.nested` overrides the answer. `workspace.enabled: false` runs her in place, as piroboros 0.2.0 did.
|
package/docs/configuration.md
CHANGED
|
@@ -35,14 +35,20 @@ Everything piroboros stores lives under `PIROBOROS_HOME` (default `~/.piroboros`
|
|
|
35
35
|
|
|
36
36
|
## Chat commands
|
|
37
37
|
|
|
38
|
-
`/model`, `/reload`, `/login`, `/settings`, `/status`, `/conclave`, `/akashic`, `/thinking-steps`, `/skills` and `/telemetry` are available in the chat, and so is one command for each skill you have installed (see [Skills](tools.md#skills)).
|
|
38
|
+
`/model`, `/reload`, `/login`, `/settings`, `/status`, `/conclave`, `/akashic`, `/thinking-steps`, `/skills`, `/learn` and `/telemetry` are available in the chat, and so is one command for each skill you have installed (see [Skills](tools.md#skills)).
|
|
39
39
|
|
|
40
40
|
`/telemetry` prints the model requests of the last 24 hours, one line per model: requests, failures, average time, tokens and cost. The last 10 seconds may not show yet. It says so when telemetry is off.
|
|
41
41
|
|
|
42
|
+
`/learn` runs the learning loop by hand and manages what it proposes. The loop is off until `learning.model` is set. After every `learning.everyTurns` user turns (3 to 100, default 10) that hold at least 1,500 characters of your own text, one background pass sends the recent chat to that model as data, with no tools, and asks for at most 2 skills and 3 memories worth keeping. `learning.thinking` sets the reasoning level (default `low`). A pass that keeps nothing three times in a row doubles the wait, up to 40 turns, and a pass that keeps something resets it. Turns you abort, turns made only of Conclave reports and repeated sends of the same text do not count. A learned skill is never written without you: it is staged under `PIROBOROS_HOME/learn/proposed`, and `/learn accept <name>` shows its text, or a line diff for a change, and asks. `/learn reject <name|all>` drops proposals and the names are not proposed again. `/learn undo <name>` restores the text before the learner changed a skill, or removes a skill it created, and refuses when you have edited the file since. Only skills the learner created can be changed by it, and a name that already exists anywhere is refused. Memories the learner keeps are written as quarantined with the actor `piroboros:learner` and stay out of the memory snapshot until `/akashic accept` releases them. `/learn` alone shows the state, the counts, the last error, why items were refused, the proposals and a pass that the restart limit parked; `/learn retry` runs a parked pass again and `/learn skip` drops it. `/learn now` starts a pass at once over the chat written since the learner became permitted. Learned skills live in `PIROBOROS_HOME/skills`, which is scanned first, so one shadows a later skill of the same name; `/learn` lists such cases.
|
|
43
|
+
|
|
42
44
|
`/login` signs in from the chat. `/login` alone lists the providers, with `[ready]` on the ones that already resolve, and the two web search keys. `/login <provider>` goes straight to one, and `/login web-tinyfish` or `/login web-exa` stores a search key. A provider that offers both an OAuth and an API key method asks which one you want, and a provider that is already signed in asks before it signs in again. What you type is masked in a box that replaces the chat, the credential goes to `auth.json`, and error text is scrubbed before it is shown. The sign-in address is shown on screen and opened with the platform's default handler. Esc cancels, and closing piroboros during a sign-in stops its local callback server. The next turn uses the new credential without a restart.
|
|
43
45
|
|
|
44
|
-
`/settings` changes `settings.json` from the chat. `/settings` lists
|
|
46
|
+
`/settings` changes `settings.json` from the chat. `/settings` lists 32 keys and the 8 Conclave members with their current values (a default is marked as such), and the list filters as you type. `/settings conclave.members.vaelia` lists that member's four keys, and `/settings <key>`, for example `/settings web.maxFetches`, goes straight to a key; an unknown key gets a hint. The editor depends on the key: a choice for words and on/off, a number box that starts at the current value and refuses a value outside the allowed range, the setup model pick for model keys (it signs in when the provider needs it), and for lists such as `guard.deny` a menu of the entries, where picking an entry removes it and "Add an entry" adds one. Every key can be reset to its default, which removes it from the file. The editor says when a change applies: at the next turn, right away, at the next Conclave run or at the next start. `cacheRetention` applies at the next turn: `"short"` keeps the prompt cache for about 5 minutes, and `"long"` keeps it for an hour and costs more per cache write.
|
|
47
|
+
|
|
48
|
+
`guard.allow` opens a project folder inside a protected location, for the file tools and search, so a project that lives in `~/.pi/agent/extensions` can be worked on. An entry is an absolute path at or inside `<pi agent dir>/extensions` (the pi agent dir is `PI_CODING_AGENT_DIR` when set to an absolute path, otherwise `~/.pi/agent`), or strictly inside a `guard.deny` root. It cannot equal a `guard.deny` entry or lie inside `PIROBOROS_HOME`, `~/.ssh` or `~/.claude`, and an entry with a link or junction in its path is ignored with a notice. It lifts only the protected location that holds it: `auth.json`, `settings.json`, `models.json` and `mcp-auth.json` beside it stay refused, and so does any `guard.deny` root inside it. Inside an allowed folder, credential-shaped names (`.env.*` except `.env.example`, `.sample` and `.template`, `.npmrc`, `*.pem`, `*.key`, `*.db`, `*.sqlite`, `credentials*`, `token`, `secrets` and similar) and `.aws`, `.ssh` and `.gnupg` folders are refused, and write and edit refuse the `.git` folder. A setting that fails these rules is refused when saved; one written by hand is ignored at use with a notice. An allowed folder inside the extensions folder is code that pi runs with your credentials: review edits and merges there like code you install, and merge while pi is not running (or reload pi after). The skills scanner reads through the same check, so `SKILL.md` files inside an allowed folder become readable to it.
|
|
49
|
+
|
|
50
|
+
A change to a security-relevant key shows the old and the new value and asks before it is saved. Those keys are `main`, `compactor.model`, `compactor.allowThirdParty`, `learning.model`, `learning.allowThirdParty`, `conclave.defaultModel`, the model of each Conclave member, `shellEnvAllow`, `shellTimeoutMs`, `guard.deny`, `guard.allow` and the `web` keys. `/model` asks the same way when it changes the main model, and asks nothing when the model is already the main one. A compactor model on a host that is not loopback also asks whether third-party use is allowed, as setup does, and setting `web.search.provider` with no stored key offers to enter the key. Every write goes through the same checked path as `/thinking-steps global`: if `settings.json` was edited outside piroboros, the write is refused until `/reload`. When piroboros was started with `--model`, `/settings` says so and explains that a change to `main` applies when it starts without the flag.
|
|
45
51
|
|
|
46
|
-
|
|
52
|
+
`/reload` shows the changed security-relevant settings (hosts, `allowThirdParty`, `shellEnvAllow`, `guard.deny`, `guard.allow`, the `web` keys) and asks before it accepts files that were edited outside piroboros. `/status` shows the messages saved, the summary view size and the cache use of recent responses. The compactor asks its model for lines of at most 400 bytes; 512 bytes stays the hard limit, and a line still over it after five tries is cut at a clause boundary. A provider reply of HTTP 429 or 503 counts as busy: the compactor waits longer and does not count it as an error, up to 20 times per node, and `/status` shows the retries made while the provider was busy. Until a compactor is configured, long messages show as "not summarized yet" lines and each request carries a window of at most 128 KB of the view.
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
`workspace.enabled` (default `true`) and `workspace.nested` (`ask`, `copy` or `inplace`, default `ask`) decide where Vesperia works. With `enabled: false` she writes straight to your project as in 0.2.0. `nested` answers the one-time question for a project that is a repository subfolder, a worktree or a submodule: `copy` gives a Workspace without git, `inplace` works in your folder. Both apply at the next `/conclave approve`, and a held Workspace of another mode refuses the approve until you merge or discard it. `workspace.confine` (`auto`, `none` or `docker`, default `auto`) and `workspace.network` (default `true`) decide how her shell is confined; see [Tools](tools.md#shell-confinement). Both apply at the next Workspace open, and `none` is the only way to turn confinement off on purpose. On Windows, `workspace.wsl.distro` names the WSL distribution to use; unset, the default distribution is used. `workspace.docker.image` (unset by default) names an image you have pulled, such as `node:26.12.1-trixie@sha256:<digest>`; with it set, `auto` tries Docker before bubblewrap, and `docker` needs it. It is a security setting, confirmed on change.
|
package/docs/privacy.md
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
[Back to the README](../README.md)
|
|
4
4
|
|
|
5
5
|
- Each provider you configure receives the prompts for the model you assign to it: the main model gets the chat view, the compactor gets the text it summarizes, and each Conclave member gets its own conversation. Everything sent to the compactor is scrubbed first: credential-shaped strings (keys, authorization headers, PEM blocks, JSON and environment-style labels, password phrases), every value in `auth.json`, and the value of every environment variable named `*_API_KEY`, `*_TOKEN` or `*_SECRET` that is 8 or more characters long. Your local log keeps the raw text. A compactor is a third party when its provider is not the one your main model or any Conclave member uses and its address is not loopback; sending the chat to a third party needs your explicit consent (`compactor.allowThirdParty: true`), and a third party also loses hex strings of 32 or more characters. Without consent the compactor shows as disabled with the reason and nothing is sent. This is checked again on every compactor request, so withdrawing consent and running `/reload` stops the next request. "Loopback" means the host is exactly `localhost`, is inside 127.0.0.0/8, or is `::1`, with no user name or password in the URL; piroboros treats it as user-declared local and cannot check that the address really is.
|
|
6
|
+
- The learning loop (off until `learning.model` is set) sends slices of the root chat to `learning.model`: your messages, the assistant's replies, tool calls and results cut to 1,500 characters each, the skills index, the text of up to two skills it created that the slice read, the names of its pending and rejected proposals and its own memories. It uses the compactor's scrub and the same consent rule: a provider no other role uses, at a non-loopback address, is a third party and needs `learning.allowThirdParty: true`, which is checked on every request. It reads only chat written after it became permitted, and again from the chat end whenever consent is withdrawn and given back, so withdrawn chat is never sent later. It never sends a Conclave member's own conversation. Staged skills, the ledger and its history are files under `PIROBOROS_HOME/learn`. Telemetry records learner requests like the others, without text.
|
|
6
7
|
- Shell output beyond 30,000 characters is cut to its first 12,000 and last 18,000 characters, with a marker in between. The cut part is not saved to any file, so the model has to run the command again to see it.
|
|
7
8
|
- Memory-briefing traces (mnemosia) are written under `PIROBOROS_HOME`. A trace is kept while it is under 90 days old or among the 500 newest, and older ones are deleted at startup. The feedback log, `feedback.jsonl`, is capped at 2 MB; when it passes the cap, the oldest lines are dropped.
|
|
8
|
-
- The shell tool is not path-confined. The guard limits which agents may write. A shell command can reach any path your account can.
|
|
9
|
+
- The shell tool is not path-confined by the guard. The guard limits which agents may write. A shell command can reach any path your account can, except Vesperia's commands in a confined Workspace (bubblewrap on Linux or in WSL 2, or Docker), which see a read-only system or a container and no home folder (see [Shell confinement](tools.md#shell-confinement)).
|
|
9
10
|
- Shell commands that kill processes (`kill`, `pkill`, `killall`, `taskkill`, `tskill`, `Stop-Process`, `spps`, or `wmic` deleting a process) are refused, because `taskkill /IM node.exe` would also end piroboros. This is a tripwire against accidents, not a sandbox: a command can be worded around it.
|
|
10
11
|
- piroboros records model request and task timings to `telemetry.sqlite` under `PIROBOROS_HOME` and sends them nowhere. It records provider and model names, tool names, token counts, cost, durations, stop reasons and error kinds, never message text, tool arguments, tool output or error messages. Records older than 7 days are deleted while piroboros runs. Telemetry is on by default; `"telemetry": false` stops it at the next start, and deleting the file removes what was recorded.
|
|
11
12
|
- piroboros sends no provider attribution headers. Requests still carry the User-Agent `pi/<version> (<platform>; node/<v>; <arch>)` set by pi-ai.
|
|
12
13
|
- The first start of this version copies `chat.sqlite` to `chat.schema1.sqlite` before upgrading it. The copy holds the whole chat, like `chat.sqlite` itself. Delete it once you no longer need to go back to 0.1.0.
|
|
13
14
|
- The memory vault mirrors to a private GitHub repository. Only GitHub remotes are tested.
|
|
15
|
+
- Vesperia's Workspace copies are folders of exact copies of your git-visible project files, under `%LOCALAPPDATA%\piroboros-ws` on Windows, `~/Library/Application Support/piroboros-ws` on macOS and `$XDG_STATE_HOME/piroboros-ws` (default `~/.local/state/piroboros-ws`) elsewhere. The snapshots taken before a merge and the merge records are stored in `PIROBOROS_HOME/ws/store.sqlite`, and a snapshot holds the live bytes of each path the merge changes. These files can contain secrets that are already in your project. Secret-named files and git-ignored files are not copied. They stay on your machine; what Vesperia reads from the Workspace goes to her model as any file she reads does.
|
package/docs/tools.md
CHANGED
|
@@ -7,6 +7,47 @@
|
|
|
7
7
|
- `find` and `grep` search the working directory. They use fff (`@ff-labs/fff-node`, an indexed finder) and fall back to ripgrep when fff cannot load or returns an error, or when `grep` is called with `exact: true`. Each result says which backend answered in `details.backend`. If neither fff nor `rg` works, the tools return a named error (`search_unavailable`). A ripgrep run that fails, for example on an invalid glob, returns `search_rg_failed` with its first error line instead of an empty result. The fff databases live in `${PIROBOROS_HOME}/fff/`. Results under protected locations (`PIROBOROS_HOME`, `~/.ssh`, `.env` files, `guard.deny`) are dropped, credential-shaped text is redacted, and output is capped at 20,000 characters.
|
|
8
8
|
- The `plan` tool keeps a short task list for the current request. The model sends the whole list each time, with exactly one item in progress. The list is shown to the model with every message of that request and is cleared when the next user message starts. Set `"planning": false` in `settings.json` to remove the tool; the change applies at the next start.
|
|
9
9
|
- If the model makes the same tool call five times in a row, it gets a reminder to change approach. If the same call fails eight times in a row, the turn ends and the status line says `stopped (stuck)`. Denied calls do not count. If the model's run produces no output and no tool is running for ten minutes, the turn ends and the status line says `stopped (idle)`. If one run makes 256 tool rounds without finishing, the turn ends and the status line says `stopped (round limit)`.
|
|
10
|
+
- A `bash` command is refused when its text names a protected location (`PIROBOROS_HOME`, `~/.pi`, `~/.ssh`, `~/.claude`, `guard.deny`) in a Windows, Git Bash, WSL or `~`/`$HOME`/`%USERPROFILE%` spelling, names a credential file (`auth.json`, `.netrc`, `id_ed25519` and the like, but not `*.pub`), or uses `..` to climb out of the `guard.allow` folder it runs in. A path inside a `guard.allow` folder is not refused. This is a tripwire against accidents, not confinement: a command can be worded around it, and only Vesperia's commands in a confined Workspace are sandboxed (see below).
|
|
11
|
+
|
|
12
|
+
## Shell confinement
|
|
13
|
+
|
|
14
|
+
With Workspaces on (the default), Vesperia's `bash` commands run inside bubblewrap on Linux when `bwrap` is on PATH and a self-test passes at the moment the Workspace opens. The choice is kept for that Workspace and made again when it is reopened. On Ubuntu install the `bubblewrap` package. Ubuntu 23.10 and later restrict unprivileged user namespaces by default; when that blocks bubblewrap the self-test fails and the start notice names the reason. On Windows the commands run inside bubblewrap in WSL (see below). When `workspace.docker.image` is set, Docker is tried first on every system (see [Docker](#docker)). macOS has no bubblewrap, so its commands run in Docker or are not confined, and the notice and `/conclave status` say which.
|
|
15
|
+
|
|
16
|
+
- What a command sees: the whole system read-only, the Workspace read-write, an empty `/tmp`, and a home folder with nothing in it. `PIROBOROS_HOME`, `~/.pi`, `~/.ssh`, `~/.claude` and every `guard.deny` folder outside the home are hidden. Folders named on PATH under your home (`~/bin`, `~/.local/bin`, a Node version folder) stay visible read-only, so tools installed there keep working. The live `.git/objects` of the project, and the object folders it borrows from through its own alternates, are visible read-only so that git works in the Workspace. The list is taken from your live repository when the Workspace opens or reopens, never from the Workspace's own `.git/objects/info/alternates`, and only a folder named `objects` is shared.
|
|
17
|
+
- What it cannot do: write outside the Workspace (the write fails, or lands in `/tmp` or the empty home folder and disappears when the command ends) or read your credentials. A live project inside your home is hidden; one outside your home, its `node_modules` included, is still readable by absolute path. Because `/tmp` and the home folder are fresh for every command, `git commit` there uses only the `user.name` and `user.email` kept from the live repository's local config.
|
|
18
|
+
- Network: `workspace.network` (default `true`) lets installs work. With it on, a command can reach your network and send any file it can see. Set it to `false` to cut the network.
|
|
19
|
+
- A command is passed to `bash -c` as one argument, so it can be at most 131,071 bytes and cannot hold a NUL byte; a longer one is refused with a message that suggests a script file in the Workspace. A command that runs past the timeout is killed with everything it started.
|
|
20
|
+
- If a command cannot start, it fails with an error and is never run again without confinement. If bubblewrap was not usable when the Workspace opened, the start notice, her brief and `/conclave status` say the shell is not confined. `workspace.confine: "none"` turns confinement off on purpose.
|
|
21
|
+
|
|
22
|
+
### The seccomp filter
|
|
23
|
+
|
|
24
|
+
Every sandbox, native or in WSL, also loads a small seccomp filter (written in `src/ws/confine.ts`, no library). It does three things: `socket` and `socketpair` calls for the AF_VSOCK family fail with EAFNOSUPPORT, the three `io_uring` calls fail with EPERM, and a process using a CPU architecture other than x86_64 or aarch64, or the 32-bit x32 system calls, is killed. Everything else is allowed. AF_VSOCK is not scoped to the sandbox's network namespace, and in WSL the Windows host answers on it (one of its ports serves your drives), so closing it matters more than the network setting. The self-test checks that a vsock socket cannot be created; a filter that does not load or a failing self-test gives no sandbox, with the warning, never an unfiltered one.
|
|
25
|
+
|
|
26
|
+
Residuals: with the network on, a command can still reach TCP ports on the Windows host and on your network, and can send any file it can see. 32-bit programs (x86 or ARM) and x32 programs do not run in the sandbox. The filter is not a general system call policy.
|
|
27
|
+
|
|
28
|
+
### Windows: bubblewrap in WSL
|
|
29
|
+
|
|
30
|
+
Install WSL 2 with a distribution whose default user is not root (Ubuntu 24.04 is the tested one), then in that distribution install `bubblewrap`, and Node 26.5 or later if your project needs `npm`. Do not use the `docker-desktop` distribution; it cannot run commands. Set `workspace.wsl.distro` to pick a distribution other than the default; the distribution and user are fixed when a Workspace opens and kept while they still resolve.
|
|
31
|
+
|
|
32
|
+
- Commands run as that user through `wsl.exe` with an argument list, never a shell string, with a minimal environment (PATH, HOME, USER, LANG and a few terminal settings) built inside WSL: nothing from your Windows environment reaches them.
|
|
33
|
+
- The Workspace stays on your Windows drive and the sandbox sees it through `/mnt/<drive>`. Everything else Windows-backed is hidden: your profile, `System32`, `PIROBOROS_HOME` and every `guard.deny` folder. A Windows program inside the Workspace does not run, and the WSL interop socket is masked.
|
|
34
|
+
- `node_modules` lives in a folder in the distribution's own filesystem (under `~/.local/state/piroboros-ws`), so `npm ci` is fast; it is empty on the Windows side and is removed with the Workspace. Files a command writes there are not merged.
|
|
35
|
+
- The Workspace folder is on drvfs, which is slow for many small files: expect the first `git status` in a project of 5,000 tracked files to take most of a minute and later ones a couple of seconds. The start notice gives an estimate above 1,000 files. A path inside the Workspace that the sandbox shows as `/mnt/c/...` is the Linux view of a Windows path; the file tools want the Windows form.
|
|
36
|
+
- `workspace.network: true` gives the commands the WSL VM's network, which includes the Windows host. Set it to `false` to cut it.
|
|
37
|
+
- A project on a network share (UNC path) is not confined, with the reason in the notice.
|
|
38
|
+
|
|
39
|
+
### Docker
|
|
40
|
+
|
|
41
|
+
Set `workspace.docker.image` to an image you have already pulled, for example `node:26.12.1-trixie@sha256:<digest>`. piroboros never pulls an image; a missing one refuses with the `docker pull` line to run. With the image set and `workspace.confine` at `auto`, Docker is tried first and bubblewrap second; `workspace.confine: "docker"` refuses the run when Docker cannot be used and never falls back.
|
|
42
|
+
|
|
43
|
+
- One container per Workspace, started when the Workspace opens or reopens and removed at merge, discard, hold and recovery. It runs with all capabilities dropped, `no-new-privileges`, at most 1,024 processes, and a stored 64-character container id that every command uses. Containers carry a label with a hash of your `PIROBOROS_HOME`; the startup sweep removes the ones of that hash that no open Workspace names, and never touches another home's.
|
|
44
|
+
- What a command sees: the image, and the Workspace at `/work`. Nothing else of your machine is mounted: not your home, `PIROBOROS_HOME` or your credentials. The live `.git/objects` is mounted read-only at `/piroboros-objects` for a Workspace with git. `HOME` is `/tmp` inside. On Linux the command runs as your user id; on Windows as the distribution's user. Writes outside `/work` land in the container and are lost when it is removed. `node_modules` is an empty folder in the Workspace (on Windows, a folder in the distribution's own filesystem), never merged.
|
|
45
|
+
- The Engine's built-in seccomp profile is kept, which refuses AF_VSOCK sockets and `io_uring`. An Engine without seccomp is refused. When the container starts, a self-test checks that a vsock socket cannot be created and that `io_uring_setup` fails (it needs `perl` in the image; without it the check is skipped with a notice). A failed check refuses Docker with the reason.
|
|
46
|
+
- piroboros runs the `docker` CLI with an empty client config of its own (so a context or credential helper in `~/.docker` never runs). Only environment variable names are passed to `docker exec`; their values are read from the CLI's own environment, never from the argument list. A command can be at most 131,071 bytes and cannot hold a NUL byte, as with bubblewrap.
|
|
47
|
+
- A command that runs past the timeout restarts the container, which ends everything it started; `/work` survives. When a command exits nonzero, piroboros asks the Engine whether the container is still running. If it is not, or the Engine does not answer, the command fails with `confinement backend unavailable`, no later command runs, nothing runs unconfined, and the run ends held with that reason. A reopen starts a new container.
|
|
48
|
+
- Windows: Docker means the Engine installed inside your WSL 2 distribution (the `docker-ce` package, with your user in the `docker` group, which is root-equivalent inside that distribution), reached as `/usr/bin/docker` through `wsl.exe`. Docker Desktop is refused, whether it is the Engine's name or its integration socket under `/mnt/wsl`. Set `workspace.wsl.distro` if it is not the default distribution. A rootless Engine is not supported.
|
|
49
|
+
- Network: `workspace.network` (default `true`) puts the container on the bridge network; `false` gives it none. With it on a command can reach your network (on Windows, the WSL VM's network, which includes the Windows host) and send any file it can see.
|
|
50
|
+
- Cost per command (measured on Windows with Docker in WSL 2): about 0.7 s, against 0.2 s for bubblewrap in WSL and 0.06 s unconfined; opening a Workspace with Docker takes about 6 s.
|
|
10
51
|
|
|
11
52
|
## Skills
|
|
12
53
|
|
|
@@ -16,5 +57,6 @@ A skill is a folder with a `SKILL.md` file. The file starts with a block between
|
|
|
16
57
|
- **What is read.** Only `name` and `description`, as plain, quoted or block (`>` and `|`) values. Other keys, including nested ones, are ignored. A name is lowercase letters, digits and single hyphens, at most 64 characters, and it may differ from its folder name. A description is cut to 512 characters, and a `SKILL.md` over 256 KB is skipped. A bad file is skipped with a reason that `/skills` shows, and it never stops startup.
|
|
17
58
|
- **What the model sees.** One line per skill (name, description and folder) in a `skills` section of the system prompt, after the chat section. The text changes only when the list changes, or when a name, description or folder does, so prompt caching keeps working. It is capped at 20 KB, filled in the order above, and `/skills` lists what did not fit. The model opens a `SKILL.md` with the `read` tool when a task matches it, and the section says that a `SKILL.md` at a listed path is your instruction. With no skills installed there is no section. A skill deleted after the last scan gives a read error until `/reload`.
|
|
18
59
|
- **Project skills need a yes.** The first time a project skill is seen, and again whenever its `SKILL.md` changes, the chat asks one question for all of them, listing the names and paths. Yes loads them. No records each as declined, and it stays out until its file changes; typing `/name` for it says so. The answers are in `PIROBOROS_HOME/skills-trust.json`, which is checked like the other config files: an edit outside piroboros is shown at startup, and a missing, corrupt or edited file means every project skill is asked about again. The question opens when the chat screen opens. Until you answer, the index holds your own skills only, and a yes adds the project ones. With `--print` no question is possible, so project skills are left out, nothing is recorded and one line on stderr says how many. Only `SKILL.md` is pinned. Scripts and other files beside it can change without a new question, so say yes only to a folder you trust.
|
|
60
|
+
- **Learned skills.** With `learning.model` set, piroboros can propose skills from your chat. They are staged outside the skills folder and written to `PIROBOROS_HOME/skills` only by `/learn accept <name>`; see [Chat commands](configuration.md#chat-commands).
|
|
19
61
|
- **Commands.** `/skill-name some request` is sent to the chat exactly as typed, and the model reads the skill. Skills appear in the command list after the built-in commands, with their descriptions. A skill named like a built-in command, such as `conclave`, stays available to the model only, and so does a name that starts with a digit. A name with a digit in it is a command only when it is a loaded skill, so `/42 is the answer` and `/v2` stay ordinary text. `/skills` lists the loaded, shadowed, skipped, declined, waiting and over-budget skills. `/reload` rescans and asks about new project skills.
|
|
20
|
-
- **Reading inside `PIROBOROS_HOME`.** The `read` tool may open files under `PIROBOROS_HOME/skills`, so skills installed there work. Files named like secrets stay refused there: `.env` files, `*.pem`, `*.key`, `*.p12`, `*.pfx`, `*.kdbx`, `id_rsa*`, `id_ed25519*`, `id_ecdsa*`, `*.sqlite*`, `auth.json`, `.netrc` and `.npmrc`. Everything else in the home stays refused for every tool: credentials, settings, the chat database, memory, traces, undo copies and the trust file. Writing under `skills` is refused too, a link out of that folder to a protected place is refused, and a `SKILL.md` that is linked into a protected place is skipped. `find` and `grep` search the working directory only, so they never reach it. The guard is a tripwire for the file tools. It cannot tell a hard link from a file, and shell commands are not confined.
|
|
62
|
+
- **Reading inside `PIROBOROS_HOME`.** The `read` tool may open files under `PIROBOROS_HOME/skills`, so skills installed there work. Files named like secrets stay refused there: `.env` files, `*.pem`, `*.key`, `*.p12`, `*.pfx`, `*.kdbx`, `id_rsa*`, `id_ed25519*`, `id_ecdsa*`, `*.sqlite*`, `auth.json`, `.netrc` and `.npmrc`. Everything else in the home stays refused for every tool: credentials, settings, the chat database, memory, traces, undo copies and the trust file. Writing under `skills` is refused too, a link out of that folder to a protected place is refused, and a `SKILL.md` that is linked into a protected place is skipped. `find` and `grep` search the working directory only, so they never reach it. The guard is a tripwire for the file tools. It cannot tell a hard link from a file, and the root chat's shell commands are not confined.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piroboros",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "A Windows-first TUI agent harness with one durable chat that never ends.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "samael",
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "26.6.4",
|
|
64
64
|
"@types/react": "19.3.0",
|
|
65
|
-
"baseline-browser-mapping": "^2.11.30",
|
|
66
65
|
"typescript": "7.0.2"
|
|
67
66
|
},
|
|
68
67
|
"overrides": {
|
package/settings.json.example
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"maxConcurrent": 8,
|
|
8
8
|
"allowThirdParty": false
|
|
9
9
|
},
|
|
10
|
+
"learning": { "thinking": "low", "everyTurns": 10, "allowThirdParty": false },
|
|
10
11
|
"conclave": {
|
|
11
12
|
"defaultModel": "example-llm/example-chat",
|
|
12
13
|
"maxTurns": 64,
|
|
@@ -21,7 +22,8 @@
|
|
|
21
22
|
"cacheRetention": "short",
|
|
22
23
|
"shellEnvAllow": [],
|
|
23
24
|
"shellTimeoutMs": 600000,
|
|
24
|
-
"guard": { "deny": [] },
|
|
25
|
+
"guard": { "deny": [], "allow": [] },
|
|
26
|
+
"workspace": { "enabled": true, "nested": "ask", "confine": "auto", "network": true },
|
|
25
27
|
"planning": true,
|
|
26
28
|
"telemetry": true,
|
|
27
29
|
"web": { "enabled": false, "maxFetches": 10, "maxSearches": 5, "search": { "provider": "tinyfish" }, "allowHosts": [], "queryHosts": [] },
|