/** * @license * Copyright 2026 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { ITask, TaskGraph } from "@workglow/task-graph"; import type { RunEventSink } from "./runEventChannel"; export interface ProjectRunEventsOptions { /** Nesting level reported on every row this projection adds. */ readonly depth?: number; /** Row that owns this graph, when it is a subgraph rather than the run's own. */ readonly parent?: string; /** * Emit `task_removed` for every row added, when this projection stops. Right * for a Map's iteration clone, which is real only while it runs; wrong for an * owned subgraph, whose rows are most of what a finished run has to show. */ readonly removeRowsOnStop?: boolean; } /** * Subscribes a running graph and reports it as {@link RunEvent}s. * * The wiring rules are the terminal UI's, and they are not obvious: wire on * `task_added`, UNwire on `task_removed` (a task released with `disown` can be * owned again, and without dropping its listeners the loop would stack a new * pair every cycle), and read the label per event rather than caching it (a * reused instance is relabelled per job). Aggregate progress, per-task usage * and stream chunks are already bridged up by the graph — including from * nested subgraphs — so those come from the graph rather than from each task. */ export declare function projectRunEvents(graph: TaskGraph, sink: RunEventSink, options?: ProjectRunEventsOptions): () => void; /** A single-task run: the task itself is row 0, its owned subgraph is depth 1. */ export declare function projectTaskRunEvents(task: ITask, sink: RunEventSink): () => void;