import type { PipelineEngineChoice, PipelineConfig } from '../types/pipeline.js';
import type { PipelineSchema, PipelineDefaultStep, PipelineTemplateStep, PipelineTemplate } from '../types/pipeline-schema.js';
import type { ModelFormat } from '../types/models.js';
import type { FrameInput } from '../types/io.js';
import type { FrameResult, DetectorOutput } from '../types/detection.js';
import type { ConfigUISchema } from './config-ui.js';
import type { InferenceCapabilities } from './inference-capabilities.js';
import type { IAddonResolver } from './pipeline-runner.js';
/**
 * Step configuration for pipeline execution — no runtime/backend (comes
 * from engine). Phase 7 (settings redesign) removed the generic
 * `confidence: number` field; per-step thresholds live in `settings`
 * and the runtime executor falls back to
 * `StepDefinition.defaultConfidence` when unset.
 */
export interface PipelineStepInput {
    readonly addonId: string;
    readonly modelId: string;
    readonly enabled: boolean;
    readonly children?: readonly PipelineStepInput[];
    readonly settings?: Readonly<Record<string, unknown>>;
}
/**
 * Input for pipeline execution. Exactly one image source must be provided:
 *  - `frame`: runtime dispatch (pipeline-runner — decoded broker frame)
 *  - `imageBase64`: one-shot benchmark (ImageTab "Run")
 *  - `referenceImage`: named file from the reference-image store
 *
 * `engine` + `deviceId` are optional contextual hints — the executor uses
 * `deviceId` for per-device overrides and traces, and `engine` to select
 * the factory (when absent, falls back to the executor's persisted
 * selection during the migration window).
 */
export interface PipelineRunInput {
    readonly steps: readonly PipelineStepInput[];
    readonly engine?: PipelineEngineChoice;
    readonly frame?: FrameInput;
    readonly referenceImage?: string;
    readonly imageBase64?: string;
    /**
     * Binary JPEG bytes — preferred over `imageBase64` on internal worker
     * hops (hub → forked worker via Moleculer MsgPack). Skips 33% base64
     * overhead + per-call decode. Exactly one of `frame`/`image`/
     * `imageBase64`/`referenceImage` is required.
     */
    readonly image?: Uint8Array;
    readonly deviceId?: number;
    /**
     * Correlation id tagged on every `pipeline.progress` event emitted
     * by this run. When a UI-initiated one-shot (`runPipelineTest`)
     * generates its own id and passes it here, the UI can filter the
     * progress stream by `sessionId + nodeId` to ignore concurrent
     * runtime dispatches from live camera frames. Server-side runs
     * that omit this field get a generated id.
     */
    readonly sessionId?: string;
}
/**
 * Singleton capability provided by the pipeline-executor addon.
 * The server backend consumes this via the capability registry.
 */
