@@ -15,6 +15,9 @@ import {
1515 isNativeExecApprovalsSnapshot ,
1616 type ExecApprovalsAllowlistEntry ,
1717 type ExecApprovalsFile ,
18+ type ExecApprovalsResolvedDefaults ,
19+ type ExecAsk ,
20+ type ExecSecurity ,
1821 type NativeExecApprovalsSnapshot ,
1922} from "../../lib/nodes/index.ts" ;
2023import {
@@ -24,16 +27,6 @@ import {
2427} from "./view-shared.ts" ;
2528import type { DevicesProps } from "./view.types.ts" ;
2629
27- type ExecSecurity = "deny" | "allowlist" | "full" ;
28- type ExecAsk = "off" | "on-miss" | "always" ;
29-
30- type ExecApprovalsResolvedDefaults = {
31- security : ExecSecurity ;
32- ask : ExecAsk ;
33- askFallback : ExecSecurity ;
34- autoAllowSkills : boolean ;
35- } ;
36-
3730type ExecApprovalsAgentOption = {
3831 id : string ;
3932 name ?: string ;
@@ -96,13 +89,19 @@ function normalizeAsk(value?: string): ExecAsk {
9689
9790function resolveExecApprovalsDefaults (
9891 form : ExecApprovalsFile | null ,
92+ reported : ExecApprovalsResolvedDefaults | undefined ,
93+ includeWildcard : boolean ,
9994) : ExecApprovalsResolvedDefaults {
10095 const defaults = form ?. defaults ?? { } ;
96+ const wildcard = includeWildcard ? ( form ?. agents ?. [ "*" ] ?? { } ) : { } ;
10197 return {
102- security : normalizeSecurity ( defaults . security ) ,
103- ask : normalizeAsk ( defaults . ask ) ,
104- askFallback : normalizeSecurity ( defaults . askFallback ?? "deny" ) ,
105- autoAllowSkills : defaults . autoAllowSkills ?? false ,
98+ security : normalizeSecurity ( wildcard . security ?? defaults . security ?? reported ?. security ) ,
99+ ask : normalizeAsk ( wildcard . ask ?? defaults . ask ?? reported ?. ask ) ,
100+ askFallback : normalizeSecurity (
101+ wildcard . askFallback ?? defaults . askFallback ?? reported ?. askFallback ?? "deny" ,
102+ ) ,
103+ autoAllowSkills :
104+ wildcard . autoAllowSkills ?? defaults . autoAllowSkills ?? reported ?. autoAllowSkills ?? false ,
106105 } ;
107106}
108107
@@ -165,7 +164,6 @@ export function resolveExecApprovalsState(props: DevicesProps): ExecApprovalsSta
165164 const fileSnapshot = snapshot && ! isNativeExecApprovalsSnapshot ( snapshot ) ? snapshot : null ;
166165 const form = nativePolicy ? null : ( props . execApprovalsForm ?? fileSnapshot ?. file ?? null ) ;
167166 const ready = Boolean ( form || nativePolicy ) ;
168- const defaults = resolveExecApprovalsDefaults ( form ) ;
169167 const agents = resolveExecApprovalsAgents ( props . configForm , form ) ;
170168 const targetNodes = resolveExecApprovalsNodes ( props . nodes ) ;
171169 const target = props . execApprovalsTarget ;
@@ -175,6 +173,11 @@ export function resolveExecApprovalsState(props: DevicesProps): ExecApprovalsSta
175173 targetNodeId = null ;
176174 }
177175 const selectedScope = resolveExecApprovalsScope ( props . execApprovalsSelectedAgent , agents ) ;
176+ const defaults = resolveExecApprovalsDefaults (
177+ form ,
178+ fileSnapshot ?. resolvedDefaults ,
179+ selectedScope !== EXEC_APPROVALS_DEFAULT_SCOPE ,
180+ ) ;
178181 const selectedAgent =
179182 selectedScope !== EXEC_APPROVALS_DEFAULT_SCOPE
180183 ? ( ( ( form ?. agents ?? { } ) [ selectedScope ] as Record < string , unknown > | undefined ) ?? null )
0 commit comments