Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

VM card: say only the browser is isolated when Docker isn't reachable

Lin (kwant bot)ce51f239cf10
diff --git a/frontend/src/computerMode.ts b/frontend/src/computerMode.ts
index 8dcf1580..37540464 100644
--- a/frontend/src/computerMode.ts
+++ b/frontend/src/computerMode.ts
@@ -31,9 +31,17 @@ export function vmCopy(isolates: string[]): { label: string; hint: string; note:
return { label: 'VM (isolated)', hint: 'Runs bots in Docker containers, away from your files.', note: null };
}
const parts = Object.keys(ISOLATED_PARTS).filter((k) => isolates.includes(k)).map((k) => ISOLATED_PARTS[k]);
+ // Without Docker (the compose stack's browser service) there is no executor container.
+ if (!isolates.includes('kwnt_shell')) {
+ return {
+ label: parts.length ? `VM (${parts.join(' and ')} isolated)` : 'VM',
+ hint: parts.length === 1 ? `The ${parts[0]} runs in a Docker container, away from your files.` : 'Uses Docker containers.',
+ note: "The built-in shell isn't available in this setup. Claude, Codex and Grok use their own shell tools.",
+ };
+ }
return {
- label: parts.length ? `VM (${parts.join(' and ')} isolated)` : 'VM',
- hint: parts.length ? `The ${parts.join(' and ')} run in Docker containers, away from your files.` : 'Uses Docker containers.',
+ label: `VM (${parts.join(' and ')} isolated)`,
+ hint: `The ${parts.join(' and ')} run in Docker containers, away from your files.`,
note: 'Claude, Codex and Grok still run on this computer, with their own file and shell tools.',
};
}
diff --git a/frontend/tests/computerMode.test.mjs b/frontend/tests/computerMode.test.mjs
index 459c9fd8..4c7c06b3 100644
--- a/frontend/tests/computerMode.test.mjs
+++ b/frontend/tests/computerMode.test.mjs
@@ -104,7 +104,15 @@ test('VM copy follows what the server says it isolates', () => {
const now = m.vmCopy(['browser', 'kwnt_shell']);
assert.equal(now.label, 'VM (browser and built-in shell isolated)');
assert.match(now.note, /Claude, Codex and Grok still run on this computer/);
- assert.equal(m.vmCopy(['browser']).label, 'VM (browser isolated)');
+ // compose stack: only the browser is isolated, and the card says the built-in shell isn't there
+ const browserOnly = m.vmCopy(['browser']);
+ assert.equal(browserOnly.label, 'VM (browser isolated)');
+ assert.equal(browserOnly.hint, 'The browser runs in a Docker container, away from your files.');
+ assert.match(browserOnly.note, /built-in shell isn't available in this setup/);
+ assert.doesNotMatch(`${browserOnly.label} ${browserOnly.hint}`, /built-in shell/);
+ const bo = render(m.ComputerModeControl, ready(settings('vm', false, true, {}, {}, ['browser'])));
+ assert.match(bo, /VM \(browser isolated\)/);
+ assert.doesNotMatch(bo, /browser and built-in shell/);
const full = m.vmCopy(['browser', 'kwnt_shell', 'cli_agents']);
assert.equal(full.label, 'VM (isolated)');
assert.equal(full.note, null);
diff --git a/src/sandbox/computer.rs b/src/sandbox/computer.rs
index 538821d7..11d5a139 100644
--- a/src/sandbox/computer.rs
+++ b/src/sandbox/computer.rs
@@ -17,6 +17,17 @@ pub const CHROME_PATH_ENV: &str = "KWNT_CHROME_PATH";
/// file and shell tools still run on the host; `cli_agents` joins this list once they move.
pub const VM_ISOLATES: [&str; 2] = ["browser", "kwnt_shell"];
+/// What vm mode isolates on this computer. The built-in shell runs in an executor container that
+/// needs Docker; with only a browser service (the compose stack, no Docker socket) just the
+/// browser is isolated and the built-in shell isn't available.
+pub fn vm_isolates(docker: bool) -> &'static [&'static str] {
+ if docker {
+ &VM_ISOLATES
+ } else {
+ &VM_ISOLATES[..1]
+ }
+}
+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ComputerMode {
@@ -724,6 +735,16 @@ mod tests {
assert!(docker.contains("KWNT_BROWSER_CDP_URL") && docker.contains("docker compose up -d browser"), "{docker}");
}
+ #[test]
+ fn vm_isolates_the_built_in_shell_only_with_docker() {
+ // Mac/Linux with Docker: the browser and the executor shell both run in containers
+ assert_eq!(vm_isolates(true), ["browser", "kwnt_shell"]);
+ // compose stack (browser service, no Docker socket): only the browser is isolated
+ assert_eq!(vm_isolates(false), ["browser"]);
+ // never the CLI agents, which still run where kwnt runs
+ assert!(!vm_isolates(true).contains(&"cli_agents"));
+ }
+
#[test]
fn chrome_uses_its_own_profile_and_a_loopback_port() {
for headless in [true, false] {
diff --git a/src/server/computer.rs b/src/server/computer.rs
index ed263bcd..5ce625ba 100644
--- a/src/server/computer.rs
+++ b/src/server/computer.rs
@@ -43,8 +43,9 @@ pub async fn apply_mode(state: &AppState) -> ComputerMode {
async fn view(state: &AppState) -> Value {
let mode = current_mode(state).await;
let local = computer::local_reason();
+ let docker = state.sandbox_manager.is_docker_available().await;
let vm = computer::vm_unavailable_reason(
- state.sandbox_manager.is_docker_available().await,
+ docker,
state.browser_service.has_endpoint(),
crate::doctor::Platform::detect(),
);
@@ -53,7 +54,7 @@ async fn view(state: &AppState) -> Value {
"mode": mode,
"available": {"local": local.is_none(), "vm": vm.is_none()},
"reasons": {"local": local, "vm": vm},
- "isolates": computer::VM_ISOLATES,
+ "isolates": computer::vm_isolates(docker),
"window": {
"visible": mode == ComputerMode::Local && state.browser_service.local_window(),
"available": window.is_none(),
diff --git a/tests/computer_mode_test.rs b/tests/computer_mode_test.rs
index 82c65ee8..955d4b35 100644
--- a/tests/computer_mode_test.rs
+++ b/tests/computer_mode_test.rs
@@ -119,8 +119,14 @@ async fn computer_mode_api_and_local_shell_approval() {
.unwrap()
.contains("KWNT_CHROME_PATH"));
assert_eq!(view["reasons"]["vm"], Value::Null);
- // VM mode is honest about what it contains: not the Claude/Codex/Grok CLIs (yet).
- assert_eq!(view["isolates"], json!(["browser", "kwnt_shell"]));
+ // VM mode is honest about what it contains: not the Claude/Codex/Grok CLIs (yet), and the
+ // built-in shell only when Docker can run its executor (not in the compose stack).
+ let isolates = if kwnt::sandbox::SandboxManager::new().is_docker_available().await {
+ json!(["browser", "kwnt_shell"])
+ } else {
+ json!(["browser"])
+ };
+ assert_eq!(view["isolates"], isolates);
assert_eq!(view["window"]["visible"], false);
if cfg!(target_os = "linux") {
// no display: Chrome can still run in the app, just not as a window
@@ -153,8 +159,7 @@ async fn computer_mode_api_and_local_shell_approval() {
assert_eq!(status, StatusCode::OK);
assert_eq!(view["mode"], "vm");
assert_eq!(
- view["isolates"],
- json!(["browser", "kwnt_shell"]),
+ view["isolates"], isolates,
"PUT returns the same shape"
);
assert_eq!(