Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Live calls: keep Live config out of server/config.ts
prantikmedhi923e4b94ac33
diff --git a/server/config.ts b/server/config.tsindex 499c4d96c8..d95d56619e 100644--- a/server/config.ts+++ b/server/config.ts@@ -24,6 +24,7 @@ import { settledFileCache, settledFileStamp } from "./settled-file.ts";import { isRemoteMcpServer, mcpServerServes, parseStoredMcpServer } from "./mcp-registry.ts"; import { postizKeyHeaders } from "./postiz/connection.ts";import { parseJson, schemaIssue, type JsonObject, type JsonValue } from "./schema.ts";import { deciderConfigSchema, type DeciderConfig } from "./decider/config.ts";+import { liveConfigSchema, liveConfigWithEnv, liveSettingEnv, type LiveConfig } from "./live-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";@@ -397,16 +398,7 @@ const appConfigSchema = z.object({fishModel: z.enum(FISH_TTS_MODELS).optional(),}).optional(),decider: deciderConfigSchema.optional(),- /** Live calls: `key` is a key for Live calls only; with `provider` "openai" (the default) a call without one uses `openai.key`, with "azure" it is the Azure resource's key and is required. `azureEndpoint` is the resource URL and `azureDeployment` the gpt-live-1 deployment name. `voice` is a GPT-Live voice. */- live: z.object({- key: optionalText,- provider: z.enum(["openai", "azure"]).optional(),- azureEndpoint: z.string().trim().max(300).optional(),- azureDeployment: z.string().trim().max(64).optional(),- voice: z.string().trim().max(40).regex(/^[a-z]*$/, "a Live voice is a lowercase built-in voice name").optional(),- readTypedReplies: z.boolean().optional(),- idleMinutes: z.number().int().min(1).max(60).optional(),- }).optional(),+ live: liveConfigSchema.optional(),/** Avatar provider credentials stay separate; choosing a router never reuses a cloud key. */imageGen: z.object({provider: z.enum(["openai", "xai", "custom"]).optional(),@@ -514,7 +506,7 @@ export interface AppConfig extends HelperConfig {tts?: { key?: string; fishKey?: string; voice?: string; provider?: "elevenlabs" | "fish" | "system" | "chatterbox" | "xai"; baseUrl?: string; model?: string; fishModel?: FishTtsModel };decider?: DeciderConfig;imageGen?: ImageGenerationConfig;- live?: { key?: string; provider?: "openai" | "azure"; azureEndpoint?: string; azureDeployment?: string; voice?: string; readTypedReplies?: boolean; idleMinutes?: number };+ live?: LiveConfig;profile?: { name?: string; email?: string; aboutMe?: string; avatarUrl?: string };rooms?: { turnTimeoutMinutes: number };mcp?: { callTimeoutMinutes?: number };@@ -805,12 +797,7 @@ export function loadConfig(): AppConfig {cfg.decider = { ...cfg.decider };if (process.env.OMB_JEV_API_KEY !== undefined) cfg.decider.key = process.env.OMB_JEV_API_KEY;if (process.env.OMB_OPENROUTER_DECIDER_KEY !== undefined) cfg.decider.openrouterKey = process.env.OMB_OPENROUTER_DECIDER_KEY; if (process.env.OMB_WORKERS_AI_TOKEN !== undefined) cfg.decider.workersAiToken = process.env.OMB_WORKERS_AI_TOKEN;- cfg.live = { ...cfg.live };- if (process.env.OMB_OPENAI_LIVE_KEY !== undefined) cfg.live.key = process.env.OMB_OPENAI_LIVE_KEY;- const liveProvider = process.env.OMB_LIVE_PROVIDER?.trim().toLowerCase();- if (liveProvider === "openai" || liveProvider === "azure") cfg.live.provider = liveProvider;- if (process.env.OMB_AZURE_OPENAI_LIVE_ENDPOINT !== undefined) cfg.live.azureEndpoint = process.env.OMB_AZURE_OPENAI_LIVE_ENDPOINT.trim();- if (process.env.OMB_AZURE_OPENAI_LIVE_DEPLOYMENT !== undefined) cfg.live.azureDeployment = process.env.OMB_AZURE_OPENAI_LIVE_DEPLOYMENT.trim();+ cfg.live = liveConfigWithEnv(cfg.live);cfg.imageGen = { ...cfg.imageGen };if (process.env.OMB_OPENAI_IMAGE_KEY !== undefined) cfg.imageGen.key = process.env.OMB_OPENAI_IMAGE_KEY;if (process.env.OMB_CUSTOM_IMAGE_KEY !== undefined) cfg.imageGen.customApiKey = process.env.OMB_CUSTOM_IMAGE_KEY;@@ -870,9 +857,7 @@ export function syncCredentialEnv(patch: Partial<Omit<AppConfig, "threads" | "ne[patch.anthropic?.url, "OMB_ANTHROPIC_API_URL"],[patch.openaiCompat?.model, "OPENAI_COMPAT_MODEL"],[patch.openaiCompat?.provider, "OPENAI_COMPAT_PROVIDER"],- [patch.live?.provider, "OMB_LIVE_PROVIDER"],- [patch.live?.azureEndpoint, "OMB_AZURE_OPENAI_LIVE_ENDPOINT"],- [patch.live?.azureDeployment, "OMB_AZURE_OPENAI_LIVE_DEPLOYMENT"],+ ...liveSettingEnv(patch.live),];for (const [value, name] of settings) {if (value === undefined) continue;diff --git a/server/live-config.ts b/server/live-config.tsnew file mode 100644index 0000000000..ee2413047a--- /dev/null+++ b/server/live-config.ts@@ -0,0 +1,42 @@+// Live calls' settings in config.json: schema, type and environment overrides, kept out of server/config.ts.+import { z } from "zod";++/** Live calls: `key` is a key for Live calls only; with `provider` "openai" (the default) a call without one uses `openai.key`, with "azure" it is the Azure resource's key and is required. `azureEndpoint` is the resource URL and `azureDeployment` the gpt-live-1 deployment name. `voice` is a GPT-Live voice. */+export const liveConfigSchema = z.object({+ key: z.string().optional(),+ provider: z.enum(["openai", "azure"]).optional(),+ azureEndpoint: z.string().trim().max(300).optional(),+ azureDeployment: z.string().trim().max(64).optional(),+ voice: z.string().trim().max(40).regex(/^[a-z]*$/, "a Live voice is a lowercase built-in voice name").optional(),+ readTypedReplies: z.boolean().optional(),+ idleMinutes: z.number().int().min(1).max(60).optional(),+});++export interface LiveConfig {+ key?: string;+ provider?: "openai" | "azure";+ azureEndpoint?: string;+ azureDeployment?: string;+ voice?: string;+ readTypedReplies?: boolean;+ idleMinutes?: number;+}++export function liveConfigWithEnv(live: LiveConfig | undefined, env: NodeJS.ProcessEnv = process.env): LiveConfig {+ const next = { ...live };+ if (env.OMB_OPENAI_LIVE_KEY !== undefined) next.key = env.OMB_OPENAI_LIVE_KEY;+ const provider = env.OMB_LIVE_PROVIDER?.trim().toLowerCase();+ if (provider === "openai" || provider === "azure") next.provider = provider;+ if (env.OMB_AZURE_OPENAI_LIVE_ENDPOINT !== undefined) next.azureEndpoint = env.OMB_AZURE_OPENAI_LIVE_ENDPOINT.trim();+ if (env.OMB_AZURE_OPENAI_LIVE_DEPLOYMENT !== undefined) next.azureDeployment = env.OMB_AZURE_OPENAI_LIVE_DEPLOYMENT.trim();+ return next;+}++/** The non-secret Live settings a settings patch mirrors into the environment. */+export function liveSettingEnv(live: LiveConfig | undefined): Array<[value: string | undefined, name: string]> {+ return [+ [live?.provider, "OMB_LIVE_PROVIDER"],+ [live?.azureEndpoint, "OMB_AZURE_OPENAI_LIVE_ENDPOINT"],+ [live?.azureDeployment, "OMB_AZURE_OPENAI_LIVE_DEPLOYMENT"],+ ];+}