import * as v8 from 'node:v8'; declare function isBunRuntime(): boolean; declare const DEFAULT_THRESHOLD_MB = 800; interface MemorySampleMb { rssMb: number; heapUsedMb: number; externalMb: number; arrayBuffersMb: number; } interface DeployContextForReport { /** Sanitized domain label (sanitizeBranch equivalent). No dots. */ domain?: string; /** Sanitized repo slug. Matches what the deploy span already carries. */ repo?: string; deployTag?: string; deployMode?: "pool" | "direct" | "external"; jsMerkle?: boolean; chunkCount?: number; carBytes?: number; reconnects?: number; durationMs?: number; sentryTraceId?: string; } interface MemoryReport { schemaVersion: 1; toolVersion: string; generatedAt: string; threshold: { thresholdMb: number; peakRssMb: number; }; deploy: DeployContextForReport; memory: { peak: MemorySampleMb; stages: Record; }; v8: { heapStatistics: ReturnType | undefined; heapSpaceStatistics: ReturnType | undefined; }; runtime: { nodeVersion: string; platform: string; arch: string; totalMemMb: number; freeMemMb: number; cpuCount: number; activeHandlesByType: Record; activeRequestsByType: Record; }; polkadotApi?: { version?: string; clientsCreated?: number; }; } declare function safeHeap(f: () => T): T | undefined; declare function buildMemoryReport(input: { thresholdMb: number; peak: MemorySampleMb; stages: Record; deploy: DeployContextForReport; }): MemoryReport; interface MaybeWriteMemoryReportInput { peak: MemorySampleMb; stages: Record; deploy: DeployContextForReport; /** Where to write the report file. Usually the build directory. */ outputDir?: string; /** Override the default 1500 MB threshold (BULLETIN_DEPLOY_MEM_REPORT_THRESHOLD_MB). */ thresholdMbOverride?: number; /** Hook for tests — defaults to isInternalContext(). */ isInternal?: () => boolean; /** Hook for tests — defaults to real fs writes. */ writeFile?: (path: string, content: string) => void; /** Hook for tests — receives the report when it would be attached to Sentry. */ onSentryAttach?: (report: MemoryReport) => void; } interface MemoryReportResult { /** Why the report did/didn't fire. Useful for tests and CLI logging. */ status: "disabled" | "below-threshold" | "not-internal" | "written" | "unsupported-runtime"; thresholdMb: number; peakRssMb: number; path?: string; } declare function maybeWriteMemoryReport(input: MaybeWriteMemoryReportInput): MemoryReportResult; /** Convert a MemorySample with raw byte fields into the MB-shaped sample. */ declare function sampleFromBytes(m: { rss: number; heapUsed: number; external: number; arrayBuffers: number; }): MemorySampleMb; export { DEFAULT_THRESHOLD_MB, type DeployContextForReport, type MaybeWriteMemoryReportInput, type MemoryReport, type MemoryReportResult, type MemorySampleMb, buildMemoryReport, isBunRuntime, maybeWriteMemoryReport, safeHeap, sampleFromBytes };