import { type ProcessFootprint, type ProcessFootprintMeasure } from "../../core/process-footprint.ts";
import type { RpcHostKernelMemory, RpcHostMemoryPressureEvent } from "./rpc-types.ts";
/** Environment override for the memory warning threshold (compared with the footprint), in megabytes. */
export declare const HOST_RSS_WARN_MB_ENV = "SENPI_RPC_HOST_RSS_WARN_MB";
export declare const DEFAULT_HOST_RSS_WARN_MB = 4096;
/** Sampling interval. Memory moves slowly; this is bookkeeping, not a hot loop. */
export declare const HOST_MEMORY_SAMPLE_MS = 30000;
/** One stderr line per window, however many samples stay above the threshold. */
export declare const HOST_MEMORY_STDERR_INTERVAL_MS: number;
/** One sample: the footprint that decides pressure, the RSS `ps` would show beside it, and the heap split. */
export interface HostMemoryReading {
    readonly footprintMb: number;
    readonly measure: ProcessFootprintMeasure;
    readonly rssMb: number;
    /** Main-thread heap in bytes: `bun:jsc heapSize()` when the runtime offers it, else `heapUsed`. */
    readonly main: {
        readonly heapBytes: number;
    };
    /** Every kernel the codemode extension's registry holds, mapped to its session; a vanished kernel is absent. */
    readonly kernels: readonly RpcHostKernelMemory[];
}
export interface HostMemorySamplerOptions {
    /** Delivers one `host_memory_pressure` lifecycle record to every connection. */
    readonly emit: (record: RpcHostMemoryPressureEvent) => void;
    /** Live session count published with the record. */
    readonly sessions: () => number;
    /** Raised while the host is above the threshold; the router halves idle parking. */
    readonly onPressure: (pressure: boolean) => void;
    /**
     * Raised once per pressure episode for a host that is above the threshold holding NO session.
     * Memory a daemon cannot attribute to a session is memory nothing will return: a superseded
     * generation in that state is pure cost and leaves (#1893).
     */
    readonly onIdlePressure?: (reading: HostMemoryReading) => void;
    /** Defaults to one stderr line; tests capture it. */
    readonly log?: (message: string) => void;
    readonly now?: () => number;
    /** The memory the host really holds (senpi#2261: RSS stays high after memory is returned). */
    readonly readFootprint?: () => ProcessFootprint;
    /** Reported beside the footprint; never decides pressure. */
    readonly readRssBytes?: () => number;
    /**
     * Live kernels, read from the codemode extension's process-global registry without importing it.
     * The host injects the accessor at start; a host without the extension lists none. Main-thread
     * only on Bun: `process.memoryUsage().heapUsed` never includes a kernel worker's heap.
     */
    readonly readKernels?: () => readonly RpcHostKernelMemory[];
    /** Main-thread heap in bytes; defaults to `bun:jsc heapSize()` when available, else `heapUsed`. */
    readonly readMainHeap?: () => number;
    readonly env?: Readonly<Record<string, string | undefined>>;
}
/**
 * Memory-footprint reporter for the shared host.
 *
 * The daemon's capacity is memory, never an occupancy cap: it never counts sessions and
 * never kills one. What it does is SAY how much memory it holds - as a lifecycle record to
 * every connection and one stderr line per five minutes - and, while it is above the
 * warning threshold, tell the router to park idle sessions at half the usual window so
 * their memory returns to the process sooner. It never refuses a session: a host with
 * no resource caps admits every open whatever it holds (#2207).
 */
export declare class HostMemorySampler {
    private readonly emit;
    private readonly sessions;
    private readonly onPressure;
    private readonly onIdlePressure?;
    private readonly log;
    private readonly now;
    private readonly readFootprint;
    private readonly readRssBytes;
    private readonly readKernels;
    private readonly readMainHeap;
    private readonly warnMb;
    private timer;
    private pressure;
    private idleReported;
    private lastLoggedAt;
    constructor(options: HostMemorySamplerOptions);
    start(): void;
    stop(): void;
    /** One sample. Public so tests drive it on an injected clock and memory readings. */
    sample(): void;
}
//# sourceMappingURL=host-memory-sampler.d.ts.map