/** * Tier 0 herdr bridge — mirror live workflow status into the herdr TUI. * * When pi runs inside a [herdr](https://herdr.dev) pane, herdr's own pi * integration already reports the pane's agent state (idle/working/blocked) * under the source `herdr:pi`. This reporter does NOT touch that state. It * layers a sidecar one-line *custom status* onto the same pane via * `herdr pane report-metadata`, so a fan-out that would otherwise show as a * single opaque "working" cell instead reads e.g. * * research_topic ▶ Synthesize 12/40 · 3.2K tok * * Design constraints (intentionally minimal — see README "Tier 0"): * - Feature-detected: a no-op unless `HERDR_PANE_ID` is present. Degrades * silently outside herdr or when the `herdr` CLI is missing. * - Separate `--source` (`pi-workflows`) + `--applies-to-source herdr:pi`, so * we annotate pi's detected agent without fighting its state machine. * - Throttled: token events fire often, so updates coalesce into one push per * `throttleMs`, and only when the rendered string actually changes. * - Self-healing: every push carries `--ttl-ms`, so a crashed/killed workflow's * status expires from the cell instead of lingering. * - Best-effort: every herdr call is fire-and-forget; failures never throw into * the workflow runtime. */ import { type ConductorRunStatus } from "./conductor-types.js"; import type { WorkflowManager } from "./workflow-manager.js"; /** Minimal view of a run needed to render the sidecar — decoupled from persistence for testability. */ export interface ActiveRunView { workflowName: string; status: string; currentPhase?: string; agents: Array<{ status: string; tokens?: number; }>; semanticStatus?: ConductorRunStatus; } /** * Render the one-line custom-status for the herdr cell, or `null` when nothing * is active (callers clear the cell on `null`). Pure — unit-tested directly. */ export declare function summarizeActiveRuns(active: ActiveRunView[]): string | null; /** * Resolve the herdr pane this process should report into, or `null` to disable. * Disabled when not inside herdr (`HERDR_PANE_ID` unset) or via the * `PI_WORKFLOWS_HERDR=0` opt-out. */ export declare function herdrPaneTarget(env?: NodeJS.ProcessEnv): string | null; export interface HerdrReporterOptions { /** Master on/off, from the `herdrStatus` setting. `false` → no-op (default on). */ enabled?: boolean; /** Override the target pane (default: `HERDR_PANE_ID`). */ paneId?: string; /** Override env used for feature detection (tests). */ env?: NodeJS.ProcessEnv; /** Override the herdr invoker (tests). Receives argv after `herdr`. */ run?: (args: string[]) => void; /** Source to annotate (default `herdr:pi`); set "" to attach pane-level only. */ appliesToSource?: string; /** Coalescing window in ms (default 750). */ throttleMs?: number; /** Status TTL in ms (default 20000). */ ttlMs?: number; } /** * Subscribe to workflow lifecycle events and mirror an aggregate status line * into the host herdr pane. Idempotent per manager (safe across `session_start` * re-fires). No-op outside herdr. * * Does not need the `ExtensionAPI` — it talks to herdr over its own CLI/socket, * exactly like the conductor was designed to shell out to tmux. */ export declare function installHerdrReporter(manager: WorkflowManager, opts?: HerdrReporterOptions): void;