/**
 * InboundMessageGate — Pre-filter for relay inbound messages.
 *
 * Gates on sender identity, trust level, rate limits, payload size, and replay.
 * Does NOT determine delivery mode — that's AutonomyGate's job.
 *
 * Part of PROP-relay-auto-connect.
 */
import { type AgentTrustManager, type AgentTrustLevel } from './AgentTrustManager.js';
import type { ThreadlineRouter } from './ThreadlineRouter.js';
import type { ReceivedMessage } from './client/ThreadlineClient.js';
/**
 * Verified-pairing config snapshot (spec §3.10). Read live at the chokepoint so a
 * config edit takes effect without a gate rebuild. When `enabled` is false the gate
 * is a complete pass-through — byte-identical legacy behavior.
 */
export interface VerifiedPairingGateConfig {
    /** Master flag (§3.10). Resolved (dev-gate applied) by the caller. */
    enabled: boolean;
    /** Governs inbound observability ONLY (FD10) — never the outbound refusal. */
    dryRun: boolean;
    /** Arms inbound credential-ingestion enforcement (read live). */
    credentialShareEnforced: boolean;
}
export interface InboundGateConfig {
    /** Max payload size in bytes (default: 64KB) */
    maxPayloadBytes?: number;
    /** Per-trust-level rate limits */
    rateLimits?: Partial<Record<AgentTrustLevel, {
        probesPerHour: number;
        messagesPerHour: number;
        messagesPerDay: number;
    }>>;
    /**
     * THIS agent's own fingerprint — bound into pair-verify receipt verification +
     * the self-pair guard (FD12). Optional: when absent, the recipient-fp check on a
     * receipt is skipped (the sender-fp + signature checks still hold).
     */
    ownFingerprint?: string;
    /**
     * Live reader for the verified-pairing config (spec §3.10). A function so the gate
     * reads the CURRENT flag state on every message (credentialShareEnforced is read
     * live). When absent/returns enabled:false, verified-pairing is a pass-through.
     */
    getVerifiedPairingConfig?: () => VerifiedPairingGateConfig;
}
export interface GateDecision {
    action: 'pass' | 'block';
    reason?: string;
    fingerprint?: string;
    message?: ReceivedMessage;
    trustLevel?: AgentTrustLevel;
    /**
     * Set for a consumed control-plane message (e.g. a `pair-verify` receipt): the
     * gate handled it inline and it must NOT be routed onward to ThreadlineRouter.
     */
    controlPlane?: boolean;
}
export declare class InboundMessageGate {
    private readonly trustManager;
    private router;
    private readonly config;
    private readonly rateLimiter;
    private readonly maxPayloadBytes;
    private cleanupTimer;
    /** Seen messageId cache for replay protection */
    private readonly seenMessageIds;
    private metrics;
    constructor(trustManager: AgentTrustManager, router: ThreadlineRouter | null, config?: InboundGateConfig);
    /**
     * Late-bind the router after server initialization.
     * The router isn't available at bootstrap time — it's created in server.ts
     * after the Threadline bootstrap completes.
     */
    setRouter(router: ThreadlineRouter): void;
    /**
     * Evaluate an inbound relay message.
     * Returns 'pass' to route to ThreadlineRouter/AutonomyGate,
     * or 'block' with reason.
     */
    evaluate(message: ReceivedMessage): Promise<GateDecision>;
    /**
     * Log a block decision to server.log. A blocked inbound is otherwise silent
     * (the decision lives only in the returned GateDecision + in-memory metric
     * counters), which is precisely how an Echo↔peer A2A leg can go dark for days
     * with no trace. The fingerprint is truncated; no payload content is logged.
     */
    private logBlock;
    /**
     * Get gate metrics for observability.
     */
    getMetrics(): {
        passed: number;
        blocked: number;
        blockedByTrust: number;
        blockedByRate: number;
        blockedBySize: number;
        blockedByReplay: number;
        probesHandled: number;
        pairVerifyProcessed: number;
        pairVerifyDropped: number;
        credentialBlocked: number;
        credentialDryRunWouldBlock: number;
    };
    /**
     * Shutdown: cleanup timers.
     */
    shutdown(): void;
    private classifyOperation;
    /**
     * Resolve the verified-pairing config live (spec §3.10). Defaults to a complete
     * pass-through (enabled:false) when no reader is wired, so legacy behavior is
     * byte-identical on a non-pairing agent.
     */
    private resolveVerifiedPairingConfig;
    /**
     * Extract the control-plane payload object (e.g. a pair-verify receipt) from an
     * inbound message. The receipt fields ride alongside `type` on the content object.
     */
    private extractControlPayload;
    private estimatePayloadSize;
    private getRateLimits;
    /**
     * Extract messageId from a ReceivedMessage.
     */
    private extractMessageId;
    /**
     * Prune expired entries from the seen-messageId cache.
     */
    private pruneSeenMessageIds;
}
//# sourceMappingURL=InboundMessageGate.d.ts.map