fix: default exec approvals to main agent (#1417) (thanks @czekaj)

This commit is contained in:
Peter Steinberger
2026-01-22 03:57:17 +00:00
parent 0c55b1e9ce
commit 2d583e877b
2 changed files with 7 additions and 5 deletions

View File

@@ -91,7 +91,10 @@ function normalizeAllowlistPattern(value: string | undefined): string | null {
return trimmed ? trimmed.toLowerCase() : null;
}
function mergeLegacyAgent(current: ExecApprovalsAgent, legacy: ExecApprovalsAgent): ExecApprovalsAgent {
function mergeLegacyAgent(
current: ExecApprovalsAgent,
legacy: ExecApprovalsAgent,
): ExecApprovalsAgent {
const allowlist: ExecAllowlistEntry[] = [];
const seen = new Set<string>();
const pushEntry = (entry: ExecAllowlistEntry) => {
@@ -120,13 +123,11 @@ function ensureDir(filePath: string) {
export function normalizeExecApprovals(file: ExecApprovalsFile): ExecApprovalsFile {
const socketPath = file.socket?.path?.trim();
const token = file.socket?.token?.trim();
const agents = { ...(file.agents ?? {}) };
const agents = { ...file.agents };
const legacyDefault = agents.default;
if (legacyDefault) {
const main = agents[DEFAULT_AGENT_ID];
agents[DEFAULT_AGENT_ID] = main
? mergeLegacyAgent(main, legacyDefault)
: legacyDefault;
agents[DEFAULT_AGENT_ID] = main ? mergeLegacyAgent(main, legacyDefault) : legacyDefault;
delete agents.default;
}
const normalized: ExecApprovalsFile = {