11import fs from "node:fs/promises" ;
22import path from "node:path" ;
3- import type { OpenClawConfig } from "../config/types.js" ;
43import { normalizeMediaProviderId } from "./provider-registry.js" ;
54import {
65 buildProviderRegistry ,
76 createMediaAttachmentCache ,
87 normalizeMediaAttachments ,
98 runCapability ,
10- type ActiveMediaModel ,
119} from "./runner.js" ;
10+ import type {
11+ DescribeImageFileParams ,
12+ DescribeImageFileWithModelParams ,
13+ DescribeVideoFileParams ,
14+ RunMediaUnderstandingFileParams ,
15+ RunMediaUnderstandingFileResult ,
16+ TranscribeAudioFileParams ,
17+ } from "./runtime-types.js" ;
18+ export type {
19+ DescribeImageFileParams ,
20+ DescribeImageFileWithModelParams ,
21+ DescribeVideoFileParams ,
22+ RunMediaUnderstandingFileParams ,
23+ RunMediaUnderstandingFileResult ,
24+ TranscribeAudioFileParams ,
25+ } from "./runtime-types.js" ;
1226
1327type MediaUnderstandingCapability = "image" | "audio" | "video" ;
1428type MediaUnderstandingOutput = Awaited < ReturnType < typeof runCapability > > [ "outputs" ] [ number ] ;
@@ -19,22 +33,6 @@ const KIND_BY_CAPABILITY: Record<MediaUnderstandingCapability, MediaUnderstandin
1933 video : "video.description" ,
2034} ;
2135
22- export type RunMediaUnderstandingFileParams = {
23- capability : MediaUnderstandingCapability ;
24- filePath : string ;
25- cfg : OpenClawConfig ;
26- agentDir ?: string ;
27- mime ?: string ;
28- activeModel ?: ActiveMediaModel ;
29- } ;
30-
31- export type RunMediaUnderstandingFileResult = {
32- text : string | undefined ;
33- provider ?: string ;
34- model ?: string ;
35- output ?: MediaUnderstandingOutput ;
36- } ;
37-
3836function buildFileContext ( params : { filePath : string ; mime ?: string } ) {
3937 return {
4038 MediaPath : params . filePath ,
@@ -92,27 +90,13 @@ export async function runMediaUnderstandingFile(
9290 }
9391}
9492
95- export async function describeImageFile ( params : {
96- filePath : string ;
97- cfg : OpenClawConfig ;
98- agentDir ?: string ;
99- mime ?: string ;
100- activeModel ?: ActiveMediaModel ;
101- } ) : Promise < RunMediaUnderstandingFileResult > {
93+ export async function describeImageFile (
94+ params : DescribeImageFileParams ,
95+ ) : Promise < RunMediaUnderstandingFileResult > {
10296 return await runMediaUnderstandingFile ( { ...params , capability : "image" } ) ;
10397}
10498
105- export async function describeImageFileWithModel ( params : {
106- filePath : string ;
107- cfg : OpenClawConfig ;
108- agentDir ?: string ;
109- mime ?: string ;
110- provider : string ;
111- model : string ;
112- prompt : string ;
113- maxTokens ?: number ;
114- timeoutMs ?: number ;
115- } ) {
99+ export async function describeImageFileWithModel ( params : DescribeImageFileWithModelParams ) {
116100 const timeoutMs = params . timeoutMs ?? 30_000 ;
117101 const providerRegistry = buildProviderRegistry ( undefined , params . cfg ) ;
118102 const provider = providerRegistry . get ( normalizeMediaProviderId ( params . provider ) ) ;
@@ -134,25 +118,15 @@ export async function describeImageFileWithModel(params: {
134118 } ) ;
135119}
136120
137- export async function describeVideoFile ( params : {
138- filePath : string ;
139- cfg : OpenClawConfig ;
140- agentDir ?: string ;
141- mime ?: string ;
142- activeModel ?: ActiveMediaModel ;
143- } ) : Promise < RunMediaUnderstandingFileResult > {
121+ export async function describeVideoFile (
122+ params : DescribeVideoFileParams ,
123+ ) : Promise < RunMediaUnderstandingFileResult > {
144124 return await runMediaUnderstandingFile ( { ...params , capability : "video" } ) ;
145125}
146126
147- export async function transcribeAudioFile ( params : {
148- filePath : string ;
149- cfg : OpenClawConfig ;
150- agentDir ?: string ;
151- mime ?: string ;
152- activeModel ?: ActiveMediaModel ;
153- language ?: string ;
154- prompt ?: string ;
155- } ) : Promise < { text : string | undefined } > {
127+ export async function transcribeAudioFile (
128+ params : TranscribeAudioFileParams ,
129+ ) : Promise < { text : string | undefined } > {
156130 const cfg =
157131 params . language || params . prompt
158132 ? {
0 commit comments