@@ -30,13 +30,16 @@ export type ToolPolicyPipelineStep = {
3030 policy : ToolPolicyLike | undefined ;
3131 label : string ;
3232 stripPluginOnlyAllowlist ?: boolean ;
33+ suppressUnavailableCoreToolWarning ?: boolean ;
3334} ;
3435
3536export function buildDefaultToolPolicyPipelineSteps ( params : {
3637 profilePolicy ?: ToolPolicyLike ;
3738 profile ?: string ;
39+ profileAlsoAllow ?: string [ ] ;
3840 providerProfilePolicy ?: ToolPolicyLike ;
3941 providerProfile ?: string ;
42+ providerProfileAlsoAllow ?: string [ ] ;
4043 globalPolicy ?: ToolPolicyLike ;
4144 globalProviderPolicy ?: ToolPolicyLike ;
4245 agentPolicy ?: ToolPolicyLike ;
@@ -52,13 +55,18 @@ export function buildDefaultToolPolicyPipelineSteps(params: {
5255 policy : params . profilePolicy ,
5356 label : profile ? `tools.profile (${ profile } )` : "tools.profile" ,
5457 stripPluginOnlyAllowlist : true ,
58+ suppressUnavailableCoreToolWarning :
59+ ! Array . isArray ( params . profileAlsoAllow ) || params . profileAlsoAllow . length === 0 ,
5560 } ,
5661 {
5762 policy : params . providerProfilePolicy ,
5863 label : providerProfile
5964 ? `tools.byProvider.profile (${ providerProfile } )`
6065 : "tools.byProvider.profile" ,
6166 stripPluginOnlyAllowlist : true ,
67+ suppressUnavailableCoreToolWarning :
68+ ! Array . isArray ( params . providerProfileAlsoAllow ) ||
69+ params . providerProfileAlsoAllow . length === 0 ,
6270 } ,
6371 { policy : params . globalPolicy , label : "tools.allow" , stripPluginOnlyAllowlist : true } ,
6472 {
@@ -113,14 +121,22 @@ export function applyToolPolicyPipeline(params: {
113121 isKnownCoreToolId ( entry ) ,
114122 ) ;
115123 const otherEntries = resolved . unknownAllowlist . filter ( ( entry ) => ! isKnownCoreToolId ( entry ) ) ;
116- const suffix = describeUnknownAllowlistSuffix ( {
117- strippedAllowlist : resolved . strippedAllowlist ,
118- hasGatedCoreEntries : gatedCoreEntries . length > 0 ,
119- hasOtherEntries : otherEntries . length > 0 ,
120- } ) ;
121- const warning = `tools: ${ step . label } allowlist contains unknown entries (${ entries } ). ${ suffix } ` ;
122- if ( rememberToolPolicyWarning ( warning ) ) {
123- params . warn ( warning ) ;
124+ if (
125+ ! shouldSuppressUnavailableCoreToolWarning ( {
126+ suppressUnavailableCoreToolWarning : step . suppressUnavailableCoreToolWarning === true ,
127+ hasGatedCoreEntries : gatedCoreEntries . length > 0 ,
128+ hasOtherEntries : otherEntries . length > 0 ,
129+ } )
130+ ) {
131+ const suffix = describeUnknownAllowlistSuffix ( {
132+ strippedAllowlist : resolved . strippedAllowlist ,
133+ hasGatedCoreEntries : gatedCoreEntries . length > 0 ,
134+ hasOtherEntries : otherEntries . length > 0 ,
135+ } ) ;
136+ const warning = `tools: ${ step . label } allowlist contains unknown entries (${ entries } ). ${ suffix } ` ;
137+ if ( rememberToolPolicyWarning ( warning ) ) {
138+ params . warn ( warning ) ;
139+ }
124140 }
125141 }
126142 policy = resolved . policy ;
@@ -132,6 +148,21 @@ export function applyToolPolicyPipeline(params: {
132148 return filtered ;
133149}
134150
151+ function shouldSuppressUnavailableCoreToolWarning ( params : {
152+ suppressUnavailableCoreToolWarning : boolean ;
153+ hasGatedCoreEntries : boolean ;
154+ hasOtherEntries : boolean ;
155+ } ) : boolean {
156+ if (
157+ ! params . suppressUnavailableCoreToolWarning ||
158+ ! params . hasGatedCoreEntries ||
159+ params . hasOtherEntries
160+ ) {
161+ return false ;
162+ }
163+ return true ;
164+ }
165+
135166function describeUnknownAllowlistSuffix ( params : {
136167 strippedAllowlist : boolean ;
137168 hasGatedCoreEntries : boolean ;
0 commit comments