import { type SpanContext, type Tracer } from "#compiled/@opentelemetry/api/index.js"; import type { InstrumentationContextRunner, InstrumentationProviderDefinition, InstrumentationTurnTerminalEvent } from "#harness/instrumentation-lifecycle.js"; /** Sized so an ordinary session stays one trace and only an outsized one rolls. */ export declare const SESSION_WINDOW_TURN_LIMIT = 200; export interface AgentSessionTraceState { readonly agentName?: string; readonly channelKind?: string; readonly context: SpanContext; readonly rootSessionId: string; readonly turnsInWindow: number; readonly window: number; } export interface AgentTurnTraceState { readonly context: SpanContext; readonly rootSessionId: string; readonly sequence: number; readonly terminal?: { readonly error?: unknown; readonly type: InstrumentationTurnTerminalEvent["type"]; }; } /** Provider-owned serializable storage for durable agent trace state. */ export interface AgentTraceStateStore { deleteSession(sessionId: string): void | PromiseLike; deleteTurn(sessionId: string, turnId: string): void | PromiseLike; getSession(sessionId: string): AgentSessionTraceState | undefined | PromiseLike; getTurn(sessionId: string, turnId: string): AgentTurnTraceState | undefined | PromiseLike; setSession(sessionId: string, state: AgentSessionTraceState): void | PromiseLike; setTurn(sessionId: string, turnId: string, state: AgentTurnTraceState): void | PromiseLike; } /** In-memory trace state used by tests and non-durable runtimes. */ export declare class InMemoryAgentTraceStateStore implements AgentTraceStateStore { #private; deleteSession(sessionId: string): void; deleteTurn(sessionId: string, turnId: string): void; getSession(sessionId: string): AgentSessionTraceState | undefined; getTurn(sessionId: string, turnId: string): AgentTurnTraceState | undefined; setSession(sessionId: string, state: AgentSessionTraceState): void; setTurn(sessionId: string, turnId: string, state: AgentTurnTraceState): void; } export interface AgentOtelInstrumentationInput { /** * Capture model prompts/responses and tool call inputs/outputs as span * attributes. Content stays on the local machine — this provider only * wires the dev-time local spool — but can be turned off per project. */ readonly captureContent?: boolean; readonly frameworkVersion: string; readonly stateStore: AgentTraceStateStore; readonly tracer: Tracer; } /** OTel event definition and its trusted framework context runner. */ export interface AgentOtelInstrumentation { readonly hook: InstrumentationProviderDefinition; readonly runInContext: InstrumentationContextRunner; } /** Creates OTel instrumentation for eve's structural `agent.*` convention. */ export declare function createAgentOtelInstrumentation(input: AgentOtelInstrumentationInput): AgentOtelInstrumentation;