import * as _opentelemetry_api from '@opentelemetry/api'; import { Span, Tracer } from '@opentelemetry/api'; import { SpanProcessor } from '@opentelemetry/sdk-trace-base'; import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'; /** * Configuration options for Moda SDK initialization */ interface ModaInitOptions { /** Base URL for the Moda ingest endpoint */ baseUrl?: string; /** Environment name (development, staging, production) */ environment?: string; /** Enable or disable the SDK (default: true) */ enabled?: boolean; /** Enable debug logging */ debug?: boolean; /** Maximum number of spans to batch before sending (default: 100) */ batchSize?: number; /** Interval in milliseconds to flush pending spans (default: 5000) */ flushInterval?: number; } /** * Options for createModaSpanProcessor() */ interface ModaSpanProcessorOptions { /** Your Moda API key */ apiKey: string; /** Base URL for the Moda ingest endpoint */ baseUrl?: string; /** Enable debug logging */ debug?: boolean; /** Maximum number of spans to batch before sending */ batchSize?: number; /** Interval in milliseconds to flush pending spans */ flushInterval?: number; } /** * Context stored in AsyncLocalStorage */ interface ModaContext { conversationId?: string; userId?: string; } /** * Generic message type for conversation tracking */ interface Message { role: 'system' | 'user' | 'assistant' | 'tool' | 'function'; content: MessageContent; name?: string; tool_call_id?: string; } /** * Message content can be a string or an array of content parts */ type MessageContent = string | ContentPart[]; /** * Content part for multi-modal messages */ interface ContentPart { type: 'text' | 'image_url' | 'image' | 'tool_use' | 'tool_result' | 'thinking'; text?: string; image_url?: { url: string; }; source?: { type: string; media_type: string; data: string; }; } /** * OpenAI-style message format */ interface OpenAIMessage { role: 'system' | 'user' | 'assistant' | 'tool' | 'function'; content: string | OpenAIContentPart[] | null; name?: string; tool_call_id?: string; tool_calls?: OpenAIToolCall[]; } interface OpenAIContentPart { type: 'text' | 'image_url'; text?: string; image_url?: { url: string; detail?: string; }; } interface OpenAIToolCall { id: string; type: 'function'; function: { name: string; arguments: string; }; } /** * Anthropic-style message format */ interface AnthropicMessage { role: 'user' | 'assistant'; content: string | AnthropicContentBlock[]; } interface AnthropicContentBlock { type: 'text' | 'image' | 'tool_use' | 'tool_result' | 'thinking'; text?: string; id?: string; name?: string; input?: Record; tool_use_id?: string; content?: string | AnthropicContentBlock[]; source?: { type: string; media_type: string; data: string; }; thinking?: string; } /** * Span attributes for LLM calls */ interface LLMSpanAttributes { 'llm.vendor': string; 'llm.request.type': string; 'llm.request.model': string; 'llm.response.model'?: string; 'llm.usage.total_tokens'?: number; 'llm.usage.prompt_tokens'?: number; 'llm.usage.completion_tokens'?: number; 'moda.conversation_id': string; 'moda.user_id'?: string; [key: string]: string | number | boolean | undefined; } /** * SDK state */ interface ModaState { initialized: boolean; apiKey: string | null; options: Required; } /** * Default configuration values */ declare const DEFAULT_OPTIONS: Required; /** * Check if the SDK is initialized */ declare function isInitialized(): boolean; /** * Initialize the Moda SDK. * * This sets up OpenTelemetry tracing with an OTLP exporter pointed at Moda's * ingestion endpoint and registers instrumentations for OpenAI and Anthropic. * * @param apiKey - Your Moda API key (format: moda_xxx) * @param options - Configuration options * * @example * ```typescript * import { Moda } from '@moda/sdk'; * * Moda.init('moda_your_api_key', { * environment: 'production', * debug: false, * }); * ``` */ declare function init(apiKey: string, options?: ModaInitOptions): Promise; /** * Force flush all pending spans to the Moda backend. * Call this before your application exits to ensure all telemetry is sent. * * @example * ```typescript * // Before shutting down * await Moda.flush(); * process.exit(0); * ``` */ declare function flush(): Promise; /** * Shutdown the SDK and release all resources. * This flushes any pending spans and stops the tracer provider. * * @example * ```typescript * process.on('SIGTERM', async () => { * await Moda.shutdown(); * process.exit(0); * }); * ``` */ declare function shutdown(): Promise; /** * Get the OpenTelemetry tracer for creating custom spans. * Returns a no-op tracer if the SDK is not initialized. */ declare function getTracer(): _opentelemetry_api.Tracer; /** * Create a standalone Moda SpanProcessor for advanced OTEL setups. * Use when you need full control over your OpenTelemetry configuration. * * @example * ```typescript * import { createModaSpanProcessor } from 'moda-ai'; * import { trace } from '@opentelemetry/api'; * * const processor = createModaSpanProcessor({ apiKey: 'moda_xxx' }); * (trace.getTracerProvider() as any).addSpanProcessor(processor); * ``` */ declare function createModaSpanProcessor(options: ModaSpanProcessorOptions): SpanProcessor; /** * Get the current Moda context from AsyncLocalStorage * @returns Current context or empty object if not set */ declare function getContext(): ModaContext; /** * Set a global conversation ID that persists across async boundaries. * This is useful when you want to track a conversation across multiple API calls * without wrapping them in a callback. * * @param id - The conversation ID to set */ declare function setConversationId(id: string): void; /** * Clear the global conversation ID. */ declare function clearConversationId(): void; /** * Set a global user ID that persists across async boundaries. * * @param id - The user ID to set */ declare function setUserId(id: string): void; /** * Clear the global user ID. */ declare function clearUserId(): void; /** * Get the combined context (AsyncLocalStorage + global) * AsyncLocalStorage takes precedence over global context */ declare function getEffectiveContext(): ModaContext; /** * Run a callback with a specific conversation ID in the AsyncLocalStorage context. * The conversation ID will be available to all async operations within the callback. * * @param id - The conversation ID to set * @param callback - The function to run with the context * @returns The return value of the callback * * @example * ```typescript * await withConversationId('my-conv-123', async () => { * await openai.chat.completions.create({ ... }); * await openai.chat.completions.create({ ... }); * // Both calls will have the same conversation ID * }); * ``` */ declare function withConversationId(id: string, callback: () => T): T; /** * Run a callback with a specific user ID in the AsyncLocalStorage context. * * @param id - The user ID to set * @param callback - The function to run with the context * @returns The return value of the callback */ declare function withUserId(id: string, callback: () => T): T; /** * Run a callback with both conversation ID and user ID in context. * * @param conversationId - The conversation ID to set * @param userId - The user ID to set * @param callback - The function to run with the context * @returns The return value of the callback */ declare function withContext(conversationId: string, userId: string, callback: () => T): T; /** * Get the global context (without AsyncLocalStorage context). * Useful for accessing the explicitly set conversationId and userId. */ declare function getGlobalContext(): ModaContext; /** * Compute a stable conversation ID from message history. * * The algorithm: * 1. If an explicit ID is provided (via context or parameter), use it * 2. Find the first user message in the conversation * 3. Compute SHA256 hash of: system prompt + first user message * 4. Return conv_[hash[:16]] * * This ensures that multi-turn conversations with the same starting point * always get the same conversation ID, enabling proper thread tracking. * * @param messages - Array of messages in the conversation * @param systemPrompt - Optional system prompt (separate from messages, e.g., Anthropic style) * @param explicitId - Optional explicit conversation ID to override computation * @returns Conversation ID in format conv_[16-char-hash] or the explicit ID */ declare function computeConversationId(messages: Message[], systemPrompt?: string, explicitId?: string): string; /** * Generate a random conversation ID * Useful for cases where automatic computation is not desired */ declare function generateRandomConversationId(): string; /** * Validate conversation ID format * @param id - Conversation ID to validate * @returns true if the ID matches expected format */ declare function isValidConversationId(id: string): boolean; /** * Manual LLM tracing API for instrumenting arbitrary LLM calls. * Use this when you can't use auto-instrumented SDKs (OpenAI/Anthropic). * * @example * ```typescript * const result = await withLLMCall( * { vendor: 'openrouter', type: 'chat' }, * async ({ span }) => { * span.reportRequest({ model: 'gpt-4', messages }); * const response = await fetch('https://api.example.com/chat', {...}); * const data = await response.json(); * span.reportResponse({ model: data.model, usage: data.usage, completions: data.choices }); * return data; * } * ); * ``` */ /** * Options for withLLMCall wrapper */ interface WithLLMCallOptions { /** LLM vendor/provider name (e.g., 'openrouter', 'cohere', 'custom') */ vendor: string; /** Request type (e.g., 'chat', 'completion', 'embedding') */ type: string; } /** * Options for reportRequest method */ interface ReportRequestOptions { /** Model identifier (e.g., 'gpt-4', 'claude-3-sonnet') */ model: string; /** Array of messages in the conversation */ messages: Message[]; /** Optional conversation ID (computed from messages if not provided) */ conversationId?: string; /** Optional user ID */ userId?: string; } /** * Completion object for reportResponse */ interface CompletionOption { /** Role of the completion (usually 'assistant') */ role?: string; /** Content of the completion */ content?: string; /** Finish reason (e.g., 'stop', 'length', 'tool_calls') */ finish_reason?: string; /** For OpenAI-style responses with nested message */ message?: { role?: string; content?: string | null; }; } /** * Options for reportResponse method */ interface ReportResponseOptions { /** Model that generated the response (may differ from request model) */ model?: string; /** Token usage metrics */ usage?: { prompt_tokens?: number; completion_tokens?: number; total_tokens?: number; input_tokens?: number; output_tokens?: number; }; /** Array of completions/choices */ completions?: CompletionOption[]; } /** * Span helper object passed to the withLLMCall callback */ interface LLMSpanHelper { /** * Report request attributes (model, messages, etc.) * Call this before making your LLM API call. */ reportRequest(options: ReportRequestOptions): void; /** * Report response attributes (usage, completions, etc.) * Call this after receiving the LLM response. */ reportResponse(options: ReportResponseOptions): void; /** * Access the underlying OpenTelemetry span for advanced use cases */ readonly rawSpan: Span; } /** * Callback function type for withLLMCall */ type LLMCallCallback = (context: { span: LLMSpanHelper; }) => Promise; /** * Wrap an arbitrary LLM call with OpenTelemetry tracing. * * Use this when you can't use auto-instrumented SDKs (OpenAI/Anthropic) * and need to manually instrument LLM calls (e.g., direct fetch to OpenRouter, * custom LLM providers, proxied requests). * * @param options - Vendor and request type configuration * @param callback - Async function that makes the LLM call * @returns The return value of the callback * * @example * ```typescript * const result = await withLLMCall( * { vendor: 'openrouter', type: 'chat' }, * async ({ span }) => { * span.reportRequest({ model: 'anthropic/claude-3-sonnet', messages }); * * const response = await fetch('https://openrouter.ai/api/v1/chat/completions', { * method: 'POST', * headers: { Authorization: `Bearer ${apiKey}` }, * body: JSON.stringify({ model, messages }), * }); * const data = await response.json(); * * span.reportResponse({ * model: data.model, * usage: data.usage, * completions: data.choices, * }); * * return data; * } * ); * ``` */ declare function withLLMCall(options: WithLLMCallOptions, callback: LLMCallCallback): Promise; /** * Vercel AI SDK integration for Moda observability. * * The Vercel AI SDK has built-in OpenTelemetry support via `experimental_telemetry`. * This module provides helper functions to integrate Moda with the AI SDK. * * @example * ```typescript * import { Moda } from 'moda-ai'; * import { generateText } from 'ai'; * * Moda.init('your-api-key'); * * const result = await generateText({ * model: openai('gpt-4o'), * prompt: 'Hello', * experimental_telemetry: Moda.getVercelAITelemetry(), * }); * ``` */ /** * Telemetry metadata for Vercel AI SDK. * Supports string, number, boolean, undefined, and arrays of these types. */ type VercelAITelemetryMetadata = Record; /** * Telemetry configuration for Vercel AI SDK's `experimental_telemetry` option. * * @see https://ai-sdk.dev/docs/ai-sdk-core/telemetry */ interface VercelAITelemetryConfig { /** * Enable or disable telemetry. When disabled, no telemetry data is collected. * @default true */ isEnabled: boolean; /** * Whether to record input data (prompts, messages). * Set to false to avoid recording sensitive information. * @default true */ recordInputs?: boolean; /** * Whether to record output data (completions, generated text). * Set to false to avoid recording sensitive information. * @default true */ recordOutputs?: boolean; /** * Identifier to group telemetry data by function. * Useful for distinguishing different AI operations in your app. */ functionId?: string; /** * Custom metadata to attach to telemetry spans. * Moda automatically includes conversation_id and user_id. */ metadata?: VercelAITelemetryMetadata; /** * Custom OpenTelemetry tracer. Moda provides its configured tracer by default. */ tracer?: Tracer; } /** * Options for customizing the Vercel AI telemetry configuration. */ interface GetVercelAITelemetryOptions { /** * Whether to record input data (prompts, messages). * @default true */ recordInputs?: boolean; /** * Whether to record output data (completions, generated text). * @default true */ recordOutputs?: boolean; /** * Identifier to group telemetry data by function. */ functionId?: string; /** * Additional custom metadata to include in telemetry spans. * Will be merged with Moda's automatic metadata (conversation_id, user_id). */ metadata?: VercelAITelemetryMetadata; } /** * Get a telemetry configuration object for the Vercel AI SDK. * * This returns a configuration that can be passed directly to the * `experimental_telemetry` option of AI SDK functions like `generateText`, * `streamText`, `generateObject`, etc. * * The configuration includes: * - Moda's OpenTelemetry tracer for span collection * - Automatic inclusion of conversation_id and user_id in metadata * - Configurable input/output recording for privacy control * * @param options - Optional configuration overrides * @returns Telemetry configuration for Vercel AI SDK * * @example * ```typescript * import { Moda } from 'moda-ai'; * import { generateText } from 'ai'; * import { openai } from '@ai-sdk/openai'; * * Moda.init('your-api-key'); * Moda.conversationId = 'conv_123'; * * const result = await generateText({ * model: openai('gpt-4o'), * prompt: 'Write a haiku about coding', * experimental_telemetry: Moda.getVercelAITelemetry(), * }); * ``` * * @example * ```typescript * // With custom options * const result = await generateText({ * model: openai('gpt-4o'), * prompt: 'Process this sensitive data', * experimental_telemetry: Moda.getVercelAITelemetry({ * recordInputs: false, // Don't record sensitive prompts * recordOutputs: false, // Don't record sensitive outputs * functionId: 'sensitive-processor', * metadata: { operation: 'pii-processing' }, * }), * }); * ``` */ declare function getVercelAITelemetry(options?: GetVercelAITelemetryOptions): VercelAITelemetryConfig; /** * TypeScript interfaces for Vapi end-of-call webhook payloads. * * These types represent the structure of data sent by Vapi when a call ends. */ interface VapiCustomer { number?: string; name?: string; } interface VapiToolCallFunction { name: string; arguments: string; } interface VapiToolCall { id: string; type: 'function'; function: VapiToolCallFunction; } interface VapiMessage { role?: 'system' | 'user' | 'assistant' | 'tool' | 'function'; content?: string; name?: string; tool_call_id?: string; tool_calls?: VapiToolCall[]; timestamp?: number; } interface VapiNode { id?: string; name?: string; messages?: VapiMessage[]; variables?: Record; } interface VapiTransfer { fromAssistant?: string; toAssistant?: string; status?: string; timestamp?: number; } interface VapiTurnLatency { turnIndex?: number; modelLatency?: number; voiceLatency?: number; transcriberLatency?: number; totalLatency?: number; startTime?: number; endTime?: number; } interface VapiPerformanceMetrics { turnLatencies?: VapiTurnLatency[]; } interface VapiCallArtifact { messages?: VapiMessage[]; messagesOpenAIFormatted?: Record[]; nodes?: VapiNode[]; variables?: Record; transfers?: VapiTransfer[]; performanceMetrics?: VapiPerformanceMetrics; } interface VapiCost { type: string; cost: number; } interface VapiCostWithDetails extends VapiCost { details?: Record; } interface VapiAnalysis { summary?: string; structuredData?: Record; successEvaluation?: string; } interface VapiTranscriptEntry { role?: string; message?: string; } interface VapiCall { id?: string; assistantId?: string; status?: string; duration?: number; endedReason?: string; cost?: number; startedAt?: string; endedAt?: string; customer?: VapiCustomer; artifact?: VapiCallArtifact; analysis?: VapiAnalysis; costs?: VapiCost[]; } interface VapiWebhookPayload { type?: string; call?: VapiCall; } interface VapiEndOfCallReport { type: 'end-of-call-report'; call: VapiCall; } interface VapiMessagePayload { type?: string; call?: VapiCall; transcript?: unknown; summary?: string; structuredData?: Record; analysis?: VapiAnalysis; artifact?: VapiCallArtifact; startedAt?: string; endedAt?: string; cost?: number; recordingUrl?: string; stereoRecordingUrl?: string; compliance?: Record; } interface VapiRealWebhookPayload { message?: VapiMessagePayload; } interface ExtractedTurn { index: number; userMessage?: VapiMessage; assistantMessage: VapiMessage; timing?: VapiTurnLatency; } interface ExtractedToolCall { name: string; id?: string; parameters?: string; result?: string; index: number; } interface ProcessVapiOptions { conversationId?: string; userId?: string; } /** * Span creation logic for Vapi call data. * * Creates OpenTelemetry spans with proper parent-child relationships. */ /** * Type guard to check if a webhook payload is an end-of-call report. * * Handles both the legacy format (top-level type/call) and the real VAPI * format (wrapped in a message object). */ declare function isEndOfCallReport(payload: Record): boolean; /** * Process a Vapi end-of-call report webhook and create OpenTelemetry spans. * * This function parses the webhook payload and creates: * - A parent span for the entire call (`vapi.call`) * - Child spans for each LLM turn (`vapi.turn.{index}`) * - Child spans for each tool execution (`vapi.tool.{name}`) * - Child spans for squad transfers (`vapi.transfer`) * * Handles both the real VAPI format (wrapped in a `message` object) and the * legacy format (top-level `type` and `call`). * * @example * ```typescript * import { Moda } from 'moda-ai'; * * Moda.init('moda_xxx'); * * // In your Express webhook handler * app.post('/webhooks/vapi', (req, res) => { * Moda.processVapiEndOfCallReport(req.body); * res.json({ status: 'ok' }); * }); * * // With custom conversation/user ID * Moda.processVapiEndOfCallReport(payload, { * conversationId: 'custom_session_123', * userId: 'user_456', * }); * ``` */ declare function processVapiEndOfCallReport(payload: Record, options?: ProcessVapiOptions): void; type OpenClawPrimitive = string | number | boolean; interface OpenClawTelemetryOptions { /** Moda API key (falls back to state/env when omitted) */ apiKey?: string; /** Moda OTLP endpoint base (falls back to state/env/default when omitted) */ baseUrl?: string; /** OpenTelemetry service name shown in telemetry backends */ serviceName?: string; /** Whether to emit traces from OpenClaw diagnostics plugin */ enableTraces?: boolean; /** Whether to emit metrics from OpenClaw diagnostics plugin */ enableMetrics?: boolean; /** Whether to emit logs from OpenClaw diagnostics plugin */ enableLogs?: boolean; /** Extra OTLP headers to attach */ additionalHeaders?: Record; } interface OpenClawTelemetryConfig { plugins: { allow: string[]; entries: Record; }; diagnostics: { enabled: boolean; otel: { enabled: boolean; endpoint: string; protocol: 'http/protobuf'; serviceName: string; traces: boolean; metrics: boolean; logs: boolean; headers: Record; }; }; } /** * Build an OpenClaw diagnostics configuration that exports OTLP data to Moda. * * This targets OpenClaw's `diagnostics-otel` plugin shape and uses Moda's OTLP * endpoint/auth defaults by default. */ declare function getOpenClawTelemetryConfig(options?: OpenClawTelemetryOptions): OpenClawTelemetryConfig; interface OpenClawEnvironmentOptions extends OpenClawTelemetryOptions { /** Additional environment variables to merge into the output map */ extraEnv?: Record; } /** * Build OTEL environment variables for launching OpenClaw with Moda telemetry. */ declare function getOpenClawEnvironment(options?: OpenClawEnvironmentOptions): Record; interface WithOpenClawOperationOptions { /** Operation name used in span name: `openclaw.` */ operation: string; /** Optional explicit conversation ID */ conversationId?: string; /** Optional explicit user ID */ userId?: string; /** Optional span attributes for operation metadata */ attributes?: Record; } type OpenClawOperationCallback = (context: { span: Span; }) => Promise | T; /** * Trace an OpenClaw operation (CLI or gateway lifecycle) with Moda attributes. */ declare function withOpenClawOperation(options: WithOpenClawOperationOptions, callback: OpenClawOperationCallback): Promise; /** * Set a dedicated tracer for Moda instrumentations. * This allows bypassing external providers (like Sentry) that may filter spans. */ declare function setModaTracer(tracer: Tracer): void; /** * Clear the dedicated Moda tracer. */ declare function clearModaTracer(): void; /** * Register all LLM client instrumentations. * This is called automatically by Moda.init() */ declare function registerInstrumentations(): Promise; /** * @moda/sdk - Official TypeScript/Node.js SDK for Moda LLM observability * * @example * ```typescript * import { Moda } from '@moda/sdk'; * * // Initialize the SDK * Moda.init('moda_your_api_key'); * * // All OpenAI/Anthropic calls are now automatically tracked * const openai = new OpenAI(); * await openai.chat.completions.create({ ... }); * * // Flush before exit * await Moda.flush(); * ``` */ /** * Create a standalone Moda TracerProvider that bypasses external providers (like Sentry). * Use this when Sentry or other OTEL providers filter out non-standard spans. */ declare function _createModaProvider(options: { apiKey: string; baseUrl?: string; debug?: boolean; batchSize?: number; flushInterval?: number; }): NodeTracerProvider; /** * Main Moda SDK object with all public methods */ declare const Moda: { /** * Initialize the Moda SDK with your API key * @see {@link init} */ init: typeof init; /** * Force flush all pending spans to the Moda backend * @see {@link flush} */ flush: typeof flush; /** * Shutdown the SDK and release all resources * @see {@link shutdown} */ shutdown: typeof shutdown; /** * Check if the SDK is initialized * @see {@link isInitialized} */ isInitialized: typeof isInitialized; /** * Set a global conversation ID for subsequent LLM calls * @see {@link setConversationId} */ setConversationId: typeof setConversationId; /** * Clear the global conversation ID * @see {@link clearConversationId} */ clearConversationId: typeof clearConversationId; /** * Set a global user ID for subsequent LLM calls * @see {@link setUserId} */ setUserId: typeof setUserId; /** * Clear the global user ID * @see {@link clearUserId} */ clearUserId: typeof clearUserId; /** * Get the OpenTelemetry tracer for custom spans * @see {@link getTracer} */ getTracer: typeof getTracer; /** * Manually trace an LLM call when using non-instrumented providers * @see {@link withLLMCall} */ withLLMCall: typeof withLLMCall; /** * Get telemetry configuration for Vercel AI SDK integration. * Returns a config object for the `experimental_telemetry` option. * @see {@link getVercelAITelemetry} * * @example * ```typescript * import { generateText } from 'ai'; * * const result = await generateText({ * model: openai('gpt-4o'), * prompt: 'Hello', * experimental_telemetry: Moda.getVercelAITelemetry(), * }); * ``` */ getVercelAITelemetry: typeof getVercelAITelemetry; /** * Build OpenClaw diagnostics config for exporting OTLP data to Moda. * @see {@link getOpenClawTelemetryConfig} */ getOpenClawTelemetryConfig: typeof getOpenClawTelemetryConfig; /** * Build OTEL environment variables for OpenClaw processes. * @see {@link getOpenClawEnvironment} */ getOpenClawEnvironment: typeof getOpenClawEnvironment; /** * Trace OpenClaw operations (CLI or gateway lifecycle) with Moda spans. * @see {@link withOpenClawOperation} */ withOpenClawOperation: typeof withOpenClawOperation; /** * Create a standalone Moda SpanProcessor for advanced OTEL setups. * Use when you need full control over your OpenTelemetry configuration. * @see {@link createModaSpanProcessor} */ createModaSpanProcessor: typeof createModaSpanProcessor; /** * Register OpenAI/Anthropic instrumentations for automatic LLM tracing. * Use with createModaProvider for Sentry integration. * * @example * ```javascript * Moda.createModaProvider({ apiKey: 'moda_xxx' }); * Moda.registerInstrumentations(); * ``` */ registerInstrumentations: typeof registerInstrumentations; /** * Create a standalone Moda TracerProvider that bypasses external providers (like Sentry). * Use this when Sentry or other OTEL providers filter out non-standard spans. * * @example * ```javascript * Moda.createModaProvider({ apiKey: 'moda_xxx' }); * Moda.registerInstrumentations(); * ``` */ createModaProvider: typeof _createModaProvider; /** * Process a Vapi end-of-call report webhook and create OpenTelemetry spans. * @see {@link processVapiEndOfCallReport} */ processVapiEndOfCallReport: typeof processVapiEndOfCallReport; /** * Check if a webhook payload is a Vapi end-of-call report. * @see {@link isEndOfCallReport} */ isEndOfCallReport: typeof isEndOfCallReport; /** * Get or set the global conversation ID. * Setting to null clears the conversation ID. * * @example * ```typescript * Moda.conversationId = 'session_123'; * await client.chat.completions.create({...}); * Moda.conversationId = null; // clear * ``` */ conversationId: string | null; /** * Get or set the global user ID. * Setting to null clears the user ID. * * @example * ```typescript * Moda.userId = 'user_456'; * await client.chat.completions.create({...}); * Moda.userId = null; // clear * ``` */ userId: string | null; }; export { DEFAULT_OPTIONS, Moda, clearConversationId, clearModaTracer, clearUserId, computeConversationId, _createModaProvider as createModaProvider, createModaSpanProcessor, Moda as default, flush, generateRandomConversationId, getContext, getEffectiveContext, getGlobalContext, getOpenClawEnvironment, getOpenClawTelemetryConfig, getTracer, getVercelAITelemetry, init, isEndOfCallReport, isInitialized, isValidConversationId, processVapiEndOfCallReport, setConversationId, setModaTracer, setUserId, shutdown, withContext, withConversationId, withLLMCall, withOpenClawOperation, withUserId }; export type { AnthropicContentBlock, AnthropicMessage, CompletionOption, ContentPart, ExtractedToolCall, ExtractedTurn, GetVercelAITelemetryOptions, LLMCallCallback, LLMSpanAttributes, LLMSpanHelper, Message, MessageContent, ModaContext, ModaInitOptions, ModaSpanProcessorOptions, ModaState, OpenAIContentPart, OpenAIMessage, OpenAIToolCall, OpenClawEnvironmentOptions, OpenClawOperationCallback, OpenClawTelemetryConfig, OpenClawTelemetryOptions, ProcessVapiOptions, ReportRequestOptions, ReportResponseOptions, VapiAnalysis, VapiCall, VapiCallArtifact, VapiCost, VapiCostWithDetails, VapiCustomer, VapiEndOfCallReport, VapiMessage, VapiMessagePayload, VapiNode, VapiPerformanceMetrics, VapiRealWebhookPayload, VapiToolCall, VapiToolCallFunction, VapiTranscriptEntry, VapiTransfer, VapiTurnLatency, VapiWebhookPayload, VercelAITelemetryConfig, VercelAITelemetryMetadata, WithLLMCallOptions, WithOpenClawOperationOptions };