feat(config): add hot-reload config + listMode (human-list/agent-list)
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
export type WhisperGateConfig = {
|
||||
enabled?: boolean;
|
||||
discordOnly?: boolean;
|
||||
listMode?: "human-list" | "agent-list";
|
||||
humanList?: string[];
|
||||
agentList?: string[];
|
||||
// backward compatibility
|
||||
bypassUserIds?: string[];
|
||||
endSymbols?: string[];
|
||||
noReplyProvider: string;
|
||||
@@ -34,14 +38,33 @@ export function evaluateDecision(params: {
|
||||
return { shouldUseNoReply: false, reason: "non_discord" };
|
||||
}
|
||||
|
||||
if (params.senderId && (config.bypassUserIds || []).includes(params.senderId)) {
|
||||
return { shouldUseNoReply: false, reason: "bypass_sender" };
|
||||
}
|
||||
const mode = config.listMode || "human-list";
|
||||
const humanList = config.humanList || config.bypassUserIds || [];
|
||||
const agentList = config.agentList || [];
|
||||
|
||||
const senderId = params.senderId || "";
|
||||
const inHumanList = !!senderId && humanList.includes(senderId);
|
||||
const inAgentList = !!senderId && agentList.includes(senderId);
|
||||
|
||||
const lastChar = getLastChar(params.content || "");
|
||||
if (lastChar && (config.endSymbols || []).includes(lastChar)) {
|
||||
return { shouldUseNoReply: false, reason: `end_symbol:${lastChar}` };
|
||||
const hasEnd = !!lastChar && (config.endSymbols || []).includes(lastChar);
|
||||
|
||||
if (mode === "human-list") {
|
||||
if (inHumanList) {
|
||||
return { shouldUseNoReply: false, reason: "human_list_sender" };
|
||||
}
|
||||
if (hasEnd) {
|
||||
return { shouldUseNoReply: false, reason: `end_symbol:${lastChar}` };
|
||||
}
|
||||
return { shouldUseNoReply: true, reason: "rule_match_no_end_symbol" };
|
||||
}
|
||||
|
||||
return { shouldUseNoReply: true, reason: "rule_match_no_end_symbol" };
|
||||
// agent-list mode: listed senders require end symbol; others bypass requirement.
|
||||
if (!inAgentList) {
|
||||
return { shouldUseNoReply: false, reason: "non_agent_list_sender" };
|
||||
}
|
||||
if (hasEnd) {
|
||||
return { shouldUseNoReply: false, reason: `end_symbol:${lastChar}` };
|
||||
}
|
||||
return { shouldUseNoReply: true, reason: "agent_list_missing_end_symbol" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user