Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
ElevenLabs Live: signed-URL-only agent, tool call events, typed key dropped on service change
Bugfixer 238e17ffa84bd
diff --git a/server/live-elevenlabs.test.ts b/server/live-elevenlabs.test.tsindex 1bef321b4f..4ddb701fbc 100644--- a/server/live-elevenlabs.test.ts+++ b/server/live-elevenlabs.test.ts@@ -53,8 +53,9 @@ describe("an ElevenLabs agent for Live calls", () => {expect(agent).toMatchObject({name: "OpenMausBot Live calls",conversation_config: { agent: { prompt: { tool_ids: ["tool_1"] } }, asr: { user_input_audio_format: "pcm_16000" }, tts: { agent_output_audio_format: "pcm_16000" } },- platform_settings: { overrides: { conversation_config_override: { agent: { prompt: { prompt: true } } } } },+ platform_settings: { overrides: { conversation_config_override: { agent: { prompt: { prompt: true } } } }, auth: { enable_auth: true } },});+ expect(agent.conversation_config.conversation.client_events).toEqual(expect.arrayContaining(["client_tool_call", "audio", "interruption", "user_transcript", "agent_response", "ping"]));});it("fails with words for the person, never ElevenLabs' body, when ElevenLabs refuses or answers oddly", async () => {diff --git a/server/live-elevenlabs.ts b/server/live-elevenlabs.tsindex cda060ee5d..0170ba9a1a 100644--- a/server/live-elevenlabs.ts+++ b/server/live-elevenlabs.ts@@ -15,6 +15,9 @@ const AGENT_ID = /^[\w-]{1,128}$/;/** The agent's audio both ways: 16 kHz 16-bit PCM, as the client sends and plays it. */const AUDIO_FORMAT = "pcm_16000";const UNEXPECTED = "ElevenLabs returned an unexpected answer. Try the call again.";+/** What ElevenLabs sends the client. A list replaces ElevenLabs' defaults, so it names every event the client reads, with+ * `client_tool_call` so `delegate` reaches the client. */+const CLIENT_EVENTS = ["conversation_initiation_metadata", "ping", "audio", "interruption", "user_transcript", "agent_response", "agent_response_correction", "client_tool_call"];/** `model` is the agent id, "" while no usable one is saved. The API root is the one ElevenLabs voices use (OMB_ELEVENLABS_API). */export function elevenLabsLiveEndpoint(agentId: string | null | undefined, env: NodeJS.ProcessEnv = process.env): LiveEndpoint {@@ -72,9 +75,11 @@ export async function setUpElevenLabsAgent(key: string, endpoint: LiveEndpoint,agent: { first_message: "", language: "en", prompt: { prompt: `You are ${product} on a live voice call.`, tool_ids: [toolId] } },asr: { user_input_audio_format: AUDIO_FORMAT },tts: { agent_output_audio_format: AUDIO_FORMAT },+ conversation: { client_events: CLIENT_EVENTS },},- // Without this ElevenLabs refuses the prompt each conversation sends.- platform_settings: { overrides: { conversation_config_override: { agent: { prompt: { prompt: true } } } } },+ // Without the override ElevenLabs refuses the prompt each conversation sends. With auth on, a conversation needs a+ // signed URL, which only the harness can get with the key: knowing the agent id is not enough to spend the person's credits.+ platform_settings: { overrides: { conversation_config_override: { agent: { prompt: { prompt: true } } } }, auth: { enable_auth: true } },});const agentId = typeof agent.agent_id === "string" && AGENT_ID.test(agent.agent_id) ? agent.agent_id : "";if (!agentId) throw new LiveSessionError(UNEXPECTED, 502);diff --git a/src/components/keys/KeyRow.tsx b/src/components/keys/KeyRow.tsxindex 746405bdcd..3d564f66d8 100644--- a/src/components/keys/KeyRow.tsx+++ b/src/components/keys/KeyRow.tsx@@ -130,6 +130,17 @@ export function KeyRow({const entry = shownKeyEntry(id, state.config);const row = rowId ? shownKeyEntry(rowId, state.config) : entry;+ // The Live key row changes service with the Live calls choice: a key typed for one service is never saved for another.+ const [draftFor, setDraftFor] = useState(entry.name);+ if (draftFor !== entry.name) {+ setDraftFor(entry.name);+ setDraft("");+ setShown(false);+ setReplacing(false);+ setProblem(null);+ setVerdict(null);+ setWorks(false);+ }const target = entry.target;if (!target) throw new Error(`${id} is not saved by a key row`);const pointer = row.id !== entry.id;diff --git a/src/components/keys/KeysPage.dom.test.ts b/src/components/keys/KeysPage.dom.test.tsindex f7018ab6e6..86554e7d62 100644--- a/src/components/keys/KeysPage.dom.test.ts+++ b/src/components/keys/KeysPage.dom.test.ts@@ -146,6 +146,19 @@ describe("the keys page", () => {expect(row("liveCalls")).toBeNull();});+ it("drops a key typed on the Live key row when the Live calls service changes, so it is never saved for the other service", () => {+ const live = { configured: false, voice: "", readTypedReplies: true, idleMinutes: 5 };+ setConfig({ ...fx.config, live: { ...live, provider: "fish" } });+ page();+ const field = () => row("liveKey")!.querySelector<HTMLInputElement>('input[type="password"]')!;+ type(field(), "typed-for-fish-audio");+ expect(field().value).toBe("typed-for-fish-audio");++ flushSync(() => setConfig({ ...fx.config, live: { ...live, provider: "elevenlabs" } }));+ expect(row("liveKey")!.textContent).toContain("ElevenLabs");+ expect(field().value).toBe("");+ });+it("opens a section that holds a saved key, and counts what is connected", () => {setConfig({ ...fx.config, box: { configured: true, last4: "c3d4" } });page();