import type { MemoryStats } from './memory.js';
import type { KnowledgeFabricBundle, ModelTierTrace, SourceMixDecision } from './knowledge-fabric.js';
import type { RuntimePrimaryClientSnapshot, RuntimeFederationUsageSnapshot } from './runtime-registry.js';
import type { SelectedCrew, SelectedSpecialist } from './specialist-roster.js';
import type { SkillArtifact } from './skill-runtime.js';
import type { WorkflowArtifact } from './workflow-runtime.js';
import type { HookArtifact } from './hook-runtime.js';
import type { AutomationArtifact } from './automation-runtime.js';
export type OrchestrationExecutionMode = 'autonomous' | 'manual-low-level';
export type ExecutionLedgerStepStatus = 'pending' | 'completed' | 'skipped' | 'blocked' | 'failed';
export type ExecutionLedgerStepId = 'identify-client-session' | 'recall-memory' | 'memory-stats' | 'planner-selection' | 'catalog-shortlist' | 'candidate-file-discovery' | 'knowledge-fabric' | 'token-optimization' | 'governance-preflight' | 'compile-instruction-packet' | 'runtime-execution' | 'structured-learning';
export interface ExecutionLedgerStep {
    id: ExecutionLedgerStepId;
    label: string;
    status: ExecutionLedgerStepStatus;
    updatedAt: number;
    reason?: string;
    summary?: string;
    details?: Record<string, unknown>;
}
export interface ExecutionLedger {
    sessionId: string;
    runId?: string;
    task: string;
    executionMode: OrchestrationExecutionMode;
    clientId?: string;
    clientFamily?: string;
    plannerApplied: boolean;
    tokenOptimizationApplied: boolean;
    steps: ExecutionLedgerStep[];
    packetHash?: string;
    lastUpdatedAt: number;
}
export interface PacketSelection {
    id: string;
    name: string;
    summary?: string;
}
export interface TokenPolicySnapshot {
    applied: boolean;
    reason: string;
    candidateFiles: string[];
    selectedFiles: string[];
    estimatedSavings: number;
    estimatedCompressionPct: number;
    codeBlockTemplates?: string[];
    codeBlockReservedTokens?: number;
}
export interface GovernanceSnapshot {
    passed: boolean;
    score: number;
    violations: string[];
    suggestions: string[];
}
export interface InstructionPacket {
    session: {
        runtimeId: string;
        sessionId: string;
        objectiveHistory: string[];
        phases: string[];
    };
    client?: {
        clientId: string;
        family: string;
        displayName: string;
        state: string;
        source: string;
    };
    task: {
        goal: string;
        executionMode: OrchestrationExecutionMode;
        manualOverrides: string[];
    };
    operatingRule: string;
    requiredSequence: string[];
    selectedCrew?: PacketSelection;
    selectedSpecialists: PacketSelection[];
    selectedSkills: PacketSelection[];
    selectedWorkflows: PacketSelection[];
    selectedHooks: PacketSelection[];
    selectedAutomations: PacketSelection[];
    governance: GovernanceSnapshot;
    federation: {
        activePeerLinks: number;
        knownPeers: number;
        tracesPublished: number;
        relayConfigured: boolean;
        relayMode: string;
        relayLastError?: string;
    };
    tokenPolicy: TokenPolicySnapshot;
    codeQualityBlocks: Array<{
        id: string;
        title: string;
        language: string;
        purpose: string;
        content: string;
    }>;
    memoryContext: {
        matches: string[];
        stats?: Pick<MemoryStats, 'prefrontal' | 'hippocampus' | 'cortex' | 'totalLinks'>;
    };
    manualOverrides: string[];
    catalogShortlist: {
        skills: string[];
        workflows: string[];
        hooks: string[];
        automations: string[];
        specialists: string[];
        crews: string[];
    };
    knowledgeFabric?: {
        summary: string;
        dominantSource: string;
        sourceMix: SourceMixDecision;
        attachedCollections: Array<{
            collectionId: string;
            name: string;
        }>;
        patternHits: Array<{
            patternId: string;
            name: string;
            score: number;
        }>;
        modelTierTrace: ModelTierTrace[];
    };
    protocol: {
        sources: string[];
        sections: Array<{
            source: string;
            heading: string;
            content: string;
        }>;
        markdown: string;
    };
    estimatedTokens: number;
    packetHash: string;
}
export interface ClientInstructionEnvelope {
    clientFamily: string;
    format: 'markdown' | 'skill-md' | 'mdc' | 'windsurfrules';
    packetHash: string;
    content: string;
}
export interface ClientBootstrapArtifact {
    fileName: string;
    format: ClientInstructionEnvelope['format'];
    content: string;
}
export interface ClientBootstrapBundle {
    clientId: string;
    clientFamily: string;
    packetHash: string;
    estimatedTokens: number;
    artifacts: ClientBootstrapArtifact[];
}
export interface PacketCompileInput {
    runtimeId: string;
    sessionId: string;
    goal: string;
    executionMode: OrchestrationExecutionMode;
    packetTokenLimit?: number;
    manualOverrides?: string[];
    objectiveHistory?: string[];
    phases?: string[];
    requiredSequence?: string[];
    client?: RuntimePrimaryClientSnapshot;
    selectedCrew?: SelectedCrew;
    selectedSpecialists?: SelectedSpecialist[];
    selectedSkills?: SkillArtifact[];
    selectedWorkflows?: WorkflowArtifact[];
    selectedHooks?: HookArtifact[];
    selectedAutomations?: AutomationArtifact[];
    catalogShortlist?: Partial<InstructionPacket['catalogShortlist']>;
    governance?: GovernanceSnapshot;
    federation?: RuntimeFederationUsageSnapshot;
    tokenPolicy?: Partial<TokenPolicySnapshot>;
    memoryMatches?: string[];
    memoryStats?: MemoryStats;
    knowledgeFabric?: KnowledgeFabricBundle;
}
export declare const PACKET_TOKEN_LIMIT = 3500;
export declare const CLIENT_BOOTSTRAP_TOKEN_LIMITS: Record<string, number>;
export declare const DEFAULT_REQUIRED_SEQUENCE: string[];
export declare const CLIENT_BOOTSTRAP_SEQUENCE: string[];
export declare function estimateInstructionTokens(value: string): number;
export declare function createExecutionLedger(input: {
    sessionId: string;
    task: string;
    executionMode: OrchestrationExecutionMode;
    clientId?: string;
    clientFamily?: string;
}): ExecutionLedger;
export declare function markExecutionLedgerStep(ledger: ExecutionLedger, stepId: ExecutionLedgerStepId, status: ExecutionLedgerStepStatus, patch?: {
    reason?: string;
    summary?: string;
    details?: Record<string, unknown>;
}): ExecutionLedger;
export declare class InstructionGateway {
    private readonly repoRoot;
    private readonly packetsDir;
    constructor(repoRoot?: string, stateRoot?: string);
    compile(input: PacketCompileInput): InstructionPacket;
    persist(packet: InstructionPacket, repoRoot?: string): {
        stateJsonPath: string;
        stateMarkdownPath: string;
        workspaceJsonPath?: string;
        workspaceMarkdownPath?: string;
    };
    renderEnvelope(packet: InstructionPacket, clientId?: string): ClientInstructionEnvelope;
    renderClientBootstrapBundle(clientId: string, options?: {
        toolProfile?: 'autonomous' | 'full';
        goal?: string;
    }): ClientBootstrapBundle;
    private selectProtocolSections;
    private toClientFamily;
    private displayNameForClient;
    private renderBootstrapArtifacts;
    private chunkContent;
    private renderCompactCodexBootstrap;
}
export declare function renderInstructionPacketMarkdown(packet: InstructionPacket): string;
