feat: add automation reactions event-trigger layer

This commit is contained in:
William Valentin
2026-02-18 10:26:40 -08:00
parent a71aa5992d
commit f341149ac7
10 changed files with 483 additions and 1 deletions
+17
View File
@@ -21,6 +21,7 @@ import type { CommandRegistry } from '../commands/index.js';
import type { ComponentRegistry } from '../intents/index.js';
import type { RoutingPolicy } from '../routing/index.js';
import { createClientFromConfig } from './models.js';
import { matchReactionPrompt } from '../automation/reactions.js';
import type { SkillRegistry } from '../skills/index.js';
import { auditLogger } from '../audit/index.js';
import { randomUUID } from 'crypto';
@@ -373,6 +374,7 @@ export function createMessageRouter(deps: {
const handler = async (msg: InboundMessage, reply: (response: OutboundMessage) => Promise<void>): Promise<void> => {
let incomingText = msg.text;
let matchedReactionName: string | undefined;
const talkMode = deps.config.audio?.talk_mode;
if (talkMode?.enabled && incomingText.trim().length > 0) {
const key = `${msg.channel}:${msg.senderId}`;
@@ -422,6 +424,20 @@ export function createMessageRouter(deps: {
}
}
const automationReactions = deps.config.automation?.reactions ?? [];
if (!msg.metadata?.isCommand && automationReactions.length > 0) {
const reactionMatch = matchReactionPrompt(automationReactions, {
channel: msg.channel,
senderId: msg.senderId,
text: incomingText,
metadata: msg.metadata,
});
if (reactionMatch) {
matchedReactionName = reactionMatch.name;
incomingText = reactionMatch.prompt;
}
}
let intentAgentOverride: string | undefined;
let intentSkillOverride: string | undefined;
if (!deps.config.intents?.enabled && deps.agentConfigRegistry?.get('research')) {
@@ -475,6 +491,7 @@ export function createMessageRouter(deps: {
const effectiveMetadata = {
...(msg.metadata ?? {}),
...(intentSkillOverride ? { skillOverride: intentSkillOverride } : {}),
...(matchedReactionName ? { automationReaction: matchedReactionName } : {}),
};
const agentConfigName = intentAgentOverride ?? deps.agentRouter?.resolve(msg.channel, msg.senderId);