Menu
popagent
publicLatest change 2fb6f198c4c71ef37dffc8ac5dca8482068a7bfc - Add governed AkurAI Build maintenance by AkurAI Build
import { beforeAll, describe, expect, test } from "bun:test";
import { MAX_AGENT_INSTRUCTIONS_CHARACTERS, type AgentSettingsInput } from "./api-types";
import { AgentSettingsStore } from "./agent-settings";
const store = new AgentSettingsStore();
beforeAll(() => store.init());
describe("AgentSettingsStore", () => {
test("bootstraps database-backed roles and persists complete role edits", async () => {
const roles = await store.list();
expect(roles.map((settings) => settings.id)).toEqual(
expect.arrayContaining([
"orchistrator", "researcher", "implementer", "reviewer",
"build-maintainer", "build-release-manager", "community-steward",
]),
);
expect(roles.map((settings) => settings.id)).not.toContain("popagent");
expect(roles.find(({ id }) => id === "orchistrator")?.tools).toContain("useBrowserSecret");
expect(roles.find(({ id }) => id === "orchistrator")?.tools).toContain("bifrostNavigator");
expect(await store.storage.db.one<{ migrated: boolean }>(`
SELECT EXISTS (
SELECT 1 FROM popagent_data_migrations
WHERE id = '2026-08-15-akurai-build-agents-v1'
) AS migrated
`)).toEqual({ migrated: true });
expect(roles.find(({ id }) => id === "researcher")?.tools).toContain("bifrostNavigator");
for (const role of roles) {
expect(role.tools).not.toEqual(expect.arrayContaining([
"storeSecret",
"recallSecret",
"updateSecret",
]));
expect(role.description.length).toBeGreaterThan(0);
expect(role.instructions).toStartWith("# Role:");
expect(role.sourceUrls.length).toBeGreaterThan(0);
}
expect(roles.find(({ id }) => id === "orchistrator")?.sourceUrls)
.toEqual(expect.arrayContaining([expect.stringContaining("msitarzewski/agency-agents")]));
expect(roles.find(({ id }) => id === "orchistrator")?.model).toBeNull();
expect(roles.find(({ id }) => id === "researcher")?.model).toBe("cx/gpt-5.3-codex-spark");
expect(roles.find(({ id }) => id === "implementer")?.model).toBeNull();
expect(roles.find(({ id }) => id === "reviewer")?.model).toBe("cx/gpt-5.3-codex-spark");
expect(roles.find(({ id }) => id === "build-maintainer")?.model)
.toBe("titan/ornith-1.0-9b-mtp-q4_k_m");
expect(roles.find(({ id }) => id === "build-release-manager")?.model)
.toBe("cx/gpt-5.6-luna-max");
expect(roles.find(({ id }) => id === "community-steward")?.model)
.toBe("cx/gpt-5.3-codex-spark");
expect(roles.find(({ id }) => id === "build-maintainer")?.workspaceAccess).toBe("read-write");
expect(roles.find(({ id }) => id === "build-release-manager")?.workspaceAccess).toBe("none");
expect(roles.find(({ id }) => id === "community-steward")?.workspaceAccess).toBe("none");
const original = await store.get("researcher");
if (!original) throw new Error("researcher settings missing");
const input: AgentSettingsInput = {
workspaceAccess: original.workspaceAccess === "none" ? "read-only" : "none",
browserAccess: original.browserAccess === "none" ? "read-only" : "none",
delegationEnabled: !original.delegationEnabled,
model: original.model,
tools: original.tools.includes("getTime") ? ["webSearch"] : ["getTime"],
name: `Test Researcher ${crypto.randomUUID().slice(0, 8)}`,
description: "Delegated test research",
instructions: `# Role: Test Researcher\n\nTest instructions ${crypto.randomUUID()}`,
};
try {
expect(await store.update("researcher", input)).toMatchObject(input);
expect(await new AgentSettingsStore().get("researcher")).toMatchObject(input);
} finally {
await store.update("researcher", original);
}
});
test("keeps Build operations inside their persisted role allowlists", async () => {
const maintainer = await store.get("build-maintainer");
if (!maintainer) throw new Error("Build maintainer settings missing");
expect(maintainer.tools).toContain("akuraiRunQueue");
expect(maintainer.tools).not.toContain("akuraiRunPromote");
await expect(store.update("orchistrator", {
name: "Orchistrator",
description: "Supervisor",
instructions: "# Role: Supervisor",
workspaceAccess: "read-write",
browserAccess: "interactive",
delegationEnabled: false,
model: null,
tools: ["akuraiRunPromote"],
})).rejects.toThrow("Non-Build agents cannot use AkurAI Build tools");
await expect(store.update("build-maintainer", {
...maintainer,
tools: ["akuraiRunPromote"],
})).rejects.toThrow("Build agent tools exceed its role allowlist");
});
test("does not update an unknown agent", async () => {
expect(await store.update("missing", {
name: "Missing",
description: "Missing role",
instructions: "Missing instructions",
workspaceAccess: "read-only",
browserAccess: "none",
delegationEnabled: true,
model: null,
tools: ["webSearch"],
})).toBeUndefined();
});
test("rejects runtime instructions beyond the storage contract", async () => {
await expect(store.update("orchistrator", {
name: "Orchistrator",
description: "Supervisor",
instructions: "x".repeat(MAX_AGENT_INSTRUCTIONS_CHARACTERS + 1),
workspaceAccess: "read-write",
browserAccess: "interactive",
delegationEnabled: false,
model: null,
tools: ["webSearch"],
})).rejects.toThrow(`Agent instructions exceed ${MAX_AGENT_INSTRUCTIONS_CHARACTERS} characters`);
});
test("rejects empty runtime identity fields", async () => {
await expect(store.update("orchistrator", {
name: " ",
description: "Supervisor",
instructions: "Instructions",
workspaceAccess: "read-write",
browserAccess: "interactive",
delegationEnabled: false,
model: null,
tools: ["webSearch"],
})).rejects.toThrow("Agent name, description, and instructions must not be empty");
});
});