reporters/index

Source: src/reporters/index.ts

Choosing a reporter, so the caller does not have to.

Requirement 3 of the project: you watch subagents work in herdr if it is running, in pi’s TUI otherwise, without changing a line of calling code. That promise is this one function.

autoReporter

function

export function autoReporter(options: AutoReporterOptions = {}): EventListener { /* … */ }

The herdr reporter when we are inside herdr, the fallback otherwise.

Never throws, never warns: not running under herdr is the normal case, not a degraded one.

AutoReporterOptions

type

export type AutoReporterOptions = HerdrOptions & {
	/** Used when herdr is absent. Defaults to {@link silentReporter}. */
	fallback?: EventListener;
};

{@link HerdrOptions}, plus what to do when there is no herdr to talk to.

combineReporters

function

export function combineReporters(...reporters: (EventListener | undefined)[]): EventListener { /* … */ }

Feeds one event stream to several reporters.

onEvent takes a single listener, so watching in two places at once - the pi TUI and herdr - needs composing. Absent entries are dropped, which is what makes combineReporters(picture.reporter, createHerdrReporter()) read well: createHerdrReporter returns undefined outside herdr.

One reporter throwing does not stop the others; that guarantee belongs to the bus, and this keeps it when there is no bus in between.