Every bot saw every builtin tool, and nothing outside the runtime's own declaration kept a run to the tools it was given: the executor ran any tool a runtime asked for, and the Pi runtime exposed all builtins whenever a caller passed an empty tool list, which the safety checker, the history summarizer and the team chat judge do on purpose. A specialist could not be kept to the tools of its lane, bots had no capability tags, and the main bot could only schedule routines for itself. - A bot can carry a builtin tool allowlist. Its runs see only the allowlisted builtins, and an empty allowlist means none. MAIN_ONLY_BUILTIN_TOOLS (empty until the user profile and delegation tools land) never reach other bots. applyTool refuses any tool the run did not expose, and an empty tool list now means no tools for the Pi runtime and its subagents. - A bot spawned by a restricted bot inherits the restriction and a duplicate keeps it, so neither path widens a bot's tools. - bots.create and bots.update accept tags, restrictBuiltinTools and allowedBuiltinTools; the router rejects names that are not builtin tools. bots.builtinTools lists the names a bot's allowlist can use. - Bot settings get a Tags field and a switch with a tool checklist under Advanced. - The main bot's schedule_create takes an optional bot: one of the user's bots in any space the user still belongs to. The routine belongs to that bot in its space and wakes in the main conversation when the bot is a member there, otherwise in its 1:1 thread. Routines record the bot that scheduled them (additive migration), so schedule_list and schedule_cancel also cover exactly the routines a bot scheduled for others. Cancelling by a name that matches several routines is refused. Tested with unit tests for the per-bot filter, the applyTool guard, the empty tool list, and on-behalf resolution, creation, listing and cancelling; with Postgres journeys for on-behalf routines waking across spaces and in the main conversation and for allowlist enforcement through the scripted runtime; and with a web E2E for the settings section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u
64 lines
2.9 KiB
TypeScript
64 lines
2.9 KiB
TypeScript
import { expect, type Page, test } from "@playwright/test";
|
|
import type { Bot } from "@rakazo/contracts";
|
|
import { activeBotId, captureScreenshot, completeOnboarding, rpc, signup } from "./helpers";
|
|
|
|
async function openCapabilities(page: Page) {
|
|
await page.getByTestId("bot-settings-trigger").click();
|
|
const settings = page.getByTestId("bot-settings");
|
|
await expect(settings).toBeVisible();
|
|
await settings.getByText("Advanced", { exact: true }).click();
|
|
const capabilities = settings.getByTestId("bot-capabilities");
|
|
await capabilities.scrollIntoViewIfNeeded();
|
|
return { settings, capabilities };
|
|
}
|
|
|
|
test("bot settings edit capability tags and the built-in tool allowlist", async ({
|
|
page,
|
|
}, testInfo) => {
|
|
const stamp = Date.now();
|
|
await signup(page, `capabilities-${stamp}@rakazo.test`, "password12", "Capabilities");
|
|
await completeOnboarding(page);
|
|
const botId = activeBotId(page);
|
|
|
|
const { settings, capabilities } = await openCapabilities(page);
|
|
await capabilities.getByLabel("Tags").fill("research, writing, research");
|
|
await expect(capabilities.getByRole("checkbox")).toHaveCount(0);
|
|
await capabilities.getByRole("switch", { name: "Limit built-in tools" }).click();
|
|
const tools = capabilities.getByRole("group", { name: "Limit built-in tools" });
|
|
await tools.getByRole("checkbox", { name: "web_fetch", exact: true }).click();
|
|
await tools.getByRole("checkbox", { name: "web_search", exact: true }).click();
|
|
await tools.getByRole("checkbox", { name: "remember", exact: true }).click();
|
|
await tools.getByRole("checkbox", { name: "remember", exact: true }).click();
|
|
await expect(tools.getByRole("checkbox", { name: "web_search", exact: true })).toBeChecked();
|
|
await expect(tools.getByRole("checkbox", { name: "shell", exact: true })).not.toBeChecked();
|
|
await captureScreenshot(page, testInfo, "bot-capabilities-settings");
|
|
|
|
const saved = page.waitForResponse(
|
|
(response) => response.url().includes("/rpc/bots/update") && response.ok(),
|
|
);
|
|
await settings.getByRole("button", { name: "Save", exact: true }).click();
|
|
await saved;
|
|
expect(await rpc<Bot>(page, "bots/get", { botId })).toMatchObject({
|
|
tags: ["research", "writing"],
|
|
restrictBuiltinTools: true,
|
|
allowedBuiltinTools: ["web_search", "web_fetch"],
|
|
});
|
|
|
|
await page.reload();
|
|
const reopened = await openCapabilities(page);
|
|
await expect(reopened.capabilities.getByLabel("Tags")).toHaveValue("research, writing");
|
|
await expect(
|
|
reopened.capabilities.getByRole("switch", { name: "Limit built-in tools" }),
|
|
).toBeChecked();
|
|
const reopenedTools = reopened.capabilities.getByRole("group", {
|
|
name: "Limit built-in tools",
|
|
});
|
|
await expect(
|
|
reopenedTools.getByRole("checkbox", { name: "web_fetch", exact: true }),
|
|
).toBeChecked();
|
|
await expect(
|
|
reopenedTools.getByRole("checkbox", { name: "remember", exact: true }),
|
|
).not.toBeChecked();
|
|
await captureScreenshot(page, testInfo, "bot-capabilities-persisted");
|
|
});
|