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

@@ -29,6 +29,7 @@ import type { ToolContext } from "../types.js";
import { detectContext, generateGuardrails } from "../context-guard.js";
import { type Tier } from "../tiers.js";
import { log as auditLog } from "../audit.js";
import { notify, getNotificationConfig } from "../notify.js";
/** Labels that map to DEV role */
const DEV_LABELS: StateLabel[] = ["To Do", "To Improve"];
@@ -496,6 +497,32 @@ export function createHeartbeatTickTool(api: OpenClawPluginApi) {
skipped: result.skipped.length,
});
// Send heartbeat notification to orchestrator DM
const notifyConfig = getNotificationConfig(pluginConfig);
const orchestratorDm = pluginConfig?.orchestratorDm as string | undefined;
await notify(
{
type: "heartbeat",
projectsScanned: projectEntries.length,
healthFixes: result.healthFixes.length,
pickups: result.pickups.length,
skipped: result.skipped.length,
dryRun,
pickupDetails: result.pickups.map((p) => ({
project: p.project,
issueId: p.issueId,
role: p.role,
})),
},
{
workspaceDir,
config: notifyConfig,
orchestratorDm,
channel: "telegram",
},
);
return jsonResult(result);
},
});