{"version":3,"sources":["../../tracing/interaction.ts","../../tracing/otel.ts","../../tracing/reflex.ts"],"sourcesContent":["/**\n * Morph Tracing — interactions, tools, and manual spans.\n *\n * An `Interaction` is one user turn / agent run. It threads association\n * properties (user_id / convo_id / event_id) onto every span created inside it —\n * including the auto-instrumented LLM spans — so a whole conversation stitches\n * together in the Morph UI. Built on Traceloop's `withTask` / `withTool` and a\n * manual tracer for already-completed tool spans.\n */\nimport { context, SpanStatusCode, trace, type Span } from '@opentelemetry/api';\nimport * as traceloop from '@traceloop/node-server-sdk';\n\nimport { metadata as buildMetadata } from './otel.js';\nimport { REFLEX_RUN_ATTRIBUTE, serializeEvals } from './reflex.js';\nimport type {\n  FinishOptions,\n  SpanParams,\n  ToolParams,\n  ToolSpan,\n  TrackToolParams,\n  TraceContext,\n} from './types.js';\n\n// Traceloop semantic-convention attribute keys.\nconst ASSOC = 'traceloop.association.properties.';\nconst ENTITY_INPUT = 'traceloop.entity.input';\nconst ENTITY_OUTPUT = 'traceloop.entity.output';\nconst ENTITY_NAME = 'traceloop.entity.name';\nconst SPAN_KIND = 'traceloop.span.kind';\n\nfunction uuid(): string {\n  const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n  if (c?.randomUUID) return c.randomUUID();\n  return 'xxxxxxxxxxxx4xxxyxxx'.replace(/[xy]/g, (ch) => {\n    const r = (Math.random() * 16) | 0;\n    return (ch === 'x' ? r : (r & 0x3) | 0x8).toString(16);\n  });\n}\n\nfunction asString(v: unknown): string {\n  if (v == null) return '';\n  return typeof v === 'string' ? v : JSON.stringify(v);\n}\n\nexport interface Interaction {\n  getEventId(): string | undefined;\n  setInput(input: string): void;\n  setProperty(key: string, value: string): void;\n  setProperties(props: Record<string, string>): void;\n  /**\n   * Run `fn` with this interaction's association properties active — required so\n   * auto-instrumented OpenAI/Anthropic spans inherit user_id / convo_id / tags.\n   */\n  run<T>(fn: () => Promise<T> | T): Promise<T>;\n  /** Run `fn` inside a traced task span; LLM calls within inherit attribution. */\n  withSpan<T>(params: SpanParams | string, fn: () => Promise<T> | T): Promise<T>;\n  /** Run `fn` inside a traced tool span. */\n  withTool<T>(params: ToolParams | string, fn: () => Promise<T> | T): Promise<T>;\n  /** Start a tool span you end manually. */\n  startToolSpan(params: ToolParams | string): ToolSpan;\n  /** Record an already-completed tool invocation. */\n  trackTool(params: TrackToolParams): void;\n  /** Metadata for the Vercel AI SDK `experimental_telemetry.metadata`. */\n  vercelAiSdkMetadata(): Record<string, string>;\n  /** End the interaction with its final output. */\n  finish(opts: FinishOptions | string): Promise<void>;\n}\n\nexport type Tracer = Pick<Interaction, 'withSpan' | 'withTool' | 'startToolSpan' | 'trackTool'>;\n\n/** Build the association-property bag Traceloop propagates onto child spans. */\nfunction associationProps(\n  ctx: TraceContext & { userId?: string },\n  extra: Record<string, string>,\n): Record<string, string> {\n  const props: Record<string, string> = { ...extra };\n  if (ctx.userId) props.user_id = ctx.userId;\n  if (ctx.convoId) props.convo_id = ctx.convoId;\n  if (ctx.eventId) props.event_id = ctx.eventId;\n  if (ctx.event) props.event_name = ctx.event;\n  return props;\n}\n\nexport function createInteractionApi(\n  initial: TraceContext & { userId?: string },\n  traceContent: boolean,\n  onClose?: (eventId: string) => void,\n): Interaction {\n  const ctx: TraceContext & { userId?: string } = {\n    ...initial,\n    eventId: initial.eventId ?? uuid(),\n  };\n  const properties: Record<string, string> = { ...(initial.properties ?? {}) };\n  let input = initial.input;\n  let workflowSpan: Span | null = null;\n  let finished = false;\n  // Serialized once. Set as a raw attribute on the workflow span only — NOT an\n  // association property, so it is not copied onto every child LLM span. Ingest\n  // reads `morph.reflex.run` off the workflow-span to enqueue the evals.\n  const reflexRun = serializeEvals(initial.evals);\n\n  const withAssoc = <T>(fn: () => Promise<T> | T): Promise<T> | T =>\n    traceloop.withAssociationProperties(associationProps(ctx, properties), fn);\n\n  const workflowName = () => ctx.event ?? 'interaction';\n\n  /** Open the interaction workflow span once; stays active until finish(). */\n  function ensureWorkflowSpan(): Span {\n    if (workflowSpan) return workflowSpan;\n    const span = traceloop.getTraceloopTracer().startSpan(workflowName());\n    span.setAttribute(SPAN_KIND, 'workflow');\n    for (const [k, v] of Object.entries(associationProps(ctx, properties))) {\n      span.setAttribute(ASSOC + k, v);\n    }\n    if (traceContent && input) span.setAttribute(ENTITY_INPUT, input);\n    if (reflexRun) span.setAttribute(REFLEX_RUN_ATTRIBUTE, reflexRun);\n    workflowSpan = span;\n    return span;\n  }\n\n  /** Run fn with association props and the workflow span as the active parent. */\n  function withWorkflowContext<T>(fn: () => Promise<T> | T): Promise<T> | T {\n    return withAssoc(() => {\n      const span = ensureWorkflowSpan();\n      return context.with(trace.setSpan(context.active(), span), fn);\n    });\n  }\n\n  /** Close the workflow span exactly once, applying final attributes. */\n  function closeWorkflowSpan(apply: (span: Span) => void): void {\n    if (finished) return;\n    withAssoc(() => {\n      const span = ensureWorkflowSpan();\n      apply(span);\n      span.end();\n    });\n    workflowSpan = null;\n    finished = true;\n    onClose?.(ctx.eventId!);\n  }\n\n  /** Record an exception + ERROR status on the workflow span, then close it. */\n  function failWorkflowSpan(err: unknown): void {\n    const e = err instanceof Error ? err : new Error(String(err));\n    closeWorkflowSpan((span) => {\n      span.recordException(e);\n      span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n      if (traceContent) span.setAttribute(ENTITY_OUTPUT, `ERROR: ${e.message}`);\n    });\n  }\n\n  const toolName = (p: ToolParams | string) => (typeof p === 'string' ? p : p.name);\n\n  function startToolSpan(params: ToolParams | string): ToolSpan {\n    const name = toolName(params);\n    const span: Span = traceloop.getTraceloopTracer().startSpan(name);\n    span.setAttribute(SPAN_KIND, 'tool');\n    span.setAttribute(ENTITY_NAME, name);\n    for (const [k, v] of Object.entries(associationProps(ctx, properties))) {\n      span.setAttribute(ASSOC + k, v);\n    }\n    if (typeof params !== 'string' && params.properties) {\n      for (const [k, v] of Object.entries(params.properties)) span.setAttribute(k, v);\n    }\n    return {\n      setInput(value: unknown) {\n        if (traceContent) span.setAttribute(ENTITY_INPUT, asString(value));\n      },\n      setOutput(value: unknown) {\n        if (traceContent) span.setAttribute(ENTITY_OUTPUT, asString(value));\n      },\n      setError(error: Error | string) {\n        const e = typeof error === 'string' ? new Error(error) : error;\n        span.recordException(e);\n        span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n      },\n      end() {\n        span.end();\n      },\n    };\n  }\n\n  return {\n    getEventId: () => ctx.eventId,\n    setInput(value: string) {\n      input = value;\n    },\n    setProperty(key: string, value: string) {\n      properties[key] = value;\n    },\n    setProperties(props: Record<string, string>) {\n      Object.assign(properties, props);\n    },\n    vercelAiSdkMetadata() {\n      return buildMetadata({\n        userId: ctx.userId ?? 'unknown',\n        convoId: ctx.convoId,\n        eventName: ctx.event,\n        eventId: ctx.eventId,\n        properties,\n      });\n    },\n    async run(fn) {\n      try {\n        return await Promise.resolve(withWorkflowContext(fn));\n      } catch (err) {\n        // Natively record the failure on the workflow span and ship it, so a\n        // throwing interaction still lands in the trace as an errored span.\n        failWorkflowSpan(err);\n        throw err;\n      }\n    },\n    withSpan(params, fn) {\n      const name = typeof params === 'string' ? params : params.name;\n      return Promise.resolve(withWorkflowContext(() => traceloop.withTask({ name }, fn)));\n    },\n    withTool(params, fn) {\n      const name = toolName(params);\n      const version = typeof params === 'string' ? undefined : params.version;\n      return Promise.resolve(withWorkflowContext(() => traceloop.withTool({ name, version }, fn)));\n    },\n    startToolSpan,\n    trackTool(params: TrackToolParams) {\n      const span = startToolSpan({ name: params.name, properties: params.properties });\n      if (params.input !== undefined) span.setInput(params.input);\n      if (params.output !== undefined) span.setOutput(params.output);\n      if (params.error) span.setError(params.error);\n      span.end();\n    },\n    async finish(opts) {\n      const output = typeof opts === 'string' ? opts : opts.output;\n      if (typeof opts !== 'string' && opts.properties) Object.assign(properties, opts.properties);\n      // No-op if run() already closed the span on error; otherwise end it now.\n      // (Creates one if finish() is called alone, i.e. begin() → finish().)\n      closeWorkflowSpan((span) => {\n        if (traceContent) span.setAttribute(ENTITY_OUTPUT, output);\n      });\n    },\n  };\n}\n\n/**\n * Inert Interaction for disabled instances. Preserves control flow — run() /\n * withTool() still execute their callback and rethrow errors — but never touches\n * the tracer. Required because the OTel provider is a process-wide singleton: a\n * disabled instance that created real spans would ship them through whichever\n * enabled instance registered the provider.\n */\nexport function createNoopInteraction(initial: TraceContext & { userId?: string }): Interaction {\n  const ctx: TraceContext & { userId?: string } = {\n    ...initial,\n    eventId: initial.eventId ?? uuid(),\n  };\n  const properties: Record<string, string> = { ...(initial.properties ?? {}) };\n  const noopToolSpan: ToolSpan = { setInput() {}, setOutput() {}, setError() {}, end() {} };\n\n  return {\n    getEventId: () => ctx.eventId,\n    setInput() {},\n    setProperty(key: string, value: string) {\n      properties[key] = value;\n    },\n    setProperties(props: Record<string, string>) {\n      Object.assign(properties, props);\n    },\n    vercelAiSdkMetadata() {\n      return buildMetadata({\n        userId: ctx.userId ?? 'unknown',\n        convoId: ctx.convoId,\n        eventName: ctx.event,\n        eventId: ctx.eventId,\n        properties,\n      });\n    },\n    async run(fn) {\n      return await fn();\n    },\n    async withSpan(_params, fn) {\n      return await fn();\n    },\n    async withTool(_params, fn) {\n      return await fn();\n    },\n    startToolSpan: () => noopToolSpan,\n    trackTool() {},\n    async finish() {},\n  };\n}\n","/**\n * Morph Tracing — Vercel AI SDK helper.\n *\n * The Vercel AI SDK emits its own OpenTelemetry spans when you pass\n * `experimental_telemetry`. There is nothing to monkey-patch; instead you tag\n * each call with `metadata()` so Morph can attribute the resulting spans to a\n * user/conversation/event.\n *\n * @example\n * ```ts\n * import { generateText } from \"ai\";\n * import { metadata } from \"@morphllm/morphsdk/tracing/otel\";\n *\n * const res = await generateText({\n *   model: openai(\"gpt-4o\"),\n *   prompt: \"Hello!\",\n *   experimental_telemetry: {\n *     isEnabled: true,\n *     metadata: metadata({ userId: \"user-123\", convoId: \"convo-456\" }),\n *   },\n * });\n * ```\n */\nimport type { MetadataOptions } from './types.js';\n\n/**\n * Reserved metadata keys Morph owns. Custom `properties` can't overwrite these,\n * so attribution (user_id / convo_id / event_id) stays intact.\n *\n * The AI SDK stores metadata as `ai.telemetry.metadata.<key>`; Traceloop's span\n * processor copies them to `traceloop.association.properties.<key>`, which is\n * what ClickHouse views read. Use snake_case names (user_id, convo_id, …).\n */\nconst RESERVED_KEYS = new Set(['user_id', 'convo_id', 'event_id', 'event_name']);\n\nfunction uuid(): string {\n  // Node 18+ and modern runtimes expose globalThis.crypto.randomUUID.\n  const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n  if (c?.randomUUID) return c.randomUUID();\n  // Fallback: RFC4122-ish without crypto.\n  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n    const r = (Math.random() * 16) | 0;\n    const v = ch === 'x' ? r : (r & 0x3) | 0x8;\n    return v.toString(16);\n  });\n}\n\n/**\n * Build the metadata object for the Vercel AI SDK's\n * `experimental_telemetry.metadata`. The values are propagated to every span the\n * AI SDK creates for that call. Generate a fresh `eventId` per call for grouping.\n */\nexport function metadata(opts: MetadataOptions): Record<string, string> {\n  const result: Record<string, string> = {\n    user_id: opts.userId,\n    event_id: opts.eventId ?? uuid(),\n  };\n  if (opts.convoId) result.convo_id = opts.convoId;\n  if (opts.eventName) result.event_name = opts.eventName;\n  if (opts.properties) {\n    for (const [key, value] of Object.entries(opts.properties)) {\n      if (!RESERVED_KEYS.has(key)) result[key] = value;\n    }\n  }\n  return result;\n}\n\nexport default { metadata };\n","/**\n * Morph Tracing — eval selection (which Reflexes to run on a trace).\n *\n * The public API is `evals` (see {@link EvalSelection}): `{ user, assistant }` choosing which role\n * each model classifies. We deliberately keep the public surface to plain nouns and hide the wire\n * detail: the selection is serialized onto a single\n * `morph.reflex.run` attribute on the interaction's workflow span (NOT an association property,\n * so it is not copied onto child LLM spans), and the per-role choice maps to the backend's\n * transform ids. Morph's ingest reads that attribute and runs the classifications async; results\n * land in the traces dashboard already labeled.\n */\nimport type { EvalSelection } from './types.js';\n\n/** Raw span attribute key carrying the serialized selection (internal wire detail). */\nexport const REFLEX_RUN_ATTRIBUTE = 'morph.reflex.run';\n\n// Public role → backend transform id. `user` classifies the user's message, `assistant` the\n// agent's output. (Whole-conversation evals are not exposed yet.)\nconst USER_TRANSFORM = 'user_message';\nconst ASSISTANT_TRANSFORM = 'assistant_message';\n\n/** One serialized entry on the wire: the model alias and the transform to run it on. */\nexport interface EvalRunEntry {\n  model: string;\n  transform: string;\n}\n\n/**\n * Normalize a public `evals` selection into deduped `{ model, transform }` wire entries.\n * `user` models run on the user turn, `assistant` models on the agent turn. Drops blank models;\n * preserves first-seen order. Exported for tests and so callers can see exactly what runs.\n */\nexport function normalizeEvals(evals: EvalSelection | undefined): EvalRunEntry[] {\n  if (!evals) return [];\n  const out: EvalRunEntry[] = [];\n  const seen = new Set<string>();\n  const add = (models: string[] | undefined, transform: string): void => {\n    // Guard against a non-array (e.g. an untyped JS caller passing { user: \"jailbreak\" }) — iterating\n    // a string would emit one bogus entry per character. Types forbid this; this is runtime defense.\n    if (!Array.isArray(models)) return;\n    for (const raw of models) {\n      const model = typeof raw === 'string' ? raw.trim() : '';\n      if (!model) continue;\n      const key = `${model} ${transform}`;\n      if (seen.has(key)) continue;\n      seen.add(key);\n      out.push({ model, transform });\n    }\n  };\n  add(evals.user, USER_TRANSFORM);\n  add(evals.assistant, ASSISTANT_TRANSFORM);\n  return out;\n}\n\n/**\n * Serialize an `evals` selection to the `morph.reflex.run` attribute string, or `null` when\n * there is nothing to run (so the attribute is simply omitted and no classification is enqueued).\n */\nexport function serializeEvals(evals: EvalSelection | undefined): string | null {\n  const entries = normalizeEvals(evals);\n  return entries.length ? JSON.stringify(entries) : null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,iBAA0D;AAC1D,gBAA2B;;;ACuB3B,IAAM,gBAAgB,oBAAI,IAAI,CAAC,WAAW,YAAY,YAAY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