import Anthropic from '@anthropic-ai/sdk';
import { c as AnthropicMessagesClient } from './types-DjPlsx0H.js';
import { C as CandidateEvent } from './types-GeEw7wzC.js';

type ErrorCategory = "transient" | "config" | "schema" | "tool-bug" | "model-limitation" | "prompt-issue";
type ErrorSeverity = "low" | "medium" | "high" | "critical";
type RolloutStage = "dev" | "staging" | "prod";
type RolloutStatus = "PENDING" | "IN_PROGRESS" | "COMPLETED" | "PAUSED" | "FAILED";
type FixProposalStatus = "DRAFT" | "APPROVED" | "REJECTED" | "DEPLOYED";
type EmergencePatternStatus = "DETECTED" | "PROPOSED" | "APPROVED" | "REJECTED" | "SHIPPED";
/** One error occurrence emitted by an agent deployment. */
interface ErrorEvent {
    id: string;
    operatorId: string;
    deploymentId: string;
    agentId: string;
    /** Normalised signature pattern, populated by ErrorAggregator after ingestion. */
    signatureId?: string;
    /** The tool, skill, or prompt component that produced the error. */
    sourceComponent?: string;
    /** Raw error message or exception text. */
    message: string;
    /** Stack trace or structured error payload, if available. */
    detail?: unknown;
    /** Brief summary of the conversation turn context, if safe to capture. */
    conversationContext?: string;
    category?: ErrorCategory;
    severity?: ErrorSeverity;
    occurredAt: Date;
    receivedAt: Date;
}
/** The canonical identity of a class of errors, after deduplication. */
interface ErrorSignature {
    id: string;
    /** Normalised message pattern — variable parts replaced with placeholders. */
    pattern: string;
    category: ErrorCategory;
    severity: ErrorSeverity;
    /** Source component or tool that consistently produces this error. */
    sourceComponent?: string;
    /** Total event count across all deployments. */
    occurrenceCount: number;
    /** Number of distinct deployments that have seen this error. */
    deploymentCount: number;
    /** Number of distinct operators that have seen this error. */
    operatorCount: number;
    firstSeenAt: Date;
    lastSeenAt: Date;
}
/**
 * A proposed fix for a recurring ErrorSignature.
 *
 * requiresApproval is always true — fixes are NEVER auto-deployed.
 * Consumers route through F0.6 Approval Flow before rollout.
 */
interface FixProposal {
    id: string;
    signatureId: string;
    /** Human-readable summary of the proposed fix. */
    summary: string;
    /** Code diff, config change, or prompt update as Markdown. */
    proposedChange: string;
    requiresApproval: true;
    status: FixProposalStatus;
    /** Confidence: 0.0–1.0 based on pattern recurrence and deployment breadth. */
    confidence: number;
    draftedAt: Date;
    approvedAt?: Date;
    deployedAt?: Date;
}
/** One conversation excerpt fed to CapabilityEmergenceDetector. */
interface ConversationExcerpt {
    deploymentId: string;
    operatorId: string;
    /** The user's turn that evidences an unmet capability need. */
    userMessage: string;
    /** The agent's response, truncated to the first 400 chars. Optional. */
    agentResponse?: string;
    occurredAt: Date;
}
/** A pattern where customers across deployments want a capability that doesn't exist. */
interface CapabilityEmergencePattern {
    id: string;
    /** Short label describing the emerging capability need. */
    capabilityLabel: string;
    /** Representative user messages that evidence this need. Capped at 10. */
    evidenceExcerpts: string[];
    /** How many distinct deployments this was detected across. */
    deploymentCount: number;
    /** Distinct operators that generated evidence. */
    operatorCount: number;
    /** Total event count supporting this pattern. */
    eventCount: number;
    /** Signal strength: 0.0–1.0. Higher = more deployments + more events. */
    confidence: number;
    status: EmergencePatternStatus;
    detectedAt: Date;
    lastUpdatedAt: Date;
}
/**
 * A recommended skill or sub-agent to build, backed by emergence signal.
 *
 * Produced by SkillRecommendationEngine. Consumers surface these to the
 * operator via F0.10 proactive surfacing for prioritisation decisions.
 */
