refactor(default-automation-rules): stringify typed config once at seed time
This commit is contained in:
1 parent
ca9b94b5a6
commit
4aaf0b8bfe
1 file changed
+25
-21
@@ -1,12 +1,16 @@
|
|||||||
export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
interface DefaultAutomationRule {
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
trigger: string;
|
trigger: string;
|
||||||
action: string;
|
action: string;
|
||||||
conditionsJson?: string;
|
/** Typed condition config. Stringified once at seed time. */
|
||||||
actionConfigJson?: string;
|
conditions?: Record<string, unknown>;
|
||||||
|
/** Typed action config. Stringified once at seed time. */
|
||||||
|
actionConfig?: Record<string, unknown>;
|
||||||
priority?: number;
|
priority?: number;
|
||||||
}> = [
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<DefaultAutomationRule> = [
|
||||||
{
|
{
|
||||||
name: "Auto-assign new tasks",
|
name: "Auto-assign new tasks",
|
||||||
description: "Automatically assign new unassigned tasks to the best-fit agent based on capabilities and workload.",
|
description: "Automatically assign new unassigned tasks to the best-fit agent based on capabilities and workload.",
|
||||||
@@ -19,7 +23,7 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
|||||||
description: "When a task is blocked, escalate to the assignee's manager.",
|
description: "When a task is blocked, escalate to the assignee's manager.",
|
||||||
trigger: "task_blocked",
|
trigger: "task_blocked",
|
||||||
action: "escalate_to_manager",
|
action: "escalate_to_manager",
|
||||||
actionConfigJson: JSON.stringify({ body: "A task assigned to your report is blocked and needs your attention." }),
|
actionConfig: { body: "A task assigned to your report is blocked and needs your attention." },
|
||||||
priority: 85,
|
priority: 85,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -27,7 +31,7 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
|||||||
description: "When a run completes successfully, escalate to the assignee's manager so they can review the completed work.",
|
description: "When a run completes successfully, escalate to the assignee's manager so they can review the completed work.",
|
||||||
trigger: "run_completed",
|
trigger: "run_completed",
|
||||||
action: "escalate_to_manager",
|
action: "escalate_to_manager",
|
||||||
actionConfigJson: JSON.stringify({ body: "A task run has completed successfully. The task has moved to review status. Please review and either approve (mark as done) or send back with feedback." }),
|
actionConfig: { body: "A task run has completed successfully. The task has moved to review status. Please review and either approve (mark as done) or send back with feedback." },
|
||||||
priority: 80,
|
priority: 80,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -35,7 +39,7 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
|||||||
description: "When a run fails after exhausting retries, attempt to reassign the task to another capable agent.",
|
description: "When a run fails after exhausting retries, attempt to reassign the task to another capable agent.",
|
||||||
trigger: "run_failed",
|
trigger: "run_failed",
|
||||||
action: "reassign_task",
|
action: "reassign_task",
|
||||||
conditionsJson: JSON.stringify({ afterRetryExhaustion: true }),
|
conditions: { afterRetryExhaustion: true },
|
||||||
priority: 75,
|
priority: 75,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -43,7 +47,7 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
|||||||
description: "Send an alert when an agent reaches 80% of their monthly budget.",
|
description: "Send an alert when an agent reaches 80% of their monthly budget.",
|
||||||
trigger: "budget_threshold",
|
trigger: "budget_threshold",
|
||||||
action: "send_message",
|
action: "send_message",
|
||||||
actionConfigJson: JSON.stringify({ subject: "Budget warning", body: "Agent is approaching budget limit (80% utilized).", priority: "urgent" }),
|
actionConfig: { subject: "Budget warning", body: "Agent is approaching budget limit (80% utilized).", priority: "urgent" },
|
||||||
priority: 70,
|
priority: 70,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -51,7 +55,7 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
|||||||
description: "When a run completes successfully, send a status update to the agent's department channel.",
|
description: "When a run completes successfully, send a status update to the agent's department channel.",
|
||||||
trigger: "run_completed",
|
trigger: "run_completed",
|
||||||
action: "send_message",
|
action: "send_message",
|
||||||
actionConfigJson: JSON.stringify({ channel: "department", subject: "Task completed", body: "A task has been completed successfully. Check the task details for more information.", priority: "low" }),
|
actionConfig: { channel: "department", subject: "Task completed", body: "A task has been completed successfully. Check the task details for more information.", priority: "low" },
|
||||||
priority: 40,
|
priority: 40,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -59,16 +63,16 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
|||||||
description: "When a new agent hire is approved, immediately wake the new agent to start onboarding.",
|
description: "When a new agent hire is approved, immediately wake the new agent to start onboarding.",
|
||||||
trigger: "hire_approved",
|
trigger: "hire_approved",
|
||||||
action: "trigger_heartbeat",
|
action: "trigger_heartbeat",
|
||||||
actionConfigJson: JSON.stringify({}),
|
actionConfig: {},
|
||||||
priority: 90,
|
priority: 90,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Auto-run assigned tasks",
|
name: "Auto-run assigned tasks",
|
||||||
description: "When a task transitions to 'todo' status, automatically wake the assigned agent to start working on it.",
|
description: "When a task transitions to 'todo' status, automatically wake the assigned agent to start working on it.",
|
||||||
trigger: "task_status_changed",
|
trigger: "task_status_changed",
|
||||||
conditionsJson: JSON.stringify({ status: "todo" }),
|
conditions: { status: "todo" },
|
||||||
action: "run_task",
|
action: "run_task",
|
||||||
actionConfigJson: JSON.stringify({}),
|
actionConfig: {},
|
||||||
priority: 65,
|
priority: 65,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -76,7 +80,7 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
|||||||
description: "When a sprint starts, notify the entire company.",
|
description: "When a sprint starts, notify the entire company.",
|
||||||
trigger: "sprint_started",
|
trigger: "sprint_started",
|
||||||
action: "send_message",
|
action: "send_message",
|
||||||
actionConfigJson: JSON.stringify({ channel: "company", subject: "Sprint started", body: "A new sprint has begun. Check your assigned tasks and start execution.", priority: "normal" }),
|
actionConfig: { channel: "company", subject: "Sprint started", body: "A new sprint has begun. Check your assigned tasks and start execution.", priority: "normal" },
|
||||||
priority: 50,
|
priority: 50,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -84,7 +88,7 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
|||||||
description: "When a sprint ends, schedule a retrospective meeting.",
|
description: "When a sprint ends, schedule a retrospective meeting.",
|
||||||
trigger: "sprint_ended",
|
trigger: "sprint_ended",
|
||||||
action: "schedule_meeting",
|
action: "schedule_meeting",
|
||||||
actionConfigJson: JSON.stringify({ meetingType: "retrospective", title: "Sprint Retrospective", durationMinutes: 45 }),
|
actionConfig: { meetingType: "retrospective", title: "Sprint Retrospective", durationMinutes: 45 },
|
||||||
priority: 55,
|
priority: 55,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -105,18 +109,18 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
|||||||
name: "Wake manager when task moves to review",
|
name: "Wake manager when task moves to review",
|
||||||
description: "When a task status changes to in_review, wake the assignee's manager to review the work.",
|
description: "When a task status changes to in_review, wake the assignee's manager to review the work.",
|
||||||
trigger: "task_status_changed",
|
trigger: "task_status_changed",
|
||||||
conditionsJson: JSON.stringify({ status: "in_review" }),
|
conditions: { status: "in_review" },
|
||||||
action: "escalate_to_manager",
|
action: "escalate_to_manager",
|
||||||
actionConfigJson: JSON.stringify({ body: "A task from your report has been submitted for review. Please review the work and either approve (mark as done) or send back with feedback." }),
|
actionConfig: { body: "A task from your report has been submitted for review. Please review the work and either approve (mark as done) or send back with feedback." },
|
||||||
priority: 82,
|
priority: 82,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Wake assigned agent on task feedback",
|
name: "Wake assigned agent on task feedback",
|
||||||
description: "When a reviewed task is sent back to in_progress with feedback, wake the assigned agent to address the feedback.",
|
description: "When a reviewed task is sent back to in_progress with feedback, wake the assigned agent to address the feedback.",
|
||||||
trigger: "task_status_changed",
|
trigger: "task_status_changed",
|
||||||
conditionsJson: JSON.stringify({ status: "in_progress", previousStatus: "in_review" }),
|
conditions: { status: "in_progress", previousStatus: "in_review" },
|
||||||
action: "trigger_heartbeat",
|
action: "trigger_heartbeat",
|
||||||
actionConfigJson: JSON.stringify({}),
|
actionConfig: {},
|
||||||
priority: 78,
|
priority: 78,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -124,7 +128,7 @@ export const DEFAULT_AUTOMATION_RULES: ReadonlyArray<{
|
|||||||
description: "When a new approval request is created and not auto-approved, escalate to the requesting agent's manager for review.",
|
description: "When a new approval request is created and not auto-approved, escalate to the requesting agent's manager for review.",
|
||||||
trigger: "approval_created",
|
trigger: "approval_created",
|
||||||
action: "escalate_to_manager",
|
action: "escalate_to_manager",
|
||||||
actionConfigJson: JSON.stringify({ body: "A new approval request needs your review. Please check the Approvals section." }),
|
actionConfig: { body: "A new approval request needs your review. Please check the Approvals section." },
|
||||||
priority: 88,
|
priority: 88,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -156,9 +160,9 @@ export function seedDefaultAutomationRules(
|
|||||||
name: rule.name,
|
name: rule.name,
|
||||||
description: rule.description,
|
description: rule.description,
|
||||||
trigger: rule.trigger,
|
trigger: rule.trigger,
|
||||||
conditionsJson: rule.conditionsJson ?? "{}",
|
conditionsJson: JSON.stringify(rule.conditions ?? {}),
|
||||||
action: rule.action,
|
action: rule.action,
|
||||||
actionConfigJson: rule.actionConfigJson ?? "{}",
|
actionConfigJson: JSON.stringify(rule.actionConfig ?? {}),
|
||||||
priority: rule.priority ?? 50,
|
priority: rule.priority ?? 50,
|
||||||
status: "active",
|
status: "active",
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user