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
82 lines
2.8 KiB
TypeScript
82 lines
2.8 KiB
TypeScript
import { Trans, useLingui } from "@lingui/react/macro";
|
|
import { Checkbox, Input, Switch } from "@rakazo/ui-web";
|
|
import { useId } from "react";
|
|
|
|
/** Capability tags and the builtin tool allowlist of one bot, edited inside its settings. */
|
|
export function BotCapabilitiesFields({
|
|
tags,
|
|
onTagsChange,
|
|
restrictBuiltinTools,
|
|
onRestrictBuiltinToolsChange,
|
|
allowedBuiltinTools,
|
|
onAllowedBuiltinToolsChange,
|
|
toolNames,
|
|
}: {
|
|
tags: string;
|
|
onTagsChange: (tags: string) => void;
|
|
restrictBuiltinTools: boolean;
|
|
onRestrictBuiltinToolsChange: (restrict: boolean) => void;
|
|
allowedBuiltinTools: string[];
|
|
onAllowedBuiltinToolsChange: (names: string[]) => void;
|
|
toolNames: string[];
|
|
}) {
|
|
const { t } = useLingui();
|
|
const ids = useId();
|
|
return (
|
|
<div data-testid="bot-capabilities">
|
|
<label htmlFor={`${ids}-tags`} className="mt-4 block text-ui-body text-muted-foreground">
|
|
<Trans>Tags</Trans>
|
|
<Input
|
|
id={`${ids}-tags`}
|
|
value={tags}
|
|
onChange={(event) => onTagsChange(event.target.value)}
|
|
placeholder={t`research, writing`}
|
|
className="mt-2"
|
|
/>
|
|
</label>
|
|
<label
|
|
htmlFor={`${ids}-restrict-tools`}
|
|
className="mt-5 flex cursor-pointer items-center gap-3 text-ui-body text-muted-foreground"
|
|
>
|
|
<Switch
|
|
id={`${ids}-restrict-tools`}
|
|
checked={restrictBuiltinTools}
|
|
onCheckedChange={onRestrictBuiltinToolsChange}
|
|
/>
|
|
<span id={`${ids}-restrict-tools-label`}>
|
|
<Trans>Limit built-in tools</Trans>
|
|
</span>
|
|
</label>
|
|
{restrictBuiltinTools ? (
|
|
<fieldset
|
|
aria-labelledby={`${ids}-restrict-tools-label`}
|
|
className="rk-scroll mt-2 max-h-56 min-w-0 overflow-y-auto rounded-xl border border-border p-1.5"
|
|
>
|
|
{toolNames.map((name) => (
|
|
<label
|
|
key={name}
|
|
htmlFor={`${ids}-tool-${name}`}
|
|
className="flex cursor-pointer items-center gap-2.5 rounded-lg px-2 py-1.5 font-mono text-ui-body-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground"
|
|
>
|
|
<Checkbox
|
|
id={`${ids}-tool-${name}`}
|
|
checked={allowedBuiltinTools.includes(name)}
|
|
onCheckedChange={(checked) =>
|
|
onAllowedBuiltinToolsChange(
|
|
checked
|
|
? toolNames.filter(
|
|
(tool) => tool === name || allowedBuiltinTools.includes(tool),
|
|
)
|
|
: allowedBuiltinTools.filter((allowed) => allowed !== name),
|
|
)
|
|
}
|
|
/>
|
|
{name}
|
|
</label>
|
|
))}
|
|
</fieldset>
|
|
) : null}
|
|
</div>
|
|
);
|
|
}
|