mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix(desktop): enforce shared agent access across devices (#6086)
## Summary - discover shared managed agents from authenticated relay directory records instead of treating channel membership as sufficient proof - publish and refresh access-policy changes immediately so running clients converge across machines without a restart or five-minute poll - route profile edits through the exact managed instance and stop/restart runtimes around access changes so unrelated edits cannot silently widen access - keep mention send-time revalidation and Block owner-only build enforcement fail closed - explain invalid custom provider/model configuration instead of leaving Save silently disabled ### Related issue Fixes #3204 ### Known residuals - a brand-new remote agent's first policy record can wait for the bounded directory poll when no authenticated directory coordinate exists yet; send-time mention revalidation remains fail closed - a failed remote-provider policy redeploy is recorded but cannot undeploy the older provider instance until the provider protocol gains the destructor tracked by #5570 ### Testing - full Desktop unit suite: 4,961 tests passed - focused profile editor Playwright workflow passed, including Customize access edits and prompt-only edits after tightening an instance - Desktop TypeScript, Biome formatting, file-size ratchet, Tauri checks, and pre-push suites passed - independently reviewed for authenticated directory trust, live subscription teardown, runtime revocation ordering, fail-open edit paths, and per-agent provider deployment serialization --------- Signed-off-by: Wes <wesbillman@users.noreply.github.com> Signed-off-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@buzz.block.builderlab.xyz> Co-authored-by: diegorumo <diegorumo@gmail.com> Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz> Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@buzz.block.builderlab.xyz>
This commit is contained in:
co-authored by
diegorumo
Carl
Brain
parent
1b7e5ac1be
commit
f716eef437
@@ -46,28 +46,30 @@ test("open agent access explains the available access before save", async ({
|
||||
name: "Hack Day Helper",
|
||||
status: "running",
|
||||
channelNames: ["general"],
|
||||
respondTo: "owner-only",
|
||||
respondTo: "anyone",
|
||||
},
|
||||
],
|
||||
});
|
||||
await page.goto("/");
|
||||
await page.getByTestId("channel-general").click();
|
||||
await page.getByTestId("channel-members-trigger").click();
|
||||
const accessBadge = page.getByTestId(
|
||||
`sidebar-managed-agent-respond-to-${agent.pubkey}`,
|
||||
);
|
||||
await expect(accessBadge).toBeVisible();
|
||||
await expect(accessBadge).toHaveText("Anyone");
|
||||
await openAgentAccessDialog(page, agent.pubkey);
|
||||
|
||||
const accessSelect = page.getByTestId("agent-respond-to-select");
|
||||
await expect(accessSelect).toHaveValue("owner-only");
|
||||
await expect(page.getByTestId("agent-access-warning")).toHaveCount(0);
|
||||
await expect(accessSelect).toHaveValue("anyone");
|
||||
const saveAccess = page.getByRole("button", { name: "Save access" });
|
||||
await expect(saveAccess).toBeVisible();
|
||||
|
||||
const commandsBeforeSave = await page.evaluate(
|
||||
() => window.__BUZZ_E2E_COMMAND_LOG__?.length ?? 0,
|
||||
);
|
||||
await accessSelect.selectOption("anyone");
|
||||
const warning = page.getByTestId("agent-access-warning");
|
||||
await expect(warning).toBeVisible();
|
||||
await expect(warning).toContainText(
|
||||
"Anyone can use this agent to access your computer, including files, accounts, and connected tools.",
|
||||
);
|
||||
await accessSelect.selectOption("owner-only");
|
||||
await expect(page.getByTestId("agent-access-warning")).toHaveCount(0);
|
||||
|
||||
await waitForAnimations(page);
|
||||
await page
|
||||
@@ -88,17 +90,19 @@ test("open agent access explains the available access before save", async ({
|
||||
(entry) =>
|
||||
entry.command === "update_managed_agent" &&
|
||||
(entry.payload as { input?: { respondTo?: string } })?.input
|
||||
?.respondTo === "anyone",
|
||||
?.respondTo === "owner-only",
|
||||
);
|
||||
}, commandsBeforeSave),
|
||||
)
|
||||
.toBe(true);
|
||||
await expect(accessBadge).toHaveText("Only me");
|
||||
|
||||
await openAgentAccessDialog(page, agent.pubkey);
|
||||
await expect(accessSelect).toHaveValue("anyone");
|
||||
await expect(accessSelect).toHaveValue("owner-only");
|
||||
// Selected people narrows the audience but not the access, so the warning
|
||||
// persists with its own audience phrase.
|
||||
await accessSelect.selectOption("allowlist");
|
||||
const warning = page.getByTestId("agent-access-warning");
|
||||
await expect(warning).toBeVisible();
|
||||
await expect(warning).toContainText(
|
||||
"Selected people can use this agent to access your computer, including files, accounts, and connected tools.",
|
||||
@@ -124,6 +128,134 @@ test("open agent access explains the available access before save", async ({
|
||||
await expect(warning).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("full agent editor tightens the exact sidebar agent instance", async ({
|
||||
page,
|
||||
}) => {
|
||||
const agent = TEST_IDENTITIES.tyler;
|
||||
const preferredSiblingPubkey = "d".repeat(64);
|
||||
const personaId = "shared-sidebar-agent";
|
||||
await installMockBridge(page, {
|
||||
acpRuntimesCatalog: [
|
||||
{
|
||||
availability: "available",
|
||||
command: "goose",
|
||||
default_args: [],
|
||||
id: "goose",
|
||||
install_hint: "",
|
||||
label: "Goose",
|
||||
mcp_command: "",
|
||||
},
|
||||
],
|
||||
globalAgentConfig: {
|
||||
env_vars: { ANTHROPIC_API_KEY: "sk-ant-test-key" },
|
||||
model: "claude-opus-4-5",
|
||||
preferred_runtime: "goose",
|
||||
provider: "anthropic",
|
||||
},
|
||||
managedAgents: [
|
||||
{
|
||||
pubkey: agent.pubkey,
|
||||
name: "Tyler Agent",
|
||||
personaId,
|
||||
status: "running",
|
||||
channelNames: ["general"],
|
||||
respondTo: "anyone",
|
||||
},
|
||||
{
|
||||
pubkey: preferredSiblingPubkey,
|
||||
name: "Preferred Sibling",
|
||||
personaId,
|
||||
status: "running",
|
||||
channelNames: [],
|
||||
respondTo: "anyone",
|
||||
},
|
||||
],
|
||||
personas: [
|
||||
{
|
||||
displayName: "Shared Sidebar Agent",
|
||||
id: personaId,
|
||||
isActive: true,
|
||||
respondTo: "anyone",
|
||||
runtime: "goose",
|
||||
systemPrompt: "Test exact instance editing.",
|
||||
},
|
||||
],
|
||||
});
|
||||
await page.goto("/");
|
||||
await page.getByTestId("channel-general").click();
|
||||
await page.getByTestId("channel-members-trigger").click();
|
||||
const accessBadge = page.getByTestId(
|
||||
`sidebar-managed-agent-respond-to-${agent.pubkey}`,
|
||||
);
|
||||
await expect(accessBadge).toHaveText("Anyone");
|
||||
|
||||
await page.getByTestId(`sidebar-member-${agent.pubkey}`).click();
|
||||
await expect(page.getByTestId("user-profile-panel")).toBeVisible();
|
||||
await page.getByTestId("user-profile-edit-agent").click();
|
||||
const dialog = page.getByRole("dialog", { name: "Edit agent" });
|
||||
await expect(dialog).toBeVisible();
|
||||
await dialog.getByRole("button", { name: "Advanced" }).click();
|
||||
await choosePersonaAccess(page, "Only me (default)");
|
||||
await dialog.getByRole("tab", { name: "Customize for this agent" }).click();
|
||||
const saveChanges = dialog.getByRole("button", { name: "Save changes" });
|
||||
await expect(saveChanges).toBeEnabled();
|
||||
await saveChanges.click();
|
||||
await expect(dialog).not.toBeVisible();
|
||||
|
||||
const updateCommand = await page.evaluate(
|
||||
(pubkey) =>
|
||||
window.__BUZZ_E2E_COMMAND_LOG__?.findLast(
|
||||
(entry) =>
|
||||
entry.command === "update_managed_agent" &&
|
||||
(entry.payload as { input?: { pubkey?: string } })?.input?.pubkey ===
|
||||
pubkey,
|
||||
),
|
||||
agent.pubkey,
|
||||
);
|
||||
expect(updateCommand?.payload).toMatchObject({
|
||||
input: { pubkey: agent.pubkey, respondTo: "owner-only" },
|
||||
});
|
||||
expect(updateCommand?.payload).not.toMatchObject({
|
||||
input: { pubkey: preferredSiblingPubkey },
|
||||
});
|
||||
|
||||
await page.getByTestId("channel-members-trigger").click();
|
||||
await expect(accessBadge).toHaveText("Only me");
|
||||
|
||||
// The definition still says "anyone" after the instance-only save above.
|
||||
// Reopening the same linked agent for an unrelated prompt edit must seed
|
||||
// access from the exact instance, or the submit silently widens it again.
|
||||
await page.getByTestId(`sidebar-member-${agent.pubkey}`).click();
|
||||
await page.getByTestId("user-profile-edit-agent").click();
|
||||
await expect(dialog).toBeVisible();
|
||||
await dialog.getByRole("button", { name: "Advanced" }).click();
|
||||
await expect(page.locator("#agent-respond-to")).toHaveText(
|
||||
"Only me (default)",
|
||||
);
|
||||
await page
|
||||
.locator("#persona-system-prompt")
|
||||
.fill("Test unrelated prompt editing after tightening access.");
|
||||
await dialog.getByRole("button", { name: "Save changes" }).click();
|
||||
await expect(dialog).not.toBeVisible();
|
||||
|
||||
const unrelatedEditCommand = await page.evaluate(
|
||||
(pubkey) =>
|
||||
window.__BUZZ_E2E_COMMAND_LOG__?.findLast(
|
||||
(entry) =>
|
||||
entry.command === "update_managed_agent" &&
|
||||
(entry.payload as { input?: { pubkey?: string } })?.input?.pubkey ===
|
||||
pubkey,
|
||||
),
|
||||
agent.pubkey,
|
||||
);
|
||||
expect(unrelatedEditCommand?.payload).toMatchObject({
|
||||
input: { pubkey: agent.pubkey },
|
||||
});
|
||||
expect(unrelatedEditCommand?.payload).not.toMatchObject({
|
||||
input: { respondTo: "anyone" },
|
||||
});
|
||||
});
|
||||
|
||||
test("a provider-backed agent's warning names the server, not this computer", async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
Reference in New Issue
Block a user