/** * Managed binary resolution for video extraction and transcoding tools. The * service owns yt-dlp cache updates and locates ffmpeg from explicit config, * the host PATH, or the packaged static binary so callers can use VideoService * without depending on machine-specific setup. */ import type { Flags as YtDlpFlags } from "youtube-dl-exec"; export type YtDlpRunner = (url: string, flags?: YtDlpFlags, opts?: object) => Promise; type FetchImpl = (input: RequestInfo | URL, init?: RequestInit) => Promise; interface YtDlpMeta { version: string; sha256: string; assetName: string; downloadedAt: number; lastUpdateAttemptedAt: number; } export interface BinaryResolverOptions { binariesDir?: string; releaseUrl?: string; fetchImpl?: FetchImpl; now?: () => number; disableAutoUpdate?: boolean; preferSystemPath?: boolean; updateThrottleMs?: number; envOverridePath?: string | null; } export declare class BinaryResolver { private static _instance; static instance(): BinaryResolver; /** Test hook: drop the singleton so the next instance() returns fresh state. */ static resetForTests(): void; private readonly binariesDir; private readonly releaseUrl; private readonly fetchImpl; private readonly now; private readonly disableAutoUpdate; private readonly preferSystemPath; private readonly updateThrottleMs; private readonly envOverridePath; private resolvedYtDlpPath; private resolvedYtDlpSource; private cachedRunner; private resolvedFfmpegPath; private updateInFlight; constructor(opts?: BinaryResolverOptions); get cacheDir(): string; get cachedYtDlpPath(): string; get metaPath(): string; /** * Resolve the yt-dlp binary path. Order: * 1. ELIZA_YT_DLP_PATH env override. * 2. If ELIZA_YT_DLP_PREFER_PATH=1: system PATH, then cache. * 3. Otherwise: cache (download if missing) → PATH fallback. */ getYtDlpPath(): Promise; /** * Resolution order: ELIZA_FFMPEG_PATH env → system ffmpeg → ffmpeg-static. * * Some installs intentionally skip dependency postinstall scripts. In that * case `ffmpeg-static` is present but its binary payload is absent, so this * resolver runs that package's installer once before declaring ffmpeg missing. */ getFfmpegPath(): Promise; /** * Build (or reuse) the yt-dlp runner bound to the resolved binary path. * The runner mirrors `youtube-dl-exec`'s default callable signature. */ getYtDlpRunner(): Promise; /** * Run yt-dlp with one auto-update + retry attempt on extractor-failure * patterns, when the active binary is the managed cache. */ runYtDlp(url: string, flags: YtDlpFlags): Promise; private shouldRetryWithUpdate; /** * Run a yt-dlp update attempt, throttled to once per `updateThrottleMs`. * Returns true iff a fresh binary was successfully installed. */ private tryUpdate; private runUpdate; private resetRunnerCache; /** Force a fresh yt-dlp download regardless of throttle. Test/admin hook. */ forceUpdateYtDlp(): Promise<{ version: string; path: string; }>; private readMeta; private writeMeta; private touchUpdateAttempt; /** * Download the latest yt-dlp release for this platform, verify the SHA256 * against the published `SHA2-256SUMS`, and atomically replace the cached * binary. Returns the new metadata on success; throws on any failure. */ downloadYtDlp(): Promise; private fetchRelease; private fetchExpectedSha; private downloadToFile; } export declare function ytDlpAssetName(): string; export declare function ytDlpFileName(): string; export declare function resolveNodeInstallRunner({ env, execPath, }?: { env?: NodeJS.ProcessEnv; execPath?: string; }): string; export declare function ffmpegStaticExecutableName(platform?: NodeJS.Platform): string; export declare function resolveFfmpegStaticCandidatePath({ packageRoot, platform, }?: { packageRoot?: string | null; platform?: NodeJS.Platform; }): string | null; export declare function formatInstallErrorReason(err: unknown): string; export {};