import { TokenSupremacyEngine, type FileRef, type ReadingPlan } from './token-supremacy.js';
import { KVBridge, type BridgeMetrics } from './kv-bridge.js';
import { type MemoryItem, type MemoryRecallFilters, type MemoryStats } from './memory.js';
import { NXLInterpreter, type AgentArchetype } from './nxl-interpreter.js';
export type BackendMode = 'default' | 'shadow' | 'experimental';
export interface BackendDescriptor {
    kind: string;
    mode: BackendMode;
    details?: Record<string, unknown>;
}
export interface MemorySnapshotCapable {
    snapshot?(limit?: number): MemoryItem[];
}
export interface MemoryBackend {
    descriptor: BackendDescriptor;
    recall(query: string, k?: number, filters?: MemoryRecallFilters): Promise<string[]>;
    store(content: string, priority?: number, tags?: string[], parentId?: string, depth?: number): Promise<string> | string;
    stats(): MemoryStats | Record<string, unknown>;
    shadowRecall?(query: string, k?: number, filters?: MemoryRecallFilters): Promise<Record<string, unknown>>;
}
export interface CompressionShadow {
    mode: BackendMode;
    bridgeMetrics?: BridgeMetrics;
    notes: string[];
}
export interface CompressionPlanResult {
    plan: ReadingPlan;
    notes: string[];
}
export interface CompressionBackend {
    descriptor: BackendDescriptor;
    planFiles(task: string, files: FileRef[]): Promise<ReadingPlan | CompressionPlanResult>;
    allocateWorkerBudget(workerIds: string[], plan: ReadingPlan): Map<string, number>;
    shadow(task: string, files: FileRef[]): Promise<CompressionShadow>;
}
export interface DSLExecutionSpec {
    goal: string;
    files: string[];
    workers: number;
    roles: string[];
    strategies: string[];
    verify: string[];
    skills: string[];
    workflows: string[];
    guardrails: boolean;
    consensus: 'local' | 'run' | 'global';
    memoryBackend: string;
    compressionBackend: string;
    dslCompiler?: string;
    backendMode?: BackendMode;
    skillPolicy: 'guarded-hot' | 'session-only' | 'manual';
    workflowPolicy?: 'guarded-hot' | 'session-only' | 'manual';
    derivationPolicy?: 'auto' | 'manual' | 'disabled';
    actions?: Array<Record<string, unknown>>;
    metadata?: Record<string, unknown>;
}
export interface DSLCompilationResult {
    spec: DSLExecutionSpec;
    raw: Record<string, unknown>;
    archetypes: AgentArchetype[];
    notes?: string[];
}
export interface DSLCompilerBackend {
    descriptor: BackendDescriptor;
    compile(goal: string, rawScript?: string, useCase?: string): DSLCompilationResult;
}
type MemoryLike = {
    recall(query: string, k?: number, filters?: MemoryRecallFilters): Promise<string[]>;
    store(content: string, priority?: number, tags?: string[], parentId?: string, depth?: number): string;
    getStats(): MemoryStats;
} & MemorySnapshotCapable;
export declare class SQLiteMemoryBackend implements MemoryBackend {
    protected memory: MemoryLike;
    descriptor: BackendDescriptor;
    constructor(memory: MemoryLike);
    recall(query: string, k?: number, filters?: MemoryRecallFilters): Promise<string[]>;
    store(content: string, priority?: number, tags?: string[], parentId?: string, depth?: number): string;
    stats(): MemoryStats;
    shadowRecall(query: string, k?: number, filters?: MemoryRecallFilters): Promise<Record<string, unknown>>;
}
export declare class TemporalHyperbolicMemoryBackend extends SQLiteMemoryBackend {
    descriptor: BackendDescriptor;
    recall(query: string, k?: number, filters?: MemoryRecallFilters): Promise<string[]>;
    shadowRecall(query: string, k?: number, filters?: MemoryRecallFilters): Promise<Record<string, unknown>>;
}
export declare class DeterministicCompressionBackend implements CompressionBackend {
    descriptor: BackendDescriptor;
    protected tokenEngine: TokenSupremacyEngine;
    protected shadowBridge: KVBridge;
    constructor(tokenEngine?: TokenSupremacyEngine, shadowBridge?: KVBridge);
    planFiles(task: string, files: FileRef[]): Promise<ReadingPlan | CompressionPlanResult>;
    allocateWorkerBudget(workerIds: string[], plan: ReadingPlan): Map<string, number>;
    shadow(task: string, files: FileRef[]): Promise<CompressionShadow>;
}
export declare class MetaCompressionBackend extends DeterministicCompressionBackend {
    descriptor: BackendDescriptor;
    private metaLearner;
    planFiles(task: string, files: FileRef[]): Promise<CompressionPlanResult>;
    allocateWorkerBudget(workerIds: string[], plan: ReadingPlan): Map<string, number>;
    shadow(task: string, files: FileRef[]): Promise<CompressionShadow>;
}
export declare class DeterministicDSLCompilerBackend implements DSLCompilerBackend {
    protected interpreter: NXLInterpreter;
    descriptor: BackendDescriptor;
    constructor(interpreter?: NXLInterpreter);
    compile(goal: string, rawScript?: string, useCase?: string): DSLCompilationResult;
}
export declare class ExperimentalAgentLangCompilerBackend extends DeterministicDSLCompilerBackend {
    descriptor: BackendDescriptor;
    compile(goal: string, rawScript?: string, useCase?: string): DSLCompilationResult;
}
export interface RuntimeBackendRegistry {
    memory: Map<string, MemoryBackend>;
    compression: Map<string, CompressionBackend>;
    dsl: Map<string, DSLCompilerBackend>;
}
export interface BackendResolution<T> {
    selected: T;
    descriptor: BackendDescriptor;
    fallback?: string;
}
export declare function buildRunId(prefix?: string): string;
export declare function normalizeReadingPlan(result: ReadingPlan | CompressionPlanResult): CompressionPlanResult;
export declare function createRuntimeBackendRegistry(memory: MemoryLike): RuntimeBackendRegistry;
export declare function resolveBackend<T>(registry: Map<string, T>, requested: string | undefined, fallbackKey: string): BackendResolution<T>;
export declare const createSQLiteMemoryBackend: (memory: MemoryLike) => SQLiteMemoryBackend;
export declare const createDeterministicCompressionBackend: (tokenEngine?: TokenSupremacyEngine, shadowBridge?: KVBridge) => DeterministicCompressionBackend;
export declare const createDeterministicDSLCompilerBackend: (interpreter?: NXLInterpreter) => DeterministicDSLCompilerBackend;
export {};
