/**
 * stdoutTelemetrySink — JSON line emission to stderr (dev-friendly default).
 *
 * One JSON object per event, suitable for `jq`, `pino-pretty`, or any
 * structured-log pipeline. Writes to stderr (not stdout) so that the agent's
 * own stdout remains free for user output.
 *
 * Ref: command-center:sprint-693:sink-stdout
 */
/**
 * Default sink for dev visibility. Zero dependency, zero I/O latency
 * (synchronous write to stream).
 */
export function stdoutTelemetrySink(opts = {}) {
    const stream = opts.stream ?? process.stderr;
    const useJson = opts.json ?? true;
    function emit(event) {
        const line = useJson
            ? JSON.stringify(event)
            : Object.entries(event)
                .map(([k, v]) => `${k}=${JSON.stringify(v)}`)
                .join(" ");
        stream.write(`${line}\n`);
    }
    return {
        name: "stdout",
        async start(event) {
            emit({ telemetry: "run.start", ...event });
        },
        async step(runId, delta) {
            emit({ telemetry: "run.step", runId, ...delta });
        },
        async finish(runId, event) {
            emit({ telemetry: "run.finish", runId, ...event });
        },
    };
}
//# sourceMappingURL=stdout.js.map