Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit a65dcfd

Browse files
committed
run setup discovery agent in plan mode
1 parent 9e370a3 commit a65dcfd

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { beforeEach, describe, expect, it, vi } from "vitest";
2+
3+
const startMutate = vi.fn(async (_input: Record<string, unknown>) => {});
4+
5+
vi.mock("@posthog/di/container", () => ({
6+
resolveService: () => ({ agent: { start: { mutate: startMutate } } }),
7+
}));
8+
9+
vi.mock("../../shell/analytics", () => ({
10+
captureException: vi.fn(),
11+
track: vi.fn(),
12+
}));
13+
14+
import { SetupRunServiceImpl } from "./setupRunServiceImpl";
15+
16+
describe("SetupRunServiceImpl.startAgent", () => {
17+
beforeEach(() => {
18+
startMutate.mockClear();
19+
});
20+
21+
it("starts the discovery agent in plan mode, never bypassPermissions", async () => {
22+
const service = new SetupRunServiceImpl();
23+
24+
await service.startAgent({
25+
taskId: "task-1",
26+
taskRunId: "run-1",
27+
repoPath: "/repo",
28+
apiHost: "https://us.posthog.com",
29+
projectId: 1,
30+
jsonSchema: {},
31+
});
32+
33+
expect(startMutate).toHaveBeenCalledTimes(1);
34+
expect(startMutate.mock.calls[0][0]).toMatchObject({
35+
permissionMode: "plan",
36+
disallowedTools: ["EnterPlanMode", "ExitPlanMode", "AskUserQuestion"],
37+
});
38+
});
39+
});

packages/ui/src/features/setup/setupRunServiceImpl.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ export class SetupRunServiceImpl implements ISetupRunService {
111111
repoPath: input.repoPath,
112112
apiHost: input.apiHost,
113113
projectId: input.projectId,
114-
permissionMode: "bypassPermissions",
114+
// Read-only scan: plan mode denies write/exec tools (VERIA-356).
115+
permissionMode: "plan",
116+
// Deny tools that would open a permission prompt no one answers on an
117+
// auto-launched run, which an injected repo could exploit to hang it.
118+
disallowedTools: ["EnterPlanMode", "ExitPlanMode", "AskUserQuestion"],
115119
jsonSchema: input.jsonSchema,
116120
});
117121
}

0 commit comments

Comments
 (0)