/**
 * Shared type and interface definitions for OrchestratorEngine.
 * Extracted from orchestrator.ts (Phase 3 split) to keep per-file size honest.
 * Re-exported from the orchestrator barrel so callers keep the same import path.
 */
import type { RepoTreeNode } from '../repo-tree.js';
import type { AgentArchetype } from '../nxl-interpreter.js';
import type { MemoryEngine } from '../memory.js';
import type { RuntimeArtifactSelectionAudit, RuntimeCatalogHealthSnapshot, RuntimeTaskGraphSnapshot, RuntimeOrchestrationSnapshot, RuntimePrimaryClientSnapshot, RuntimeSourceAwareTokenBudgetSnapshot, RuntimeTokenSummarySnapshot, RuntimeWorkerPlanSnapshot } from '../runtime-registry.js';
import type { SessionDNAManager } from '../session-dna.js';
import type { ClientRegistry } from '../client-registry.js';
import type { KnowledgeFabricBundle } from '../knowledge-fabric.js';
import type { BootstrapManifestStatus } from '../client-bootstrap.js';
import type { WorkspaceContext } from '../workspace-resolver.js';
import type { GhostReport, ExecutionTask, SubAgentRuntime } from '../../phantom/index.js';
import type { FilePrior, FilePriorInput } from '../priors/file-priors.js';
export type AgentType = 'researcher' | 'coder' | 'planner' | 'executor' | 'reviewer' | 'architect' | 'ux-validator';
export interface Agent {
    id: string;
    type: AgentType | string;
    task: string;
    state: 'pending' | 'running' | 'complete' | 'failed';
    result?: string;
    archetype?: AgentArchetype;
}
export interface Task {
    id: string;
    description: string;
    complexity: number;
    subtasks: string[];
}
export interface AutonomyIntent {
    taskType: 'bugfix' | 'feature' | 'release' | 'review' | 'research' | 'refactor' | 'ops' | 'pm' | 'test' | 'frontend' | 'backend' | 'ai' | 'marketing' | 'sales' | 'data';
    secondaryType?: string;
    intentScores?: Record<string, number>;
    riskClass: 'low' | 'medium' | 'high';
    complexity: number;
}
export type BootstrapDepth = 'fast' | 'deep';
export interface ArtifactHistoryRecord {
    score: number;
    helpful: number;
    neutral: number;
    redundant: number;
    harmful: number;
    updatedAt: number;
    lastVerificationResult: 'verified' | 'mixed' | 'failed' | 'none';
}
export type ArtifactOutcomeHistoryMap = Record<string, ArtifactHistoryRecord>;
export interface PersistedFilePriorState {
    version: 1;
    updatedAt: number;
    history: FilePriorInput[];
    priors: FilePrior[];
}
export interface BootstrapRequestOptions extends Partial<ExecutionTask> {
    depth?: BootstrapDepth;
    include?: string[];
}
export interface SessionAutonomyState {
    runtimeId: string;
    sessionId: string;
    startedAt: number;
    updatedAt: number;
    lastPrompt: string;
    objectiveHistory: string[];
    phases: string[];
    mode: RuntimeOrchestrationSnapshot['mode'];
    repeatedFailures: number;
    continuationDepth: number;
    intent: AutonomyIntent;
    selectedCrew?: string;
    selectedSpecialists: string[];
    selectedSkills: string[];
    selectedWorkflows: string[];
    selectedHooks: string[];
    selectedAutomations: string[];
    lastMemoryMatches: string[];
    latestSessionDNA?: {
        sessionId: string;
        timestamp: number;
        handoverScore: number;
    };
    lastRunId?: string;
    primaryClient?: RuntimePrimaryClientSnapshot;
    tokenSummary?: RuntimeTokenSummarySnapshot;
    artifactOutcomeHistory?: ArtifactOutcomeHistoryMap;
}
export interface SessionBootstrapResult {
    depth?: BootstrapDepth;
    workspace?: {
        workspaceRoot: string;
        repoRoot: string;
        repoName: string;
        remoteUrl?: string;
        workspaceSource: WorkspaceContext['workspaceSource'];
        stateKey: string;
        notes: string[];
    };
    client?: RuntimePrimaryClientSnapshot;
    memoryRecall: {
        count: number;
        matches: string[];
    };
    memoryStats: ReturnType<MemoryEngine['getStats']>;
    memoryHealth?: {
        totalEntries: number;
        quarantined: number;
    };
    needsDeepBootstrap?: boolean;
    changedSinceLastSession?: {
        latestSessionId?: string;
        filesAccessed: string[];
        filesModified: string[];
        currentDirtyFiles: string[];
    };
    recommendedNextStep: 'nexus_orchestrate' | 'nexus_plan_execution';
    recommendedExecutionMode: RuntimeOrchestrationSnapshot['mode'];
    shortlist: {
        crews: string[];
        specialists: string[];
        skills: string[];
        workflows: string[];
        hooks: string[];
        automations: string[];
    };
    tokenOptimization: {
        required: boolean;
        reason: string;
        candidateFiles: string[];
        autoApplied?: boolean;
        estimatedSavings?: number;
        source?: string;
        plan?: string;
        planMetrics?: {
            files: number;
            savings: number;
            compressedTokens: number;
            originalTokens: number;
            pct?: number;
        };
        policy?: {
            feature: string;
            enabled: boolean;
            reason: string;
            contextHash: string;
        };
    };
    sessionSummaryBootstrap?: {
        summary: string;
        summaryTokens: number;
        originalTokens: number;
        savedTokens: number;
    };
    projectMemoryBootstrap?: {
        count: number;
        matches: string[];
    };
    reviewGates: string[];
    catalogHealth: RuntimeCatalogHealthSnapshot;
    sourceMixRecommendation: {
        dominantSource: string;
        reasons: string[];
    };
    ragCandidateStatus: {
        attachedCollections: number;
        retrievedChunks: number;
        selectedChunks: number;
        droppedChunks: number;
        attachedNames: string[];
    };
    clientBootstrapStatus?: BootstrapManifestStatus;
    artifactSelectionAudit: RuntimeArtifactSelectionAudit;
    taskGraphPreview: RuntimeTaskGraphSnapshot;
    workerPlanPreview: RuntimeWorkerPlanSnapshot;
    knowledgeFabric: {
        summary: string;
        dominantSource: string;
        attachedCollections: string[];
        patternHits: string[];
        selectedFiles: string[];
        modelTiers: string[];
    };
    autoGhostPass?: {
        applied: boolean;
        riskAreas: string[];
        workerApproaches: number;
        estimatedTokens: number;
        policy: {
            feature: string;
            enabled: boolean;
            reason: string;
            contextHash: string;
        };
    };
    repoTree?: RepoTreeNode;
    candidateFilesDropped?: string[];
}
export interface CatalogItem {
    id: string;
    name: string;
    body: string;
    catalogOrigin?: string;
    catalogPath?: string;
    catalogPriority?: number;
}
export interface CatalogCacheEntry {
    signature: string;
    items: CatalogItem[];
}
export interface ResolvedSelections {
    crew?: string;
    specialists: string[];
    skills: string[];
    workflows: string[];
    hooks: string[];
    automations: string[];
    audit: RuntimeArtifactSelectionAudit;
}
export interface PreparedExecution {
    workspace: SessionBootstrapResult['workspace'];
    intent: AutonomyIntent;
    phases: string[];
    primaryClient?: RuntimePrimaryClientSnapshot;
    bootstrapManifest: BootstrapManifestStatus;
    latestDNA?: ReturnType<typeof SessionDNAManager.loadLatest>;
    memoryMatches: string[];
    memoryStats: ReturnType<MemoryEngine['getStats']>;
    candidateFiles: string[];
    candidateFilesDropped: string[];
    crSignals: Map<string, number>;
    knowledgeFabric: KnowledgeFabricBundle;
    plannedFiles: string[];
    planner: Awaited<ReturnType<SubAgentRuntime['planExecution']>>;
    selections: ResolvedSelections;
    catalogHealth: RuntimeCatalogHealthSnapshot;
    tokenBudget: RuntimeSourceAwareTokenBudgetSnapshot;
    workerCount: number;
    mode: RuntimeOrchestrationSnapshot['mode'];
    taskGraph: RuntimeTaskGraphSnapshot;
    workerPlan: RuntimeWorkerPlanSnapshot;
    autoGhostPass?: GhostReport;
    autoGhostPassDecision?: {
        feature: string;
        enabled: boolean;
        reason: string;
        contextHash: string;
    };
}
export interface OrchestratorOptions {
    memory?: MemoryEngine;
    runtime?: SubAgentRuntime;
    clientRegistry?: ClientRegistry;
    sessionDNA?: SessionDNAManager;
    repoRoot?: string;
}
export interface RepoSearchManifest {
    version: 1;
    files: Record<string, {
        mtimeMs: number;
        size: number;
        tokens?: string[];
    }>;
}
export declare const MAX_AUTONOMY_HISTORY = 24;
export declare const MAX_DISCOVERED_FILES = 32;
export declare const ABSOLUTE_SECONDARY_MIN = 0.3;
export declare const DISCOVERY_EXTENSIONS: Set<string>;
export declare const DISCOVERY_IGNORES: Set<string>;
export declare const DISCOVERY_FILENAME_SKIPS: Set<string>;
export declare const DISCOVERY_BINARY_EXTENSIONS: Set<string>;
export declare const REPO_SEARCH_HEAD_BYTES = 2000;
/** Default per-file byte cap for the ngram indexer. Override with
 *  NEXUS_NGRAM_MAX_FILE_BYTES. Files above this are skipped (not truncated). */
export declare const DISCOVERY_DEFAULT_MAX_FILE_BYTES = 256000;
