/** * MetricsRegistry — Zero-dependency Prometheus-compatible metrics. * * Provides Counter, Gauge, and Histogram metric types with label support. * Exports metrics in Prometheus text exposition format for scraping. * * No runtime dependencies — drop-in for any HTTP server or the MCP endpoint. * * @module Metrics */ /** Supported metric types */ export type MetricType = 'counter' | 'gauge' | 'histogram'; /** A set of label key-value pairs */ export type Labels = Record; /** Configuration for a histogram */ export interface HistogramBuckets { /** Upper bounds for each bucket (must be sorted ascending) */ boundaries: number[]; } /** Monotonically increasing counter */ export declare class Counter { readonly name: string; readonly help: string; private series; private labelMap; constructor(name: string, help: string); inc(labels?: Labels, amount?: number): void; get(labels?: Labels): number; /** Prometheus text lines */ expose(): string; } /** Gauge — can go up or down */ export declare class Gauge { readonly name: string; readonly help: string; private series; private labelMap; constructor(name: string, help: string); set(labels: Labels, value: number): void; set(value: number): void; inc(labels?: Labels, amount?: number): void; dec(labels?: Labels, amount?: number): void; get(labels?: Labels): number; expose(): string; } /** Histogram with configurable buckets */ export declare class Histogram { readonly name: string; readonly help: string; readonly boundaries: number[]; private series; private labelMap; constructor(name: string, help: string, buckets?: HistogramBuckets); observe(labels: Labels, value: number): void; observe(value: number): void; expose(): string; } /** * Central metrics registry. Collects all metrics and exposes them in * Prometheus text format. * * @example * ```ts * const registry = new MetricsRegistry(); * const delegations = registry.counter('nai_delegations_total', 'Total delegations'); * const activeAgents = registry.gauge('nai_active_agents', 'Currently active agents'); * const latency = registry.histogram('nai_delegation_duration_ms', 'Delegation latency'); * * delegations.inc({ agent: 'planner' }); * activeAgents.set(5); * latency.observe({ agent: 'planner' }, 142); * * const text = registry.expose(); // Prometheus text exposition format * ``` */ export declare class MetricsRegistry { private counters; private gauges; private histograms; /** Create or retrieve a counter */ counter(name: string, help: string): Counter; /** Create or retrieve a gauge */ gauge(name: string, help: string): Gauge; /** Create or retrieve a histogram */ histogram(name: string, help: string, buckets?: HistogramBuckets): Histogram; /** * Export all registered metrics in Prometheus text exposition format. */ expose(): string; /** Get a specific counter by name */ getCounter(name: string): Counter | undefined; /** Get a specific gauge by name */ getGauge(name: string): Gauge | undefined; /** Get a specific histogram by name */ getHistogram(name: string): Histogram | undefined; /** Total number of registered metrics */ get size(): number; } /** * Create a pre-configured MetricsRegistry with standard orchestrator metrics. * * Returns the registry and named handles to the individual metrics. */ export declare function createOrchestratorMetrics(): { registry: MetricsRegistry; delegationsTotal: Counter; delegationErrors: Counter; permissionChecks: Counter; permissionDenials: Counter; injectionBlocks: Counter; qualityRejections: Counter; blackboardWrites: Counter; activeAgents: Gauge; blackboardSize: Gauge; budgetUsedPercent: Gauge; delegationDurationMs: Histogram; adapterDurationMs: Histogram; }; //# sourceMappingURL=metrics.d.ts.map