refactor(heartbeat): centralize [Heartbeat] prefix as a shared constant
P2-36: Multiple subsystems were string-coupled via the magic '[Heartbeat]' prefix. Introduce src/main/orchestration/heartbeat-task.ts as the single source of truth and replace scattered literals in heartbeat dispatch, automation actions, and run completion. P3-52: Collapse 5-deep ternary in automation-actions' wake-trigger selection into lookup helpers (deriveHeartbeatWakeTrigger, deriveEscalationWakeTrigger).
This commit is contained in:
1 parent
4838750009
commit
bb397dff02
4 files changed
+48
-26
No files matched your search
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Heartbeat task title conventions.
|
||||
*
|
||||
* Heartbeat tasks are synthesized by the orchestrator when an agent wakes with
|
||||
* no actionable work; they carry the `[Heartbeat]` title prefix so the rest of
|
||||
* the system can detect them without a dedicated `kind` column.
|
||||
*
|
||||
* Centralizing the prefix here prevents drift between the writer (heartbeat
|
||||
* dispatch) and readers (automation, escalation, route filters).
|
||||
*/
|
||||
export const HEARTBEAT_TASK_TITLE_PREFIX = "[Heartbeat]";
|
||||
|
||||
export function isHeartbeatTaskTitle(title: string | null | undefined): boolean {
|
||||
return !!title && title.startsWith(HEARTBEAT_TASK_TITLE_PREFIX);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import type { AppDatabase } from "../database";
|
||||
import type { AgentRecord, ConnectorRecord } from "@shared/types";
|
||||
import type { OrchestrationDependencies } from "./types";
|
||||
import type { RunDispatchParams } from "./turn-context";
|
||||
import { HEARTBEAT_TASK_TITLE_PREFIX } from "./heartbeat-task";
|
||||
|
||||
export function createHeartbeat(
|
||||
deps: OrchestrationDependencies,
|
||||
@@ -151,10 +152,10 @@ export function createHeartbeat(
|
||||
}
|
||||
|
||||
const taskTitle = isCeo
|
||||
? `[Heartbeat] ${agent.name} — Strategic planning & task delegation`
|
||||
? `${HEARTBEAT_TASK_TITLE_PREFIX} ${agent.name} — Strategic planning & task delegation`
|
||||
: isManager
|
||||
? `[Heartbeat] ${agent.name} — Review team & delegate work`
|
||||
: `[Heartbeat] ${agent.name} — Check for work`;
|
||||
? `${HEARTBEAT_TASK_TITLE_PREFIX} ${agent.name} — Review team & delegate work`
|
||||
: `${HEARTBEAT_TASK_TITLE_PREFIX} ${agent.name} — Check for work`;
|
||||
const taskDescription = isCeo
|
||||
? "Review active company goals. Break each goal into projects and actionable tasks. Assign tasks to department leads and team members. Create tasks using the API. This is your primary responsibility as CEO — ensure every goal has a clear execution plan with assigned owners."
|
||||
: isManager
|
||||
|
||||
Reference in new issue
Block a user