fix(agent): auto-approve scoped investigation edits
This commit is contained in:
@@ -716,8 +716,9 @@ describe("streamPromptResponse", () => {
|
||||
});
|
||||
|
||||
|
||||
describe("background sandbox Shell approval", () => {
|
||||
it.each(["permission.asked", "permission.v2.asked"])("only auto-approves sandbox Shell for %s", async (type) => {
|
||||
describe("background sandbox permissions", () => {
|
||||
it.each([["permission.asked", true], ["permission.v2.asked", true],
|
||||
["permission.asked", false], ["permission.v2.asked", false]] as const)("limits session Shell/edit approval for %s background=%s", async (type, background) => {
|
||||
const replies: Array<Record<string, unknown>> = [];
|
||||
const runtime = {
|
||||
subscribeEvents: async () => createEventStream([
|
||||
@@ -739,11 +740,14 @@ describe("background sandbox Shell approval", () => {
|
||||
const events: Array<{ event: string; data: Record<string, unknown> }> = [];
|
||||
await streamPromptResponse({
|
||||
runtime, sessionId: "runtime-session-1", clientSessionId: "client-session-1",
|
||||
message: "后台调查", approvalMode: "request", backgroundSandboxShell: true,
|
||||
message: "后台调查", approvalMode: "request", backgroundSandboxPermissions: background,
|
||||
write: (event, data) => events.push({ event, data }),
|
||||
});
|
||||
expect(replies).toEqual([{ requestId: "shell", sessionId: "runtime-session-1", reply: "once" }]);
|
||||
expect(replies).toEqual(background ? [
|
||||
{ requestId: "shell", sessionId: "runtime-session-1", reply: "once" },
|
||||
{ requestId: "edit", sessionId: "runtime-session-1", reply: "once" },
|
||||
] : []);
|
||||
expect(events.filter(({ event }) => event === "permission_request")
|
||||
.map(({ data }) => data.permission)).toEqual(["edit", "mcp_fixture_write"]);
|
||||
.map(({ data }) => data.permission)).toEqual(background ? ["mcp_fixture_write"] : ["shell", "edit", "mcp_fixture_write"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user