Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

#5512: name the Fish agent with the product name

milind-soni25af5b10816d
diff --git a/docs/verification/live-calls.md b/docs/verification/live-calls.md
index baa34a6483..2a76dc2615 100644
--- a/docs/verification/live-calls.md
+++ b/docs/verification/live-calls.md
@@ -126,7 +126,8 @@ Audio key from Settings → API keys (`tts.fishKey`, `OMB_FISH_AUDIO_API_KEY`),
the same key Fish voices use; nothing else is asked. On the first call the
harness sets up an agent on that key's account (`server/live-fish.ts`
`setUpFishAgent`): a client tool `delegate` (`POST /v1/agent/tools`), an agent
-on the `live3` engine in English with that tool (`POST /v1/agent/agents`),
+named "<product> Live calls" (`productName` in `server/brand.ts`: MausBot, or a
+white-label brand's name) on the `live3` engine in English with that tool (`POST /v1/agent/agents`),
`overrides_allowed: ["system_prompt"]` (`PATCH /v1/agent/agents/{id}`), and a
publish. It saves the agent as `live.fishAgentId` with `live.fishAgentFor`, a
short SHA-256 print of the key, so a key for another account sets up its own
diff --git a/server/brand.test.ts b/server/brand.test.ts
index 43045520e8..743097cd3f 100644
--- a/server/brand.test.ts
+++ b/server/brand.test.ts
@@ -3,7 +3,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach, describe, expect, it } from "vitest";
-import { DEFAULT_BRAND, describeBrand, loadBrand } from "./brand.ts";
+import { DEFAULT_BRAND, describeBrand, loadBrand, productName } from "./brand.ts";
const dirs: string[] = [];
const licensed = (feature: string) => feature === "whitelabel";
@@ -26,6 +26,7 @@ describe("brand.json", () => {
const file = join(tmpdir(), "omb-brand-missing", "brand.json");
expect(loadBrand({ file, isEntitled: licensed })).toEqual({ brand: DEFAULT_BRAND, source: "default", file });
expect(describeBrand(loadBrand({ file, isEntitled: licensed }))).toBe("brand: default");
+ expect(productName(loadBrand({ file, isEntitled: licensed }))).toBe("MausBot");
});
it("applies a valid file on a licensed server", () => {
@@ -42,6 +43,7 @@ describe("brand.json", () => {
expect(status.brand.accent).toBe("#1D4ED8");
expect(status.notice).toBeUndefined();
expect(describeBrand(status)).toBe(`brand: Reliable Platform (from ${file})`);
+ expect(productName(status)).toBe("Reliable Platform");
});
it("keeps the default brand on an unlicensed server and says so", () => {
diff --git a/server/brand.ts b/server/brand.ts
index 366b65c94c..222d3741b6 100644
--- a/server/brand.ts
+++ b/server/brand.ts
@@ -39,6 +39,8 @@ export const brandSchema = z
export type Brand = z.infer<typeof brandSchema>;
export const DEFAULT_BRAND: Brand = { name: "OpenMausBot" };
+/** The product's name wherever a person reads it. OpenMausBot names only the open-source project and its repository. */
+export const PRODUCT_NAME = "MausBot";
export interface BrandStatus {
brand: Brand;
@@ -83,3 +85,8 @@ export function describeBrand(status: BrandStatus): string {
if (status.source === "file") return `brand: ${status.brand.name} (from ${status.file})`;
return `brand: default${status.notice ? ` (${status.notice})` : ""}`;
}
+
+/** The name a person reads: an applied brand file's own name, else MausBot. `DEFAULT_BRAND.name` stays the project's name. */
+export function productName(status: BrandStatus = loadBrand()): string {
+ return status.source === "file" ? status.brand.name : PRODUCT_NAME;
+}
diff --git a/server/live-fish.test.ts b/server/live-fish.test.ts
index 85ac3b82a1..6adaaedb35 100644
--- a/server/live-fish.test.ts
+++ b/server/live-fish.test.ts
@@ -50,10 +50,11 @@ describe("the Fish agent for Live calls", () => {
const route = `${init!.method} ${String(url).replace(ENDPOINT.apiBase, "")}`;
return new Response(JSON.stringify(answers[route] ?? {}), { status: route in answers ? 200 : 404 });
});
- await expect(setUpFishAgent(" fish-key ", { ...ENDPOINT, model: "" }, fetchImpl)).resolves.toBe("agent_new");
+ await expect(setUpFishAgent(" fish-key ", { ...ENDPOINT, model: "" }, "MausBot", fetchImpl)).resolves.toBe("agent_new");
const calls = fetchImpl.mock.calls.map(([url, init]) => ({ route: `${init!.method} ${String(url).replace(ENDPOINT.apiBase, "")}`, body: JSON.parse(String(init!.body)), init: init! }));
expect(calls.map((call) => call.route)).toEqual(Object.keys(answers));
expect(calls[0]!.body).toMatchObject({ name: "delegate", tool_type: "client", expects_response: true });
+ expect(calls[1]!.body.name).toBe("MausBot Live calls");
expect(calls[1]!.body.config).toEqual({ voice: { engine: "live3", speaking_language: "en" }, tools: { enabled: true, tool_ids: ["tool_1"] } });
expect(calls[2]!.body).toEqual({ overrides_allowed: ["system_prompt"] });
for (const call of calls) {
@@ -64,9 +65,9 @@ describe("the Fish agent for Live calls", () => {
it("stops at Fish's first refusal with the user's next step, never Fish's body", async () => {
const fetchImpl = fakeFetch(401, { message: "raw fish-key detail" });
- await expect(setUpFishAgent("fish-key", ENDPOINT, fetchImpl)).rejects.toMatchObject({ status: 502, message: fishErrorMessage(401) });
+ await expect(setUpFishAgent("fish-key", ENDPOINT, "MausBot", fetchImpl)).rejects.toMatchObject({ status: 502, message: fishErrorMessage(401) });
expect(fetchImpl).toHaveBeenCalledTimes(1);
- await expect(setUpFishAgent("fish-key", ENDPOINT, fakeFetch(201, {}))).rejects.toMatchObject({ status: 502 });
+ await expect(setUpFishAgent("fish-key", ENDPOINT, "MausBot", fakeFetch(201, {}))).rejects.toMatchObject({ status: 502 });
});
});
diff --git a/server/live-fish.ts b/server/live-fish.ts
index 3ce73fc1f2..69efa40bda 100644
--- a/server/live-fish.ts
+++ b/server/live-fish.ts
@@ -46,9 +46,9 @@ export function usableFishAgent(live: LiveConfig | undefined, key: string): stri
return live?.fishAgentFor === undefined || (key.trim() !== "" && live.fishAgentFor === fishKeyPrint(key)) ? id : null;
}
-/** Fish API v1: a Live 3 agent in English with the client tool `delegate` and a system prompt each session may override
- * (`createFishLiveSession` sends one), published so sessions can start. Returns its id. */
-export async function setUpFishAgent(key: string, endpoint: LiveEndpoint, fetchImpl: typeof fetch = fetch): Promise<string> {
+/** Fish API v1: a Live 3 agent in English named for `product`, with the client tool `delegate` and a system prompt each
+ * session may override (`createFishLiveSession` sends one), published so sessions can start. Returns its id. */
+export async function setUpFishAgent(key: string, endpoint: LiveEndpoint, product: string, fetchImpl: typeof fetch = fetch): Promise<string> {
const call = (method: string, path: string, body: unknown) => fishSetupRequest(fetchImpl, key, method, `${endpoint.apiBase}${path}`, body);
const tool = await call("POST", "/tools", {
name: FISH_DELEGATE_TOOL,
@@ -61,7 +61,7 @@ export async function setUpFishAgent(key: string, endpoint: LiveEndpoint, fetchI
const toolId = typeof tool.tool_id === "string" ? tool.tool_id : "";
if (!toolId) throw new LiveSessionError(FISH_UNEXPECTED, 502);
const agent = await call("POST", "/agents", {
- name: "OpenMausBot Live calls",
+ name: `${product} Live calls`.slice(0, 120),
config: { voice: { engine: "live3", speaking_language: "en" }, tools: { enabled: true, tool_ids: [toolId] } },
});
const agentId = typeof agent.agent_id === "string" && AGENT_ID.test(agent.agent_id) ? agent.agent_id : "";
diff --git a/server/live-session-wiring.test.ts b/server/live-session-wiring.test.ts
index 0895ede2f7..568a5427ba 100644
--- a/server/live-session-wiring.test.ts
+++ b/server/live-session-wiring.test.ts
@@ -18,7 +18,7 @@ function fakeFish({ goneAgents = [] as string[] } = {}) {
function wiring(fetchImpl: typeof fetch, env: NodeJS.ProcessEnv = {}) {
const saveFishAgent = vi.fn();
- const wired = liveSessionWiring({ bot: () => ({ name: "Rigel" }), history: () => [], cloudHome: false, othersOnLoopback: () => false, saveFishAgent, env, fetchImpl });
+ const wired = liveSessionWiring({ bot: () => ({ name: "Rigel" }), history: () => [], cloudHome: false, othersOnLoopback: () => false, saveFishAgent, productName: () => "Acme", env, fetchImpl });
return { ...wired, saveFishAgent };
}
@@ -32,6 +32,8 @@ describe("a Fish Audio call's session", () => {
const answer = await w.calls.createSession({ ...start, endpoint: fishLiveEndpoint("", {}) });
expect(routes(fetchImpl)).toEqual(["POST /tools", "POST /agents", "PATCH /agents/agent_new", "POST /agents/agent_new/publish", "POST /sessions"]);
expect(w.saveFishAgent).toHaveBeenCalledWith({ fishAgentId: "agent_new", fishAgentFor: fishKeyPrint("fish-key") });
+ const created = fetchImpl.mock.calls.find(([url, init]) => init!.method === "POST" && String(url).endsWith("/agents"))!;
+ expect(JSON.parse(String(created[1]!.body)).name).toBe("Acme Live calls");
expect(answer).toMatchObject({ sessionId: "sess_1", fish: { type: "fish", session: TOKEN } });
const relayToken = (answer as { fish: { relayToken: string } }).fish.relayToken;
expect(w.fishRelay("sess_1", relayToken)).not.toBeNull();
diff --git a/server/live-session-wiring.ts b/server/live-session-wiring.ts
index f7a205c010..d26c16be14 100644
--- a/server/live-session-wiring.ts
+++ b/server/live-session-wiring.ts
@@ -1,3 +1,4 @@
+import { productName } from "./brand.ts";
import type { LiveCallDeps } from "./live-call-controller.ts";
import { openLiveSocket } from "./live-call-controller.ts";
import { createLiveSession, liveAttachUrl, type LiveBot, type LiveEndpoint, type LiveHistoryMessage } from "./live-call.ts";
@@ -13,6 +14,8 @@ export interface LiveSessionWiringInput {
othersOnLoopback(): boolean;
/** Saves the Fish Audio agent the harness set up, with the account it belongs to. */
saveFishAgent(agent: Required<Pick<LiveConfig, "fishAgentId" | "fishAgentFor">>): void;
+ /** The name a person reads, which names the Fish agent on their account; the brand's own by default. */
+ productName?(): string;
env?: NodeJS.ProcessEnv;
fetchImpl?: typeof fetch;
}
@@ -28,7 +31,7 @@ export function liveSessionWiring(input: LiveSessionWiringInput): {
const fetchImpl = input.fetchImpl ?? fetch;
const setUpAgent = async (key: string, endpoint: LiveEndpoint): Promise<LiveEndpoint> => {
- const fishAgentId = await setUpFishAgent(key, endpoint, fetchImpl);
+ const fishAgentId = await setUpFishAgent(key, endpoint, (input.productName ?? productName)(), fetchImpl);
input.saveFishAgent({ fishAgentId, fishAgentFor: fishKeyPrint(key) });
return { ...endpoint, model: fishAgentId };
};