/** * gen_ai / MCP span mapping — the one place that turns extracted hook content (or on-site * MCP call data) into OpenTelemetry GenAI/MCP semantic-convention span attributes (the * `GEN_AI` keys below). Standard keys only — no OpenClaw `openclaw.content.*` mirror, no * OpenInference `input.value`/`output.value` aliases; `gen_ai.system_instructions` is the * spec's underscore form. * * Content (messages, system instructions, tool args/result) is the highest-PII surface, so * it is always redacted *before* stamping and capped *after* (sanitize → redact → cap) so a * truncated value can't re-expose a partial secret. If the redactor fails to load, content is * dropped rather than emitted unredacted. */ import type { Attributes, Span } from "@opentelemetry/api"; /** * Max chars per content attribute value, applied after redaction. A transport-safety * cap that sits far under the OTLP/HTTP request-body limit (~20 MiB), not a backend * storage limit — content this size is rare and we'd rather truncate than risk a * rejected export. */ export declare const MAX_OTEL_CONTENT_ATTRIBUTE_CHARS: number; /** Max items per message / tool-definition array, applied after redaction. */ export declare const MAX_OTEL_CONTENT_ARRAY_ITEMS = 200; export declare const GEN_AI: { readonly OPERATION_NAME: "gen_ai.operation.name"; readonly CONVERSATION_ID: "gen_ai.conversation.id"; readonly PROVIDER_NAME: "gen_ai.provider.name"; readonly REQUEST_MODEL: "gen_ai.request.model"; readonly REQUEST_TEMPERATURE: "gen_ai.request.temperature"; readonly REQUEST_MAX_TOKENS: "gen_ai.request.max_tokens"; readonly RESPONSE_MODEL: "gen_ai.response.model"; readonly RESPONSE_FINISH_REASONS: "gen_ai.response.finish_reasons"; readonly USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens"; readonly USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens"; readonly USAGE_CACHE_READ_TOKENS: "gen_ai.usage.cache_read_tokens"; readonly USAGE_CACHE_WRITE_TOKENS: "gen_ai.usage.cache_write_tokens"; readonly USAGE_TOTAL_TOKENS: "gen_ai.usage.total_tokens"; readonly SYSTEM_INSTRUCTIONS: "gen_ai.system_instructions"; readonly INPUT_MESSAGES: "gen_ai.input.messages"; readonly OUTPUT_MESSAGES: "gen_ai.output.messages"; readonly TOOL_DEFINITIONS: "gen_ai.tool.definitions"; readonly AGENT_NAME: "gen_ai.agent.name"; readonly TOOL_NAME: "gen_ai.tool.name"; readonly TOOL_CALL_ID: "gen_ai.tool.call.id"; readonly TOOL_CALL_ARGUMENTS: "gen_ai.tool.call.arguments"; readonly TOOL_CALL_RESULT: "gen_ai.tool.call.result"; }; /** Reset the cached redactor (tests only). */ export declare function __resetContentRedactorForTest(): void; /** * Turn a content value into a capped JSON string with PII redacted: sanitize framework * metadata, redact (when a redactor is available), then serialize within the caps. * Array content keeps the newest items (dropping oldest with a visible elision marker, * so the result stays valid JSON); non-array content is tail-truncated with a suffix. * Returns `undefined` when the value is empty. Never throws — a failure drops the value. */ export declare function redactAndCapContent(value: unknown): Promise; /** Redact + cap a content value and stamp it onto the span (when capture is on and non-empty). */ export declare function setGenAiContentAttribute(span: Span, key: string, value: unknown): Promise; /** Set every defined value in `attrs` on the span, skipping undefined/null. Never throws. */ export declare function setDefinedAttributes(span: Span, attrs: Attributes): void; /** Low-cardinality `error.type` for the spec: error.name, the string itself, else "_OTHER". */ export declare function errorTypeOf(error: unknown): string; /** * Mark a span as failed: record the exception, set ERROR status, and stamp the spec's * low-cardinality `error.type`. Never throws. */ export declare function recordSpanError(span: Span, error: unknown): void; /** First finite number among the candidates, else undefined. */ export declare function firstNumber(...values: unknown[]): number | undefined; /** Normalize a finish-reason value to a string array (gen_ai.response.finish_reasons is an array). */ export declare function toFinishReasons(value: unknown): string[] | undefined; /** Normalize a list of raw provider messages into spec `{ role, parts }` objects. */ export declare function normalizeGenAiMessages(value: unknown, fallbackRole: "user" | "assistant"): Array> | undefined; //# sourceMappingURL=gen-ai.d.ts.map