/** * DiagnosticsBus — the scope-owned collector that gathers {@link DiagnosticEvent}s * across the uniform tool lifecycle and snapshots them as {@link RunDiagnostics} * to ride on a `CommandOutcome` (north-star §5.10, release 2.12.0). * * Per-invocation state, held on {@link RunScope} (the no-module-singleton rule): * library code deep in the call tree emits via `currentScope()?.diagnostics`, and * the host assembler attaches `scope.diagnostics.snapshot()` to every outcome. * Additive — the logger, runId, and graph OTEL spans stay; this is the * structured, JSON-emittable layer on top. * * The bus is a runtime collector (like the logger), so it stamps wall-clock time * (`new Date().toISOString()`) — the `Date.now()`-free contract applies to the * pure formatters (`buildSignalEnvelope`), not to this collector. The OTEL trace * bridge is best-effort: `snapshot().trace` carries the active span's * trace/span ids when telemetry is on, parsed from the W3C `traceparent` the * kernel already exposes — so bundled and external tools are observable * identically, with no SDK dependency in the kernel. */ import type { DiagnosticEvent, DiagnosticLevel, DiagnosticPhase, RunDiagnostics } from './run-diagnostics.js'; /** A diagnostic event with the timestamp left to the bus to stamp. */ export type DiagnosticEventInput = Omit & { readonly at?: string; }; /** * The per-invocation diagnostics collector. Construct one per {@link RunScope}. */ export declare class DiagnosticsBus { private readonly runId; private readonly events; private readonly metrics; constructor(runId: string); /** * Append a lifecycle event. The bus stamps `at` (ISO-8601) when the caller did * not supply one. Cheap and allocation-light; safe to call from any phase. */ emit(event: DiagnosticEventInput): void; /** Convenience: emit at a given phase/level with an optional data bag. */ event(phase: DiagnosticPhase, level: DiagnosticLevel, message: string, data?: Readonly>): void; /** Increment a named counter (e.g. `'plugins.loaded'`). Defaults to +1. */ counter(name: string, delta?: number): void; /** * Materialize the JSON-emittable snapshot carried on a `CommandOutcome`. Pure * read: copies the event stream + metrics and bridges the active OTEL trace. */ snapshot(): RunDiagnostics; } //# sourceMappingURL=diagnostics-bus.d.ts.map