/** * Task lifecycle span helpers. * * Tracks the full task state machine: * TASK_CREATED → TASK_STARTED → TASK_BLOCKED → TASK_PROGRESS * Terminal states: TASK_COMPLETED | TASK_FAILED | TASK_CANCELLED * * One span per task. Optionally parented to an agent span. */ import type { Span, SpanAttributes } from '../types.js'; import type { RuntimeTracer } from '../tracer.js'; /** Context supplied when starting a task lifecycle span. */ export interface TaskSpanContext { /** Task ID (unique). */ readonly taskId: string; /** Optional agent ID that owns this task. */ readonly agentId?: string | undefined; /** Human-readable task description. */ readonly description: string; /** Task scheduling priority. */ readonly priority: number; /** Trace ID for cross-span correlation. */ readonly traceId: string; /** * Optional parent span ID for nesting under an agent span. * When provided, this task span becomes a child of the agent span. */ readonly parentSpanId?: string | undefined; } /** Phase transitions recordable on a task lifecycle span. */ export type TaskPhase = 'started' | 'blocked' | 'progress'; /** Result context supplied when ending a task lifecycle span. */ export interface TaskSpanEndContext { /** Final outcome of the task. */ readonly outcome: 'completed' | 'failed' | 'cancelled'; /** Duration of the task in milliseconds. */ readonly durationMs: number; /** Error description when outcome is 'failed'. */ readonly error?: string | undefined; /** Cancel reason when outcome is 'cancelled'. */ readonly reason?: string | undefined; } /** * Start a task lifecycle span. * * @param tracer - RuntimeTracer instance. * @param ctx - Context from TASK_CREATED event. */ export declare function startTaskSpan(tracer: RuntimeTracer, ctx: TaskSpanContext): Span; /** * Record a task phase transition event. * * @param span - The active task lifecycle span. * @param phase - The phase reached. * @param attrs - Optional additional attributes. */ export declare function recordTaskPhase(span: Span, phase: TaskPhase, attrs?: SpanAttributes): void; /** * End a task lifecycle span. * * @param span - The span returned by `startTaskSpan`. * @param ctx - Task lifecycle end context. */ export declare function endTaskSpan(span: Span, ctx: TaskSpanEndContext): void; //# sourceMappingURL=task.d.ts.map