Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Idle SSH server desktops: fixed 480-minute window, no settings field

milind-soniac38897090c7
diff --git a/server/app-settings/registry-config.ts b/server/app-settings/registry-config.ts
index 0e3bf5afba..029b2cb13a 100644
--- a/server/app-settings/registry-config.ts
+++ b/server/app-settings/registry-config.ts
@@ -10,7 +10,6 @@ import { DEFAULT_WINDOW_MINUTES } from "../cache-keepwarm.ts";
import { botsTowardLimit } from "../../shared/bot-limit.ts";
import { parseSocks5Proxy } from "../browser/egress/policy.ts";
import { CONFIG_PATCH_FIELDS as F, MAX_THREAD_EVENT_LOG_BYTES, MIN_THREAD_EVENT_LOG_BYTES } from "../config.ts";
-import { vpsIdleTimeoutMinutes } from "../vps-config.ts";
import { display, withoutKeys, type RegistryDeps, type SettingEntry, type Where, type WritableSpec } from "./registry.ts";
/** Security: what a bot or card reads of a section never carries a key, token, secret or password field. */
@@ -152,11 +151,6 @@ export function configEntries(deps: Pick<RegistryDeps, "cfg" | "saveConfig" | "b
value: nonEmpty(F.localVm.unwrap().pick({ mode: true, maxInstances: true, idleTimeoutMinutes: true }).strict()), allowed: '{"mode"?:"shared"|"per-bot"|"pool","maxInstances"?,"idleTimeoutMinutes"?}',
current: () => cfg().localVm ?? {}, patch: (localVm) => ({ localVm }), says: (localVm) => `Private desktops: ${fields(localVm)}`,
}),
- section({
- id: "desktops.vpsIdle", label: "Server desktop idle timeout", help: "Minutes before an idle SSH server desktop stops.", where: "page:desktops",
- synonyms: ["VPS", "SSH", "idle timer"], value: F.vpsIdle.unwrap().shape.timeoutMinutes.unwrap(), allowed: "5 to 1440 whole minutes",
- current: () => vpsIdleTimeoutMinutes(cfg()), patch: (timeoutMinutes) => ({ vpsIdle: { timeoutMinutes } }),
- }),
feature("computer.sharing", "Computer sharing", "Whether every paired device may lend its computer to bots here. Each lent folder or app is still picked and confirmed on that device.", "page:desktops",
["share computer", "shared computers", "lend", "lending"], "sharedComputers", false,
"Let every paired device lend its computer to bots here, not only your own. A lent folder can be used to reach a shell", "Stop every device, your own included, lending its computer to bots here"),
diff --git a/server/host/vps-idle.test.ts b/server/host/vps-idle.test.ts
new file mode 100644
index 0000000000..c3d1fbb735
--- /dev/null
+++ b/server/host/vps-idle.test.ts
@@ -0,0 +1,74 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+const viewer = vi.hoisted(() => ({ open: false }));
+vi.mock("../vps-computer.ts", () => ({
+ vpsDesktopConnection: vi.fn(() => (viewer.open ? { port: 5901, password: "p", live: () => true, retain: () => () => {} } : undefined)),
+ vpsComputerAction: vi.fn(async (_action: string, _cfg: unknown, _botId: string, _runner: unknown, shouldStop?: () => boolean) =>
+ ({ container: shouldStop && !shouldStop() ? "running" : "stopped" })),
+ stopVpsDesktopTunnel: vi.fn(),
+ vpsComputerRunning: vi.fn(async () => false),
+ listManagedVpsComputers: vi.fn(async () => ({ instances: [] })),
+}));
+
+import type { AppConfig } from "../config.ts";
+import type { BotRecord } from "../store.ts";
+import * as vps from "../vps-computer.ts";
+import { createVpsIdleHost } from "./vps-idle.ts";
+
+const DEFAULT_WINDOW_MS = 480 * 60_000;
+
+/** The Cloud browser sandbox's 3-minute rule lives in cloud-computer-power and never reaches this timer. */
+function host() {
+ const bot = { id: "bot-1", name: "Bot", cloudBackend: "vps" } as BotRecord;
+ const cfg = { vps: { sshAlias: "my-vps" } } as AppConfig;
+ const idle = createVpsIdleHost({
+ cfg,
+ store: { bots: [bot], bot: (id) => (id === bot.id ? bot : null) },
+ botHasActiveTurn: () => false,
+ hasActiveRoutine: () => false,
+ isSharedVmHeld: () => false,
+ hasComputerPreview: () => false,
+ isVpsConfigTransitioning: () => false,
+ isLifecycleBusy: () => false,
+ claimBotComputerLifecycle: () => () => {},
+ isShuttingDown: () => false,
+ });
+ return { bot, idle };
+}
+
+const stops = () => vi.mocked(vps.vpsComputerAction).mock.calls.filter(([action]) => action === "stop");
+
+describe("idle SSH server desktops", () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ viewer.open = false;
+ vi.mocked(vps.vpsComputerAction).mockClear();
+ });
+ afterEach(() => vi.useRealTimers());
+
+ it("stops a quiet desktop after the fixed 480-minute window, not before", async () => {
+ const { bot, idle } = host();
+ idle.touchVpsIdle(bot);
+ await vi.advanceTimersByTimeAsync(DEFAULT_WINDOW_MS - 1_000);
+ expect(stops()).toHaveLength(0);
+ await vi.advanceTimersByTimeAsync(1_000);
+ expect(stops()).toHaveLength(1);
+ idle.cancelAll();
+ });
+
+ it("never stops a desktop while a person is viewing it, and starts a full window once they leave", async () => {
+ const { bot, idle } = host();
+ viewer.open = true;
+ idle.touchVpsIdle(bot);
+ await vi.advanceTimersByTimeAsync(3 * DEFAULT_WINDOW_MS);
+ expect(stops()).toHaveLength(0);
+ expect(vi.mocked(vps.vpsDesktopConnection)).toHaveBeenCalledWith(bot.id);
+
+ viewer.open = false;
+ await vi.advanceTimersByTimeAsync(DEFAULT_WINDOW_MS / 2);
+ expect(stops()).toHaveLength(0);
+ await vi.advanceTimersByTimeAsync(DEFAULT_WINDOW_MS);
+ expect(stops()).toHaveLength(1);
+ idle.cancelAll();
+ });
+});
diff --git a/server/index.test.ts b/server/index.test.ts
index bcbb8938e4..05aee1fa4a 100644
--- a/server/index.test.ts
+++ b/server/index.test.ts
@@ -11029,17 +11029,19 @@ describe("harness HTTP API", () => {
await api("PATCH", "/api/config", { localVm: { mode: "shared", maxInstances: 2 } });
});
- it("keeps VPS and private desktop idle timeouts independent", async () => {
+ it("keeps the config-file VPS desktop idle timeout apart from the private desktop's and out of the app's settings", async () => {
const get = async () => (await api("GET", "/api/config")).body;
- expect((await get()).vpsIdle).toEqual({ timeoutMinutes: 480 });
+ expect((await get()).vpsIdle).toBeUndefined();
try {
for (const timeoutMinutes of [4, 1441, 5.5, "5", null]) {
expect((await api("PATCH", "/api/config", { vpsIdle: { timeoutMinutes } })).status).toBe(400);
}
const saved = await api("PATCH", "/api/config", { vpsIdle: { timeoutMinutes: 5 } });
- expect(saved.body).toMatchObject({ vpsIdle: { timeoutMinutes: 5 }, localVm: { idleTimeoutMinutes: 480 } });
+ expect(saved.status).toBe(200);
+ expect(saved.body).toMatchObject({ localVm: { idleTimeoutMinutes: 480 } });
+ expect(saved.body.vpsIdle).toBeUndefined();
await api("PATCH", "/api/config", { localVm: { idleTimeoutMinutes: 30 } });
- expect(await get()).toMatchObject({ vpsIdle: { timeoutMinutes: 5 }, localVm: { idleTimeoutMinutes: 30 } });
+ expect(await get()).toMatchObject({ localVm: { idleTimeoutMinutes: 30 } });
expect(JSON.parse(readFileSync(join(home, ".openmausbot", "config.json"), "utf8")).vpsIdle).toEqual({ timeoutMinutes: 5 });
} finally {
await api("PATCH", "/api/config", { vpsIdle: { timeoutMinutes: 480 }, localVm: { idleTimeoutMinutes: 480 } });
diff --git a/server/index.ts b/server/index.ts
index 3d81e8abcc..f56d499165 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -175,7 +175,7 @@ import {
builtInBrowserEnabled,
persistableInstanceConfigs,
type AppConfig,
- vpsIdleTimeoutMinutes, vpsResources, vpsSshAlias,
+ vpsResources, vpsSshAlias,
DATA_DIR, EVENTS_DIR,
onConfigSaved,
CLAUDE_API_INSTANCE,
@@ -11578,7 +11578,6 @@ function configStatus() {
configured: composio.configured(cfg), mode: composio.connectionMode(cfg),
},
box: { ...boat.describeBoatAccount(cfg), ...(boat.boatAccount(cfg)?.included ? {} : keyHint(cfg.box?.token)) },
- vpsIdle: { timeoutMinutes: vpsIdleTimeoutMinutes(cfg) },
vps: { configured: Boolean(vpsSshAlias(cfg)), sshAlias: vpsSshAlias(cfg) ?? "", servers: cfg.vpsServers ?? [], ...vpsResources(cfg) },
opencodeGo: { ...keyStatus(cfg.opencodeGo?.apiKey), providerKeys: Object.keys(openCodeProviderKeys(cfg)) },
tts: tts.describeVoice(cfg),
diff --git a/src/components/LocalComputerSection.tsx b/src/components/LocalComputerSection.tsx
index 8a6fc4c689..464dab1c63 100644
--- a/src/components/LocalComputerSection.tsx
+++ b/src/components/LocalComputerSection.tsx
@@ -666,11 +666,11 @@ export function parseLocalVmIdleTimeoutMinutes(value: string): number | null {
export function LocalVmIdleTimeoutSetting({
minutes,
disabled,
- onSave, id = "local-vm-idle-timeout", detail = t("vm.idle.detail"),
+ onSave,
}: {
minutes: number;
disabled: boolean;
- onSave: (minutes: number) => Promise<void>; id?: string; detail?: string;
+ onSave: (minutes: number) => Promise<void>;
}) {
const [value, setValue] = useState(String(minutes));
const [dirty, setDirty] = useState(false);
@@ -705,12 +705,12 @@ export function LocalVmIdleTimeoutSetting({
<div className="mt-3 flex flex-col gap-1">
<div className="flex items-center justify-between gap-6">
<div className="min-w-0">
- <label htmlFor={id} className="text-[14px] leading-5 text-ink">{t("vm.idle.label")}</label>
- <div id={`${id}-help`} className="text-[13px] leading-[18px] text-ink-secondary">{detail}</div>
+ <label htmlFor="local-vm-idle-timeout" className="text-[14px] leading-5 text-ink">{t("vm.idle.label")}</label>
+ <div id="local-vm-idle-timeout-help" className="text-[13px] leading-[18px] text-ink-secondary">{t("vm.idle.detail")}</div>
</div>
<span className="flex shrink-0 items-center gap-2">
<input
- id={id}
+ id="local-vm-idle-timeout"
type="number"
min={MIN_LOCAL_VM_IDLE_TIMEOUT_MINUTES}
max={MAX_LOCAL_VM_IDLE_TIMEOUT_MINUTES}
@@ -719,7 +719,7 @@ export function LocalVmIdleTimeoutSetting({
value={value}
disabled={disabled || saving}
aria-invalid={Boolean(error)}
- aria-describedby={error ? `${id}-error ${id}-help` : `${id}-help`}
+ aria-describedby={error ? "local-vm-idle-timeout-error local-vm-idle-timeout-help" : "local-vm-idle-timeout-help"}
onChange={(event) => {
setValue(event.target.value);
setDirty(true);
@@ -735,7 +735,7 @@ export function LocalVmIdleTimeoutSetting({
</span>
</div>
{error ? (
- <p id={`${id}-error`} role="alert" className="text-[12px] leading-4 text-danger">
+ <p id="local-vm-idle-timeout-error" role="alert" className="text-[12px] leading-4 text-danger">
{error}
</p>
) : null}
diff --git a/src/components/keys/VpsServersPanel.tsx b/src/components/keys/VpsServersPanel.tsx
index 7e751bcf7e..71835f433d 100644
--- a/src/components/keys/VpsServersPanel.tsx
+++ b/src/components/keys/VpsServersPanel.tsx
@@ -1,12 +1,10 @@
import { useContext, useId, useState } from "react";
import { ChevronRight, Loader2 } from "lucide-react";
-import { api, type ConfigStatus } from "@/state/store";
import { useStoreDispatch, useStoreSelector } from "@/state/store-select";
import { productName } from "@/lib/brand";
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
import { sshServerAnchor } from "../devices/device-words";
-import { LocalVmIdleTimeoutSetting } from "../LocalComputerSection";
import { SettingsShellContext } from "../settings/settings-shell";
import { KEY_FIELD } from "./KeyRow";
import { CPUS, Field, LimitField, limitValue, MEMORY_GB, useVpsSave, useVpsSaving, VpsServerEditor, type VpsNamedServer } from "./VpsServerEditor";
@@ -33,24 +31,6 @@ export function VpsConnection() {
{notice && <div role="status" className="text-[12px] leading-4 text-ink-secondary">{notice}</div>}
<VpsServers />
<p className="text-[12px] leading-4 text-ink-secondary">{t("keys.vps.limitsHint")}</p>
- <VpsIdleTimeout />
- </div>
- );
-}
-
-/** One idle window for every SSH server desktop, saved apart from the private desktop's. */
-function VpsIdleTimeout() {
- const minutes = useStoreSelector((s) => s.config?.vpsIdle?.timeoutMinutes);
- const dispatch = useStoreDispatch();
- const configured = useStoreSelector((s) => Boolean(s.config?.vps?.sshAlias || s.config?.vps?.servers?.length));
- if (minutes === undefined || !configured) return null;
- const save = async (timeoutMinutes: number) => {
- const config: ConfigStatus = await api("/api/config", { method: "PATCH", body: JSON.stringify({ vpsIdle: { timeoutMinutes } }) });
- dispatch({ type: "configStatus", config });
- };
- return (
- <div data-vps-idle="">
- <LocalVmIdleTimeoutSetting id="vps-idle-timeout" detail={t("keys.vps.idle.detail")} minutes={minutes} disabled={false} onSave={save} />
</div>
);
}
diff --git a/src/lib/config-status-frame.ts b/src/lib/config-status-frame.ts
index 66b9d0cb20..a5d88e9f5b 100644
--- a/src/lib/config-status-frame.ts
+++ b/src/lib/config-status-frame.ts
@@ -3,7 +3,7 @@ import type { ConfigStatus } from "@/state/config-status";
// A setting left out here is wiped from state.config whenever a config frame lands.
export type ConfigStatusFrame = Pick<
ConfigStatus,
- "awakeLimit" | "pausedBots" | "pausedByPerson" | "heldBots" | "xai" | "mistral" | "cerebras" | "groq" | "greenference" | "modelgo" | "meta" | "deepseek" | "xResearch" | "treg" | "postiz" | "anthropic" | "openai" | "openrouter" | "openaiCompat" | "fleet" | "composio" | "box" | "vps" | "vpsIdle" | "rooms" | "mcp" | "threads" | "automaticRecovery" | "cacheKeepWarm" | "localVm" | "opencodeGo" | "tts" | "decider" | "helpers" | "imageGen" | "live" | "savedKeys" | "profile" | "everyBotRules" | "language" | "features" | "onboarding" | "browserEngine" | "browserProfiles" | "edition" | "budgets" | "billing" | "managedPolicy" | "cloudHome" | "team" | "workspaceBanner" | "toolGroups"
+ "awakeLimit" | "pausedBots" | "pausedByPerson" | "heldBots" | "xai" | "mistral" | "cerebras" | "groq" | "greenference" | "modelgo" | "meta" | "deepseek" | "xResearch" | "treg" | "postiz" | "anthropic" | "openai" | "openrouter" | "openaiCompat" | "fleet" | "composio" | "box" | "vps" | "rooms" | "mcp" | "threads" | "automaticRecovery" | "cacheKeepWarm" | "localVm" | "opencodeGo" | "tts" | "decider" | "helpers" | "imageGen" | "live" | "savedKeys" | "profile" | "everyBotRules" | "language" | "features" | "onboarding" | "browserEngine" | "browserProfiles" | "edition" | "budgets" | "billing" | "managedPolicy" | "cloudHome" | "team" | "workspaceBanner" | "toolGroups"
>;
/** What the server says about the place itself. Its frames carry them as GET /api/config does, one left out meaning
@@ -33,7 +33,7 @@ export function configStatusFromFrame(frame: ConfigStatusFrame, held?: ConfigSta
fleet: frame.fleet, toolGroups: frame.toolGroups,
composio: frame.composio,
box: frame.box,
- vps: frame.vps, vpsIdle: frame.vpsIdle,
+ vps: frame.vps,
rooms: frame.rooms,
mcp: frame.mcp,
threads: frame.threads,
diff --git a/src/locales/en.json b/src/locales/en.json
index 735032e793..b0d7d80f93 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -4415,7 +4415,6 @@
"keys.vps.servers.namePlaceholder": "Home lab",
"keys.vps.servers.add": "Add",
"keys.vps.servers.removeAria": "Remove {name}",
- "keys.vps.idle.detail": "Applies to server desktops only, not the private desktop. A desktop with a running turn is never stopped.",
"keys.vps.limitsHint": "Memory and cores are the most each bot's desktop on a server may use. Left empty, a named server uses the default server's, and the default uses 4 GB and 2 cores. A running desktop takes a change the next time it starts. Saving checks that the machine has them.",
"usage.title": "Usage",
"planUsage.title": "Plan usage",
diff --git a/src/state/config-status.ts b/src/state/config-status.ts
index 788fab7c27..1c9dfd3c62 100644
--- a/src/state/config-status.ts
+++ b/src/state/config-status.ts
@@ -55,8 +55,6 @@ export interface ConfigStatus {
box: SavedKey & { included?: boolean };
/** `servers`: named servers for the per-bot picker; empty for client sessions, missing from an older server. */
vps: { configured: boolean; sshAlias: string; servers?: { name: string; sshAlias: string; memoryGb?: number; cpus?: number }[]; memoryGb?: number; cpus?: number };
- /** The idle window for SSH server desktops. Absent from older servers. */
- vpsIdle?: { timeoutMinutes: number };
rooms: { turnTimeoutMinutes: number };
/** Per-call ceiling (minutes) for a bot's MCP tools. Absent from servers
* older than the setting; read it with mcpCallTimeoutMinutes(). */