import type { ChunkId, DocumentId, EmbeddingModelIdentity, IndexingJobError, KnowledgeCapsuleId, KnowledgeSourceId, VectorRecord } from "@oscharko-dev/keiko-contracts";
import type { OpenAIEmbeddingAdapter } from "@oscharko-dev/keiko-model-gateway";
import type { WorkspaceFs } from "@oscharko-dev/keiko-workspace";
import type { ChunkingOptions } from "../chunking/index.js";
import type { DiscoveryOptions } from "../discovery/index.js";
import { KnowledgeStoreError } from "../errors.js";
import type { ParserRegistry } from "../parsers/index.js";
import type { AuditEventSink } from "../privacy/index.js";
import type { KnowledgeStore } from "../store.js";
export declare const DEFAULT_INDEXING_BATCH_SIZE = 64;
export declare const DEFAULT_INDEXING_CONCURRENCY = 4;
export type IndexingErrorCode = "INCOMPATIBLE_EMBEDDING_IDENTITY" | "EMBEDDING_ADAPTER_FAILED" | "DISCOVERY_FAILED" | "CHUNKING_FAILED" | "CANCELLED" | "CAPSULE_NOT_FOUND" | "INVALID_OPTIONS" | "PERSISTENCE_FAILED";
export declare class IndexingError extends KnowledgeStoreError {
    readonly name: string;
    readonly code: IndexingErrorCode;
    constructor(code: IndexingErrorCode, message: string, options?: {
        cause?: unknown;
    });
}
export interface IndexingOptions {
    readonly capsuleId: KnowledgeCapsuleId;
    readonly sourceIds?: readonly KnowledgeSourceId[];
    readonly parserRegistry: ParserRegistry;
    readonly workspaceFs: WorkspaceFs;
    readonly embeddingAdapter: OpenAIEmbeddingAdapter;
    readonly store: KnowledgeStore;
    readonly signal?: AbortSignal;
    readonly progress?: (event: IndexingEvent) => void;
    readonly auditSink?: AuditEventSink;
    readonly force?: boolean;
    readonly batchSize?: number;
    readonly concurrency?: number;
    readonly chunkingOptions?: ChunkingOptions;
    readonly discoveryOptions?: DiscoveryOptions;
    readonly now?: () => number;
    readonly idSource?: () => string;
}
export interface IndexingJobStartedEvent {
    readonly kind: "job-started";
    readonly jobId: string;
    readonly capsuleId: KnowledgeCapsuleId;
    readonly sourceIds: readonly KnowledgeSourceId[];
    readonly startedAt: number;
}
export interface IndexingDocumentDiscoveredEvent {
    readonly kind: "document-discovered";
    readonly jobId: string;
    readonly relativePath: string;
    readonly sizeBytes: number;
}
export interface IndexingDocumentExtractedEvent {
    readonly kind: "document-extracted";
    readonly jobId: string;
    readonly documentId: DocumentId;
    readonly relativePath: string;
}
export interface IndexingDocumentChunkedEvent {
    readonly kind: "document-chunked";
    readonly jobId: string;
    readonly documentId: DocumentId;
    readonly chunkCount: number;
}
export interface IndexingDocumentEmbeddedEvent {
    readonly kind: "document-embedded";
    readonly jobId: string;
    readonly documentId: DocumentId;
    readonly vectorCount: number;
    readonly resumeToken: ChunkId;
}
export interface IndexingDocumentSkippedEvent {
    readonly kind: "document-skipped";
    readonly jobId: string;
    readonly documentId: DocumentId;
    readonly reason: "unchanged" | "already-embedded" | "unsupported";
}
export interface IndexingDocumentFailedEvent {
    readonly kind: "document-failed";
    readonly jobId: string;
    readonly documentId?: DocumentId;
    readonly relativePath?: string;
    readonly error: IndexingJobError;
}
export interface IndexingJobCompletedEvent {
    readonly kind: "job-completed";
    readonly jobId: string;
    readonly result: IndexingResult;
}
export interface IndexingJobCancelledEvent {
    readonly kind: "job-cancelled";
    readonly jobId: string;
    readonly result: IndexingResult;
}
export interface IndexingJobFailedEvent {
    readonly kind: "job-failed";
    readonly jobId: string;
    readonly error: IndexingJobError;
    readonly result: IndexingResult;
}
export type IndexingEvent = IndexingJobStartedEvent | IndexingDocumentDiscoveredEvent | IndexingDocumentExtractedEvent | IndexingDocumentChunkedEvent | IndexingDocumentEmbeddedEvent | IndexingDocumentSkippedEvent | IndexingDocumentFailedEvent | IndexingJobCompletedEvent | IndexingJobCancelledEvent | IndexingJobFailedEvent;
export interface IndexingResult {
    readonly jobId: string;
    readonly capsuleId: KnowledgeCapsuleId;
    readonly status: "succeeded" | "failed" | "cancelled";
    readonly totalDocuments: number;
    readonly processedDocuments: number;
    readonly failedDocuments: number;
    readonly skippedDocuments: number;
    readonly vectorsPersisted: number;
    readonly startedAt: number;
    readonly finishedAt: number;
    readonly lastError?: IndexingJobError;
    readonly embeddingIdentity?: EmbeddingModelIdentity;
}
export interface ChunkToEmbed {
    readonly id: ChunkId;
    readonly capsuleId: KnowledgeCapsuleId;
    readonly sourceId: KnowledgeSourceId;
    readonly documentId: DocumentId;
    readonly text: string;
}
export interface EmbedRetryOptions {
    readonly maxRetries: number;
    readonly baseDelayMs: number;
    readonly sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
}
export interface EmbedBatchOptions {
    readonly adapter: OpenAIEmbeddingAdapter;
    readonly store: KnowledgeStore;
    readonly pinnedIdentity: EmbeddingModelIdentity;
    readonly concurrency: number;
    readonly signal?: AbortSignal;
    readonly now: () => number;
    readonly idSource: () => string;
    readonly retry?: EmbedRetryOptions;
}
export interface EmbedBatchResult {
    readonly vectors: readonly VectorRecord[];
    readonly errors: readonly IndexingJobError[];
}
//# sourceMappingURL=types.d.ts.map