fix: align exec default reporting with runtime

This commit is contained in:
Peter Steinberger
2026-04-08 04:37:06 +01:00
parent dce3abaef7
commit d9d9d357b4
3 changed files with 67 additions and 4 deletions

View File

@@ -1,8 +1,17 @@
import { describe, expect, it } from "vitest";
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { SessionEntry } from "../config/sessions.js";
import * as execApprovals from "../infra/exec-approvals.js";
import { resolveExecDefaults } from "./exec-defaults.js";
describe("resolveExecDefaults", () => {
beforeEach(() => {
vi.restoreAllMocks();
vi.spyOn(execApprovals, "loadExecApprovals").mockReturnValue({
version: 1,
agents: {},
});
});
it("does not advertise node routing when exec host is pinned to gateway", () => {
expect(
resolveExecDefaults({
@@ -55,4 +64,44 @@ describe("resolveExecDefaults", () => {
}).canRequestNode,
).toBe(true);
});
it("uses host approval defaults for gateway when exec policy is unset", () => {
expect(
resolveExecDefaults({
cfg: {
tools: {
exec: {
host: "auto",
},
},
},
sandboxAvailable: false,
}),
).toMatchObject({
host: "auto",
effectiveHost: "gateway",
security: "full",
ask: "off",
});
});
it("keeps sandbox deny by default when auto resolves to sandbox", () => {
expect(
resolveExecDefaults({
cfg: {
tools: {
exec: {
host: "auto",
},
},
},
sandboxAvailable: true,
}),
).toMatchObject({
host: "auto",
effectiveHost: "sandbox",
security: "deny",
ask: "off",
});
});
});