11// Public video-generation helpers and types for provider plugins.
2- //
3- // Keep these public type declarations local to the plugin-sdk entrypoint so the
4- // emitted declaration surface stays stable for package-boundary consumers.
52
6- import type { AuthProfileStore } from "../agents/auth-profiles/types.js" ;
7- import type { OpenClawConfig } from "../config/types.openclaw.js" ;
83import {
94 DASHSCOPE_WAN_VIDEO_CATALOG_BY_MODEL ,
105 DASHSCOPE_WAN_VIDEO_CAPABILITIES ,
@@ -13,187 +8,31 @@ import {
138 DEFAULT_VIDEO_GENERATION_TIMEOUT_MS ,
149 runDashscopeVideoGenerationTask ,
1510} from "../video-generation/dashscope-compatible.js" ;
11+ import type { VideoGenerationProvider , VideoGenerationResult } from "../video-generation/types.js" ;
1612import { resolveApiKeyForProvider } from "./provider-auth-runtime.js" ;
1713import { isProviderApiKeyConfigured } from "./provider-auth.js" ;
1814import {
1915 resolveProviderHttpRequestConfig ,
2016 sanitizeConfiguredModelProviderRequest ,
2117} from "./provider-http.js" ;
2218
23- /** Video asset returned by a provider after generation or transformation. */
24- export type GeneratedVideoAsset = {
25- /** Non-empty raw video bytes; may accompany url as a delivery fallback. */
26- buffer ?: Buffer ;
27- /** Provider-hosted URL returned instead of bytes or alongside them as a delivery fallback.
28- * When buffer is absent, callers can forward or download without materializing the video. */
29- url ?: string ;
30- mimeType : string ;
31- fileName ?: string ;
32- metadata ?: Record < string , unknown > ;
33- } ;
34-
35- /** Resolution label accepted by video generation providers. */
36- export type VideoGenerationResolution =
37- | "360P"
38- | "480P"
39- | "540P"
40- | "720P"
41- | "768P"
42- | "1080P"
43- | ( string & { } ) ;
44-
45- /**
46- * Canonical semantic role hints for reference assets (first/last frame,
47- * reference image/video/audio). Providers may accept additional role strings;
48- * the asset.role type accepts both canonical values and arbitrary strings.
49- */
50- export type VideoGenerationAssetRole =
51- | "first_frame"
52- | "last_frame"
53- | "reference_image"
54- | "reference_video"
55- | "reference_audio" ;
56-
57- /** Source media asset supplied to image/video/audio-to-video providers. */
58- export type VideoGenerationSourceAsset = {
59- url ?: string ;
60- buffer ?: Buffer ;
61- mimeType ?: string ;
62- fileName ?: string ;
63- /**
64- * Optional semantic role hint forwarded to the provider. Canonical values
65- * come from `VideoGenerationAssetRole`; plain strings are accepted for
66- * provider-specific extensions.
67- */
68- role ?: VideoGenerationAssetRole | ( string & { } ) ;
69- metadata ?: Record < string , unknown > ;
70- } ;
71-
72- /** Context passed when checking whether a video provider is configured. */
73- export type VideoGenerationProviderConfiguredContext = {
74- cfg ?: OpenClawConfig ;
75- agentDir ?: string ;
76- } ;
77-
78- /** Context passed when resolving model-specific video generation capabilities. */
79- export type VideoGenerationModelCapabilitiesContext = {
80- provider : string ;
81- model : string ;
82- cfg : OpenClawConfig ;
83- agentDir ?: string ;
84- authStore ?: AuthProfileStore ;
85- timeoutMs ?: number ;
86- } ;
87-
88- /** Normalized request object passed to a selected video generation provider. */
89- export type VideoGenerationRequest = {
90- provider : string ;
91- model : string ;
92- prompt : string ;
93- cfg : OpenClawConfig ;
94- agentDir ?: string ;
95- authStore ?: AuthProfileStore ;
96- timeoutMs ?: number ;
97- size ?: string ;
98- aspectRatio ?: string ;
99- resolution ?: VideoGenerationResolution ;
100- durationSeconds ?: number ;
101- audio ?: boolean ;
102- watermark ?: boolean ;
103- inputImages ?: VideoGenerationSourceAsset [ ] ;
104- inputVideos ?: VideoGenerationSourceAsset [ ] ;
105- /** Reference audio assets (e.g. background music) forwarded to the provider. */
106- inputAudios ?: VideoGenerationSourceAsset [ ] ;
107- /** Arbitrary provider-specific parameters forwarded as-is (e.g. seed, draft, camerafixed). */
108- providerOptions ?: Record < string , unknown > ;
109- } ;
110-
111- /** Provider video generation response returned to the runtime. */
112- export type VideoGenerationResult = {
113- videos : GeneratedVideoAsset [ ] ;
114- model ?: string ;
115- metadata ?: Record < string , unknown > ;
116- } ;
117-
118- /** Supported high-level video generation operation modes. */
119- export type VideoGenerationMode = "generate" | "imageToVideo" | "videoToVideo" ;
120-
121- /**
122- * Primitive type tag for a declared `providerOptions` key. Keep narrow —
123- * plugins that need richer shapes should leave them out of the typed contract
124- * and interpret the forwarded opaque value inside their own provider code.
125- */
126- export type VideoGenerationProviderOptionType = "number" | "boolean" | "string" ;
127-
128- /** Capability limits and supported options for one video generation mode. */
129- export type VideoGenerationModeCapabilities = {
130- maxVideos ?: number ;
131- maxInputImages ?: number ;
132- maxInputImagesByModel ?: Readonly < Record < string , number > > ;
133- maxInputVideos ?: number ;
134- maxInputVideosByModel ?: Readonly < Record < string , number > > ;
135- /** Max number of reference audio assets the provider accepts (e.g. background music, voice reference). */
136- maxInputAudios ?: number ;
137- maxInputAudiosByModel ?: Readonly < Record < string , number > > ;
138- maxDurationSeconds ?: number ;
139- supportedDurationSeconds ?: readonly number [ ] ;
140- supportedDurationSecondsByModel ?: Readonly < Record < string , readonly number [ ] > > ;
141- sizes ?: readonly string [ ] ;
142- aspectRatios ?: readonly string [ ] ;
143- resolutions ?: readonly VideoGenerationResolution [ ] ;
144- supportsSize ?: boolean ;
145- supportsAspectRatio ?: boolean ;
146- supportsResolution ?: boolean ;
147- supportsAudio ?: boolean ;
148- supportsWatermark ?: boolean ;
149- /**
150- * Declared typed schema for `VideoGenerationRequest.providerOptions`. Keys
151- * listed here are accepted and validated against the declared primitive
152- * type before forwarding; unknown keys or type mismatches skip the
153- * candidate provider at runtime so mis-typed or provider-specific options
154- * never silently reach the wrong provider.
155- */
156- providerOptions ?: Readonly < Record < string , VideoGenerationProviderOptionType > > ;
157- } ;
158-
159- /** Capability block for transform modes that may be independently enabled. */
160- export type VideoGenerationTransformCapabilities = VideoGenerationModeCapabilities & {
161- enabled : boolean ;
162- } ;
163-
164- /** Full provider capability map including base and transform mode overrides. */
165- export type VideoGenerationProviderCapabilities = VideoGenerationModeCapabilities & {
166- generate ?: VideoGenerationModeCapabilities ;
167- imageToVideo ?: VideoGenerationTransformCapabilities ;
168- videoToVideo ?: VideoGenerationTransformCapabilities ;
169- } ;
170-
171- /** Static catalog metadata that overrides provider defaults for one video model. */
172- export type VideoGenerationCatalogModelEntry = {
173- capabilities ?: VideoGenerationProviderCapabilities ;
174- modes ?: readonly VideoGenerationMode [ ] ;
175- } ;
176-
177- /** Video generation provider contract implemented by provider plugins. */
178- export type VideoGenerationProvider = {
179- id : string ;
180- aliases ?: string [ ] ;
181- label ?: string ;
182- defaultModel ?: string ;
183- /** Default provider operation timeout in milliseconds when caller/config omit timeoutMs. */
184- defaultTimeoutMs ?: number ;
185- models ?: string [ ] ;
186- capabilities : VideoGenerationProviderCapabilities ;
187- catalogByModel ?: Readonly < Record < string , VideoGenerationCatalogModelEntry > > ;
188- isConfigured ?: ( ctx : VideoGenerationProviderConfiguredContext ) => boolean ;
189- resolveModelCapabilities ?: (
190- ctx : VideoGenerationModelCapabilitiesContext ,
191- ) =>
192- | VideoGenerationProviderCapabilities
193- | undefined
194- | Promise < VideoGenerationProviderCapabilities | undefined > ;
195- generateVideo : ( req : VideoGenerationRequest ) => Promise < VideoGenerationResult > ;
196- } ;
19+ export type {
20+ GeneratedVideoAsset ,
21+ VideoGenerationResolution ,
22+ VideoGenerationAssetRole ,
23+ VideoGenerationSourceAsset ,
24+ VideoGenerationProviderConfiguredContext ,
25+ VideoGenerationModelCapabilitiesContext ,
26+ VideoGenerationRequest ,
27+ VideoGenerationResult ,
28+ VideoGenerationMode ,
29+ VideoGenerationProviderOptionType ,
30+ VideoGenerationModeCapabilities ,
31+ VideoGenerationTransformCapabilities ,
32+ VideoGenerationProviderCapabilities ,
33+ VideoGenerationCatalogModelEntry ,
34+ VideoGenerationProvider ,
35+ } from "../video-generation/types.js" ;
19736
19837export type DashscopeVideoGenerationProviderOptions = {
19938 providerId : string ;
0 commit comments