/** * @license * Copyright 2026 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { RunEvent } from "./RunEventTypes"; export interface RunEventSink { emit(event: RunEvent): void; /** Resolves once the bytes are flushed — the parent reads what we wrote. */ close(): Promise; } /** Env var a parent process sets to ask its child for a machine-readable run. */ export declare const RUN_EVENTS_ENV = "WORKGLOW_RUN_EVENTS"; /** * Env var naming where answers to the run's human prompts arrive. * * Its own descriptor rather than stdin: stdin belongs to the command being run, * and a run started with stdin closed (`< /dev/null`, a service manager, a CI * job) must not die because the answers reader saw EOF. */ export declare const RUN_ANSWERS_ENV = "WORKGLOW_RUN_ANSWERS"; /** * Installs the process-wide sink. * * Every failure here is swallowed: the channel is a reporting side-channel, and * a run that would have succeeded must not die because the thing watching it * went away — a parent closing a pipe is an ordinary way for that to happen. */ export declare function installRunEventChannel(target: string): RunEventSink | undefined; /** * Reads NDJSON answer lines from the descriptor the parent named. Returns a * stop function, or undefined when nothing is listening. * * Stop and start it freely: a descriptor the parent handed us belongs to the * parent and is never closed here. `fs` read streams close theirs on * `destroy()` even with `autoClose: false`, and a closed number is handed * straight back to the process — so the next `open()` (a database, a model * cache, the log) takes the slot, the next question reads that file instead of * the parent's answers, and the release after it closes that subsystem's * descriptor. Hence the explicit read loop. */ export declare function readRunAnswerLines(target: string, onLine: (line: string) => void): (() => void) | undefined; export declare function getRunEventSink(): RunEventSink | undefined; /** * Test seam: drops the installed sink so one test file cannot leak into the * next. The answer readers go with it — they are keyed by descriptor number, * and a test that closes its own fd frees that number for the next test's. */ export declare function resetRunEventChannelForTesting(): void;