Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
app_settings: a never-saved setting reads as the default the app runs on
aivsomkar899a20de3233
diff --git a/server/app-settings/host.test.ts b/server/app-settings/host.test.tsindex f1ec3b58ed..a9081890e4 100644--- a/server/app-settings/host.test.ts+++ b/server/app-settings/host.test.ts@@ -155,6 +155,21 @@ describe("safe tier", () => {expect(await host.undo({ threadId: turn.threadId, requestId })).toEqual({ claimed: true, state: "already_undone" });});+ it("a setting never saved reads as the default the app runs on, so Undo of its first change sets that default back", async () => {+ const { host, set, cfg, cards, turn, saved } = fixture();+ delete cfg.rooms; delete cfg.threads; cfg.mcp = {};+ for (const [id, value] of [["rooms.turnTimeoutMinutes", 45], ["mcp.callTimeoutMinutes", 20], ["threads.maxConcurrentPerBot", 7]] as const) {+ const before = cards().length;+ expect((await set(id, value)).status).toBe(200);+ const card = cards()[before]!.card;+ expect(card.appSettingRequest.before, id).toMatch(/^\d+$/);+ expect(await host.undo({ threadId: turn.threadId, requestId: String(card.requestId) }), id).toEqual({ claimed: true, state: "undone" });+ }+ expect(saved.slice(-1)).toEqual([{ threads: { maxConcurrentPerBot: Number(cards()[2]!.card.appSettingRequest.before) } }]);+ expect(saved).toContainEqual({ rooms: { turnTimeoutMinutes: 5 } });+ expect(saved).toContainEqual({ mcp: { callTimeoutMinutes: 10 } });+ });+it("reorders and groups bots through the registry, with typed values kept for undo", async () => {const { host, set, bots, cards, turn } = fixture();expect((await set("bots.order", ["clive", "kiwi"])).status).toBe(200);diff --git a/server/app-settings/registry.ts b/server/app-settings/registry.tsindex dca115e16d..afd3209deb 100644--- a/server/app-settings/registry.ts+++ b/server/app-settings/registry.ts@@ -2,8 +2,8 @@ import { z } from "zod";import { credentialIsConfigured, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, type CredentialConfig, type CredentialTargetId } from "../../shared/credential-request.ts";import { WINDOW_PREFS, type WindowPrefId } from "../../shared/app-settings.ts";-import { MAX_CONCURRENT_BOT_THREADS } from "../bot-thread-limits.ts";-import { MAX_MCP_CALL_TIMEOUT_MINUTES, MAX_ROOM_TURN_TIMEOUT_MINUTES, MIN_MCP_CALL_TIMEOUT_MINUTES, MIN_ROOM_TURN_TIMEOUT_MINUTES, type AppConfig } from "../config.ts";+import { defaultBotThreads, MAX_CONCURRENT_BOT_THREADS } from "../bot-thread-limits.ts";+import { MAX_MCP_CALL_TIMEOUT_MINUTES, MAX_ROOM_TURN_TIMEOUT_MINUTES, mcpCallTimeoutMinutes, MIN_MCP_CALL_TIMEOUT_MINUTES, MIN_ROOM_TURN_TIMEOUT_MINUTES, roomTurnTimeoutMinutes, type AppConfig } from "../config.ts";import type { RequestAuth } from "../request-auth.ts";import { callRoute, type RouteReply } from "../routes/call-route.ts";import type { RouteHandler } from "../routes/table.ts";@@ -114,7 +114,7 @@ export function createSettingsRegistry(deps: RegistryDeps): SettingEntry[] {writable({id: "threads.maxConcurrentPerBot", label: "Threads per bot", help: "How many conversations one bot may work on at once.", where: "Settings → You and your bots",synonyms: ["concurrent", "parallel", "limit", "limits", "thread limit"], tier: "safe", value: z.number().int().min(1).max(MAX_CONCURRENT_BOT_THREADS), allowed: `1 to ${MAX_CONCURRENT_BOT_THREADS}`,- current: () => cfg().threads?.maxConcurrentPerBot, write: config((maxConcurrentPerBot: number) => ({ threads: { maxConcurrentPerBot } })),+ current: () => cfg().threads?.maxConcurrentPerBot ?? defaultBotThreads(), write: config((maxConcurrentPerBot: number) => ({ threads: { maxConcurrentPerBot } })),}),writable({id: "threads.eventLogRetentionDays", label: "Thread log retention", help: "Days a closed conversation's event logs are kept; null keeps them forever.", where: "Settings → Data",@@ -125,12 +125,12 @@ export function createSettingsRegistry(deps: RegistryDeps): SettingEntry[] {writable({id: "rooms.turnTimeoutMinutes", label: "Room turn timeout", help: "Minutes a bot's turn in a room may run before it is stopped.", where: "Settings → You and your bots",synonyms: ["room", "channel", "timeout", "turn limit"], tier: "safe", value: z.number().int().min(MIN_ROOM_TURN_TIMEOUT_MINUTES).max(MAX_ROOM_TURN_TIMEOUT_MINUTES), allowed: `${MIN_ROOM_TURN_TIMEOUT_MINUTES} to ${MAX_ROOM_TURN_TIMEOUT_MINUTES} minutes`,- current: () => cfg().rooms?.turnTimeoutMinutes, write: config((turnTimeoutMinutes: number) => ({ rooms: { turnTimeoutMinutes } })),+ current: () => roomTurnTimeoutMinutes(cfg()), write: config((turnTimeoutMinutes: number) => ({ rooms: { turnTimeoutMinutes } })),}),writable({id: "mcp.callTimeoutMinutes", label: "MCP call timeout", help: "Minutes one MCP tool call may run.", where: "Settings → AI",synonyms: ["mcp", "tool timeout", "call timeout"], tier: "safe", value: z.number().int().min(MIN_MCP_CALL_TIMEOUT_MINUTES).max(MAX_MCP_CALL_TIMEOUT_MINUTES), allowed: `${MIN_MCP_CALL_TIMEOUT_MINUTES} to ${MAX_MCP_CALL_TIMEOUT_MINUTES} minutes`,- current: () => cfg().mcp?.callTimeoutMinutes, write: config((callTimeoutMinutes: number) => ({ mcp: { callTimeoutMinutes } })),+ current: () => mcpCallTimeoutMinutes(cfg()), write: config((callTimeoutMinutes: number) => ({ mcp: { callTimeoutMinutes } })),}),writable({id: "bots.defaultModel", label: "Default model for new bots", help: "The engine and model a newly created bot starts on; existing bots keep theirs. Ids come from list_models.", where: "Settings → You and your bots",