import type { ModelCatalogEntry } from './models.js';
import type { ClassMapDefinition } from './labels.js';
import type { PipelineSlot } from './pipeline.js';
import type { ConfigField } from '../interfaces/config-ui.js';
/**
 * Each pipeline step implements this interface as a class.
 * `definition` holds the static metadata; `getConfigSchema()` declares
 * per-step settings (class filters, thresholds, etc.) that the UI renders
 * dynamically and that can be overridden per-run.
 */
export interface IPipelineStep {
    readonly definition: StepDefinition;
    getConfigSchema(): readonly ConfigField[];
}
export type PostprocessorType = 'yolo' | 'yolo-seg' | 'scrfd' | 'arcface' | 'softmax' | 'ctc' | 'saliency' | 'yamnet';
export interface StepDefinition {
    /** Unique step identifier (e.g., 'object-detection', 'face-detection') */
    readonly id: string;
    /** Human-readable name */
    readonly name: string;
    /** Pipeline slot type */
    readonly slot: PipelineSlot;
    /** Which postprocessor to apply to raw model output */
    readonly postprocessor: PostprocessorType;
    /** How this step receives its input */
    readonly extractMode: 'full-frame' | 'crop-roi';
    /** Classes this step accepts from a parent detector (null = root, accepts full frame) */
    readonly inputClasses: readonly string[] | null;
    /** Classes this step outputs (e.g., ['person','vehicle','animal'] for YOLO) */
    readonly outputClasses: readonly string[];
    /** Available models for this step */
    readonly models: readonly ModelCatalogEntry[];
    /** Default model when no user preference is set */
    readonly defaultModelId: string;
    /**
     * Optional per-format model preference. When an agent seeds its
     * `addonDefaults[this.id]`, it looks up `defaultModelIdByFormat[agent.activeEngine.format]`
     * first, then falls back to `defaultModelId`. Lets a step express "on
     * coreml prefer apple-soundanalysis, on onnx prefer yamnet-onnx" without
     * duplicating the step definition per engine.
     */
    readonly defaultModelIdByFormat?: Readonly<Record<string, string>>;
    /**
     * Whether a newly-seeded agent has this addon enabled by default.
     * Absent = `true`. Operators can always toggle this after boot; this
     * flag only controls the initial seed for operator-first-touch
     * convenience (e.g. keep refiners off by default so operators opt in
     * rather than out).
     */
    readonly enabledByDefault?: boolean;
    /** Default confidence threshold */
    readonly defaultConfidence: number;
    /** Runtime label lookup (e.g., class name arrays for softmax, charset for CTC) */
    readonly labels?: readonly string[];
    /** Character set for CTC decode (index 0 = blank token) */
    readonly charset?: readonly string[];
    /** COCO-to-macro class mapping (e.g., 'car' → 'vehicle') */
    readonly classMap?: ClassMapDefinition;
    /** UI grouping label — steps with the same group are displayed together (e.g., 'Segmentation') */
    readonly group?: string;
    /**
     * Default minimum parent detection score to trigger this child step.
     * Child steps are skipped if the parent detection's confidence is
     * below this threshold. Saves inference for low-confidence detections.
     * E.g., face-detection with minParentScore=0.7 only runs on persons
     * detected with score ≥ 0.7. Configurable per-step via settings.
     */
    readonly defaultMinParentScore?: number;
}
export interface PoolModelConfig {
    /** Absolute path to the model file (.mlpackage, .xml, .onnx) */
    readonly path: string;
    /** Largest dimension of model input (e.g., 640 for 640×640) */
    readonly inputSize: number;
    /** How to preprocess the image before inference */
    readonly preprocessMode: 'letterbox' | 'resize';
    /** Postprocessor to apply to raw output in Python */
    readonly postprocessor: PostprocessorType;
    /** Confidence threshold for NMS / filtering */
    readonly confidence: number;
    /** Label names for softmax-based classifiers */
    readonly labels?: readonly string[];
    /** Character set for CTC-based recognizers */
    readonly charset?: readonly string[];
    /** Number of classes (for YOLO: 80 COCO or 1 for plate) */
    readonly numClasses?: number;
    /** Anchor strides for SCRFD (default [8, 16, 32]) */
    readonly strides?: readonly number[];
    /** Mask threshold for saliency/segmentation */
    readonly maskThreshold?: number;
    /** Hardware device target (CoreML: cpu/gpu/ane/all, OpenVINO: auto/cpu/gpu/npu, ONNX: cpu/cuda/coreml) */
    readonly device?: string;
}
export interface DetectionsOutput {
    readonly kind: 'detections';
    readonly detections: readonly {
        readonly class: string;
        readonly score: number;
        readonly bbox: readonly [number, number, number, number];
        readonly landmarks?: readonly {
            readonly x: number;
            readonly y: number;
        }[];
        /** Base64-encoded binary mask cropped to bbox (instance segmentation) */
        readonly mask?: string;
        /** Width of the decoded mask in pixels */
        readonly maskWidth?: number;
        /** Height of the decoded mask in pixels */
        readonly maskHeight?: number;
    }[];
}
export interface ClassificationsOutput {
    readonly kind: 'classifications';
    readonly classifications: readonly {
        readonly class: string;
        readonly score: number;
    }[];
    /** Full ranked list for debugging (top-N). Only populated when traceVerbosity is enabled. */
    readonly alternates?: readonly {
        readonly class: string;
        readonly score: number;
    }[];
}
export interface EmbeddingOutput {
    readonly kind: 'embedding';
    readonly embedding: readonly number[];
    readonly embeddingNorm: readonly number[];
}
export interface TextOutput {
    readonly kind: 'text';
    readonly text: string;
    readonly confidence: number;
}
export interface MaskOutput {
    readonly kind: 'mask';
    readonly mask: string;
    readonly maskWidth: number;
    readonly maskHeight: number;
}
/** Discriminated union for step output — use switch(output.kind) */
export type StepOutput = DetectionsOutput | ClassificationsOutput | EmbeddingOutput | TextOutput | MaskOutput;
export type TraceVerbosity = 'off' | 'summary' | 'full';
export interface PipelineRunOptions {
    readonly traceVerbosity?: TraceVerbosity;
}
export interface StepTrace {
    readonly stepId: string;
    readonly modelId: string;
    readonly slot: PipelineSlot;
    readonly postprocessor: PostprocessorType;
    readonly preprocessMs: number;
    readonly inferenceMs: number;
    readonly postprocessMs: number;
    readonly totalMs: number;
    readonly inputType: 'full-frame' | 'crop-roi';
    readonly inputSize: {
        readonly width: number;
        readonly height: number;
    };
    /** Class name of the parent detection that triggered this step */
    readonly parentDetection?: string;
    readonly outputKind: StepOutput['kind'];
    readonly outputCount: number;
    /** Human-readable top result (e.g., "person 0.92", "cat 0.88", "ABC123") */
    readonly topResult?: string;
    readonly error?: string;
}
export interface PipelineExecutionTrace {
    readonly traceId: string;
    readonly deviceId: number;
    readonly timestamp: number;
    readonly frameSize: {
        readonly width: number;
        readonly height: number;
    };
    readonly engineRuntime: string;
    readonly steps: readonly StepTrace[];
    readonly totalMs: number;
    readonly detectionCount: number;
    readonly [key: string]: unknown;
}
export interface MotionBox {
    readonly bbox: readonly [number, number, number, number];
    readonly changeScore: number;
}
export interface MotionRawEvent {
    readonly type: 'motion.raw';
    readonly deviceId: string;
    readonly timestamp: number;
    readonly boxes: readonly MotionBox[];
    readonly frameSize: {
        readonly width: number;
        readonly height: number;
    };
    readonly motionScore: number;
}
export interface PipelineTraceEvent {
    readonly type: 'pipeline.trace';
    readonly trace: PipelineExecutionTrace;
}
//# sourceMappingURL=pipeline-step.d.ts.map