


















@@ -385,6 +385,20 @@ function readPreviewStringList(value: unknown): string[] | undefined {
385385 : undefined;
386386}
387387388+function collectUncoveredConfiguredToolSectionGrantEntries(
389+configuredEntries: ConfiguredToolSectionGrantEntry[],
390+profilePolicy: ToolPolicyConfig,
391+): ConfiguredToolSectionGrantEntry[] {
392+return configuredEntries
393+.map((entry) => ({
394+ ...entry,
395+grants: entry.grants.filter(
396+(toolName) => !isToolAllowedByPolicyName(toolName, profilePolicy),
397+),
398+}))
399+.filter((entry) => entry.grants.length > 0);
400+}
401+388402function formatProfileConfiguredSectionGrantAdvice(params: {
389403pathLabel: string;
390404grants: string[];
@@ -431,14 +445,10 @@ function collectProfileConfiguredToolSectionScopeWarnings(params: {
431445 ? tools.alsoAllow.filter((entry): entry is string => typeof entry === "string")
432446 : params.inheritedAlsoAllow;
433447const profilePolicy = mergeAlsoAllowPolicy(resolveToolProfilePolicy(profile), alsoAllow);
434-const uncoveredEntries = configuredEntries
435-.map((entry) => {
436-const grants = entry.grants.filter(
437-(toolName) => !isToolAllowedByPolicyName(toolName, profilePolicy),
438-);
439-return { grants, label: entry.label };
440-})
441-.filter((entry) => entry.grants.length > 0);
448+const uncoveredEntries = collectUncoveredConfiguredToolSectionGrantEntries(
449+configuredEntries,
450+profilePolicy,
451+);
442452if (uncoveredEntries.length === 0) {
443453return [];
444454}
@@ -486,14 +496,10 @@ function collectByProviderConfiguredToolSectionWarnings(params: {
486496const alsoAllow =
487497readPreviewStringList(policy.alsoAllow) ?? readPreviewStringList(inheritedPolicy?.alsoAllow);
488498const profilePolicy = mergeAlsoAllowPolicy(resolveToolProfilePolicy(profile), alsoAllow);
489-const uncoveredEntries = params.configuredEntries
490-.map((entry) => ({
491- ...entry,
492-grants: entry.grants.filter(
493-(toolName) => !isToolAllowedByPolicyName(toolName, profilePolicy),
494-),
495-}))
496-.filter((entry) => entry.grants.length > 0);
499+const uncoveredEntries = collectUncoveredConfiguredToolSectionGrantEntries(
500+params.configuredEntries,
501+profilePolicy,
502+);
497503if (uncoveredEntries.length === 0) {
498504return [];
499505}
@@ -626,14 +632,10 @@ function collectInheritedByProviderConfiguredToolSectionWarnings(params: {
626632readPreviewStringList(overridingPolicy?.alsoAllow) ??
627633readPreviewStringList(inheritedPolicy.alsoAllow);
628634const profilePolicy = mergeAlsoAllowPolicy(resolveToolProfilePolicy(profile), alsoAllow);
629-const uncoveredEntries = params.configuredEntries
630-.map((entry) => ({
631- ...entry,
632-grants: entry.grants.filter(
633-(toolName) => !isToolAllowedByPolicyName(toolName, profilePolicy),
634-),
635-}))
636-.filter((entry) => entry.grants.length > 0);
635+const uncoveredEntries = collectUncoveredConfiguredToolSectionGrantEntries(
636+params.configuredEntries,
637+profilePolicy,
638+);
637639if (uncoveredEntries.length === 0) {
638640return [];
639641}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。