export interface IPipelineExecutorProvider {
    /** Build pipeline schema filtered by the selected (or provided) engine */
    getSchema(engine?: PipelineEngineChoice): Promise<PipelineSchema>;
    /** Get all available engines probed on this agent */
    getAvailableEngines(): Promise<PipelineEngineChoice[]>;
    /** Build default step tree for an engine */
    getDefaultSteps(engine: PipelineEngineChoice): Promise<PipelineDefaultStep[]>;
    /** Get persisted global steps (null if not yet configured). Kept read-only for benchmark fallback. */
    getGlobalSteps(): Promise<PipelineDefaultStep[] | null>;
    /** Get the runner-ready pipeline config */
    getGlobalPipelineConfig(): Promise<PipelineConfig | null>;
    /** Get the currently selected engine (bootstrap default on the node). */
    getSelectedEngine(): Promise<PipelineEngineChoice>;
    getOrchestratorConfigSchema(): Promise<ConfigUISchema>;
    /** Get full inference capabilities (addon models, runtimes, etc.) */
    getCapabilities(forceRefresh?: boolean): Promise<InferenceCapabilities>;
    /** Get available models for a specific addon */
    getAddonModels(input: {
        addonId: string;
    }): Promise<readonly import('./inference-capabilities.js').ModelAvailability[]>;
    /** Download a specific model */
    downloadModel(input: {
        modelId: string;
        format: ModelFormat;
        addonId: string;
    }): Promise<{
        filePath: string;
        sizeMB: number;
        durationMs: number;
    }>;
    /** Delete a downloaded model from disk */
    deleteModel(input: {
        modelId: string;
        format: ModelFormat;
        addonId: string;
    }): Promise<{
        success: true;
    }>;
    /** Execute the full pipeline on a reference/base64 image (for UI/benchmark) */
    runPipeline(input: PipelineRunInput, onProgress?: (message: string) => void): Promise<FrameResult>;
    /**
     * Batched execution — N raw frames packed into one cap call. Routes
     * through `SharedInferencePool.inferBatch` (`MSG_INFER_BATCH = 0x03`)
     * so IPC + JSON envelope cost is amortised N:1 vs N concurrent
     * `runPipeline` calls. Constraints:
     *   - Single root step (no crop children) — multi-step trees fall
     *     back to sequential execution per-frame inside the provider.
     *   - Uniform model across the batch (Python pool resolves one model
     *     index per request).
     * Used by the Scrypted-comparison benchmark to mirror
     * `detectObjects(media, {batch})`.
     */
    runPipelineBatch(input: {
        readonly steps: readonly PipelineStepInput[];
        readonly engine?: PipelineEngineChoice;
        readonly frames: readonly FrameInput[];
        readonly deviceId?: number;
        readonly sessionId?: string;
    }): Promise<{
        readonly results: readonly FrameResult[];
    }>;
    /** Run single-addon detection on a frame */
    detect(input: {
        addonId: string;
        frame: FrameInput;
        config?: Record<string, unknown>;
    }): Promise<DetectorOutput>;
    listReferenceImages(): Promise<Array<{
        id: string;
        filename: string;
        sizeKB: number;
    }>>;
    getReferenceImage(input: {
        filename: string;
    }): Promise<{
        base64: string;
        filename: string;
    } | null>;
    getReferenceAudioFiles(): Promise<readonly {
        filename: string;
        sizeKb: number;
    }[]>;
    getReferenceAudio(input: {
        filename: string;
    }): Promise<{
        base64: string;
    }>;
    getAudioCapabilities(): Promise<{
        activeBackend: string;
        availableBackends: readonly {
            id: string;
            name: string;
            description: string;
            available: boolean;
        }[];
        sampleRate: number;
        chunkDurationMs: number;
    }>;
    /**
     * Run the audio classifier on a reference WAV file (benchmark path).
     *
     * Returns an `AudioResult` wrapped in a `{success, error?, frame?}`
     * envelope so the UI can render a clean failure when the classifier
     * cap isn't available. Each class above the step's `minScore`
     * threshold becomes one `AudioDetection` entry; the full top-N ranked
     * list lives in `frame.debug.alternateLabels['audio-classifier']`.
     */
    runAudioTest(input: {
        addonId: string;
        modelId: string;
        filename?: string;
        settings?: Record<string, unknown>;
    }): Promise<{
        success: boolean;
        error?: string;
        frame?: import('../types/detection.js').AudioResult;
    }>;
    listTemplates(): Promise<PipelineTemplate[]>;
    saveTemplate(input: {
        name: string;
        steps: readonly PipelineTemplateStep[];
        engine: PipelineEngineChoice;
    }): Promise<PipelineTemplate>;
    updateTemplate(input: {
        id: string;
        name?: string;
        steps?: readonly PipelineTemplateStep[];
    }): Promise<PipelineTemplate>;
    deleteTemplate(input: {
        id: string;
    }): Promise<void>;
    /** Get the detection pipeline addon's config schema (for detection-config UI). */
    getDetectionConfigSchema(): Promise<ConfigUISchema | null>;
    /** Get the addon resolver for runtime pipeline execution */
    getAddonResolver(): Promise<IAddonResolver>;
    /** Set the in-process tRPC client for inter-capability calls. */
    setApi(api: unknown): Promise<void>;
}
//# sourceMappingURL=pipeline-executor-capability.d.ts.map