{"version":3,"sources":["../../tracing/types.ts"],"sourcesContent":["/**\n * Morph Tracing — public types.\n *\n * Morph Tracing instruments the top AI SDKs (OpenAI, Anthropic, Vercel AI SDK,\n * Bedrock, Vertex, Cohere, Together, LangChain, LlamaIndex, …) and ships\n * OpenTelemetry spans to Morph. It is a thin, Morph-branded layer over\n * OpenLLMetry / Traceloop, exactly like `raindrop-ai` is.\n */\n\n/**\n * Modules to explicitly instrument. Pass the imported SDK module/constructor so\n * Traceloop patches the exact instance your app uses. If omitted, all supported\n * libraries are auto-instrumented.\n */\n/**\n * Reflexes (evals) to run automatically on a trace. You pick which role each model classifies:\n * `user` (the user's message) and/or `assistant` (the agent's output). Always explicit — there is\n * no implicit default, since a model run on the wrong role gives a meaningless label.\n *\n * @example evals: { user: [\"jailbreak\", \"guardrail\"] }\n * @example evals: { user: [\"jailbreak\"], assistant: [\"leaked-thinking\"] }\n */\nexport interface EvalSelection {\n  /** Reflexes to run on the user's message, e.g. [\"jailbreak\", \"guardrail\"]. */\n  user?: string[];\n  /** Reflexes to run on the agent's output, e.g. [\"leaked-thinking\", \"stuck-in-a-loop\"]. */\n  assistant?: string[];\n}\n\nexport interface InstrumentModules {\n  openAI?: unknown;\n  anthropic?: unknown;\n  cohere?: unknown;\n  bedrock?: unknown;\n  google_vertexai?: unknown;\n  google_aiplatform?: unknown;\n  pinecone?: unknown;\n  together?: unknown;\n  langchain?: boolean;\n  llamaIndex?: unknown;\n  chromadb?: unknown;\n  qdrant?: unknown;\n  mcp?: unknown;\n  [key: string]: unknown;\n}\n\nexport interface MorphTracingConfig {\n  /**\n   * Morph API key. Defaults to `process.env.MORPH_API_KEY`. Sent as\n   * `Authorization: Bearer <apiKey>` to the trace ingest endpoint.\n   */\n  apiKey?: string;\n  /**\n   * Base URL for the Morph ingest API. Traces are POSTed to `${baseUrl}/v1/traces`.\n   * Defaults to `process.env.MORPH_TRACES_URL` then `https://api.morphllm.com`.\n   */\n  baseUrl?: string;\n  /** Service/app name attached to every span. Defaults to the host package name. */\n  appName?: string;\n  /**\n   * When true, the SDK initializes nothing and ships nothing. Useful for tests\n   * and local/dev. Defaults to false.\n   */\n  disabled?: boolean;\n  /**\n   * Send spans immediately instead of batching. Defaults to true outside\n   * production (`NODE_ENV !== 'production'`) so local runs flush instantly.\n   */\n  disableBatching?: boolean;\n  /**\n   * Capture prompt/response content on spans. Set false for zero-data-retention.\n   * Defaults to true.\n   */\n  traceContent?: boolean;\n  /** Explicit modules to instrument. Omit to auto-instrument everything. */\n  instrumentModules?: InstrumentModules;\n  /**\n   * Set true when you run your own OpenTelemetry NodeSDK. Morph will not start\n   * its own SDK; instead use `getInstrumentations()` and `createSpanProcessor()`.\n   */\n  useExternalOtel?: boolean;\n  /** Extra headers merged onto the OTLP exporter request. */\n  headers?: Record<string, string>;\n  /** Verbose `[morph-tracing]` logging. Defaults to `MORPH_TRACING_DEBUG=1`. */\n  debug?: boolean;\n  /**\n   * Default evals to run on every interaction's trace. Overridable per-interaction via\n   * `begin({ evals })`. Requires `begin()` — evals only run on turns wrapped in an interaction\n   * (so the trace carries an event id). Omit for none.\n   */\n  evals?: EvalSelection;\n}\n\n/** Identity + content for a single traced AI interaction. */\nexport interface TraceContext {\n  /** Stable identifier for the interaction; auto-generated if omitted. */\n  eventId?: string;\n  /** End-user identifier. */\n  userId?: string;\n  /** Conversation/session identifier grouping related interactions. */\n  convoId?: string;\n  /** Event name (defaults to \"ai_generation\" on the backend). */\n  event?: string;\n  /** User input for this interaction. */\n  input?: string;\n  /** Arbitrary string metadata propagated onto spans. */\n  properties?: Record<string, string>;\n  /**\n   * Evals to run automatically on this interaction's trace. Results appear in the traces\n   * dashboard already labeled. Overrides any default set in `morphTracing({ evals })`.\n   * Omit to inherit the default (or run none).\n   */\n  evals?: EvalSelection;\n}\n\nexport interface SpanParams {\n  name: string;\n  properties?: Record<string, string>;\n}\n\nexport interface ToolParams {\n  name: string;\n  version?: number;\n  properties?: Record<string, string>;\n}\n\n/** Record a tool invocation that has already completed. */\nexport interface TrackToolParams {\n  name: string;\n  input?: unknown;\n  output?: unknown;\n  durationMs?: number;\n  error?: Error | string;\n  properties?: Record<string, string>;\n}\n\nexport interface FinishOptions {\n  output: string;\n  properties?: Record<string, string>;\n}\n\n/** A manual tool span the caller drives explicitly. */\nexport interface ToolSpan {\n  setInput(input: unknown): void;\n  setOutput(output: unknown): void;\n  setError(error: Error | string): void;\n  end(): void;\n}\n\n/** Metadata payload for the Vercel AI SDK `experimental_telemetry.metadata`. */\nexport interface MetadataOptions {\n  userId: string;\n  convoId?: string;\n  eventName?: string;\n  eventId?: string;\n  /** Custom tags, e.g. { source: \"support-bot\" } → association.properties.source */\n  properties?: Record<string, string>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}