Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
import { describe, expect, test } from "bun:test";
import {
defaultAgentId,
defaultAgentProfile,
PICKED_HARNESS_AGENT_ID,
} from "@/lib/agents/default-agent";
import type { AgentProfile } from "@/lib/agents/queries";
function agent(id: string, name = id): AgentProfile {
return {
avatarSeed: id,
builtIn: id === "general-assistant",
canManage: true,
endpoint: id === PICKED_HARNESS_AGENT_ID ? "http://127.0.0.1:4201" : null,
hasAuth: false,
hasCallbackToken: false,
isolated: false,
isolationActive: false,
isolationOffReason: null,
hidden: false,
pinned: false,
id,
mine: true,
name,
roleDescription: "Role",
systemOwned: false,
title: name,
visibility: "private",
};
}
describe("default agent selection", () => {
test("prefers the picked harness over the first visible agent", () => {
const chosen = defaultAgentProfile([
agent("general-assistant", "General Assistant"),
agent(PICKED_HARNESS_AGENT_ID, "LangGraph"),
]);
expect(chosen?.id).toBe(PICKED_HARNESS_AGENT_ID);
expect(
defaultAgentId([
agent("general-assistant"),
agent(PICKED_HARNESS_AGENT_ID),
]),
).toBe(PICKED_HARNESS_AGENT_ID);
});
test("keeps the route-specific fallback when there is no picked harness", () => {
const general = agent("general-assistant", "General Assistant");
const shared = agent("shared-agent", "Shared Agent");
expect(defaultAgentProfile([general, shared], shared)?.id).toBe(
"shared-agent",
);
});
test("falls back to the first agent when no picked harness or route fallback exists", () => {
expect(
defaultAgentId([agent("general-assistant"), agent("researcher")]),
).toBe("general-assistant");
});
test("returns undefined when the roster is still absent", () => {
expect(defaultAgentId(undefined)).toBeUndefined();
});
});