Something went wrong. Try again.
Your thinking partner.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031import { describe, expect, test } from "bun:test";import { findPrimaryCoAgent, selectPrimaryCoAgent } from "./launch";
const agent = (id: string, name: string) => ({ id, name, model: "model",});
describe("launch agent selection", () => { test("selects Co by name regardless of capitalization or surrounding space", () => { expect(selectPrimaryCoAgent([agent("other", "Planner"), agent("co-1", " cO ")])).toEqual( agent("co-1", " cO "), ); });
test("does not substitute an unrelated agent when Co is absent", () => { expect(selectPrimaryCoAgent([agent("other", "Planner")])).toBeUndefined(); expect(selectPrimaryCoAgent([])).toBeUndefined(); });
test("walks agent pages until it finds Co", async () => { const pages = new Map([ [undefined, { agents: [agent("other", "Planner")], nextAfter: "page-2" }], ["page-2", { agents: [agent("co-1", "co")], nextAfter: undefined }], ]); const loadPage = async (after?: string) => pages.get(after)!; await expect(findPrimaryCoAgent(loadPage)).resolves.toEqual(agent("co-1", "co")); });});