/** * Session recovery span helpers. * * Tracks the full session lifecycle: * SESSION_STARTED | SESSION_LOADING → SESSION_RESUMED | SESSION_REPAIRING * → SESSION_RECONCILING → SESSION_READY * Terminal error state: SESSION_RECOVERY_FAILED * * One span per session initialisation / recovery attempt. */ import type { Span, SpanAttributes } from '../types.js'; import type { RuntimeTracer } from '../tracer.js'; /** Context supplied when starting a session lifecycle span. */ export interface SessionSpanContext { /** Session ID. */ readonly sessionId: string; /** Trace ID for cross-span correlation. */ readonly traceId: string; /** Profile ID used for this session (present on new sessions). */ readonly profileId?: string | undefined; /** Working directory for this session (present on new sessions). */ readonly workingDir?: string | undefined; /** Path to the saved session file (present on resumed sessions). */ readonly path?: string | undefined; } /** Phase transitions recordable on a session lifecycle span. */ export type SessionPhase = 'loading' | 'resumed' | 'repairing' | 'reconciling'; /** Result context supplied when ending a session lifecycle span. */ export interface SessionSpanEndContext { /** Final outcome of the session initialisation. */ readonly outcome: 'ready' | 'recovery_failed'; /** Error description when outcome is 'recovery_failed'. */ readonly error?: string | undefined; /** Number of turns loaded on resume (if applicable). */ readonly turnCount?: number | undefined; /** Number of messages reconciled (if applicable). */ readonly messageCount?: number | undefined; } /** * Start a session lifecycle span. * * @param tracer - RuntimeTracer instance. * @param ctx - Context from SESSION_STARTED or SESSION_LOADING event. */ export declare function startSessionSpan(tracer: RuntimeTracer, ctx: SessionSpanContext): Span; /** * Record a session lifecycle phase transition. * * @param span - The active session lifecycle span. * @param phase - The phase reached. * @param attrs - Optional additional attributes. */ export declare function recordSessionPhase(span: Span, phase: SessionPhase, attrs?: SpanAttributes): void; /** * End a session lifecycle span. * * @param span - The span returned by `startSessionSpan`. * @param ctx - Session lifecycle end context. */ export declare function endSessionSpan(span: Span, ctx: SessionSpanEndContext): void; //# sourceMappingURL=session.d.ts.map