import type { StepResult, ToolSet } from 'ai'; /** * Metric sample compatible with @contractspec/lib.evolution OperationMetricSample. */ export interface OperationMetricSample { operation: { name: string; version: string; }; durationMs: number; success: boolean; timestamp: Date; metadata?: Record; } /** * Interface for collecting telemetry metrics. * * Implementations can send metrics to: * - @contractspec/lib.evolution for self-improvement * - PostHog for analytics * - Custom monitoring systems */ export interface TelemetryCollector { /** * Collect a metric sample. */ collect(sample: OperationMetricSample): Promise; } interface TrackAgentStepContext { sessionId?: string; tenantId?: string; actorId?: string; workflowId?: string; traceId?: string; stepIndex?: number; stepStartedAt?: Date; } /** * Track an agent step for telemetry. * * Called from ContractSpecAgent.onStepFinish to feed metrics * to the evolution engine. * * @param collector - Telemetry collector * @param agentId - Agent identifier (e.g., "support.bot.v1") * @param step - AI SDK step result * @param durationMs - Optional step duration in milliseconds */ export declare function trackAgentStep(collector: TelemetryCollector, agentId: string, step: StepResult, durationMs?: number, context?: TrackAgentStepContext): Promise; /** * In-memory telemetry collector for testing. */ export declare class InMemoryTelemetryCollector implements TelemetryCollector { private readonly samples; collect(sample: OperationMetricSample): Promise; /** * Get all collected samples. */ getSamples(): OperationMetricSample[]; /** * Get samples for a specific operation. */ getSamplesForOperation(operationName: string): OperationMetricSample[]; /** * Clear all samples. */ clear(): void; } /** * Create an in-memory telemetry collector. */ export declare function createInMemoryTelemetryCollector(): InMemoryTelemetryCollector; /** * No-op telemetry collector that discards all metrics. */ export declare const noopTelemetryCollector: TelemetryCollector; export {};