interface SkillRecommendation {
    id: string;
    patternId: string;
    /** Proposed name for the new skill (kebab-case). */
    skillName: string;
    /** Rationale: what the skill does and why the demand signal is strong. */
    rationale: string;
    /** Composite demand score: eventCount × deploymentCount × confidence. */
    demandScore: number;
    /** Suggested agent-kit module path, e.g. "src/calendar-sync/". */
    suggestedModulePath?: string;
    rankedAt: Date;
}
/** One stage in a staged improvement rollout. */
interface RolloutStageRecord {
    stage: RolloutStage;
    status: RolloutStatus;
    targetDeploymentIds: string[];
    startedAt?: Date;
    completedAt?: Date;
    /** Brief telemetry summary from this stage (error rates, success counts). */
    telemetrySummary?: string;
}
/** Options for initiating an improvement rollout. */
interface RolloutOptions {
    /** Defaults to ["dev", "staging", "prod"]. */
    targetStages?: RolloutStage[];
}
/** An approved fix or capability being rolled out across the deployment fleet. */
interface ImprovementRollout {
    id: string;
    /** References either a FixProposal.id or CapabilityEmergencePattern.id. */
    improvementId: string;
    improvementType: "fix" | "capability";
    stages: RolloutStageRecord[];
    overallStatus: RolloutStatus;
    createdAt: Date;
    updatedAt: Date;
}
interface ErrorEventStore {
    append(event: ErrorEvent): Promise<void>;
    listBySignature(signatureId: string, limit?: number): Promise<ErrorEvent[]>;
    listRecent(deploymentId: string, since: Date): Promise<ErrorEvent[]>;
}
interface ErrorSignatureStore {
    get(id: string): Promise<ErrorSignature | null>;
    getByPattern(pattern: string): Promise<ErrorSignature | null>;
    upsert(sig: ErrorSignature): Promise<ErrorSignature>;
    /** Returns signatures sorted by occurrenceCount desc. */
    listByFrequency(minOccurrences?: number): Promise<ErrorSignature[]>;
}
interface FixProposalStore {
    create(proposal: Omit<FixProposal, "id" | "draftedAt">): Promise<FixProposal>;
    get(id: string): Promise<FixProposal | null>;
    update(id: string, patch: Partial<FixProposal>): Promise<FixProposal>;
    listPending(): Promise<FixProposal[]>;
    listBySignature(signatureId: string): Promise<FixProposal[]>;
}
interface EmergencePatternStore {
    create(pattern: Omit<CapabilityEmergencePattern, "id" | "detectedAt" | "lastUpdatedAt">): Promise<CapabilityEmergencePattern>;
    get(id: string): Promise<CapabilityEmergencePattern | null>;
    update(id: string, patch: Partial<CapabilityEmergencePattern>): Promise<CapabilityEmergencePattern>;
    /** Returns patterns sorted by confidence desc. */
    listByConfidence(minConfidence?: number): Promise<CapabilityEmergencePattern[]>;
}
interface RolloutStore {
    create(rollout: Omit<ImprovementRollout, "id" | "createdAt" | "updatedAt">): Promise<ImprovementRollout>;
    get(id: string): Promise<ImprovementRollout | null>;
    update(id: string, patch: Partial<ImprovementRollout>): Promise<ImprovementRollout>;
    listActive(): Promise<ImprovementRollout[]>;
}
/** The kind of failure captured by SubAgentErrorCapture. */
type CaptureKind = "tool_call" | "timeout" | "malformed_input" | "retry_exhaustion";
/** Arguments shared by every SubAgentErrorCapture entry point. */
interface CaptureContext {
    operatorId: string;
    deploymentId: string;
    agentId: string;
    /** Tool name, skill name, or prompt component that produced the error. */
    sourceComponent?: string;
    /** Brief summary of the conversation turn — kept short, safe-to-store. */
    conversationContext?: string;
}
/**
 * A condition extracted from conversation context that correlates with an
 * error pattern. Examples:
 *   { kind: "contains_emoji", value: "true" }
 *   { kind: "subject_length_bucket", value: ">200" }
 *   { kind: "attachment_present", value: "true" }
 *   { kind: "keyword", value: "calendar" }
 */
interface PatternCondition {
    kind: "contains_emoji" | "subject_length_bucket" | "message_length_bucket" | "attachment_present" | "keyword" | "non_ascii_chars";
    value: string;
}
/**
 * A contextual pattern — a recurring error pinned to one or more conditions
 * that distinguish failure cases from success cases. The strategic value
 * is "agent X's tool Y fails when condition Z is true".
 */
interface ContextualPattern {
    id: string;
    signatureId: string;
    /** Human-readable label: "Olive's draft_reply fails when subject contains emoji". */
    label: string;
    /** Conditions that co-occur with this failure. */
    conditions: PatternCondition[];
    /** Distinct agents that emitted the underlying signature. */
    affectedAgents: string[];
    /** Distinct deployments affected. */
    affectedDeployments: string[];
    /** Number of events supporting this pattern. */
    evidenceCount: number;
    /** Signal strength 0.0–1.0. Higher = more events × more conditions matched. */
    confidence: number;
    detectedAt: Date;
}
/** Strategy class that a FixRecommender suggests for a contextual pattern. */
type FixStrategy = "input_sanitisation" | "retry_strategy" | "alternative_tool_path" | "validation_guard" | "prompt_update" | "config_change";
/** A concrete, rule-derived fix recommendation for a contextual pattern. */
interface FixRecommendation {
    id: string;
    patternId: string;
    signatureId: string;
    strategy: FixStrategy;
    rationale: string;
    /** Suggested configuration block (JSON-encodable) — e.g. retry options. */
    suggestedConfig?: Record<string, unknown>;
    /** Confidence the strategy will resolve the pattern. */
    confidence: number;
    requiresApproval: true;
    recommendedAt: Date;
}
/** A prompt-update recommendation for an agent whose error pattern looks like a misunderstanding. */
interface PromptUpdateRecommendation {
    id: string;
    patternId: string;
    /** Agent whose system prompt should be updated. */
    agentId: string;
    /** Short summary of the misunderstanding the prompt update should address. */
    summary: string;
    /** Markdown text suggesting the prompt addition or rewording. */
    suggestedPromptDelta: string;
    confidence: number;
    requiresApproval: true;
    draftedAt: Date;
}
/** Categories of learning that can be shared or consumed across customers. */
type LearningCategory = "errors" | "fixes" | "capabilities";
/** Per-customer opt-in policy for cross-customer learning. */
interface CustomerSharingPolicy {
    customerId: string;
    /** Categories this customer agrees to contribute (anonymised). */
    shareCategories: LearningCategory[];
    /** Categories this customer agrees to receive from the fleet. */
    consumeCategories: LearningCategory[];
    /** Free-text reason for any restriction (compliance, NDA, vertical concerns). */
    notes?: string;
    updatedAt: Date;
}
interface CustomerSharingPolicyStore {
    get(customerId: string): Promise<CustomerSharingPolicy | null>;
    upsert(policy: CustomerSharingPolicy): Promise<CustomerSharingPolicy>;
    list(): Promise<CustomerSharingPolicy[]>;
}
/**
 * The on-the-wire shape after anonymisation. Customer identifiers, operator
 * identifiers, and free-text evidence excerpts containing PII are stripped.
 * The pattern, fix, or capability label survives intact.
 */
