import type { KnowledgeFabricSnapshot } from './knowledge-fabric.js';
import type { BootstrapManifestStatus } from './client-bootstrap.js';
import type { WorktreeHealthSnapshot } from './worktree-health.js';
import type { ExecutionLedger, InstructionPacket, OrchestrationExecutionMode } from './instruction-gateway.js';
export type RuntimeUsageCategory = 'memories' | 'skills' | 'roster' | 'crews' | 'plan' | 'workflows' | 'hooks' | 'automations' | 'governance' | 'federation';
export interface RuntimeUsageEntry {
    status: 'unused' | 'used';
    lastUsedAt?: number;
    summary?: string;
    details?: string[];
    count?: number;
}
export interface RuntimeLibrariesSnapshot {
    skills: number;
    workflows: number;
    hooks: number;
    automations: number;
    specialists: number;
    crews: number;
}
export interface RuntimeRelaySnapshot {
    configured: boolean;
    mode: 'live' | 'degraded';
    lastError?: string;
    lastSyncAt?: number;
    lastPublishAt?: number;
}
export interface RuntimeFederationUsageSnapshot {
    activePeerLinks: number;
    knownPeers: number;
    tracesPublished: number;
    relay: RuntimeRelaySnapshot;
}
export interface RuntimeLatestRunSnapshot {
    runId: string;
    goal: string;
    state: string;
    updatedAt: number;
}
export interface RuntimeTokenRunSnapshot {
    runId: string;
    goal: string;
    timestamp: number;
    grossInputTokens: number;
    compressedTokens: number;
    savedTokens: number;
    forwardedTokens: number;
    compressionPct: number;
    byPhase: Record<string, number>;
    bySubsystem: Record<string, number>;
    bySourceClass: Record<string, number>;
}
export interface RuntimeTokenSummarySnapshot {
    grossInputTokens: number;
    compressedTokens: number;
    savedTokens: number;
    forwardedTokens: number;
    compressionPct: number;
    totalRuns: number;
    totalEvents: number;
    byPhase: Record<string, number>;
    bySubsystem: Record<string, number>;
    bySourceClass: Record<string, number>;
    timeline: RuntimeTokenRunSnapshot[];
    lastUpdatedAt?: number;
}
export interface RuntimeOrchestrationSnapshot {
    sessionId: string;
    lastPrompt: string;
    taskType: string;
    riskClass: string;
    mode: 'single-pass' | 'bounded-swarm' | 'continuation-capable';
    phases: string[];
    objectiveHistory: string[];
    selectedCrew?: string;
    selectedSpecialists: string[];
    selectedSkills: string[];
    selectedWorkflows: string[];
    selectedHooks: string[];
    selectedAutomations: string[];
    repeatedFailures: number;
    continuationDepth: number;
    latestSessionDNA?: {
        sessionId: string;
        timestamp: number;
        handoverScore: number;
    };
    lastUpdatedAt: number;
}
export interface RuntimePrimaryClientSnapshot {
    clientId: string;
    clientFamily?: string;
    displayName: string;
    state: 'primaryActive' | 'active' | 'idle' | 'installed' | 'offline';
    source: string;
    confidence: number;
    evidence: string[];
    lastSeen?: number;
}
export interface RuntimeClientsSnapshot {
    primary?: RuntimePrimaryClientSnapshot;
    detected: RuntimePrimaryClientSnapshot[];
    lastUpdatedAt: number;
}
export interface RuntimeSequenceComplianceSnapshot {
    status: 'idle' | 'partial' | 'compliant' | 'manual-low-level';
    summary: string;
    updatedAt: number;
}
export interface RuntimeClientInstructionStatus {
    clientId?: string;
    clientFamily?: string;
    toolProfile: 'autonomous' | 'full';
    status: 'guided' | 'manual';
    summary: string;
    instructionFiles?: string[];
    updatedAt: number;
}
export interface RuntimeCatalogHealthEntry {
    available: number;
    usable: number;
    selected: number;
    rejected: number;
    readable: boolean;
    localDirectory?: string;
    localDirectories?: string[];
    localOverrideFiles?: number;
    issues: string[];
}
export interface RuntimeCatalogHealthSnapshot {
    scannedAt: number;
    overall: 'healthy' | 'warning' | 'degraded';
    issues: string[];
    categories: {
        skills: RuntimeCatalogHealthEntry;
        workflows: RuntimeCatalogHealthEntry;
        hooks: RuntimeCatalogHealthEntry;
        automations: RuntimeCatalogHealthEntry;
        specialists: RuntimeCatalogHealthEntry;
        crews: RuntimeCatalogHealthEntry;
    };
}
export interface RuntimeArtifactSelectionEntry {
    kind: 'skill' | 'workflow' | 'hook' | 'automation' | 'specialist' | 'crew';
    id: string;
    name: string;
    selected: boolean;
    score: number;
    source: 'explicit' | 'planner' | 'knowledge-fabric' | 'runtime-resolver' | 'scorer';
    confidence: 'high' | 'medium' | 'low';
    authorityTier?: 'memory-file-priors' | 'patterns' | 'specialists-crews' | 'skills' | 'workflows' | 'hooks' | 'automations';
    selectionPolicy?: 'explicit-only' | 'global-first';
    blockedReason?: string;
    artifactClass?: 'engineering-core' | 'operator-layer' | 'general' | 'out-of-domain';
    memoryClass?: 'scratch' | 'session_learning' | 'project_fact' | 'reusable_pattern';
    freshness?: 'hot' | 'warm' | 'cold' | 'stale';
    promotionReason?: string;
    lastVerificationResult?: 'verified' | 'mixed' | 'failed' | 'none';
    catalogOrigin?: string;
    catalogPath?: string;
    catalogPriority?: number;
    reason: string;
}
export interface RuntimeArtifactSelectionAudit {
    generatedAt: number;
    summary: string;
    selected: RuntimeArtifactSelectionEntry[];
    rejected: RuntimeArtifactSelectionEntry[];
}
export interface RuntimeMemoryHealthSnapshot {
    generatedAt: number;
    schemaVersion: number;
    total: number;
    active: number;
    quarantined: number;
    scrap: number;
    expired: number;
    promoted: number;
    shared: number;
    purgeEligible: number;
    quarantineBacklog: number;
    lastHygieneAt: number | null;
    topTags: string[];
}
export interface RuntimeSourceAwareTokenBudgetSnapshot {
    applied: boolean;
    reason: string;
    totalBudget: number;
    bySource: Record<string, number>;
    byStage: Record<string, number>;
    dropped: Array<{
        sourceClass: string;
        label: string;
        reason: string;
    }>;
    dominantSource?: string;
    codeBlocks?: {
        requested: boolean;
        detectedBlocks: number;
        reservedTokens: number;
        templates: string[];
        languages: string[];
    };
    qualityGates?: string[];
    recommendations?: string[];
}
export interface RuntimeTaskGraphPhase {
    id: string;
    title: string;
    goal: string;
    kind: 'research' | 'plan' | 'implement' | 'verify' | 'release';
    branch: number;
    dependsOn: string[];
}
export interface RuntimeTaskGraphSnapshot {
    generatedAt: number;
    summary: string;
    branchCount: number;
    independentBranches: number;
    dominantKind: RuntimeTaskGraphPhase['kind'];
    phases: RuntimeTaskGraphPhase[];
}
export interface RuntimeWorkerPlanLane {
    role: 'planner' | 'coder' | 'researcher' | 'integrator' | 'reviewer' | 'continuation';
    count: number;
    reason: string;
}
export interface RuntimeWorkerPlanSnapshot {
    generatedAt: number;
    mode: RuntimeOrchestrationSnapshot['mode'];
    totalWorkers: number;
    continuationAllowed: boolean;
    summary: string;
    lanes: RuntimeWorkerPlanLane[];
}
export interface RuntimeArtifactOutcomeEntry {
    kind: RuntimeArtifactSelectionEntry['kind'];
    id: string;
    name: string;
    outcome: 'helpful' | 'neutral' | 'redundant' | 'harmful';
    score: number;
    reason: string;
}
export interface RuntimeArtifactOutcomeSnapshot {
    generatedAt: number;
    summary: string;
    outcomes: RuntimeArtifactOutcomeEntry[];
}
export interface RuntimeRagUsageSummary {
    generatedAt: number;
    attachedCollections: number;
    attachedNames: string[];
    retrievedChunks: number;
    selectedChunks: number;
    droppedChunks: number;
    dominantSource?: string;
    usedInPlanner: boolean;
    usedInPacket: boolean;
    usedInRuntime: boolean;
}
export interface RuntimeMemoryScopeUsageSnapshot {
    generatedAt: number;
    byScope: Record<string, number>;
    byState: Record<string, number>;
    byLayer: Record<'working' | 'session' | 'project' | 'pattern', number>;
    sharedContextCount: number;
    contract: Record<string, {
        id: string;
        description: string;
        scopes: string[];
        preferredTiers: string[];
        lanes: string[];
        rawEvidenceRetained: true;
        auditTrail: {
            snapshots: true;
            history: true;
            provenance: true;
        };
    }>;
}
export type MemoryReconciliationAction = 'ADD' | 'UPDATE' | 'MERGE' | 'DELETE' | 'NONE' | 'QUARANTINE';
export interface RuntimeMemoryReconciliationEntry {
    candidate: string;
    action: MemoryReconciliationAction;
    reason: string;
    relatedIds: string[];
    storedId?: string;
    expiresAt?: number;
}
export interface RuntimeMemoryReconciliationSummary {
    generatedAt: number;
    actionCounts: Record<MemoryReconciliationAction, number>;
    entries: RuntimeMemoryReconciliationEntry[];
}
export interface RuntimeRepoIdentitySnapshot {
    repoRoot: string;
    workspaceRoot: string;
    repoName: string;
    workspaceSource: string;
    workspaceStateKey: string;
    remoteUrl?: string;
}
export interface RuntimeRegistrySnapshot {
    runtimeId: string;
    pid: number;
    cwd: string;
    entrypoint: string;
    startedAt: number;
    lastHeartbeatAt: number;
    lastActivityAt: number;
    libraries: RuntimeLibrariesSnapshot;
    usage: Record<RuntimeUsageCategory, RuntimeUsageEntry>;
    latestRun?: RuntimeLatestRunSnapshot;
    federation?: RuntimeFederationUsageSnapshot;
    tokens?: RuntimeTokenSummarySnapshot;
    orchestration?: RuntimeOrchestrationSnapshot;
    knowledgeFabric?: KnowledgeFabricSnapshot;
    clients?: RuntimeClientsSnapshot;
    clientId?: string;
    clientFamily?: string;
    instructionPacketHash?: string;
    instructionPacket?: InstructionPacket;
    executionMode?: OrchestrationExecutionMode;
    executionLedger?: ExecutionLedger;
    plannerApplied?: boolean;
    tokenOptimizationApplied?: boolean;
    tokenAutoApplied?: boolean;
    bootstrapCalled?: boolean;
    orchestrateCalled?: boolean;
    plannerCalled?: boolean;
    skipReasons?: string[];
    lastToolCalls?: string[];
    sequenceCompliance?: RuntimeSequenceComplianceSnapshot;
    clientInstructionStatus?: RuntimeClientInstructionStatus;
    catalogHealth?: RuntimeCatalogHealthSnapshot;
    artifactSelectionAudit?: RuntimeArtifactSelectionAudit;
    artifactOutcome?: RuntimeArtifactOutcomeSnapshot;
    memoryHealth?: RuntimeMemoryHealthSnapshot;
    memoryScopeUsage?: RuntimeMemoryScopeUsageSnapshot;
    memoryReconciliationSummary?: RuntimeMemoryReconciliationSummary;
    repoIdentity?: RuntimeRepoIdentitySnapshot;
    bootstrapManifestStatus?: BootstrapManifestStatus;
    sourceAwareTokenBudget?: RuntimeSourceAwareTokenBudgetSnapshot;
    taskGraph?: RuntimeTaskGraphSnapshot;
    workerPlan?: RuntimeWorkerPlanSnapshot;
    ragUsageSummary?: RuntimeRagUsageSummary;
    worktreeHealth?: WorktreeHealthSnapshot;
}
export interface ListedRuntimeSnapshot extends RuntimeRegistrySnapshot {
    health: 'active' | 'stale';
}
export declare function createEmptyUsageState(): Record<RuntimeUsageCategory, RuntimeUsageEntry>;
export declare function createEmptyTokenSummary(): RuntimeTokenSummarySnapshot;
export declare function resolveNexusStateDir(): string;
export declare class RuntimeRegistry {
    private readonly registryDir;
    constructor(rootDir?: string);
    private ensureDir;
    list(): ListedRuntimeSnapshot[];
    read(runtimeId: string): RuntimeRegistrySnapshot | undefined;
    write(snapshot: RuntimeRegistrySnapshot): RuntimeRegistrySnapshot;
    remove(runtimeId: string): void;
    pruneStalePublic(): void;
    private pruneStale;
    private snapshotPath;
}
