feat: add programmatic alerting for worker lifecycle events (#16) (#17)

Adds notification system for full visibility into the DevClaw pipeline:

Events and targets:
- workerStart: Posted to project group when worker spawns/resumes
- workerComplete: Posted to project group when DEV done/QA pass/fail/refine
- heartbeat: Posted to orchestrator DM with tick summary

Implementation:
- New lib/notify.ts module with buildMessage() and sendMessage()
- Integrated into task_pickup, task_complete, and heartbeat_tick
- Uses OpenClaw gateway to invoke message tool

Configuration (optional):
- orchestratorDm: Chat ID for heartbeat notifications
- notifications.heartbeatDm: Enable/disable heartbeat DM (default: true)
- notifications.workerStart: Enable/disable start notifications (default: true)
- notifications.workerComplete: Enable/disable completion notifications (default: true)

Notifications fail silently (logged but don't break main flow).
This commit is contained in:
Lauren ten Hoor
2026-02-10 00:40:44 +08:00
committed by GitHub
parent c88071db0e
commit d40aa41b16
5 changed files with 354 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ import { getProject, getWorker, readProjects } from "../projects.js";
import type { ToolContext } from "../types.js";
import { detectContext, generateGuardrails } from "../context-guard.js";
import { isDevTier, isTier, type Tier } from "../tiers.js";
import { notify, getNotificationConfig } from "../notify.js";
/** Labels that map to DEV role */
const DEV_LABELS: StateLabel[] = ["To Do", "To Improve"];
@@ -300,7 +301,28 @@ export function createTaskPickupTool(api: OpenClawPluginApi) {
pluginConfig,
});
// 9. Build result
// 9. Send notification to project group
const notifyConfig = getNotificationConfig(pluginConfig);
await notify(
{
type: "workerStart",
project: project.name,
groupId,
issueId: issue.iid,
issueTitle: issue.title,
role,
model: dispatchResult.modelAlias,
sessionAction: dispatchResult.sessionAction,
},
{
workspaceDir,
config: notifyConfig,
groupId,
channel: context.channel,
},
);
// 10. Build result
const result: Record<string, unknown> = {
success: true,
project: project.name,