interface AnonymisedLearning {
    category: LearningCategory;
    /** Origin customer identifier hashed with a per-fleet salt — not reversible. */
    originHash: string;
    /** The payload — shape depends on category. */
    payload: {
        kind: "error_signature";
        pattern: string;
        categoryHint: ErrorCategory;
        occurrenceCount: number;
        deploymentCount: number;
    } | {
        kind: "fix_recommendation";
        strategy: FixStrategy;
        rationale: string;
        suggestedConfig?: Record<string, unknown>;
    } | {
        kind: "capability_emergence";
        capabilityLabel: string;
        deploymentCount: number;
        eventCount: number;
    };
    sharedAt: Date;
}

interface ClassificationResult {
    category: ErrorCategory;
    severity: ErrorSeverity;
}
declare class ErrorClassifier {
    /**
     * Classifies a single error event by matching message + detail text against
     * known patterns. Returns category and severity; never throws.
     */
    classify(event: Pick<ErrorEvent, "message" | "detail" | "sourceComponent">): ClassificationResult;
    classifyAll(events: Pick<ErrorEvent, "message" | "detail" | "sourceComponent">[]): ClassificationResult[];
}

interface ErrorAggregatorOptions {
    /** Minimum occurrences before a signature is returned from listTopErrors. Default: 3. */
    minOccurrencesForSurface?: number;
}
declare class ErrorAggregator {
    private readonly eventStore;
    private readonly signatureStore;
    private readonly classifier;
    private readonly minOccurrencesForSurface;
    constructor(eventStore: ErrorEventStore, signatureStore: ErrorSignatureStore, classifier: ErrorClassifier, options?: ErrorAggregatorOptions);
    /**
     * Ingests a single ErrorEvent, classifies it, and upserts the corresponding
     * ErrorSignature. Returns the updated (or newly created) signature.
     */
    ingest(event: ErrorEvent): Promise<ErrorSignature>;
    /**
     * Ingests multiple events in sequence. Returns all updated signatures.
     * Useful for batch backfill from an existing error log.
     */
    ingestBatch(events: ErrorEvent[]): Promise<ErrorSignature[]>;
    /** Returns the most frequent error signatures above the surface threshold. */
    listTopErrors(): Promise<ErrorSignature[]>;
}
/**
 * Normalises an error message into a stable pattern by replacing variable
 * portions (UUIDs, timestamps, numbers, long quoted strings) with placeholders.
 */
declare function normalizePattern(message: string): string;

interface FixProposerOptions {
    /** Default: "claude-haiku-4-5-20251001". */
    model?: string;
    maxTokens?: number;
    /** Minimum occurrences before proposing a fix. Default: 5. */
    minOccurrencesForProposal?: number;
}
declare class FixProposer {
    private readonly anthropic;
    private readonly signatureStore;
    private readonly eventStore;
    private readonly proposalStore;
    private readonly model;
    private readonly maxTokens;
    private readonly minOccurrences;
    constructor(anthropic: Anthropic, signatureStore: ErrorSignatureStore, eventStore: ErrorEventStore, proposalStore: FixProposalStore, options?: FixProposerOptions);
    /**
     * Scans all signatures above the recurrence threshold and drafts fix proposals
     * for those that don't yet have a pending or approved proposal.
     * Returns the newly created proposals.
     */
    proposeFixesForTopErrors(): Promise<FixProposal[]>;
    /**
     * Drafts a fix proposal for a specific signature, using up to `examples` for
     * context. Returns the stored FixProposal in DRAFT status.
     */
    draftProposal(sig: ErrorSignature, examples: ErrorEvent[]): Promise<FixProposal>;
    private callClaude;
}

