mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:51:23 +00:00
refactor(tools): dedupe alsoAllow merge
This commit is contained in:
@@ -291,3 +291,13 @@ export function resolveToolProfilePolicy(profile?: string): ToolProfilePolicy |
|
||||
deny: resolved.deny ? [...resolved.deny] : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function mergeAlsoAllowPolicy<TPolicy extends { allow?: string[] }>(
|
||||
policy: TPolicy | undefined,
|
||||
alsoAllow?: string[],
|
||||
): TPolicy | undefined {
|
||||
if (!policy?.allow || !Array.isArray(alsoAllow) || alsoAllow.length === 0) {
|
||||
return policy;
|
||||
}
|
||||
return { ...policy, allow: Array.from(new Set([...policy.allow, ...alsoAllow])) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user