import type { TelemetryEvent, TelemetrySink } from './TelemetryEvent.js'; /** * Compute the IPC path for the telemetry socket. * * Uses a deterministic fingerprint based on `process.cwd()` so the * socket path remains stable across server restarts. This enables * the Inspector TUI to reconnect automatically without PID tracking. * * - Windows: `\\.\pipe\mcp-fusion-{fingerprint}` (Named Pipe, auto-cleaned by OS) * - POSIX: `/tmp/mcp-fusion-{fingerprint}.sock` (Unix Domain Socket) * * @param fingerprint - Custom fingerprint (defaults to SHA-256 of cwd) * @returns The IPC path string */ export declare function getTelemetryPath(fingerprint?: string): string; /** * Discover active telemetry sockets by scanning the registry directory. * Works on Windows, Mac, and Linux. * * Reads `{REGISTRY_DIR}/*.json` marker files written by running servers. * Each file contains `{ pid, path }`. Stale files from crashed processes * (e.g. SIGKILL where cleanup handlers never run) are detected via PID * probing and automatically cleaned up. * * @returns Array of discovered sockets with their PIDs */ export declare function discoverSockets(): Array<{ pid: number; path: string; cwd?: string; }>; /** * Configuration for the telemetry bus. */ export interface TelemetryBusConfig { /** * Custom IPC path. If omitted, uses the default path convention. */ readonly path?: string; /** * Callback invoked when a TUI client connects. * Receives a function to send the initial topology snapshot. */ readonly onConnect?: () => TelemetryEvent | undefined; } /** * A running telemetry bus instance. */ export interface TelemetryBusInstance { /** The emit function — pass as `TelemetrySink` to the server */ readonly emit: TelemetrySink; /** The IPC path the bus is listening on */ readonly path: string; /** Number of connected TUI clients */ readonly clientCount: () => number; /** Gracefully shut down the bus */ readonly close: () => Promise; } /** * Create an out-of-band telemetry bus for MCP Fusion. * * The returned `emit` function is the {@link TelemetrySink} to pass * to `AttachOptions.telemetry`. It broadcasts events as NDJSON * to all connected TUI clients via IPC. * * When no clients are connected, `emit()` is a no-op — zero overhead. * * @param config - Optional configuration * @returns A promise that resolves to the running bus instance * * @example * ```typescript * import { createTelemetryBus } from '@vinkius-core/mcp-fusion/observability'; * * const bus = await createTelemetryBus(); * * // Pass to server attachment * registry.attachToServer(server, { * contextFactory: createContext, * telemetry: bus.emit, * }); * * // On shutdown * await bus.close(); * ``` */ export declare function createTelemetryBus(config?: TelemetryBusConfig): Promise; //# sourceMappingURL=TelemetryBus.d.ts.map