interface EmergenceDetectorOptions {
    /** Default: "claude-sonnet-4-6". Use Haiku for high-volume deployments. */
    model?: string;
    maxTokens?: number;
    /**
     * Minimum number of distinct deployments a pattern must span before it is
     * persisted. Default: 2.
     */
    minDeploymentsForPattern?: number;
    /** Max excerpts sent to Claude per batch call. Default: 20. */
    excerptBatchSize?: number;
}
declare class CapabilityEmergenceDetector {
    private readonly anthropic;
    private readonly patternStore;
    private readonly model;
    private readonly maxTokens;
    private readonly minDeployments;
    private readonly batchSize;
    constructor(anthropic: Anthropic, patternStore: EmergencePatternStore, options?: EmergenceDetectorOptions);
    /**
     * Analyses a batch of conversation excerpts for unmet capability signals.
     * Clusters signals into CapabilityEmergencePatterns, merges with existing
     * patterns, and returns all affected patterns (new + updated).
     */
    analyzeConversations(excerpts: ConversationExcerpt[]): Promise<CapabilityEmergencePattern[]>;
    private extractSignals;
    private findSimilarPattern;
}

interface SkillRecommendationEngineOptions {
    /** Default: "claude-haiku-4-5-20251001". */
    model?: string;
    /** Minimum confidence before a pattern is included. Default: 0.3. */
    minConfidence?: number;
}
declare class SkillRecommendationEngine {
    private readonly patternStore;
    private readonly anthropic?;
    private readonly model;
    private readonly minConfidence;
    constructor(patternStore: EmergencePatternStore, anthropic?: Anthropic | undefined, options?: SkillRecommendationEngineOptions);
    /**
     * Generates and ranks SkillRecommendations from detected emergence patterns.
     * Results are sorted by demand score, highest first.
     *
     * If an Anthropic client was provided, Claude derives the skill name,
     * rationale, and suggested module path. Otherwise, the pattern label is
     * used directly — useful for testing without API access.
     */
    generateRecommendations(): Promise<SkillRecommendation[]>;
    private deriveSkillSpec;
}

declare class ImprovementRolloutOrchestrator {
    private readonly rolloutStore;
    private readonly fixProposalStore;
    private readonly patternStore;
    constructor(rolloutStore: RolloutStore, fixProposalStore: FixProposalStore, patternStore: EmergencePatternStore);
    /**
     * Initiates a staged rollout for an approved FixProposal.
     * Throws if the proposal is not in APPROVED status.
     */
    initiateFixRollout(proposalId: string, allDeploymentIds: string[], options?: RolloutOptions): Promise<ImprovementRollout>;
    /**
     * Initiates a staged rollout for an approved CapabilityEmergencePattern.
     * Throws if the pattern is not in APPROVED status.
     */
    initiateCapabilityRollout(patternId: string, allDeploymentIds: string[], options?: RolloutOptions): Promise<ImprovementRollout>;
    /**
     * Marks the current in-progress stage as COMPLETED (attaching telemetry)
     * and starts the next stage. If all stages complete, sets overallStatus to
     * COMPLETED.
     *
     * Callers are expected to pass telemetrySummary as evidence that the stage
     * was successful before advancing.
     */
    advanceStage(rolloutId: string, telemetrySummary?: string): Promise<ImprovementRollout>;
    /** Pauses an in-progress rollout. Resume by calling advanceStage again. */
    pauseRollout(rolloutId: string): Promise<ImprovementRollout>;
    listActiveRollouts(): Promise<ImprovementRollout[]>;
    private createRollout;
}

declare class InMemoryErrorEventStore implements ErrorEventStore {
    private readonly events;
    append(event: ErrorEvent): Promise<void>;
    listBySignature(signatureId: string, limit?: number): Promise<ErrorEvent[]>;
    listRecent(deploymentId: string, since: Date): Promise<ErrorEvent[]>;
}
declare class InMemoryErrorSignatureStore implements ErrorSignatureStore {
    private readonly sigs;
    get(id: string): Promise<ErrorSignature | null>;
    getByPattern(pattern: string): Promise<ErrorSignature | null>;
    upsert(sig: ErrorSignature): Promise<ErrorSignature>;
    listByFrequency(minOccurrences?: number): Promise<ErrorSignature[]>;
}
declare class InMemoryFixProposalStore implements FixProposalStore {
    private readonly proposals;
    create(proposal: Omit<FixProposal, "id" | "draftedAt">): Promise<FixProposal>;
    get(id: string): Promise<FixProposal | null>;
    update(id: string, patch: Partial<FixProposal>): Promise<FixProposal>;
    listPending(): Promise<FixProposal[]>;
    listBySignature(signatureId: string): Promise<FixProposal[]>;
}
declare class InMemoryEmergencePatternStore implements EmergencePatternStore {
    private readonly patterns;
    create(pattern: Omit<CapabilityEmergencePattern, "id" | "detectedAt" | "lastUpdatedAt">): Promise<CapabilityEmergencePattern>;
    get(id: string): Promise<CapabilityEmergencePattern | null>;
    update(id: string, patch: Partial<CapabilityEmergencePattern>): Promise<CapabilityEmergencePattern>;
    listByConfidence(minConfidence?: number): Promise<CapabilityEmergencePattern[]>;
}
declare class InMemoryRolloutStore implements RolloutStore {
    private readonly rollouts;
    create(rollout: Omit<ImprovementRollout, "id" | "createdAt" | "updatedAt">): Promise<ImprovementRollout>;
    get(id: string): Promise<ImprovementRollout | null>;
    update(id: string, patch: Partial<ImprovementRollout>): Promise<ImprovementRollout>;
    listActive(): Promise<ImprovementRollout[]>;
}

