/** * Native OpenTelemetry Hooks * * Creates real OTel spans during agent execution with proper context propagation * and gen_ai semantic conventions. Unlike the post-hoc `createOTelExporter()`, * these hooks create spans in real time with correct parent-child relationships. * * Requires `@opentelemetry/api` (regular dependency, no-ops without SDK registered). * * @example * ```typescript * import { createOTelHooks } from '@compilr-dev/agents'; * * const hooks = createOTelHooks({ * providerName: 'claude', * tracerName: 'my-agent', * }); * * const agent = new Agent({ provider, hooks }); * ``` */ import type { HooksConfig } from '../hooks/types.js'; /** * Configuration for OTel hooks */ export interface OTelHooksConfig { /** Tracer name (default: '@compilr-dev/agents') */ tracerName?: string; /** Tracer version */ tracerVersion?: string; /** Provider name for gen_ai.system mapping (e.g. 'claude', 'openai') */ providerName?: string; /** Trace iteration spans (default: true) */ traceIterations?: boolean; /** Trace LLM call spans (default: true) */ traceLLM?: boolean; /** Trace tool execution spans (default: true) */ traceTools?: boolean; /** Include input/output content in span attributes (default: false) */ includeIO?: boolean; /** Truncate attribute values at this length (default: 1000) */ truncateAt?: number; } /** * Create native OpenTelemetry hooks for agent instrumentation. * * These hooks create real OTel spans during execution, as opposed to the * post-hoc `createOTelExporter()` which recreates spans after the fact. * * Span hierarchy: * ``` * agent.iteration [INTERNAL] * ├── gen_ai.chat [CLIENT] (gen_ai.system, tokens, model) * ├── agent.tool.read_file [INTERNAL] (tool.name, success, duration) * └── agent.tool.bash [INTERNAL] * ``` * * @param config - Optional configuration * @returns HooksConfig ready to pass to Agent constructor */ export declare function createOTelHooks(config?: OTelHooksConfig): HooksConfig;