const RING = [];
const MAX = 150;
export function bridgePipelineLog(entry) {
    const row = {
        layer: 'bridge',
        at: entry.at ?? Date.now(),
        dir: entry.dir,
        event: entry.event,
        requestId: entry.requestId,
        agentId: entry.agentId,
        bytes: entry.bytes,
        msgs: entry.msgs,
        detail: entry.detail,
    };
    RING.push(row);
    while (RING.length > MAX)
        RING.shift();
    const rid = row.requestId ? ` rid=${row.requestId}` : '';
    console.log(`[history-pipe] bridge ${row.dir} ${row.event}${rid} agent=${row.agentId ?? '-'} bytes=${row.bytes ?? '-'} msgs=${row.msgs ?? '-'} ${row.detail ?? ''}`.trim());
}
export function bridgePipelineSnapshot() {
    return [...RING];
}
export function bridgePipelineReportLines() {
    return RING.map((r) => {
        const t = new Date(r.at).toISOString().slice(11, 23);
        return `${t} bridge ${r.dir} ${r.event} rid=${r.requestId ?? '-'} agent=${r.agentId ?? '-'} bytes=${r.bytes ?? '-'} msgs=${r.msgs ?? '-'} ${r.detail ?? ''}`.trim();
    });
}