interface SubAgentErrorCaptureOptions {
    /** Default timeout (ms) applied by captureWithTimeout when none is supplied. */
    defaultTimeoutMs?: number;
}
/**
 * Wraps sub-agent operations and converts failures into normalised
 * ErrorEvents. On success, returns the operation's value unchanged.
 * On failure, captures the error then re-throws — callers retain control of
 * their own failure semantics.
 */
declare class SubAgentErrorCapture {
    private readonly aggregator;
    private readonly defaultTimeoutMs;
    constructor(aggregator: ErrorAggregator, options?: SubAgentErrorCaptureOptions);
    /** Wrap a tool call. Captures and re-throws on failure. */
    captureToolCall<T>(ctx: CaptureContext, fn: () => Promise<T>): Promise<T>;
    /**
     * Wrap a call with a hard timeout. If the operation runs longer than
     * `timeoutMs`, captures a "timeout" event and rejects. The underlying
     * promise is not cancelled — callers must implement that themselves.
     */
    captureWithTimeout<T>(ctx: CaptureContext, fn: () => Promise<T>, timeoutMs?: number): Promise<T>;
    /** Explicit capture entry point for malformed input failures. */
    captureMalformedInput(ctx: CaptureContext, message: string, detail?: unknown): Promise<ErrorSignature>;
    /** Explicit capture entry point for retry-exhaustion failures. */
    captureRetryExhaustion(ctx: CaptureContext, attempts: number, lastError: unknown): Promise<ErrorSignature>;
    private record;
}

interface PatternExtractorOptions {
    /** Minimum events supporting a pattern before it qualifies. Default: 3. */
    minEvidenceCount?: number;
    /** Minimum fraction of events that must share a condition. Default: 0.6. */
    minConditionShare?: number;
}
declare class ContextualPatternExtractor {
    private readonly signatureStore;
    private readonly eventStore;
    private readonly minEvidence;
    private readonly minShare;
    constructor(signatureStore: ErrorSignatureStore, eventStore: ErrorEventStore, options?: PatternExtractorOptions);
    /**
     * Sweeps all signatures and produces a contextual pattern per signature
     * whose events share a discriminating condition. Returns the list of new
     * patterns — callers persist them as they see fit.
     */
    extractPatterns(): Promise<ContextualPattern[]>;
    /** Build a contextual pattern for a single signature, or null if too weak. */
    buildPattern(sig: ErrorSignature, events: ErrorEvent[]): ContextualPattern | null;
}

interface FixRecommenderOptions {
    /** Minimum pattern confidence before a recommendation is emitted. Default: 0.3. */
    minPatternConfidence?: number;
}
declare class FixRecommender {
    private readonly signatureStore;
    private readonly minConfidence;
    constructor(signatureStore: ErrorSignatureStore, options?: FixRecommenderOptions);
    /** Generate a fix recommendation for a single contextual pattern. */
    recommend(pattern: ContextualPattern): Promise<FixRecommendation | null>;
    /** Bulk variant — skips patterns below the confidence threshold. */
    recommendAll(patterns: ContextualPattern[]): Promise<FixRecommendation[]>;
}

interface PromptUpdateRecommenderOptions {
    /** Default: "claude-haiku-4-5-20251001". */
    model?: string;
    maxTokens?: number;
    /** Minimum events before we'll spend tokens drafting. Default: 3. */
    minEvidenceCount?: number;
}
declare class PromptUpdateRecommender {
    private readonly anthropic;
    private readonly signatureStore;
    private readonly eventStore;
    private readonly model;
    private readonly maxTokens;
    private readonly minEvidence;
    constructor(anthropic: AnthropicMessagesClient, signatureStore: ErrorSignatureStore, eventStore: ErrorEventStore, options?: PromptUpdateRecommenderOptions);
    /**
     * Draft a prompt-update recommendation for a contextual pattern.
     * Returns null if the pattern doesn't look prompt-rooted, the signature
     * is missing, or evidence is insufficient.
     */
    recommend(pattern: ContextualPattern): Promise<PromptUpdateRecommendation | null>;
    private callClaude;
}

