/** * @file On-disk cache metadata helpers for dlx binaries. * * - `getDlxCachePath` — root of the binary cache (alias of getSocketDlxDir) * - `getBinaryCacheMetadataPath` — path to a cache entry's .dlx-metadata.json * - `isBinaryCacheValid` — TTL-based liveness check * - `writeBinaryCacheMetadata` — atomic write of cache metadata * - `cleanDlxCache` — TTL-based eviction sweep * - `listDlxCache` — enumerate cached binaries with their metadata Split out of * `dlx/binary.ts` for size hygiene. */ import { getSocketDlxDir } from '../paths/socket.js'; import type { DlxMetadata } from './binary-types.js'; /** * Clean expired entries from the DLX cache. * * @example * ;```typescript * // Remove cache entries older than the default TTL * const removed = await cleanDlxCache() * * // Remove entries older than 1 hour * const removed2 = await cleanDlxCache(60 * 60 * 1000) * ``` */ export declare function cleanDlxCache(maxAge?: number): Promise; /** * Get metadata file path for a cached binary. * * @example * ;```typescript * const metaPath = getBinaryCacheMetadataPath('/tmp/dlx-cache/a1b2c3d4') * // '/tmp/dlx-cache/a1b2c3d4/.dlx-metadata.json' * ``` */ export declare function getBinaryCacheMetadataPath(cacheEntryPath: string): string; /** * Get the DLX binary cache directory path. Alias of `getSocketDlxDir` — DLX * binary cache uses the same directory as dlx-package for unified DLX storage. * * @example * ;```typescript * const cachePath = getDlxCachePath() * ``` */ export declare const getDlxCachePath: typeof getSocketDlxDir; /** * Check if a cached binary is still valid. * * @example * ;```typescript * const ttl = 7 * 24 * 60 * 60 * 1000 * const valid = await isBinaryCacheValid('/tmp/dlx-cache/a1b2c3d4', ttl) * if (!valid) { * // Re-download the binary * } * ``` */ export declare function isBinaryCacheValid(cacheEntryPath: string, cacheTtl: number): Promise; /** * Get information about cached binaries. * * @example * ```typescript * const entries = await listDlxCache() * for (const entry of entries) { * console.log(`${entry.name}: ${entry.size} bytes`) * } * ``` */ export declare function listDlxCache(): Promise>; /** * Read the DlxMetadata for a cached binary. Returns `undefined` when the * metadata file is missing, unreadable, or doesn't match the expected shape. * Useful for callers that want to recover the integrity / size / source URL of * an already-cached download without re-fetching. * * @example * ```typescript * const meta = await readBinaryCacheMetadata(cacheEntryDir) * if (meta) { * console.log(`Pinned integrity: ${meta.integrity}`) * } * ``` */ export declare function readBinaryCacheMetadata(cacheEntryPath: string): Promise; /** * Write metadata for a cached binary. Uses unified schema shared with C++ * decompressor and CLI dlxBinary. * * @example * ;```typescript * await writeBinaryCacheMetadata( * '/tmp/dlx-cache/a1b2c3d4', * 'a1b2c3d4', * 'https://example.com/tool', * 'sha512-abc123...', * 15000000, * ) * ``` */ export declare function writeBinaryCacheMetadata(cacheEntryPath: string, cacheKey: string, url: string, integrity: string, size: number): Promise;