UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

61 lines (60 loc) • 2.74 kB
import { n as resolveFilesystemPath } from "./home-dir-EKmgmdPG.mjs"; import { o as getAsyncWorkSignal } from "./async-work-scope-BXagjUap.mjs"; import { i as formatEnvelopeForText, n as runCapabilityCommand } from "./providers-command-D9EdIVJQ.mjs"; import { t as isMissingMediaUnderstandingProvider } from "./media-understanding-result-B9ThU4q5.mjs"; //#region src/cli/capability-cli/media-understanding-command.ts function registerMediaUnderstandingCommand(e, t) { const n = t === "audio"; const r = e.command(n ? "transcribe" : "describe").description(n ? "Transcribe one audio file" : "Describe one video file").requiredOption("--file <path>", n ? "Audio file" : "Video file").option("--agent <id>", "Agent whose model and auth state should be used"); if (n) r.option("--language <code>", "Language hint").option("--prompt <text>", "Prompt hint"); r.option("--model <provider/model>", "Model override").option("--json", "Output JSON", false).action((e, r) => runCapabilityCommand(e.json, formatEnvelopeForText, async () => { const { requireProviderModelOverride: i, resolveLocalCapabilityAgent: a, resolveCapabilityAgentOption: o } = await import("./shared-CwcDzg1K.mjs"); const s = e.file; const c = o(r, e.agent); const { getModelsCommandSecretTargetIds: l } = await import("./command-secret-targets-CYdGJLhL.mjs"); const { transcribeAudioFile: u, describeVideoFile: d } = await import("./runtime-B1oFfDL6.mjs"); const { cfg: f, agentId: p, agentDir: m } = await a({ commandName: n ? "infer audio transcribe" : "infer video.describe", targetIds: l(), agent: c, ...n ? {} : { surface: "infer video describe" } }); const h = i(e.model); const g = resolveFilesystemPath(s); const _ = { filePath: g, cfg: f, agentId: p, agentDir: m, activeModel: h }; const v = getAsyncWorkSignal(); const y = n ? await u({ ..._, language: e.language, prompt: e.prompt }) : await d(_, v ? { signal: v, assertCurrent: () => v.throwIfAborted() } : void 0); if (!y.text) { if (n && isMissingMediaUnderstandingProvider(y)) throw new Error("No audio transcription provider is configured or ready. Configure an audio-capable tools.media.models entry, or pass --model <provider/model> after configuring that provider's auth/API key."); throw new Error(`No ${n ? "transcript" : "description"} returned for ${t}: ${g}`); } return { ok: true, capability: n ? "audio.transcribe" : "video.describe", transport: "local", provider: y.provider, model: y.model, attempts: [], outputs: [{ path: g, text: y.text, kind: n ? "audio.transcription" : "video.description" }] }; })); } //#endregion export { registerMediaUnderstandingCommand as t };