declare class InMemoryCustomerSharingPolicyStore implements CustomerSharingPolicyStore {
    private readonly policies;
    get(customerId: string): Promise<CustomerSharingPolicy | null>;
    upsert(policy: CustomerSharingPolicy): Promise<CustomerSharingPolicy>;
    list(): Promise<CustomerSharingPolicy[]>;
}
/** Per-customer opt-in policy enforcement. Default policy is fully opted-out. */
declare class OptInPolicyEnforcer {
    private readonly store;
    constructor(store: CustomerSharingPolicyStore);
    /**
     * Returns true when `customerId` has agreed to contribute the given
     * category to the fleet. Default (no policy stored) is false — opt-in.
     */
    canShare(customerId: string, category: LearningCategory): Promise<boolean>;
    /**
     * Returns true when `customerId` has agreed to receive learnings of the
     * given category from the fleet. Default is false — opt-in.
     */
    canConsume(customerId: string, category: LearningCategory): Promise<boolean>;
    /** Convenience: returns customers that have opted in to a given share/consume. */
    listShareSubscribers(category: LearningCategory): Promise<string[]>;
    listConsumeSubscribers(category: LearningCategory): Promise<string[]>;
}

interface LearningSharerOptions {
    /**
     * Salt mixed into the originHash. A fleet-stable secret prevents the hash
     * from being trivially reversible across deployments. Required for any
     * production use — default is an obvious sentinel.
     */
    originHashSalt?: string;
}
declare class LearningSharer {
    private readonly policy;
    private readonly salt;
    constructor(policy: OptInPolicyEnforcer, options?: LearningSharerOptions);
    /**
     * Anonymise an ErrorSignature for cross-customer sharing.
     * Returns null when the origin customer has not opted in to share errors.
     */
    shareErrorSignature(originCustomerId: string, sig: ErrorSignature): Promise<AnonymisedLearning | null>;
    /** Anonymise a FixRecommendation. */
    shareFixRecommendation(originCustomerId: string, rec: FixRecommendation): Promise<AnonymisedLearning | null>;
    /**
     * Anonymise a CapabilityEmergencePattern. Evidence excerpts are stripped
     * — only the capability label and aggregate counts survive.
     */
    shareCapabilityEmergence(originCustomerId: string, pattern: CapabilityEmergencePattern): Promise<AnonymisedLearning | null>;
    /**
     * Distribute a batch of anonymised learnings to all customers opted in to
     * the given category. Returns a delivery map: customerId → number of
     * learnings the consumer accepted (gated by their consume policy).
     */
    distribute(category: LearningCategory, learnings: AnonymisedLearning[], deliver: (customerId: string, l: AnonymisedLearning) => Promise<void>): Promise<Record<string, number>>;
    /** Expose the hash function for testing the round-trip cleanly. */
    hash(customerId: string): string;
}

interface LearningMindConfig {
    signatureStore: ErrorSignatureStore;
    eventStore: ErrorEventStore;
    extractorOptions?: PatternExtractorOptions;
    recommenderOptions?: FixRecommenderOptions;
    /** Optional Claude-backed prompt-update recommender (omit to skip prompt updates). */
    promptUpdateRecommender?: PromptUpdateRecommender;
    /** Optional sharer — when present, sweep() also produces anonymised batches. */
    sharer?: LearningSharer;
    /** Origin customer id used when invoking the sharer. */
    originCustomerId?: string;
    /** Minimum recommendation confidence before surfacing as a CandidateEvent. Default: 0.5. */
    minSurfaceConfidence?: number;
}
interface LearningMindSweepResult {
    patterns: ContextualPattern[];
    fixRecommendations: FixRecommendation[];
    promptUpdates: PromptUpdateRecommendation[];
    candidateEvents: CandidateEvent[];
    anonymised: AnonymisedLearning[];
}
declare class LearningMind {
    private readonly config;
    private readonly extractor;
    private readonly fixRecommender;
    private readonly promptRecommender?;
    private readonly sharer?;
    private readonly originCustomerId?;
    private readonly minSurfaceConfidence;
    constructor(config: LearningMindConfig);
    /** Full sweep — extract patterns, recommend fixes, surface, optionally share. */
    sweep(now?: Date): Promise<LearningMindSweepResult>;
    /** Convert the latest recommendations into CandidateEvents for F0.10. */
    surfaceHighImpactFixes(fixes: FixRecommendation[], patterns: ContextualPattern[], now?: Date): CandidateEvent[];
    private toCandidateEvents;
    private anonymise;
}

