fix(exec): skip node approval prepare in yolo mode

This commit is contained in:
Peter Steinberger
2026-04-27 01:27:32 +01:00
parent 11e17793e1
commit acd1bd7d31
4 changed files with 409 additions and 215 deletions

View File

@@ -238,6 +238,13 @@ describe("executeNodeHostCommand", () => {
});
it("forwards prepared systemRunPlan on async node invoke after approval", async () => {
resolveExecHostApprovalContextMock.mockReturnValue({
approvals: { allowlist: [], file: { version: 1, agents: {} } },
hostSecurity: "full",
hostAsk: "always",
askFallback: "deny",
});
const result = await executeNodeHostCommand({
command: "bun ./script.ts",
workdir: "/tmp/work",
@@ -259,11 +266,11 @@ describe("executeNodeHostCommand", () => {
);
await vi.waitFor(() => {
expect(callGatewayToolMock).toHaveBeenCalledTimes(2);
expect(callGatewayToolMock).toHaveBeenCalledTimes(3);
});
expect(callGatewayToolMock).toHaveBeenNthCalledWith(
2,
3,
"node.invoke",
expect.anything(),
expect.objectContaining({
@@ -277,9 +284,7 @@ describe("executeNodeHostCommand", () => {
);
});
it("suppresses node completion events when notifyOnExit is disabled", async () => {
requiresExecApprovalMock.mockReturnValue(false);
it("skips approval prepare in full/off mode", async () => {
await executeNodeHostCommand({
command: "bun ./script.ts",
workdir: "/tmp/work",
@@ -294,17 +299,28 @@ describe("executeNodeHostCommand", () => {
notifyOnExit: false,
});
expect(callGatewayToolMock).toHaveBeenNthCalledWith(
2,
expect(callGatewayToolMock).toHaveBeenCalledTimes(1);
expect(callGatewayToolMock).toHaveBeenCalledWith(
"node.invoke",
expect.anything(),
expect.objectContaining({
command: "system.run",
params: expect.objectContaining({
command: ["bash", "-lc", "bun ./script.ts"],
rawCommand: "bun ./script.ts",
suppressNotifyOnExit: true,
}),
}),
);
expect(callGatewayToolMock).toHaveBeenCalledWith(
"node.invoke",
expect.anything(),
expect.objectContaining({
params: expect.not.objectContaining({
systemRunPlan: expect.anything(),
}),
}),
);
});
it("denies timed-out inline-eval requests instead of invoking the node", async () => {