Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

feat(release,server,web): publish sandbox plugins on all dist (#873)

Myriad-Dreamin1987662b0a3f
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 2403a1cb..00df2cca 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -207,11 +207,18 @@ jobs:
# bin/penguin is scripts/launchers/penguin, shipped verbatim — it is the one spelling of
# the payload layout (lib/dist/penguin.js, web/, an optional node/), and the shape
# scripts/test-installer.sh pins.
- - name: Assemble penguin/ (lib + web + bin)
+ # lib/plugins/: the builtin plugins (the sandbox backends among them) as the npm prefix
+ # the desktop app ships too — the server looks one directory above dist/ for it — so an
+ # installed CLI enables this platform's sandbox backend from the Plugins page with no
+ # registry, the same as the desktop app. Shipped, not installed: nothing loads until the
+ # operator adds it. One prefix serves every payload below (native parts per platform).
+ - name: Assemble penguin/ (lib + web + bin + plugins)
run: |
pnpm --config.node-linker=hoisted --filter @prismshadow/penguin-cli --prod deploy "$PWD/out/penguin/lib"
cp -r packages/web/dist out/penguin/web
install -D -m 755 scripts/launchers/penguin out/penguin/bin/penguin
+ node scripts/build-plugins.mjs --out out/penguin/lib/plugins
+ test -f out/penguin/lib/plugins/node_modules/@prismshadow/penguin-plugin-sandbox-bwrap/package.json
# Program payloads: linux runtimes use .tar.xz, darwin .tar.gz (nodejs.org naming);
# node/ is only lightly trimmed (drop share/doc and share/man, keep the rest). Payloads
diff --git a/changelog/unreleased/2026-09-28-sandbox-on-every-install.md b/changelog/unreleased/2026-09-28-sandbox-on-every-install.md
new file mode 100644
index 00000000..b1488f54
--- /dev/null
+++ b/changelog/unreleased/2026-09-28-sandbox-on-every-install.md
@@ -0,0 +1,29 @@
+# The sandbox is there on every install
+
+- **Date:** 2026-09-28
+- **Type:** feat
+- **Scope:** `release`, `server`, `web`
+
+[中文版](2026-09-28-sandbox-on-every-install.zh.md)
+
+The same sandbox on every platform and every way of installing: the composer's permission menu,
+the Sandbox card on the Settings dialog's Plugins page, and this platform's backend ready to
+enable. What differs by platform is which backend serves and its own options, drawn inside the
+Sandbox card. Confinement still starts Off; nothing is enabled for the operator.
+
+- **The installed CLI carries the builtin plugins.** Every installer payload (Linux, macOS,
+ Windows) now ships the builtin plugin prefix under `lib/plugins/` — the four sandbox backends
+ among them — as the desktop app already did. Enabling this platform's backend from the Plugins
+ page copies nothing over the network; before, an installed CLI had to fetch it from the npm
+ registry, and on a host that cannot reach it there was no sandbox to enable.
+- **The composer says when nothing can enforce a level.** With no sandbox backend installed,
+ Read only, Workspace write, No network and Local network stay listed, greyed out and marked
+ "Not installed", with how to add one in their tooltip — where before they could be picked and
+ every command was then refused. When a backend is enabled but failed to load or failed its
+ check (the WSL backend before its distro is set up), the same levels are marked "Unavailable"
+ instead, and the tooltip names the backend and gives its reason. A backend that confines files
+ but not the network (the DSH adaptor) greys out only the network levels it cannot enforce.
+- The Session's `sandbox` object in the API gains three response-only fields beside
+ `localNetworkSupported`: `confinementSupported` (Read only and Workspace write can be
+ enforced), `noNetworkSupported` (No network can be) and `unavailableBackends` (each enabled
+ backend that is not in use, with why; one for another platform is not listed).
diff --git a/changelog/unreleased/2026-09-28-sandbox-on-every-install.zh.md b/changelog/unreleased/2026-09-28-sandbox-on-every-install.zh.md
new file mode 100644
index 00000000..fc28cfb1
--- /dev/null
+++ b/changelog/unreleased/2026-09-28-sandbox-on-every-install.zh.md
@@ -0,0 +1,13 @@
+# 每一种安装都有沙盒
+
+- **Date:** 2026-09-28
+- **Type:** feat
+- **Scope:** `release`, `server`, `web`
+
+[English](2026-09-28-sandbox-on-every-install.md)
+
+每个平台、每种安装方式看到的是同一个沙盒:输入框的权限菜单、设置对话框插件页上的「沙盒」卡片,以及随时可以启用的本平台后端。平台之间的区别只在由哪个后端实施、以及它自己的选项(画在「沙盒」卡片里面)。封禁仍默认关闭,不替运维启用任何东西。
+
+- **安装的 CLI 带上内置插件。** 各平台(Linux、macOS、Windows)的安装包都在 `lib/plugins/` 下附带内置插件前缀——其中包括四个沙盒后端——与桌面端此前的做法相同。在插件页启用本平台的后端不再经过网络;此前安装的 CLI 要从 npm registry 取包,连不上 registry 的主机就没有沙盒可启用。
+- **输入框说明哪些档位没有后端能实施。** 未安装任何沙盒后端时,「只读」「仅工作区可写」「无网络」「本地网络」仍列出,但置灰并标注「未安装」,提示里写明如何添加后端——此前它们可以被选中,随后每条命令都会被拒绝。后端已启用、但加载失败或检查没通过时(例如专用发行版尚未初始化的 WSL 后端),这几个档位改标「不可用」,提示里写出该后端的名字与原因。只能封禁文件、不能管网络的后端(DSH 适配器)只置灰它实施不了的网络档位。
+- API 中 Session 的 `sandbox` 对象在 `localNetworkSupported` 旁新增三个仅用于响应的字段:`confinementSupported`(「只读」与「仅工作区可写」可以实施)、`noNetworkSupported`(「无网络」可以实施)与 `unavailableBackends`(已启用但未在用的后端及原因;适用于其他平台的后端不列)。
diff --git a/packages/server/src/api/types.ts b/packages/server/src/api/types.ts
index 1cbca80c..3adf42bb 100644
--- a/packages/server/src/api/types.ts
+++ b/packages/server/src/api/types.ts
@@ -1468,12 +1468,34 @@ export interface SessionSandbox {
mode: SessionSandboxMode;
/** `open` = unrestricted, `local` = only the host's localhost, `none` = no network. */
network: SessionSandboxNetwork;
+ /**
+ * Response only, ignored in requests: whether a sandbox backend on this server can enforce
+ * the `read-only` and `workspace-write` modes. False on a deployment with no backend
+ * installed, where either mode would refuse every command: the composer shows them greyed
+ * out, saying no backend is installed.
+ */
+ confinementSupported?: boolean;
+ /** Response only, ignored in requests: the same for the `none` network level. */
+ noNetworkSupported?: boolean;
/**
* Response only, ignored in requests: whether a sandbox backend on this server can enforce
* the `local` level. When false the composer shows it greyed out, and picking it is refused
* (400 `sandbox_unsupported`).
*/
localNetworkSupported?: boolean;
+ /**
+ * Response only, ignored in requests: the sandbox backends that are enabled here but failed
+ * to load or failed their check (a WSL distro not set up, a wrong program path), each with
+ * why. A backend for another platform is not listed. With none mounted and one listed, the
+ * composer marks the confining levels unavailable and gives the first one's reason.
+ */
+ unavailableBackends?: UnavailableSandboxBackend[];
+}
+
+/** An enabled sandbox backend that is not in use on this server, and why. */
+export interface UnavailableSandboxBackend {
+ name: string;
+ reason: string;
}
/** The network levels, widest first. */
diff --git a/packages/server/src/runtime/session-manager.ts b/packages/server/src/runtime/session-manager.ts
index 6133209d..0d624d50 100644
--- a/packages/server/src/runtime/session-manager.ts
+++ b/packages/server/src/runtime/session-manager.ts
@@ -2703,8 +2703,8 @@ export class SessionsModule {
confineSpawn: env.confineSpawn,
assembly,
sandboxDefaults: () => sandbox.currentSettings(),
- sandboxLocalNetwork: () =>
- sandbox.backends().some((b) => b.dimensions.includes("network-local")),
+ sandboxDimensions: () => [...new Set(sandbox.backends().flatMap((b) => b.dimensions))],
+ sandboxUnavailable: () => sandbox.failures(),
});
this.manager = manager;
this.sessionService = sessionService;
diff --git a/packages/server/src/services/session-service.ts b/packages/server/src/services/session-service.ts
index 08c70b85..4901d5a5 100644
--- a/packages/server/src/services/session-service.ts
+++ b/packages/server/src/services/session-service.ts
@@ -30,6 +30,7 @@ import type {
SessionSandbox,
SessionSource,
ServerEvent,
+ UnavailableSandboxBackend,
} from "../api/types.js";
import { HttpError, isMissingCredential, modelCredentialMissing } from "../http/errors.js";
import { badRequest } from "../http/validate.js";
@@ -41,7 +42,7 @@ import { matchesWorkspaceGroup } from "./workspace-group.js";
import type { TraceIndex, TraceIndexStore } from "../mechanisms/traces.js";
import type { SessionIndex, SessionOrigins } from "../mechanisms/sessions.js";
import type { ProjectConfigStore } from "../mechanisms/projects.js";
-import type { SandboxSettings } from "@prismshadow/penguin-core/plugin";
+import type { SandboxDimension, SandboxSettings } from "@prismshadow/penguin-core/plugin";
const SANDBOX_MODE_RANK: Record<SandboxSettings["mode"], number> = {
"read-only": 0,
@@ -60,12 +61,25 @@ function networkOf(policy: SandboxSettings): SessionSandbox["network"] {
return policy.network ?? "open";
}
-/** A stored policy as the composer sees it, with whether this server can enforce `local`. */
+/**
+ * A stored policy as the composer sees it, with which of its levels this server can enforce:
+ * `dimensions` is what the mounted sandbox backends implement between them — none on a
+ * deployment that has not installed one. `unavailable` is each backend that is enabled but
+ * failed to load or failed its check, with why; one for another platform is not among them.
+ */
export function sessionSandboxOf(
policy: SandboxSettings,
- localNetworkSupported = false,
+ dimensions: readonly SandboxDimension[] = [],
+ unavailable: readonly UnavailableSandboxBackend[] = [],
): SessionSandbox {
- return { mode: policy.mode, network: networkOf(policy), localNetworkSupported };
+ return {
+ mode: policy.mode,
+ network: networkOf(policy),
+ confinementSupported: dimensions.includes("fs-write"),
+ noNetworkSupported: dimensions.includes("network"),
+ localNetworkSupported: dimensions.includes("network-local"),
+ unavailableBackends: unavailable.map(({ name, reason }) => ({ name, reason })),
+ };
}
/**
@@ -186,8 +200,10 @@ export interface SessionServiceDeps {
sandboxDefaults?: () => SandboxSettings;
/** Host-owned model-request hooks, forwarded to core for every Session LLM. */
assembly?: AgentAssembly;
- /** Whether a mounted sandbox backend implements the `local` network level. */
- sandboxLocalNetwork?: () => boolean;
+ /** The dimensions the mounted sandbox backends implement between them (none when absent). */
+ sandboxDimensions?: () => readonly SandboxDimension[];
+ /** The enabled sandbox backends that failed to load or failed their check, with why. */
+ sandboxUnavailable?: () => readonly UnavailableSandboxBackend[];
}
export class SessionService {
@@ -200,12 +216,20 @@ export class SessionService {
/** Whether this server can enforce the `local` network level right now. */
localNetworkSupported(): boolean {
- return this.deps.sandboxLocalNetwork?.() ?? false;
+ return this.sandboxDimensions().includes("network-local");
}
- /** A policy as the composer sees it, with this server's support for `local`. */
+ private sandboxDimensions(): readonly SandboxDimension[] {
+ return this.deps.sandboxDimensions?.() ?? [];
+ }
+
+ /** A policy as the composer sees it, with which of its levels this server can enforce. */
sandboxView(policy: SandboxSettings): SessionSandbox {
- return sessionSandboxOf(policy, this.localNetworkSupported());
+ return sessionSandboxOf(
+ policy,
+ this.sandboxDimensions(),
+ this.deps.sandboxUnavailable?.() ?? [],
+ );
}
/** A Session's policy: its snapshot, or — for a row from before snapshots — the settings. */
diff --git a/packages/server/test/project-chat-defaults.test.ts b/packages/server/test/project-chat-defaults.test.ts
index e974fa4d..df57ba80 100644
--- a/packages/server/test/project-chat-defaults.test.ts
+++ b/packages/server/test/project-chat-defaults.test.ts
@@ -31,7 +31,14 @@ import type { TestApp } from "./helpers.js";
/** What GET serves beside the block: the sandbox policy a new Session starts with (read-only). */
const SERVED = {
- sandbox: { mode: "danger-full-access", network: "open", localNetworkSupported: false },
+ sandbox: {
+ mode: "danger-full-access",
+ network: "open",
+ confinementSupported: false,
+ noNetworkSupported: false,
+ localNetworkSupported: false,
+ unavailableBackends: [],
+ },
};
/** The file's app and its three users; every case below works in a Project of its own. */
diff --git a/packages/server/test/session-sandbox.test.ts b/packages/server/test/session-sandbox.test.ts
index cba5bfcd..62b135c3 100644
--- a/packages/server/test/session-sandbox.test.ts
+++ b/packages/server/test/session-sandbox.test.ts
@@ -16,6 +16,14 @@ import { applySandboxPick, sessionSandboxOf } from "../src/services/session-serv
const sqlite = process.getBuiltinModule("node:sqlite");
+/** What a server with no sandbox backend mounted says it can enforce: nothing. */
+const NO_BACKEND = {
+ confinementSupported: false,
+ noNetworkSupported: false,
+ localNetworkSupported: false,
+ unavailableBackends: [],
+};
+
const ROW: SessionRow = {
sessionId: "session-1",
projectId: "p",
@@ -43,7 +51,46 @@ describe("picking a Session's sandbox from the composer", () => {
expect(sessionSandboxOf(next)).toEqual({
mode: "read-only",
network: "none",
+ ...NO_BACKEND,
+ });
+ });
+
+ it("says which levels the mounted backends can enforce, and none without a backend", () => {
+ const policy: SandboxSettings = { mode: "danger-full-access" };
+ expect(sessionSandboxOf(policy)).toEqual({
+ mode: "danger-full-access",
+ network: "open",
+ ...NO_BACKEND,
+ });
+ // A filesystem-only backend (the DSH adaptor) confines, but cannot cut the network.
+ expect(sessionSandboxOf(policy, ["fs-write"])).toEqual({
+ mode: "danger-full-access",
+ network: "open",
+ confinementSupported: true,
+ noNetworkSupported: false,
localNetworkSupported: false,
+ unavailableBackends: [],
+ });
+ });
+
+ it("names an enabled backend that failed its check, and leaves out one for another platform", async () => {
+ const svc = new SandboxService([
+ [
+ "penguin-wsl",
+ () => Promise.reject(new Error("the sandbox distro is not set up; run Set up")),
+ ],
+ // Another platform's backend declines: nothing is wrong with it here.
+ ["penguin-seatbelt", () => null],
+ ]);
+ await svc.whenReady();
+ const dimensions = [...new Set(svc.backends().flatMap((b) => b.dimensions))];
+ expect(sessionSandboxOf({ mode: "danger-full-access" }, dimensions, svc.failures())).toEqual({
+ mode: "danger-full-access",
+ network: "open",
+ ...NO_BACKEND,
+ unavailableBackends: [
+ { name: "penguin-wsl", reason: "the sandbox distro is not set up; run Set up" },
+ ],
});
});
@@ -63,10 +110,13 @@ describe("picking a Session's sandbox from the composer", () => {
const open: SandboxSettings = { mode: "workspace-write" };
const local = applySandboxPick(open, { network: "local" }, open, false, true);
expect(local.network).toBe("local");
- expect(sessionSandboxOf(local, true)).toEqual({
+ expect(sessionSandboxOf(local, ["fs-write", "network", "network-local"])).toEqual({
mode: "workspace-write",
network: "local",
+ confinementSupported: true,
+ noNetworkSupported: true,
localNetworkSupported: true,
+ unavailableBackends: [],
});
// Under settings of "local", a non-admin may cut the network but not open it.
const localDefaults: SandboxSettings = { mode: "workspace-write", network: "local" };
@@ -187,7 +237,7 @@ describe("the API: settings seed new Sessions, and never reach existing ones", (
expect(first.session.sandbox).toEqual({
mode: "workspace-write",
network: "none",
- localNetworkSupported: false,
+ ...NO_BACKEND,
});
// The settings change: a new Session starts from it, the existing one does not move.
@@ -198,13 +248,13 @@ describe("the API: settings seed new Sessions, and never reach existing ones", (
expect(again.session.sandbox).toEqual({
mode: "workspace-write",
network: "none",
- localNetworkSupported: false,
+ ...NO_BACKEND,
});
const second = (await (await create()).json()) as Created;
expect(second.session.sandbox).toEqual({
mode: "read-only",
network: "open",
- localNetworkSupported: false,
+ ...NO_BACKEND,
});
// A non-admin tightens freely, and may not loosen past the settings.
@@ -215,7 +265,7 @@ describe("the API: settings seed new Sessions, and never reach existing ones", (
expect(((await tightened.json()) as Created).session.sandbox).toEqual({
mode: "read-only",
network: "none",
- localNetworkSupported: false,
+ ...NO_BACKEND,
});
const loosened = await owner.patch(`/api/sessions/${second.session.sessionId}`, {
sandbox: { mode: "danger-full-access" },
diff --git a/packages/web/src/features/chat/permission-select.tsx b/packages/web/src/features/chat/permission-select.tsx
index c0172219..a19bf276 100644
--- a/packages/web/src/features/chat/permission-select.tsx
+++ b/packages/web/src/features/chat/permission-select.tsx
@@ -5,7 +5,9 @@
* administrator, More…, which opens the Settings page's Sandbox card.
*
* Filesystem and Network edit the Session's own sandbox policy: a Session keeps the policy it
- * was created with, so the Settings page only decides what NEW Sessions start from.
+ * was created with, so the Settings page only decides what NEW Sessions start from. The menu is
+ * the same on every platform; a level this server cannot enforce is greyed out rather than
+ * hidden — with no sandbox backend installed, every level short of full access, marked so.
*
* Approval lists the modes the composer passes in (see approval-mode.ts): an organization's
* Session is not offered `always-ask` unless it is the current value.
@@ -29,8 +31,12 @@ import { toneInk } from "../../lib/tone";
import {
PERMISSION_LEVEL_GLYPH,
PERMISSION_LEVEL_TONE,
+ firstUnavailableBackend,
+ fsModeBlock,
+ networkBlock,
permissionLevel,
} from "../../lib/permission-level";
+import type { LevelBlock } from "../../lib/permission-level";
import { useAuth } from "../../state/auth";
import { SettingsDialog } from "../settings/settings-dialog";
@@ -39,18 +45,21 @@ const NETWORK_MODES: SessionSandbox["network"][] = ["open", "local", "none"];
/**
* One choice row: its text, and a check when it is the current value. An unavailable choice
- * stays listed, greyed out, with a short note saying why (`unavailable`).
+ * stays listed, greyed out, with a short note (`note`, "Not supported" unless given) and the
+ * reason in its title (`unavailable`).
*/
function Choice({
label,
selected,
onPick,
unavailable,
+ note,
}: {
label: string;
selected: boolean;
onPick: () => void;
unavailable?: string;
+ note?: string;
}) {
const off = unavailable !== undefined;
return (
@@ -59,7 +68,7 @@ function Choice({
checked={selected}
disabled={off}
data-tooltip={unavailable}
- trailing={off ? S.chat.permission.unsupported : undefined}
+ trailing={off ? (note ?? S.chat.permission.unsupported) : undefined}
onSelect={onPick}
/>
);
@@ -102,6 +111,21 @@ export function PermissionSelect({
// The Sandbox card lives on the Plugins page, which only an administrator can open.
const isAdmin = useAuth().user?.isAdmin === true;
const P = S.chat.permission;
+ // A level this server cannot enforce stays listed, greyed out, saying why — with no backend
+ // mounted, that is every level short of full access: not installed, or enabled but failing
+ // its check, with the first such backend's reason.
+ const failed = firstUnavailableBackend(sandbox);
+ const blocked = (block: LevelBlock | null) =>
+ block === null
+ ? {}
+ : block === "no-backend"
+ ? { unavailable: P.noBackend, note: P.notInstalled }
+ : block === "unavailable" && failed !== null
+ ? { unavailable: P.backendUnavailable(failed.name, failed.reason), note: P.notAvailable }
+ : {
+ unavailable:
+ block === "local-unsupported" ? P.localUnsupported : P.noNetworkUnsupported,
+ };
const level = permissionLevel(approvalMode, sandbox);
// The swap animation plays only for a CHANGE of level, never on the first paint — React's
// "adjust state while rendering" pattern for information from the previous render.
@@ -162,6 +186,7 @@ export function PermissionSelect({
key={mode}
label={P.fsModes[mode] ?? mode}
selected={sandbox.mode === mode}
+ {...blocked(fsModeBlock(sandbox, mode))}
onPick={() =>
mode === sandbox.mode
? setOpen(false)
@@ -175,10 +200,7 @@ export function PermissionSelect({
key={network}
label={P.networkModes[network] ?? network}
selected={sandbox.network === network}
- // The local level needs a backend that can enforce it on this server.
- {...(network === "local" && sandbox.localNetworkSupported !== true
- ? { unavailable: P.localUnsupported }
- : {})}
+ {...blocked(networkBlock(sandbox, network))}
onPick={() =>
network === sandbox.network
? setOpen(false)
diff --git a/packages/web/src/lib/permission-level.ts b/packages/web/src/lib/permission-level.ts
index 91f196ff..c824b380 100644
--- a/packages/web/src/lib/permission-level.ts
+++ b/packages/web/src/lib/permission-level.ts
@@ -55,5 +55,48 @@ export const PERMISSION_LEVEL_GLYPH: Record<PermissionLevel, string> = {
"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",
};
+/**
+ * Why a sandbox level cannot be picked on this server, or null when it can. With no backend
+ * mounted, every level short of full access would refuse every command: `unavailable` when a
+ * backend is enabled but failed to load or failed its check (see `firstUnavailableBackend`),
+ * `no-backend` when none is enabled at all. Otherwise, the network level the mounted backends
+ * cannot enforce. Only an explicit false from the server counts — one that does not report a
+ * level is not second-guessed.
+ */
+export type LevelBlock = "no-backend" | "unavailable" | "local-unsupported" | "none-unsupported";
+
+/** The first enabled backend that is not in use, whose reason the composer shows, or null. */
+export function firstUnavailableBackend(
+ sandbox: SessionSandbox,
+): { name: string; reason: string } | null {
+ return sandbox.unavailableBackends?.[0] ?? null;
+}
+
+/** The block for a level no mounted backend can enforce: why nothing is mounted. */
+function unmounted(sandbox: SessionSandbox): LevelBlock {
+ return firstUnavailableBackend(sandbox) === null ? "no-backend" : "unavailable";
+}
+
+export function fsModeBlock(
+ sandbox: SessionSandbox,
+ mode: SessionSandbox["mode"],
+): LevelBlock | null {
+ if (mode === "danger-full-access") return null;
+ return sandbox.confinementSupported === false ? unmounted(sandbox) : null;
+}
+
+export function networkBlock(
+ sandbox: SessionSandbox,
+ network: SessionSandbox["network"],
+): LevelBlock | null {
+ if (network === "open") return null;
+ if (sandbox.confinementSupported === false) return unmounted(sandbox);
+ // `local` predates the other two flags, and has always been refused unless reported true.
+ if (network === "local") {
+ return sandbox.localNetworkSupported === true ? null : "local-unsupported";
+ }
+ return sandbox.noNetworkSupported === false ? "none-unsupported" : null;
+}
+
/** What a Session starts from when the server has not said: confinement off, network open. */
export const UNCONFINED: SessionSandbox = { mode: "danger-full-access", network: "open" };
diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.ts
index 2581af1c..04cca137 100644
--- a/packages/web/src/lib/strings-en.ts
+++ b/packages/web/src/lib/strings-en.ts
@@ -2660,6 +2660,15 @@ Scenarios:
} as Record<string, string>,
unsupported: "Not supported",
localUnsupported: "No sandbox backend on this machine can limit the network to localhost",
+ /** The short note beside a level nothing can enforce because no backend is installed. */
+ notInstalled: "Not installed",
+ noBackend:
+ "No sandbox backend is installed on this server, so commands cannot be confined. An administrator can enable this platform's backend on the Plugins page (More…).",
+ noNetworkUnsupported: "No sandbox backend on this machine can cut the network off",
+ /** The short note beside a level whose enabled backend failed its check. */
+ notAvailable: "Unavailable",
+ backendUnavailable: (name: string, reason: string) =>
+ `The sandbox backend ${name} is enabled but not in use: ${reason}. An administrator can fix this on the Sandbox card (More…).`,
more: "More…",
approval: "Approval",
},
diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.ts
index 4926237a..637f8c8c 100644
--- a/packages/web/src/lib/strings.ts
+++ b/packages/web/src/lib/strings.ts
@@ -2713,6 +2713,13 @@ Benchmark:
} as Record<string, string>,
unsupported: "不支持",
localUnsupported: "本机的沙盒后端不支持只允许 localhost",
+ notInstalled: "未安装",
+ noBackend:
+ "本服务器没有安装沙盒后端,命令无法被封禁。管理员可在插件页启用适用于本平台的后端(更多…)。",
+ noNetworkUnsupported: "本机的沙盒后端不支持断开网络",
+ notAvailable: "不可用",
+ backendUnavailable: (name: string, reason: string) =>
+ `沙盒后端 ${name} 已启用但未在用:${reason}。管理员可在「更多…」里的沙盒卡片处理。`,
more: "更多…",
approval: "审批",
},
diff --git a/packages/web/test/permission-level.test.ts b/packages/web/test/permission-level.test.ts
index 5bc953dc..bee9c9d4 100644
--- a/packages/web/test/permission-level.test.ts
+++ b/packages/web/test/permission-level.test.ts
@@ -9,10 +9,90 @@
*/
import { describe, expect, it } from "vitest";
import type { SessionSandbox } from "@prismshadow/penguin-server/api";
-import { PERMISSION_LEVEL_GLYPH, permissionLevel } from "../src/lib/permission-level";
+import {
+ PERMISSION_LEVEL_GLYPH,
+ firstUnavailableBackend,
+ fsModeBlock,
+ networkBlock,
+ permissionLevel,
+} from "../src/lib/permission-level";
const FULL: SessionSandbox = { mode: "danger-full-access", network: "open" };
+describe("which levels the composer lets a person pick", () => {
+ const NO_BACKEND: SessionSandbox = {
+ ...FULL,
+ confinementSupported: false,
+ noNetworkSupported: false,
+ localNetworkSupported: false,
+ };
+
+ it("with no backend installed, every level short of full access is marked not installed", () => {
+ expect(fsModeBlock(NO_BACKEND, "read-only")).toBe("no-backend");
+ expect(fsModeBlock(NO_BACKEND, "workspace-write")).toBe("no-backend");
+ expect(fsModeBlock(NO_BACKEND, "danger-full-access")).toBeNull();
+ expect(networkBlock(NO_BACKEND, "none")).toBe("no-backend");
+ expect(networkBlock(NO_BACKEND, "local")).toBe("no-backend");
+ expect(networkBlock(NO_BACKEND, "open")).toBeNull();
+ });
+
+ it("with an enabled backend that failed its check, those levels are unavailable, with its reason", () => {
+ const failed: SessionSandbox = {
+ ...NO_BACKEND,
+ unavailableBackends: [
+ { name: "penguin-wsl", reason: "the sandbox distro is not set up" },
+ { name: "penguin-dsh", reason: "cannot load" },
+ ],
+ };
+ expect(fsModeBlock(failed, "read-only")).toBe("unavailable");
+ expect(fsModeBlock(failed, "workspace-write")).toBe("unavailable");
+ expect(fsModeBlock(failed, "danger-full-access")).toBeNull();
+ expect(networkBlock(failed, "none")).toBe("unavailable");
+ expect(networkBlock(failed, "local")).toBe("unavailable");
+ expect(networkBlock(failed, "open")).toBeNull();
+ expect(firstUnavailableBackend(failed)).toEqual({
+ name: "penguin-wsl",
+ reason: "the sandbox distro is not set up",
+ });
+ // An empty list is the not-installed case.
+ const none: SessionSandbox = { ...NO_BACKEND, unavailableBackends: [] };
+ expect(fsModeBlock(none, "read-only")).toBe("no-backend");
+ expect(firstUnavailableBackend(none)).toBeNull();
+ // A mounted backend wins: a second one failing does not grey out what the first enforces.
+ const mounted: SessionSandbox = { ...failed, confinementSupported: true };
+ expect(fsModeBlock(mounted, "read-only")).toBeNull();
+ });
+
+ it("with a filesystem-only backend, confinement is open and only the network levels are not", () => {
+ const fsOnly: SessionSandbox = { ...NO_BACKEND, confinementSupported: true };
+ expect(fsModeBlock(fsOnly, "read-only")).toBeNull();
+ expect(fsModeBlock(fsOnly, "workspace-write")).toBeNull();
+ expect(networkBlock(fsOnly, "none")).toBe("none-unsupported");
+ expect(networkBlock(fsOnly, "local")).toBe("local-unsupported");
+ });
+
+ it("with a full backend, nothing is blocked", () => {
+ const full: SessionSandbox = {
+ ...FULL,
+ confinementSupported: true,
+ noNetworkSupported: true,
+ localNetworkSupported: true,
+ };
+ for (const mode of ["read-only", "workspace-write", "danger-full-access"] as const) {
+ expect(fsModeBlock(full, mode)).toBeNull();
+ }
+ for (const network of ["none", "local", "open"] as const) {
+ expect(networkBlock(full, network)).toBeNull();
+ }
+ });
+
+ it("a server that does not report the flags is not second-guessed, except for local", () => {
+ expect(fsModeBlock(FULL, "read-only")).toBeNull();
+ expect(networkBlock(FULL, "none")).toBeNull();
+ expect(networkBlock(FULL, "local")).toBe("local-unsupported");
+ });
+});
+
describe("permission level", () => {
it("is all only when nothing holds the Agent back", () => {
expect(permissionLevel("allow-all", FULL)).toBe("all");