diff --git a/src/media-understanding/fs.ts b/src/media-understanding/fs.ts new file mode 100644 index 00000000000..3bea43d0536 --- /dev/null +++ b/src/media-understanding/fs.ts @@ -0,0 +1,13 @@ +import fs from "node:fs/promises"; + +export async function fileExists(filePath?: string | null): Promise { + if (!filePath) { + return false; + } + try { + await fs.stat(filePath); + return true; + } catch { + return false; + } +} diff --git a/src/media-understanding/runner.entries.ts b/src/media-understanding/runner.entries.ts index b40e16fa531..e1f74bef8bb 100644 --- a/src/media-understanding/runner.entries.ts +++ b/src/media-understanding/runner.entries.ts @@ -25,6 +25,7 @@ import { DEFAULT_TIMEOUT_SECONDS, } from "./defaults.js"; import { MediaUnderstandingSkipError } from "./errors.js"; +import { fileExists } from "./fs.js"; import { extractGeminiResponse } from "./output-extract.js"; import { describeImageWithModel } from "./providers/image.js"; import { getMediaUnderstandingProvider, normalizeMediaProviderId } from "./providers/index.js"; @@ -129,18 +130,6 @@ function resolveWhisperCppOutputPath(args: string[]): string | null { return `${outputBase}.txt`; } -async function fileExists(filePath?: string | null): Promise { - if (!filePath) { - return false; - } - try { - await fs.stat(filePath); - return true; - } catch { - return false; - } -} - async function resolveCliOutput(params: { command: string; args: string[]; diff --git a/src/media-understanding/runner.ts b/src/media-understanding/runner.ts index 8dd7e2f979a..2ca1ce654fe 100644 --- a/src/media-understanding/runner.ts +++ b/src/media-understanding/runner.ts @@ -32,6 +32,7 @@ import { DEFAULT_IMAGE_MODELS, } from "./defaults.js"; import { isMediaUnderstandingSkipError } from "./errors.js"; +import { fileExists } from "./fs.js"; import { extractGeminiResponse } from "./output-extract.js"; import { buildMediaUnderstandingRegistry, @@ -175,18 +176,6 @@ async function hasBinary(name: string): Promise { return Boolean(await findBinary(name)); } -async function fileExists(filePath?: string | null): Promise { - if (!filePath) { - return false; - } - try { - await fs.stat(filePath); - return true; - } catch { - return false; - } -} - async function probeGeminiCli(): Promise { const cached = geminiProbeCache.get("gemini"); if (cached) {