Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
main: Local VM settings move out of config.ts, the reply-wait picker uses Select (#3826)
Milind Soni800c130b6168
diff --git a/server/config.ts b/server/config.tsindex b7a8bfb0fc..2ff80c8416 100644--- a/server/config.ts+++ b/server/config.ts@@ -25,6 +25,8 @@ import { parseJson, schemaIssue, type JsonObject, type JsonValue } from "./schemimport { deciderConfigSchema, type DeciderConfig } from "./decider/config.ts";import { browserEngineConfigSchema, isValidCdpTarget, type BrowserEngineConfig } from "./browser/config.ts";import { roomContextSettings } from "./room-context-settings.ts";+import { MAX_LOCAL_VM_IDLE_TIMEOUT_MINUTES, MAX_LOCAL_VM_MAX_INSTANCES, MIN_LOCAL_VM_IDLE_TIMEOUT_MINUTES, MIN_LOCAL_VM_MAX_INSTANCES } from "./local-vm-settings.ts";+export * from "./local-vm-settings.ts";const optionalText = z.string().optional();const SSH_ALIAS = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/;@@ -46,13 +48,6 @@ export const MAX_CONCURRENT_BOT_THREADS = 16;/** The floor keeps a log tail large enough for the event inspector's recent-line window. */export const MIN_THREAD_EVENT_LOG_BYTES = 256 * 1024;export const MAX_THREAD_EVENT_LOG_BYTES = 4 * 1024 * 1024 * 1024;-export const DEFAULT_LOCAL_VM_MODE = "shared" as const;-export const DEFAULT_LOCAL_VM_MAX_INSTANCES = 2;-export const MIN_LOCAL_VM_MAX_INSTANCES = 1;-export const MAX_LOCAL_VM_MAX_INSTANCES = 8;-export const DEFAULT_LOCAL_VM_IDLE_TIMEOUT_MINUTES = 480;-export const MIN_LOCAL_VM_IDLE_TIMEOUT_MINUTES = 5;-export const MAX_LOCAL_VM_IDLE_TIMEOUT_MINUTES = 1_440;export function isValidSshAlias(value: unknown): value is string {return typeof value === "string" && SSH_ALIAS.test(value);@@ -654,23 +649,6 @@ export function threadEventLogRetentionDays(cfg: AppConfig): number | null {return cfg.threads?.eventLogRetentionDays ?? null;}-export function localVmMode(cfg: AppConfig): "shared" | "per-bot" | "pool" {- return cfg.localVm?.mode ?? DEFAULT_LOCAL_VM_MODE;-}--export function localVmMaxInstances(cfg: AppConfig): number {- return cfg.localVm?.maxInstances ?? DEFAULT_LOCAL_VM_MAX_INSTANCES;-}--export function localVmIdleTimeoutMinutes(cfg: AppConfig): number {- return cfg.localVm?.idleTimeoutMinutes ?? DEFAULT_LOCAL_VM_IDLE_TIMEOUT_MINUTES;-}--/** App preservation is deliberately opt-in: a normal image replacement keeps its existing small, predictable footprint. */-export function localVmPreservesInstalledApps(cfg: AppConfig): boolean {- return cfg.localVm?.preserveInstalledApps === true;-}-export function skillAuthoringEnabled(cfg: AppConfig): boolean {return cfg.features?.skillAuthoring !== false;}diff --git a/server/index.test.ts b/server/index.test.tsindex a577f6c53e..e470e864a0 100644--- a/server/index.test.ts+++ b/server/index.test.ts@@ -10436,7 +10436,7 @@ describe("harness HTTP API", () => {const first = (await api("POST", "/api/bots")).body.bot;const second = (await api("POST", "/api/bots")).body.bot;const before = await api("GET", "/api/config");- expect(before.body.localVm).toEqual({ mode: "shared", maxInstances: 2, idleTimeoutMinutes: 480 });+ expect(before.body.localVm).toEqual({ mode: "shared", maxInstances: 2, idleTimeoutMinutes: 480, preserveInstalledApps: false });const shared = await api("GET", `/api/bots/${first.id}/local-computer`);expect(shared.status).toBe(200);@@ -10446,7 +10446,7 @@ describe("harness HTTP API", () => {localVm: { mode: "per-bot", maxInstances: 5 },});expect(saved.status).toBe(200);- expect(saved.body.localVm).toEqual({ mode: "per-bot", maxInstances: 5, idleTimeoutMinutes: 480 });+ expect(saved.body.localVm).toEqual({ mode: "per-bot", maxInstances: 5, idleTimeoutMinutes: 480, preserveInstalledApps: false });const [firstStatus, secondStatus] = await Promise.all([api("GET", `/api/bots/${first.id}/local-computer`),@@ -10486,7 +10486,7 @@ describe("harness HTTP API", () => {expect(invalid.body.error).toContain("localVm.maxInstances");const disk = JSON.parse(readFileSync(join(home, ".openmausbot", "config.json"), "utf8"));- expect(disk.localVm).toEqual({ mode: "per-bot", maxInstances: 5, idleTimeoutMinutes: 480 });+ expect(disk.localVm).toEqual({ mode: "per-bot", maxInstances: 5, idleTimeoutMinutes: 480, preserveInstalledApps: false });await api("PATCH", "/api/config", { localVm: { mode: "shared", maxInstances: 2 } });});@@ -10505,7 +10505,7 @@ describe("harness HTTP API", () => {const saved = await api("PATCH", "/api/config", { localVm: { idleTimeoutMinutes: 30 } });expect(saved.status).toBe(200);- expect(saved.body.localVm).toEqual({ mode: "shared", maxInstances: 2, idleTimeoutMinutes: 30 });+ expect(saved.body.localVm).toEqual({ mode: "shared", maxInstances: 2, idleTimeoutMinutes: 30, preserveInstalledApps: false });expect((await api("GET", "/api/config")).body.localVm.idleTimeoutMinutes).toBe(30);expect((await api("GET", "/api/local-computer")).body.idle_timeout_ms).toBe(30 * 60_000);diff --git a/server/local-vm-settings.ts b/server/local-vm-settings.tsnew file mode 100644index 0000000000..5909142d01--- /dev/null+++ b/server/local-vm-settings.ts@@ -0,0 +1,27 @@+// The Local VM's settings, read from the config the server loaded.+import type { AppConfig } from "./config.ts";++export const DEFAULT_LOCAL_VM_MODE = "shared" as const;+export const DEFAULT_LOCAL_VM_MAX_INSTANCES = 2;+export const MIN_LOCAL_VM_MAX_INSTANCES = 1;+export const MAX_LOCAL_VM_MAX_INSTANCES = 8;+export const DEFAULT_LOCAL_VM_IDLE_TIMEOUT_MINUTES = 480;+export const MIN_LOCAL_VM_IDLE_TIMEOUT_MINUTES = 5;+export const MAX_LOCAL_VM_IDLE_TIMEOUT_MINUTES = 1_440;++export function localVmMode(cfg: AppConfig): "shared" | "per-bot" | "pool" {+ return cfg.localVm?.mode ?? DEFAULT_LOCAL_VM_MODE;+}++export function localVmMaxInstances(cfg: AppConfig): number {+ return cfg.localVm?.maxInstances ?? DEFAULT_LOCAL_VM_MAX_INSTANCES;+}++export function localVmIdleTimeoutMinutes(cfg: AppConfig): number {+ return cfg.localVm?.idleTimeoutMinutes ?? DEFAULT_LOCAL_VM_IDLE_TIMEOUT_MINUTES;+}++/** App preservation is deliberately opt-in: a normal image replacement keeps its existing small, predictable footprint. */+export function localVmPreservesInstalledApps(cfg: AppConfig): boolean {+ return cfg.localVm?.preserveInstalledApps === true;+}diff --git a/src/components/OpenAiCompatServers.tsx b/src/components/OpenAiCompatServers.tsxindex 6ea612dfd8..af3ee01765 100644--- a/src/components/OpenAiCompatServers.tsx+++ b/src/components/OpenAiCompatServers.tsx@@ -6,6 +6,7 @@ import { keySaved } from "@/lib/product-events";import { addedServers } from "@/lib/openai-compat-endpoints";import { cn } from "@/lib/cn";import { KEY_FIELD } from "./keys/KeyRow";+import { Select } from "./Select";export function modelIds(text: string): string[] {return [...new Set(text.split(/[,,、\s]+/).map((id) => id.trim()).filter(Boolean))];@@ -68,7 +69,9 @@ function AddedServers({ servers }: { servers: Array<InstanceInfo & { url?: strin<div className="truncate text-[12px] text-ink">{server.displayName}</div>{server.url && <div className="truncate font-mono text-[11px] text-ink-secondary">{server.url}</div>}</div>- <select+ <Select+ size="sm"+ className="shrink-0"value={server.replyWaitMinutes ?? ""}onChange={(event) => {const minutes = event.target.value ? Number(event.target.value) : null;@@ -77,13 +80,12 @@ function AddedServers({ servers }: { servers: Array<InstanceInfo & { url?: strindisabled={busy !== null}aria-label={t("apiInstances.replyWaitFor", { name: server.displayName })}title={t("apiInstances.replyWaitHint")}- className="shrink-0 rounded-md border border-hairline/60 bg-inset px-1.5 py-1 text-[11.5px] text-ink focus:border-accent focus:outline-none disabled:opacity-50"><option value="">{t("apiInstances.replyWaitDefault")}</option>{[...new Set([...REPLY_WAIT_CHOICES, ...(server.replyWaitMinutes ? [server.replyWaitMinutes] : [])])].sort((a, b) => a - b).map((minutes) => (<option key={minutes} value={minutes}>{t("apiInstances.replyWaitMinutes", { minutes: String(minutes) })}</option>))}- </select>+ </Select><buttontype="button"onClick={() => run("other", () => api(`/api/instances/${encodeURIComponent(server.instanceId)}/refresh-models`, { method: "POST" }))}