feat: IRC — add first-class channel support

Adds IRC as a first-class channel with core config surfaces (schema/hints/dock), plugin auto-enable detection, routing/policy alignment, and docs/tests.

Co-authored-by: Vignesh <vigneshnatarajan92@gmail.com>
This commit is contained in:
Vignesh
2026-02-10 15:33:57 -08:00
committed by GitHub
parent 90f58333e9
commit fa906b26ad
50 changed files with 4907 additions and 791 deletions

View File

@@ -20,6 +20,29 @@ export type ChannelGroupPolicy = {
type ChannelGroups = Record<string, ChannelGroupConfig>;
function resolveChannelGroupConfig(
groups: ChannelGroups | undefined,
groupId: string,
caseInsensitive = false,
): ChannelGroupConfig | undefined {
if (!groups) {
return undefined;
}
const direct = groups[groupId];
if (direct) {
return direct;
}
if (!caseInsensitive) {
return undefined;
}
const target = groupId.toLowerCase();
const matchedKey = Object.keys(groups).find((key) => key !== "*" && key.toLowerCase() === target);
if (!matchedKey) {
return undefined;
}
return groups[matchedKey];
}
export type GroupToolPolicySender = {
senderId?: string | null;
senderName?: string | null;
@@ -125,18 +148,18 @@ export function resolveChannelGroupPolicy(params: {
channel: GroupPolicyChannel;
groupId?: string | null;
accountId?: string | null;
groupIdCaseInsensitive?: boolean;
}): ChannelGroupPolicy {
const { cfg, channel } = params;
const groups = resolveChannelGroups(cfg, channel, params.accountId);
const allowlistEnabled = Boolean(groups && Object.keys(groups).length > 0);
const normalizedId = params.groupId?.trim();
const groupConfig = normalizedId && groups ? groups[normalizedId] : undefined;
const groupConfig = normalizedId
? resolveChannelGroupConfig(groups, normalizedId, params.groupIdCaseInsensitive)
: undefined;
const defaultConfig = groups?.["*"];
const allowAll = allowlistEnabled && Boolean(groups && Object.hasOwn(groups, "*"));
const allowed =
!allowlistEnabled ||
allowAll ||
(normalizedId ? Boolean(groups && Object.hasOwn(groups, normalizedId)) : false);
const allowed = !allowlistEnabled || allowAll || Boolean(groupConfig);
return {
allowlistEnabled,
allowed,
@@ -150,6 +173,7 @@ export function resolveChannelGroupRequireMention(params: {
channel: GroupPolicyChannel;
groupId?: string | null;
accountId?: string | null;
groupIdCaseInsensitive?: boolean;
requireMentionOverride?: boolean;
overrideOrder?: "before-config" | "after-config";
}): boolean {
@@ -180,6 +204,7 @@ export function resolveChannelGroupToolsPolicy(
channel: GroupPolicyChannel;
groupId?: string | null;
accountId?: string | null;
groupIdCaseInsensitive?: boolean;
} & GroupToolPolicySender,
): GroupToolPolicyConfig | undefined {
const { groupConfig, defaultConfig } = resolveChannelGroupPolicy(params);