type index_AnonymisedLearning = AnonymisedLearning;
type index_CapabilityEmergenceDetector = CapabilityEmergenceDetector;
declare const index_CapabilityEmergenceDetector: typeof CapabilityEmergenceDetector;
type index_CapabilityEmergencePattern = CapabilityEmergencePattern;
type index_CaptureContext = CaptureContext;
type index_CaptureKind = CaptureKind;
type index_ClassificationResult = ClassificationResult;
type index_ContextualPattern = ContextualPattern;
type index_ContextualPatternExtractor = ContextualPatternExtractor;
declare const index_ContextualPatternExtractor: typeof ContextualPatternExtractor;
type index_ConversationExcerpt = ConversationExcerpt;
type index_CustomerSharingPolicy = CustomerSharingPolicy;
type index_CustomerSharingPolicyStore = CustomerSharingPolicyStore;
type index_EmergenceDetectorOptions = EmergenceDetectorOptions;
type index_EmergencePatternStatus = EmergencePatternStatus;
type index_EmergencePatternStore = EmergencePatternStore;
type index_ErrorAggregator = ErrorAggregator;
declare const index_ErrorAggregator: typeof ErrorAggregator;
type index_ErrorAggregatorOptions = ErrorAggregatorOptions;
type index_ErrorCategory = ErrorCategory;
type index_ErrorClassifier = ErrorClassifier;
declare const index_ErrorClassifier: typeof ErrorClassifier;
type index_ErrorEvent = ErrorEvent;
type index_ErrorEventStore = ErrorEventStore;
type index_ErrorSeverity = ErrorSeverity;
type index_ErrorSignature = ErrorSignature;
type index_ErrorSignatureStore = ErrorSignatureStore;
type index_FixProposal = FixProposal;
type index_FixProposalStatus = FixProposalStatus;
type index_FixProposalStore = FixProposalStore;
type index_FixProposer = FixProposer;
declare const index_FixProposer: typeof FixProposer;
type index_FixProposerOptions = FixProposerOptions;
type index_FixRecommendation = FixRecommendation;
type index_FixRecommender = FixRecommender;
declare const index_FixRecommender: typeof FixRecommender;
type index_FixRecommenderOptions = FixRecommenderOptions;
type index_FixStrategy = FixStrategy;
type index_ImprovementRollout = ImprovementRollout;
type index_ImprovementRolloutOrchestrator = ImprovementRolloutOrchestrator;
declare const index_ImprovementRolloutOrchestrator: typeof ImprovementRolloutOrchestrator;
type index_InMemoryCustomerSharingPolicyStore = InMemoryCustomerSharingPolicyStore;
declare const index_InMemoryCustomerSharingPolicyStore: typeof InMemoryCustomerSharingPolicyStore;
type index_InMemoryEmergencePatternStore = InMemoryEmergencePatternStore;
declare const index_InMemoryEmergencePatternStore: typeof InMemoryEmergencePatternStore;
type index_InMemoryErrorEventStore = InMemoryErrorEventStore;
declare const index_InMemoryErrorEventStore: typeof InMemoryErrorEventStore;
type index_InMemoryErrorSignatureStore = InMemoryErrorSignatureStore;
declare const index_InMemoryErrorSignatureStore: typeof InMemoryErrorSignatureStore;
type index_InMemoryFixProposalStore = InMemoryFixProposalStore;
declare const index_InMemoryFixProposalStore: typeof InMemoryFixProposalStore;
type index_InMemoryRolloutStore = InMemoryRolloutStore;
declare const index_InMemoryRolloutStore: typeof InMemoryRolloutStore;
type index_LearningCategory = LearningCategory;
type index_LearningMind = LearningMind;
declare const index_LearningMind: typeof LearningMind;
type index_LearningMindConfig = LearningMindConfig;
type index_LearningMindSweepResult = LearningMindSweepResult;
type index_LearningSharer = LearningSharer;
declare const index_LearningSharer: typeof LearningSharer;
type index_LearningSharerOptions = LearningSharerOptions;
type index_OptInPolicyEnforcer = OptInPolicyEnforcer;
declare const index_OptInPolicyEnforcer: typeof OptInPolicyEnforcer;
type index_PatternCondition = PatternCondition;
type index_PatternExtractorOptions = PatternExtractorOptions;
type index_PromptUpdateRecommendation = PromptUpdateRecommendation;
type index_PromptUpdateRecommender = PromptUpdateRecommender;
declare const index_PromptUpdateRecommender: typeof PromptUpdateRecommender;
type index_PromptUpdateRecommenderOptions = PromptUpdateRecommenderOptions;
type index_RolloutOptions = RolloutOptions;
type index_RolloutStage = RolloutStage;
type index_RolloutStageRecord = RolloutStageRecord;
type index_RolloutStatus = RolloutStatus;
type index_RolloutStore = RolloutStore;
type index_SkillRecommendation = SkillRecommendation;
type index_SkillRecommendationEngine = SkillRecommendationEngine;
declare const index_SkillRecommendationEngine: typeof SkillRecommendationEngine;
type index_SkillRecommendationEngineOptions = SkillRecommendationEngineOptions;
type index_SubAgentErrorCapture = SubAgentErrorCapture;
declare const index_SubAgentErrorCapture: typeof SubAgentErrorCapture;
type index_SubAgentErrorCaptureOptions = SubAgentErrorCaptureOptions;
declare const index_normalizePattern: typeof normalizePattern;
declare namespace index {
  export { type index_AnonymisedLearning as AnonymisedLearning, index_CapabilityEmergenceDetector as CapabilityEmergenceDetector, type index_CapabilityEmergencePattern as CapabilityEmergencePattern, type index_CaptureContext as CaptureContext, type index_CaptureKind as CaptureKind, type index_ClassificationResult as ClassificationResult, type index_ContextualPattern as ContextualPattern, index_ContextualPatternExtractor as ContextualPatternExtractor, type index_ConversationExcerpt as ConversationExcerpt, type index_CustomerSharingPolicy as CustomerSharingPolicy, type index_CustomerSharingPolicyStore as CustomerSharingPolicyStore, type index_EmergenceDetectorOptions as EmergenceDetectorOptions, type index_EmergencePatternStatus as EmergencePatternStatus, type index_EmergencePatternStore as EmergencePatternStore, index_ErrorAggregator as ErrorAggregator, type index_ErrorAggregatorOptions as ErrorAggregatorOptions, type index_ErrorCategory as ErrorCategory, index_ErrorClassifier as ErrorClassifier, type index_ErrorEvent as ErrorEvent, type index_ErrorEventStore as ErrorEventStore, type index_ErrorSeverity as ErrorSeverity, type index_ErrorSignature as ErrorSignature, type index_ErrorSignatureStore as ErrorSignatureStore, type index_FixProposal as FixProposal, type index_FixProposalStatus as FixProposalStatus, type index_FixProposalStore as FixProposalStore, index_FixProposer as FixProposer, type index_FixProposerOptions as FixProposerOptions, type index_FixRecommendation as FixRecommendation, index_FixRecommender as FixRecommender, type index_FixRecommenderOptions as FixRecommenderOptions, type index_FixStrategy as FixStrategy, type index_ImprovementRollout as ImprovementRollout, index_ImprovementRolloutOrchestrator as ImprovementRolloutOrchestrator, index_InMemoryCustomerSharingPolicyStore as InMemoryCustomerSharingPolicyStore, index_InMemoryEmergencePatternStore as InMemoryEmergencePatternStore, index_InMemoryErrorEventStore as InMemoryErrorEventStore, index_InMemoryErrorSignatureStore as InMemoryErrorSignatureStore, index_InMemoryFixProposalStore as InMemoryFixProposalStore, index_InMemoryRolloutStore as InMemoryRolloutStore, type index_LearningCategory as LearningCategory, index_LearningMind as LearningMind, type index_LearningMindConfig as LearningMindConfig, type index_LearningMindSweepResult as LearningMindSweepResult, index_LearningSharer as LearningSharer, type index_LearningSharerOptions as LearningSharerOptions, index_OptInPolicyEnforcer as OptInPolicyEnforcer, type index_PatternCondition as PatternCondition, type index_PatternExtractorOptions as PatternExtractorOptions, type index_PromptUpdateRecommendation as PromptUpdateRecommendation, index_PromptUpdateRecommender as PromptUpdateRecommender, type index_PromptUpdateRecommenderOptions as PromptUpdateRecommenderOptions, type index_RolloutOptions as RolloutOptions, type index_RolloutStage as RolloutStage, type index_RolloutStageRecord as RolloutStageRecord, type index_RolloutStatus as RolloutStatus, type index_RolloutStore as RolloutStore, type index_SkillRecommendation as SkillRecommendation, index_SkillRecommendationEngine as SkillRecommendationEngine, type index_SkillRecommendationEngineOptions as SkillRecommendationEngineOptions, index_SubAgentErrorCapture as SubAgentErrorCapture, type index_SubAgentErrorCaptureOptions as SubAgentErrorCaptureOptions, index_normalizePattern as normalizePattern };
}

