import * as traceloop from '@traceloop/node-server-sdk'; import { Interaction, Tracer } from './interaction.js'; import { EvalSelection, MorphTracingConfig, TraceContext, MetadataOptions } from './types.js'; interface ResolvedConfig { apiKey: string; baseUrl: string; appName: string; disableBatching: boolean; traceContent: boolean; headers?: Record; debug: boolean; evals?: EvalSelection; } /** * Handle returned by {@link morphTracing}. Create interactions with `begin()`, * get a non-interactive `tracer()`, and flush/shutdown the exporter. */ declare class MorphTracing { private readonly cfg; private readonly active; readonly enabled: boolean; constructor(config?: MorphTracingConfig); /** * Begin a new traced interaction (a single user turn / agent run). On a * disabled instance this returns an inert no-op interaction — callbacks still * run, but no spans are created or shipped. */ begin(ctx: TraceContext & { userId: string; event?: string; }): Interaction; /** Look up an in-flight interaction by its eventId. */ getActiveInteraction(eventId: string): Interaction | undefined; /** * Non-interactive tracer for batch jobs where you only care about * spans/token usage, not a user-facing interaction. */ tracer(globalProperties?: Record): Tracer; /** Build Vercel AI SDK telemetry metadata (see `@morphllm/morphsdk/tracing/otel`). */ metadata(opts: MetadataOptions): Record; /** Span processor for `useExternalOtel: true` integrations. */ createSpanProcessor(options?: Parameters[0]): ReturnType; /** Flush any batched spans immediately. Safe to call when idle. */ forceFlush(): Promise; /** Flush and stop tracing. */ shutdown(): Promise; } /** * Initialize Morph Tracing and auto-instrument supported AI SDKs. * * Requires the optional OpenTelemetry / Traceloop backends (see this module's * README). They install automatically with the SDK unless optional deps are * skipped; importing `/tracing` without them throws a module-not-found error * naming the missing package. */ declare function morphTracing(config?: MorphTracingConfig): MorphTracing; export { MorphTracing, type ResolvedConfig, morphTracing };