mirror of
https://github.com/block/buzz.git
synced 2026-10-27 04:30:52 +00:00
🤖 I’m Larry. ## Summary Managed-agent definitions can now choose which installed ACP transport will launch the agent. The choice sits beside **Agent harness** while creating or editing an agent, so it is made before first deployment and remains visible afterward. Buzz discovers executable commands named `buzz-*-acp`, keeps **Buzz ACP (default)** as the safe default, and preserves existing custom command values. Discovery and launch share the same resolver, so a command offered in the picker is the command Buzz will execute. ## UX walkthrough ### 1. The ACP command picker appears while creating the agent The default is explicit, and the helper text explains that this selection controls deployment.  ### 2. Installed wrapper commands are offered by name Here Buzz has discovered `buzz-janet-acp` alongside the stock transport.  ### 3. The wrapper is selected before deployment  ### 4. The deployed profile reports the effective command  ### 5. Editing the deployed agent reopens its definition with the choice preserved  ## Details - Definitions carry the selected ACP command through relay publication, snapshots, imports, team adoption, deployment, and later edits. - Existing definitions without this field continue to use `buzz-acp`. - Unknown persisted commands remain visible but unavailable rather than being silently replaced. - Discovery is read-only and never executes candidates. It filters non-files and non-executables, supports Windows `.exe`, `.cmd`, and `.bat` shims, deduplicates aliases, and returns a stable sorted list. - Command names remain portable; Buzz does not persist machine-specific absolute paths. --------- Signed-off-by: Logan Johnson <loganj@squareup.com> Signed-off-by: Larry <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz> Signed-off-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz> Co-authored-by: Larry <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@nostr> Co-authored-by: Larry <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz> Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
529 lines
17 KiB
TypeScript
529 lines
17 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
import { installMockBridge, TEST_IDENTITIES } from "../helpers/bridge";
|
|
|
|
const BAKED_DEFAULTS = [
|
|
{ key: "BUZZ_AGENT_PROVIDER", value: "anthropic", masked: false },
|
|
{
|
|
key: "BUZZ_AGENT_MODEL",
|
|
value: "claude-opus-4-8",
|
|
masked: false,
|
|
},
|
|
{ key: "BUZZ_AGENT_THINKING_EFFORT", value: "high", masked: false },
|
|
{ key: "ANTHROPIC_API_KEY", value: "sk-ant-baked-test", masked: true },
|
|
];
|
|
|
|
// Edit-agent dialog coverage (Phase 1B.3b-pre). Written against TODAY'S
|
|
// EditAgentDialog, before the B3b re-host, so the re-host is guarded by a
|
|
// pre-existing spec rather than one written alongside it.
|
|
//
|
|
// Mock-boundary caveat: the e2eBridge `update_managed_agent` handler echoes
|
|
// name/model/systemPrompt/envVars/respondTo/respondToAllowlist into the
|
|
// mock store — it does NOT
|
|
// model the diff-based partial-update wire semantics (change-detected-or-omit,
|
|
// tri-state provider, harnessOverride derivation), and it ignores
|
|
// agentCommand/harnessOverride entirely. This spec therefore pins UI behavior
|
|
// (open → edit → save → persisted in UI), not wire semantics. The inherit
|
|
// toggle is not reachable here at all (see the routing pin below) — its
|
|
// behavior is covered by B3b's component-level pinning test (inherit-toggle
|
|
// → gate → submit); wire semantics stay component-test territory
|
|
// (personaRuntimeModel.test.mjs).
|
|
|
|
// Tyler's pubkey maps to gooseSurface in the mock bridge (runtimeId "goose"),
|
|
// which supports LLM provider selection — same seed the readiness-screenshot
|
|
// spec uses for its edit-dialog shot.
|
|
const AGENT_PUBKEY = TEST_IDENTITIES.tyler.pubkey;
|
|
const AGENT_NAME = "Tyler Agent";
|
|
const PERSONA_ID = "persona-edit-e2e";
|
|
|
|
/**
|
|
* Open the Edit Agent dialog for the seeded managed agent via the profile
|
|
* panel (agents view → agent card → Edit quick action) — EditAgentDialog's
|
|
* only mount path.
|
|
*/
|
|
async function openEditDialog(page: import("@playwright/test").Page) {
|
|
await page.goto("/");
|
|
await page.getByTestId("open-agents-view").click();
|
|
|
|
const agentButton = page.getByRole("button", {
|
|
name: `${AGENT_NAME} agent profile`,
|
|
});
|
|
await expect(agentButton).toBeVisible({ timeout: 10_000 });
|
|
await agentButton.click();
|
|
|
|
await expect(page.getByTestId("user-profile-panel")).toBeVisible({
|
|
timeout: 10_000,
|
|
});
|
|
await page.getByTestId("user-profile-edit-agent").click();
|
|
|
|
await expect(page.getByTestId("edit-agent-dialog")).toBeVisible({
|
|
timeout: 10_000,
|
|
});
|
|
// Provider field visible = runtime catalog loaded and form settled.
|
|
await expect(page.locator("#edit-agent-llm-provider")).toBeVisible({
|
|
timeout: 10_000,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Pick an option from a PersonaDropdownField (menu-based, not a native
|
|
* <select> — Create's fields are selects, Edit's are not).
|
|
*/
|
|
async function pickDropdownOption(
|
|
page: import("@playwright/test").Page,
|
|
triggerId: string,
|
|
optionName: string | RegExp,
|
|
) {
|
|
await page.locator(`#${triggerId}`).click();
|
|
await page.getByRole("menuitemradio", { name: optionName }).click();
|
|
}
|
|
|
|
test.describe("agent definition dialog", () => {
|
|
test("owner-only-access build shows disabled agent access with an explanation", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page, {
|
|
ownerOnlyAccessBuild: true,
|
|
bakedBuildEnv: BAKED_DEFAULTS,
|
|
});
|
|
await page.goto("/");
|
|
await page.getByTestId("open-agents-view").click();
|
|
await page.getByTestId("new-agent-card").click();
|
|
|
|
const dialog = page.getByRole("dialog");
|
|
await dialog.getByRole("button", { name: "Advanced", exact: true }).click();
|
|
|
|
await expect(dialog.getByTestId("agent-respond-to")).toBeVisible();
|
|
await expect(dialog.locator("#agent-respond-to")).toBeDisabled();
|
|
await expect(dialog.locator("#agent-respond-to")).toContainText(
|
|
"Only me (default)",
|
|
);
|
|
await expect(
|
|
dialog.getByTestId("agent-respond-to-disabled-reason"),
|
|
).toHaveText("This build disallows changing this setting.");
|
|
});
|
|
});
|
|
|
|
test.describe("edit agent dialog", () => {
|
|
test("owner-only-access build shows a disabled owner-only access control with an explanation", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page, {
|
|
ownerOnlyAccessBuild: true,
|
|
bakedBuildEnv: BAKED_DEFAULTS,
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
respondTo: "anyone",
|
|
},
|
|
],
|
|
});
|
|
|
|
await openEditDialog(page);
|
|
|
|
const accessControl = page.getByTestId("agent-respond-to");
|
|
await expect(accessControl).toBeVisible();
|
|
await expect(page.locator("#agent-respond-to")).toBeDisabled();
|
|
await expect(page.locator("#agent-respond-to")).toContainText(
|
|
"Only me (default)",
|
|
);
|
|
await expect(
|
|
page.getByTestId("agent-respond-to-disabled-reason"),
|
|
).toHaveText("This build disallows changing this setting.");
|
|
});
|
|
|
|
test("OSS build keeps the managed-agent access control", async ({ page }) => {
|
|
await installMockBridge(page, {
|
|
bakedBuildEnv: BAKED_DEFAULTS,
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
},
|
|
],
|
|
});
|
|
|
|
await openEditDialog(page);
|
|
|
|
await expect(page.getByTestId("agent-respond-to")).toBeVisible();
|
|
});
|
|
|
|
test("edits the agent name and persists it across a dialog reopen", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page, {
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
},
|
|
],
|
|
});
|
|
|
|
await openEditDialog(page);
|
|
|
|
const nameInput = page.locator("#edit-agent-name");
|
|
await expect(nameInput).toHaveValue(AGENT_NAME);
|
|
await nameInput.fill("Tyler Agent Renamed");
|
|
|
|
await page.getByTestId("edit-agent-dialog-submit").click();
|
|
await expect(page.getByTestId("edit-agent-dialog")).not.toBeVisible();
|
|
|
|
// Reopen: the dialog re-reads the managed-agents store, proving the save
|
|
// survived the dialog lifecycle rather than living in local state. (The
|
|
// panel HEADER is not asserted — it renders the relay profile name, which
|
|
// the update path does not touch.)
|
|
await page.getByTestId("user-profile-edit-agent").click();
|
|
await expect(page.locator("#edit-agent-name")).toHaveValue(
|
|
"Tyler Agent Renamed",
|
|
{ timeout: 10_000 },
|
|
);
|
|
});
|
|
|
|
test("changes the model via custom entry and persists it", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page, {
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
},
|
|
],
|
|
});
|
|
|
|
await openEditDialog(page);
|
|
|
|
// Pick a provider so model discovery has a scope, then set a custom model.
|
|
await pickDropdownOption(page, "edit-agent-llm-provider", "Anthropic");
|
|
await pickDropdownOption(page, "edit-agent-model", "Custom model...");
|
|
await page.locator("#edit-agent-custom-model").fill("claude-opus-4-5");
|
|
// Anthropic requires a credential before save unlocks.
|
|
await page.getByLabel("Anthropic API Key").fill("sk-test-edit-agent-e2e");
|
|
|
|
const submit = page.getByTestId("edit-agent-dialog-submit");
|
|
await expect(submit).toBeEnabled({ timeout: 10_000 });
|
|
await submit.click();
|
|
await expect(page.getByTestId("edit-agent-dialog")).not.toBeVisible();
|
|
|
|
await page.getByTestId("user-profile-edit-agent").click();
|
|
await expect(page.getByTestId("edit-agent-dialog")).toBeVisible({
|
|
timeout: 10_000,
|
|
});
|
|
// Custom model round-trips: the reopened dialog shows it in the custom
|
|
// input (the discovered-model lists don't contain it).
|
|
await expect(page.locator("#edit-agent-custom-model")).toHaveValue(
|
|
"claude-opus-4-5",
|
|
{ timeout: 10_000 },
|
|
);
|
|
});
|
|
|
|
test("tells colliding Databricks model names apart and persists the chosen id", async ({
|
|
page,
|
|
}) => {
|
|
const goosePathId = "data_workflow_tools.goose.gpt-6-astra";
|
|
const systemAiId = "system.ai.gpt-6-astra";
|
|
await installMockBridge(page, {
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
envVars: { DATABRICKS_HOST: "https://databricks.example.test" },
|
|
},
|
|
],
|
|
// The agent inherits Databricks from the global defaults; the mock's
|
|
// update_managed_agent does not echo a per-agent provider.
|
|
globalAgentConfig: {
|
|
preferred_runtime: "goose",
|
|
provider: "databricks_v2",
|
|
model: null,
|
|
env_vars: {},
|
|
},
|
|
discoverAgentModels: {
|
|
models: [
|
|
{ id: goosePathId, name: goosePathId },
|
|
{ id: systemAiId, name: systemAiId },
|
|
],
|
|
supportsSwitching: true,
|
|
selectedModel: null,
|
|
},
|
|
});
|
|
|
|
await openEditDialog(page);
|
|
|
|
await page.locator("#edit-agent-model").click();
|
|
await expect(
|
|
page.getByRole("menuitemradio", {
|
|
name: "GPT-6 Astra (data_workflow_tools.goose)",
|
|
}),
|
|
).toBeVisible();
|
|
await page
|
|
.getByRole("menuitemradio", { name: "GPT-6 Astra (system.ai)" })
|
|
.click();
|
|
await expect(page.locator("#edit-agent-model")).toHaveText(
|
|
"GPT-6 Astra (system.ai)",
|
|
);
|
|
|
|
const submit = page.getByTestId("edit-agent-dialog-submit");
|
|
await expect(submit).toBeEnabled({ timeout: 10_000 });
|
|
await submit.click();
|
|
await expect(page.getByTestId("edit-agent-dialog")).not.toBeVisible();
|
|
|
|
const persistedModel = () =>
|
|
page.evaluate(async (pubkey) => {
|
|
const agents = (await (
|
|
window as typeof window & {
|
|
__BUZZ_E2E_INVOKE_MOCK_COMMAND__?: (
|
|
command: string,
|
|
payload: unknown,
|
|
) => Promise<unknown>;
|
|
}
|
|
).__BUZZ_E2E_INVOKE_MOCK_COMMAND__?.("list_managed_agents", null)) as
|
|
| Array<{ pubkey: string; model: string | null }>
|
|
| undefined;
|
|
return agents?.find((agent) => agent.pubkey === pubkey)?.model;
|
|
}, AGENT_PUBKEY);
|
|
await expect.poll(persistedModel).toBe(systemAiId);
|
|
|
|
await page.getByTestId("user-profile-edit-agent").click();
|
|
await expect(page.locator("#edit-agent-model")).toHaveText(
|
|
"GPT-6 Astra (system.ai)",
|
|
{ timeout: 10_000 },
|
|
);
|
|
});
|
|
|
|
test("keeps the custom command visible without opening Advanced", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page, {
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
},
|
|
],
|
|
});
|
|
|
|
await openEditDialog(page);
|
|
|
|
const advanced = page.getByRole("button", {
|
|
name: "Advanced",
|
|
exact: true,
|
|
});
|
|
await expect(advanced).toHaveAttribute("aria-expanded", "false");
|
|
await pickDropdownOption(page, "edit-agent-runtime", "Custom command");
|
|
await expect(page.locator("#edit-agent-command")).toBeVisible();
|
|
await expect(advanced).toHaveAttribute("aria-expanded", "false");
|
|
});
|
|
|
|
test("marks a missing advanced credential without opening Advanced", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page, {
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
},
|
|
],
|
|
});
|
|
|
|
await openEditDialog(page);
|
|
|
|
const advanced = page.getByRole("button", {
|
|
name: "Advanced",
|
|
exact: true,
|
|
});
|
|
await expect(advanced).toHaveAttribute("aria-expanded", "false");
|
|
await pickDropdownOption(page, "edit-agent-llm-provider", "Databricks v2");
|
|
await expect(advanced).toHaveAttribute("aria-expanded", "false");
|
|
await expect(
|
|
page.getByTestId("edit-agent-advanced-required-badge"),
|
|
).toHaveText("Required");
|
|
await expect(page.getByTestId("edit-agent-dialog-submit")).toBeDisabled();
|
|
|
|
await advanced.click();
|
|
await expect(page.getByLabel("Value for DATABRICKS_HOST")).toBeVisible();
|
|
});
|
|
|
|
test("shows baked defaults in the instance editor", async ({ page }) => {
|
|
await installMockBridge(page, {
|
|
bakedBuildEnv: BAKED_DEFAULTS,
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
},
|
|
],
|
|
});
|
|
|
|
await openEditDialog(page);
|
|
|
|
await expect(page.locator("#edit-agent-llm-provider")).toHaveText(
|
|
"Anthropic (inherited from build)",
|
|
);
|
|
await expect(page.locator("#edit-agent-model")).toHaveText(
|
|
"Inherit build default (claude-opus-4-8)",
|
|
);
|
|
const defaults = page.getByTestId("agent-ai-defaults-notice");
|
|
await expect(
|
|
defaults.getByText("Anthropic", { exact: true }),
|
|
).toBeVisible();
|
|
await expect(
|
|
defaults.getByText("claude-opus-4-8", { exact: true }),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("explicit global defaults override baked labels in the instance editor", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page, {
|
|
bakedBuildEnv: BAKED_DEFAULTS,
|
|
globalAgentConfig: {
|
|
provider: "anthropic",
|
|
model: "claude-opus-4-5",
|
|
env_vars: { BUZZ_AGENT_THINKING_EFFORT: "low" },
|
|
},
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
},
|
|
],
|
|
});
|
|
|
|
await openEditDialog(page);
|
|
|
|
await expect(page.locator("#edit-agent-llm-provider")).toHaveText(
|
|
"Use agent defaults (anthropic)",
|
|
);
|
|
await expect(page.locator("#edit-agent-model")).toHaveText(
|
|
"Use agent defaults (claude-opus-4-5)",
|
|
);
|
|
const defaults = page.getByTestId("agent-ai-defaults-notice");
|
|
await expect(
|
|
defaults.getByText("Anthropic", { exact: true }),
|
|
).toBeVisible();
|
|
await expect(
|
|
defaults.getByText("claude-opus-4-5", { exact: true }),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("discovers, selects, and persists an ACP command from the agent profile", async ({
|
|
page,
|
|
}) => {
|
|
await installMockBridge(page, {
|
|
acpCommands: [
|
|
{
|
|
command: "buzz-janet-acp",
|
|
binaryPath: "/usr/local/bin/buzz-janet-acp",
|
|
},
|
|
],
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
},
|
|
],
|
|
});
|
|
|
|
await openEditDialog(page);
|
|
await page.getByRole("button", { name: "Advanced", exact: true }).click();
|
|
|
|
const acpPicker = page.locator("#edit-agent-acp-command");
|
|
await expect(acpPicker).toBeVisible();
|
|
await acpPicker.click();
|
|
await expect(
|
|
page.getByRole("menuitemradio", { name: "buzz-janet-acp" }),
|
|
).toBeVisible();
|
|
await page.getByRole("menuitemradio", { name: "buzz-janet-acp" }).click();
|
|
await expect(acpPicker).toContainText("buzz-janet-acp");
|
|
await page.screenshot({
|
|
path: test.info().outputPath("acp-command-selected.png"),
|
|
fullPage: true,
|
|
});
|
|
|
|
await page.getByTestId("edit-agent-dialog-submit").click();
|
|
await expect(page.getByTestId("edit-agent-dialog")).not.toBeVisible();
|
|
|
|
await page.getByTestId("user-profile-edit-agent").click();
|
|
await page.getByRole("button", { name: "Advanced", exact: true }).click();
|
|
await expect(page.locator("#edit-agent-acp-command")).toContainText(
|
|
"buzz-janet-acp",
|
|
);
|
|
await page.screenshot({
|
|
path: test.info().outputPath("acp-command-persisted.png"),
|
|
fullPage: true,
|
|
});
|
|
});
|
|
|
|
test("profile Edit opens the persona editor for a persona-linked agent", async ({
|
|
page,
|
|
}) => {
|
|
// A persona-linked agent inherits ACP transport from its definition, so the
|
|
// profile Edit action must open the persona editor.
|
|
await installMockBridge(page, {
|
|
managedAgents: [
|
|
{
|
|
pubkey: AGENT_PUBKEY,
|
|
name: AGENT_NAME,
|
|
personaId: PERSONA_ID,
|
|
status: "stopped",
|
|
channelNames: ["agents"],
|
|
},
|
|
],
|
|
personas: [
|
|
{
|
|
id: PERSONA_ID,
|
|
displayName: "Edit E2E Persona",
|
|
systemPrompt: "You are the edit-agent e2e persona.",
|
|
},
|
|
],
|
|
});
|
|
|
|
await page.goto("/");
|
|
await page.getByTestId("open-agents-view").click();
|
|
|
|
// Persona-linked agents render grouped under the persona's card name.
|
|
const agentButton = page.getByRole("button", {
|
|
name: "Edit E2E Persona agent profile",
|
|
});
|
|
await expect(agentButton).toBeVisible({ timeout: 10_000 });
|
|
await agentButton.click();
|
|
|
|
await expect(page.getByTestId("user-profile-panel")).toBeVisible({
|
|
timeout: 10_000,
|
|
});
|
|
await page.getByTestId("user-profile-edit-agent").click();
|
|
|
|
// Persona editor opens with the definition-owned ACP command field.
|
|
await expect(page.getByTestId("persona-dialog")).toBeVisible({
|
|
timeout: 10_000,
|
|
});
|
|
await expect(page.getByTestId("edit-agent-dialog")).not.toBeVisible();
|
|
await page.getByRole("tab", { name: "Customize for this agent" }).click();
|
|
await expect(page.locator("#persona-acp-command")).toBeVisible();
|
|
});
|
|
});
|