export { type RolloutStage as $, type AnonymisedLearning as A, type FixRecommenderOptions as B, CapabilityEmergenceDetector as C, type FixStrategy as D, type EmergenceDetectorOptions as E, type FixProposal as F, ImprovementRolloutOrchestrator as G, InMemoryCustomerSharingPolicyStore as H, type ImprovementRollout as I, InMemoryEmergencePatternStore as J, InMemoryErrorEventStore as K, InMemoryErrorSignatureStore as L, InMemoryFixProposalStore as M, InMemoryRolloutStore as N, type LearningCategory as O, LearningMind as P, type LearningMindConfig as Q, type LearningMindSweepResult as R, LearningSharer as S, type LearningSharerOptions as T, OptInPolicyEnforcer as U, type PatternCondition as V, type PatternExtractorOptions as W, type PromptUpdateRecommendation as X, PromptUpdateRecommender as Y, type PromptUpdateRecommenderOptions as Z, type RolloutOptions as _, type CapabilityEmergencePattern as a, type RolloutStageRecord as a0, type RolloutStatus as a1, type RolloutStore as a2, type SkillRecommendation as a3, SkillRecommendationEngine as a4, type SkillRecommendationEngineOptions as a5, SubAgentErrorCapture as a6, type SubAgentErrorCaptureOptions as a7, index as a8, normalizePattern as a9, type CaptureContext as b, type CaptureKind as c, type ClassificationResult as d, type ContextualPattern as e, ContextualPatternExtractor as f, type ConversationExcerpt as g, type CustomerSharingPolicy as h, type CustomerSharingPolicyStore as i, type EmergencePatternStatus as j, type EmergencePatternStore as k, ErrorAggregator as l, type ErrorAggregatorOptions as m, type ErrorCategory as n, ErrorClassifier as o, type ErrorEvent as p, type ErrorEventStore as q, type ErrorSeverity as r, type ErrorSignature as s, type ErrorSignatureStore as t, type FixProposalStatus as u, type FixProposalStore as v, FixProposer as w, type FixProposerOptions as x, type FixRecommendation as y, FixRecommender as z };
