/** * Observability callbacks manager for MCP-use. * * This module provides a centralized manager for handling observability callbacks * from various platforms (Langfuse, Laminar, etc.) in a clean and extensible way. */ import type { BaseCallbackHandler } from "@langchain/core/callbacks/base"; /** Configures callbacks and trace metadata for an agent. */ export interface ObservabilityConfig { /** Custom callbacks to use instead of defaults */ customCallbacks?: BaseCallbackHandler[]; /** Whether to enable verbose logging */ verbose?: boolean; /** Whether to enable observability (defaults to true) */ observe?: boolean; /** Agent ID for tagging traces */ agentId?: string; /** Metadata to add to traces */ metadata?: Record; /** Function to get current metadata from agent */ metadataProvider?: () => Record; /** Function to get current tags from agent */ tagsProvider?: () => string[]; } /** Snapshot returned by {@link ObservabilityManager.getStatus}. */ export interface ObservabilityStatus { /** Whether observability is enabled and has at least one callback. */ enabled: boolean; /** Number of active callbacks. */ callbackCount: number; /** Human-readable callback handler names. */ handlerNames: string[]; /** Current trace metadata. */ metadata: Record; /** Current trace tags. */ tags: string[]; } /** Discovers, configures, and shuts down LangChain observability callbacks. */ export declare class ObservabilityManager { private customCallbacks?; private availableHandlers; private handlerNames; private initialized; private verbose; private observe; private agentId?; private metadata?; private metadataProvider?; private tagsProvider?; /** * @param config - Callback selection and trace metadata settings. */ constructor(config?: ObservabilityConfig); /** * Collect all available observability handlers from configured platforms. */ private collectAvailableHandlers; /** * Get the list of callbacks to use. * @returns List of callbacks - either custom callbacks if provided, or all available observability handlers. */ getCallbacks(): Promise; /** * Get the names of available handlers. * @returns List of handler names (e.g., ["Langfuse", "Laminar"]) */ getHandlerNames(): Promise; /** * Check if any callbacks are available. * @returns True if callbacks are available, False otherwise. */ hasCallbacks(): Promise; /** * Get the current observability status including metadata and tags. * @returns Object containing enabled status, callback count, handler names, metadata, and tags. */ getStatus(): Promise; /** * Add a callback to the custom callbacks list. * @param callback - The callback to add. */ addCallback(callback: BaseCallbackHandler): void; /** * Clear all custom callbacks. */ clearCallbacks(): void; /** * Flush all pending traces to observability platforms. * Important for serverless environments and short-lived processes. */ flush(): Promise; /** * Shutdown all handlers gracefully (for serverless environments). */ shutdown(): Promise; /** * String representation of the ObservabilityManager. */ toString(): string; } //# sourceMappingURL=manager.d.ts.map