Channels: add per-group tool policies

This commit is contained in:
Adam Holt
2026-01-24 15:35:05 +13:00
committed by Peter Steinberger
parent e51bf46abe
commit c07949a99c
47 changed files with 512 additions and 11 deletions

View File

@@ -1,11 +1,13 @@
import type { ChannelId } from "../channels/plugins/types.js";
import { normalizeAccountId } from "../routing/session-key.js";
import type { ClawdbotConfig } from "./config.js";
import type { GroupToolPolicyConfig } from "./types.tools.js";
export type GroupPolicyChannel = ChannelId;
export type ChannelGroupConfig = {
requireMention?: boolean;
tools?: GroupToolPolicyConfig;
};
export type ChannelGroupPolicy = {
@@ -91,3 +93,15 @@ export function resolveChannelGroupRequireMention(params: {
}
return true;
}
export function resolveChannelGroupToolsPolicy(params: {
cfg: ClawdbotConfig;
channel: GroupPolicyChannel;
groupId?: string | null;
accountId?: string | null;
}): GroupToolPolicyConfig | undefined {
const { groupConfig, defaultConfig } = resolveChannelGroupPolicy(params);
if (groupConfig?.tools) return groupConfig.tools;
if (defaultConfig?.tools) return defaultConfig.tools;
return undefined;
}