import type { LoadedConfig } from "./config.js";
import { resolveEffectiveMcpPackState } from "./mcp-pack-selection.js";
import type { ExecutionPlanState } from "./execution-plan.js";
import { type ExecutionStateRecord } from "./execution-state.js";
import { type RuntimeDerivedOutputStatus, type RuntimeDecision, type RuntimeExecutionEvent, type RuntimeIdentity } from "../runtime/client.js";
import { type RepoReadiness } from "./repo-readiness.js";
import { listSpecialists } from "./specialists.js";
import type { ValidationIssue } from "./validator.js";
import type { ContextTraceState, FileAnalysisEntry, SkippedPathEntry } from "./context-trace.js";
import type { RuntimeLifecycleState } from "./runtime-lifecycle.js";
import type { EcosystemCatalog } from "../integrations/ecosystem-catalog.js";
import { loadMachineAdvisory } from "../integrations/machine-advisory.js";
import type { MachineAdvisoryState } from "../integrations/machine-advisory.js";
import type { MachineParitySummaryState } from "../integrations/machine-parity.js";
import type { SkillMatch } from "./skills-registry.js";
import type { TokenBreakdownState } from "./token-estimator.js";
import type { MeasuredUsageState } from "./token-intelligence.js";
import type { NextAction } from "./next-action.js";
import { type RepoIntelligenceSummary } from "./repo-intelligence.js";
import { type ReadyRepoSubstrateState } from "./ready-substrate.js";
import type { WorkflowState } from "./workflow-engine.js";
export interface RepoControlPanelItem {
    label: string;
    value: string;
    tone?: "default" | "warn";
}
export interface RepoMemoryBankEntry {
    label: string;
    path: string;
    present: boolean;
}
export interface RepoValidationSummary {
    ok: boolean;
    errors: number;
    warnings: number;
    issues: ValidationIssue[];
}
export type RepoControlMode = "bridge-unavailable" | "repo-not-initialized" | "initialized-invalid" | "initialized-with-warnings" | "healthy";
export interface RepoControlStatus {
    mode: RepoControlMode;
    title: string;
    detail: string;
    sourceOfTruthNote: string;
}
export interface RepoControlLoadState {
    source: "fresh" | "warm-snapshot" | "stale-snapshot";
    freshness: "fresh" | "warm" | "stale";
    generatedAt: string;
    snapshotSavedAt: string | null;
    snapshotAgeMs: number | null;
    detail: string;
}
export interface RepoControlExecutionState {
    revision: number;
    operationId: string | null;
    task: string | null;
    sourceCommand: string | null;
    lifecycle: ExecutionStateRecord["lifecycle"];
    reason: string | null;
    nextCommand: string | null;
    blockedBy: string[];
    lastUpdatedAt: string | null;
    artifacts: ExecutionStateRecord["artifacts"];
    lastEvent: ExecutionStateRecord["lastEvent"];
}
export interface KiwiControlContextView {
    task: string | null;
    selectedFiles: string[];
    excludedPatterns: string[];
    reason: string | null;
    confidence: string | null;
    confidenceDetail: string | null;
    keywordMatches: string[];
    tree: KiwiControlContextTree;
    timestamp: string | null;
}
export type KiwiControlContextTreeStatus = "selected" | "candidate" | "excluded";
export interface KiwiControlContextTreeNode {
    name: string;
    path: string;
    kind: "directory" | "file";
    status: KiwiControlContextTreeStatus;
    expanded: boolean;
    children: KiwiControlContextTreeNode[];
}
export interface KiwiControlContextTree {
    nodes: KiwiControlContextTreeNode[];
    selectedCount: number;
    candidateCount: number;
    excludedCount: number;
}
export interface KiwiControlTokenAnalytics {
    selectedTokens: number;
    fullRepoTokens: number;
    savingsPercent: number;
    fileCountSelected: number;
    fileCountTotal: number;
    estimationMethod: string | null;
    estimateNote: string | null;
    topDirectories: Array<{
        directory: string;
        tokens: number;
        fileCount: number;
    }>;
    task: string | null;
    timestamp: string | null;
}
export interface KiwiControlEfficiency {
    instructionsGenerated: boolean;
    instructionsPath: string | null;
}
export interface KiwiControlNextActions {
    actions: Array<{
        action: string;
        file: string | null;
        command: string | null;
        reason: string;
        priority: "critical" | "high" | "normal" | "low";
    }>;
    summary: string;
}
export interface KiwiControlFeedback {
    totalRuns: number;
    successRate: number;
    adaptationLevel: "limited" | "active";
    note: string;
    basedOnPastRuns: boolean;
    reusedPattern: string | null;
    similarTasks: Array<{
        task: string;
        similarity: number;
        timestamp: string;
    }>;
    recentEntries: Array<{
        task: string;
        success: boolean;
        filesSelected: number;
        filesUsed: number;
        filesWasted: number;
        timestamp: string;
    }>;
    topBoostedFiles: Array<{
        file: string;
        score: number;
    }>;
    topPenalizedFiles: Array<{
        file: string;
        score: number;
    }>;
}
export interface KiwiControlExecution {
    totalExecutions: number;
    totalTokensUsed: number;
    averageTokensPerRun: number;
    successRate: number;
    recentExecutions: Array<{
        task: string;
        success: boolean;
        tokensUsed: number;
        filesTouched: number;
        tool: string | null;
        timestamp: string;
    }>;
    tokenTrend: "improving" | "stable" | "worsening" | "insufficient-data";
}
export interface KiwiControlWastedFiles {
    files: Array<{
        file: string;
        tokens: number;
        reason: string;
    }>;
    totalWastedTokens: number;
    removalSavingsPercent: number;
}
export interface KiwiControlHeavyDirectories {
    directories: Array<{
        directory: string;
        tokens: number;
        fileCount: number;
        percentOfRepo: number;
        suggestion: string;
    }>;
}
export interface KiwiControlIndexing {
    totalFiles: number;
    observedFiles: number;
    selectedFiles: number;
    candidateFiles: number;
    excludedFiles: number;
    discoveredFiles: number;
    analyzedFiles: number;
    skippedFiles: number;
    skippedDirectories: number;
    visitedDirectories: number;
    maxDepthExplored: number;
    fileBudgetReached: boolean;
    directoryBudgetReached: boolean;
    partialScan: boolean;
    ignoreRulesApplied: string[];
    skipped: SkippedPathEntry[];
    indexedFiles: number;
    indexUpdatedFiles: number;
    indexReusedFiles: number;
    impactFiles: number;
    changedSignals: number;
    keywordSignals: number;
    importSignals: number;
    repoContextSignals: number;
    scopeArea: string | null;
    coverageNote: string;
    selectionReason: string | null;
}
export interface KiwiControlFileAnalysis {
    totalFiles: number;
    scannedFiles: number;
    skippedFiles: number;
    selectedFiles: number;
    excludedFiles: number;
    selected: FileAnalysisEntry[];
    excluded: FileAnalysisEntry[];
    skipped: SkippedPathEntry[];
}
export interface KiwiControlContextTrace {
    initialSignals: ContextTraceState["initialSignals"];
    expansionSteps: ContextTraceState["expansionSteps"];
    honesty: ContextTraceState["honesty"];
}
export interface KiwiControlTokenBreakdown {
    partialScan: boolean;
    categories: TokenBreakdownState["categories"];
}
export interface KiwiControlDecisionLogic {
    summary: string;
    decisionPriority: NextAction["priority"];
    inputSignals: string[];
    reasoningChain: string[];
    ignoredSignals: string[];
}
export interface KiwiControlRuntimeLifecycle {
    currentTask: string | null;
    currentStage: string;
    validationStatus: "ok" | "warn" | "error" | null;
    nextSuggestedCommand: string | null;
    nextRecommendedAction: string | null;
    recentEvents: RuntimeLifecycleState["recentEvents"];
}
export interface KiwiControlExecutionEvents {
    source: "runtime" | "compatibility" | "unavailable";
    latestRevision: number | null;
    recentEvents: RuntimeExecutionEvent[];
}
export interface KiwiControlMeasuredUsage {
    available: boolean;
    source: MeasuredUsageState["source"];
    totalTokens: number;
    totalRuns: number;
    runs: MeasuredUsageState["runs"];
    workflows: MeasuredUsageState["workflows"];
    files: MeasuredUsageState["files"];
    note: string;
}
export interface KiwiControlSkills {
    activeSkills: SkillMatch[];
    suggestedSkills: SkillMatch[];
    totalSkills: number;
}
export interface KiwiControlWorkflow {
    task: string | null;
    status: WorkflowState["status"];
    currentStepId: string | null;
    steps: WorkflowState["steps"];
}
export interface KiwiControlExecutionTrace {
    steps: Array<{
        stepId: string;
        action: string;
        status: string;
        expectedOutput: string | null;
        files: string[];
        skillsApplied: string[];
        attemptCount: number;
        retryCount: number;
        tokenUsage: {
            source: string;
            measuredTokens: number | null;
            estimatedTokens: number | null;
            note: string;
        };
        result: WorkflowState["steps"][number]["result"];
        output: string | null;
        validation: string | null;
        failureReason: string | null;
        updatedAt: string | null;
    }>;
    whyThisHappened: string;
}
export interface KiwiControlExecutionPlan {
    summary: string;
    intent: ExecutionPlanState["intent"];
    hierarchy: ExecutionPlanState["hierarchy"];
    state: ExecutionPlanState["state"];
    currentStepIndex: number;
    confidence: string | null;
    risk: ExecutionPlanState["risk"];
    blocked: boolean;
    steps: ExecutionPlanState["steps"];
    nextCommands: string[];
    lastError: ExecutionPlanState["lastError"];
    impactPreview: ExecutionPlanState["impactPreview"];
    verificationLayers: ExecutionPlanState["verificationLayers"];
    partialResults: ExecutionPlanState["partialResults"];
}
export interface KiwiControlRepoIntelligence extends RepoIntelligenceSummary {
}
export interface KiwiControlState {
    contextView: KiwiControlContextView;
    tokenAnalytics: KiwiControlTokenAnalytics;
    efficiency: KiwiControlEfficiency;
    nextActions: KiwiControlNextActions;
    feedback: KiwiControlFeedback;
    execution: KiwiControlExecution;
    wastedFiles: KiwiControlWastedFiles;
    heavyDirectories: KiwiControlHeavyDirectories;
    indexing: KiwiControlIndexing;
    fileAnalysis: KiwiControlFileAnalysis;
    contextTrace: KiwiControlContextTrace;
    tokenBreakdown: KiwiControlTokenBreakdown;
    decisionLogic: KiwiControlDecisionLogic;
    runtimeLifecycle: KiwiControlRuntimeLifecycle;
    executionEvents: KiwiControlExecutionEvents;
    measuredUsage: KiwiControlMeasuredUsage;
    skills: KiwiControlSkills;
    workflow: KiwiControlWorkflow;
    executionTrace: KiwiControlExecutionTrace;
    executionPlan: KiwiControlExecutionPlan;
    repoIntelligence: KiwiControlRepoIntelligence;
    readySubstrate: ReadyRepoSubstrateState;
}
export interface RepoControlState {
    targetRoot: string;
    loadState: RepoControlLoadState;
    profileName: string;
    executionMode: string;
    projectType: string;
    repoState: RepoControlStatus;
    executionState: RepoControlExecutionState;
    readiness: RepoReadiness;
    runtimeIdentity: RuntimeIdentity | null;
    derivedFreshness: RuntimeDerivedOutputStatus[];
    runtimeDecision: RuntimeDecision;
    repoOverview: RepoControlPanelItem[];
    continuity: RepoControlPanelItem[];
    memoryBank: RepoMemoryBankEntry[];
    specialists: {
        activeSpecialist: string;
        recommendedSpecialist: string;
        available: ReturnType<typeof listSpecialists>;
        activeProfile: ReturnType<typeof listSpecialists>[number] | null;
        recommendedProfile: ReturnType<typeof listSpecialists>[number] | null;
        handoffTargets: string[];
        safeParallelHint: string;
    };
    mcpPacks: {
        selectedPack: Awaited<ReturnType<typeof resolveEffectiveMcpPackState>>["selectedPack"];
        selectedPackSource: Awaited<ReturnType<typeof resolveEffectiveMcpPackState>>["selectedPackSource"];
        explicitSelection: string | null;
        suggestedPack: Awaited<ReturnType<typeof resolveEffectiveMcpPackState>>["suggestedPack"];
        available: Awaited<ReturnType<typeof resolveEffectiveMcpPackState>>["availablePacks"];
        compatibleCapabilities: Awaited<ReturnType<typeof resolveEffectiveMcpPackState>>["effectiveCapabilities"];
        effectiveCapabilityIds: string[];
        preferredCapabilityIds: string[];
        executable: boolean;
        unavailablePackReason: string | null;
        capabilityStatus: "compatible" | "limited" | "blocked";
        note: string;
    };
    validation: RepoValidationSummary;
    ecosystem: EcosystemCatalog;
    machineAdvisory: MachineAdvisoryState;
    machineParity: MachineParitySummaryState;
    kiwiControl: KiwiControlState;
}
interface RepoControlSnapshotArtifact {
    artifactType: "kiwi-control/repo-control-snapshot";
    version: 1;
    savedAt: string;
    state: RepoControlState;
}
export declare function loadWarmRepoControlSnapshot(targetRoot: string, options?: {
    warmMaxAgeMs?: number;
    staleMaxAgeMs?: number;
}): Promise<RepoControlState | null>;
export declare function persistRepoControlSnapshot(targetRoot: string, state: RepoControlState): Promise<string>;
export declare function buildRepoControlSnapshotArtifact(state: RepoControlState, savedAt?: string): RepoControlSnapshotArtifact;
export declare function buildRepoControlState(options: {
    repoRoot: string;
    targetRoot: string;
    profileName?: string;
    machineAdvisoryOptions?: Parameters<typeof loadMachineAdvisory>[0];
    preferSnapshot?: boolean;
    readOnly?: boolean;
}): Promise<RepoControlState>;
export declare function buildRepoControlStateFromConfig(options: {
    config: LoadedConfig;
    repoRoot: string;
    targetRoot: string;
    profileName?: string;
    machineAdvisoryOptions?: Parameters<typeof loadMachineAdvisory>[0];
    readOnly?: boolean;
}): Promise<RepoControlState>;
export {};
//# sourceMappingURL=ui-state.d.ts.map