export interface Span {
	id: string;
	name: string;
	startTime: number;
	endTime?: number;
	attributes: Record<string, unknown>;
	children: Span[];
}

export interface Trace {
	id: string;
	rootSpan: Span;
	startTime: number;
	endTime?: number;
	attributes: Record<string, unknown>;
}

export function isTraceEnabled(): boolean;
export function initTraceCollector(
	projectRoot: string,
	sessionId: string | null,
	command: string,
	model: string | null,
): unknown;
export function flushTrace(projectRoot: string): void;
export function getActiveTrace(): Trace | null;
export function startUnitSpan(
	unitType: string,
	unitId: string,
	attributes?: Record<string, unknown>,
): Span;
export function startToolSpan(
	parentSpan: Span,
	toolName: string,
	toolCallId: string,
	attributes?: Record<string, unknown>,
): Span;
export function completeSpan(span: Span, status?: string): void;
export function traceEvent(
	span: Span,
	name: string,
	attrs: Record<string, unknown>,
): void;
export function traceError(span: Span, message: string, stack?: string): void;
export function findTraceSpan(id: string): Span | null;
export function setTraceCost(
	inputTokens: number,
	outputTokens: number,
	cacheReadTokens: number,
	cacheWriteTokens: number,
	costUsd: number,
): void;
export function setTraceExitCode(code: number): void;
