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
+21
View File
@@ -257,6 +257,25 @@ const mcpSchema = z.object({
const modelTierEnum = z.enum(['fast', 'default', 'complex', 'local']);
const reactionFilterSchema = z.object({
/** Case-insensitive substring match against inbound message text. */
contains: z.string().optional(),
/** Case-insensitive regex match against inbound message text. */
regex: z.string().optional(),
/** Dot-path metadata constraints (exact string comparison). */
metadata: z.record(z.string(), z.string()).optional(),
}).optional();
const automationReactionSchema = z.object({
name: z.string().min(1, 'Reaction name is required'),
enabled: z.boolean().default(true),
/** Source channels/events this rule applies to (e.g. gmail, webhook). */
on: z.array(z.string().min(1)).default([]),
filter: reactionFilterSchema,
/** Prompt template to run when matched. Supports {{text}}, {{channel}}, {{sender_id}}, {{metadata.*}}. */
run: z.string().min(1, 'Reaction run template is required'),
});
const cronJobSchema = z.object({
name: z.string().min(1, 'Cron job name is required'),
schedule: z.string().min(1, 'Cron schedule is required'),
@@ -422,6 +441,7 @@ const automationDeliveryModeSchema = z.enum(['shared_session', 'isolated_job', '
const automationSchema = z.object({
/** Session strategy for automation-triggered runs (cron/webhooks/gmail). */
delivery_mode: automationDeliveryModeSchema.default('shared_session'),
reactions: z.array(automationReactionSchema).default([]),
cron: z.array(cronJobSchema).default([]),
webhooks: z.array(webhookSchema).default([]),
gmail: gmailSchema,
@@ -999,6 +1019,7 @@ export type DailyBriefingConfig = z.infer<typeof dailyBriefingSchema>;
export type MinioSyncTaskConfig = z.infer<typeof minioSyncTaskSchema>;
export type MinioSyncAutomationConfig = z.infer<typeof minioSyncAutomationSchema>;
export type AutomationDeliveryMode = z.infer<typeof automationDeliveryModeSchema>;
export type AutomationReactionConfig = z.infer<typeof automationReactionSchema>;
export type PairingCodeConfig = z.infer<typeof pairingSchema>;
export type LogLevel = z.infer<typeof logLevelSchema>;
export type AuditConfig = z.infer<typeof auditSchema>;