@latitude-data/telemetry 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +95 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +21 -21
- package/dist/index.js +95 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/sdk/redact.ts","../../../../src/env/env.ts","../../../../../../constants/src/tracing/segment.ts","../../../../../../constants/src/tracing/span.ts","../../../../../../constants/src/tracing/trace.ts","../../../../../../constants/src/tracing/index.ts","../../../../../../constants/src/ai.ts","../../../../../../constants/src/config.ts","../../../../../../constants/src/evaluations/shared.ts","../../../../../../constants/src/evaluations/human.ts","../../../../../../constants/src/evaluations/llm.ts","../../../../../../constants/src/evaluations/rule.ts","../../../../../../constants/src/evaluations/index.ts","../../../../../../constants/src/events/legacy.ts","../../../../../../constants/src/events/events.ts","../../../../../../constants/src/integrations.ts","../../../../../../constants/src/models.ts","../../../../../../constants/src/history.ts","../../../../../../constants/src/index.ts","../../../../src/instrumentations/manual.ts","../../../../src/instrumentations/latitude.ts","../../../../src/sdk/sdk.ts"],"sourcesContent":["import * as otel from '@opentelemetry/api'\nimport { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-node'\n\nexport interface RedactSpanProcessorOptions {\n attributes: (string | RegExp)[]\n mask?: (attribute: string, value: any) => string\n}\n\nexport class RedactSpanProcessor implements SpanProcessor {\n private options: RedactSpanProcessorOptions\n\n constructor(options: RedactSpanProcessorOptions) {\n this.options = options\n\n if (!options.mask) {\n this.options.mask = (_attribute: string, _value: any) => '******'\n }\n }\n\n onStart(_span: ReadableSpan, _context: otel.Context): void {\n // Noop\n }\n\n onEnd(span: ReadableSpan): void {\n Object.assign(span.attributes, this.redactAttributes(span.attributes))\n for (const event of span.events) {\n if (!event.attributes) continue\n Object.assign(event.attributes, this.redactAttributes(event.attributes))\n }\n for (const link of span.links) {\n if (!link.attributes) continue\n Object.assign(link.attributes, this.redactAttributes(link.attributes))\n }\n }\n\n forceFlush(): Promise<void> {\n return Promise.resolve()\n }\n\n shutdown(): Promise<void> {\n return Promise.resolve()\n }\n\n private shouldRedact(attribute: string) {\n return this.options.attributes.some((pattern) => {\n if (typeof pattern === 'string') {\n return attribute === pattern\n } else if (pattern instanceof RegExp) {\n return pattern.test(attribute)\n }\n return false\n })\n }\n\n private redactAttributes(attributes: otel.Attributes) {\n const redacted: otel.Attributes = {}\n\n for (const [key, value] of Object.entries(attributes)) {\n if (this.shouldRedact(key)) {\n redacted[key] = this.options.mask!(key, value)\n }\n }\n\n return redacted\n }\n}\n\nexport const DEFAULT_REDACT_SPAN_PROCESSOR = () =>\n new RedactSpanProcessor({\n attributes: [\n /^.*auth.*$/i,\n /^.*authorization.*$/i,\n /^(?!gen_ai\\.).*token.*$/i,\n /^.*secret.*$/i,\n /^.*key.*$/i,\n /^.*password.*$/i,\n /^.*cookie.*$/i,\n /^.*session.*$/i,\n /^.*credential.*$/i,\n /^.*signature.*$/i,\n /^.*oauth.*$/i,\n /^.*saml.*$/i,\n /^.*openid.*$/i,\n /^.*refresh.*$/i,\n /^.*jwt.*$/i,\n /^.*otp.*$/i,\n /^.*mfa.*$/i,\n /^.*csrf.*$/i,\n /^.*xsrf.*$/i,\n /^.*refresh.*$/i,\n /^.*x[-_]forwarded[-_]for.*$/i,\n /^.*x[-_]real[-_]ip.*$/i,\n ],\n })\n","const DEFAULT_GATEWAY_BASE_URL =\n {\n production: 'https://gateway.latitude.so',\n development: 'http://localhost:8787',\n test: 'http://localhost:8787',\n }[process.env.NODE_ENV ?? 'development'] ?? 'http://localhost:8787'\n\nfunction GET_GATEWAY_BASE_URL() {\n if (process.env.GATEWAY_BASE_URL) {\n return process.env.GATEWAY_BASE_URL\n }\n\n if (!process.env.GATEWAY_HOSTNAME) {\n return DEFAULT_GATEWAY_BASE_URL\n }\n\n const protocol = process.env.GATEWAY_SSL ? 'https' : 'http'\n const port = process.env.GATEWAY_PORT ?? (process.env.GATEWAY_SSL ? 443 : 80)\n const hostname = process.env.GATEWAY_HOSTNAME\n\n return `${protocol}://${hostname}:${port}`\n}\n\nexport const env = { GATEWAY_BASE_URL: GET_GATEWAY_BASE_URL() } as const\n","import { Message } from 'promptl-ai'\nimport { z } from 'zod'\nimport { DocumentType } from '../index'\nimport { LatitudePromptConfig } from '../latitudePromptSchema'\nimport { SpanStatus } from './span'\n\nexport enum SegmentSource {\n API = 'api',\n Playground = 'playground',\n Evaluation = 'evaluation', // Note: from prompts of llm evaluations\n Experiment = 'experiment',\n User = 'user',\n SharedPrompt = 'shared_prompt',\n AgentAsTool = 'agent_as_tool', // TODO(tracing): deprecated, use SegmentType.Document with DocumentType.Agent instead\n EmailTrigger = 'email_trigger',\n ScheduledTrigger = 'scheduled_trigger',\n}\n\nexport enum SegmentType {\n Document = 'document',\n Step = 'step',\n}\n\ntype BaseSegmentMetadata<T extends SegmentType = SegmentType> = {\n traceId: string\n segmentId: string\n type: T\n}\n\ntype StepSegmentMetadata = BaseSegmentMetadata<SegmentType.Step> & {\n configuration: LatitudePromptConfig // From the first completion span\n input: Message[] // From the first completion span\n // Fields below are optional if the spans had an error\n output?: Message[] // From the last completion span\n}\n\ntype DocumentSegmentMetadata = BaseSegmentMetadata<SegmentType.Document> &\n Omit<StepSegmentMetadata, keyof BaseSegmentMetadata<SegmentType.Step>> & {\n prompt: string // From the first segment span\n parameters: Record<string, unknown> // From the first segment span\n }\n\n// prettier-ignore\nexport type SegmentMetadata<T extends SegmentType = SegmentType> =\n T extends SegmentType.Document ? DocumentSegmentMetadata :\n T extends SegmentType.Step ? StepSegmentMetadata :\n never;\n\nexport type Segment<T extends SegmentType = SegmentType> = {\n id: string\n traceId: string\n parentId?: string // Parent segment identifier\n workspaceId: number\n apiKeyId: number\n externalId?: string // Custom user identifier from the first span or inherited from parent\n name: string // Enriched when ingested\n source: SegmentSource // From the first span or inherited from parent\n type: T\n status: SpanStatus // From the last span (errored spans have priority)\n message?: string // From the last span (errored spans have priority)\n logUuid?: string // TODO(tracing): temporal related log, remove when observability is ready\n commitUuid: string // From the first span or inherited from parent\n documentUuid: string // From the first span or inherited from parent. When running an llm evaluation this is the evaluation uuid and source is Evaluation\n documentHash: string // From the first completion span or current document\n documentType: DocumentType // From the first completion span or current document\n experimentUuid?: string // From the first span or inherited from parent\n provider: string // From the first completion span or current document\n model: string // From the first completion span or current document\n tokens: number // Aggregated tokens from all completion spans\n cost: number // Aggregated cost from all completion spans\n duration: number // Elapsed time between the first and last span\n startedAt: Date\n endedAt?: Date // From the last span when the segment is closed\n createdAt: Date\n updatedAt: Date\n}\n\nexport type SegmentWithDetails<T extends SegmentType = SegmentType> =\n Segment<T> & {\n metadata?: SegmentMetadata<T> // Metadata is optional if the segment has not ended, had an early error or it could not be uploaded\n }\n\nconst baseSegmentBaggageSchema = z.object({\n id: z.string(),\n parentId: z.string().optional(),\n source: z.nativeEnum(SegmentSource),\n})\nexport const segmentBaggageSchema = z.discriminatedUnion('type', [\n baseSegmentBaggageSchema.extend({\n type: z.literal(SegmentType.Document),\n data: z.object({\n logUuid: z.string().optional(), // TODO(tracing): temporal related log, remove when observability is ready\n commitUuid: z.string(),\n documentUuid: z.string(),\n experimentUuid: z.string().optional(),\n externalId: z.string().optional(),\n }),\n }),\n baseSegmentBaggageSchema.extend({\n type: z.literal(SegmentType.Step),\n data: z.undefined().optional(),\n }),\n])\n\n// prettier-ignore\nexport type SegmentBaggage<T extends SegmentType = SegmentType> = Extract<z.infer<typeof segmentBaggageSchema>, { type: T }>\n","export enum SpanKind {\n Internal = 'internal',\n Server = 'server',\n Client = 'client',\n Producer = 'producer',\n Consumer = 'consumer',\n}\n\n// Note: loosely based on OpenTelemetry GenAI semantic conventions\nexport enum SpanType {\n Tool = 'tool', // Note: asynchronous tools such as agents are conversation segments\n Completion = 'completion',\n Embedding = 'embedding',\n Retrieval = 'retrieval',\n Reranking = 'reranking',\n Http = 'http', // Note: raw HTTP requests and responses\n Segment = 'segment', // (Partial) Wrappers so spans belong to the same trace\n Unknown = 'unknown', // Other spans we don't care about\n}\n\nexport const GENAI_SPANS = [\n SpanType.Tool,\n SpanType.Completion,\n SpanType.Embedding,\n SpanType.Retrieval,\n SpanType.Reranking,\n]\n\nexport const HIDDEN_SPANS = [SpanType.Http, SpanType.Segment, SpanType.Unknown]\n\nexport enum SpanStatus {\n Unset = 'unset',\n Ok = 'ok',\n Error = 'error',\n}\n\n// Note: get span attribute keys from @opentelemetry/semantic-conventions/incubating\nexport type SpanAttribute = string | number | boolean\n\nexport type SpanEvent = {\n name: string\n timestamp: Date\n attributes?: Record<string, SpanAttribute>\n}\n\nexport type SpanLink = {\n traceId: string\n spanId: string\n attributes?: Record<string, SpanAttribute>\n}\n\ntype BaseSpanMetadata<T extends SpanType = SpanType> = {\n traceId: string\n spanId: string\n type: T\n attributes: Record<string, SpanAttribute>\n events: SpanEvent[]\n links: SpanLink[]\n}\n\ntype ToolSpanMetadata = BaseSpanMetadata<SpanType.Tool> & {\n name: string\n call: {\n id: string\n arguments: Record<string, unknown>\n }\n // Fields below are optional if the span had an error\n result?: {\n value: unknown\n isError: boolean\n }\n}\n\ntype CompletionSpanMetadata = BaseSpanMetadata<SpanType.Completion> & {\n provider: string\n model: string\n configuration: Record<string, unknown>\n input: Record<string, unknown>[]\n // Fields below are optional if the span had an error\n output?: Record<string, unknown>[]\n tokens?: {\n prompt: number\n cached: number\n reasoning: number\n completion: number\n }\n cost?: number // Enriched when ingested\n finishReason?: string\n}\n\ntype HttpSpanMetadata = BaseSpanMetadata<SpanType.Http> & {\n request: {\n method: string\n url: string\n headers: Record<string, string>\n body: string | Record<string, unknown>\n }\n // Fields below are optional if the span had an error\n response?: {\n status: number\n headers: Record<string, string>\n body: string | Record<string, unknown>\n }\n}\n\n// prettier-ignore\nexport type SpanMetadata<T extends SpanType = SpanType> =\n T extends SpanType.Tool ? ToolSpanMetadata :\n T extends SpanType.Completion ? CompletionSpanMetadata :\n T extends SpanType.Embedding ? BaseSpanMetadata<T> :\n T extends SpanType.Retrieval ? BaseSpanMetadata<T> :\n T extends SpanType.Reranking ? BaseSpanMetadata<T> :\n T extends SpanType.Http ? HttpSpanMetadata :\n T extends SpanType.Segment ? BaseSpanMetadata<T> :\n T extends SpanType.Unknown ? BaseSpanMetadata<T> :\n never;\n\nexport type Span<T extends SpanType = SpanType> = {\n id: string\n traceId: string\n segmentId?: string\n parentId?: string // Parent span identifier\n workspaceId: number\n apiKeyId: number\n name: string\n kind: SpanKind\n type: T\n status: SpanStatus\n message?: string\n duration: number\n startedAt: Date\n endedAt: Date\n createdAt: Date\n updatedAt: Date\n}\n\nexport type SpanWithDetails<T extends SpanType = SpanType> = Span<T> & {\n metadata?: SpanMetadata<T> // Metadata is optional if it could not be uploaded\n}\n","import { z } from 'zod'\nimport { Segment, SegmentBaggage, SegmentType } from './segment'\nimport { Span, SpanType } from './span'\n\n// Note: Traces are unmaterialized but this context is used to propagate the trace\n// See www.w3.org/TR/trace-context and w3c.github.io/baggage\nexport const traceContextSchema = z.object({\n traceparent: z.string(), // <version>-<trace-id>-<span-id>-<trace-flags>\n tracestate: z.string().optional(), // <key>=urlencoded(<value>)[,<key>=urlencoded(<value>)]*\n baggage: z.string().optional(), // <key>=urlencoded(<value>)[,<key>=urlencoded(<value>)]*\n})\nexport type TraceContext = z.infer<typeof traceContextSchema>\n\nexport type TraceBaggage = {\n segment: Pick<SegmentBaggage, 'id' | 'parentId'> // Note: helper for third-party observability services\n segments: (SegmentBaggage &\n Pick<TraceContext, 'traceparent' | 'tracestate'> & {\n paused?: boolean\n })[]\n}\n\nexport type AssembledSpan<T extends SpanType = SpanType> = Span<T> & {\n class: 'span'\n parts: AssembledSpan[]\n}\n\nexport type AssembledSegment<T extends SegmentType = SegmentType> =\n Segment<T> & {\n class: 'segment'\n parts: (AssembledSegment | AssembledSpan)[]\n }\n\n// Note: full trace structure ready to be drawn, parts are ordered by timestamp\nexport type AssembledTrace = {\n id: string\n parts: (AssembledSegment | AssembledSpan)[]\n}\n","import { z } from 'zod'\n\nexport * from './segment'\nexport * from './span'\nexport * from './trace'\n\n/* Note: Instrumentation scopes from all language SDKs */\n\nexport const SCOPE_LATITUDE = 'so.latitude.instrumentation'\n\nexport enum InstrumentationScope {\n Manual = 'manual',\n Latitude = 'latitude',\n OpenAI = 'openai',\n Anthropic = 'anthropic',\n AzureOpenAI = 'azure',\n VercelAI = 'vercelai',\n VertexAI = 'vertexai',\n AIPlatform = 'aiplatform',\n MistralAI = 'mistralai', // Only python\n Bedrock = 'bedrock',\n Sagemaker = 'sagemaker', // Only python\n TogetherAI = 'togetherai',\n Replicate = 'replicate', // Only python\n Groq = 'groq', // Only python\n Cohere = 'cohere',\n LiteLLM = 'litellm', // Only python\n Langchain = 'langchain',\n LlamaIndex = 'llamaindex',\n DSPy = 'dspy', // Only python\n Haystack = 'haystack', // Only python\n Ollama = 'ollama', // Only python\n Transformers = 'transformers', // Only python\n AlephAlpha = 'alephalpha', // Only python\n}\n\n/* Note: non-standard OpenTelemetry semantic conventions used in Latitude */\n\nconst ATTR_LATITUDE = 'latitude'\n\nexport const ATTR_LATITUDE_TYPE = `${ATTR_LATITUDE}.type`\n\nexport const ATTR_LATITUDE_SEGMENT_ID = `${ATTR_LATITUDE}.segment.id`\nexport const ATTR_LATITUDE_SEGMENT_PARENT_ID = `${ATTR_LATITUDE}.segment.parent_id`\nexport const ATTR_LATITUDE_SEGMENTS = `${ATTR_LATITUDE}.segments`\n\nexport const GEN_AI_TOOL_TYPE_VALUE_FUNCTION = 'function'\nexport const ATTR_GEN_AI_TOOL_CALL_ARGUMENTS = 'gen_ai.tool.call.arguments'\nexport const ATTR_GEN_AI_TOOL_RESULT_VALUE = 'gen_ai.tool.result.value'\nexport const ATTR_GEN_AI_TOOL_RESULT_IS_ERROR = 'gen_ai.tool.result.is_error'\n\nexport const ATTR_GEN_AI_REQUEST = 'gen_ai.request'\nexport const ATTR_GEN_AI_REQUEST_CONFIGURATION = 'gen_ai.request.configuration'\nexport const ATTR_GEN_AI_REQUEST_TEMPLATE = 'gen_ai.request.template'\nexport const ATTR_GEN_AI_REQUEST_PARAMETERS = 'gen_ai.request.parameters'\nexport const ATTR_GEN_AI_REQUEST_MESSAGES = 'gen_ai.request.messages'\nexport const ATTR_GEN_AI_RESPONSE = 'gen_ai.response'\nexport const ATTR_GEN_AI_RESPONSE_MESSAGES = 'gen_ai.response.messages'\n\nexport const ATTR_GEN_AI_USAGE_PROMPT_TOKENS = 'gen_ai.usage.prompt_tokens'\nexport const ATTR_GEN_AI_USAGE_CACHED_TOKENS = 'gen_ai.usage.cached_tokens'\nexport const ATTR_GEN_AI_USAGE_REASONING_TOKENS = 'gen_ai.usage.reasoning_tokens' // prettier-ignore\nexport const ATTR_GEN_AI_USAGE_COMPLETION_TOKENS = 'gen_ai.usage.completion_tokens' // prettier-ignore\n\nexport const ATTR_GEN_AI_PROMPTS = 'gen_ai.prompt' // gen_ai.prompt.{index}.{role/content/...}\nexport const ATTR_GEN_AI_COMPLETIONS = 'gen_ai.completion' // gen_ai.completion.{index}.{role/content/...}\nexport const ATTR_GEN_AI_MESSAGE_ROLE = 'role'\nexport const ATTR_GEN_AI_MESSAGE_CONTENT = 'content' // string or object\nexport const ATTR_GEN_AI_MESSAGE_TOOL_NAME = 'tool_name'\nexport const ATTR_GEN_AI_MESSAGE_TOOL_CALL_ID = 'tool_call_id'\nexport const ATTR_GEN_AI_MESSAGE_TOOL_RESULT_IS_ERROR = 'is_error'\nexport const ATTR_GEN_AI_MESSAGE_TOOL_CALLS = 'tool_calls' // gen_ai.completion.{index}.tool_calls.{index}.{id/name/arguments}\nexport const ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ID = 'id'\nexport const ATTR_GEN_AI_MESSAGE_TOOL_CALLS_NAME = 'name'\nexport const ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS = 'arguments'\n\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_STOP = 'stop'\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_TOOL_CALLS = 'tool_calls'\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_LENGTH = 'length'\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_ERROR = 'error'\n\nexport const ATTR_HTTP_REQUEST_URL = 'http.request.url'\nexport const ATTR_HTTP_REQUEST_BODY = 'http.request.body'\nexport const ATTR_HTTP_REQUEST_HEADERS = 'http.request.header'\nexport const ATTR_HTTP_RESPONSE_BODY = 'http.response.body'\nexport const ATTR_HTTP_RESPONSE_HEADERS = 'http.response.header'\n\n/* Note: non-standard OpenTelemetry semantic conventions used in other systems */\n\n// https://github.com/Arize-ai/phoenix/blob/main/src/phoenix/trace/schemas.py\nexport const GEN_AI_OPERATION_NAME_VALUE_TOOL = 'tool'\nexport const GEN_AI_OPERATION_NAME_VALUE_COMPLETION = 'completion'\nexport const GEN_AI_OPERATION_NAME_VALUE_EMBEDDING = 'embedding'\nexport const GEN_AI_OPERATION_NAME_VALUE_RETRIEVAL = 'retrieval'\nexport const GEN_AI_OPERATION_NAME_VALUE_RERANKING = 'reranking'\n\n// https://github.com/traceloop/openllmetry/blob/main/packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py\nexport const ATTR_LLM_REQUEST_TYPE = 'llm.request.type'\nexport const LLM_REQUEST_TYPE_VALUE_COMPLETION = 'completion'\nexport const LLM_REQUEST_TYPE_VALUE_CHAT = 'chat'\nexport const LLM_REQUEST_TYPE_VALUE_EMBEDDING = 'embedding'\nexport const LLM_REQUEST_TYPE_VALUE_RERANK = 'rerank'\n\n/* Note: Schemas for span ingestion following OpenTelemetry service request specification */\n\nexport namespace Otlp {\n export const attributeValueSchema = z.object({\n stringValue: z.string().optional(),\n intValue: z.number().optional(),\n boolValue: z.boolean().optional(),\n arrayValue: z\n .object({\n values: z.array(\n z.object({\n stringValue: z.string().optional(),\n intValue: z.number().optional(),\n boolValue: z.boolean().optional(),\n }),\n ),\n })\n .optional(),\n })\n export type AttributeValue = z.infer<typeof attributeValueSchema>\n\n export const attributeSchema = z.object({\n key: z.string(),\n value: attributeValueSchema,\n })\n export type Attribute = z.infer<typeof attributeSchema>\n\n export const eventSchema = z.object({\n name: z.string(),\n timeUnixNano: z.string(),\n attributes: z.array(attributeSchema).optional(),\n })\n export type Event = z.infer<typeof eventSchema>\n\n export const linkSchema = z.object({\n traceId: z.string(),\n spanId: z.string(),\n attributes: z.array(attributeSchema).optional(),\n })\n export type Link = z.infer<typeof linkSchema>\n\n export const statusSchema = z.object({\n code: z.number(),\n message: z.string().optional(),\n })\n export type Status = z.infer<typeof statusSchema>\n\n export const spanSchema = z.object({\n traceId: z.string(),\n spanId: z.string(),\n parentSpanId: z.string().optional(),\n name: z.string(),\n kind: z.number(),\n startTimeUnixNano: z.string(),\n endTimeUnixNano: z.string(),\n status: statusSchema.optional(),\n events: z.array(eventSchema).optional(),\n links: z.array(linkSchema).optional(),\n attributes: z.array(attributeSchema).optional(),\n })\n export type Span = z.infer<typeof spanSchema>\n\n export const scopeSchema = z.object({\n name: z.string(),\n version: z.string().optional(),\n })\n export type Scope = z.infer<typeof scopeSchema>\n\n export const scopeSpanSchema = z.object({\n scope: scopeSchema,\n spans: z.array(spanSchema),\n })\n export type ScopeSpan = z.infer<typeof scopeSpanSchema>\n\n export const resourceSchema = z.object({\n attributes: z.array(attributeSchema),\n })\n export type Resource = z.infer<typeof resourceSchema>\n\n export const resourceSpanSchema = z.object({\n resource: resourceSchema,\n scopeSpans: z.array(scopeSpanSchema),\n })\n export type ResourceSpan = z.infer<typeof resourceSpanSchema>\n\n export const serviceRequestSchema = z.object({\n resourceSpans: z.array(resourceSpanSchema),\n })\n export type ServiceRequest = z.infer<typeof serviceRequestSchema>\n}\n","import { Message, ToolCall } from '@latitude-data/compiler'\nimport { Tool, FinishReason, LanguageModelUsage, TextStreamPart } from 'ai'\nimport { JSONSchema7 } from 'json-schema'\nimport { z } from 'zod'\n\nimport { ProviderLog } from './models'\nimport { LatitudeEventData, LegacyChainEventTypes } from './events'\nimport { ParameterType } from './config'\nimport { AzureConfig, LatitudePromptConfig } from './latitudePromptSchema'\nimport { TraceContext } from './tracing/trace'\n\nexport type AgentToolsMap = Record<string, string> // { [toolName]: agentPath }\n\nexport type ToolDefinition = JSONSchema7 & {\n description: string\n parameters: {\n type: 'object'\n properties: Record<string, JSONSchema7>\n required?: string[]\n additionalProperties: boolean\n }\n}\n\nexport type VercelProviderTool = {\n type: 'provider-defined'\n id: `${string}.${string}`\n args: Record<string, unknown>\n parameters: z.ZodObject<{}, 'strip', z.ZodTypeAny, {}, {}>\n}\n\nexport type VercelTools = Record<string, VercelProviderTool | ToolDefinition>\n\nexport type ToolDefinitionsMap = Record<string, ToolDefinition>\nexport type ToolsItem =\n | ToolDefinitionsMap // - tool_name: <tool_definition>\n | string // - latitude/* (no spaces)\n\n// Config supported by Vercel\nexport type VercelConfig = {\n provider: string\n model: string\n url?: string\n cacheControl?: boolean\n schema?: JSONSchema7\n parameters?: Record<string, { type: ParameterType }>\n tools?: VercelTools\n azure?: AzureConfig\n}\n\nexport type PartialPromptConfig = Omit<LatitudePromptConfig, 'provider'>\n\nexport type ProviderData = TextStreamPart<Record<string, Tool>>\n\nexport type ChainEventDto = ProviderData | LatitudeEventData\n\nexport type ChainCallResponseDto =\n | Omit<ChainStepResponse<'object'>, 'documentLogUuid' | 'providerLog'>\n | Omit<ChainStepResponse<'text'>, 'documentLogUuid' | 'providerLog'>\n\nexport type ChainEventDtoResponse =\n | Omit<ChainStepResponse<'object'>, 'providerLog'>\n | Omit<ChainStepResponse<'text'>, 'providerLog'>\n\nexport type StreamType = 'object' | 'text'\ntype BaseResponse = {\n text: string\n usage: LanguageModelUsage\n documentLogUuid?: string\n providerLog?: ProviderLog\n}\n\nexport type ChainStepTextResponse = BaseResponse & {\n streamType: 'text'\n reasoning?: string | undefined\n toolCalls: ToolCall[]\n}\n\nexport type ChainStepObjectResponse = BaseResponse & {\n streamType: 'object'\n object: any\n}\n\nexport type ChainStepResponse<T extends StreamType> = T extends 'text'\n ? ChainStepTextResponse\n : T extends 'object'\n ? ChainStepObjectResponse\n : never\n\nexport enum StreamEventTypes {\n Latitude = 'latitude-event',\n Provider = 'provider-event',\n}\n\nexport type LegacyChainEvent =\n | {\n data: LegacyLatitudeEventData\n event: StreamEventTypes.Latitude\n }\n | {\n data: ProviderData\n event: StreamEventTypes.Provider\n }\n\nexport type LegacyLatitudeStepEventData = {\n type: LegacyChainEventTypes.Step\n config: LatitudePromptConfig\n isLastStep: boolean\n messages: Message[]\n documentLogUuid?: string\n}\n\nexport type LegacyLatitudeStepCompleteEventData = {\n type: LegacyChainEventTypes.StepComplete\n response: ChainStepResponse<StreamType>\n documentLogUuid?: string\n}\n\nexport type LegacyLatitudeChainCompleteEventData = {\n type: LegacyChainEventTypes.Complete\n config: LatitudePromptConfig\n messages?: Message[]\n object?: any\n response: ChainStepResponse<StreamType>\n finishReason: FinishReason\n documentLogUuid?: string\n}\n\nexport type LegacyLatitudeChainErrorEventData = {\n type: LegacyChainEventTypes.Error\n error: Error\n}\n\nexport type LegacyLatitudeEventData =\n | LegacyLatitudeStepEventData\n | LegacyLatitudeStepCompleteEventData\n | LegacyLatitudeChainCompleteEventData\n | LegacyLatitudeChainErrorEventData\n\nexport type RunSyncAPIResponse = {\n uuid: string\n conversation: Message[]\n toolRequests: ToolCall[]\n response: ChainCallResponseDto\n agentResponse?: { response: string } | Record<string, unknown>\n trace: TraceContext\n}\n\nexport type ChatSyncAPIResponse = RunSyncAPIResponse\n\nexport const toolCallResponseSchema = z.object({\n id: z.string(),\n name: z.string(),\n result: z.unknown(),\n isError: z.boolean().optional(),\n text: z.string().optional(),\n})\n\nexport type ToolCallResponse = z.infer<typeof toolCallResponseSchema>\n","export enum ParameterType {\n Text = 'text',\n Image = 'image',\n File = 'file',\n}\n\nexport const LATITUDE_TOOL_PREFIX = 'lat_tool'\nexport const AGENT_TOOL_PREFIX = 'lat_agent'\nexport const AGENT_RETURN_TOOL_NAME = 'end_autonomous_chain'\nexport const FAKE_AGENT_START_TOOL_NAME = 'start_autonomous_chain'\n\nexport enum LatitudeTool {\n RunCode = 'code',\n WebSearch = 'search',\n WebExtract = 'extract',\n}\n\nexport enum LatitudeToolInternalName {\n RunCode = 'lat_tool_run_code',\n WebSearch = 'lat_tool_web_search',\n WebExtract = 'lat_tool_web_extract',\n}\n\nexport const MAX_STEPS_CONFIG_NAME = 'maxSteps'\nexport const DEFAULT_MAX_STEPS = 20\nexport const ABSOLUTE_MAX_STEPS = 150\n","import { z } from 'zod'\n\nconst actualOutputConfiguration = z.object({\n messageSelection: z.enum(['last', 'all']), // Which assistant messages to select\n contentFilter: z.enum(['text', 'image', 'file', 'tool_call']).optional(),\n parsingFormat: z.enum(['string', 'json']),\n fieldAccessor: z.string().optional(), // Field accessor to get the output from if it's a key-value format\n})\nexport type ActualOutputConfiguration = z.infer<\n typeof actualOutputConfiguration\n>\n\nconst expectedOutputConfiguration = z.object({\n parsingFormat: z.enum(['string', 'json']),\n fieldAccessor: z.string().optional(), // Field accessor to get the output from if it's a key-value format\n})\nexport type ExpectedOutputConfiguration = z.infer<\n typeof expectedOutputConfiguration\n>\n\nexport const ACCESSIBLE_OUTPUT_FORMATS = ['json']\n\nexport const baseEvaluationConfiguration = z.object({\n reverseScale: z.boolean(), // If true, lower is better, otherwise, higher is better\n actualOutput: actualOutputConfiguration.optional(), // Optional for backwards compatibility\n expectedOutput: expectedOutputConfiguration.optional(), // Optional for backwards compatibility\n})\nexport const baseEvaluationResultMetadata = z.object({\n // Configuration snapshot is defined in every metric specification\n actualOutput: z.string(),\n expectedOutput: z.string().optional(),\n datasetLabel: z.string().optional(),\n})\nexport const baseEvaluationResultError = z.object({\n message: z.string(),\n})\n","import { z } from 'zod'\nimport {\n baseEvaluationConfiguration,\n baseEvaluationResultError,\n baseEvaluationResultMetadata,\n} from './shared'\n\nconst humanEvaluationConfiguration = baseEvaluationConfiguration.extend({\n criteria: z.string().optional(),\n})\nconst humanEvaluationResultMetadata = baseEvaluationResultMetadata.extend({\n reason: z.string().optional(),\n})\nconst humanEvaluationResultError = baseEvaluationResultError.extend({})\n\n// BINARY\n\nconst humanEvaluationBinaryConfiguration = humanEvaluationConfiguration.extend({\n passDescription: z.string().optional(),\n failDescription: z.string().optional(),\n})\nconst humanEvaluationBinaryResultMetadata =\n humanEvaluationResultMetadata.extend({\n configuration: humanEvaluationBinaryConfiguration,\n })\nconst humanEvaluationBinaryResultError = humanEvaluationResultError.extend({})\nexport const HumanEvaluationBinarySpecification = {\n name: 'Binary',\n description:\n 'Judges whether the response meets the criteria. The resulting score is \"passed\" or \"failed\"',\n configuration: humanEvaluationBinaryConfiguration,\n resultMetadata: humanEvaluationBinaryResultMetadata,\n resultError: humanEvaluationBinaryResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: false,\n supportsManualEvaluation: true,\n} as const\nexport type HumanEvaluationBinaryConfiguration = z.infer<\n typeof HumanEvaluationBinarySpecification.configuration\n>\nexport type HumanEvaluationBinaryResultMetadata = z.infer<\n typeof HumanEvaluationBinarySpecification.resultMetadata\n>\nexport type HumanEvaluationBinaryResultError = z.infer<\n typeof HumanEvaluationBinarySpecification.resultError\n>\n\n// RATING\n\nconst humanEvaluationRatingConfiguration = humanEvaluationConfiguration.extend({\n minRating: z.number(),\n minRatingDescription: z.string().optional(),\n maxRating: z.number(),\n maxRatingDescription: z.string().optional(),\n minThreshold: z.number().optional(), // Threshold in rating range\n maxThreshold: z.number().optional(), // Threshold in rating range\n})\nconst humanEvaluationRatingResultMetadata =\n humanEvaluationResultMetadata.extend({\n configuration: humanEvaluationRatingConfiguration,\n })\nconst humanEvaluationRatingResultError = humanEvaluationResultError.extend({})\nexport const HumanEvaluationRatingSpecification = {\n name: 'Rating',\n description:\n 'Judges the response by rating it under a criteria. The resulting score is the rating',\n configuration: humanEvaluationRatingConfiguration,\n resultMetadata: humanEvaluationRatingResultMetadata,\n resultError: humanEvaluationRatingResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: false,\n supportsManualEvaluation: true,\n} as const\nexport type HumanEvaluationRatingConfiguration = z.infer<\n typeof HumanEvaluationRatingSpecification.configuration\n>\nexport type HumanEvaluationRatingResultMetadata = z.infer<\n typeof HumanEvaluationRatingSpecification.resultMetadata\n>\nexport type HumanEvaluationRatingResultError = z.infer<\n typeof HumanEvaluationRatingSpecification.resultError\n>\n\n/* ------------------------------------------------------------------------- */\n\nexport enum HumanEvaluationMetric {\n Binary = 'binary',\n Rating = 'rating',\n}\n\n// prettier-ignore\nexport type HumanEvaluationConfiguration<M extends HumanEvaluationMetric = HumanEvaluationMetric> =\n M extends HumanEvaluationMetric.Binary ? HumanEvaluationBinaryConfiguration :\n M extends HumanEvaluationMetric.Rating ? HumanEvaluationRatingConfiguration :\n never;\n\n// prettier-ignore\nexport type HumanEvaluationResultMetadata<M extends HumanEvaluationMetric = HumanEvaluationMetric> =\n M extends HumanEvaluationMetric.Binary ? HumanEvaluationBinaryResultMetadata :\n M extends HumanEvaluationMetric.Rating ? HumanEvaluationRatingResultMetadata :\n never;\n\n// prettier-ignore\nexport type HumanEvaluationResultError<M extends HumanEvaluationMetric = HumanEvaluationMetric> =\n M extends HumanEvaluationMetric.Binary ? HumanEvaluationBinaryResultError :\n M extends HumanEvaluationMetric.Rating ? HumanEvaluationRatingResultError :\n never;\n\nexport const HumanEvaluationSpecification = {\n name: 'Human-in-the-Loop',\n description: 'Evaluate responses using a human as a judge',\n configuration: humanEvaluationConfiguration,\n resultMetadata: humanEvaluationResultMetadata,\n resultError: humanEvaluationResultError,\n // prettier-ignore\n metrics: {\n [HumanEvaluationMetric.Binary]: HumanEvaluationBinarySpecification,\n [HumanEvaluationMetric.Rating]: HumanEvaluationRatingSpecification,\n },\n} as const\n","import { z } from 'zod'\nimport {\n baseEvaluationConfiguration,\n baseEvaluationResultError,\n baseEvaluationResultMetadata,\n} from './shared'\n\nconst llmEvaluationConfiguration = baseEvaluationConfiguration.extend({\n provider: z.string(),\n model: z.string(),\n})\nconst llmEvaluationResultMetadata = baseEvaluationResultMetadata.extend({\n evaluationLogId: z.number(),\n reason: z.string(),\n tokens: z.number(),\n cost: z.number(),\n duration: z.number(),\n})\nconst llmEvaluationResultError = baseEvaluationResultError.extend({\n runErrorId: z.number().optional(),\n})\n\n// BINARY\n\nconst llmEvaluationBinaryConfiguration = llmEvaluationConfiguration.extend({\n criteria: z.string(),\n passDescription: z.string(),\n failDescription: z.string(),\n})\nconst llmEvaluationBinaryResultMetadata = llmEvaluationResultMetadata.extend({\n configuration: llmEvaluationBinaryConfiguration,\n})\nconst llmEvaluationBinaryResultError = llmEvaluationResultError.extend({})\nexport const LlmEvaluationBinarySpecification = {\n name: 'Binary',\n description:\n 'Judges whether the response meets the criteria. The resulting score is \"passed\" or \"failed\"',\n configuration: llmEvaluationBinaryConfiguration,\n resultMetadata: llmEvaluationBinaryResultMetadata,\n resultError: llmEvaluationBinaryResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type LlmEvaluationBinaryConfiguration = z.infer<\n typeof LlmEvaluationBinarySpecification.configuration\n>\nexport type LlmEvaluationBinaryResultMetadata = z.infer<\n typeof LlmEvaluationBinarySpecification.resultMetadata\n>\nexport type LlmEvaluationBinaryResultError = z.infer<\n typeof LlmEvaluationBinarySpecification.resultError\n>\n\n// RATING\n\nconst llmEvaluationRatingConfiguration = llmEvaluationConfiguration.extend({\n criteria: z.string(),\n minRating: z.number(),\n minRatingDescription: z.string(),\n maxRating: z.number(),\n maxRatingDescription: z.string(),\n minThreshold: z.number().optional(), // Threshold in rating range\n maxThreshold: z.number().optional(), // Threshold in rating range\n})\nconst llmEvaluationRatingResultMetadata = llmEvaluationResultMetadata.extend({\n configuration: llmEvaluationRatingConfiguration,\n})\nconst llmEvaluationRatingResultError = llmEvaluationResultError.extend({})\nexport const LlmEvaluationRatingSpecification = {\n name: 'Rating',\n description:\n 'Judges the response by rating it under a criteria. The resulting score is the rating',\n configuration: llmEvaluationRatingConfiguration,\n resultMetadata: llmEvaluationRatingResultMetadata,\n resultError: llmEvaluationRatingResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type LlmEvaluationRatingConfiguration = z.infer<\n typeof LlmEvaluationRatingSpecification.configuration\n>\nexport type LlmEvaluationRatingResultMetadata = z.infer<\n typeof LlmEvaluationRatingSpecification.resultMetadata\n>\nexport type LlmEvaluationRatingResultError = z.infer<\n typeof LlmEvaluationRatingSpecification.resultError\n>\n\n// COMPARISON\n\nconst llmEvaluationComparisonConfiguration = llmEvaluationConfiguration.extend({\n criteria: z.string(),\n passDescription: z.string(),\n failDescription: z.string(),\n minThreshold: z.number().optional(), // Threshold percentage\n maxThreshold: z.number().optional(), // Threshold percentage\n})\nconst llmEvaluationComparisonResultMetadata =\n llmEvaluationResultMetadata.extend({\n configuration: llmEvaluationComparisonConfiguration,\n })\nconst llmEvaluationComparisonResultError = llmEvaluationResultError.extend({})\nexport const LlmEvaluationComparisonSpecification = {\n name: 'Comparison',\n description:\n 'Judges the response by comparing the criteria to the expected output. The resulting score is the percentage of compared criteria that is met',\n configuration: llmEvaluationComparisonConfiguration,\n resultMetadata: llmEvaluationComparisonResultMetadata,\n resultError: llmEvaluationComparisonResultError,\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type LlmEvaluationComparisonConfiguration = z.infer<\n typeof LlmEvaluationComparisonSpecification.configuration\n>\nexport type LlmEvaluationComparisonResultMetadata = z.infer<\n typeof LlmEvaluationComparisonSpecification.resultMetadata\n>\nexport type LlmEvaluationComparisonResultError = z.infer<\n typeof LlmEvaluationComparisonSpecification.resultError\n>\n\n// CUSTOM\n\nconst llmEvaluationCustomConfiguration = llmEvaluationConfiguration.extend({\n prompt: z.string(),\n minScore: z.number(),\n maxScore: z.number(),\n minThreshold: z.number().optional(), // Threshold percentage\n maxThreshold: z.number().optional(), // Threshold percentage\n})\nconst llmEvaluationCustomResultMetadata = llmEvaluationResultMetadata.extend({\n configuration: llmEvaluationCustomConfiguration,\n})\nconst llmEvaluationCustomResultError = llmEvaluationResultError.extend({})\nexport const LlmEvaluationCustomSpecification = {\n name: 'Custom',\n description:\n 'Judges the response under a criteria using a custom prompt. The resulting score is the value of criteria that is met',\n configuration: llmEvaluationCustomConfiguration,\n resultMetadata: llmEvaluationCustomResultMetadata,\n resultError: llmEvaluationCustomResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type LlmEvaluationCustomConfiguration = z.infer<\n typeof LlmEvaluationCustomSpecification.configuration\n>\nexport type LlmEvaluationCustomResultMetadata = z.infer<\n typeof LlmEvaluationCustomSpecification.resultMetadata\n>\nexport type LlmEvaluationCustomResultError = z.infer<\n typeof LlmEvaluationCustomSpecification.resultError\n>\n\nexport const LLM_EVALUATION_CUSTOM_PROMPT_DOCUMENTATION = `\n/*\n IMPORTANT: The evaluation MUST return an object with the score and reason fields.\n\n These are the available variables:\n - {{ actualOutput }} (string): The actual output to evaluate\n - {{ expectedOutput }} (string/undefined): The, optional, expected output to compare against\n - {{ conversation }} (string): The full conversation of the evaluated log\n\n - {{ messages }} (array of objects): All the messages of the conversation\n - {{ toolCalls }} (array of objects): All the tool calls of the conversation\n - {{ cost }} (number): The cost, in cents, of the evaluated log\n - {{ tokens }} (number): The tokens of the evaluated log\n - {{ duration }} (number): The duration, in seconds, of the evaluated log\n\n More info on messages and tool calls format in: https://docs.latitude.so/promptl/syntax/messages\n\n - {{ prompt }} (string): The prompt of the evaluated log\n - {{ config }} (object): The configuration of the evaluated log\n - {{ parameters }} (object): The parameters of the evaluated log\n\n More info on configuration and parameters format in: https://docs.latitude.so/promptl/syntax/configuration\n*/\n`.trim()\n\n// CUSTOM LABELED\n\nexport const LlmEvaluationCustomLabeledSpecification = {\n ...LlmEvaluationCustomSpecification,\n name: 'Custom (Labeled)',\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\n\n/* ------------------------------------------------------------------------- */\n\nexport enum LlmEvaluationMetric {\n Binary = 'binary',\n Rating = 'rating',\n Comparison = 'comparison',\n Custom = 'custom',\n CustomLabeled = 'custom_labeled',\n}\n\nexport type LlmEvaluationMetricAnyCustom =\n | LlmEvaluationMetric.Custom\n | LlmEvaluationMetric.CustomLabeled\n\n// prettier-ignore\nexport type LlmEvaluationConfiguration<M extends LlmEvaluationMetric = LlmEvaluationMetric> =\n M extends LlmEvaluationMetric.Binary ? LlmEvaluationBinaryConfiguration :\n M extends LlmEvaluationMetric.Rating ? LlmEvaluationRatingConfiguration :\n M extends LlmEvaluationMetric.Comparison ? LlmEvaluationComparisonConfiguration :\n M extends LlmEvaluationMetric.Custom ? LlmEvaluationCustomConfiguration :\n M extends LlmEvaluationMetric.CustomLabeled ? LlmEvaluationCustomConfiguration :\n never;\n\n// prettier-ignore\nexport type LlmEvaluationResultMetadata<M extends LlmEvaluationMetric = LlmEvaluationMetric> =\n M extends LlmEvaluationMetric.Binary ? LlmEvaluationBinaryResultMetadata :\n M extends LlmEvaluationMetric.Rating ? LlmEvaluationRatingResultMetadata :\n M extends LlmEvaluationMetric.Comparison ? LlmEvaluationComparisonResultMetadata :\n M extends LlmEvaluationMetric.Custom ? LlmEvaluationCustomResultMetadata :\n M extends LlmEvaluationMetric.CustomLabeled ? LlmEvaluationCustomResultMetadata :\n never;\n\n// prettier-ignore\nexport type LlmEvaluationResultError<M extends LlmEvaluationMetric = LlmEvaluationMetric> =\n M extends LlmEvaluationMetric.Binary ? LlmEvaluationBinaryResultError :\n M extends LlmEvaluationMetric.Rating ? LlmEvaluationRatingResultError :\n M extends LlmEvaluationMetric.Comparison ? LlmEvaluationComparisonResultError :\n M extends LlmEvaluationMetric.Custom ? LlmEvaluationCustomResultError :\n M extends LlmEvaluationMetric.CustomLabeled ? LlmEvaluationCustomResultError :\n never;\n\nexport const LlmEvaluationSpecification = {\n name: 'LLM-as-a-Judge',\n description: 'Evaluate responses using an LLM as a judge',\n configuration: llmEvaluationConfiguration,\n resultMetadata: llmEvaluationResultMetadata,\n resultError: llmEvaluationResultError,\n // prettier-ignore\n metrics: {\n [LlmEvaluationMetric.Binary]: LlmEvaluationBinarySpecification,\n [LlmEvaluationMetric.Rating]: LlmEvaluationRatingSpecification,\n [LlmEvaluationMetric.Comparison]: LlmEvaluationComparisonSpecification,\n [LlmEvaluationMetric.Custom]: LlmEvaluationCustomSpecification,\n [LlmEvaluationMetric.CustomLabeled]: LlmEvaluationCustomLabeledSpecification,\n },\n} as const\n\nexport const LLM_EVALUATION_PROMPT_PARAMETERS = [\n 'actualOutput',\n 'expectedOutput',\n 'conversation',\n 'cost',\n 'tokens',\n 'duration',\n 'config',\n 'toolCalls',\n 'messages',\n 'prompt',\n 'parameters',\n 'context',\n 'response',\n] as const\n\nexport type LlmEvaluationPromptParameter =\n (typeof LLM_EVALUATION_PROMPT_PARAMETERS)[number]\n","import { z } from 'zod'\nimport {\n baseEvaluationConfiguration,\n baseEvaluationResultError,\n baseEvaluationResultMetadata,\n} from './shared'\n\nconst ruleEvaluationConfiguration = baseEvaluationConfiguration.extend({})\nconst ruleEvaluationResultMetadata = baseEvaluationResultMetadata.extend({})\nconst ruleEvaluationResultError = baseEvaluationResultError.extend({})\n\n// EXACT MATCH\n\nconst ruleEvaluationExactMatchConfiguration =\n ruleEvaluationConfiguration.extend({\n caseInsensitive: z.boolean(),\n })\nconst ruleEvaluationExactMatchResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationExactMatchConfiguration,\n })\nconst ruleEvaluationExactMatchResultError = ruleEvaluationResultError.extend({})\nexport const RuleEvaluationExactMatchSpecification = {\n name: 'Exact Match',\n description:\n 'Checks if the response is exactly the same as the expected output. The resulting score is \"matched\" or \"unmatched\"',\n configuration: ruleEvaluationExactMatchConfiguration,\n resultMetadata: ruleEvaluationExactMatchResultMetadata,\n resultError: ruleEvaluationExactMatchResultError,\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationExactMatchConfiguration = z.infer<\n typeof RuleEvaluationExactMatchSpecification.configuration\n>\nexport type RuleEvaluationExactMatchResultMetadata = z.infer<\n typeof RuleEvaluationExactMatchSpecification.resultMetadata\n>\nexport type RuleEvaluationExactMatchResultError = z.infer<\n typeof RuleEvaluationExactMatchSpecification.resultError\n>\n\n// REGULAR EXPRESSION\n\nconst ruleEvaluationRegularExpressionConfiguration =\n ruleEvaluationConfiguration.extend({\n pattern: z.string(),\n })\nconst ruleEvaluationRegularExpressionResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationRegularExpressionConfiguration,\n })\nconst ruleEvaluationRegularExpressionResultError =\n ruleEvaluationResultError.extend({})\nexport const RuleEvaluationRegularExpressionSpecification = {\n name: 'Regular Expression',\n description:\n 'Checks if the response matches the regular expression. The resulting score is \"matched\" or \"unmatched\"',\n configuration: ruleEvaluationRegularExpressionConfiguration,\n resultMetadata: ruleEvaluationRegularExpressionResultMetadata,\n resultError: ruleEvaluationRegularExpressionResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationRegularExpressionConfiguration = z.infer<\n typeof RuleEvaluationRegularExpressionSpecification.configuration\n>\nexport type RuleEvaluationRegularExpressionResultMetadata = z.infer<\n typeof RuleEvaluationRegularExpressionSpecification.resultMetadata\n>\nexport type RuleEvaluationRegularExpressionResultError = z.infer<\n typeof RuleEvaluationRegularExpressionSpecification.resultError\n>\n\n// SCHEMA VALIDATION\n\nconst ruleEvaluationSchemaValidationConfiguration =\n ruleEvaluationConfiguration.extend({\n format: z.enum(['json']),\n schema: z.string(),\n })\nconst ruleEvaluationSchemaValidationResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationSchemaValidationConfiguration,\n })\nconst ruleEvaluationSchemaValidationResultError =\n ruleEvaluationResultError.extend({})\nexport const RuleEvaluationSchemaValidationSpecification = {\n name: 'Schema Validation',\n description:\n 'Checks if the response follows the schema. The resulting score is \"valid\" or \"invalid\"',\n configuration: ruleEvaluationSchemaValidationConfiguration,\n resultMetadata: ruleEvaluationSchemaValidationResultMetadata,\n resultError: ruleEvaluationSchemaValidationResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationSchemaValidationConfiguration = z.infer<\n typeof RuleEvaluationSchemaValidationSpecification.configuration\n>\nexport type RuleEvaluationSchemaValidationResultMetadata = z.infer<\n typeof RuleEvaluationSchemaValidationSpecification.resultMetadata\n>\nexport type RuleEvaluationSchemaValidationResultError = z.infer<\n typeof RuleEvaluationSchemaValidationSpecification.resultError\n>\n\n// LENGTH COUNT\n\nconst ruleEvaluationLengthCountConfiguration =\n ruleEvaluationConfiguration.extend({\n algorithm: z.enum(['character', 'word', 'sentence']),\n minLength: z.number().optional(),\n maxLength: z.number().optional(),\n })\nconst ruleEvaluationLengthCountResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationLengthCountConfiguration,\n })\nconst ruleEvaluationLengthCountResultError = ruleEvaluationResultError.extend(\n {},\n)\nexport const RuleEvaluationLengthCountSpecification = {\n name: 'Length Count',\n description:\n 'Checks if the response is of a certain length. The resulting score is the length of the response',\n configuration: ruleEvaluationLengthCountConfiguration,\n resultMetadata: ruleEvaluationLengthCountResultMetadata,\n resultError: ruleEvaluationLengthCountResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationLengthCountConfiguration = z.infer<\n typeof RuleEvaluationLengthCountSpecification.configuration\n>\nexport type RuleEvaluationLengthCountResultMetadata = z.infer<\n typeof RuleEvaluationLengthCountSpecification.resultMetadata\n>\nexport type RuleEvaluationLengthCountResultError = z.infer<\n typeof RuleEvaluationLengthCountSpecification.resultError\n>\n\n// LEXICAL OVERLAP\n\nconst ruleEvaluationLexicalOverlapConfiguration =\n ruleEvaluationConfiguration.extend({\n algorithm: z.enum(['substring', 'levenshtein_distance', 'rouge']),\n minOverlap: z.number().optional(), // Percentage of overlap\n maxOverlap: z.number().optional(), // Percentage of overlap\n })\nconst ruleEvaluationLexicalOverlapResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationLexicalOverlapConfiguration,\n })\nconst ruleEvaluationLexicalOverlapResultError =\n ruleEvaluationResultError.extend({})\nexport const RuleEvaluationLexicalOverlapSpecification = {\n name: 'Lexical Overlap',\n description:\n 'Checks if the response contains the expected output. The resulting score is the percentage of overlap',\n configuration: ruleEvaluationLexicalOverlapConfiguration,\n resultMetadata: ruleEvaluationLexicalOverlapResultMetadata,\n resultError: ruleEvaluationLexicalOverlapResultError,\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationLexicalOverlapConfiguration = z.infer<\n typeof RuleEvaluationLexicalOverlapSpecification.configuration\n>\nexport type RuleEvaluationLexicalOverlapResultMetadata = z.infer<\n typeof RuleEvaluationLexicalOverlapSpecification.resultMetadata\n>\nexport type RuleEvaluationLexicalOverlapResultError = z.infer<\n typeof RuleEvaluationLexicalOverlapSpecification.resultError\n>\n\n// SEMANTIC SIMILARITY\n\nconst ruleEvaluationSemanticSimilarityConfiguration =\n ruleEvaluationConfiguration.extend({\n algorithm: z.enum(['cosine_distance']),\n minSimilarity: z.number().optional(), // Percentage of similarity\n maxSimilarity: z.number().optional(), // Percentage of similarity\n })\nconst ruleEvaluationSemanticSimilarityResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationSemanticSimilarityConfiguration,\n })\nconst ruleEvaluationSemanticSimilarityResultError =\n ruleEvaluationResultError.extend({})\nexport const RuleEvaluationSemanticSimilaritySpecification = {\n name: 'Semantic Similarity',\n description:\n 'Checks if the response is semantically similar to the expected output. The resulting score is the percentage of similarity',\n configuration: ruleEvaluationSemanticSimilarityConfiguration,\n resultMetadata: ruleEvaluationSemanticSimilarityResultMetadata,\n resultError: ruleEvaluationSemanticSimilarityResultError,\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationSemanticSimilarityConfiguration = z.infer<\n typeof RuleEvaluationSemanticSimilaritySpecification.configuration\n>\nexport type RuleEvaluationSemanticSimilarityResultMetadata = z.infer<\n typeof RuleEvaluationSemanticSimilaritySpecification.resultMetadata\n>\nexport type RuleEvaluationSemanticSimilarityResultError = z.infer<\n typeof RuleEvaluationSemanticSimilaritySpecification.resultError\n>\n\n// NUMERIC SIMILARITY\n\nconst ruleEvaluationNumericSimilarityConfiguration =\n ruleEvaluationConfiguration.extend({\n algorithm: z.enum(['relative_difference']),\n minSimilarity: z.number().optional(), // Percentage of similarity\n maxSimilarity: z.number().optional(), // Percentage of similarity\n })\nconst ruleEvaluationNumericSimilarityResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationNumericSimilarityConfiguration,\n })\nconst ruleEvaluationNumericSimilarityResultError =\n ruleEvaluationResultError.extend({})\nexport const RuleEvaluationNumericSimilaritySpecification = {\n name: 'Numeric Similarity',\n description:\n 'Checks if the response is numerically similar to the expected output. The resulting score is the percentage of similarity',\n configuration: ruleEvaluationNumericSimilarityConfiguration,\n resultMetadata: ruleEvaluationNumericSimilarityResultMetadata,\n resultError: ruleEvaluationNumericSimilarityResultError,\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationNumericSimilarityConfiguration = z.infer<\n typeof RuleEvaluationNumericSimilaritySpecification.configuration\n>\nexport type RuleEvaluationNumericSimilarityResultMetadata = z.infer<\n typeof RuleEvaluationNumericSimilaritySpecification.resultMetadata\n>\nexport type RuleEvaluationNumericSimilarityResultError = z.infer<\n typeof RuleEvaluationNumericSimilaritySpecification.resultError\n>\n\n/* ------------------------------------------------------------------------- */\n\nexport enum RuleEvaluationMetric {\n ExactMatch = 'exact_match',\n RegularExpression = 'regular_expression',\n SchemaValidation = 'schema_validation',\n LengthCount = 'length_count',\n LexicalOverlap = 'lexical_overlap',\n SemanticSimilarity = 'semantic_similarity',\n NumericSimilarity = 'numeric_similarity',\n}\n\n// prettier-ignore\nexport type RuleEvaluationConfiguration<M extends RuleEvaluationMetric = RuleEvaluationMetric> = \n M extends RuleEvaluationMetric.ExactMatch ? RuleEvaluationExactMatchConfiguration :\n M extends RuleEvaluationMetric.RegularExpression ? RuleEvaluationRegularExpressionConfiguration :\n M extends RuleEvaluationMetric.SchemaValidation ? RuleEvaluationSchemaValidationConfiguration :\n M extends RuleEvaluationMetric.LengthCount ? RuleEvaluationLengthCountConfiguration :\n M extends RuleEvaluationMetric.LexicalOverlap ? RuleEvaluationLexicalOverlapConfiguration :\n M extends RuleEvaluationMetric.SemanticSimilarity ? RuleEvaluationSemanticSimilarityConfiguration :\n M extends RuleEvaluationMetric.NumericSimilarity ? RuleEvaluationNumericSimilarityConfiguration :\n never;\n\n// prettier-ignore\nexport type RuleEvaluationResultMetadata<M extends RuleEvaluationMetric = RuleEvaluationMetric> = \n M extends RuleEvaluationMetric.ExactMatch ? RuleEvaluationExactMatchResultMetadata :\n M extends RuleEvaluationMetric.RegularExpression ? RuleEvaluationRegularExpressionResultMetadata :\n M extends RuleEvaluationMetric.SchemaValidation ? RuleEvaluationSchemaValidationResultMetadata :\n M extends RuleEvaluationMetric.LengthCount ? RuleEvaluationLengthCountResultMetadata :\n M extends RuleEvaluationMetric.LexicalOverlap ? RuleEvaluationLexicalOverlapResultMetadata :\n M extends RuleEvaluationMetric.SemanticSimilarity ? RuleEvaluationSemanticSimilarityResultMetadata :\n M extends RuleEvaluationMetric.NumericSimilarity ? RuleEvaluationNumericSimilarityResultMetadata :\n never;\n\n// prettier-ignore\nexport type RuleEvaluationResultError<M extends RuleEvaluationMetric = RuleEvaluationMetric> = \n M extends RuleEvaluationMetric.ExactMatch ? RuleEvaluationExactMatchResultError :\n M extends RuleEvaluationMetric.RegularExpression ? RuleEvaluationRegularExpressionResultError :\n M extends RuleEvaluationMetric.SchemaValidation ? RuleEvaluationSchemaValidationResultError :\n M extends RuleEvaluationMetric.LengthCount ? RuleEvaluationLengthCountResultError :\n M extends RuleEvaluationMetric.LexicalOverlap ? RuleEvaluationLexicalOverlapResultError :\n M extends RuleEvaluationMetric.SemanticSimilarity ? RuleEvaluationSemanticSimilarityResultError :\n M extends RuleEvaluationMetric.NumericSimilarity ? RuleEvaluationNumericSimilarityResultError :\n never;\n\nexport const RuleEvaluationSpecification = {\n name: 'Programmatic Rule',\n description: 'Evaluate responses using a programmatic rule',\n configuration: ruleEvaluationConfiguration,\n resultMetadata: ruleEvaluationResultMetadata,\n resultError: ruleEvaluationResultError,\n // prettier-ignore\n metrics: {\n [RuleEvaluationMetric.ExactMatch]: RuleEvaluationExactMatchSpecification,\n [RuleEvaluationMetric.RegularExpression]: RuleEvaluationRegularExpressionSpecification,\n [RuleEvaluationMetric.SchemaValidation]: RuleEvaluationSchemaValidationSpecification,\n [RuleEvaluationMetric.LengthCount]: RuleEvaluationLengthCountSpecification,\n [RuleEvaluationMetric.LexicalOverlap]: RuleEvaluationLexicalOverlapSpecification,\n [RuleEvaluationMetric.SemanticSimilarity]: RuleEvaluationSemanticSimilaritySpecification,\n [RuleEvaluationMetric.NumericSimilarity]: RuleEvaluationNumericSimilaritySpecification,\n },\n} as const\n","import { z } from 'zod'\nimport { SegmentSource } from '../tracing'\nimport {\n HumanEvaluationConfiguration,\n HumanEvaluationMetric,\n HumanEvaluationResultError,\n HumanEvaluationResultMetadata,\n HumanEvaluationSpecification,\n} from './human'\nimport {\n LlmEvaluationConfiguration,\n LlmEvaluationMetric,\n LlmEvaluationResultError,\n LlmEvaluationResultMetadata,\n LlmEvaluationSpecification,\n} from './llm'\nimport {\n RuleEvaluationConfiguration,\n RuleEvaluationMetric,\n RuleEvaluationResultError,\n RuleEvaluationResultMetadata,\n RuleEvaluationSpecification,\n} from './rule'\n\nexport * from './human'\nexport * from './llm'\nexport * from './rule'\nexport * from './shared'\n\nexport enum EvaluationType {\n Rule = 'rule',\n Llm = 'llm',\n Human = 'human',\n}\n\nexport const EvaluationTypeSchema = z.nativeEnum(EvaluationType)\n\n// prettier-ignore\nexport type EvaluationMetric<T extends EvaluationType = EvaluationType> =\n T extends EvaluationType.Rule ? RuleEvaluationMetric :\n T extends EvaluationType.Llm ? LlmEvaluationMetric :\n T extends EvaluationType.Human ? HumanEvaluationMetric :\n never;\n\nexport const EvaluationMetricSchema = z.union([\n z.nativeEnum(RuleEvaluationMetric),\n z.nativeEnum(LlmEvaluationMetric),\n z.nativeEnum(HumanEvaluationMetric),\n])\n\n// prettier-ignore\nexport type EvaluationConfiguration<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> =\n T extends EvaluationType.Rule ? RuleEvaluationConfiguration<M extends RuleEvaluationMetric ? M : never> :\n T extends EvaluationType.Llm ? LlmEvaluationConfiguration<M extends LlmEvaluationMetric ? M : never> :\n T extends EvaluationType.Human ? HumanEvaluationConfiguration<M extends HumanEvaluationMetric ? M : never> :\n never;\n\nexport const EvaluationConfigurationSchema = z.custom<EvaluationConfiguration>()\n\n// prettier-ignore\nexport type EvaluationResultMetadata<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> =\n T extends EvaluationType.Rule ? RuleEvaluationResultMetadata<M extends RuleEvaluationMetric ? M : never> :\n T extends EvaluationType.Llm ? LlmEvaluationResultMetadata<M extends LlmEvaluationMetric ? M : never> :\n T extends EvaluationType.Human ? HumanEvaluationResultMetadata<M extends HumanEvaluationMetric ? M : never> :\n never;\n\n// prettier-ignore\nexport const EvaluationResultMetadataSchema = z.custom<EvaluationResultMetadata>()\n\n// prettier-ignore\nexport type EvaluationResultError<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> =\n T extends EvaluationType.Rule ? RuleEvaluationResultError<M extends RuleEvaluationMetric ? M : never> :\n T extends EvaluationType.Llm ? LlmEvaluationResultError<M extends LlmEvaluationMetric ? M : never> :\n T extends EvaluationType.Human ? HumanEvaluationResultError<M extends HumanEvaluationMetric ? M : never> :\n never;\n\n// prettier-ignore\nexport const EvaluationResultErrorSchema = z.custom<EvaluationResultError>()\n\n// prettier-ignore\ntype ZodSchema<T = any> = z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, T, T>\n\nexport type EvaluationMetricSpecification<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> = {\n name: string\n description: string\n configuration: ZodSchema<EvaluationConfiguration<T, M>>\n resultMetadata: ZodSchema<EvaluationResultMetadata<T, M>>\n resultError: ZodSchema<EvaluationResultError<T, M>>\n requiresExpectedOutput: boolean\n supportsLiveEvaluation: boolean\n supportsBatchEvaluation: boolean\n supportsManualEvaluation: boolean\n}\n\nexport type EvaluationSpecification<T extends EvaluationType = EvaluationType> =\n {\n name: string\n description: string\n configuration: ZodSchema\n resultMetadata: ZodSchema\n resultError: ZodSchema\n metrics: { [M in EvaluationMetric<T>]: EvaluationMetricSpecification<T, M> }\n }\n\nexport const EVALUATION_SPECIFICATIONS = {\n [EvaluationType.Rule]: RuleEvaluationSpecification,\n [EvaluationType.Llm]: LlmEvaluationSpecification,\n [EvaluationType.Human]: HumanEvaluationSpecification,\n} as const satisfies {\n [T in EvaluationType]: EvaluationSpecification<T>\n}\ntype EvaluationSpecifications = typeof EVALUATION_SPECIFICATIONS\n\n// prettier-ignore\ntype EvaluationMetricSpecificationFilter<\n F extends keyof EvaluationMetricSpecification,\n T extends EvaluationType = EvaluationType\n> = { [K in EvaluationType]: {\n [M in keyof EvaluationSpecifications[K]['metrics']]:\n // @ts-expect-error F can indeed index M type\n EvaluationSpecifications[K]['metrics'][M][F] extends true ? M : never\n }[keyof EvaluationSpecifications[K]['metrics']]\n}[T] & EvaluationMetric<T>\n\nexport type LiveEvaluationMetric<T extends EvaluationType = EvaluationType> =\n EvaluationMetricSpecificationFilter<'supportsLiveEvaluation', T>\n\nexport type BatchEvaluationMetric<T extends EvaluationType = EvaluationType> =\n EvaluationMetricSpecificationFilter<'supportsBatchEvaluation', T>\n\nexport type ManualEvaluationMetric<T extends EvaluationType = EvaluationType> =\n EvaluationMetricSpecificationFilter<'supportsManualEvaluation', T>\n\nexport type EvaluationV2<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> = {\n uuid: string\n versionId: number\n workspaceId: number\n commitId: number\n documentUuid: string\n name: string\n description: string\n type: T\n metric: M\n configuration: EvaluationConfiguration<T, M>\n evaluateLiveLogs?: boolean | null\n enableSuggestions?: boolean | null\n autoApplySuggestions?: boolean | null\n createdAt: Date\n updatedAt: Date\n deletedAt?: Date | null\n}\n\nexport type EvaluationResultValue<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> =\n | {\n score: number\n normalizedScore: number\n metadata: EvaluationResultMetadata<T, M>\n hasPassed: boolean\n error?: null\n }\n | {\n score?: null\n normalizedScore?: null\n metadata?: null\n hasPassed?: null\n error: EvaluationResultError<T, M>\n }\n\nexport type EvaluationResultV2<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> = {\n id: number\n uuid: string\n workspaceId: number\n commitId: number\n evaluationUuid: string\n experimentId?: number | null\n datasetId?: number | null\n evaluatedRowId?: number | null\n evaluatedLogId: number\n usedForSuggestion?: boolean | null\n createdAt: Date\n updatedAt: Date\n} & EvaluationResultValue<T, M>\n\nexport type PublicManualEvaluationResultV2 = Pick<\n EvaluationResultV2<EvaluationType.Human, HumanEvaluationMetric>,\n | 'uuid'\n | 'score'\n | 'normalizedScore'\n | 'metadata'\n | 'hasPassed'\n | 'createdAt'\n | 'updatedAt'\n> & { versionUuid: string; error: string | null }\n\nexport type EvaluationSettings<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> = Pick<\n EvaluationV2<T, M>,\n 'name' | 'description' | 'type' | 'metric' | 'configuration'\n>\n\nexport const EvaluationSettingsSchema = z.object({\n name: z.string(),\n description: z.string(),\n type: EvaluationTypeSchema,\n metric: EvaluationMetricSchema,\n configuration: EvaluationConfigurationSchema,\n})\n\nexport type EvaluationOptions = Pick<\n EvaluationV2,\n 'evaluateLiveLogs' | 'enableSuggestions' | 'autoApplySuggestions'\n>\n\nexport const EvaluationOptionsSchema = z.object({\n evaluateLiveLogs: z.boolean().nullable().optional(),\n enableSuggestions: z.boolean().nullable().optional(),\n autoApplySuggestions: z.boolean().nullable().optional(),\n})\n\nexport const EVALUATION_SCORE_SCALE = 100\n\nexport const DEFAULT_DATASET_LABEL = 'output'\n\nexport const LIVE_EVALUABLE_LOG_SOURCES = Object.values(SegmentSource).filter(\n (source) =>\n source !== SegmentSource.Evaluation && source !== SegmentSource.Experiment,\n) as SegmentSource[]\n","import { Message } from '@latitude-data/compiler'\nimport { ChainEventDtoResponse } from '..'\nimport { FinishReason } from 'ai'\nimport { LatitudePromptConfig } from '../latitudePromptSchema'\n\nexport enum LegacyChainEventTypes {\n Error = 'chain-error',\n Step = 'chain-step',\n Complete = 'chain-complete',\n StepComplete = 'chain-step-complete',\n}\n\nexport type LegacyEventData =\n | {\n type: LegacyChainEventTypes.Step\n config: LatitudePromptConfig\n isLastStep: boolean\n messages: Message[]\n uuid?: string\n }\n | {\n type: LegacyChainEventTypes.StepComplete\n response: ChainEventDtoResponse\n uuid?: string\n }\n | {\n type: LegacyChainEventTypes.Complete\n config: LatitudePromptConfig\n finishReason?: FinishReason\n messages?: Message[]\n object?: any\n response: ChainEventDtoResponse\n uuid?: string\n }\n | {\n type: LegacyChainEventTypes.Error\n error: {\n name: string\n message: string\n stack?: string\n }\n }\n","import { Config, Message, ToolCall } from '@latitude-data/compiler'\nimport {\n ChainStepResponse,\n ProviderData,\n StreamEventTypes,\n StreamType,\n} from '..'\nimport { FinishReason, LanguageModelUsage } from 'ai'\nimport { ChainError, RunErrorCodes } from '../errors'\nimport { TraceContext } from '../tracing/trace'\n\nexport enum ChainEventTypes {\n ChainStarted = 'chain-started',\n StepStarted = 'step-started',\n ProviderStarted = 'provider-started',\n ProviderCompleted = 'provider-completed',\n ToolsStarted = 'tools-started',\n ToolCompleted = 'tool-completed',\n StepCompleted = 'step-completed',\n ChainCompleted = 'chain-completed',\n ChainError = 'chain-error',\n ToolsRequested = 'tools-requested',\n IntegrationWakingUp = 'integration-waking-up',\n}\n\ninterface GenericLatitudeEventData {\n type: ChainEventTypes\n messages: Message[]\n uuid: string\n}\n\nexport interface LatitudeChainStartedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ChainStarted\n}\n\nexport interface LatitudeStepStartedEventData extends GenericLatitudeEventData {\n type: ChainEventTypes.StepStarted\n}\n\nexport interface LatitudeProviderStartedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ProviderStarted\n config: Config\n}\n\nexport interface LatitudeProviderCompletedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ProviderCompleted\n providerLogUuid: string\n tokenUsage: LanguageModelUsage\n finishReason: FinishReason\n response: ChainStepResponse<StreamType>\n}\n\nexport interface LatitudeToolsStartedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ToolsStarted\n tools: ToolCall[]\n}\n\nexport interface LatitudeToolCompletedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ToolCompleted\n}\n\nexport interface LatitudeStepCompletedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.StepCompleted\n}\n\nexport interface LatitudeChainCompletedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ChainCompleted\n tokenUsage: LanguageModelUsage\n finishReason: FinishReason\n trace: TraceContext\n}\n\nexport interface LatitudeChainErrorEventData extends GenericLatitudeEventData {\n type: ChainEventTypes.ChainError\n error: Error | ChainError<RunErrorCodes>\n}\n\nexport interface LatitudeToolsRequestedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ToolsRequested\n tools: ToolCall[]\n trace: TraceContext\n}\n\nexport interface LatitudeIntegrationWakingUpEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.IntegrationWakingUp\n integrationName: string\n}\n\nexport type LatitudeEventData =\n | LatitudeChainStartedEventData\n | LatitudeStepStartedEventData\n | LatitudeProviderStartedEventData\n | LatitudeProviderCompletedEventData\n | LatitudeToolsStartedEventData\n | LatitudeToolCompletedEventData\n | LatitudeStepCompletedEventData\n | LatitudeChainCompletedEventData\n | LatitudeChainErrorEventData\n | LatitudeToolsRequestedEventData\n | LatitudeIntegrationWakingUpEventData\n\n// Just a type helper for ChainStreamManager. Omit<LatitudeEventData, 'messages' | 'uuid'> does not work.\nexport type OmittedLatitudeEventData =\n | Omit<LatitudeChainStartedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeStepStartedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeProviderStartedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeProviderCompletedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeToolsStartedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeToolCompletedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeStepCompletedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeChainCompletedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeChainErrorEventData, 'messages' | 'uuid'>\n | Omit<LatitudeToolsRequestedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeIntegrationWakingUpEventData, 'messages' | 'uuid'>\n\nexport type ChainEvent =\n | {\n event: StreamEventTypes.Latitude\n data: LatitudeEventData\n }\n | {\n event: StreamEventTypes.Provider\n data: ProviderData\n }\n","export enum IntegrationType {\n Latitude = 'latitude', // For internal use only\n ExternalMCP = 'custom_mcp',\n HostedMCP = 'mcp_server',\n}\n\nexport enum HostedIntegrationType {\n Stripe = 'stripe',\n Slack = 'slack',\n Github = 'github',\n Notion = 'notion',\n Twitter = 'twitter',\n Airtable = 'airtable',\n Linear = 'linear',\n YoutubeCaptions = 'youtube_captions',\n Reddit = 'reddit',\n Telegram = 'telegram',\n Tinybird = 'tinybird',\n Perplexity = 'perplexity',\n\n AwsKbRetrieval = 'aws_kb_retrieval',\n BraveSearch = 'brave_search',\n EverArt = 'ever_art',\n Fetch = 'fetch',\n GitLab = 'gitlab',\n GoogleMaps = 'google_maps',\n Sentry = 'sentry',\n Puppeteer = 'puppeteer',\n Time = 'time',\n browserbase = 'browserbase',\n Neon = 'neon',\n Postgres = 'postgres',\n Supabase = 'supabase',\n Redis = 'redis',\n Jira = 'jira',\n Attio = 'attio',\n Ghost = 'ghost',\n Figma = 'figma',\n Hyperbrowser = 'hyperbrowser',\n Audiense = 'audiense',\n Apify = 'apify',\n Exa = 'exa',\n YepCode = 'yepcode',\n Monday = 'monday',\n\n AgentQL = 'agentql',\n AgentRPC = 'agentrpc',\n AstraDB = 'astra_db',\n Bankless = 'bankless',\n Bicscan = 'bicscan',\n Chargebee = 'chargebee',\n Chronulus = 'chronulus',\n CircleCI = 'circleci',\n Codacy = 'codacy',\n CodeLogic = 'codelogic',\n Convex = 'convex',\n Dart = 'dart',\n DevHubCMS = 'devhub_cms',\n Elasticsearch = 'elasticsearch',\n ESignatures = 'esignatures',\n Fewsats = 'fewsats',\n Firecrawl = 'firecrawl',\n\n Graphlit = 'graphlit',\n Heroku = 'heroku',\n IntegrationAppHubspot = 'integration_app_hubspot',\n\n LaraTranslate = 'lara_translate',\n Logfire = 'logfire',\n Langfuse = 'langfuse',\n LingoSupabase = 'lingo_supabase',\n Make = 'make',\n Meilisearch = 'meilisearch',\n Momento = 'momento',\n\n Neo4jAura = 'neo4j_aura',\n Octagon = 'octagon',\n\n Paddle = 'paddle',\n PayPal = 'paypal',\n Qdrant = 'qdrant',\n Raygun = 'raygun',\n Rember = 'rember',\n Riza = 'riza',\n Search1API = 'search1api',\n Semgrep = 'semgrep',\n\n Tavily = 'tavily',\n Unstructured = 'unstructured',\n Vectorize = 'vectorize',\n Xero = 'xero',\n Readwise = 'readwise',\n Airbnb = 'airbnb',\n Mintlify = 'mintlify',\n\n // Require all auth file :point_down:\n // Gmail = 'google_drive',\n // GoogleCalendar = 'google_drive',\n // GoogleDrive = 'google_drive',\n // GoogleWorkspace = 'google_workspace', // env vars not supported (?)\n\n // TODO: implement these\n // Wordpress = 'wordpress', // Not on OpenTools\n // Discord = 'discord', // Not on OpenTools\n // Intercom = 'intercom', // Not on OpenTools\n\n // Hubspot = 'hubspot', // Docker based\n // Loops = 'loops', // Does not exist\n}\n","import { LogSources } from '.'\nimport { Message, ToolCall } from '@latitude-data/compiler'\nimport { PartialPromptConfig } from './ai'\n\nexport type DocumentLog = {\n id: number\n uuid: string\n documentUuid: string\n commitId: number\n resolvedContent: string\n contentHash: string\n parameters: Record<string, unknown>\n customIdentifier: string | null\n duration: number | null\n source: LogSources | null\n createdAt: Date\n updatedAt: Date\n experimentId: number | null\n}\n\n// TODO(evalsv2): Remove\nexport enum EvaluationResultableType {\n Boolean = 'evaluation_resultable_booleans',\n Text = 'evaluation_resultable_texts',\n Number = 'evaluation_resultable_numbers',\n}\n\n// TODO(evalsv2): Remove\nexport type EvaluationResult = {\n id: number\n uuid: string\n evaluationId: number\n documentLogId: number\n evaluatedProviderLogId: number | null\n evaluationProviderLogId: number | null\n resultableType: EvaluationResultableType | null\n resultableId: number | null\n source: LogSources | null\n reason: string | null\n createdAt: Date\n updatedAt: Date\n}\n\n// TODO(evalsv2): Remove\nexport type EvaluationResultDto = EvaluationResult & {\n result: string | number | boolean | undefined\n}\n\nexport type ProviderLog = {\n id: number\n uuid: string\n documentLogUuid: string | null\n providerId: number | null\n model: string | null\n finishReason: string | null\n config: PartialPromptConfig | null\n messages: Message[]\n responseObject: unknown | null\n responseText: string | null\n toolCalls: ToolCall[]\n tokens: number | null\n costInMillicents: number | null\n duration: number | null\n source: LogSources | null\n apiKeyId: number | null\n generatedAt: Date | null\n updatedAt: Date\n}\n\nexport type DocumentVersion = {\n id: number\n createdAt: Date\n updatedAt: Date\n deletedAt: Date | null\n documentUuid: string\n commitId: number\n path: string\n content: string\n resolvedContent: string | null\n contentHash: string | null\n datasetId: number | null\n datasetV2Id: number | null\n}\n\nexport type SimplifiedDocumentVersion = {\n documentUuid: string\n path: string\n content: string\n isDeleted: boolean\n}\n","export enum ModifiedDocumentType {\n Created = 'created',\n Updated = 'updated',\n UpdatedPath = 'updated_path',\n Deleted = 'deleted',\n}\n\nexport type ChangedDocument = {\n documentUuid: string\n path: string\n errors: number\n changeType: ModifiedDocumentType\n}\n","// TODO(tracing): deprecated\nexport { SegmentSource as LogSources } from './tracing'\n\nexport const HEAD_COMMIT = 'live'\n\nexport enum Providers {\n OpenAI = 'openai',\n Anthropic = 'anthropic',\n Groq = 'groq',\n Mistral = 'mistral',\n Azure = 'azure',\n Google = 'google',\n GoogleVertex = 'google_vertex',\n AnthropicVertex = 'anthropic_vertex',\n Custom = 'custom',\n XAI = 'xai',\n AmazonBedrock = 'amazon_bedrock',\n DeepSeek = 'deepseek',\n Perplexity = 'perplexity',\n}\n\nexport enum DocumentType {\n Prompt = 'prompt',\n Agent = 'agent',\n}\n\nexport enum DocumentTriggerType {\n Email = 'email',\n Scheduled = 'scheduled',\n}\n\nexport enum DocumentTriggerParameters {\n SenderEmail = 'senderEmail',\n SenderName = 'senderName',\n Subject = 'subject',\n Body = 'body',\n Attachments = 'attachments',\n}\n\nexport type ExperimentMetadata = {\n prompt: string\n promptHash: string\n parametersMap: Record<string, number>\n datasetLabels: Record<string, string> // name for the expected output column in golden datasets, based on evaluation uuid\n fromRow?: number\n toRow?: number\n count: number // Total number of to generate logs in the experiment\n}\n\nexport type ExperimentEvaluationScore = {\n count: number\n totalScore: number\n totalNormalizedScore: number\n}\n\nexport type ExperimentScores = {\n [evaluationUuid: string]: ExperimentEvaluationScore\n}\n\nexport * from './ai'\nexport * from './config'\nexport * from './evaluations'\nexport * from './events'\nexport * from './helpers'\nexport * from './integrations'\nexport * from './mcp'\nexport * from './models'\nexport * from './tools'\nexport * from './tracing'\nexport * from './history'\n\n// TODO: Move to env\nexport const EMAIL_TRIGGER_DOMAIN = 'run.latitude.so' as const\nexport const OPENAI_PROVIDER_ENDPOINTS = [\n 'chat_completions',\n 'responses',\n] as const\n","import { BaseInstrumentation } from '$telemetry/instrumentations/base'\nimport {\n ATTR_GEN_AI_COMPLETIONS,\n ATTR_GEN_AI_MESSAGE_CONTENT,\n ATTR_GEN_AI_MESSAGE_ROLE,\n ATTR_GEN_AI_MESSAGE_TOOL_CALL_ID,\n ATTR_GEN_AI_MESSAGE_TOOL_CALLS,\n ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS,\n ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ID,\n ATTR_GEN_AI_MESSAGE_TOOL_CALLS_NAME,\n ATTR_GEN_AI_MESSAGE_TOOL_NAME,\n ATTR_GEN_AI_MESSAGE_TOOL_RESULT_IS_ERROR,\n ATTR_GEN_AI_PROMPTS,\n ATTR_GEN_AI_REQUEST,\n ATTR_GEN_AI_REQUEST_CONFIGURATION,\n ATTR_GEN_AI_REQUEST_MESSAGES,\n ATTR_GEN_AI_REQUEST_PARAMETERS,\n ATTR_GEN_AI_REQUEST_TEMPLATE,\n ATTR_GEN_AI_RESPONSE,\n ATTR_GEN_AI_RESPONSE_MESSAGES,\n ATTR_GEN_AI_TOOL_CALL_ARGUMENTS,\n ATTR_GEN_AI_TOOL_RESULT_IS_ERROR,\n ATTR_GEN_AI_TOOL_RESULT_VALUE,\n ATTR_GEN_AI_USAGE_CACHED_TOKENS,\n ATTR_GEN_AI_USAGE_COMPLETION_TOKENS,\n ATTR_GEN_AI_USAGE_PROMPT_TOKENS,\n ATTR_GEN_AI_USAGE_REASONING_TOKENS,\n ATTR_HTTP_REQUEST_BODY,\n ATTR_HTTP_REQUEST_HEADERS,\n ATTR_HTTP_REQUEST_URL,\n ATTR_HTTP_RESPONSE_BODY,\n ATTR_HTTP_RESPONSE_HEADERS,\n ATTR_LATITUDE_SEGMENT_ID,\n ATTR_LATITUDE_SEGMENT_PARENT_ID,\n ATTR_LATITUDE_SEGMENTS,\n ATTR_LATITUDE_TYPE,\n GEN_AI_TOOL_TYPE_VALUE_FUNCTION,\n GENAI_SPANS,\n HEAD_COMMIT,\n SegmentBaggage,\n SegmentSource,\n SegmentType,\n SpanType,\n TraceBaggage,\n TraceContext,\n} from '@latitude-data/constants'\nimport * as otel from '@opentelemetry/api'\nimport { propagation, trace } from '@opentelemetry/api'\nimport {\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n} from '@opentelemetry/semantic-conventions'\nimport {\n ATTR_GEN_AI_OPERATION_NAME,\n ATTR_GEN_AI_RESPONSE_FINISH_REASONS,\n ATTR_GEN_AI_RESPONSE_MODEL,\n ATTR_GEN_AI_SYSTEM,\n ATTR_GEN_AI_TOOL_CALL_ID,\n ATTR_GEN_AI_TOOL_NAME,\n ATTR_GEN_AI_TOOL_TYPE,\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n} from '@opentelemetry/semantic-conventions/incubating'\nimport { v4 as uuid } from 'uuid'\n\nexport type StartSpanOptions = {\n name?: string\n attributes?: otel.Attributes\n}\n\nexport type EndSpanOptions = {\n attributes?: otel.Attributes\n}\n\nexport type ErrorOptions = {\n attributes?: otel.Attributes\n}\n\nexport type StartToolSpanOptions = StartSpanOptions & {\n name: string\n call: {\n id: string\n arguments: Record<string, unknown>\n }\n}\n\nexport type EndToolSpanOptions = EndSpanOptions & {\n result: {\n value: unknown\n isError: boolean\n }\n}\n\nexport type StartCompletionSpanOptions = StartSpanOptions & {\n provider: string\n model: string\n configuration: Record<string, unknown>\n input: Record<string, unknown>[]\n}\n\nexport type EndCompletionSpanOptions = EndSpanOptions & {\n output: Record<string, unknown>[]\n tokens: {\n prompt: number\n cached: number\n reasoning: number\n completion: number\n }\n finishReason: string\n}\n\nexport type StartHttpSpanOptions = StartSpanOptions & {\n request: {\n method: string\n url: string\n headers: Record<string, string>\n body: string | Record<string, unknown>\n }\n}\n\nexport type EndHttpSpanOptions = EndSpanOptions & {\n response: {\n status: number\n headers: Record<string, string>\n body: string | Record<string, unknown>\n }\n}\n\nexport type SegmentOptions = {\n attributes?: otel.Attributes\n baggage?: Record<string, otel.BaggageEntry>\n _internal?: {\n id?: string\n source?: SegmentSource\n }\n}\n\nexport type PromptSegmentOptions = SegmentOptions & {\n logUuid?: string // TODO(tracing): temporal related log, remove when observability is ready\n versionUuid?: string // Alias for commitUuid\n promptUuid: string // Alias for documentUuid\n experimentUuid?: string\n externalId?: string\n template: string\n parameters?: Record<string, unknown>\n}\n\nexport class ManualInstrumentation implements BaseInstrumentation {\n private enabled: boolean\n private readonly source: SegmentSource\n private readonly tracer: otel.Tracer\n\n constructor(source: SegmentSource, tracer: otel.Tracer) {\n this.enabled = false\n this.source = source\n this.tracer = tracer\n }\n\n isEnabled() {\n return this.enabled\n }\n\n enable() {\n this.enabled = true\n }\n\n disable() {\n this.enabled = false\n }\n\n baggage(ctx: otel.Context | TraceContext) {\n if ('traceparent' in ctx) {\n ctx = propagation.extract(otel.ROOT_CONTEXT, ctx)\n }\n\n const baggage = Object.fromEntries(\n propagation.getBaggage(ctx)?.getAllEntries() || [],\n )\n if (\n !(ATTR_LATITUDE_SEGMENT_ID in baggage) ||\n !(ATTR_LATITUDE_SEGMENTS in baggage)\n ) {\n return undefined\n }\n\n const segment = {\n id: baggage[ATTR_LATITUDE_SEGMENT_ID]!.value,\n parentId: baggage[ATTR_LATITUDE_SEGMENT_PARENT_ID]?.value,\n }\n\n let segments = []\n try {\n segments = JSON.parse(baggage[ATTR_LATITUDE_SEGMENTS]!.value)\n } catch (error) {\n return undefined\n }\n\n if (segments.length < 1) {\n return undefined\n }\n\n return { segment, segments } as TraceBaggage\n }\n\n private setBaggage(\n ctx: otel.Context,\n baggage: TraceBaggage | undefined,\n extra?: Record<string, otel.BaggageEntry>,\n ) {\n let parent = Object.fromEntries(\n propagation.getBaggage(ctx)?.getAllEntries() || [],\n )\n\n parent = Object.fromEntries(\n Object.entries(parent).filter(\n ([attribute]) =>\n attribute !== ATTR_LATITUDE_SEGMENT_ID &&\n attribute !== ATTR_LATITUDE_SEGMENT_PARENT_ID &&\n attribute !== ATTR_LATITUDE_SEGMENTS,\n ),\n )\n\n if (!baggage) {\n const payload = propagation.createBaggage({ ...parent, ...(extra || {}) })\n return propagation.setBaggage(ctx, payload)\n }\n\n let jsonSegments = ''\n try {\n jsonSegments = JSON.stringify(baggage.segments)\n } catch (error) {\n jsonSegments = '[]'\n }\n\n const payload = propagation.createBaggage({\n ...parent,\n [ATTR_LATITUDE_SEGMENT_ID]: { value: baggage.segment.id },\n ...(baggage.segment.parentId && {\n [ATTR_LATITUDE_SEGMENT_PARENT_ID]: { value: baggage.segment.parentId },\n }),\n [ATTR_LATITUDE_SEGMENTS]: { value: jsonSegments },\n ...(extra || {}),\n })\n\n return propagation.setBaggage(ctx, payload)\n }\n\n pause(ctx: otel.Context) {\n const baggage = this.baggage(ctx)\n if (baggage) {\n baggage.segments.at(-1)!.paused = true\n }\n\n ctx = this.setBaggage(ctx, baggage)\n let carrier = {} as TraceContext\n propagation.inject(ctx, carrier)\n\n return carrier\n }\n\n resume(ctx: TraceContext) {\n return propagation.extract(otel.ROOT_CONTEXT, ctx)\n }\n\n restored(ctx: otel.Context) {\n const baggage = this.baggage(ctx)\n return !baggage?.segments.some((segment) => segment.paused)\n }\n\n restore(ctx: otel.Context) {\n let baggage = this.baggage(ctx)\n if (!baggage) return ctx\n\n const segments = baggage.segments\n while (segments.at(-1)?.paused) segments.pop()\n\n const segment = segments.at(-1)\n if (!segment) return otel.ROOT_CONTEXT\n\n baggage = {\n segment: { id: segment.id, parentId: segment.parentId },\n segments: segments,\n }\n\n ctx = this.setBaggage(ctx, baggage)\n let carrier = {} as TraceContext\n propagation.inject(ctx, carrier)\n\n carrier.traceparent = segment.traceparent\n carrier.tracestate = segment.tracestate\n\n return this.resume(carrier)\n }\n\n private capitalize(str: string) {\n if (str.length === 0) return str\n return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1)\n }\n\n private toCamelCase(str: string) {\n return str\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[^A-Za-z0-9]+/g, ' ')\n .trim()\n .split(' ')\n .map((w, i) => (i ? this.capitalize(w) : w.toLowerCase()))\n .join('')\n }\n\n private toSnakeCase(str: string) {\n return str\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/[^A-Za-z0-9]+/g, '_')\n .replace(/_+/g, '_')\n .replace(/^_+|_+$/g, '')\n .toLowerCase()\n }\n\n private toKebabCase(input: string) {\n return input\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[^A-Za-z0-9]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-+|-+$/g, '')\n .toLowerCase()\n }\n\n private error(span: otel.Span, error: Error, options?: ErrorOptions) {\n options = options || {}\n\n span.recordException(error)\n span.setAttributes(options.attributes || {})\n span.setStatus({\n code: otel.SpanStatusCode.ERROR,\n message: error.message || undefined,\n })\n span.end()\n }\n\n private span<T extends SpanType>(\n ctx: otel.Context,\n name: string,\n type: T,\n options?: StartSpanOptions,\n ) {\n if (!this.enabled) {\n return {\n context: ctx,\n end: (_options?: EndSpanOptions) => {},\n fail: (_error: Error, _options?: ErrorOptions) => {},\n }\n }\n\n const start = options || {}\n\n let operation = undefined\n if (GENAI_SPANS.includes(type)) {\n operation = type\n }\n\n const span = this.tracer.startSpan(\n name,\n {\n attributes: {\n [ATTR_LATITUDE_TYPE]: type,\n ...(operation && {\n [ATTR_GEN_AI_OPERATION_NAME]: operation,\n }),\n ...(start.attributes || {}),\n },\n kind: otel.SpanKind.CLIENT,\n },\n ctx,\n )\n\n const newCtx = trace.setSpan(ctx, span)\n\n return {\n context: newCtx,\n end: (options?: EndSpanOptions) => {\n const end = options || {}\n\n span.setAttributes(end.attributes || {})\n span.setStatus({ code: otel.SpanStatusCode.OK })\n span.end()\n },\n fail: (error: Error, options?: ErrorOptions) => {\n this.error(span, error, options)\n },\n }\n }\n\n tool(ctx: otel.Context, options: StartToolSpanOptions) {\n const start = options\n\n let jsonArguments = ''\n try {\n jsonArguments = JSON.stringify(start.call.arguments)\n } catch (error) {\n jsonArguments = '{}'\n }\n\n const span = this.span(ctx, start.name, SpanType.Tool, {\n attributes: {\n [ATTR_GEN_AI_TOOL_NAME]: start.name,\n [ATTR_GEN_AI_TOOL_TYPE]: GEN_AI_TOOL_TYPE_VALUE_FUNCTION,\n [ATTR_GEN_AI_TOOL_CALL_ID]: start.call.id,\n [ATTR_GEN_AI_TOOL_CALL_ARGUMENTS]: jsonArguments,\n ...(start.attributes || {}),\n },\n })\n\n return {\n context: span.context,\n end: (options: EndToolSpanOptions) => {\n const end = options\n\n let stringResult = ''\n if (typeof end.result.value !== 'string') {\n try {\n stringResult = JSON.stringify(end.result.value)\n } catch (error) {\n stringResult = '{}'\n }\n } else {\n stringResult = end.result.value\n }\n\n span.end({\n attributes: {\n [ATTR_GEN_AI_TOOL_RESULT_VALUE]: stringResult,\n [ATTR_GEN_AI_TOOL_RESULT_IS_ERROR]: end.result.isError,\n ...(end.attributes || {}),\n },\n })\n },\n fail: span.fail,\n }\n }\n\n private attribifyMessageToolCalls(\n prefix: string,\n toolCalls: Record<string, unknown>[],\n ) {\n const attributes: otel.Attributes = {}\n\n for (let i = 0; i < toolCalls.length; i++) {\n for (const key in toolCalls[i]!) {\n const field = this.toCamelCase(key)\n let value = toolCalls[i]![key]\n if (value === null || value === undefined) continue\n\n switch (field) {\n case 'id':\n case 'toolCallId':\n case 'toolUseId': {\n if (typeof value !== 'string') continue\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ID}`\n ] = value\n break\n }\n\n case 'name':\n case 'toolName': {\n if (typeof value !== 'string') continue\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_NAME}`\n ] = value\n break\n }\n\n case 'arguments':\n case 'toolArguments':\n case 'input': {\n if (typeof value === 'string') {\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS}`\n ] = value\n } else {\n try {\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS}`\n ] = JSON.stringify(value)\n } catch (error) {\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS}`\n ] = '{}'\n }\n }\n break\n }\n\n /* OpenAI function calls */\n case 'function': {\n if (typeof value !== 'object') continue\n if (!('name' in value)) continue\n if (typeof value.name !== 'string') continue\n if (!('arguments' in value)) continue\n if (typeof value.arguments !== 'string') continue\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_NAME}`\n ] = value.name\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS}`\n ] = value.arguments\n break\n }\n }\n }\n }\n\n return attributes\n }\n\n private attribifyMessageContent(prefix: string, content: unknown) {\n let attributes: otel.Attributes = {}\n\n if (typeof content === 'string') {\n attributes[`${prefix}.${ATTR_GEN_AI_MESSAGE_CONTENT}`] = content\n return attributes\n }\n\n try {\n attributes[`${prefix}.${ATTR_GEN_AI_MESSAGE_CONTENT}`] =\n JSON.stringify(content)\n } catch (error) {\n attributes[`${prefix}.${ATTR_GEN_AI_MESSAGE_CONTENT}`] = '[]'\n }\n\n if (!Array.isArray(content)) return attributes\n\n /* Tool calls for Anthropic and PromptL are in the content */\n const toolCalls = []\n for (const item of content) {\n for (const key in item) {\n if (this.toCamelCase(key) !== 'type') continue\n if (typeof item[key] !== 'string') continue\n if (item[key] !== 'tool-call' && item[key] !== 'tool_use') continue\n toolCalls.push(item)\n }\n }\n\n if (toolCalls.length > 0) {\n attributes = {\n ...attributes,\n ...this.attribifyMessageToolCalls(prefix, toolCalls),\n }\n }\n\n return attributes\n }\n\n private attribifyMessages(\n direction: 'input' | 'output',\n messages: Record<string, unknown>[],\n ) {\n const prefix =\n direction === 'input' ? ATTR_GEN_AI_PROMPTS : ATTR_GEN_AI_COMPLETIONS\n\n let attributes: otel.Attributes = {}\n for (let i = 0; i < messages.length; i++) {\n for (const key in messages[i]!) {\n const field = this.toCamelCase(key)\n let value = messages[i]![key]\n if (value === null || value === undefined) continue\n\n switch (field) {\n case 'role': {\n if (typeof value !== 'string') continue\n attributes[`${prefix}.${i}.${ATTR_GEN_AI_MESSAGE_ROLE}`] = value\n break\n }\n\n /* Tool calls for Anthropic and PromptL are in the content */\n case 'content': {\n attributes = {\n ...attributes,\n ...this.attribifyMessageContent(`${prefix}.${i}`, value),\n }\n break\n }\n\n /* Tool calls for OpenAI */\n case 'toolCalls': {\n if (!Array.isArray(value)) continue\n attributes = {\n ...attributes,\n ...this.attribifyMessageToolCalls(`${prefix}.${i}`, value),\n }\n break\n }\n\n /* Tool result for OpenAI / Anthropic / PromptL */\n\n case 'toolCallId':\n case 'toolId':\n case 'toolUseId': {\n if (typeof value !== 'string') continue\n attributes[`${prefix}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALL_ID}`] =\n value\n break\n }\n\n case 'toolName': {\n if (typeof value !== 'string') continue\n attributes[`${prefix}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_NAME}`] =\n value\n break\n }\n\n // Note: 'toolResult' is 'content' itself\n\n case 'isError': {\n if (typeof value !== 'boolean') continue\n attributes[\n `${prefix}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_RESULT_IS_ERROR}`\n ] = value\n break\n }\n }\n }\n }\n\n return attributes\n }\n\n private attribifyConfiguration(\n direction: 'input' | 'output',\n configuration: Record<string, unknown>,\n ) {\n const prefix =\n direction === 'input' ? ATTR_GEN_AI_REQUEST : ATTR_GEN_AI_RESPONSE\n\n const attributes: otel.Attributes = {}\n for (const key in configuration) {\n const field = this.toSnakeCase(key)\n let value = configuration[key]\n if (value === null || value === undefined) continue\n if (typeof value === 'object' && !Array.isArray(value)) {\n try {\n value = JSON.stringify(value)\n } catch (error) {\n value = '{}'\n }\n }\n\n attributes[`${prefix}.${field}`] = value as any\n }\n\n return attributes\n }\n\n completion(ctx: otel.Context, options: StartCompletionSpanOptions) {\n const start = options\n\n const configuration = {\n ...start.configuration,\n model: start.model,\n }\n let jsonConfiguration = ''\n try {\n jsonConfiguration = JSON.stringify(configuration)\n } catch (error) {\n jsonConfiguration = '{}'\n }\n const attrConfiguration = this.attribifyConfiguration(\n 'input',\n configuration,\n )\n\n let jsonInput = ''\n try {\n jsonInput = JSON.stringify(start.input)\n } catch (error) {\n jsonInput = '[]'\n }\n const attrInput = this.attribifyMessages('input', start.input)\n\n const span = this.span(\n ctx,\n start.name || `${start.provider} / ${start.model}`,\n SpanType.Completion,\n {\n attributes: {\n [ATTR_GEN_AI_SYSTEM]: start.provider,\n [ATTR_GEN_AI_REQUEST_CONFIGURATION]: jsonConfiguration,\n ...attrConfiguration,\n [ATTR_GEN_AI_REQUEST_MESSAGES]: jsonInput,\n ...attrInput,\n ...(start.attributes || {}),\n },\n },\n )\n\n return {\n context: span.context,\n end: (options: EndCompletionSpanOptions) => {\n const end = options\n\n let jsonOutput = ''\n try {\n jsonOutput = JSON.stringify(end.output)\n } catch (error) {\n jsonOutput = '[]'\n }\n const attrOutput = this.attribifyMessages('output', end.output)\n\n const inputTokens = end.tokens.prompt + end.tokens.cached\n const outputTokens = end.tokens.reasoning + end.tokens.completion\n\n span.end({\n attributes: {\n [ATTR_GEN_AI_RESPONSE_MESSAGES]: jsonOutput,\n ...attrOutput,\n [ATTR_GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,\n [ATTR_GEN_AI_USAGE_PROMPT_TOKENS]: end.tokens.prompt,\n [ATTR_GEN_AI_USAGE_CACHED_TOKENS]: end.tokens.cached,\n [ATTR_GEN_AI_USAGE_REASONING_TOKENS]: end.tokens.reasoning,\n [ATTR_GEN_AI_USAGE_COMPLETION_TOKENS]: end.tokens.completion,\n [ATTR_GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,\n [ATTR_GEN_AI_RESPONSE_MODEL]: start.model,\n [ATTR_GEN_AI_RESPONSE_FINISH_REASONS]: [end.finishReason],\n ...(end.attributes || {}),\n },\n })\n },\n fail: span.fail,\n }\n }\n\n embedding(ctx: otel.Context, options?: StartSpanOptions) {\n return this.span(\n ctx,\n options?.name || 'Embedding',\n SpanType.Embedding,\n options,\n )\n }\n\n retrieval(ctx: otel.Context, options?: StartSpanOptions) {\n return this.span(\n ctx,\n options?.name || 'Retrieval',\n SpanType.Retrieval,\n options,\n )\n }\n\n reranking(ctx: otel.Context, options?: StartSpanOptions) {\n return this.span(\n ctx,\n options?.name || 'Reranking',\n SpanType.Reranking,\n options,\n )\n }\n\n private attribifyHeaders(\n direction: 'request' | 'response',\n headers: Record<string, string>,\n ) {\n const prefix =\n direction === 'request'\n ? ATTR_HTTP_REQUEST_HEADERS\n : ATTR_HTTP_RESPONSE_HEADERS\n\n const attributes: otel.Attributes = {}\n for (const key in headers) {\n const field = this.toKebabCase(key)\n const value = headers[key]\n if (value === null || value === undefined) continue\n\n attributes[`${prefix}.${field}`] = value as any\n }\n\n return attributes\n }\n\n http(ctx: otel.Context, options: StartHttpSpanOptions) {\n const start = options\n\n const method = start.request.method.toUpperCase()\n\n const attrHeaders = this.attribifyHeaders('request', start.request.headers)\n\n let finalBody = ''\n if (typeof start.request.body === 'string') {\n finalBody = start.request.body\n } else {\n try {\n finalBody = JSON.stringify(start.request.body)\n } catch (error) {\n finalBody = '{}'\n }\n }\n\n const span = this.span(\n ctx,\n start.name || `${method} ${start.request.url}`,\n SpanType.Http,\n {\n attributes: {\n [ATTR_HTTP_REQUEST_METHOD]: method,\n [ATTR_HTTP_REQUEST_URL]: start.request.url,\n ...attrHeaders,\n [ATTR_HTTP_REQUEST_BODY]: finalBody,\n ...(start.attributes || {}),\n },\n },\n )\n\n return {\n context: span.context,\n end: (options: EndHttpSpanOptions) => {\n const end = options\n\n const attrHeaders = this.attribifyHeaders(\n 'response',\n end.response.headers,\n )\n\n let finalBody = ''\n if (typeof end.response.body === 'string') {\n finalBody = end.response.body\n } else {\n try {\n finalBody = JSON.stringify(end.response.body)\n } catch (error) {\n finalBody = '{}'\n }\n }\n\n span.end({\n attributes: {\n [ATTR_HTTP_RESPONSE_STATUS_CODE]: end.response.status,\n ...attrHeaders,\n [ATTR_HTTP_RESPONSE_BODY]: finalBody,\n ...(end.attributes || {}),\n },\n })\n },\n fail: span.fail,\n }\n }\n\n private segment<T extends SegmentType>(\n ctx: otel.Context,\n type: T,\n data: SegmentBaggage<T>['data'],\n options?: SegmentOptions,\n ) {\n options = options || {}\n\n let baggage = this.baggage(ctx)\n const parent = baggage?.segments.at(-1)\n const segments = baggage?.segments || []\n\n segments.push({\n ...({\n id: options._internal?.id || uuid(),\n ...(parent?.id && { parentId: parent.id }),\n source: options._internal?.source || parent?.source || this.source,\n type: type,\n data: data,\n } as SegmentBaggage<T>),\n traceparent: 'undefined',\n tracestate: undefined,\n })\n const segment = segments.at(-1)!\n\n baggage = {\n segment: { id: segment.id, parentId: segment.parentId },\n segments: segments,\n }\n\n ctx = this.setBaggage(ctx, baggage, options.baggage)\n\n // Dummy wrapper to force the same trace and carry on some segment attributes\n const span = this.span(ctx, type, SpanType.Segment, {\n attributes: options.attributes,\n })\n\n let carrier = {} as TraceContext\n propagation.inject(span.context, carrier)\n\n baggage.segments.at(-1)!.traceparent = carrier.traceparent\n baggage.segments.at(-1)!.tracestate = carrier.tracestate\n\n // Fix current segment span segments attribute now that we know the trace\n trace\n .getSpan(span.context)!\n .setAttribute(ATTR_LATITUDE_SEGMENTS, JSON.stringify(baggage.segments))\n\n ctx = this.setBaggage(span.context, baggage, options.baggage)\n\n return { context: ctx, end: span.end, fail: span.fail }\n }\n\n prompt(\n ctx: otel.Context,\n {\n logUuid,\n versionUuid,\n promptUuid,\n experimentUuid,\n externalId,\n template,\n parameters,\n ...rest\n }: PromptSegmentOptions,\n ) {\n const baggage = {\n ...(logUuid && { logUuid }), // TODO(tracing): temporal related log, remove when observability is ready\n commitUuid: versionUuid || HEAD_COMMIT,\n documentUuid: promptUuid,\n ...(experimentUuid && { experimentUuid }),\n ...(externalId && { externalId }),\n }\n\n let jsonParameters = ''\n try {\n jsonParameters = JSON.stringify(parameters || {})\n } catch (error) {\n jsonParameters = '{}'\n }\n\n const attributes = {\n [ATTR_GEN_AI_REQUEST_TEMPLATE]: template,\n [ATTR_GEN_AI_REQUEST_PARAMETERS]: jsonParameters,\n ...(rest.attributes || {}),\n }\n\n return this.segment(ctx, SegmentType.Document, baggage, {\n ...rest,\n attributes,\n })\n }\n\n step(ctx: otel.Context, options?: SegmentOptions) {\n return this.segment(ctx, SegmentType.Step, undefined, options)\n }\n}\n","import { BaseInstrumentation } from '$telemetry/instrumentations/base'\nimport { ManualInstrumentation } from '$telemetry/instrumentations/manual'\nimport {\n GEN_AI_RESPONSE_FINISH_REASON_VALUE_STOP,\n GEN_AI_RESPONSE_FINISH_REASON_VALUE_TOOL_CALLS,\n SegmentSource,\n TraceContext,\n} from '@latitude-data/constants'\nimport type * as latitude from '@latitude-data/sdk'\nimport * as otel from '@opentelemetry/api'\nimport { context } from '@opentelemetry/api'\nimport type * as promptl from 'promptl-ai'\n\nexport type LatitudeInstrumentationOptions = {\n module: typeof latitude.Latitude\n completions?: boolean\n}\n\nexport class LatitudeInstrumentation implements BaseInstrumentation {\n private readonly options: LatitudeInstrumentationOptions\n private readonly telemetry: ManualInstrumentation\n\n constructor(\n source: SegmentSource,\n tracer: otel.Tracer,\n options: LatitudeInstrumentationOptions,\n ) {\n this.telemetry = new ManualInstrumentation(source, tracer)\n this.options = options\n }\n\n isEnabled() {\n return this.telemetry.isEnabled()\n }\n\n enable() {\n this.options.module.instrument(this)\n this.telemetry.enable()\n }\n\n disable() {\n this.telemetry.disable()\n this.options.module.uninstrument()\n }\n\n private countTokens<M extends promptl.AdapterMessageType>(messages: M[]) {\n let length = 0\n\n for (const message of messages) {\n if (!('content' in message)) continue\n if (typeof message.content === 'string') {\n length += message.content.length\n } else if (Array.isArray(message.content)) {\n for (const content of message.content) {\n if (content.type === 'text') {\n length += content.text.length\n }\n }\n }\n }\n\n // Note: this is an estimation to not bundle a tokenizer\n return Math.ceil(length / 4)\n }\n\n withTraceContext<F extends () => ReturnType<F>>(\n ctx: TraceContext,\n fn: F,\n ): ReturnType<F> {\n return context.with(this.telemetry.resume(ctx), fn)\n }\n\n async wrapToolHandler<\n F extends latitude.ToolHandler<latitude.ToolSpec, keyof latitude.ToolSpec>,\n >(fn: F, ...args: Parameters<F>): Promise<Awaited<ReturnType<F>>> {\n const toolArguments = args[0]\n const { toolId, toolName } = args[1]\n\n const $tool = this.telemetry.tool(context.active(), {\n name: toolName,\n call: {\n id: toolId,\n arguments: toolArguments,\n },\n })\n\n let result\n try {\n result = await context.with(\n $tool.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n if ((error as Error).name === 'ToolExecutionPausedError') {\n $tool.fail(error as Error)\n throw error\n }\n\n $tool.end({\n result: {\n value: (error as Error).message,\n isError: true,\n },\n })\n throw error\n }\n\n $tool.end({\n result: {\n value: result,\n isError: false,\n },\n })\n\n return result\n }\n\n async wrapRenderChain<F extends latitude.Latitude['renderChain']>(\n fn: F,\n ...args: Parameters<F>\n ): Promise<Awaited<ReturnType<F>>> {\n const { prompt, parameters } = args[0]\n\n const $prompt = this.telemetry.prompt(context.active(), {\n versionUuid: prompt.versionUuid,\n promptUuid: prompt.uuid,\n template: prompt.content,\n parameters: parameters,\n })\n\n let result\n try {\n result = await context.with(\n $prompt.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n $prompt.fail(error as Error)\n throw error\n }\n\n $prompt.end()\n\n return result\n }\n\n async wrapRenderAgent<F extends latitude.Latitude['renderAgent']>(\n fn: F,\n ...args: Parameters<F>\n ): Promise<Awaited<ReturnType<F>>> {\n const { prompt, parameters } = args[0]\n\n const $prompt = this.telemetry.prompt(context.active(), {\n versionUuid: prompt.versionUuid,\n promptUuid: prompt.uuid,\n template: prompt.content,\n parameters: parameters,\n })\n\n let result\n try {\n result = await context.with(\n $prompt.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n $prompt.fail(error as Error)\n throw error\n }\n\n $prompt.end()\n\n return result\n }\n\n async wrapRenderStep<F extends latitude.Latitude['renderStep']>(\n fn: F,\n ...args: Parameters<F>\n ): Promise<Awaited<ReturnType<F>>> {\n const $step = this.telemetry.step(context.active())\n\n let result\n try {\n result = await context.with(\n $step.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n $step.fail(error as Error)\n throw error\n }\n\n $step.end()\n\n return result\n }\n\n async wrapRenderCompletion<F extends latitude.Latitude['renderCompletion']>(\n fn: F,\n ...args: Parameters<F>\n ): Promise<Awaited<ReturnType<F>>> {\n if (!this.options.completions) {\n return await ((fn as any)(...args) as ReturnType<F>)\n }\n\n const { provider, config, messages } = args[0]\n const model = (config.model as string) || 'unknown'\n\n const $completion = this.telemetry.completion(context.active(), {\n name: `${provider} / ${model}`,\n provider: provider,\n model: model,\n configuration: config,\n input: messages as Record<string, unknown>[],\n })\n\n let result\n try {\n result = await context.with(\n $completion.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n $completion.fail(error as Error)\n throw error\n }\n\n // Note: enhance, this is just an estimation\n const promptTokens = this.countTokens(messages)\n const completionTokens = this.countTokens(result.messages)\n\n $completion.end({\n output: result.messages as Record<string, unknown>[],\n tokens: {\n prompt: promptTokens,\n cached: 0,\n reasoning: 0,\n completion: completionTokens,\n },\n finishReason:\n result.toolRequests.length > 0\n ? GEN_AI_RESPONSE_FINISH_REASON_VALUE_TOOL_CALLS\n : GEN_AI_RESPONSE_FINISH_REASON_VALUE_STOP,\n })\n\n return result\n }\n\n async wrapRenderTool<F extends latitude.Latitude['renderTool']>(\n fn: F,\n ...args: Parameters<F>\n ): Promise<Awaited<ReturnType<F>>> {\n const { toolRequest } = args[0]\n\n const $tool = this.telemetry.tool(context.active(), {\n name: toolRequest.toolName,\n call: {\n id: toolRequest.toolCallId,\n arguments: toolRequest.toolArguments,\n },\n })\n\n let result\n try {\n result = await context.with(\n $tool.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n $tool.fail(error as Error)\n throw error\n }\n\n $tool.end({\n result: {\n value: result,\n isError: false, // Note: currently unknown\n },\n })\n\n return result\n }\n}\n","import { env } from '$telemetry/env'\nimport {\n BaseInstrumentation,\n LatitudeInstrumentation,\n LatitudeInstrumentationOptions,\n ManualInstrumentation,\n PromptSegmentOptions,\n SegmentOptions,\n StartCompletionSpanOptions,\n StartHttpSpanOptions,\n StartSpanOptions,\n StartToolSpanOptions,\n} from '$telemetry/instrumentations'\nimport { DEFAULT_REDACT_SPAN_PROCESSOR } from '$telemetry/sdk/redact'\nimport {\n InstrumentationScope,\n SCOPE_LATITUDE,\n SegmentSource,\n TraceContext,\n} from '@latitude-data/constants'\nimport * as otel from '@opentelemetry/api'\nimport { context, propagation, TextMapPropagator } from '@opentelemetry/api'\nimport {\n ALLOW_ALL_BAGGAGE_KEYS,\n BaggageSpanProcessor,\n} from '@opentelemetry/baggage-span-processor'\nimport { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks'\nimport {\n CompositePropagator,\n W3CBaggagePropagator,\n W3CTraceContextPropagator,\n} from '@opentelemetry/core'\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'\nimport { registerInstrumentations } from '@opentelemetry/instrumentation'\nimport { Resource } from '@opentelemetry/resources'\nimport {\n BatchSpanProcessor,\n NodeTracerProvider,\n SimpleSpanProcessor,\n SpanExporter,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-node'\nimport { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions'\nimport { AnthropicInstrumentation } from '@traceloop/instrumentation-anthropic'\nimport { AzureOpenAIInstrumentation } from '@traceloop/instrumentation-azure'\nimport { BedrockInstrumentation } from '@traceloop/instrumentation-bedrock'\nimport { CohereInstrumentation } from '@traceloop/instrumentation-cohere'\nimport { LangChainInstrumentation } from '@traceloop/instrumentation-langchain'\nimport { LlamaIndexInstrumentation } from '@traceloop/instrumentation-llamaindex'\nimport { OpenAIInstrumentation } from '@traceloop/instrumentation-openai'\nimport { TogetherInstrumentation } from '@traceloop/instrumentation-together'\nimport {\n AIPlatformInstrumentation,\n VertexAIInstrumentation,\n} from '@traceloop/instrumentation-vertexai'\n\nimport type * as anthropic from '@anthropic-ai/sdk'\nimport type * as bedrock from '@aws-sdk/client-bedrock-runtime'\nimport type * as azure from '@azure/openai'\nimport type * as aiplatform from '@google-cloud/aiplatform'\nimport type * as vertexai from '@google-cloud/vertexai'\nimport type * as langchain_runnables from '@langchain/core/runnables'\nimport type * as langchain_vectorstores from '@langchain/core/vectorstores'\nimport type * as latitude from '@latitude-data/sdk'\nimport type * as cohere from 'cohere-ai'\nimport type * as langchain_agents from 'langchain/agents'\nimport type * as langchain_chains from 'langchain/chains'\nimport type * as langchain_tools from 'langchain/tools'\nimport type * as llamaindex from 'llamaindex'\nimport type * as openai from 'openai'\nimport type * as togetherai from 'together-ai'\n\nconst TRACES_URL = `${env.GATEWAY_BASE_URL}/api/v3/otlp/v1/traces`\nconst SERVICE_NAME = process.env.npm_package_name || 'unknown'\nconst SCOPE_VERSION = process.env.npm_package_version || 'unknown'\n\nexport type TelemetryContext = otel.Context\nexport const BACKGROUND = () => otel.ROOT_CONTEXT\n\nclass ScopedTracerProvider implements otel.TracerProvider {\n private readonly scope: string\n private readonly version: string\n private readonly provider: otel.TracerProvider\n\n constructor(scope: string, version: string, provider: otel.TracerProvider) {\n this.scope = scope\n this.version = version\n this.provider = provider\n }\n\n getTracer(_name: string, _version?: string, options?: otel.TracerOptions) {\n return this.provider.getTracer(this.scope, this.version, options)\n }\n}\n\nexport const DEFAULT_SPAN_EXPORTER = (apiKey: string) =>\n new OTLPTraceExporter({\n url: TRACES_URL,\n headers: {\n Authorization: `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n },\n timeoutMillis: 30 * 1000,\n })\n\n// Note: Only exporting typescript instrumentations\nexport enum Instrumentation {\n Latitude = InstrumentationScope.Latitude,\n OpenAI = InstrumentationScope.OpenAI,\n Anthropic = InstrumentationScope.Anthropic,\n AzureOpenAI = InstrumentationScope.AzureOpenAI,\n VercelAI = InstrumentationScope.VercelAI,\n VertexAI = InstrumentationScope.VertexAI,\n AIPlatform = InstrumentationScope.AIPlatform,\n Bedrock = InstrumentationScope.Bedrock,\n TogetherAI = InstrumentationScope.TogetherAI,\n Cohere = InstrumentationScope.Cohere,\n Langchain = InstrumentationScope.Langchain,\n LlamaIndex = InstrumentationScope.LlamaIndex,\n}\n\nexport type TelemetryOptions = {\n instrumentations?: {\n [Instrumentation.Latitude]?:\n | typeof latitude.Latitude\n | LatitudeInstrumentationOptions\n [Instrumentation.OpenAI]?: typeof openai.OpenAI\n [Instrumentation.Anthropic]?: typeof anthropic\n [Instrumentation.AzureOpenAI]?: typeof azure\n [Instrumentation.VercelAI]?: 'manual'\n [Instrumentation.VertexAI]?: typeof vertexai\n [Instrumentation.AIPlatform]?: typeof aiplatform\n [Instrumentation.Bedrock]?: typeof bedrock\n [Instrumentation.TogetherAI]?: typeof togetherai.Together\n [Instrumentation.Cohere]?: typeof cohere\n [Instrumentation.Langchain]?: {\n chainsModule: typeof langchain_chains\n agentsModule: typeof langchain_agents\n toolsModule: typeof langchain_tools\n vectorStoreModule: typeof langchain_vectorstores\n runnablesModule: typeof langchain_runnables\n }\n [Instrumentation.LlamaIndex]?: typeof llamaindex\n }\n disableBatch?: boolean\n exporter?: SpanExporter\n processors?: SpanProcessor[]\n propagators?: TextMapPropagator[]\n}\n\nexport class LatitudeTelemetry {\n private options: TelemetryOptions\n private provider: NodeTracerProvider\n private telemetry: ManualInstrumentation\n private instrumentations: BaseInstrumentation[]\n\n constructor(apiKey: string, options?: TelemetryOptions) {\n this.options = options || {}\n\n if (!this.options.exporter) {\n this.options.exporter = DEFAULT_SPAN_EXPORTER(apiKey)\n }\n\n context.setGlobalContextManager(\n new AsyncLocalStorageContextManager().enable(),\n )\n\n propagation.setGlobalPropagator(\n new CompositePropagator({\n propagators: [\n ...(this.options.propagators || []),\n new W3CTraceContextPropagator(),\n new W3CBaggagePropagator(),\n ],\n }),\n )\n\n this.provider = new NodeTracerProvider({\n resource: new Resource({ [ATTR_SERVICE_NAME]: SERVICE_NAME }),\n })\n\n // Note: important, must run before the exporter span processors\n this.provider.addSpanProcessor(\n new BaggageSpanProcessor(ALLOW_ALL_BAGGAGE_KEYS),\n )\n\n if (this.options.processors) {\n this.options.processors.forEach((processor) => {\n this.provider.addSpanProcessor(processor)\n })\n } else {\n this.provider.addSpanProcessor(DEFAULT_REDACT_SPAN_PROCESSOR())\n }\n\n if (this.options.disableBatch) {\n this.provider.addSpanProcessor(\n new SimpleSpanProcessor(this.options.exporter),\n )\n } else {\n this.provider.addSpanProcessor(\n new BatchSpanProcessor(this.options.exporter),\n )\n }\n\n this.provider.register()\n\n process.on('SIGTERM', async () => this.shutdown)\n process.on('SIGINT', async () => this.shutdown)\n\n this.telemetry = null as unknown as ManualInstrumentation\n this.instrumentations = []\n this.initInstrumentations()\n this.instrument()\n }\n\n async flush() {\n await this.provider.forceFlush()\n await this.options.exporter!.forceFlush?.()\n }\n\n async shutdown() {\n await this.flush()\n await this.provider.shutdown()\n await this.options.exporter!.shutdown?.()\n }\n\n tracerProvider(instrumentation: Instrumentation) {\n return new ScopedTracerProvider(\n `${SCOPE_LATITUDE}.${instrumentation}`,\n SCOPE_VERSION,\n this.provider,\n )\n }\n\n tracer(instrumentation: Instrumentation) {\n return this.tracerProvider(instrumentation).getTracer('')\n }\n\n // TODO(tracing): auto instrument outgoing HTTP requests\n private initInstrumentations() {\n this.instrumentations = []\n\n const tracer = this.tracer(InstrumentationScope.Manual as any)\n this.telemetry = new ManualInstrumentation(SegmentSource.API, tracer)\n this.instrumentations.push(this.telemetry)\n\n const latitude = this.options.instrumentations?.latitude\n if (latitude) {\n const tracer = this.tracer(Instrumentation.Latitude)\n const instrumentation = new LatitudeInstrumentation(\n SegmentSource.API,\n tracer,\n typeof latitude === 'object' ? latitude : { module: latitude },\n )\n this.instrumentations.push(instrumentation)\n }\n\n const openai = this.options.instrumentations?.openai\n if (openai) {\n const provider = this.tracerProvider(Instrumentation.OpenAI)\n const instrumentation = new OpenAIInstrumentation({ enrichTokens: true })\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(openai)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const anthropic = this.options.instrumentations?.anthropic\n if (anthropic) {\n const provider = this.tracerProvider(Instrumentation.Anthropic)\n const instrumentation = new AnthropicInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(anthropic)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const azure = this.options.instrumentations?.azure\n if (azure) {\n const provider = this.tracerProvider(Instrumentation.AzureOpenAI)\n const instrumentation = new AzureOpenAIInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(azure)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const vertexai = this.options.instrumentations?.vertexai\n if (vertexai) {\n const provider = this.tracerProvider(Instrumentation.VertexAI)\n const instrumentation = new VertexAIInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(vertexai)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const aiplatform = this.options.instrumentations?.aiplatform\n if (aiplatform) {\n const provider = this.tracerProvider(Instrumentation.AIPlatform)\n const instrumentation = new AIPlatformInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(aiplatform)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const bedrock = this.options.instrumentations?.bedrock\n if (bedrock) {\n const provider = this.tracerProvider(Instrumentation.Bedrock)\n const instrumentation = new BedrockInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(bedrock)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const togetherai = this.options.instrumentations?.togetherai\n if (togetherai) {\n const provider = this.tracerProvider(Instrumentation.TogetherAI)\n const instrumentation = new TogetherInstrumentation({\n enrichTokens: true,\n })\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(togetherai)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const cohere = this.options.instrumentations?.cohere\n if (cohere) {\n const provider = this.tracerProvider(Instrumentation.Cohere)\n const instrumentation = new CohereInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(cohere)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const langchain = this.options.instrumentations?.langchain\n if (langchain) {\n const provider = this.tracerProvider(Instrumentation.Langchain)\n const instrumentation = new LangChainInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(langchain)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const llamaindex = this.options.instrumentations?.llamaindex\n if (llamaindex) {\n const provider = this.tracerProvider(Instrumentation.LlamaIndex)\n const instrumentation = new LlamaIndexInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(llamaindex)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n }\n\n instrument() {\n this.instrumentations.forEach((instrumentation) => {\n if (!instrumentation.isEnabled()) instrumentation.enable()\n })\n }\n\n uninstrument() {\n this.instrumentations.forEach((instrumentation) => {\n if (instrumentation.isEnabled()) instrumentation.disable()\n })\n }\n\n baggage(ctx: otel.Context | TraceContext) {\n return this.telemetry.baggage(ctx)\n }\n\n pause(ctx: otel.Context) {\n return this.telemetry.pause(ctx)\n }\n\n resume(ctx: TraceContext) {\n return this.telemetry.resume(ctx)\n }\n\n restored(ctx: otel.Context) {\n return this.telemetry.restored(ctx)\n }\n\n restore(ctx: otel.Context) {\n return this.telemetry.restore(ctx)\n }\n\n tool(ctx: otel.Context, options: StartToolSpanOptions) {\n return this.telemetry.tool(ctx, options)\n }\n\n completion(ctx: otel.Context, options: StartCompletionSpanOptions) {\n return this.telemetry.completion(ctx, options)\n }\n\n embedding(ctx: otel.Context, options?: StartSpanOptions) {\n return this.telemetry.embedding(ctx, options)\n }\n\n retrieval(ctx: otel.Context, options?: StartSpanOptions) {\n return this.telemetry.retrieval(ctx, options)\n }\n\n reranking(ctx: otel.Context, options?: StartSpanOptions) {\n return this.telemetry.reranking(ctx, options)\n }\n\n http(ctx: otel.Context, options: StartHttpSpanOptions) {\n return this.telemetry.http(ctx, options)\n }\n\n prompt(ctx: otel.Context, options: PromptSegmentOptions) {\n return this.telemetry.prompt(ctx, options)\n }\n\n step(ctx: otel.Context, options?: SegmentOptions) {\n return this.telemetry.step(ctx, options)\n }\n}\n\nexport type {\n EndCompletionSpanOptions,\n EndHttpSpanOptions,\n EndSpanOptions,\n EndToolSpanOptions,\n ErrorOptions,\n PromptSegmentOptions,\n SegmentOptions,\n StartCompletionSpanOptions,\n StartHttpSpanOptions,\n StartSpanOptions,\n StartToolSpanOptions,\n} from '$telemetry/instrumentations'\n"],"names":["z","propagation","otel","ATTR_GEN_AI_OPERATION_NAME","trace","ATTR_GEN_AI_TOOL_NAME","ATTR_GEN_AI_TOOL_TYPE","ATTR_GEN_AI_TOOL_CALL_ID","ATTR_GEN_AI_SYSTEM","ATTR_GEN_AI_USAGE_INPUT_TOKENS","ATTR_GEN_AI_USAGE_OUTPUT_TOKENS","ATTR_GEN_AI_RESPONSE_MODEL","ATTR_GEN_AI_RESPONSE_FINISH_REASONS","ATTR_HTTP_REQUEST_METHOD","ATTR_HTTP_RESPONSE_STATUS_CODE","uuid","context","OTLPTraceExporter","Instrumentation","AsyncLocalStorageContextManager","CompositePropagator","W3CTraceContextPropagator","W3CBaggagePropagator","NodeTracerProvider","Resource","ATTR_SERVICE_NAME","BaggageSpanProcessor","ALLOW_ALL_BAGGAGE_KEYS","SimpleSpanProcessor","BatchSpanProcessor","instrumentation","OpenAIInstrumentation","registerInstrumentations","AnthropicInstrumentation","AzureOpenAIInstrumentation","VertexAIInstrumentation","AIPlatformInstrumentation","BedrockInstrumentation","TogetherInstrumentation","CohereInstrumentation","LangChainInstrumentation","LlamaIndexInstrumentation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAQa,mBAAmB,CAAA;AACtB,IAAA,OAAO;AAEf,IAAA,WAAA,CAAY,OAAmC,EAAA;AAC7C,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;AAEtB,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;AACjB,YAAA,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,UAAkB,EAAE,MAAW,KAAK,QAAQ;;;IAIrE,OAAO,CAAC,KAAmB,EAAE,QAAsB,EAAA;;;AAInD,IAAA,KAAK,CAAC,IAAkB,EAAA;AACtB,QAAA,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACtE,QAAA,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;YAC/B,IAAI,CAAC,KAAK,CAAC,UAAU;gBAAE;AACvB,YAAA,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;;AAE1E,QAAA,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,UAAU;gBAAE;AACtB,YAAA,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;;;IAI1E,UAAU,GAAA;AACR,QAAA,OAAO,OAAO,CAAC,OAAO,EAAE;;IAG1B,QAAQ,GAAA;AACN,QAAA,OAAO,OAAO,CAAC,OAAO,EAAE;;AAGlB,IAAA,YAAY,CAAC,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EAAE,OAA0B,EAAA;QACrD,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC;;IAG/C,SAAS,CAAC,GAAiB,EAAE,OAA0B,EAAA;QACrD,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC;;IAG/C,SAAS,CAAC,GAAiB,EAAE,OAA0B,EAAA;QACrD,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC;;IAG/C,IAAI,CAAC,GAAiB,EAAE,OAA6B,EAAA;QACnD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC;;IAG1C,MAAM,CAAC,GAAiB,EAAE,OAA6B,EAAA;QACrD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC;;IAG5C,IAAI,CAAC,GAAiB,EAAE,OAAwB,EAAA;QAC9C,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC;;AAE3C;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/sdk/redact.ts","../../../../src/env/env.ts","../../../../../../constants/src/tracing/segment.ts","../../../../../../constants/src/tracing/span.ts","../../../../../../constants/src/tracing/trace.ts","../../../../../../constants/src/tracing/index.ts","../../../../../../constants/src/ai.ts","../../../../../../constants/src/config.ts","../../../../../../constants/src/evaluations/shared.ts","../../../../../../constants/src/evaluations/human.ts","../../../../../../constants/src/evaluations/llm.ts","../../../../../../constants/src/evaluations/rule.ts","../../../../../../constants/src/evaluations/index.ts","../../../../../../constants/src/events/legacy.ts","../../../../../../constants/src/events/events.ts","../../../../../../constants/src/integrations.ts","../../../../../../constants/src/models.ts","../../../../../../constants/src/history.ts","../../../../../../constants/src/index.ts","../../../../src/instrumentations/manual.ts","../../../../src/instrumentations/latitude.ts","../../../../src/sdk/sdk.ts"],"sourcesContent":["import * as otel from '@opentelemetry/api'\nimport { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-node'\n\nexport interface RedactSpanProcessorOptions {\n attributes: (string | RegExp)[]\n mask?: (attribute: string, value: any) => string\n}\n\nexport class RedactSpanProcessor implements SpanProcessor {\n private options: RedactSpanProcessorOptions\n\n constructor(options: RedactSpanProcessorOptions) {\n this.options = options\n\n if (!options.mask) {\n this.options.mask = (_attribute: string, _value: any) => '******'\n }\n }\n\n onStart(_span: ReadableSpan, _context: otel.Context): void {\n // Noop\n }\n\n onEnd(span: ReadableSpan): void {\n Object.assign(span.attributes, this.redactAttributes(span.attributes))\n for (const event of span.events) {\n if (!event.attributes) continue\n Object.assign(event.attributes, this.redactAttributes(event.attributes))\n }\n for (const link of span.links) {\n if (!link.attributes) continue\n Object.assign(link.attributes, this.redactAttributes(link.attributes))\n }\n }\n\n forceFlush(): Promise<void> {\n return Promise.resolve()\n }\n\n shutdown(): Promise<void> {\n return Promise.resolve()\n }\n\n private shouldRedact(attribute: string) {\n return this.options.attributes.some((pattern) => {\n if (typeof pattern === 'string') {\n return attribute === pattern\n } else if (pattern instanceof RegExp) {\n return pattern.test(attribute)\n }\n return false\n })\n }\n\n private redactAttributes(attributes: otel.Attributes) {\n const redacted: otel.Attributes = {}\n\n for (const [key, value] of Object.entries(attributes)) {\n if (this.shouldRedact(key)) {\n redacted[key] = this.options.mask!(key, value)\n }\n }\n\n return redacted\n }\n}\n\nexport const DEFAULT_REDACT_SPAN_PROCESSOR = () =>\n new RedactSpanProcessor({\n attributes: [\n /^.*auth.*$/i,\n /^.*authorization.*$/i,\n /^(?!gen_ai\\.).*token.*$/i,\n /^.*secret.*$/i,\n /^.*key.*$/i,\n /^.*password.*$/i,\n /^.*cookie.*$/i,\n /^.*session.*$/i,\n /^.*credential.*$/i,\n /^.*signature.*$/i,\n /^.*oauth.*$/i,\n /^.*saml.*$/i,\n /^.*openid.*$/i,\n /^.*refresh.*$/i,\n /^.*jwt.*$/i,\n /^.*otp.*$/i,\n /^.*mfa.*$/i,\n /^.*csrf.*$/i,\n /^.*xsrf.*$/i,\n /^.*refresh.*$/i,\n /^.*x[-_]forwarded[-_]for.*$/i,\n /^.*x[-_]real[-_]ip.*$/i,\n ],\n })\n","const DEFAULT_GATEWAY_BASE_URL =\n {\n production: 'https://gateway.latitude.so',\n development: 'http://localhost:8787',\n test: 'http://localhost:8787',\n }[process.env.NODE_ENV ?? 'development'] ?? 'http://localhost:8787'\n\nfunction GET_GATEWAY_BASE_URL() {\n if (process.env.GATEWAY_BASE_URL) {\n return process.env.GATEWAY_BASE_URL\n }\n\n if (!process.env.GATEWAY_HOSTNAME) {\n return DEFAULT_GATEWAY_BASE_URL\n }\n\n const protocol = process.env.GATEWAY_SSL ? 'https' : 'http'\n const port = process.env.GATEWAY_PORT ?? (process.env.GATEWAY_SSL ? 443 : 80)\n const hostname = process.env.GATEWAY_HOSTNAME\n\n return `${protocol}://${hostname}:${port}`\n}\n\nexport const env = { GATEWAY_BASE_URL: GET_GATEWAY_BASE_URL() } as const\n","import { Message } from 'promptl-ai'\nimport { z } from 'zod'\nimport { DocumentType } from '../index'\nimport { SpanStatus } from './span'\n\nexport enum SegmentSource {\n API = 'api',\n Playground = 'playground',\n Evaluation = 'evaluation', // Note: from prompts of llm evaluations\n Experiment = 'experiment',\n User = 'user',\n SharedPrompt = 'shared_prompt',\n AgentAsTool = 'agent_as_tool', // TODO(tracing): deprecated, use SegmentType.Document with DocumentType.Agent instead\n EmailTrigger = 'email_trigger',\n ScheduledTrigger = 'scheduled_trigger',\n}\n\nexport enum SegmentType {\n Document = 'document',\n Step = 'step',\n}\n\nexport type SegmentSpecification<T extends SegmentType = SegmentType> = {\n name: string\n description: string\n _type?: T // TODO(tracing): required for type inference, remove this when something in the specification uses the type\n}\n\nexport const SEGMENT_SPECIFICATIONS = {\n [SegmentType.Document]: {\n name: 'Prompt',\n description: 'A prompt',\n },\n [SegmentType.Step]: {\n name: 'Step',\n description: 'A step in a prompt',\n },\n} as const satisfies {\n [T in SegmentType]: SegmentSpecification<T>\n}\n\nexport type BaseSegmentMetadata<T extends SegmentType = SegmentType> = {\n traceId: string\n segmentId: string\n type: T\n}\n\nexport type StepSegmentMetadata = BaseSegmentMetadata<SegmentType.Step> & {\n configuration: Record<string, unknown> // From the first completion span/segment\n input: Message[] // From the first completion span/segment\n // Fields below are optional if the spans had an error\n output?: Message[] // From the last completion span/segment\n}\n\nexport type DocumentSegmentMetadata =\n BaseSegmentMetadata<SegmentType.Document> &\n Omit<StepSegmentMetadata, keyof BaseSegmentMetadata<SegmentType.Step>> & {\n prompt: string // From first segment span/segment or current run or document\n parameters: Record<string, unknown> // From first segment span/segment or current run\n }\n\n// prettier-ignore\nexport type SegmentMetadata<T extends SegmentType = SegmentType> =\n T extends SegmentType.Document ? DocumentSegmentMetadata :\n T extends SegmentType.Step ? StepSegmentMetadata :\n never;\n\nexport const SEGMENT_METADATA_STORAGE_KEY = (\n workspaceId: number,\n traceId: string,\n segmentId: string,\n) => encodeURI(`workspaces/${workspaceId}/traces/${traceId}/${segmentId}`)\nexport const SEGMENT_METADATA_CACHE_TTL = 1 * 60 // 1 hour\n\nexport type Segment<T extends SegmentType = SegmentType> = {\n id: string\n traceId: string\n parentId?: string // Parent segment identifier\n workspaceId: number\n apiKeyId: number\n externalId?: string // Custom user identifier from current or inherited from parent\n name: string // Enriched when ingested\n source: SegmentSource // From current or inherited from parent\n type: T\n status: SpanStatus // From the last span/segment (errored spans have priority)\n message?: string // From the last span/segment (errored spans have priority)\n logUuid?: string // TODO(tracing): temporal related log, remove when observability is ready\n commitUuid: string // From current or inherited from parent\n documentUuid: string // From current or inherited from parent. When running an llm evaluation this is the evaluation uuid and source is Evaluation\n documentHash: string // From current run or document\n documentType: DocumentType // From current run or document\n experimentUuid?: string // From current or inherited from parent\n provider: string // From first completion span/segment or current run or document\n model: string // From first completion span/segment or current run or document\n tokens: number // Aggregated tokens from all completion spans/segments\n cost: number // Aggregated cost from all completion spans/segments\n duration: number // Elapsed time between the first and last span/segment\n startedAt: Date // From the first span/segment\n endedAt: Date // From the last span/segment\n createdAt: Date\n updatedAt: Date\n}\n\nexport type SegmentWithDetails<T extends SegmentType = SegmentType> =\n Segment<T> & {\n metadata?: SegmentMetadata<T> // Metadata is optional if the segment has not ended, had an early error or it could not be uploaded\n }\n\nconst baseSegmentBaggageSchema = z.object({\n id: z.string(),\n parentId: z.string().optional(),\n source: z.nativeEnum(SegmentSource),\n})\nexport const segmentBaggageSchema = z.discriminatedUnion('type', [\n baseSegmentBaggageSchema.extend({\n type: z.literal(SegmentType.Document),\n data: z.object({\n logUuid: z.string().optional(), // TODO(tracing): temporal related log, remove when observability is ready\n commitUuid: z.string(),\n documentUuid: z.string(),\n experimentUuid: z.string().optional(),\n externalId: z.string().optional(),\n }),\n }),\n baseSegmentBaggageSchema.extend({\n type: z.literal(SegmentType.Step),\n data: z.undefined().optional(),\n }),\n])\n\n// prettier-ignore\nexport type SegmentBaggage<T extends SegmentType = SegmentType> = Extract<z.infer<typeof segmentBaggageSchema>, { type: T }>\n","import { Message } from 'promptl-ai'\nimport { FinishReason } from '../ai'\n\nexport enum SpanKind {\n Internal = 'internal',\n Server = 'server',\n Client = 'client',\n Producer = 'producer',\n Consumer = 'consumer',\n}\n\n// Note: loosely based on OpenTelemetry GenAI semantic conventions\nexport enum SpanType {\n Tool = 'tool', // Note: asynchronous tools such as agents are conversation segments\n Completion = 'completion',\n Embedding = 'embedding',\n Retrieval = 'retrieval',\n Reranking = 'reranking',\n Http = 'http', // Note: raw HTTP requests and responses\n Segment = 'segment', // (Partial) Wrappers so spans belong to the same trace\n Unknown = 'unknown', // Other spans we don't care about\n}\n\nexport type SpanSpecification<T extends SpanType = SpanType> = {\n name: string\n description: string\n isGenAI: boolean\n isHidden: boolean\n _type?: T // TODO(tracing): required for type inference, remove this when something in the specification uses the type\n}\n\nexport const SPAN_SPECIFICATIONS = {\n [SpanType.Tool]: {\n name: 'Tool',\n description: 'A tool call',\n isGenAI: true,\n isHidden: false,\n },\n [SpanType.Completion]: {\n name: 'Completion',\n description: 'A completion call',\n isGenAI: true,\n isHidden: false,\n },\n [SpanType.Embedding]: {\n name: 'Embedding',\n description: 'An embedding call',\n isGenAI: true,\n isHidden: false,\n },\n [SpanType.Retrieval]: {\n name: 'Retrieval',\n description: 'A retrieval call',\n isGenAI: true,\n isHidden: false,\n },\n [SpanType.Reranking]: {\n name: 'Reranking',\n description: 'A reranking call',\n isGenAI: true,\n isHidden: false,\n },\n [SpanType.Http]: {\n name: 'HTTP',\n description: 'An HTTP request',\n isGenAI: false,\n isHidden: true,\n },\n [SpanType.Segment]: {\n name: 'Segment',\n description: 'A (partial) segment of a trace',\n isGenAI: false,\n isHidden: true,\n },\n [SpanType.Unknown]: {\n name: 'Unknown',\n description: 'An unknown span',\n isGenAI: false,\n isHidden: true,\n },\n} as const satisfies {\n [T in SpanType]: SpanSpecification<T>\n}\n\nexport enum SpanStatus {\n Unset = 'unset',\n Ok = 'ok',\n Error = 'error',\n}\n\n// Note: get span attribute keys from @opentelemetry/semantic-conventions/incubating\nexport type SpanAttribute = string | number | boolean | SpanAttribute[]\n\nexport type SpanEvent = {\n name: string\n timestamp: Date\n attributes: Record<string, SpanAttribute>\n}\n\nexport type SpanLink = {\n traceId: string\n spanId: string\n attributes: Record<string, SpanAttribute>\n}\n\nexport type BaseSpanMetadata<T extends SpanType = SpanType> = {\n traceId: string\n spanId: string\n type: T\n attributes: Record<string, SpanAttribute>\n events: SpanEvent[]\n links: SpanLink[]\n}\n\nexport type ToolSpanMetadata = BaseSpanMetadata<SpanType.Tool> & {\n name: string\n call: {\n id: string\n arguments: Record<string, unknown>\n }\n // Fields below are optional if the span had an error\n result?: {\n value: unknown\n isError: boolean\n }\n}\n\nexport type CompletionSpanMetadata = BaseSpanMetadata<SpanType.Completion> & {\n provider: string\n model: string\n configuration: Record<string, unknown>\n input: Message[]\n // Fields below are optional if the span had an error\n output?: Message[]\n tokens?: {\n prompt: number\n cached: number\n reasoning: number\n completion: number\n }\n cost?: number // Enriched when ingested\n finishReason?: FinishReason\n}\n\nexport type HttpSpanMetadata = BaseSpanMetadata<SpanType.Http> & {\n request: {\n method: string\n url: string\n headers: Record<string, string>\n body: string | Record<string, unknown>\n }\n // Fields below are optional if the span had an error\n response?: {\n status: number\n headers: Record<string, string>\n body: string | Record<string, unknown>\n }\n}\n\n// prettier-ignore\nexport type SpanMetadata<T extends SpanType = SpanType> =\n T extends SpanType.Tool ? ToolSpanMetadata :\n T extends SpanType.Completion ? CompletionSpanMetadata :\n T extends SpanType.Embedding ? BaseSpanMetadata<T> :\n T extends SpanType.Retrieval ? BaseSpanMetadata<T> :\n T extends SpanType.Reranking ? BaseSpanMetadata<T> :\n T extends SpanType.Http ? HttpSpanMetadata :\n T extends SpanType.Segment ? BaseSpanMetadata<T> :\n T extends SpanType.Unknown ? BaseSpanMetadata<T> :\n never;\n\nexport const SPAN_METADATA_STORAGE_KEY = (\n workspaceId: number,\n traceId: string,\n spanId: string,\n) => encodeURI(`workspaces/${workspaceId}/traces/${traceId}/${spanId}`)\nexport const SPAN_METADATA_CACHE_TTL = 24 * 60 * 60 // 1 day\n\nexport type Span<T extends SpanType = SpanType> = {\n id: string\n traceId: string\n segmentId?: string\n parentId?: string // Parent span identifier\n workspaceId: number\n apiKeyId: number\n name: string\n kind: SpanKind\n type: T\n status: SpanStatus\n message?: string\n duration: number\n startedAt: Date\n endedAt: Date\n createdAt: Date\n updatedAt: Date\n}\n\nexport type SpanWithDetails<T extends SpanType = SpanType> = Span<T> & {\n metadata?: SpanMetadata<T> // Metadata is optional if it could not be uploaded\n}\n","import { z } from 'zod'\nimport { Segment, SegmentBaggage, SegmentType } from './segment'\nimport { Span, SpanType } from './span'\n\n// Note: Traces are unmaterialized but this context is used to propagate the trace\n// See www.w3.org/TR/trace-context and w3c.github.io/baggage\nexport const traceContextSchema = z.object({\n traceparent: z.string(), // <version>-<trace-id>-<span-id>-<trace-flags>\n tracestate: z.string().optional(), // <key>=urlencoded(<value>)[,<key>=urlencoded(<value>)]*\n baggage: z.string().optional(), // <key>=urlencoded(<value>)[,<key>=urlencoded(<value>)]*\n})\nexport type TraceContext = z.infer<typeof traceContextSchema>\n\nexport type TraceBaggage = {\n segment: Pick<SegmentBaggage, 'id' | 'parentId'> // Note: helper for third-party observability services\n segments: (SegmentBaggage &\n Pick<TraceContext, 'traceparent' | 'tracestate'> & {\n paused?: boolean\n })[]\n}\n\nexport type AssembledSpan<T extends SpanType = SpanType> = Span<T> & {\n class: 'span'\n parts: AssembledSpan[]\n}\n\nexport type AssembledSegment<T extends SegmentType = SegmentType> =\n Segment<T> & {\n class: 'segment'\n parts: (AssembledSegment | AssembledSpan)[]\n }\n\n// Note: full trace structure ready to be drawn, parts are ordered by timestamp\nexport type AssembledTrace = {\n id: string\n parts: (AssembledSegment | AssembledSpan)[]\n}\n\nexport const TRACE_CACHE_TTL = 5 * 60 // 5 minutes\n","import { z } from 'zod'\n\nexport * from './segment'\nexport * from './span'\nexport * from './trace'\n\n/* Note: Instrumentation scopes from all language SDKs */\n\nexport const SCOPE_LATITUDE = 'so.latitude.instrumentation'\n\nexport enum InstrumentationScope {\n Manual = 'manual',\n Latitude = 'latitude',\n OpenAI = 'openai',\n Anthropic = 'anthropic',\n AzureOpenAI = 'azure',\n VercelAI = 'vercelai',\n VertexAI = 'vertexai',\n AIPlatform = 'aiplatform',\n MistralAI = 'mistralai', // Only python\n Bedrock = 'bedrock',\n Sagemaker = 'sagemaker', // Only python\n TogetherAI = 'togetherai',\n Replicate = 'replicate', // Only python\n Groq = 'groq', // Only python\n Cohere = 'cohere',\n LiteLLM = 'litellm', // Only python\n Langchain = 'langchain',\n LlamaIndex = 'llamaindex',\n DSPy = 'dspy', // Only python\n Haystack = 'haystack', // Only python\n Ollama = 'ollama', // Only python\n Transformers = 'transformers', // Only python\n AlephAlpha = 'alephalpha', // Only python\n}\n\n/* Note: non-standard OpenTelemetry semantic conventions used in Latitude */\n\nconst ATTR_LATITUDE = 'latitude'\n\nexport const ATTR_LATITUDE_INTERNAL = `${ATTR_LATITUDE}.internal`\n\nexport const ATTR_LATITUDE_TYPE = `${ATTR_LATITUDE}.type`\n\nexport const ATTR_LATITUDE_SEGMENT_ID = `${ATTR_LATITUDE}.segment.id`\nexport const ATTR_LATITUDE_SEGMENT_PARENT_ID = `${ATTR_LATITUDE}.segment.parent_id`\nexport const ATTR_LATITUDE_SEGMENTS = `${ATTR_LATITUDE}.segments`\n\nexport const GEN_AI_TOOL_TYPE_VALUE_FUNCTION = 'function'\nexport const ATTR_GEN_AI_TOOL_CALL_ARGUMENTS = 'gen_ai.tool.call.arguments'\nexport const ATTR_GEN_AI_TOOL_RESULT_VALUE = 'gen_ai.tool.result.value'\nexport const ATTR_GEN_AI_TOOL_RESULT_IS_ERROR = 'gen_ai.tool.result.is_error'\n\nexport const ATTR_GEN_AI_REQUEST = 'gen_ai.request'\nexport const ATTR_GEN_AI_REQUEST_MODEL = 'gen_ai.request.model'\nexport const ATTR_GEN_AI_REQUEST_CONFIGURATION = 'gen_ai.request.configuration'\nexport const ATTR_GEN_AI_REQUEST_TEMPLATE = 'gen_ai.request.template'\nexport const ATTR_GEN_AI_REQUEST_PARAMETERS = 'gen_ai.request.parameters'\nexport const ATTR_GEN_AI_REQUEST_MESSAGES = 'gen_ai.request.messages'\nexport const ATTR_GEN_AI_REQUEST_SYSTEM_PROMPT = 'gen_ai.request.system'\nexport const ATTR_GEN_AI_RESPONSE = 'gen_ai.response'\nexport const ATTR_GEN_AI_RESPONSE_MESSAGES = 'gen_ai.response.messages'\n\nexport const ATTR_GEN_AI_USAGE_PROMPT_TOKENS = 'gen_ai.usage.prompt_tokens'\nexport const ATTR_GEN_AI_USAGE_CACHED_TOKENS = 'gen_ai.usage.cached_tokens'\nexport const ATTR_GEN_AI_USAGE_REASONING_TOKENS = 'gen_ai.usage.reasoning_tokens' // prettier-ignore\nexport const ATTR_GEN_AI_USAGE_COMPLETION_TOKENS = 'gen_ai.usage.completion_tokens' // prettier-ignore\n\nexport const ATTR_GEN_AI_PROMPTS = 'gen_ai.prompt' // gen_ai.prompt.{index}.{role/content/...}\nexport const ATTR_GEN_AI_COMPLETIONS = 'gen_ai.completion' // gen_ai.completion.{index}.{role/content/...}\nexport const ATTR_GEN_AI_MESSAGE_ROLE = 'role'\nexport const ATTR_GEN_AI_MESSAGE_CONTENT = 'content' // string or object\nexport const ATTR_GEN_AI_MESSAGE_TOOL_NAME = 'tool_name'\nexport const ATTR_GEN_AI_MESSAGE_TOOL_CALL_ID = 'tool_call_id'\nexport const ATTR_GEN_AI_MESSAGE_TOOL_RESULT_IS_ERROR = 'is_error'\nexport const ATTR_GEN_AI_MESSAGE_TOOL_CALLS = 'tool_calls' // gen_ai.completion.{index}.tool_calls.{index}.{id/name/arguments}\nexport const ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ID = 'id'\nexport const ATTR_GEN_AI_MESSAGE_TOOL_CALLS_NAME = 'name'\nexport const ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS = 'arguments'\n\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_STOP = 'stop'\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_LENGTH = 'length'\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_CONTENT_FILTER = 'content_filter' // prettier-ignore\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_TOOL_CALLS = 'tool_calls'\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_ERROR = 'error'\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_OTHER = 'other'\nexport const GEN_AI_RESPONSE_FINISH_REASON_VALUE_UNKNOWN = 'unknown'\n\nexport const ATTR_HTTP_REQUEST_URL = 'http.request.url'\nexport const ATTR_HTTP_REQUEST_BODY = 'http.request.body'\nexport const ATTR_HTTP_REQUEST_HEADER = 'http.request.header'\nexport const ATTR_HTTP_REQUEST_HEADERS = 'http.request.headers'\nexport const ATTR_HTTP_RESPONSE_BODY = 'http.response.body'\nexport const ATTR_HTTP_RESPONSE_HEADER = 'http.response.header'\nexport const ATTR_HTTP_RESPONSE_HEADERS = 'http.response.headers'\n\n/* Note: non-standard OpenTelemetry semantic conventions used in other systems */\n\n// https://github.com/Arize-ai/openinference/blob/main/python/openinference-semantic-conventions/src/openinference/semconv/trace/__init__.py\nexport const GEN_AI_OPERATION_NAME_VALUE_TOOL = 'tool'\nexport const GEN_AI_OPERATION_NAME_VALUE_COMPLETION = 'completion'\nexport const GEN_AI_OPERATION_NAME_VALUE_EMBEDDING = 'embedding'\nexport const GEN_AI_OPERATION_NAME_VALUE_RETRIEVAL = 'retrieval'\nexport const GEN_AI_OPERATION_NAME_VALUE_RERANKING = 'reranking'\n\nexport const ATTR_TOOL_NAME = 'tool.name'\nexport const ATTR_TOOL_CALL_ID = 'tool_call.id'\nexport const ATTR_TOOL_CALL_FUNCTION_ARGUMENTS = 'tool_call.function.arguments'\nexport const ATTR_TOOL_CALL_FUNCTION_RESULT = 'tool_call.function.result'\n\nexport const ATTR_LLM_PROVIDER = 'llm.provider'\nexport const ATTR_LLM_SYSTEM = 'llm.system'\nexport const ATTR_LLM_MODEL_NAME = 'llm.model_name'\n\nexport const ATTR_LLM_TOKEN_COUNT_PROMPT = 'llm.token_count.prompt'\nexport const ATTR_LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_INPUT = 'llm.token_count.prompt_details.cache_input' // prettier-ignore\nexport const ATTR_LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_READ = 'llm.token_count.prompt_details.cache_read' // prettier-ignore\nexport const ATTR_LLM_TOKEN_COUNT_PROMPT_DETAILS_CACHE_WRITE = 'llm.token_count.prompt_details.cache_write' // prettier-ignore\nexport const ATTR_LLM_TOKEN_COUNT_COMPLETION_DETAILS_REASONING = 'llm.token_count.completion_details.reasoning' // prettier-ignore\nexport const ATTR_LLM_TOKEN_COUNT_COMPLETION = 'llm.token_count.completion' // prettier-ignore\n\nexport const ATTR_LLM_INVOCATION_PARAMETERS = 'llm.invocation_parameters'\n\nexport const ATTR_LLM_INPUT_MESSAGES = 'llm.input_messages'\nexport const ATTR_LLM_OUTPUT_MESSAGES = 'llm.output_messages'\n\nexport const ATTR_LLM_PROMPTS = 'llm.prompts' // llm.prompts.{index}.{role/content/...}\nexport const ATTR_LLM_COMPLETIONS = 'llm.completions' // llm.completions.{index}.{role/content/...}\n\n// https://github.com/traceloop/openllmetry/blob/main/packages/opentelemetry-semantic-conventions-ai/opentelemetry/semconv_ai/__init__.py\nexport const ATTR_LLM_REQUEST_TYPE = 'llm.request.type'\nexport const LLM_REQUEST_TYPE_VALUE_COMPLETION = 'completion'\nexport const LLM_REQUEST_TYPE_VALUE_CHAT = 'chat'\nexport const LLM_REQUEST_TYPE_VALUE_EMBEDDING = 'embedding'\nexport const LLM_REQUEST_TYPE_VALUE_RERANK = 'rerank'\n\nexport const ATTR_GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS = 'gen_ai.usage.cache_creation_input_tokens' // prettier-ignore\nexport const ATTR_GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS = 'gen_ai.usage.cache_read_input_tokens' // prettier-ignore\n\nexport const ATTR_LLM_RESPONSE_FINISH_REASON = 'llm.response.finish_reason'\nexport const ATTR_LLM_RESPONSE_STOP_REASON = 'llm.response.stop_reason'\n\n// https://ai-sdk.dev/docs/ai-sdk-core/telemetry#span-details\nexport const ATTR_AI_OPERATION_ID = 'ai.operationId'\nexport const AI_OPERATION_ID_VALUE_TOOL = 'ai.toolCall'\nexport const AI_OPERATION_ID_VALUE_GENERATE_TEXT = 'ai.generateText'\nexport const AI_OPERATION_ID_VALUE_STREAM_TEXT = 'ai.streamText'\nexport const AI_OPERATION_ID_VALUE_GENERATE_OBJECT = 'ai.generateObject'\nexport const AI_OPERATION_ID_VALUE_STREAM_OBJECT = 'ai.streamObject'\n\nexport const ATTR_AI_TOOL_CALL_NAME = 'ai.toolCall.name'\nexport const ATTR_AI_TOOL_CALL_ID = 'ai.toolCall.id'\nexport const ATTR_AI_TOOL_CALL_ARGS = 'ai.toolCall.args'\nexport const ATTR_AI_TOOL_CALL_RESULT = 'ai.toolCall.result'\n\nexport const ATTR_AI_MODEL_PROVIDER = 'ai.model.provider'\nexport const ATTR_AI_MODEL_ID = 'ai.model.id'\nexport const ATTR_AI_RESPONSE_MODEL = 'ai.response.model'\n\nexport const ATTR_AI_USAGE_PROMPT_TOKENS = 'ai.usage.promptTokens'\nexport const ATTR_AI_USAGE_COMPLETION_TOKENS = 'ai.usage.completionTokens'\n\nexport const ATTR_AI_RESPONSE_FINISH_REASON = 'ai.response.finishReason'\n\nexport const ATTR_AI_SETTINGS = 'ai.settings'\n\nexport const ATTR_AI_PROMPT_MESSAGES = 'ai.prompt.messages'\nexport const ATTR_AI_RESPONSE_TEXT = 'ai.response.text'\nexport const ATTR_AI_RESPONSE_OBJECT = 'ai.response.object'\nexport const ATTR_AI_RESPONSE_TOOL_CALLS = 'ai.response.toolCalls'\n\n/* Note: Schemas for span ingestion following OpenTelemetry service request specification */\n\nexport namespace Otlp {\n export const attributeValueSchema = z.object({\n stringValue: z.string().optional(),\n intValue: z.number().optional(),\n boolValue: z.boolean().optional(),\n arrayValue: z\n .object({\n values: z.array(\n z.object({\n stringValue: z.string().optional(),\n intValue: z.number().optional(),\n boolValue: z.boolean().optional(),\n }),\n ),\n })\n .optional(),\n })\n export type AttributeValue = z.infer<typeof attributeValueSchema>\n\n export const attributeSchema = z.object({\n key: z.string(),\n value: attributeValueSchema,\n })\n export type Attribute = z.infer<typeof attributeSchema>\n\n export const eventSchema = z.object({\n name: z.string(),\n timeUnixNano: z.string(),\n attributes: z.array(attributeSchema).optional(),\n })\n export type Event = z.infer<typeof eventSchema>\n\n export const linkSchema = z.object({\n traceId: z.string(),\n spanId: z.string(),\n attributes: z.array(attributeSchema).optional(),\n })\n export type Link = z.infer<typeof linkSchema>\n\n export enum StatusCode {\n Unset = 0,\n Ok = 1,\n Error = 2,\n }\n\n export const statusSchema = z.object({\n code: z.number(),\n message: z.string().optional(),\n })\n export type Status = z.infer<typeof statusSchema>\n\n export enum SpanKind {\n Internal = 0,\n Server = 1,\n Client = 2,\n Producer = 3,\n Consumer = 4,\n }\n\n export const spanSchema = z.object({\n traceId: z.string(),\n spanId: z.string(),\n parentSpanId: z.string().optional(),\n name: z.string(),\n kind: z.number(),\n startTimeUnixNano: z.string(),\n endTimeUnixNano: z.string(),\n status: statusSchema.optional(),\n events: z.array(eventSchema).optional(),\n links: z.array(linkSchema).optional(),\n attributes: z.array(attributeSchema).optional(),\n })\n export type Span = z.infer<typeof spanSchema>\n\n export const scopeSchema = z.object({\n name: z.string(),\n version: z.string().optional(),\n })\n export type Scope = z.infer<typeof scopeSchema>\n\n export const scopeSpanSchema = z.object({\n scope: scopeSchema,\n spans: z.array(spanSchema),\n })\n export type ScopeSpan = z.infer<typeof scopeSpanSchema>\n\n export const resourceSchema = z.object({\n attributes: z.array(attributeSchema),\n })\n export type Resource = z.infer<typeof resourceSchema>\n\n export const resourceSpanSchema = z.object({\n resource: resourceSchema,\n scopeSpans: z.array(scopeSpanSchema),\n })\n export type ResourceSpan = z.infer<typeof resourceSpanSchema>\n\n export const serviceRequestSchema = z.object({\n resourceSpans: z.array(resourceSpanSchema),\n })\n export type ServiceRequest = z.infer<typeof serviceRequestSchema>\n}\n\nexport const TRACING_JOBS_MAX_ATTEMPTS = 3\nexport const TRACING_JOBS_DELAY_BETWEEN_CONFLICTS = () =>\n (Math.floor(Math.random() * 10) + 1) * 1000 // 1-10 random seconds in order to serialize conflicts (best effort)\n","import { Message, ToolCall } from '@latitude-data/compiler'\nimport {\n LanguageModelUsage,\n TextStreamPart,\n Tool,\n FinishReason as VercelFinishReason,\n} from 'ai'\nimport { JSONSchema7 } from 'json-schema'\nimport { z } from 'zod'\n\nimport { ParameterType } from './config'\nimport { LatitudeEventData, LegacyChainEventTypes } from './events'\nimport { AzureConfig, LatitudePromptConfig } from './latitudePromptSchema'\nimport { ProviderLog } from './models'\nimport { TraceContext } from './tracing/trace'\n\nexport type AgentToolsMap = Record<string, string> // { [toolName]: agentPath }\n\nexport type ToolDefinition = JSONSchema7 & {\n description: string\n parameters: {\n type: 'object'\n properties: Record<string, JSONSchema7>\n required?: string[]\n additionalProperties: boolean\n }\n}\n\nexport type VercelProviderTool = {\n type: 'provider-defined'\n id: `${string}.${string}`\n args: Record<string, unknown>\n parameters: z.ZodObject<{}, 'strip', z.ZodTypeAny, {}, {}>\n}\n\nexport type VercelTools = Record<string, VercelProviderTool | ToolDefinition>\n\nexport type ToolDefinitionsMap = Record<string, ToolDefinition>\nexport type ToolsItem =\n | ToolDefinitionsMap // - tool_name: <tool_definition>\n | string // - latitude/* (no spaces)\n\n// Config supported by Vercel\nexport type VercelConfig = {\n provider: string\n model: string\n url?: string\n cacheControl?: boolean\n schema?: JSONSchema7\n parameters?: Record<string, { type: ParameterType }>\n tools?: VercelTools\n azure?: AzureConfig\n}\n\nexport type PartialPromptConfig = Omit<LatitudePromptConfig, 'provider'>\n\nexport type ProviderData = TextStreamPart<Record<string, Tool>>\n\nexport type ChainEventDto = ProviderData | LatitudeEventData\n\nexport type ChainCallResponseDto =\n | Omit<ChainStepResponse<'object'>, 'documentLogUuid' | 'providerLog'>\n | Omit<ChainStepResponse<'text'>, 'documentLogUuid' | 'providerLog'>\n\nexport type ChainEventDtoResponse =\n | Omit<ChainStepResponse<'object'>, 'providerLog'>\n | Omit<ChainStepResponse<'text'>, 'providerLog'>\n\nexport type StreamType = 'object' | 'text'\ntype BaseResponse = {\n text: string\n usage: LanguageModelUsage\n documentLogUuid?: string\n providerLog?: ProviderLog\n}\n\nexport type ChainStepTextResponse = BaseResponse & {\n streamType: 'text'\n reasoning?: string | undefined\n toolCalls: ToolCall[]\n}\n\nexport type ChainStepObjectResponse = BaseResponse & {\n streamType: 'object'\n object: any\n}\n\nexport type ChainStepResponse<T extends StreamType> = T extends 'text'\n ? ChainStepTextResponse\n : T extends 'object'\n ? ChainStepObjectResponse\n : never\n\nexport enum StreamEventTypes {\n Latitude = 'latitude-event',\n Provider = 'provider-event',\n}\n\nexport type LegacyChainEvent =\n | {\n data: LegacyLatitudeEventData\n event: StreamEventTypes.Latitude\n }\n | {\n data: ProviderData\n event: StreamEventTypes.Provider\n }\n\nexport type LegacyLatitudeStepEventData = {\n type: LegacyChainEventTypes.Step\n config: LatitudePromptConfig\n isLastStep: boolean\n messages: Message[]\n documentLogUuid?: string\n}\n\nexport type LegacyLatitudeStepCompleteEventData = {\n type: LegacyChainEventTypes.StepComplete\n response: ChainStepResponse<StreamType>\n documentLogUuid?: string\n}\n\nexport type LegacyLatitudeChainCompleteEventData = {\n type: LegacyChainEventTypes.Complete\n config: LatitudePromptConfig\n messages?: Message[]\n object?: any\n response: ChainStepResponse<StreamType>\n finishReason: VercelFinishReason\n documentLogUuid?: string\n}\n\nexport type LegacyLatitudeChainErrorEventData = {\n type: LegacyChainEventTypes.Error\n error: Error\n}\n\nexport type LegacyLatitudeEventData =\n | LegacyLatitudeStepEventData\n | LegacyLatitudeStepCompleteEventData\n | LegacyLatitudeChainCompleteEventData\n | LegacyLatitudeChainErrorEventData\n\nexport type RunSyncAPIResponse = {\n uuid: string\n conversation: Message[]\n toolRequests: ToolCall[]\n response: ChainCallResponseDto\n agentResponse?: { response: string } | Record<string, unknown>\n trace: TraceContext\n}\n\nexport type ChatSyncAPIResponse = RunSyncAPIResponse\n\nexport const toolCallResponseSchema = z.object({\n id: z.string(),\n name: z.string(),\n result: z.unknown(),\n isError: z.boolean().optional(),\n text: z.string().optional(),\n})\n\nexport type ToolCallResponse = z.infer<typeof toolCallResponseSchema>\n\nexport enum FinishReason {\n Stop = 'stop',\n Length = 'length',\n ContentFilter = 'content-filter',\n ToolCalls = 'tool-calls',\n Error = 'error',\n Other = 'other',\n Unknown = 'unknown',\n}\n","export enum ParameterType {\n Text = 'text',\n Image = 'image',\n File = 'file',\n}\n\nexport const LATITUDE_TOOL_PREFIX = 'lat_tool'\nexport const AGENT_TOOL_PREFIX = 'lat_agent'\nexport const AGENT_RETURN_TOOL_NAME = 'end_autonomous_chain'\nexport const FAKE_AGENT_START_TOOL_NAME = 'start_autonomous_chain'\n\nexport enum LatitudeTool {\n RunCode = 'code',\n WebSearch = 'search',\n WebExtract = 'extract',\n}\n\nexport enum LatitudeToolInternalName {\n RunCode = 'lat_tool_run_code',\n WebSearch = 'lat_tool_web_search',\n WebExtract = 'lat_tool_web_extract',\n}\n\nexport const MAX_STEPS_CONFIG_NAME = 'maxSteps'\nexport const DEFAULT_MAX_STEPS = 20\nexport const ABSOLUTE_MAX_STEPS = 150\n","import { z } from 'zod'\n\nconst actualOutputConfiguration = z.object({\n messageSelection: z.enum(['last', 'all']), // Which assistant messages to select\n contentFilter: z.enum(['text', 'image', 'file', 'tool_call']).optional(),\n parsingFormat: z.enum(['string', 'json']),\n fieldAccessor: z.string().optional(), // Field accessor to get the output from if it's a key-value format\n})\nexport type ActualOutputConfiguration = z.infer<\n typeof actualOutputConfiguration\n>\n\nconst expectedOutputConfiguration = z.object({\n parsingFormat: z.enum(['string', 'json']),\n fieldAccessor: z.string().optional(), // Field accessor to get the output from if it's a key-value format\n})\nexport type ExpectedOutputConfiguration = z.infer<\n typeof expectedOutputConfiguration\n>\n\nexport const ACCESSIBLE_OUTPUT_FORMATS = ['json']\n\nexport const baseEvaluationConfiguration = z.object({\n reverseScale: z.boolean(), // If true, lower is better, otherwise, higher is better\n actualOutput: actualOutputConfiguration.optional(), // Optional for backwards compatibility\n expectedOutput: expectedOutputConfiguration.optional(), // Optional for backwards compatibility\n})\nexport const baseEvaluationResultMetadata = z.object({\n // Configuration snapshot is defined in every metric specification\n actualOutput: z.string(),\n expectedOutput: z.string().optional(),\n datasetLabel: z.string().optional(),\n})\nexport const baseEvaluationResultError = z.object({\n message: z.string(),\n})\n","import { z } from 'zod'\nimport {\n baseEvaluationConfiguration,\n baseEvaluationResultError,\n baseEvaluationResultMetadata,\n} from './shared'\n\nconst humanEvaluationConfiguration = baseEvaluationConfiguration.extend({\n criteria: z.string().optional(),\n})\nconst humanEvaluationResultMetadata = baseEvaluationResultMetadata.extend({\n reason: z.string().optional(),\n})\nconst humanEvaluationResultError = baseEvaluationResultError.extend({})\n\n// BINARY\n\nconst humanEvaluationBinaryConfiguration = humanEvaluationConfiguration.extend({\n passDescription: z.string().optional(),\n failDescription: z.string().optional(),\n})\nconst humanEvaluationBinaryResultMetadata =\n humanEvaluationResultMetadata.extend({\n configuration: humanEvaluationBinaryConfiguration,\n })\nconst humanEvaluationBinaryResultError = humanEvaluationResultError.extend({})\nexport const HumanEvaluationBinarySpecification = {\n name: 'Binary',\n description:\n 'Judges whether the response meets the criteria. The resulting score is \"passed\" or \"failed\"',\n configuration: humanEvaluationBinaryConfiguration,\n resultMetadata: humanEvaluationBinaryResultMetadata,\n resultError: humanEvaluationBinaryResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: false,\n supportsManualEvaluation: true,\n} as const\nexport type HumanEvaluationBinaryConfiguration = z.infer<\n typeof HumanEvaluationBinarySpecification.configuration\n>\nexport type HumanEvaluationBinaryResultMetadata = z.infer<\n typeof HumanEvaluationBinarySpecification.resultMetadata\n>\nexport type HumanEvaluationBinaryResultError = z.infer<\n typeof HumanEvaluationBinarySpecification.resultError\n>\n\n// RATING\n\nconst humanEvaluationRatingConfiguration = humanEvaluationConfiguration.extend({\n minRating: z.number(),\n minRatingDescription: z.string().optional(),\n maxRating: z.number(),\n maxRatingDescription: z.string().optional(),\n minThreshold: z.number().optional(), // Threshold in rating range\n maxThreshold: z.number().optional(), // Threshold in rating range\n})\nconst humanEvaluationRatingResultMetadata =\n humanEvaluationResultMetadata.extend({\n configuration: humanEvaluationRatingConfiguration,\n })\nconst humanEvaluationRatingResultError = humanEvaluationResultError.extend({})\nexport const HumanEvaluationRatingSpecification = {\n name: 'Rating',\n description:\n 'Judges the response by rating it under a criteria. The resulting score is the rating',\n configuration: humanEvaluationRatingConfiguration,\n resultMetadata: humanEvaluationRatingResultMetadata,\n resultError: humanEvaluationRatingResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: false,\n supportsManualEvaluation: true,\n} as const\nexport type HumanEvaluationRatingConfiguration = z.infer<\n typeof HumanEvaluationRatingSpecification.configuration\n>\nexport type HumanEvaluationRatingResultMetadata = z.infer<\n typeof HumanEvaluationRatingSpecification.resultMetadata\n>\nexport type HumanEvaluationRatingResultError = z.infer<\n typeof HumanEvaluationRatingSpecification.resultError\n>\n\n/* ------------------------------------------------------------------------- */\n\nexport enum HumanEvaluationMetric {\n Binary = 'binary',\n Rating = 'rating',\n}\n\n// prettier-ignore\nexport type HumanEvaluationConfiguration<M extends HumanEvaluationMetric = HumanEvaluationMetric> =\n M extends HumanEvaluationMetric.Binary ? HumanEvaluationBinaryConfiguration :\n M extends HumanEvaluationMetric.Rating ? HumanEvaluationRatingConfiguration :\n never;\n\n// prettier-ignore\nexport type HumanEvaluationResultMetadata<M extends HumanEvaluationMetric = HumanEvaluationMetric> =\n M extends HumanEvaluationMetric.Binary ? HumanEvaluationBinaryResultMetadata :\n M extends HumanEvaluationMetric.Rating ? HumanEvaluationRatingResultMetadata :\n never;\n\n// prettier-ignore\nexport type HumanEvaluationResultError<M extends HumanEvaluationMetric = HumanEvaluationMetric> =\n M extends HumanEvaluationMetric.Binary ? HumanEvaluationBinaryResultError :\n M extends HumanEvaluationMetric.Rating ? HumanEvaluationRatingResultError :\n never;\n\nexport const HumanEvaluationSpecification = {\n name: 'Human-in-the-Loop',\n description: 'Evaluate responses using a human as a judge',\n configuration: humanEvaluationConfiguration,\n resultMetadata: humanEvaluationResultMetadata,\n resultError: humanEvaluationResultError,\n // prettier-ignore\n metrics: {\n [HumanEvaluationMetric.Binary]: HumanEvaluationBinarySpecification,\n [HumanEvaluationMetric.Rating]: HumanEvaluationRatingSpecification,\n },\n} as const\n","import { z } from 'zod'\nimport {\n baseEvaluationConfiguration,\n baseEvaluationResultError,\n baseEvaluationResultMetadata,\n} from './shared'\n\nconst llmEvaluationConfiguration = baseEvaluationConfiguration.extend({\n provider: z.string(),\n model: z.string(),\n})\nconst llmEvaluationResultMetadata = baseEvaluationResultMetadata.extend({\n evaluationLogId: z.number(),\n reason: z.string(),\n tokens: z.number(),\n cost: z.number(),\n duration: z.number(),\n})\nconst llmEvaluationResultError = baseEvaluationResultError.extend({\n runErrorId: z.number().optional(),\n})\n\n// BINARY\n\nconst llmEvaluationBinaryConfiguration = llmEvaluationConfiguration.extend({\n criteria: z.string(),\n passDescription: z.string(),\n failDescription: z.string(),\n})\nconst llmEvaluationBinaryResultMetadata = llmEvaluationResultMetadata.extend({\n configuration: llmEvaluationBinaryConfiguration,\n})\nconst llmEvaluationBinaryResultError = llmEvaluationResultError.extend({})\nexport const LlmEvaluationBinarySpecification = {\n name: 'Binary',\n description:\n 'Judges whether the response meets the criteria. The resulting score is \"passed\" or \"failed\"',\n configuration: llmEvaluationBinaryConfiguration,\n resultMetadata: llmEvaluationBinaryResultMetadata,\n resultError: llmEvaluationBinaryResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type LlmEvaluationBinaryConfiguration = z.infer<\n typeof LlmEvaluationBinarySpecification.configuration\n>\nexport type LlmEvaluationBinaryResultMetadata = z.infer<\n typeof LlmEvaluationBinarySpecification.resultMetadata\n>\nexport type LlmEvaluationBinaryResultError = z.infer<\n typeof LlmEvaluationBinarySpecification.resultError\n>\n\n// RATING\n\nconst llmEvaluationRatingConfiguration = llmEvaluationConfiguration.extend({\n criteria: z.string(),\n minRating: z.number(),\n minRatingDescription: z.string(),\n maxRating: z.number(),\n maxRatingDescription: z.string(),\n minThreshold: z.number().optional(), // Threshold in rating range\n maxThreshold: z.number().optional(), // Threshold in rating range\n})\nconst llmEvaluationRatingResultMetadata = llmEvaluationResultMetadata.extend({\n configuration: llmEvaluationRatingConfiguration,\n})\nconst llmEvaluationRatingResultError = llmEvaluationResultError.extend({})\nexport const LlmEvaluationRatingSpecification = {\n name: 'Rating',\n description:\n 'Judges the response by rating it under a criteria. The resulting score is the rating',\n configuration: llmEvaluationRatingConfiguration,\n resultMetadata: llmEvaluationRatingResultMetadata,\n resultError: llmEvaluationRatingResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type LlmEvaluationRatingConfiguration = z.infer<\n typeof LlmEvaluationRatingSpecification.configuration\n>\nexport type LlmEvaluationRatingResultMetadata = z.infer<\n typeof LlmEvaluationRatingSpecification.resultMetadata\n>\nexport type LlmEvaluationRatingResultError = z.infer<\n typeof LlmEvaluationRatingSpecification.resultError\n>\n\n// COMPARISON\n\nconst llmEvaluationComparisonConfiguration = llmEvaluationConfiguration.extend({\n criteria: z.string(),\n passDescription: z.string(),\n failDescription: z.string(),\n minThreshold: z.number().optional(), // Threshold percentage\n maxThreshold: z.number().optional(), // Threshold percentage\n})\nconst llmEvaluationComparisonResultMetadata =\n llmEvaluationResultMetadata.extend({\n configuration: llmEvaluationComparisonConfiguration,\n })\nconst llmEvaluationComparisonResultError = llmEvaluationResultError.extend({})\nexport const LlmEvaluationComparisonSpecification = {\n name: 'Comparison',\n description:\n 'Judges the response by comparing the criteria to the expected output. The resulting score is the percentage of compared criteria that is met',\n configuration: llmEvaluationComparisonConfiguration,\n resultMetadata: llmEvaluationComparisonResultMetadata,\n resultError: llmEvaluationComparisonResultError,\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type LlmEvaluationComparisonConfiguration = z.infer<\n typeof LlmEvaluationComparisonSpecification.configuration\n>\nexport type LlmEvaluationComparisonResultMetadata = z.infer<\n typeof LlmEvaluationComparisonSpecification.resultMetadata\n>\nexport type LlmEvaluationComparisonResultError = z.infer<\n typeof LlmEvaluationComparisonSpecification.resultError\n>\n\n// CUSTOM\n\nconst llmEvaluationCustomConfiguration = llmEvaluationConfiguration.extend({\n prompt: z.string(),\n minScore: z.number(),\n maxScore: z.number(),\n minThreshold: z.number().optional(), // Threshold percentage\n maxThreshold: z.number().optional(), // Threshold percentage\n})\nconst llmEvaluationCustomResultMetadata = llmEvaluationResultMetadata.extend({\n configuration: llmEvaluationCustomConfiguration,\n})\nconst llmEvaluationCustomResultError = llmEvaluationResultError.extend({})\nexport const LlmEvaluationCustomSpecification = {\n name: 'Custom',\n description:\n 'Judges the response under a criteria using a custom prompt. The resulting score is the value of criteria that is met',\n configuration: llmEvaluationCustomConfiguration,\n resultMetadata: llmEvaluationCustomResultMetadata,\n resultError: llmEvaluationCustomResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type LlmEvaluationCustomConfiguration = z.infer<\n typeof LlmEvaluationCustomSpecification.configuration\n>\nexport type LlmEvaluationCustomResultMetadata = z.infer<\n typeof LlmEvaluationCustomSpecification.resultMetadata\n>\nexport type LlmEvaluationCustomResultError = z.infer<\n typeof LlmEvaluationCustomSpecification.resultError\n>\n\nexport const LLM_EVALUATION_CUSTOM_PROMPT_DOCUMENTATION = `\n/*\n IMPORTANT: The evaluation MUST return an object with the score and reason fields.\n\n These are the available variables:\n - {{ actualOutput }} (string): The actual output to evaluate\n - {{ expectedOutput }} (string/undefined): The, optional, expected output to compare against\n - {{ conversation }} (string): The full conversation of the evaluated log\n\n - {{ messages }} (array of objects): All the messages of the conversation\n - {{ toolCalls }} (array of objects): All the tool calls of the conversation\n - {{ cost }} (number): The cost, in cents, of the evaluated log\n - {{ tokens }} (number): The tokens of the evaluated log\n - {{ duration }} (number): The duration, in seconds, of the evaluated log\n\n More info on messages and tool calls format in: https://docs.latitude.so/promptl/syntax/messages\n\n - {{ prompt }} (string): The prompt of the evaluated log\n - {{ config }} (object): The configuration of the evaluated log\n - {{ parameters }} (object): The parameters of the evaluated log\n\n More info on configuration and parameters format in: https://docs.latitude.so/promptl/syntax/configuration\n*/\n`.trim()\n\n// CUSTOM LABELED\n\nexport const LlmEvaluationCustomLabeledSpecification = {\n ...LlmEvaluationCustomSpecification,\n name: 'Custom (Labeled)',\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\n\n/* ------------------------------------------------------------------------- */\n\nexport enum LlmEvaluationMetric {\n Binary = 'binary',\n Rating = 'rating',\n Comparison = 'comparison',\n Custom = 'custom',\n CustomLabeled = 'custom_labeled',\n}\n\nexport type LlmEvaluationMetricAnyCustom =\n | LlmEvaluationMetric.Custom\n | LlmEvaluationMetric.CustomLabeled\n\n// prettier-ignore\nexport type LlmEvaluationConfiguration<M extends LlmEvaluationMetric = LlmEvaluationMetric> =\n M extends LlmEvaluationMetric.Binary ? LlmEvaluationBinaryConfiguration :\n M extends LlmEvaluationMetric.Rating ? LlmEvaluationRatingConfiguration :\n M extends LlmEvaluationMetric.Comparison ? LlmEvaluationComparisonConfiguration :\n M extends LlmEvaluationMetric.Custom ? LlmEvaluationCustomConfiguration :\n M extends LlmEvaluationMetric.CustomLabeled ? LlmEvaluationCustomConfiguration :\n never;\n\n// prettier-ignore\nexport type LlmEvaluationResultMetadata<M extends LlmEvaluationMetric = LlmEvaluationMetric> =\n M extends LlmEvaluationMetric.Binary ? LlmEvaluationBinaryResultMetadata :\n M extends LlmEvaluationMetric.Rating ? LlmEvaluationRatingResultMetadata :\n M extends LlmEvaluationMetric.Comparison ? LlmEvaluationComparisonResultMetadata :\n M extends LlmEvaluationMetric.Custom ? LlmEvaluationCustomResultMetadata :\n M extends LlmEvaluationMetric.CustomLabeled ? LlmEvaluationCustomResultMetadata :\n never;\n\n// prettier-ignore\nexport type LlmEvaluationResultError<M extends LlmEvaluationMetric = LlmEvaluationMetric> =\n M extends LlmEvaluationMetric.Binary ? LlmEvaluationBinaryResultError :\n M extends LlmEvaluationMetric.Rating ? LlmEvaluationRatingResultError :\n M extends LlmEvaluationMetric.Comparison ? LlmEvaluationComparisonResultError :\n M extends LlmEvaluationMetric.Custom ? LlmEvaluationCustomResultError :\n M extends LlmEvaluationMetric.CustomLabeled ? LlmEvaluationCustomResultError :\n never;\n\nexport const LlmEvaluationSpecification = {\n name: 'LLM-as-a-Judge',\n description: 'Evaluate responses using an LLM as a judge',\n configuration: llmEvaluationConfiguration,\n resultMetadata: llmEvaluationResultMetadata,\n resultError: llmEvaluationResultError,\n // prettier-ignore\n metrics: {\n [LlmEvaluationMetric.Binary]: LlmEvaluationBinarySpecification,\n [LlmEvaluationMetric.Rating]: LlmEvaluationRatingSpecification,\n [LlmEvaluationMetric.Comparison]: LlmEvaluationComparisonSpecification,\n [LlmEvaluationMetric.Custom]: LlmEvaluationCustomSpecification,\n [LlmEvaluationMetric.CustomLabeled]: LlmEvaluationCustomLabeledSpecification,\n },\n} as const\n\nexport const LLM_EVALUATION_PROMPT_PARAMETERS = [\n 'actualOutput',\n 'expectedOutput',\n 'conversation',\n 'cost',\n 'tokens',\n 'duration',\n 'config',\n 'toolCalls',\n 'messages',\n 'prompt',\n 'parameters',\n 'context',\n 'response',\n] as const\n\nexport type LlmEvaluationPromptParameter =\n (typeof LLM_EVALUATION_PROMPT_PARAMETERS)[number]\n","import { z } from 'zod'\nimport {\n baseEvaluationConfiguration,\n baseEvaluationResultError,\n baseEvaluationResultMetadata,\n} from './shared'\n\nconst ruleEvaluationConfiguration = baseEvaluationConfiguration.extend({})\nconst ruleEvaluationResultMetadata = baseEvaluationResultMetadata.extend({})\nconst ruleEvaluationResultError = baseEvaluationResultError.extend({})\n\n// EXACT MATCH\n\nconst ruleEvaluationExactMatchConfiguration =\n ruleEvaluationConfiguration.extend({\n caseInsensitive: z.boolean(),\n })\nconst ruleEvaluationExactMatchResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationExactMatchConfiguration,\n })\nconst ruleEvaluationExactMatchResultError = ruleEvaluationResultError.extend({})\nexport const RuleEvaluationExactMatchSpecification = {\n name: 'Exact Match',\n description:\n 'Checks if the response is exactly the same as the expected output. The resulting score is \"matched\" or \"unmatched\"',\n configuration: ruleEvaluationExactMatchConfiguration,\n resultMetadata: ruleEvaluationExactMatchResultMetadata,\n resultError: ruleEvaluationExactMatchResultError,\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationExactMatchConfiguration = z.infer<\n typeof RuleEvaluationExactMatchSpecification.configuration\n>\nexport type RuleEvaluationExactMatchResultMetadata = z.infer<\n typeof RuleEvaluationExactMatchSpecification.resultMetadata\n>\nexport type RuleEvaluationExactMatchResultError = z.infer<\n typeof RuleEvaluationExactMatchSpecification.resultError\n>\n\n// REGULAR EXPRESSION\n\nconst ruleEvaluationRegularExpressionConfiguration =\n ruleEvaluationConfiguration.extend({\n pattern: z.string(),\n })\nconst ruleEvaluationRegularExpressionResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationRegularExpressionConfiguration,\n })\nconst ruleEvaluationRegularExpressionResultError =\n ruleEvaluationResultError.extend({})\nexport const RuleEvaluationRegularExpressionSpecification = {\n name: 'Regular Expression',\n description:\n 'Checks if the response matches the regular expression. The resulting score is \"matched\" or \"unmatched\"',\n configuration: ruleEvaluationRegularExpressionConfiguration,\n resultMetadata: ruleEvaluationRegularExpressionResultMetadata,\n resultError: ruleEvaluationRegularExpressionResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationRegularExpressionConfiguration = z.infer<\n typeof RuleEvaluationRegularExpressionSpecification.configuration\n>\nexport type RuleEvaluationRegularExpressionResultMetadata = z.infer<\n typeof RuleEvaluationRegularExpressionSpecification.resultMetadata\n>\nexport type RuleEvaluationRegularExpressionResultError = z.infer<\n typeof RuleEvaluationRegularExpressionSpecification.resultError\n>\n\n// SCHEMA VALIDATION\n\nconst ruleEvaluationSchemaValidationConfiguration =\n ruleEvaluationConfiguration.extend({\n format: z.enum(['json']),\n schema: z.string(),\n })\nconst ruleEvaluationSchemaValidationResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationSchemaValidationConfiguration,\n })\nconst ruleEvaluationSchemaValidationResultError =\n ruleEvaluationResultError.extend({})\nexport const RuleEvaluationSchemaValidationSpecification = {\n name: 'Schema Validation',\n description:\n 'Checks if the response follows the schema. The resulting score is \"valid\" or \"invalid\"',\n configuration: ruleEvaluationSchemaValidationConfiguration,\n resultMetadata: ruleEvaluationSchemaValidationResultMetadata,\n resultError: ruleEvaluationSchemaValidationResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationSchemaValidationConfiguration = z.infer<\n typeof RuleEvaluationSchemaValidationSpecification.configuration\n>\nexport type RuleEvaluationSchemaValidationResultMetadata = z.infer<\n typeof RuleEvaluationSchemaValidationSpecification.resultMetadata\n>\nexport type RuleEvaluationSchemaValidationResultError = z.infer<\n typeof RuleEvaluationSchemaValidationSpecification.resultError\n>\n\n// LENGTH COUNT\n\nconst ruleEvaluationLengthCountConfiguration =\n ruleEvaluationConfiguration.extend({\n algorithm: z.enum(['character', 'word', 'sentence']),\n minLength: z.number().optional(),\n maxLength: z.number().optional(),\n })\nconst ruleEvaluationLengthCountResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationLengthCountConfiguration,\n })\nconst ruleEvaluationLengthCountResultError = ruleEvaluationResultError.extend(\n {},\n)\nexport const RuleEvaluationLengthCountSpecification = {\n name: 'Length Count',\n description:\n 'Checks if the response is of a certain length. The resulting score is the length of the response',\n configuration: ruleEvaluationLengthCountConfiguration,\n resultMetadata: ruleEvaluationLengthCountResultMetadata,\n resultError: ruleEvaluationLengthCountResultError,\n requiresExpectedOutput: false,\n supportsLiveEvaluation: true,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationLengthCountConfiguration = z.infer<\n typeof RuleEvaluationLengthCountSpecification.configuration\n>\nexport type RuleEvaluationLengthCountResultMetadata = z.infer<\n typeof RuleEvaluationLengthCountSpecification.resultMetadata\n>\nexport type RuleEvaluationLengthCountResultError = z.infer<\n typeof RuleEvaluationLengthCountSpecification.resultError\n>\n\n// LEXICAL OVERLAP\n\nconst ruleEvaluationLexicalOverlapConfiguration =\n ruleEvaluationConfiguration.extend({\n algorithm: z.enum(['substring', 'levenshtein_distance', 'rouge']),\n minOverlap: z.number().optional(), // Percentage of overlap\n maxOverlap: z.number().optional(), // Percentage of overlap\n })\nconst ruleEvaluationLexicalOverlapResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationLexicalOverlapConfiguration,\n })\nconst ruleEvaluationLexicalOverlapResultError =\n ruleEvaluationResultError.extend({})\nexport const RuleEvaluationLexicalOverlapSpecification = {\n name: 'Lexical Overlap',\n description:\n 'Checks if the response contains the expected output. The resulting score is the percentage of overlap',\n configuration: ruleEvaluationLexicalOverlapConfiguration,\n resultMetadata: ruleEvaluationLexicalOverlapResultMetadata,\n resultError: ruleEvaluationLexicalOverlapResultError,\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationLexicalOverlapConfiguration = z.infer<\n typeof RuleEvaluationLexicalOverlapSpecification.configuration\n>\nexport type RuleEvaluationLexicalOverlapResultMetadata = z.infer<\n typeof RuleEvaluationLexicalOverlapSpecification.resultMetadata\n>\nexport type RuleEvaluationLexicalOverlapResultError = z.infer<\n typeof RuleEvaluationLexicalOverlapSpecification.resultError\n>\n\n// SEMANTIC SIMILARITY\n\nconst ruleEvaluationSemanticSimilarityConfiguration =\n ruleEvaluationConfiguration.extend({\n algorithm: z.enum(['cosine_distance']),\n minSimilarity: z.number().optional(), // Percentage of similarity\n maxSimilarity: z.number().optional(), // Percentage of similarity\n })\nconst ruleEvaluationSemanticSimilarityResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationSemanticSimilarityConfiguration,\n })\nconst ruleEvaluationSemanticSimilarityResultError =\n ruleEvaluationResultError.extend({})\nexport const RuleEvaluationSemanticSimilaritySpecification = {\n name: 'Semantic Similarity',\n description:\n 'Checks if the response is semantically similar to the expected output. The resulting score is the percentage of similarity',\n configuration: ruleEvaluationSemanticSimilarityConfiguration,\n resultMetadata: ruleEvaluationSemanticSimilarityResultMetadata,\n resultError: ruleEvaluationSemanticSimilarityResultError,\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationSemanticSimilarityConfiguration = z.infer<\n typeof RuleEvaluationSemanticSimilaritySpecification.configuration\n>\nexport type RuleEvaluationSemanticSimilarityResultMetadata = z.infer<\n typeof RuleEvaluationSemanticSimilaritySpecification.resultMetadata\n>\nexport type RuleEvaluationSemanticSimilarityResultError = z.infer<\n typeof RuleEvaluationSemanticSimilaritySpecification.resultError\n>\n\n// NUMERIC SIMILARITY\n\nconst ruleEvaluationNumericSimilarityConfiguration =\n ruleEvaluationConfiguration.extend({\n algorithm: z.enum(['relative_difference']),\n minSimilarity: z.number().optional(), // Percentage of similarity\n maxSimilarity: z.number().optional(), // Percentage of similarity\n })\nconst ruleEvaluationNumericSimilarityResultMetadata =\n ruleEvaluationResultMetadata.extend({\n configuration: ruleEvaluationNumericSimilarityConfiguration,\n })\nconst ruleEvaluationNumericSimilarityResultError =\n ruleEvaluationResultError.extend({})\nexport const RuleEvaluationNumericSimilaritySpecification = {\n name: 'Numeric Similarity',\n description:\n 'Checks if the response is numerically similar to the expected output. The resulting score is the percentage of similarity',\n configuration: ruleEvaluationNumericSimilarityConfiguration,\n resultMetadata: ruleEvaluationNumericSimilarityResultMetadata,\n resultError: ruleEvaluationNumericSimilarityResultError,\n requiresExpectedOutput: true,\n supportsLiveEvaluation: false,\n supportsBatchEvaluation: true,\n supportsManualEvaluation: false,\n} as const\nexport type RuleEvaluationNumericSimilarityConfiguration = z.infer<\n typeof RuleEvaluationNumericSimilaritySpecification.configuration\n>\nexport type RuleEvaluationNumericSimilarityResultMetadata = z.infer<\n typeof RuleEvaluationNumericSimilaritySpecification.resultMetadata\n>\nexport type RuleEvaluationNumericSimilarityResultError = z.infer<\n typeof RuleEvaluationNumericSimilaritySpecification.resultError\n>\n\n/* ------------------------------------------------------------------------- */\n\nexport enum RuleEvaluationMetric {\n ExactMatch = 'exact_match',\n RegularExpression = 'regular_expression',\n SchemaValidation = 'schema_validation',\n LengthCount = 'length_count',\n LexicalOverlap = 'lexical_overlap',\n SemanticSimilarity = 'semantic_similarity',\n NumericSimilarity = 'numeric_similarity',\n}\n\n// prettier-ignore\nexport type RuleEvaluationConfiguration<M extends RuleEvaluationMetric = RuleEvaluationMetric> = \n M extends RuleEvaluationMetric.ExactMatch ? RuleEvaluationExactMatchConfiguration :\n M extends RuleEvaluationMetric.RegularExpression ? RuleEvaluationRegularExpressionConfiguration :\n M extends RuleEvaluationMetric.SchemaValidation ? RuleEvaluationSchemaValidationConfiguration :\n M extends RuleEvaluationMetric.LengthCount ? RuleEvaluationLengthCountConfiguration :\n M extends RuleEvaluationMetric.LexicalOverlap ? RuleEvaluationLexicalOverlapConfiguration :\n M extends RuleEvaluationMetric.SemanticSimilarity ? RuleEvaluationSemanticSimilarityConfiguration :\n M extends RuleEvaluationMetric.NumericSimilarity ? RuleEvaluationNumericSimilarityConfiguration :\n never;\n\n// prettier-ignore\nexport type RuleEvaluationResultMetadata<M extends RuleEvaluationMetric = RuleEvaluationMetric> = \n M extends RuleEvaluationMetric.ExactMatch ? RuleEvaluationExactMatchResultMetadata :\n M extends RuleEvaluationMetric.RegularExpression ? RuleEvaluationRegularExpressionResultMetadata :\n M extends RuleEvaluationMetric.SchemaValidation ? RuleEvaluationSchemaValidationResultMetadata :\n M extends RuleEvaluationMetric.LengthCount ? RuleEvaluationLengthCountResultMetadata :\n M extends RuleEvaluationMetric.LexicalOverlap ? RuleEvaluationLexicalOverlapResultMetadata :\n M extends RuleEvaluationMetric.SemanticSimilarity ? RuleEvaluationSemanticSimilarityResultMetadata :\n M extends RuleEvaluationMetric.NumericSimilarity ? RuleEvaluationNumericSimilarityResultMetadata :\n never;\n\n// prettier-ignore\nexport type RuleEvaluationResultError<M extends RuleEvaluationMetric = RuleEvaluationMetric> = \n M extends RuleEvaluationMetric.ExactMatch ? RuleEvaluationExactMatchResultError :\n M extends RuleEvaluationMetric.RegularExpression ? RuleEvaluationRegularExpressionResultError :\n M extends RuleEvaluationMetric.SchemaValidation ? RuleEvaluationSchemaValidationResultError :\n M extends RuleEvaluationMetric.LengthCount ? RuleEvaluationLengthCountResultError :\n M extends RuleEvaluationMetric.LexicalOverlap ? RuleEvaluationLexicalOverlapResultError :\n M extends RuleEvaluationMetric.SemanticSimilarity ? RuleEvaluationSemanticSimilarityResultError :\n M extends RuleEvaluationMetric.NumericSimilarity ? RuleEvaluationNumericSimilarityResultError :\n never;\n\nexport const RuleEvaluationSpecification = {\n name: 'Programmatic Rule',\n description: 'Evaluate responses using a programmatic rule',\n configuration: ruleEvaluationConfiguration,\n resultMetadata: ruleEvaluationResultMetadata,\n resultError: ruleEvaluationResultError,\n // prettier-ignore\n metrics: {\n [RuleEvaluationMetric.ExactMatch]: RuleEvaluationExactMatchSpecification,\n [RuleEvaluationMetric.RegularExpression]: RuleEvaluationRegularExpressionSpecification,\n [RuleEvaluationMetric.SchemaValidation]: RuleEvaluationSchemaValidationSpecification,\n [RuleEvaluationMetric.LengthCount]: RuleEvaluationLengthCountSpecification,\n [RuleEvaluationMetric.LexicalOverlap]: RuleEvaluationLexicalOverlapSpecification,\n [RuleEvaluationMetric.SemanticSimilarity]: RuleEvaluationSemanticSimilaritySpecification,\n [RuleEvaluationMetric.NumericSimilarity]: RuleEvaluationNumericSimilaritySpecification,\n },\n} as const\n","import { z } from 'zod'\nimport { SegmentSource } from '../tracing'\nimport {\n HumanEvaluationConfiguration,\n HumanEvaluationMetric,\n HumanEvaluationResultError,\n HumanEvaluationResultMetadata,\n HumanEvaluationSpecification,\n} from './human'\nimport {\n LlmEvaluationConfiguration,\n LlmEvaluationMetric,\n LlmEvaluationResultError,\n LlmEvaluationResultMetadata,\n LlmEvaluationSpecification,\n} from './llm'\nimport {\n RuleEvaluationConfiguration,\n RuleEvaluationMetric,\n RuleEvaluationResultError,\n RuleEvaluationResultMetadata,\n RuleEvaluationSpecification,\n} from './rule'\n\nexport * from './human'\nexport * from './llm'\nexport * from './rule'\nexport * from './shared'\n\nexport enum EvaluationType {\n Rule = 'rule',\n Llm = 'llm',\n Human = 'human',\n}\n\nexport const EvaluationTypeSchema = z.nativeEnum(EvaluationType)\n\n// prettier-ignore\nexport type EvaluationMetric<T extends EvaluationType = EvaluationType> =\n T extends EvaluationType.Rule ? RuleEvaluationMetric :\n T extends EvaluationType.Llm ? LlmEvaluationMetric :\n T extends EvaluationType.Human ? HumanEvaluationMetric :\n never;\n\nexport const EvaluationMetricSchema = z.union([\n z.nativeEnum(RuleEvaluationMetric),\n z.nativeEnum(LlmEvaluationMetric),\n z.nativeEnum(HumanEvaluationMetric),\n])\n\n// prettier-ignore\nexport type EvaluationConfiguration<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> =\n T extends EvaluationType.Rule ? RuleEvaluationConfiguration<M extends RuleEvaluationMetric ? M : never> :\n T extends EvaluationType.Llm ? LlmEvaluationConfiguration<M extends LlmEvaluationMetric ? M : never> :\n T extends EvaluationType.Human ? HumanEvaluationConfiguration<M extends HumanEvaluationMetric ? M : never> :\n never;\n\nexport const EvaluationConfigurationSchema = z.custom<EvaluationConfiguration>()\n\n// prettier-ignore\nexport type EvaluationResultMetadata<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> =\n T extends EvaluationType.Rule ? RuleEvaluationResultMetadata<M extends RuleEvaluationMetric ? M : never> :\n T extends EvaluationType.Llm ? LlmEvaluationResultMetadata<M extends LlmEvaluationMetric ? M : never> :\n T extends EvaluationType.Human ? HumanEvaluationResultMetadata<M extends HumanEvaluationMetric ? M : never> :\n never;\n\n// prettier-ignore\nexport const EvaluationResultMetadataSchema = z.custom<EvaluationResultMetadata>()\n\n// prettier-ignore\nexport type EvaluationResultError<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> =\n T extends EvaluationType.Rule ? RuleEvaluationResultError<M extends RuleEvaluationMetric ? M : never> :\n T extends EvaluationType.Llm ? LlmEvaluationResultError<M extends LlmEvaluationMetric ? M : never> :\n T extends EvaluationType.Human ? HumanEvaluationResultError<M extends HumanEvaluationMetric ? M : never> :\n never;\n\n// prettier-ignore\nexport const EvaluationResultErrorSchema = z.custom<EvaluationResultError>()\n\n// prettier-ignore\ntype ZodSchema<T = any> = z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, T, T>\n\nexport type EvaluationMetricSpecification<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> = {\n name: string\n description: string\n configuration: ZodSchema<EvaluationConfiguration<T, M>>\n resultMetadata: ZodSchema<EvaluationResultMetadata<T, M>>\n resultError: ZodSchema<EvaluationResultError<T, M>>\n requiresExpectedOutput: boolean\n supportsLiveEvaluation: boolean\n supportsBatchEvaluation: boolean\n supportsManualEvaluation: boolean\n}\n\nexport type EvaluationSpecification<T extends EvaluationType = EvaluationType> =\n {\n name: string\n description: string\n configuration: ZodSchema\n resultMetadata: ZodSchema\n resultError: ZodSchema\n metrics: { [M in EvaluationMetric<T>]: EvaluationMetricSpecification<T, M> }\n }\n\nexport const EVALUATION_SPECIFICATIONS = {\n [EvaluationType.Rule]: RuleEvaluationSpecification,\n [EvaluationType.Llm]: LlmEvaluationSpecification,\n [EvaluationType.Human]: HumanEvaluationSpecification,\n} as const satisfies {\n [T in EvaluationType]: EvaluationSpecification<T>\n}\ntype EvaluationSpecifications = typeof EVALUATION_SPECIFICATIONS\n\n// prettier-ignore\ntype EvaluationMetricSpecificationFilter<\n F extends keyof EvaluationMetricSpecification,\n T extends EvaluationType = EvaluationType\n> = { [K in EvaluationType]: {\n [M in keyof EvaluationSpecifications[K]['metrics']]:\n // @ts-expect-error F can indeed index M type\n EvaluationSpecifications[K]['metrics'][M][F] extends true ? M : never\n }[keyof EvaluationSpecifications[K]['metrics']]\n}[T] & EvaluationMetric<T>\n\nexport type LiveEvaluationMetric<T extends EvaluationType = EvaluationType> =\n EvaluationMetricSpecificationFilter<'supportsLiveEvaluation', T>\n\nexport type BatchEvaluationMetric<T extends EvaluationType = EvaluationType> =\n EvaluationMetricSpecificationFilter<'supportsBatchEvaluation', T>\n\nexport type ManualEvaluationMetric<T extends EvaluationType = EvaluationType> =\n EvaluationMetricSpecificationFilter<'supportsManualEvaluation', T>\n\nexport type EvaluationV2<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> = {\n uuid: string\n versionId: number\n workspaceId: number\n commitId: number\n documentUuid: string\n name: string\n description: string\n type: T\n metric: M\n configuration: EvaluationConfiguration<T, M>\n evaluateLiveLogs?: boolean | null\n enableSuggestions?: boolean | null\n autoApplySuggestions?: boolean | null\n createdAt: Date\n updatedAt: Date\n deletedAt?: Date | null\n}\n\nexport type EvaluationResultValue<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> =\n | {\n score: number\n normalizedScore: number\n metadata: EvaluationResultMetadata<T, M>\n hasPassed: boolean\n error?: null\n }\n | {\n score?: null\n normalizedScore?: null\n metadata?: null\n hasPassed?: null\n error: EvaluationResultError<T, M>\n }\n\nexport type EvaluationResultV2<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> = {\n id: number\n uuid: string\n workspaceId: number\n commitId: number\n evaluationUuid: string\n experimentId?: number | null\n datasetId?: number | null\n evaluatedRowId?: number | null\n evaluatedLogId: number\n usedForSuggestion?: boolean | null\n createdAt: Date\n updatedAt: Date\n} & EvaluationResultValue<T, M>\n\nexport type PublicManualEvaluationResultV2 = Pick<\n EvaluationResultV2<EvaluationType.Human, HumanEvaluationMetric>,\n | 'uuid'\n | 'score'\n | 'normalizedScore'\n | 'metadata'\n | 'hasPassed'\n | 'createdAt'\n | 'updatedAt'\n> & { versionUuid: string; error: string | null }\n\nexport type EvaluationSettings<\n T extends EvaluationType = EvaluationType,\n M extends EvaluationMetric<T> = EvaluationMetric<T>,\n> = Pick<\n EvaluationV2<T, M>,\n 'name' | 'description' | 'type' | 'metric' | 'configuration'\n>\n\nexport const EvaluationSettingsSchema = z.object({\n name: z.string(),\n description: z.string(),\n type: EvaluationTypeSchema,\n metric: EvaluationMetricSchema,\n configuration: EvaluationConfigurationSchema,\n})\n\nexport type EvaluationOptions = Pick<\n EvaluationV2,\n 'evaluateLiveLogs' | 'enableSuggestions' | 'autoApplySuggestions'\n>\n\nexport const EvaluationOptionsSchema = z.object({\n evaluateLiveLogs: z.boolean().nullable().optional(),\n enableSuggestions: z.boolean().nullable().optional(),\n autoApplySuggestions: z.boolean().nullable().optional(),\n})\n\nexport const EVALUATION_SCORE_SCALE = 100\n\nexport const DEFAULT_DATASET_LABEL = 'output'\n\nexport const LIVE_EVALUABLE_LOG_SOURCES = Object.values(SegmentSource).filter(\n (source) =>\n source !== SegmentSource.Evaluation && source !== SegmentSource.Experiment,\n) as SegmentSource[]\n","import { Message } from '@latitude-data/compiler'\nimport { ChainEventDtoResponse } from '..'\nimport { FinishReason } from 'ai'\nimport { LatitudePromptConfig } from '../latitudePromptSchema'\n\nexport enum LegacyChainEventTypes {\n Error = 'chain-error',\n Step = 'chain-step',\n Complete = 'chain-complete',\n StepComplete = 'chain-step-complete',\n}\n\nexport type LegacyEventData =\n | {\n type: LegacyChainEventTypes.Step\n config: LatitudePromptConfig\n isLastStep: boolean\n messages: Message[]\n uuid?: string\n }\n | {\n type: LegacyChainEventTypes.StepComplete\n response: ChainEventDtoResponse\n uuid?: string\n }\n | {\n type: LegacyChainEventTypes.Complete\n config: LatitudePromptConfig\n finishReason?: FinishReason\n messages?: Message[]\n object?: any\n response: ChainEventDtoResponse\n uuid?: string\n }\n | {\n type: LegacyChainEventTypes.Error\n error: {\n name: string\n message: string\n stack?: string\n }\n }\n","import { Config, Message, ToolCall } from '@latitude-data/compiler'\nimport {\n ChainStepResponse,\n ProviderData,\n StreamEventTypes,\n StreamType,\n} from '..'\nimport { FinishReason, LanguageModelUsage } from 'ai'\nimport { ChainError, RunErrorCodes } from '../errors'\nimport { TraceContext } from '../tracing/trace'\n\nexport enum ChainEventTypes {\n ChainStarted = 'chain-started',\n StepStarted = 'step-started',\n ProviderStarted = 'provider-started',\n ProviderCompleted = 'provider-completed',\n ToolsStarted = 'tools-started',\n ToolCompleted = 'tool-completed',\n StepCompleted = 'step-completed',\n ChainCompleted = 'chain-completed',\n ChainError = 'chain-error',\n ToolsRequested = 'tools-requested',\n IntegrationWakingUp = 'integration-waking-up',\n}\n\ninterface GenericLatitudeEventData {\n type: ChainEventTypes\n messages: Message[]\n uuid: string\n}\n\nexport interface LatitudeChainStartedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ChainStarted\n}\n\nexport interface LatitudeStepStartedEventData extends GenericLatitudeEventData {\n type: ChainEventTypes.StepStarted\n}\n\nexport interface LatitudeProviderStartedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ProviderStarted\n config: Config\n}\n\nexport interface LatitudeProviderCompletedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ProviderCompleted\n providerLogUuid: string\n tokenUsage: LanguageModelUsage\n finishReason: FinishReason\n response: ChainStepResponse<StreamType>\n}\n\nexport interface LatitudeToolsStartedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ToolsStarted\n tools: ToolCall[]\n}\n\nexport interface LatitudeToolCompletedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ToolCompleted\n}\n\nexport interface LatitudeStepCompletedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.StepCompleted\n}\n\nexport interface LatitudeChainCompletedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ChainCompleted\n tokenUsage: LanguageModelUsage\n finishReason: FinishReason\n trace: TraceContext\n}\n\nexport interface LatitudeChainErrorEventData extends GenericLatitudeEventData {\n type: ChainEventTypes.ChainError\n error: Error | ChainError<RunErrorCodes>\n}\n\nexport interface LatitudeToolsRequestedEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.ToolsRequested\n tools: ToolCall[]\n trace: TraceContext\n}\n\nexport interface LatitudeIntegrationWakingUpEventData\n extends GenericLatitudeEventData {\n type: ChainEventTypes.IntegrationWakingUp\n integrationName: string\n}\n\nexport type LatitudeEventData =\n | LatitudeChainStartedEventData\n | LatitudeStepStartedEventData\n | LatitudeProviderStartedEventData\n | LatitudeProviderCompletedEventData\n | LatitudeToolsStartedEventData\n | LatitudeToolCompletedEventData\n | LatitudeStepCompletedEventData\n | LatitudeChainCompletedEventData\n | LatitudeChainErrorEventData\n | LatitudeToolsRequestedEventData\n | LatitudeIntegrationWakingUpEventData\n\n// Just a type helper for ChainStreamManager. Omit<LatitudeEventData, 'messages' | 'uuid'> does not work.\nexport type OmittedLatitudeEventData =\n | Omit<LatitudeChainStartedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeStepStartedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeProviderStartedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeProviderCompletedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeToolsStartedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeToolCompletedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeStepCompletedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeChainCompletedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeChainErrorEventData, 'messages' | 'uuid'>\n | Omit<LatitudeToolsRequestedEventData, 'messages' | 'uuid'>\n | Omit<LatitudeIntegrationWakingUpEventData, 'messages' | 'uuid'>\n\nexport type ChainEvent =\n | {\n event: StreamEventTypes.Latitude\n data: LatitudeEventData\n }\n | {\n event: StreamEventTypes.Provider\n data: ProviderData\n }\n","export enum IntegrationType {\n Latitude = 'latitude', // For internal use only\n ExternalMCP = 'custom_mcp',\n HostedMCP = 'mcp_server',\n Pipedream = 'pipedream',\n}\n\nexport enum HostedIntegrationType {\n Stripe = 'stripe',\n Slack = 'slack',\n Github = 'github',\n Notion = 'notion',\n Twitter = 'twitter',\n Airtable = 'airtable',\n Linear = 'linear',\n YoutubeCaptions = 'youtube_captions',\n Reddit = 'reddit',\n Telegram = 'telegram',\n Tinybird = 'tinybird',\n Perplexity = 'perplexity',\n\n AwsKbRetrieval = 'aws_kb_retrieval',\n BraveSearch = 'brave_search',\n EverArt = 'ever_art',\n Fetch = 'fetch',\n GitLab = 'gitlab',\n GoogleMaps = 'google_maps',\n Sentry = 'sentry',\n Puppeteer = 'puppeteer',\n Time = 'time',\n browserbase = 'browserbase',\n Neon = 'neon',\n Postgres = 'postgres',\n Supabase = 'supabase',\n Redis = 'redis',\n Jira = 'jira',\n Attio = 'attio',\n Ghost = 'ghost',\n Figma = 'figma',\n Hyperbrowser = 'hyperbrowser',\n Audiense = 'audiense',\n Apify = 'apify',\n Exa = 'exa',\n YepCode = 'yepcode',\n Monday = 'monday',\n\n AgentQL = 'agentql',\n AgentRPC = 'agentrpc',\n AstraDB = 'astra_db',\n Bankless = 'bankless',\n Bicscan = 'bicscan',\n Chargebee = 'chargebee',\n Chronulus = 'chronulus',\n CircleCI = 'circleci',\n Codacy = 'codacy',\n CodeLogic = 'codelogic',\n Convex = 'convex',\n Dart = 'dart',\n DevHubCMS = 'devhub_cms',\n Elasticsearch = 'elasticsearch',\n ESignatures = 'esignatures',\n Fewsats = 'fewsats',\n Firecrawl = 'firecrawl',\n\n Graphlit = 'graphlit',\n Heroku = 'heroku',\n IntegrationAppHubspot = 'integration_app_hubspot',\n\n LaraTranslate = 'lara_translate',\n Logfire = 'logfire',\n Langfuse = 'langfuse',\n LingoSupabase = 'lingo_supabase',\n Make = 'make',\n Meilisearch = 'meilisearch',\n Momento = 'momento',\n\n Neo4jAura = 'neo4j_aura',\n Octagon = 'octagon',\n\n Paddle = 'paddle',\n PayPal = 'paypal',\n Qdrant = 'qdrant',\n Raygun = 'raygun',\n Rember = 'rember',\n Riza = 'riza',\n Search1API = 'search1api',\n Semgrep = 'semgrep',\n\n Tavily = 'tavily',\n Unstructured = 'unstructured',\n Vectorize = 'vectorize',\n Xero = 'xero',\n Readwise = 'readwise',\n Airbnb = 'airbnb',\n Mintlify = 'mintlify',\n\n // Require all auth file :point_down:\n // Gmail = 'google_drive',\n // GoogleCalendar = 'google_drive',\n // GoogleDrive = 'google_drive',\n // GoogleWorkspace = 'google_workspace', // env vars not supported (?)\n\n // TODO: implement these\n // Wordpress = 'wordpress', // Not on OpenTools\n // Discord = 'discord', // Not on OpenTools\n // Intercom = 'intercom', // Not on OpenTools\n\n // Hubspot = 'hubspot', // Docker based\n // Loops = 'loops', // Does not exist\n}\n","import { LogSources } from '.'\nimport { Message, ToolCall } from '@latitude-data/compiler'\nimport { PartialPromptConfig } from './ai'\n\nexport type DocumentLog = {\n id: number\n uuid: string\n documentUuid: string\n commitId: number\n resolvedContent: string\n contentHash: string\n parameters: Record<string, unknown>\n customIdentifier: string | null\n duration: number | null\n source: LogSources | null\n createdAt: Date\n updatedAt: Date\n experimentId: number | null\n}\n\n// TODO(evalsv2): Remove\nexport enum EvaluationResultableType {\n Boolean = 'evaluation_resultable_booleans',\n Text = 'evaluation_resultable_texts',\n Number = 'evaluation_resultable_numbers',\n}\n\n// TODO(evalsv2): Remove\nexport type EvaluationResult = {\n id: number\n uuid: string\n evaluationId: number\n documentLogId: number\n evaluatedProviderLogId: number | null\n evaluationProviderLogId: number | null\n resultableType: EvaluationResultableType | null\n resultableId: number | null\n source: LogSources | null\n reason: string | null\n createdAt: Date\n updatedAt: Date\n}\n\n// TODO(evalsv2): Remove\nexport type EvaluationResultDto = EvaluationResult & {\n result: string | number | boolean | undefined\n}\n\nexport type ProviderLog = {\n id: number\n uuid: string\n documentLogUuid: string | null\n providerId: number | null\n model: string | null\n finishReason: string | null\n config: PartialPromptConfig | null\n messages: Message[]\n responseObject: unknown | null\n responseText: string | null\n toolCalls: ToolCall[]\n tokens: number | null\n costInMillicents: number | null\n duration: number | null\n source: LogSources | null\n apiKeyId: number | null\n generatedAt: Date | null\n updatedAt: Date\n}\n\nexport type DocumentVersion = {\n id: number\n createdAt: Date\n updatedAt: Date\n deletedAt: Date | null\n documentUuid: string\n commitId: number\n path: string\n content: string\n resolvedContent: string | null\n contentHash: string | null\n datasetId: number | null\n datasetV2Id: number | null\n}\n\nexport type SimplifiedDocumentVersion = {\n documentUuid: string\n path: string\n content: string\n isDeleted: boolean\n}\n","export enum ModifiedDocumentType {\n Created = 'created',\n Updated = 'updated',\n UpdatedPath = 'updated_path',\n Deleted = 'deleted',\n}\n\nexport type ChangedDocument = {\n documentUuid: string\n path: string\n errors: number\n changeType: ModifiedDocumentType\n}\n","// TODO(tracing): deprecated\nexport { SegmentSource as LogSources } from './tracing'\n\nexport const HEAD_COMMIT = 'live'\n\nexport enum Providers {\n OpenAI = 'openai',\n Anthropic = 'anthropic',\n Groq = 'groq',\n Mistral = 'mistral',\n Azure = 'azure',\n Google = 'google',\n GoogleVertex = 'google_vertex',\n AnthropicVertex = 'anthropic_vertex',\n Custom = 'custom',\n XAI = 'xai',\n AmazonBedrock = 'amazon_bedrock',\n DeepSeek = 'deepseek',\n Perplexity = 'perplexity',\n}\n\nexport enum DocumentType {\n Prompt = 'prompt',\n Agent = 'agent',\n}\n\nexport enum DocumentTriggerType {\n Email = 'email',\n Scheduled = 'scheduled',\n}\n\nexport enum DocumentTriggerParameters {\n SenderEmail = 'senderEmail',\n SenderName = 'senderName',\n Subject = 'subject',\n Body = 'body',\n Attachments = 'attachments',\n}\n\nexport type ExperimentMetadata = {\n prompt: string\n promptHash: string\n parametersMap: Record<string, number>\n datasetLabels: Record<string, string> // name for the expected output column in golden datasets, based on evaluation uuid\n fromRow?: number\n toRow?: number\n count: number // Total number of to generate logs in the experiment\n}\n\nexport type ExperimentEvaluationScore = {\n count: number\n totalScore: number\n totalNormalizedScore: number\n}\n\nexport type ExperimentScores = {\n [evaluationUuid: string]: ExperimentEvaluationScore\n}\n\nexport * from './ai'\nexport * from './config'\nexport * from './evaluations'\nexport * from './events'\nexport * from './helpers'\nexport * from './integrations'\nexport * from './mcp'\nexport * from './models'\nexport * from './tools'\nexport * from './tracing'\nexport * from './history'\n\n// TODO: Move to env\nexport const EMAIL_TRIGGER_DOMAIN = 'run.latitude.so' as const\nexport const OPENAI_PROVIDER_ENDPOINTS = [\n 'chat_completions',\n 'responses',\n] as const\n","import { BaseInstrumentation } from '$telemetry/instrumentations/base'\nimport {\n ATTR_GEN_AI_COMPLETIONS,\n ATTR_GEN_AI_MESSAGE_CONTENT,\n ATTR_GEN_AI_MESSAGE_ROLE,\n ATTR_GEN_AI_MESSAGE_TOOL_CALL_ID,\n ATTR_GEN_AI_MESSAGE_TOOL_CALLS,\n ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS,\n ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ID,\n ATTR_GEN_AI_MESSAGE_TOOL_CALLS_NAME,\n ATTR_GEN_AI_MESSAGE_TOOL_NAME,\n ATTR_GEN_AI_MESSAGE_TOOL_RESULT_IS_ERROR,\n ATTR_GEN_AI_PROMPTS,\n ATTR_GEN_AI_REQUEST,\n ATTR_GEN_AI_REQUEST_CONFIGURATION,\n ATTR_GEN_AI_REQUEST_MESSAGES,\n ATTR_GEN_AI_REQUEST_PARAMETERS,\n ATTR_GEN_AI_REQUEST_TEMPLATE,\n ATTR_GEN_AI_RESPONSE,\n ATTR_GEN_AI_RESPONSE_MESSAGES,\n ATTR_GEN_AI_TOOL_CALL_ARGUMENTS,\n ATTR_GEN_AI_TOOL_RESULT_IS_ERROR,\n ATTR_GEN_AI_TOOL_RESULT_VALUE,\n ATTR_GEN_AI_USAGE_CACHED_TOKENS,\n ATTR_GEN_AI_USAGE_COMPLETION_TOKENS,\n ATTR_GEN_AI_USAGE_PROMPT_TOKENS,\n ATTR_GEN_AI_USAGE_REASONING_TOKENS,\n ATTR_HTTP_REQUEST_BODY,\n ATTR_HTTP_REQUEST_HEADER,\n ATTR_HTTP_REQUEST_URL,\n ATTR_HTTP_RESPONSE_BODY,\n ATTR_HTTP_RESPONSE_HEADER,\n ATTR_LATITUDE_SEGMENT_ID,\n ATTR_LATITUDE_SEGMENT_PARENT_ID,\n ATTR_LATITUDE_SEGMENTS,\n ATTR_LATITUDE_TYPE,\n GEN_AI_TOOL_TYPE_VALUE_FUNCTION,\n HEAD_COMMIT,\n SEGMENT_SPECIFICATIONS,\n SegmentBaggage,\n SegmentSource,\n SegmentType,\n SPAN_SPECIFICATIONS,\n SpanType,\n TraceBaggage,\n TraceContext,\n} from '@latitude-data/constants'\nimport * as otel from '@opentelemetry/api'\nimport { propagation, trace } from '@opentelemetry/api'\nimport {\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n} from '@opentelemetry/semantic-conventions'\nimport {\n ATTR_GEN_AI_OPERATION_NAME,\n ATTR_GEN_AI_RESPONSE_FINISH_REASONS,\n ATTR_GEN_AI_RESPONSE_MODEL,\n ATTR_GEN_AI_SYSTEM,\n ATTR_GEN_AI_TOOL_CALL_ID,\n ATTR_GEN_AI_TOOL_NAME,\n ATTR_GEN_AI_TOOL_TYPE,\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n} from '@opentelemetry/semantic-conventions/incubating'\nimport { v4 as uuid } from 'uuid'\n\nexport type StartSpanOptions = {\n name?: string\n attributes?: otel.Attributes\n}\n\nexport type EndSpanOptions = {\n attributes?: otel.Attributes\n}\n\nexport type ErrorOptions = {\n attributes?: otel.Attributes\n}\n\nexport type StartToolSpanOptions = StartSpanOptions & {\n name: string\n call: {\n id: string\n arguments: Record<string, unknown>\n }\n}\n\nexport type EndToolSpanOptions = EndSpanOptions & {\n result: {\n value: unknown\n isError: boolean\n }\n}\n\nexport type StartCompletionSpanOptions = StartSpanOptions & {\n provider: string\n model: string\n configuration: Record<string, unknown>\n input: Record<string, unknown>[]\n}\n\nexport type EndCompletionSpanOptions = EndSpanOptions & {\n output: Record<string, unknown>[]\n tokens: {\n prompt: number\n cached: number\n reasoning: number\n completion: number\n }\n finishReason: string\n}\n\nexport type StartHttpSpanOptions = StartSpanOptions & {\n request: {\n method: string\n url: string\n headers: Record<string, string>\n body: string | Record<string, unknown>\n }\n}\n\nexport type EndHttpSpanOptions = EndSpanOptions & {\n response: {\n status: number\n headers: Record<string, string>\n body: string | Record<string, unknown>\n }\n}\n\nexport type SegmentOptions = {\n attributes?: otel.Attributes\n baggage?: Record<string, otel.BaggageEntry>\n _internal?: {\n id?: string\n source?: SegmentSource\n }\n}\n\nexport type PromptSegmentOptions = SegmentOptions & {\n logUuid?: string // TODO(tracing): temporal related log, remove when observability is ready\n versionUuid?: string // Alias for commitUuid\n promptUuid: string // Alias for documentUuid\n experimentUuid?: string\n externalId?: string\n template: string\n parameters?: Record<string, unknown>\n}\n\nexport class ManualInstrumentation implements BaseInstrumentation {\n private enabled: boolean\n private readonly source: SegmentSource\n private readonly tracer: otel.Tracer\n\n constructor(source: SegmentSource, tracer: otel.Tracer) {\n this.enabled = false\n this.source = source\n this.tracer = tracer\n }\n\n isEnabled() {\n return this.enabled\n }\n\n enable() {\n this.enabled = true\n }\n\n disable() {\n this.enabled = false\n }\n\n baggage(ctx: otel.Context | TraceContext) {\n if ('traceparent' in ctx) {\n ctx = propagation.extract(otel.ROOT_CONTEXT, ctx)\n }\n\n const baggage = Object.fromEntries(\n propagation.getBaggage(ctx)?.getAllEntries() || [],\n )\n if (\n !(ATTR_LATITUDE_SEGMENT_ID in baggage) ||\n !(ATTR_LATITUDE_SEGMENTS in baggage)\n ) {\n return undefined\n }\n\n const segment = {\n id: baggage[ATTR_LATITUDE_SEGMENT_ID]!.value,\n parentId: baggage[ATTR_LATITUDE_SEGMENT_PARENT_ID]?.value,\n }\n\n let segments = []\n try {\n segments = JSON.parse(baggage[ATTR_LATITUDE_SEGMENTS]!.value)\n } catch (error) {\n return undefined\n }\n\n if (segments.length < 1) {\n return undefined\n }\n\n return { segment, segments } as TraceBaggage\n }\n\n private setBaggage(\n ctx: otel.Context,\n baggage: TraceBaggage | undefined,\n extra?: Record<string, otel.BaggageEntry>,\n ) {\n let parent = Object.fromEntries(\n propagation.getBaggage(ctx)?.getAllEntries() || [],\n )\n\n parent = Object.fromEntries(\n Object.entries(parent).filter(\n ([attribute]) =>\n attribute !== ATTR_LATITUDE_SEGMENT_ID &&\n attribute !== ATTR_LATITUDE_SEGMENT_PARENT_ID &&\n attribute !== ATTR_LATITUDE_SEGMENTS,\n ),\n )\n\n if (!baggage) {\n const payload = propagation.createBaggage({ ...parent, ...(extra || {}) })\n return propagation.setBaggage(ctx, payload)\n }\n\n let jsonSegments = ''\n try {\n jsonSegments = JSON.stringify(baggage.segments)\n } catch (error) {\n jsonSegments = '[]'\n }\n\n const payload = propagation.createBaggage({\n ...parent,\n [ATTR_LATITUDE_SEGMENT_ID]: { value: baggage.segment.id },\n ...(baggage.segment.parentId && {\n [ATTR_LATITUDE_SEGMENT_PARENT_ID]: { value: baggage.segment.parentId },\n }),\n [ATTR_LATITUDE_SEGMENTS]: { value: jsonSegments },\n ...(extra || {}),\n })\n\n return propagation.setBaggage(ctx, payload)\n }\n\n pause(ctx: otel.Context) {\n const baggage = this.baggage(ctx)\n if (baggage) {\n baggage.segments.at(-1)!.paused = true\n }\n\n ctx = this.setBaggage(ctx, baggage)\n let carrier = {} as TraceContext\n propagation.inject(ctx, carrier)\n\n return carrier\n }\n\n resume(ctx: TraceContext) {\n return propagation.extract(otel.ROOT_CONTEXT, ctx)\n }\n\n restored(ctx: otel.Context) {\n const baggage = this.baggage(ctx)\n return !baggage?.segments.some((segment) => segment.paused)\n }\n\n restore(ctx: otel.Context) {\n let baggage = this.baggage(ctx)\n if (!baggage) return ctx\n\n const segments = baggage.segments\n while (segments.at(-1)?.paused) segments.pop()\n\n const segment = segments.at(-1)\n if (!segment) return otel.ROOT_CONTEXT\n\n baggage = {\n segment: { id: segment.id, parentId: segment.parentId },\n segments: segments,\n }\n\n ctx = this.setBaggage(ctx, baggage)\n let carrier = {} as TraceContext\n propagation.inject(ctx, carrier)\n\n carrier.traceparent = segment.traceparent\n carrier.tracestate = segment.tracestate\n\n return this.resume(carrier)\n }\n\n private capitalize(str: string) {\n if (str.length === 0) return str\n return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1)\n }\n\n private toCamelCase(str: string) {\n return str\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[^A-Za-z0-9]+/g, ' ')\n .trim()\n .split(' ')\n .map((w, i) => (i ? this.capitalize(w) : w.toLowerCase()))\n .join('')\n }\n\n private toSnakeCase(str: string) {\n return str\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/[^A-Za-z0-9]+/g, '_')\n .replace(/_+/g, '_')\n .replace(/^_+|_+$/g, '')\n .toLowerCase()\n }\n\n private toKebabCase(input: string) {\n return input\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/[^A-Za-z0-9]+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-+|-+$/g, '')\n .toLowerCase()\n }\n\n private error(span: otel.Span, error: Error, options?: ErrorOptions) {\n options = options || {}\n\n span.recordException(error)\n span.setAttributes(options.attributes || {})\n span.setStatus({\n code: otel.SpanStatusCode.ERROR,\n message: error.message || undefined,\n })\n span.end()\n }\n\n private span<T extends SpanType>(\n ctx: otel.Context,\n name: string,\n type: T,\n options?: StartSpanOptions,\n ) {\n if (!this.enabled) {\n return {\n context: ctx,\n end: (_options?: EndSpanOptions) => {},\n fail: (_error: Error, _options?: ErrorOptions) => {},\n }\n }\n\n const start = options || {}\n\n let operation = undefined\n if (SPAN_SPECIFICATIONS[type].isGenAI) {\n operation = type\n }\n\n const span = this.tracer.startSpan(\n name,\n {\n attributes: {\n [ATTR_LATITUDE_TYPE]: type,\n ...(operation && {\n [ATTR_GEN_AI_OPERATION_NAME]: operation,\n }),\n ...(start.attributes || {}),\n },\n kind: otel.SpanKind.CLIENT,\n },\n ctx,\n )\n\n const newCtx = trace.setSpan(ctx, span)\n\n return {\n context: newCtx,\n end: (options?: EndSpanOptions) => {\n const end = options || {}\n\n span.setAttributes(end.attributes || {})\n span.setStatus({ code: otel.SpanStatusCode.OK })\n span.end()\n },\n fail: (error: Error, options?: ErrorOptions) => {\n this.error(span, error, options)\n },\n }\n }\n\n tool(ctx: otel.Context, options: StartToolSpanOptions) {\n const start = options\n\n let jsonArguments = ''\n try {\n jsonArguments = JSON.stringify(start.call.arguments)\n } catch (error) {\n jsonArguments = '{}'\n }\n\n const span = this.span(ctx, start.name, SpanType.Tool, {\n attributes: {\n [ATTR_GEN_AI_TOOL_NAME]: start.name,\n [ATTR_GEN_AI_TOOL_TYPE]: GEN_AI_TOOL_TYPE_VALUE_FUNCTION,\n [ATTR_GEN_AI_TOOL_CALL_ID]: start.call.id,\n [ATTR_GEN_AI_TOOL_CALL_ARGUMENTS]: jsonArguments,\n ...(start.attributes || {}),\n },\n })\n\n return {\n context: span.context,\n end: (options: EndToolSpanOptions) => {\n const end = options\n\n let stringResult = ''\n if (typeof end.result.value !== 'string') {\n try {\n stringResult = JSON.stringify(end.result.value)\n } catch (error) {\n stringResult = '{}'\n }\n } else {\n stringResult = end.result.value\n }\n\n span.end({\n attributes: {\n [ATTR_GEN_AI_TOOL_RESULT_VALUE]: stringResult,\n [ATTR_GEN_AI_TOOL_RESULT_IS_ERROR]: end.result.isError,\n ...(end.attributes || {}),\n },\n })\n },\n fail: span.fail,\n }\n }\n\n private attribifyMessageToolCalls(\n prefix: string,\n toolCalls: Record<string, unknown>[],\n ) {\n const attributes: otel.Attributes = {}\n\n for (let i = 0; i < toolCalls.length; i++) {\n for (const key in toolCalls[i]!) {\n const field = this.toCamelCase(key)\n let value = toolCalls[i]![key]\n if (value === null || value === undefined) continue\n\n switch (field) {\n case 'id':\n case 'toolCallId':\n case 'toolUseId': {\n if (typeof value !== 'string') continue\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ID}`\n ] = value\n break\n }\n\n case 'name':\n case 'toolName': {\n if (typeof value !== 'string') continue\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_NAME}`\n ] = value\n break\n }\n\n case 'arguments':\n case 'toolArguments':\n case 'input': {\n if (typeof value === 'string') {\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS}`\n ] = value\n } else {\n try {\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS}`\n ] = JSON.stringify(value)\n } catch (error) {\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS}`\n ] = '{}'\n }\n }\n break\n }\n\n /* OpenAI function calls */\n case 'function': {\n if (typeof value !== 'object') continue\n if (!('name' in value)) continue\n if (typeof value.name !== 'string') continue\n if (!('arguments' in value)) continue\n if (typeof value.arguments !== 'string') continue\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_NAME}`\n ] = value.name\n attributes[\n `${prefix}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALLS_ARGUMENTS}`\n ] = value.arguments\n break\n }\n }\n }\n }\n\n return attributes\n }\n\n private attribifyMessageContent(prefix: string, content: unknown) {\n let attributes: otel.Attributes = {}\n\n if (typeof content === 'string') {\n attributes[`${prefix}.${ATTR_GEN_AI_MESSAGE_CONTENT}`] = content\n return attributes\n }\n\n try {\n attributes[`${prefix}.${ATTR_GEN_AI_MESSAGE_CONTENT}`] =\n JSON.stringify(content)\n } catch (error) {\n attributes[`${prefix}.${ATTR_GEN_AI_MESSAGE_CONTENT}`] = '[]'\n }\n\n if (!Array.isArray(content)) return attributes\n\n /* Tool calls for Anthropic and PromptL are in the content */\n const toolCalls = []\n for (const item of content) {\n for (const key in item) {\n if (this.toCamelCase(key) !== 'type') continue\n if (typeof item[key] !== 'string') continue\n if (item[key] !== 'tool-call' && item[key] !== 'tool_use') continue\n toolCalls.push(item)\n }\n }\n\n if (toolCalls.length > 0) {\n attributes = {\n ...attributes,\n ...this.attribifyMessageToolCalls(prefix, toolCalls),\n }\n }\n\n return attributes\n }\n\n private attribifyMessages(\n direction: 'input' | 'output',\n messages: Record<string, unknown>[],\n ) {\n const prefix =\n direction === 'input' ? ATTR_GEN_AI_PROMPTS : ATTR_GEN_AI_COMPLETIONS\n\n let attributes: otel.Attributes = {}\n for (let i = 0; i < messages.length; i++) {\n for (const key in messages[i]!) {\n const field = this.toCamelCase(key)\n let value = messages[i]![key]\n if (value === null || value === undefined) continue\n\n switch (field) {\n case 'role': {\n if (typeof value !== 'string') continue\n attributes[`${prefix}.${i}.${ATTR_GEN_AI_MESSAGE_ROLE}`] = value\n break\n }\n\n /* Tool calls for Anthropic and PromptL are in the content */\n case 'content': {\n attributes = {\n ...attributes,\n ...this.attribifyMessageContent(`${prefix}.${i}`, value),\n }\n break\n }\n\n /* Tool calls for OpenAI */\n case 'toolCalls': {\n if (!Array.isArray(value)) continue\n attributes = {\n ...attributes,\n ...this.attribifyMessageToolCalls(`${prefix}.${i}`, value),\n }\n break\n }\n\n /* Tool result for OpenAI / Anthropic / PromptL */\n\n case 'toolCallId':\n case 'toolId':\n case 'toolUseId': {\n if (typeof value !== 'string') continue\n attributes[`${prefix}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_CALL_ID}`] =\n value\n break\n }\n\n case 'toolName': {\n if (typeof value !== 'string') continue\n attributes[`${prefix}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_NAME}`] =\n value\n break\n }\n\n // Note: 'toolResult' is 'content' itself\n\n case 'isError': {\n if (typeof value !== 'boolean') continue\n attributes[\n `${prefix}.${i}.${ATTR_GEN_AI_MESSAGE_TOOL_RESULT_IS_ERROR}`\n ] = value\n break\n }\n }\n }\n }\n\n return attributes\n }\n\n private attribifyConfiguration(\n direction: 'input' | 'output',\n configuration: Record<string, unknown>,\n ) {\n const prefix =\n direction === 'input' ? ATTR_GEN_AI_REQUEST : ATTR_GEN_AI_RESPONSE\n\n const attributes: otel.Attributes = {}\n for (const key in configuration) {\n const field = this.toSnakeCase(key)\n let value = configuration[key]\n if (value === null || value === undefined) continue\n if (typeof value === 'object' && !Array.isArray(value)) {\n try {\n value = JSON.stringify(value)\n } catch (error) {\n value = '{}'\n }\n }\n\n attributes[`${prefix}.${field}`] = value as any\n }\n\n return attributes\n }\n\n completion(ctx: otel.Context, options: StartCompletionSpanOptions) {\n const start = options\n\n const configuration = {\n ...start.configuration,\n model: start.model,\n }\n let jsonConfiguration = ''\n try {\n jsonConfiguration = JSON.stringify(configuration)\n } catch (error) {\n jsonConfiguration = '{}'\n }\n const attrConfiguration = this.attribifyConfiguration(\n 'input',\n configuration,\n )\n\n let jsonInput = ''\n try {\n jsonInput = JSON.stringify(start.input)\n } catch (error) {\n jsonInput = '[]'\n }\n const attrInput = this.attribifyMessages('input', start.input)\n\n const span = this.span(\n ctx,\n start.name || `${start.provider} / ${start.model}`,\n SpanType.Completion,\n {\n attributes: {\n [ATTR_GEN_AI_SYSTEM]: start.provider,\n [ATTR_GEN_AI_REQUEST_CONFIGURATION]: jsonConfiguration,\n ...attrConfiguration,\n [ATTR_GEN_AI_REQUEST_MESSAGES]: jsonInput,\n ...attrInput,\n ...(start.attributes || {}),\n },\n },\n )\n\n return {\n context: span.context,\n end: (options: EndCompletionSpanOptions) => {\n const end = options\n\n let jsonOutput = ''\n try {\n jsonOutput = JSON.stringify(end.output)\n } catch (error) {\n jsonOutput = '[]'\n }\n const attrOutput = this.attribifyMessages('output', end.output)\n\n const inputTokens = end.tokens.prompt + end.tokens.cached\n const outputTokens = end.tokens.reasoning + end.tokens.completion\n\n span.end({\n attributes: {\n [ATTR_GEN_AI_RESPONSE_MESSAGES]: jsonOutput,\n ...attrOutput,\n [ATTR_GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,\n [ATTR_GEN_AI_USAGE_PROMPT_TOKENS]: end.tokens.prompt,\n [ATTR_GEN_AI_USAGE_CACHED_TOKENS]: end.tokens.cached,\n [ATTR_GEN_AI_USAGE_REASONING_TOKENS]: end.tokens.reasoning,\n [ATTR_GEN_AI_USAGE_COMPLETION_TOKENS]: end.tokens.completion,\n [ATTR_GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,\n [ATTR_GEN_AI_RESPONSE_MODEL]: start.model,\n [ATTR_GEN_AI_RESPONSE_FINISH_REASONS]: [end.finishReason],\n ...(end.attributes || {}),\n },\n })\n },\n fail: span.fail,\n }\n }\n\n embedding(ctx: otel.Context, options?: StartSpanOptions) {\n return this.span(\n ctx,\n options?.name || SPAN_SPECIFICATIONS[SpanType.Embedding].name,\n SpanType.Embedding,\n options,\n )\n }\n\n retrieval(ctx: otel.Context, options?: StartSpanOptions) {\n return this.span(\n ctx,\n options?.name || SPAN_SPECIFICATIONS[SpanType.Retrieval].name,\n SpanType.Retrieval,\n options,\n )\n }\n\n reranking(ctx: otel.Context, options?: StartSpanOptions) {\n return this.span(\n ctx,\n options?.name || SPAN_SPECIFICATIONS[SpanType.Reranking].name,\n SpanType.Reranking,\n options,\n )\n }\n\n private attribifyHeaders(\n direction: 'request' | 'response',\n headers: Record<string, string>,\n ) {\n const prefix =\n direction === 'request'\n ? ATTR_HTTP_REQUEST_HEADER\n : ATTR_HTTP_RESPONSE_HEADER\n\n const attributes: otel.Attributes = {}\n for (const key in headers) {\n const field = this.toKebabCase(key)\n const value = headers[key]\n if (value === null || value === undefined) continue\n\n attributes[`${prefix}.${field}`] = value as any\n }\n\n return attributes\n }\n\n http(ctx: otel.Context, options: StartHttpSpanOptions) {\n const start = options\n\n const method = start.request.method.toUpperCase()\n\n // Note: do not serialize headers as a single attribute because fields won't be redacted\n const attrHeaders = this.attribifyHeaders('request', start.request.headers)\n\n let finalBody = ''\n if (typeof start.request.body === 'string') {\n finalBody = start.request.body\n } else {\n try {\n finalBody = JSON.stringify(start.request.body)\n } catch (error) {\n finalBody = '{}'\n }\n }\n\n const span = this.span(\n ctx,\n start.name || `${method} ${start.request.url}`,\n SpanType.Http,\n {\n attributes: {\n [ATTR_HTTP_REQUEST_METHOD]: method,\n [ATTR_HTTP_REQUEST_URL]: start.request.url,\n ...attrHeaders,\n [ATTR_HTTP_REQUEST_BODY]: finalBody,\n ...(start.attributes || {}),\n },\n },\n )\n\n return {\n context: span.context,\n end: (options: EndHttpSpanOptions) => {\n const end = options\n\n // Note: do not serialize headers as a single attribute because fields won't be redacted\n const attrHeaders = this.attribifyHeaders(\n 'response',\n end.response.headers,\n )\n\n let finalBody = ''\n if (typeof end.response.body === 'string') {\n finalBody = end.response.body\n } else {\n try {\n finalBody = JSON.stringify(end.response.body)\n } catch (error) {\n finalBody = '{}'\n }\n }\n\n span.end({\n attributes: {\n [ATTR_HTTP_RESPONSE_STATUS_CODE]: end.response.status,\n ...attrHeaders,\n [ATTR_HTTP_RESPONSE_BODY]: finalBody,\n ...(end.attributes || {}),\n },\n })\n },\n fail: span.fail,\n }\n }\n\n private segment<T extends SegmentType>(\n ctx: otel.Context,\n type: T,\n data: SegmentBaggage<T>['data'],\n options?: SegmentOptions,\n ) {\n options = options || {}\n\n let baggage = this.baggage(ctx)\n const parent = baggage?.segments.at(-1)\n const segments = baggage?.segments || []\n\n segments.push({\n ...({\n id: options._internal?.id || uuid(),\n ...(parent?.id && { parentId: parent.id }),\n source: options._internal?.source || parent?.source || this.source,\n type: type,\n data: data,\n } as SegmentBaggage<T>),\n traceparent: 'undefined',\n tracestate: undefined,\n })\n const segment = segments.at(-1)!\n\n baggage = {\n segment: { id: segment.id, parentId: segment.parentId },\n segments: segments,\n }\n\n ctx = this.setBaggage(ctx, baggage, options.baggage)\n\n // Dummy wrapper to force the same trace and carry on some segment attributes\n const span = this.span(\n ctx,\n SEGMENT_SPECIFICATIONS[type].name,\n SpanType.Segment,\n { attributes: options.attributes },\n )\n\n let carrier = {} as TraceContext\n propagation.inject(span.context, carrier)\n\n baggage.segments.at(-1)!.traceparent = carrier.traceparent\n baggage.segments.at(-1)!.tracestate = carrier.tracestate\n\n // Fix current segment span segments attribute now that we know the trace\n trace\n .getSpan(span.context)!\n .setAttribute(ATTR_LATITUDE_SEGMENTS, JSON.stringify(baggage.segments))\n\n ctx = this.setBaggage(span.context, baggage, options.baggage)\n\n return { context: ctx, end: span.end, fail: span.fail }\n }\n\n prompt(\n ctx: otel.Context,\n {\n logUuid,\n versionUuid,\n promptUuid,\n experimentUuid,\n externalId,\n template,\n parameters,\n ...rest\n }: PromptSegmentOptions,\n ) {\n const baggage = {\n ...(logUuid && { logUuid }), // TODO(tracing): temporal related log, remove when observability is ready\n commitUuid: versionUuid || HEAD_COMMIT,\n documentUuid: promptUuid,\n ...(experimentUuid && { experimentUuid }),\n ...(externalId && { externalId }),\n }\n\n let jsonParameters = ''\n try {\n jsonParameters = JSON.stringify(parameters || {})\n } catch (error) {\n jsonParameters = '{}'\n }\n\n const attributes = {\n [ATTR_GEN_AI_REQUEST_TEMPLATE]: template,\n [ATTR_GEN_AI_REQUEST_PARAMETERS]: jsonParameters,\n ...(rest.attributes || {}),\n }\n\n return this.segment(ctx, SegmentType.Document, baggage, {\n ...rest,\n attributes,\n })\n }\n\n step(ctx: otel.Context, options?: SegmentOptions) {\n return this.segment(ctx, SegmentType.Step, undefined, options)\n }\n}\n","import { BaseInstrumentation } from '$telemetry/instrumentations/base'\nimport { ManualInstrumentation } from '$telemetry/instrumentations/manual'\nimport {\n GEN_AI_RESPONSE_FINISH_REASON_VALUE_STOP,\n GEN_AI_RESPONSE_FINISH_REASON_VALUE_TOOL_CALLS,\n SegmentSource,\n TraceContext,\n} from '@latitude-data/constants'\nimport type * as latitude from '@latitude-data/sdk'\nimport * as otel from '@opentelemetry/api'\nimport { context } from '@opentelemetry/api'\nimport type * as promptl from 'promptl-ai'\n\nexport type LatitudeInstrumentationOptions = {\n module: typeof latitude.Latitude\n completions?: boolean\n}\n\nexport class LatitudeInstrumentation implements BaseInstrumentation {\n private readonly options: LatitudeInstrumentationOptions\n private readonly telemetry: ManualInstrumentation\n\n constructor(\n source: SegmentSource,\n tracer: otel.Tracer,\n options: LatitudeInstrumentationOptions,\n ) {\n this.telemetry = new ManualInstrumentation(source, tracer)\n this.options = options\n }\n\n isEnabled() {\n return this.telemetry.isEnabled()\n }\n\n enable() {\n this.options.module.instrument(this)\n this.telemetry.enable()\n }\n\n disable() {\n this.telemetry.disable()\n this.options.module.uninstrument()\n }\n\n private countTokens<M extends promptl.AdapterMessageType>(messages: M[]) {\n let length = 0\n\n for (const message of messages) {\n if (!('content' in message)) continue\n if (typeof message.content === 'string') {\n length += message.content.length\n } else if (Array.isArray(message.content)) {\n for (const content of message.content) {\n if (content.type === 'text') {\n length += content.text.length\n }\n }\n }\n }\n\n // Note: this is an estimation to not bundle a tokenizer\n return Math.ceil(length / 4)\n }\n\n withTraceContext<F extends () => ReturnType<F>>(\n ctx: TraceContext,\n fn: F,\n ): ReturnType<F> {\n return context.with(this.telemetry.resume(ctx), fn)\n }\n\n async wrapToolHandler<\n F extends latitude.ToolHandler<latitude.ToolSpec, keyof latitude.ToolSpec>,\n >(fn: F, ...args: Parameters<F>): Promise<Awaited<ReturnType<F>>> {\n const toolArguments = args[0]\n const { toolId, toolName } = args[1]\n\n const $tool = this.telemetry.tool(context.active(), {\n name: toolName,\n call: {\n id: toolId,\n arguments: toolArguments,\n },\n })\n\n let result\n try {\n result = await context.with(\n $tool.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n if ((error as Error).name === 'ToolExecutionPausedError') {\n $tool.fail(error as Error)\n throw error\n }\n\n $tool.end({\n result: {\n value: (error as Error).message,\n isError: true,\n },\n })\n throw error\n }\n\n $tool.end({\n result: {\n value: result,\n isError: false,\n },\n })\n\n return result\n }\n\n async wrapRenderChain<F extends latitude.Latitude['renderChain']>(\n fn: F,\n ...args: Parameters<F>\n ): Promise<Awaited<ReturnType<F>>> {\n const { prompt, parameters } = args[0]\n\n const $prompt = this.telemetry.prompt(context.active(), {\n versionUuid: prompt.versionUuid,\n promptUuid: prompt.uuid,\n template: prompt.content,\n parameters: parameters,\n })\n\n let result\n try {\n result = await context.with(\n $prompt.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n $prompt.fail(error as Error)\n throw error\n }\n\n $prompt.end()\n\n return result\n }\n\n async wrapRenderAgent<F extends latitude.Latitude['renderAgent']>(\n fn: F,\n ...args: Parameters<F>\n ): Promise<Awaited<ReturnType<F>>> {\n const { prompt, parameters } = args[0]\n\n const $prompt = this.telemetry.prompt(context.active(), {\n versionUuid: prompt.versionUuid,\n promptUuid: prompt.uuid,\n template: prompt.content,\n parameters: parameters,\n })\n\n let result\n try {\n result = await context.with(\n $prompt.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n $prompt.fail(error as Error)\n throw error\n }\n\n $prompt.end()\n\n return result\n }\n\n async wrapRenderStep<F extends latitude.Latitude['renderStep']>(\n fn: F,\n ...args: Parameters<F>\n ): Promise<Awaited<ReturnType<F>>> {\n const $step = this.telemetry.step(context.active())\n\n let result\n try {\n result = await context.with(\n $step.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n $step.fail(error as Error)\n throw error\n }\n\n $step.end()\n\n return result\n }\n\n async wrapRenderCompletion<F extends latitude.Latitude['renderCompletion']>(\n fn: F,\n ...args: Parameters<F>\n ): Promise<Awaited<ReturnType<F>>> {\n if (!this.options.completions) {\n return await ((fn as any)(...args) as ReturnType<F>)\n }\n\n const { provider, config, messages } = args[0]\n const model = (config.model as string) || 'unknown'\n\n const $completion = this.telemetry.completion(context.active(), {\n name: `${provider} / ${model}`,\n provider: provider,\n model: model,\n configuration: config,\n input: messages as Record<string, unknown>[],\n })\n\n let result\n try {\n result = await context.with(\n $completion.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n $completion.fail(error as Error)\n throw error\n }\n\n // Note: enhance, this is just an estimation\n const promptTokens = this.countTokens(messages)\n const completionTokens = this.countTokens(result.messages)\n\n $completion.end({\n output: result.messages as Record<string, unknown>[],\n tokens: {\n prompt: promptTokens,\n cached: 0,\n reasoning: 0,\n completion: completionTokens,\n },\n finishReason:\n result.toolRequests.length > 0\n ? GEN_AI_RESPONSE_FINISH_REASON_VALUE_TOOL_CALLS\n : GEN_AI_RESPONSE_FINISH_REASON_VALUE_STOP,\n })\n\n return result\n }\n\n async wrapRenderTool<F extends latitude.Latitude['renderTool']>(\n fn: F,\n ...args: Parameters<F>\n ): Promise<Awaited<ReturnType<F>>> {\n const { toolRequest } = args[0]\n\n const $tool = this.telemetry.tool(context.active(), {\n name: toolRequest.toolName,\n call: {\n id: toolRequest.toolCallId,\n arguments: toolRequest.toolArguments,\n },\n })\n\n let result\n try {\n result = await context.with(\n $tool.context,\n async () => await ((fn as any)(...args) as ReturnType<F>),\n )\n } catch (error) {\n $tool.fail(error as Error)\n throw error\n }\n\n $tool.end({\n result: {\n value: result,\n isError: false, // Note: currently unknown\n },\n })\n\n return result\n }\n}\n","import { env } from '$telemetry/env'\nimport {\n BaseInstrumentation,\n LatitudeInstrumentation,\n LatitudeInstrumentationOptions,\n ManualInstrumentation,\n PromptSegmentOptions,\n SegmentOptions,\n StartCompletionSpanOptions,\n StartHttpSpanOptions,\n StartSpanOptions,\n StartToolSpanOptions,\n} from '$telemetry/instrumentations'\nimport { DEFAULT_REDACT_SPAN_PROCESSOR } from '$telemetry/sdk/redact'\nimport {\n InstrumentationScope,\n SCOPE_LATITUDE,\n SegmentSource,\n TraceContext,\n} from '@latitude-data/constants'\nimport * as otel from '@opentelemetry/api'\nimport { context, propagation, TextMapPropagator } from '@opentelemetry/api'\nimport {\n ALLOW_ALL_BAGGAGE_KEYS,\n BaggageSpanProcessor,\n} from '@opentelemetry/baggage-span-processor'\nimport { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks'\nimport {\n CompositePropagator,\n W3CBaggagePropagator,\n W3CTraceContextPropagator,\n} from '@opentelemetry/core'\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'\nimport { registerInstrumentations } from '@opentelemetry/instrumentation'\nimport { Resource } from '@opentelemetry/resources'\nimport {\n BatchSpanProcessor,\n NodeTracerProvider,\n SimpleSpanProcessor,\n SpanExporter,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-node'\nimport { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions'\nimport { AnthropicInstrumentation } from '@traceloop/instrumentation-anthropic'\nimport { AzureOpenAIInstrumentation } from '@traceloop/instrumentation-azure'\nimport { BedrockInstrumentation } from '@traceloop/instrumentation-bedrock'\nimport { CohereInstrumentation } from '@traceloop/instrumentation-cohere'\nimport { LangChainInstrumentation } from '@traceloop/instrumentation-langchain'\nimport { LlamaIndexInstrumentation } from '@traceloop/instrumentation-llamaindex'\nimport { OpenAIInstrumentation } from '@traceloop/instrumentation-openai'\nimport { TogetherInstrumentation } from '@traceloop/instrumentation-together'\nimport {\n AIPlatformInstrumentation,\n VertexAIInstrumentation,\n} from '@traceloop/instrumentation-vertexai'\n\nimport type * as anthropic from '@anthropic-ai/sdk'\nimport type * as bedrock from '@aws-sdk/client-bedrock-runtime'\nimport type * as azure from '@azure/openai'\nimport type * as aiplatform from '@google-cloud/aiplatform'\nimport type * as vertexai from '@google-cloud/vertexai'\nimport type * as langchain_runnables from '@langchain/core/runnables'\nimport type * as langchain_vectorstores from '@langchain/core/vectorstores'\nimport type * as latitude from '@latitude-data/sdk'\nimport type * as cohere from 'cohere-ai'\nimport type * as langchain_agents from 'langchain/agents'\nimport type * as langchain_chains from 'langchain/chains'\nimport type * as langchain_tools from 'langchain/tools'\nimport type * as llamaindex from 'llamaindex'\nimport type * as openai from 'openai'\nimport type * as togetherai from 'together-ai'\n\nconst TRACES_URL = `${env.GATEWAY_BASE_URL}/api/v3/traces`\nconst SERVICE_NAME = process.env.npm_package_name || 'unknown'\nconst SCOPE_VERSION = process.env.npm_package_version || 'unknown'\n\nexport type TelemetryContext = otel.Context\nexport const BACKGROUND = () => otel.ROOT_CONTEXT\n\nclass ScopedTracerProvider implements otel.TracerProvider {\n private readonly scope: string\n private readonly version: string\n private readonly provider: otel.TracerProvider\n\n constructor(scope: string, version: string, provider: otel.TracerProvider) {\n this.scope = scope\n this.version = version\n this.provider = provider\n }\n\n getTracer(_name: string, _version?: string, options?: otel.TracerOptions) {\n return this.provider.getTracer(this.scope, this.version, options)\n }\n}\n\nexport const DEFAULT_SPAN_EXPORTER = (apiKey: string) =>\n new OTLPTraceExporter({\n url: TRACES_URL,\n headers: {\n Authorization: `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n },\n timeoutMillis: 30 * 1000,\n })\n\n// Note: Only exporting typescript instrumentations\nexport enum Instrumentation {\n Latitude = InstrumentationScope.Latitude,\n OpenAI = InstrumentationScope.OpenAI,\n Anthropic = InstrumentationScope.Anthropic,\n AzureOpenAI = InstrumentationScope.AzureOpenAI,\n VercelAI = InstrumentationScope.VercelAI,\n VertexAI = InstrumentationScope.VertexAI,\n AIPlatform = InstrumentationScope.AIPlatform,\n Bedrock = InstrumentationScope.Bedrock,\n TogetherAI = InstrumentationScope.TogetherAI,\n Cohere = InstrumentationScope.Cohere,\n Langchain = InstrumentationScope.Langchain,\n LlamaIndex = InstrumentationScope.LlamaIndex,\n}\n\nexport type TelemetryOptions = {\n instrumentations?: {\n [Instrumentation.Latitude]?:\n | typeof latitude.Latitude\n | LatitudeInstrumentationOptions\n [Instrumentation.OpenAI]?: typeof openai.OpenAI\n [Instrumentation.Anthropic]?: typeof anthropic\n [Instrumentation.AzureOpenAI]?: typeof azure\n [Instrumentation.VercelAI]?: 'manual'\n [Instrumentation.VertexAI]?: typeof vertexai\n [Instrumentation.AIPlatform]?: typeof aiplatform\n [Instrumentation.Bedrock]?: typeof bedrock\n [Instrumentation.TogetherAI]?: typeof togetherai.Together\n [Instrumentation.Cohere]?: typeof cohere\n [Instrumentation.Langchain]?: {\n chainsModule: typeof langchain_chains\n agentsModule: typeof langchain_agents\n toolsModule: typeof langchain_tools\n vectorStoreModule: typeof langchain_vectorstores\n runnablesModule: typeof langchain_runnables\n }\n [Instrumentation.LlamaIndex]?: typeof llamaindex\n }\n disableBatch?: boolean\n exporter?: SpanExporter\n processors?: SpanProcessor[]\n propagators?: TextMapPropagator[]\n}\n\nexport class LatitudeTelemetry {\n private options: TelemetryOptions\n private provider: NodeTracerProvider\n private telemetry: ManualInstrumentation\n private instrumentations: BaseInstrumentation[]\n\n constructor(apiKey: string, options?: TelemetryOptions) {\n this.options = options || {}\n\n if (!this.options.exporter) {\n this.options.exporter = DEFAULT_SPAN_EXPORTER(apiKey)\n }\n\n context.setGlobalContextManager(\n new AsyncLocalStorageContextManager().enable(),\n )\n\n propagation.setGlobalPropagator(\n new CompositePropagator({\n propagators: [\n ...(this.options.propagators || []),\n new W3CTraceContextPropagator(),\n new W3CBaggagePropagator(),\n ],\n }),\n )\n\n this.provider = new NodeTracerProvider({\n resource: new Resource({ [ATTR_SERVICE_NAME]: SERVICE_NAME }),\n })\n\n // Note: important, must run before the exporter span processors\n this.provider.addSpanProcessor(\n new BaggageSpanProcessor(ALLOW_ALL_BAGGAGE_KEYS),\n )\n\n if (this.options.processors) {\n this.options.processors.forEach((processor) => {\n this.provider.addSpanProcessor(processor)\n })\n } else {\n this.provider.addSpanProcessor(DEFAULT_REDACT_SPAN_PROCESSOR())\n }\n\n if (this.options.disableBatch) {\n this.provider.addSpanProcessor(\n new SimpleSpanProcessor(this.options.exporter),\n )\n } else {\n this.provider.addSpanProcessor(\n new BatchSpanProcessor(this.options.exporter),\n )\n }\n\n this.provider.register()\n\n process.on('SIGTERM', async () => this.shutdown)\n process.on('SIGINT', async () => this.shutdown)\n\n this.telemetry = null as unknown as ManualInstrumentation\n this.instrumentations = []\n this.initInstrumentations()\n this.instrument()\n }\n\n async flush() {\n await this.provider.forceFlush()\n await this.options.exporter!.forceFlush?.()\n }\n\n async shutdown() {\n await this.flush()\n await this.provider.shutdown()\n await this.options.exporter!.shutdown?.()\n }\n\n tracerProvider(instrumentation: Instrumentation) {\n return new ScopedTracerProvider(\n `${SCOPE_LATITUDE}.${instrumentation}`,\n SCOPE_VERSION,\n this.provider,\n )\n }\n\n tracer(instrumentation: Instrumentation) {\n return this.tracerProvider(instrumentation).getTracer('')\n }\n\n // TODO(tracing): auto instrument outgoing HTTP requests\n private initInstrumentations() {\n this.instrumentations = []\n\n const tracer = this.tracer(InstrumentationScope.Manual as any)\n this.telemetry = new ManualInstrumentation(SegmentSource.API, tracer)\n this.instrumentations.push(this.telemetry)\n\n const latitude = this.options.instrumentations?.latitude\n if (latitude) {\n const tracer = this.tracer(Instrumentation.Latitude)\n const instrumentation = new LatitudeInstrumentation(\n SegmentSource.API,\n tracer,\n typeof latitude === 'object' ? latitude : { module: latitude },\n )\n this.instrumentations.push(instrumentation)\n }\n\n const openai = this.options.instrumentations?.openai\n if (openai) {\n const provider = this.tracerProvider(Instrumentation.OpenAI)\n const instrumentation = new OpenAIInstrumentation({ enrichTokens: true })\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(openai)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const anthropic = this.options.instrumentations?.anthropic\n if (anthropic) {\n const provider = this.tracerProvider(Instrumentation.Anthropic)\n const instrumentation = new AnthropicInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(anthropic)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const azure = this.options.instrumentations?.azure\n if (azure) {\n const provider = this.tracerProvider(Instrumentation.AzureOpenAI)\n const instrumentation = new AzureOpenAIInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(azure)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const vertexai = this.options.instrumentations?.vertexai\n if (vertexai) {\n const provider = this.tracerProvider(Instrumentation.VertexAI)\n const instrumentation = new VertexAIInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(vertexai)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const aiplatform = this.options.instrumentations?.aiplatform\n if (aiplatform) {\n const provider = this.tracerProvider(Instrumentation.AIPlatform)\n const instrumentation = new AIPlatformInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(aiplatform)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const bedrock = this.options.instrumentations?.bedrock\n if (bedrock) {\n const provider = this.tracerProvider(Instrumentation.Bedrock)\n const instrumentation = new BedrockInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(bedrock)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const togetherai = this.options.instrumentations?.togetherai\n if (togetherai) {\n const provider = this.tracerProvider(Instrumentation.TogetherAI)\n const instrumentation = new TogetherInstrumentation({\n enrichTokens: true,\n })\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(togetherai)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const cohere = this.options.instrumentations?.cohere\n if (cohere) {\n const provider = this.tracerProvider(Instrumentation.Cohere)\n const instrumentation = new CohereInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(cohere)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const langchain = this.options.instrumentations?.langchain\n if (langchain) {\n const provider = this.tracerProvider(Instrumentation.Langchain)\n const instrumentation = new LangChainInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(langchain)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n\n const llamaindex = this.options.instrumentations?.llamaindex\n if (llamaindex) {\n const provider = this.tracerProvider(Instrumentation.LlamaIndex)\n const instrumentation = new LlamaIndexInstrumentation()\n instrumentation.setTracerProvider(provider)\n instrumentation.manuallyInstrument(llamaindex)\n registerInstrumentations({\n instrumentations: [instrumentation],\n tracerProvider: provider,\n })\n this.instrumentations.push(instrumentation)\n }\n }\n\n instrument() {\n this.instrumentations.forEach((instrumentation) => {\n if (!instrumentation.isEnabled()) instrumentation.enable()\n })\n }\n\n uninstrument() {\n this.instrumentations.forEach((instrumentation) => {\n if (instrumentation.isEnabled()) instrumentation.disable()\n })\n }\n\n baggage(ctx: otel.Context | TraceContext) {\n return this.telemetry.baggage(ctx)\n }\n\n pause(ctx: otel.Context) {\n return this.telemetry.pause(ctx)\n }\n\n resume(ctx: TraceContext) {\n return this.telemetry.resume(ctx)\n }\n\n restored(ctx: otel.Context) {\n return this.telemetry.restored(ctx)\n }\n\n restore(ctx: otel.Context) {\n return this.telemetry.restore(ctx)\n }\n\n tool(ctx: otel.Context, options: StartToolSpanOptions) {\n return this.telemetry.tool(ctx, options)\n }\n\n completion(ctx: otel.Context, options: StartCompletionSpanOptions) {\n return this.telemetry.completion(ctx, options)\n }\n\n embedding(ctx: otel.Context, options?: StartSpanOptions) {\n return this.telemetry.embedding(ctx, options)\n }\n\n retrieval(ctx: otel.Context, options?: StartSpanOptions) {\n return this.telemetry.retrieval(ctx, options)\n }\n\n reranking(ctx: otel.Context, options?: StartSpanOptions) {\n return this.telemetry.reranking(ctx, options)\n }\n\n http(ctx: otel.Context, options: StartHttpSpanOptions) {\n return this.telemetry.http(ctx, options)\n }\n\n prompt(ctx: otel.Context, options: PromptSegmentOptions) {\n return this.telemetry.prompt(ctx, options)\n }\n\n step(ctx: otel.Context, options?: SegmentOptions) {\n return this.telemetry.step(ctx, options)\n }\n}\n\nexport type {\n EndCompletionSpanOptions,\n EndHttpSpanOptions,\n EndSpanOptions,\n EndToolSpanOptions,\n ErrorOptions,\n PromptSegmentOptions,\n SegmentOptions,\n StartCompletionSpanOptions,\n StartHttpSpanOptions,\n StartSpanOptions,\n StartToolSpanOptions,\n} from '$telemetry/instrumentations'\n"],"names":["z","propagation","otel","ATTR_GEN_AI_OPERATION_NAME","trace","ATTR_GEN_AI_TOOL_NAME","ATTR_GEN_AI_TOOL_TYPE","ATTR_GEN_AI_TOOL_CALL_ID","ATTR_GEN_AI_SYSTEM","ATTR_GEN_AI_USAGE_INPUT_TOKENS","ATTR_GEN_AI_USAGE_OUTPUT_TOKENS","ATTR_GEN_AI_RESPONSE_MODEL","ATTR_GEN_AI_RESPONSE_FINISH_REASONS","ATTR_HTTP_REQUEST_METHOD","ATTR_HTTP_RESPONSE_STATUS_CODE","uuid","context","OTLPTraceExporter","Instrumentation","AsyncLocalStorageContextManager","CompositePropagator","W3CTraceContextPropagator","W3CBaggagePropagator","NodeTracerProvider","Resource","ATTR_SERVICE_NAME","BaggageSpanProcessor","ALLOW_ALL_BAGGAGE_KEYS","SimpleSpanProcessor","BatchSpanProcessor","instrumentation","OpenAIInstrumentation","registerInstrumentations","AnthropicInstrumentation","AzureOpenAIInstrumentation","VertexAIInstrumentation","AIPlatformInstrumentation","BedrockInstrumentation","TogetherInstrumentation","CohereInstrumentation","LangChainInstrumentation","LlamaIndexInstrumentation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAQa,mBAAmB,CAAA;AACtB,IAAA,OAAO;AAEf,IAAA,WAAA,CAAY,OAAmC,EAAA;AAC7C,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;AAEtB,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;AACjB,YAAA,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,UAAkB,EAAE,MAAW,KAAK,QAAQ;;;IAIrE,OAAO,CAAC,KAAmB,EAAE,QAAsB,EAAA;;;AAInD,IAAA,KAAK,CAAC,IAAkB,EAAA;AACtB,QAAA,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACtE,QAAA,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;YAC/B,IAAI,CAAC,KAAK,CAAC,UAAU;gBAAE;AACvB,YAAA,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;;AAE1E,QAAA,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,UAAU;gBAAE;AACtB,YAAA,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EA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