feat(hn-monitor): unify Slack + Telegram into single dual-transport agent

Merged
KH
4mo ago
+2-515

Summary

Replaces the separate hn-monitor and hn-monitor-telegram agents with a single dual-transport agent. Delivers to Slack, Telegram, or both — configuration-driven via SLACK_CHANNEL and TELEGRAM_CHAT inputs (both optional).

Depends on workforce#250 for @agentworkforce/delivery (now published as ^0.1.0).

Changes

  • Single agent.ts — uses createDelivery from @agentworkforce/delivery, auto-detects configured transports
  • Non-blocking parentRef threading — header published with 0ms timeout, body threaded via parentRef (x-reply-radar pattern, zero receipt round-trips)
  • Backported Telegram improvements: fetchWithTimeout (8s AbortController), withTimeout for LLM, pending thread body recovery with headerRefs for proper retry threading
  • Shared helpers (input, list, withTimeout, fetchWithTimeout) from @agentworkforce/delivery
  • Persona declares both slack and telegram integrations, both inputs optional: true
  • Q&A routes relay inbox DMs and Telegram messages through shared handler, replies only to origin transport
  • Recovery tests verify pending body retry preserves threading context
  • Removed hn-monitor-telegram/ directory (now superseded)
  • 161/161 tests pass, typecheck clean

Summary by cubic

Unifies the Slack and Telegram HN monitors into one agent that posts to Slack, Telegram, or both via @agentworkforce/delivery. Adds non-blocking threading with robust recovery and prevents cross-post or partial-publish failures.

  • New Features

    • Config via SLACK_CHANNEL and TELEGRAM_CHAT (optional) with unified, non-blocking parentRef threading; adds fetchWithTimeout (8s) and withTimeout to prevent hangs.
    • Durable recovery: saves headerRefs and retries threaded bodies on the next scan; unified Q&A for relay DMs and Telegram, replying only on the origin transport.
  • Bug Fixes

    • Treats partial header publishes as failures; builds pending state before sending the body; clears orphaned pending bodies when targets change; fixes cross-post leakage with transport-scoped delivery.
    • Removes hn-monitor-telegram/ and superseded Telegram tests; updates imports; uses published @agentworkforce/delivery@^0.1.0 (matches main).