Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge #7452: Gemini Live model picker
milind-soniee2643a82696
diff --cc packages/phone-protocol/src/live-call-wire.tsindex b02cae9665,7c4e8659b5..eb63876eb9--- a/packages/phone-protocol/src/live-call-wire.ts+++ b/packages/phone-protocol/src/live-call-wire.ts@@@ -95,15 -86,10 +95,17 @@@ export interface LiveSettingsvoice: string;/** The Gemini Live voice for "gemini" calls; absent means Gemini's default. */geminiVoice?: string;+ /** The Gemini Live model for "gemini" calls; absent means Gemini's default. */+ geminiModel?: string;readTypedReplies: boolean;idleMinutes: number;+ /** Opts direct OpenAI GPT-Live WebRTC calls into speech-wake standby; absent or false keeps active inference. */+ standby?: boolean;+ /** Whole seconds before standby, from 5 to 60; defaults to 15 when enabled. */+ standbyIdleSeconds?: number;+ historyMessages?: number;+ historyMessageChars?: number;+ historyTotalChars?: number;}/** The single-use token Fish Audio returns for one agent session (Fish API v1 `LiveKitSessionToken`), passed verbatim todiff --cc server/live-config.tsindex 34f3338e12,005a626258..2dd305437f--- a/server/live-config.ts+++ b/server/live-config.ts@@@ -1,6 -1,6 +1,6 @@@// Live calls' settings in config.json: schema, type and environment overrides, kept out of server/config.ts.import { z } from "zod";- import { liveHistoryLimitError } from "../shared/live-call.ts";-import { parseGeminiLiveModel } from "../shared/live-call.ts";++import { liveHistoryLimitError, parseGeminiLiveModel } from "../shared/live-call.ts";export const LIVE_KEY_NEEDS_ENDPOINT = "Save the Azure endpoint first: a Live key works only with the endpoint it was saved for.";export const LIVE_KEY_NEEDS_CUSTOM_ENDPOINT = "Save the custom endpoint first: a Live key works only with the endpoint it was saved for.";@@@ -24,13 -22,9 +24,14 @@@ export const liveConfigSchema = z.objecelevenlabsAgentFor: z.string().max(64).optional(),voice: z.string().trim().max(40).regex(/^[a-z]*$/, "a Live voice is a lowercase built-in voice name").optional(),geminiVoice: z.string().trim().max(40).regex(/^[A-Za-z]*$/, "a Gemini Live voice is a built-in voice name").optional(),+ geminiModel: z.string().trim().max(80).transform((name) => name.replace(/^models\//, "")).refine((name) => name === "" || parseGeminiLiveModel(name) !== undefined, "a Gemini Live model is a Gemini model id").optional(),readTypedReplies: z.boolean().optional(),idleMinutes: z.number().int().min(1).max(60).optional(),+ standby: z.boolean().optional(),+ standbyIdleSeconds: z.number().int().min(LIVE_STANDBY_IDLE_SECONDS_MIN).max(LIVE_STANDBY_IDLE_SECONDS_MAX).optional(),+ historyMessages: z.number().int().min(0).max(200).optional(),+ historyMessageChars: z.number().int().min(100).max(12_000).optional(),+ historyTotalChars: z.number().int().min(500).max(60_000).optional(),});export interface LiveConfig {@@@ -48,13 -42,9 +49,14 @@@elevenlabsAgentFor?: string;voice?: string;geminiVoice?: string;+ geminiModel?: string;readTypedReplies?: boolean;idleMinutes?: number;+ standby?: boolean;+ standbyIdleSeconds?: number;+ historyMessages?: number;+ historyMessageChars?: number;+ historyTotalChars?: number;}/** Where a key saved now may go: "openai", "azure:<host>" or "custom:<host>"; null while Azure or a custom endpoint is chosendiff --cc server/live-gemini.tsindex ff1400cdd2,d03bc12c35..c65f6929e5--- a/server/live-gemini.ts+++ b/server/live-gemini.ts@@@ -1,8 -1,8 +1,8 @@@// Gemini Live calls. The Gemini key never leaves the harness: the client gets only a single-use ephemeral token whose setup// (model, instructions, the `delegate` tool) the harness locks here, and it relays what was said as a Fish Audio call does.import { randomBytes } from "node:crypto";- import { geminiLiveVoice } from "../shared/live-call.ts";+ import { GEMINI_LIVE_DEFAULT_MODEL, geminiLiveVoice, parseGeminiLiveModel } from "../shared/live-call.ts";-import type { LiveGeminiSession } from "../shared/wire.ts";+import type { LiveGeminiSession, LiveHistoryLimits } from "../shared/wire.ts";import { LiveSessionError, type LiveBot, type LiveEndpoint, type LiveHistoryMessage } from "./live-call.ts";import { FISH_DELEGATE_TOOL, fishInstructions } from "./live-fish.ts";diff --cc server/live-settings.tsindex 0a532113c5,2bc5f351e6..c18609c0a2--- a/server/live-settings.ts+++ b/server/live-settings.ts@@@ -101,13 -85,8 +101,14 @@@ export function liveSettingsFor(cfg: Ap...(cfg.live?.customModel ? { customModel: cfg.live.customModel } : {}),voice: cfg.live?.voice ?? "",...(cfg.live?.geminiVoice ? { geminiVoice: cfg.live.geminiVoice } : {}),+ ...(cfg.live?.geminiModel ? { geminiModel: cfg.live.geminiModel } : {}),readTypedReplies: cfg.live?.readTypedReplies ?? true,idleMinutes: Number.isInteger(minutes) && minutes! >= 1 && minutes! <= 60 ? minutes! : LIVE_IDLE_MINUTES_DEFAULT,+ ...(cfg.live?.standby === true ? { standby: true } : {}),+ ...(cfg.live?.standby === true || cfg.live?.standbyIdleSeconds !== undefined ? {+ standbyIdleSeconds: Number.isInteger(cfg.live.standbyIdleSeconds) && cfg.live.standbyIdleSeconds! >= LIVE_STANDBY_IDLE_SECONDS_MIN && cfg.live.standbyIdleSeconds! <= LIVE_STANDBY_IDLE_SECONDS_MAX+ ? cfg.live.standbyIdleSeconds! : LIVE_STANDBY_IDLE_SECONDS_DEFAULT,+ } : {}),+ ...liveHistorySettings(cfg.live, provider),};}diff --cc server/routes/live.test.tsindex 3ac6871778,0caacdb502..d051e273e1--- a/server/routes/live.test.ts+++ b/server/routes/live.test.ts@@@ -149,9 -142,16 +149,19 @@@ describe("live routes", () =>expect((await request(d, "PATCH", "/api/live/settings", { geminiVoice: "marin" })).status).toBe(400);expect((await request(d, "PATCH", "/api/live/settings", { geminiVoice: "Kore" })).status).toBe(200);expect((await request(d, "PATCH", "/api/live/settings", { geminiVoice: "" })).status).toBe(200);+ expect(await request(d, "PATCH", "/api/live/settings", { standby: true, standbyIdleSeconds: 15 })).toMatchObject({ status: 200, body: { live: { standby: true, standbyIdleSeconds: 15 } } });+ for (const standbyIdleSeconds of [4, 61, 10.5]) expect((await request(d, "PATCH", "/api/live/settings", { standbyIdleSeconds })).status).toBe(400);- expect(d.saved).toEqual([{ idleMinutes: 10, readTypedReplies: false }, { geminiVoice: "Kore" }, { geminiVoice: "" }, { standby: true, standbyIdleSeconds: 15 }]);+ expect((await request(d, "PATCH", "/api/live/settings", { geminiModel: "../bad" })).status).toBe(400);+ expect((await request(d, "PATCH", "/api/live/settings", { geminiModel: "models/gemini-3.1-flash-live-preview" })).status).toBe(200);+ expect((await request(d, "PATCH", "/api/live/settings", { geminiModel: "" })).status).toBe(200);+ expect(d.saved).toEqual([+ { idleMinutes: 10, readTypedReplies: false },+ { geminiVoice: "Kore" },+ { geminiVoice: "" },++ { standby: true, standbyIdleSeconds: 15 },+ { geminiModel: "gemini-3.1-flash-live-preview" },+ { geminiModel: "" },+ ]);});it("saves an Azure provider, endpoint and deployment, refusing a host the key must not reach", async () => {const d = deps();diff --cc server/routes/live.tsindex 0fc4a5ea0c,1d32b31f22..f38acc6744--- a/server/routes/live.ts+++ b/server/routes/live.ts@@@ -2,9 -2,8 +2,9 @@@import type { IncomingMessage } from "node:http";import { z } from "zod";import type { LiveFishRelayCommand, LiveFishRelayEvent, LiveProvider, LiveSettings } from "../../shared/wire.ts";- import { GEMINI_LIVE_VOICE_OPTIONS, liveHistoryLimitError } from "../../shared/live-call.ts";-import { GEMINI_LIVE_VOICE_OPTIONS, parseGeminiLiveModel } from "../../shared/live-call.ts";++import { GEMINI_LIVE_VOICE_OPTIONS, liveHistoryLimitError, parseGeminiLiveModel } from "../../shared/live-call.ts";import { azureLiveDeployment, azureOpenAiRoot, customLiveApiBase, customLiveModel, LiveSessionError, MAX_SDP_BYTES } from "../live-call.ts";+import { LIVE_STANDBY_IDLE_SECONDS_MAX, LIVE_STANDBY_IDLE_SECONDS_MIN } from "../live-config.ts";import { LiveCallBusyError, type LiveCallController } from "../live-call-controller.ts";import { RELAY_POLL_MS } from "../live-fish.ts";import { PASS, type RouteContext, type RouteHandler } from "./table.ts";@@@ -15,7 -14,7 +15,7 @@@ export interface LiveRouteDepsdeviceRevoked?: (device: string) => void;resolveTarget(botId: string, threadId: string | undefined): { botId: string; botName: string; threadId: string } | null;settings(): LiveSettings;- saveSettings(patch: { provider?: LiveProvider; azureEndpoint?: string; azureDeployment?: string; customEndpoint?: string; customModel?: string; voice?: string; geminiVoice?: string; readTypedReplies?: boolean; idleMinutes?: number; standby?: boolean; standbyIdleSeconds?: number; historyMessages?: number; historyMessageChars?: number; historyTotalChars?: number }): Promise<LiveSettings>;- saveSettings(patch: { provider?: LiveProvider; azureEndpoint?: string; azureDeployment?: string; customEndpoint?: string; customModel?: string; voice?: string; geminiVoice?: string; geminiModel?: string; readTypedReplies?: boolean; idleMinutes?: number }): Promise<LiveSettings>;++ saveSettings(patch: { provider?: LiveProvider; azureEndpoint?: string; azureDeployment?: string; customEndpoint?: string; customModel?: string; voice?: string; geminiVoice?: string; geminiModel?: string; readTypedReplies?: boolean; idleMinutes?: number; standby?: boolean; standbyIdleSeconds?: number; historyMessages?: number; historyMessageChars?: number; historyTotalChars?: number }): Promise<LiveSettings>;/** A running relayed (Fish Audio, Gemini or ElevenLabs) call's relay, only for the token its start answered with. */fishRelay(sessionId: string, token: string): { receive(events: LiveFishRelayEvent[], from?: number): void; poll(waitMs: number): Promise<{ commands: LiveFishRelayCommand[]; closed: boolean }> } | null;}@@@ -59,13 -56,10 +59,15 @@@ const settingsBody = z.object(voice: z.string().trim().max(40).regex(/^[a-z]*$/).optional(),// "" goes back to the default voice.geminiVoice: z.string().trim().refine((name) => name === "" || GEMINI_LIVE_VOICE_OPTIONS.some((option) => option.id === name)).optional(),+ // "" goes back to the default model.+ geminiModel: z.string().trim().max(80).transform((name) => name.replace(/^models\//, "")).refine((name) => name === "" || parseGeminiLiveModel(name) !== undefined).optional(),readTypedReplies: z.boolean().optional(),idleMinutes: z.number().int().min(1).max(60).optional(),+ standby: z.boolean().optional(),+ standbyIdleSeconds: z.number().int().min(LIVE_STANDBY_IDLE_SECONDS_MIN).max(LIVE_STANDBY_IDLE_SECONDS_MAX).optional(),+ historyMessages: z.number().int().min(0).max(200).optional(),+ historyMessageChars: z.number().int().min(100).max(12_000).optional(),+ historyTotalChars: z.number().int().min(500).max(60_000).optional(),}).strict();const DEVICE_ID = /^[\w-]{1,128}$/;diff --cc src/components/LiveCallSettings.tsxindex 7d73544548,3a8c7eed19..9419df7888--- a/src/components/LiveCallSettings.tsx+++ b/src/components/LiveCallSettings.tsx@@@ -1,13 -1,10 +1,13 @@@import { useCallback, useId, useState } from "react";-import { GEMINI_LIVE_MODEL_OPTIONS, GEMINI_LIVE_VOICE_OPTIONS, geminiLiveModel, geminiLiveVoice, LIVE_VOICE_OPTIONS } from "../../shared/live-call";-import { t } from "@/lib/i18n";+import {- GEMINI_LIVE_VOICE_OPTIONS, geminiLiveVoice, LIVE_HISTORY_MIN, LIVE_STANDBY_IDLE_SECONDS_DEFAULT, LIVE_VOICE_OPTIONS,++ GEMINI_LIVE_MODEL_OPTIONS, GEMINI_LIVE_VOICE_OPTIONS, geminiLiveModel, geminiLiveVoice, LIVE_HISTORY_MIN, LIVE_STANDBY_IDLE_SECONDS_DEFAULT, LIVE_VOICE_OPTIONS,+ liveHistoryCaps, resolveLiveHistoryLimits,+} from "../../shared/live-call";+import { intlLocale, t } from "@/lib/i18n";import { liveDisclosure, liveKeyCopy, liveKeyFormKey } from "@/lib/call-mode";import { api, useStore, type Bot, type ConfigStatus } from "@/state/store";-import type { LiveSettings } from "../../shared/wire";+import type { LiveHistoryLimits, LiveSettings } from "../../shared/wire";import { LiveKeySetup } from "./LiveKeySetup";import { LiveProviderSettings } from "./LiveProviderSettings";import { BotLiveVoiceSelect } from "./BotLiveVoiceSelect";@@@ -54,8 -38,10 +54,10 @@@ export function LiveCallSettings({ botconst voiceOptions = gemini ? GEMINI_LIVE_VOICE_OPTIONS : LIVE_VOICE_OPTIONS;const voice = gemini ? geminiLiveVoice(live.geminiVoice) : live.voice || "marin";const known = voiceOptions.some((option) => option.id === voice);+ const geminiModel = geminiLiveModel(live.geminiModel);+ const knownGeminiModel = GEMINI_LIVE_MODEL_OPTIONS.some((option) => option.id === geminiModel);- const save = async (patch: Partial<Pick<LiveSettings, "voice" | "geminiVoice" | "readTypedReplies" | "idleMinutes" | "standby" | "standbyIdleSeconds" | keyof LiveHistoryLimits>>) => {- const save = async (patch: Partial<Pick<LiveSettings, "voice" | "geminiVoice" | "geminiModel" | "readTypedReplies" | "idleMinutes">>) => {++ const save = async (patch: Partial<Pick<LiveSettings, "voice" | "geminiVoice" | "geminiModel" | "readTypedReplies" | "idleMinutes" | "standby" | "standbyIdleSeconds" | keyof LiveHistoryLimits>>) => {setSaving(true);setError(null);try {